M1: contracts and vectors (SPEC v0.1, schema 1)
contracts/openapi.yaml (OpenAPI 3.1, E-1..E-33, error shape and the exhaustive error code enum, device bearer scheme), contracts/schema/ server-v1.sql (SPEC §14.1 verbatim), seven test-vector files per §14.5.5, 80 examples (every JSON body of §14.3.4, every error code, sync pull/push, every FCM push type), and tools/contracts-check.py (stdlib-only reference of §9.1, §9.3, §9.4 and §14.5.4 plus shape checks; the M1 gate). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"format": 1,
|
||||
"function": "over_settled_accounts",
|
||||
"cases": [
|
||||
{
|
||||
"name": "none: every allocation within the debt (equal to the debt is not over)",
|
||||
"input": {
|
||||
"allocations": [ { "account_id": "X", "amount_ore": 30000 }, { "account_id": "Y", "amount_ore": 5000 } ],
|
||||
"accounts": [
|
||||
{ "account_id": "X", "created_at": "2025-01-01T00:00:00.000Z", "archived": false, "payer_net_ore": -30000 },
|
||||
{ "account_id": "Y", "created_at": "2025-02-01T00:00:00.000Z", "archived": false, "payer_net_ore": -20000 }
|
||||
]
|
||||
},
|
||||
"expected": { "ok": [] }
|
||||
},
|
||||
{
|
||||
"name": "one: Y gets one öre more than owed",
|
||||
"input": {
|
||||
"allocations": [ { "account_id": "X", "amount_ore": 30000 }, { "account_id": "Y", "amount_ore": 20001 } ],
|
||||
"accounts": [
|
||||
{ "account_id": "X", "created_at": "2025-01-01T00:00:00.000Z", "archived": false, "payer_net_ore": -30000 },
|
||||
{ "account_id": "Y", "created_at": "2025-02-01T00:00:00.000Z", "archived": false, "payer_net_ore": -20000 }
|
||||
]
|
||||
},
|
||||
"expected": { "ok": ["Y"] }
|
||||
},
|
||||
{
|
||||
"name": "an account where the payer is owed: any allocation is over (max(0, -net) = 0)",
|
||||
"input": {
|
||||
"allocations": [ { "account_id": "Z", "amount_ore": 1 } ],
|
||||
"accounts": [ { "account_id": "Z", "created_at": "2024-12-01T00:00:00.000Z", "archived": false, "payer_net_ore": 10000 } ]
|
||||
},
|
||||
"expected": { "ok": ["Z"] }
|
||||
},
|
||||
{
|
||||
"name": "an unknown account counts as net 0",
|
||||
"input": {
|
||||
"allocations": [ { "account_id": "X", "amount_ore": 100 }, { "account_id": "U", "amount_ore": 100 } ],
|
||||
"accounts": [ { "account_id": "X", "created_at": "2025-01-01T00:00:00.000Z", "archived": false, "payer_net_ore": -30000 } ]
|
||||
},
|
||||
"expected": { "ok": ["U"] }
|
||||
},
|
||||
{
|
||||
"name": "several: reported in allocation order, not account order",
|
||||
"input": {
|
||||
"allocations": [ { "account_id": "Y", "amount_ore": 25000 }, { "account_id": "X", "amount_ore": 100 }, { "account_id": "Z", "amount_ore": 1 } ],
|
||||
"accounts": [
|
||||
{ "account_id": "X", "created_at": "2025-01-01T00:00:00.000Z", "archived": false, "payer_net_ore": -30000 },
|
||||
{ "account_id": "Y", "created_at": "2025-02-01T00:00:00.000Z", "archived": false, "payer_net_ore": -20000 },
|
||||
{ "account_id": "Z", "created_at": "2024-12-01T00:00:00.000Z", "archived": true, "payer_net_ore": 0 }
|
||||
]
|
||||
},
|
||||
"expected": { "ok": ["Y", "Z"] }
|
||||
},
|
||||
{
|
||||
"name": "no allocations",
|
||||
"input": { "allocations": [], "accounts": [ { "account_id": "X", "created_at": "2025-01-01T00:00:00.000Z", "archived": false, "payer_net_ore": -30000 } ] },
|
||||
"expected": { "ok": [] }
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user