oliver-zehentleitner / maity
hub: contract test that GET answers carry the top-level fields docs/api.md names
tsk-x4c4v639trrv Done Maity Coder Claude 004
Adopted by the maintainer from the jour fixe of 2026-11-08 (round jfx-x83wyff3vxm0, req-7y4mfywt9cmn). One contract test per GET route comparing the answer's top-level keys with the shape in docs/api.md, starting with GET …/roles (docs/api.md promises builtin, the hub returns only custom; that gap is already a P3 on the hub roll-up). Content is not modelled.
Notes
Maity Coder Claude 004 · Nov 8, 2026, 11:50 UTC
Plan (maity-coder-claude-004#eyq5). A hub test PR from main 8062dfb7, no product code. Source: jour fixe 2026-11-08 (req-7y4mfywt9cmn).
Boundary:
- Guarantees: for every GET route in the shape list, a real answer from the hub (test client, a fresh project) carries each top-level key docs/api.md names for it. Every GET route of the API is either in that list or in a pending list with a reason, so a new GET route without either fails the test. Each listed key is anchored to a quote that must still be in docs/api.md, so the list cannot drift from the contract silently.
- Does not guarantee: content (types, nesting, values, item shapes), keys the hub sends beyond the contract (extra keys pass), error answers, non-GET routes, and the routes still in the pending list.
- P3: which routes come next, wording of reasons, the order of the lists.
Finding the shape per route: listed by hand, anchored to the text. docs/api.md gives shapes in three forms:
- JSON examples in fenced blocks;
- inline braces in prose (
{"builtin": […], "custom": […]}); - field tables.
A parser would have to guess which of these is the answer of which route. So the test holds a table:
SHAPES = {("GET", "/projects/{}/{}/roles"): ("{\"builtin\": [{name, description, guide, scopes}], \"custom\": […]}", {"builtin", "custom"}), …}The quote is a literal string. The test checks that it occurs in docs/api.md and that each key is named in it. If the contract changes those words, the entry fails until it is updated, as
citesdo in reviews.Every GET route is accounted for. As in test_contract_routes.py, the test reads the GET routes from the app's OpenAPI (
/api/v1/…, path parameters plain). Each must be inSHAPESorPENDING(one line per route, its reason on the same line, e.g.# not yet: tsk-x4c4v639trrv). An entry that is no longer a route fails, and so does an entry that is in both lists. A new GET route in either list fails with its name.First PR, small, with routes a fresh project answers without special setup:
- GET …/roles;
- GET /me;
- GET /projects/{owner}/{slug};
- GET …/members;
- GET …/tasks;
- GET …/requests.
All other GET routes (about 124) go into
PENDING. Follow-up PRs move routes fromPENDINGtoSHAPESin batches by section.The roles `builtin` gap: a known failure, not fixed here. The contract promises
builtinwithdescription,guideandscopesper built-in role. The hub answerscustomonly. Fixing it is product work: description texts, guide resolution per §6.28, scopes. The test lists it inKNOWN_GAPS = {("GET", "/projects/{}/{}/roles"): {"builtin"}} # hub roll-up P3, its own card. The test then fails if the gap is closed and the entry is still there, so the entry is removed with the fix. I'd open (or ask you to open) a hub card for the fix.Not modelled: content. Only
set(contract keys) - set(answer keys)is checked, per route.Files: hub/tests/test_contract_shapes.py (new); hub/context/testing.md, one entry (why hand-listed and anchored rather than parsed; why extra keys pass); a changelog fragment is not needed (tests only), unless you want one.
Checks before review: the test is red on main without
KNOWN_GAPS(the roles gap). A fake new GET route, added in a temporary test app, fails. Plus black, ruff, mypy, test_contract_*, test_paths and test_public_read.An agent · Nov 19, 2026, 07:53 UTC
From tsk-nkwg0gztpmqg (#2006):
GET /invitations/{token}now answersrestricted_texts(§3.4, from #1538)./invitations/{}is still inPENDINGinhub/tests/test_contract_shapes.py, so no contract-shape test checks this answer's keys yet. Moving it in needs a token fixture; lotse put it with this card's batches.