63 lines
4.5 KiB
Markdown
63 lines
4.5 KiB
Markdown
# Contract: V1-2.3 worker verification (M6)
|
|
|
|
Owner brief « Validation définitive V1-2.2 », 2026-11-01 (V1-2.2 VERIFIED at `c73415a`, BDR-092):
|
|
start V1-2.3 along the validated plan, V1-2 contract §16.4 (objective, prerequisites, tests,
|
|
acceptance), §6.4 (server verdict), §6.5 (failures), §12.3 (M6). Branch
|
|
`feature/v1-2-anatomical-sheets`. Sandbox stack only; DEV and production untouched; no merge;
|
|
no V1-2.4; STOP at the owner checkpoint (server workflow V1-2.1 to V1-2.3).
|
|
|
|
## Criteria
|
|
|
|
- W1 M6 `sheet_verification_jobs`, forward-only, service role only (revoked from `public`,
|
|
`anon`, `authenticated`), `security definer`, `search_path = ''`:
|
|
`claim_sheet_verifications(limit)` (clamped, `for update skip locked`, rounds `verifying` with no
|
|
live lease, token + `locked_at` set, `attempts` incremented, an expired lease counted, the attempt
|
|
limit closing the round `verification_failed` / `unavailable`);
|
|
`get_sheet_verification_input(review_id, lease_token)` (the frozen document and the base as text,
|
|
the referenced drawing rows registered for the sheet: asset id, sha256, byte size, bucket, object
|
|
key; nothing for a stale token or status);
|
|
`complete_sheet_verification(review_id, lease_token, verdict)` (accepted only while `verifying`
|
|
with the live token; binding = the round's sheet, version, revision, review; a passed verdict's
|
|
group keys = `general`, the document's view and zone ids and the base's removed ones, its drawings
|
|
= the document's asset ids with the rows' sha256; a failed verdict accepted without groups or
|
|
drawings, its code from the closed list; else `stale` or `malformed`, nothing written; moves to
|
|
`open` or `verification_failed` / `failed`; audited);
|
|
`fail_sheet_verification(review_id, lease_token, code)` (closed worker codes; claimable again
|
|
below the limit, `verification_failed` / `unavailable` at it; audited).
|
|
pgTAP allowed and denied cases; `database.types.ts` regenerated; publication still refused
|
|
without an approved round whose passed verdict is current.
|
|
- W2 Child `verify`: the same binary, empty environment, rlimits and seccomp installed before
|
|
reading stdin; reads one framed input (binding, rows, document, base, drawing bytes) under the
|
|
per-command input cap; runs `faunosteo_core` `compute_verdict`; writes the verdict JSON under the
|
|
output cap. The parent never parses the document or the drawings. Seccomp allowlist derived again
|
|
for this path (Docker `test` stage).
|
|
- W3 Spawner per command: input cap, output cap, deadline and memory per command (`decode`
|
|
unchanged); `verify` sized on the at-caps fixture (about 13 MiB input).
|
|
- W4 Mode `run --jobs sheet-verify`: claim, input, Storage downloads (missing object = drawing
|
|
missing for the core, never a worker failure), child, completion; transient, timeout, resource and
|
|
crash outcomes reported by `fail_sheet_verification` with a closed code; a broken sandbox stops
|
|
the worker. Avatar and purge processing unchanged in the default mode; the verification mode runs
|
|
no sweep. RPC body cap of this mode raised to the verdict size.
|
|
- W5 Compose service of its own under the `worker` profile (read-only, `cap_drop: ALL`, same
|
|
hardening as `worker`); sandbox start of the verification worker; never started on DEV.
|
|
- W6 Tests: `pnpm worker:test` (sandbox, seccomp derivation), unit and fake-backend job tests for
|
|
each §6.5 row, hostile corpus through the child, e2e on the sandbox stack (clean sheet passes,
|
|
each failure and its exit, stale or malformed completion writes nothing, avatars and purges
|
|
unaffected, publication refused without a current passed verdict, the sandbox working copy
|
|
verified in place with its shared drawing, verification time at the caps within budget), upgrade
|
|
rehearsal from the DEV state (Git fixture of the DEV drawing, §12.3), `pnpm e2e:avatar` unchanged.
|
|
- W7 Docs describe only what is implemented: V1-2 contract §6.4, §6.5, §12.3, §16.4; STORAGE.md
|
|
worker section; RUST.md; SUPABASE.md; DEPLOY.md / compose notes; CLAUDE.md.
|
|
- W8 Gates: `pnpm rust:check`, `pnpm worker:test`, `pnpm worker:image`, sandbox `test-db` and
|
|
`types --check`, `pnpm check:all` on the final HEAD, `pnpm e2e:shell` on the sandbox; fresh
|
|
verifier and security reviews on the final HEAD.
|
|
|
|
## Proposals for the owner (checkpoint)
|
|
|
|
Closed worker failure codes, attempt limit (five), lease duration, the service name: chosen by the
|
|
implementer, listed at the checkpoint for confirmation.
|
|
|
|
## Out of scope
|
|
|
|
DEV and production (every §16.11 operation), screens, V1-2.4 onwards, merge, deploy.
|