Reviewer: Claude Fable 5.1 (claude-fable-5-1) — whole-code review @ 2f1cac8
Branch operator-http, 7 commits on main 69ea999, hub CI green at the tip. Read: the author's description above and its 9 deviations; implementation/team-provisioning-amendment.md on main (the design I approved in #92 round 3) with #92's round-2 blockers and round-3 notes; team-provisioning-app.md §6–§7 (Alta's calls); team-members.md §2; AGENTS.md in full. Reviewed the whole diff (38 files) against the design and the existing code: internal/operator/{plan,http_verbs,credential,directory,protocol,engine,inspect,verification}.go, both http_migrations, internal/home/{operator_http,operator_confirm,operator_material,consumer_registry,security,exchange,signout,dashboard_config,runtime,directory,app,signin_return,schema_inventory}.go, both templates, every new test, and the handoff pin (69ea999 records its own review in #93, so the round-3 gate 1 is met). make test run locally: green, except the -race step's Linux-only internal/provisioner setup failure, which CI covers. Fifteen mutations run by hand (list at the end).
Verdict: CHANGES REQUIRED (narrow)
The shape is the approved design, built faithfully: plans are verified and only closed fields reach disk (owner blind-indexed, name sealed, no plan bytes — gate 2 now decodes the envelope and scans payload, signature, raw and base64url, file + WAL + SHM); one pending and one open per role is UNIQUE(state) plus the store's checks; expiry sweeps run before each operation in their own statement, at the end of each plan and window, and at boot; the kind→verb table is windowAdmits; every directory mutation but initialize goes through fence on the window's label and operator_http_teams; register-consumer is driven only by the directory's signed record with issuer and directory fixed to the pins, the union collision check and the 4,096 cap before the INSERT; the registry is one immutable map behind an atomic.Pointer, swapped after each committed write, and every reader uses it (/authorize, handleAssertion, sign-out, dashboard_config); form-action is per response on the two pages whose form leaves the origin; a collision refuses boot; the transport sits outside CSRF and before sessions on both routers and refuses cookies, Origin, Sec-Fetch-*, query, wrong media, bad prefilter (fixed 401 body) and size, in that order; both confirm pages do what §4 steps 2–3 say, including the random-nonce fresh intent cleared on use, the reserved consumer refused in handleAssertion, recovery and Keymail-without-gesture refused, the owner retyped and compared as a blind index inside the write, and a credential page that renders only compiled names, prefixes and fixed text (gate 5 test with label, name, address, typed address and a consumer hostname as canaries). Logs are a fixed vocabulary with an 8-character operation prefix (gate 9 test over the whole sequence, hostile refusals included). Gate 1 runs over both databases. Gate 10 covers every new route.
Three things stop a merge. Two are small code-plus-test changes; one is the design document catching up with what was built.
BLOCKERS
1. A directory-signed record can commit a consumer row the registry reload refuses — and the next boot refuses with it, permanently. internal/operator/http_verbs.go:306-313 admits any b.Audience that passes operator.Origin and collides with nothing. consumerRegistry.load (internal/home/consumer_registry.go:76) then runs assertion.NewVerifier(credential, origin, keys), which refuses issuer == audience. I confirmed it with a throwaway test on this branch: a record signed by the directory's provisioning key with Audience = https://id.oficina.works is registered (err=nil, one row); a credential role booted with such a row fails NewRuntime with invalid assertion configuration (runtime.go:225). After the write, every exact replay answers 503 (operator_http.go:403-405), and consumers_no_delete makes the row unremovable without hand surgery on the live database. Only the directory's provisioning key can produce the record, so this is a directory compromise or a directory bug — but §8 concedes a directory compromise "could sign provisioning records", not a standing refusal to boot the credential origin, which AGENTS.md calls a suite-wide outage. Fix: make the verb's admission the reload's admission, so no row can be committed that load would refuse. NewCredentialHTTP takes an admit func(id, origin string) bool; newOperatorEndpoint (operator_http.go:256) wires it to consumerName(id) && assertion.NewVerifier(cfg.origins.Credential, origin, cfg.keys) == nil; register calls it before the collision checks and the INSERT. (At minimum refuse b.Audience == h.c.engine.verifier.pins.Origin || b.Audience == h.c.directory in the verb, but the shared predicate is what keeps the two from drifting again.) Tests: in http_verbs_test.go, a record with audience = the credential origin is ErrRefused and the table stays empty; in internal/home, an invariant test that registers through the HTTP fixture and then calls registry.load on a fresh registry — it must succeed for every row the verb admitted.
2. credential.retire-consumer's app scope has no test. internal/operator/http_verbs.go:350 checks !contains(w.Apps, app); dropping it leaves make test green (mutant survived). §10.5 names "app outside apps" and §10.8 says removing the window check fails a named test; this verb is the one place that is not true. Fix: in TestOperatorHTTPRegisterConsumerOnlyFromTheDirectoryRecord (or a new test), open a retire-apps window for sheets, assert retiring alpha-docs is ErrRefused with the row still active, then the docs window retires it as today.
3. The amendment now says things the branch does not do, and nothing on the branch records the difference. implementation/team-provisioning-amendment.md §5 "the native Linux command can act only with Alta's pins and key" is false after deviation 1 (the command refuses such a database outright); §3 lists credential.inspect as one of the actions, not as required (deviation 8); §7 "New tables" omits consumers.app (deviation 2); §10.4 "differing plan_ids across roles refused at confirm" is unbuildable (deviation 3); §5 puts baseline_attestation "signed in the plan" (deviation 4, it is in the operation input); §4 says nothing about confirm during an open window (deviation 6) or where the role's own keys come from (deviation 7). AGENTS.md's rule for binding documents is that they are fixed in the same commit as the code that falsifies them. Fix: a "Round 4 (implementation, discussion 94)" entry in §13 — or a short §14 — recording each deviation and this review's ruling on it, plus the §5 sentence rewritten to "restore through the native command needs a reviewed profile regeneration first; until then it refuses a database that has served over HTTP". One commit on this branch so the squash carries it. No re-review of the prose needed.
Deviations — rulings
- Separate migration sets,
ServingSchemavsSchema. Accepted, with blocker 3 recording it. The frozen compatibility, admission and legacy-diagnostic profiles are reviewed artefacts and the new assertion inoperator_schema_linux_test.gokeeps the HTTP tables out of them; restore stays gated (§2 item 7) and platform 117 does not exist, so the native command is not a live path any serving database needs today. The legacy diagnostic readingmismatchon every directory boot is a standing false alarm — see the non-blocking note; it is not a reason to move the tables into the frozen set. consumers.app. Accepted: a compiled slug under aCHECK, needed for the retire scope. Add it to §7.- Cross-role
plan_idcheck at confirm. Accepted. The §10.4 item over-specified what round 2 asked for ("sameplan_idon both roles, shown on both pages so Paul can see he is confirming one plan twice"); each POST carrying the id its GET showed, refusing any other, is the buildable half, and it is tested. baseline_attestationininitialize's input. Accepted: it is still under Alta's signature, verified by the same key, inside the same window, andinitializekeeps its four-empty-tables precondition. Fix the §5 wording.- Stale sessions redirect rather than render a refusal. Accepted: a redirect that forces a real gesture is a refusal that recovers, no window opens on any of the four cases, and
TestOperatorCredentialConfirmRefusesKeymailWithoutGestureAndRecoverycovers both the GET and the POST. - An open window blocks a second confirm with 409. Accepted; one open per role is
UNIQUE(state), and 409 until the window expires is the right answer — the design's silence was an omission. - Keys from
HOME_OPERATOR_MATERIAL. Accepted: the same reviewed material the native command reads, withdistinctOperatorKeysextended to Alta's key and the directory's pins. <role>.inspectrequired. Accepted; Alta resynchronises from it, and refusing a configuration without it is correct.- CSP guard exemption for
security.go. Accepted: one file, andTestConsumerPolicyOnlyWidensFormActionholdssetConsumerPolicyto adding exactly one registered origin to form-action and nothing to an unregistered one.
Non-blocking
- Inside-the-write re-checks are dead by construction.
operator_confirm.go:116-119and:231-241re-check subject and freshness inside theOpenadmit closure, but the closure captures the samesthe outer*OperatorSessioncheck already passed in the same request, so both mutants dropping them survive. Not a hole: plan expiry is genuinely re-read inside the transaction (scanPlan,plan.go:374). Either say so in the comment or make the closure the POST's only check so the mutation is killed. exchange.go:81: the explicitintent.Consumer == operatorConfirmConsumerrefusal is belt-and-braces (the union lookup already refuses it); that mutant survives, which is fine.operator_http.go:403: the post-commit reload runs onr.Context(); a client disconnect after the commit leaves the union stale until Alta replays. Usecontext.Background()—loadalready bounds itself to 5 s.operator_http.go:267: boot sweeps but schedules nosweepAtfor rows that survive a restart, so a pending plan submitted just before a deploy lingers until the next access. After the bootSweep, schedule for any remaining pending/open row.- Design note for a later amendment, not a deviation:
credential.retire-consumeris app-scoped, not team-scoped (the credential role sees no labels), so a confirmedretire-appswindow admits retiring any table consumer of those apps for any team, and the credential page cannot show Paul which. The mirror ofregister's record-derivation would be a directorydisablereceipt. The approved design has this shape; recording it here so it is weighed before a second team exists. noscript_test.go's sweep walks a fixture withoutHOME_OPERATOR_HTTP, so the two confirm pages are outside the scriptless sweep. Both templates carry no script, but the gate does not look. Add a pass over the operator fixture.- Legacy diagnostic:
legacy-directory-v1.jsonis an exact object set, so every directory boot will now logmismatch. Either extend the profile under its own review or have the diagnostic ignore theoficina_directory_operator_httpset; until then a true mismatch hides behind a false one. handleOperator: a body that failsVerifyis routed to inspect and logged as<role>.inspect refused; closed vocabulary, fine, but the log cannot tell a bad operation from a bad inspect. Optional: log verb-on that path.credentialOperatorSession's stale-GET intent overwrites any in-flight handoff intent cookie; harmless (that handoff fails closed and restarts), noting it only.
Tests, as checked
§10: 1 mounting (TestOperatorEndpointIsOffWithoutConfiguration; host-spoof and other-role in TestOperatorTransportRefusesBrowsersAndChecksPrefilterFirst); 2 transport (same test, 13 cases plus the 64 KiB body); 3 signature (TestOperatorPlanVerifyRefusesWrongKeyContextPinsAndClock, engine tests, TestOperatorHTTPReplayAfterWindowExpiryReturnsStoredResult); 4 ceremony (the seven ceremony tests, every listed item present); 5 scope (TestOperatorHTTPProvenanceFenceAndScope, …DisableConsumerUnderRetireApps, …OwnerSeedIsExistingOnlyAndTheTypedOwner); 6 blocker 2 (TestOperatorHTTPRegisterConsumerOnlyFromTheDirectoryRecord, eight refusals, plus the pre-existing-team fence in the end-to-end test); 7 registry (TestConsumerRegistryUnionPastSixteen, …CollisionRefusesBoot, …ConsumerTableCap, the two CSP tests, the race loop); 9 gates (whole-sequence gate 1 + 9, gate 2 static reach + plan-submit path, gate 5, gate 10, additive migrations with the old schema re-applied); 10 canary not run, correctly, since no deploy was in scope.
Mutations I ran (each restored; working tree clean): owner-seed typed-owner compare, fence in provision, issuer pin in register, env-origin collision, directory windowAdmits, credential windowAdmits, seed-team name byte compare, recovery refusal, typed-owner compare always true, query refusal, intent not cleared on confirm, reload after write dropped — all killed by a named test. Survived: retire app scope (blocker 2); inside-the-write session re-checks on both pages; the belt-and-braces reserved-consumer check (acceptable).
What this approves, once the blockers land
The operator HTTP transport, the confirm ceremony on both roles, the consumer registry with per-response form-action, and the four new verbs, as code — subject to CI green on the fixed tip and the §10.10 canary on deployed previews before anything is promoted. Reply here with the fixing commit; I expect to approve on the diff without another whole-code pass. Still gated elsewhere, unchanged: CARLOS team-scoped-credentials (platform 449) before Alta reaches production, Alta itself, the Team page, and Paul's §12 pre-flight confirmation before the first production initialize.