From 7c4bf124f419258214d39a7a982b0fe4389fd7ea Mon Sep 17 00:00:00 2001 From: bchanot Date: Wed, 28 Oct 2026 20:16:34 +0100 Subject: [PATCH] chore(memory): V1-2.1 review findings fixed, evidence, TODO, journal --- .../2026-10-28-v1-2-1-corrections-evidence.md | 60 ++++++++++++------- .claude/memory/journal.md | 1 + .claude/tasks/TODO.md | 3 +- 3 files changed, 41 insertions(+), 23 deletions(-) diff --git a/.claude/audits/2026-10-28-v1-2-1-corrections-evidence.md b/.claude/audits/2026-10-28-v1-2-1-corrections-evidence.md index 52cb4a0e..5ecbc33b 100644 --- a/.claude/audits/2026-10-28-v1-2-1-corrections-evidence.md +++ b/.claude/audits/2026-10-28-v1-2-1-corrections-evidence.md @@ -49,7 +49,7 @@ files of this pass: |---|---|---| | 006 | 2 not ok: another editor uploads a pending key it did not register (L5) | 16/16 | | 016 | 1 not ok: a draft from a deprecated version takes it as base (M2) | 50/50 | -| 017 | M1 approval on an archived sheet succeeds; M2 base from a deprecated version; the file aborts there | 85/85 | +| 017 | M1 approval on an archived sheet succeeds; M2 base from a deprecated version; the file aborts there | 85/85 (110/110 after the final decisions pass, §4) | | 018 | 93 not ok of 337: capability holders at aal1 get `rights.capability` instead of `rights.mfa` (§6.7); `delete_sheet_asset` answers a raw code | 337/337 | | 019 | 38/38 (lost coverage of behaviour that was already correct) | 38/38 | | sheets-concurrency | 5 failed of 15: publish against withdraw (no version lock), two deprecations (no sheet lock), archive against approve (no sheet lock) | 15/15 | @@ -57,42 +57,58 @@ files of this pass: ## 4. Real-stack results on the corrected HEAD Final decisions pass (owner brief « V1-2.1 : décisions finales du propriétaire »), code at -`7eca441` (M6 option A, text size measure, pgTAP 015/017). Earlier figures (1 333 pgTAP) were -the `2af61e7` state. +`5620399` (M6 option A, text size measure with the bounded number walk, pgTAP 015/017/020; +only `.claude/` differs at the final HEAD). Earlier figures (1 333 pgTAP) were the `2af61e7` +state; an intermediate pass at `7eca441` gave 1 352 before the review findings below. | Run | Fresh stack | Upgraded stack (M3 + Git fixture, then M4+M5) | |---|---|---| -| pgTAP (`test-db`) | 1 352/1 352 | 1 352/1 352 | +| pgTAP (`test-db`, 18 files) | 1 807/1 807 | 1 807/1 807 | | sandbox suite, run 1 | 86/86 | 86/86 | | sandbox suite, run 2 (same stack) | 86/86 | 86/86 | | of which two-session concurrency (`sheets-concurrency`) | 16/16 each run | 16/16 each run | -| pgTAP again after both suite runs | 1 352/1 352 | 1 352/1 352 | +| pgTAP again after both suite runs | 1 807/1 807 | 1 807/1 807 | | `types --check` | types match | types match | -PGlite: 127/127 (packages/supabase: the 17 pgTAP files and the closed-code census). +PGlite: 128/128 (packages/supabase: the 18 pgTAP files and the closed-code census). -New in 017: M6 (owner self-grants `sheet_reviewer`; owner-reviewer acknowledges and approves a -version written by E, E publishes; owner refused on a round it authored, `review.separation`; -publication after an author's approval refused, `publish.approval.invalid`) and the document -size (cap − 1 and cap saved and measured, cap + 1 refused, a 2 MiB document of 3-byte -characters saved, cap + 1 in 4-byte characters refused, a dense document within the cap as text -and over it as binary jsonb saved whole, creation over the cap refused, the table CHECK -definition). Every refusal answers `document.too_large` (23514), never a raw constraint error. +New in this pass: + +- 017 M6: owner self-grants `sheet_reviewer`; owner-reviewer acknowledges and approves a version + written by E, E publishes; owner refused on a round it authored (`review.separation`); + publication after an author's approval refused (`publish.approval.invalid`). +- 017 size: cap − 1 and cap saved and measured exactly; cap + 1 refused; a 2 MiB document of + 3-byte characters saved; cap + 1 in 4-byte characters refused; a dense document within the cap + as text and over it as binary jsonb saved whole; creation over the cap refused; numbers that + JavaScript prints with an exponent stored and measured in plain form; a document under the cap + in compact JavaScript form but over it as measured refused; 9 000 numbers of 131 072 digits + refused with the closed code; the table CHECK definition. Every refusal answers + `document.too_large` (23514), never a raw error. +- 017 `publish.species.other` refused alone. +- 020 (449): the AR-1 B matrix of §15 in full (6 caller classes × aal1/aal2 × grant/revoke × 4 + roles × self/other, each refusal with « nothing written »), the regression chain on the real + owner and admin at aal1, and the rights RPCs (`grant_catalog_right` on itself and on another, + `revoke_catalog_right`, `lookup_catalog_account`, `list_catalog_grants`) refused to every + non-owner class at aal2 (`rights.owner`) and at aal1 (`rights.mfa`). + +Number bomb on the real image (`runs2/fresh/bomb.log`, sandbox): the shipped function answers +`document.too_large`; the same payload under the previous body (`octet_length(p_doc::text)` +alone, rolled back) fails with `out of memory` after a 1 GiB buffer. ## 5. Timing at the caps (§15, budget 2 000 ms for save, submit, publish) Synthetic document: 64 views, 1 024 annotations, 8 192 finding nodes (depth 8), 1 089 review -groups, 4 drawings of 2 000 000 bytes. Since the size measure follows the contract, the labels are -calibrated on the text alone: text 2 076 707 bytes (cap 2 097 152), binary jsonb 2 346 648 bytes, -over the cap and accepted, as the contract's measure requires. HTTP wall-clock through PostgREST -on the development machine, milliseconds (min / median / max): +groups, 4 drawings of 2 000 000 bytes. The labels are calibrated on the contract's text measure +alone: text 2 076 707 bytes (cap 2 097 152), binary jsonb 2 346 648 bytes, over the cap and +accepted, as the measure requires. HTTP wall-clock through PostgREST on the development machine, +code `5620399`, milliseconds (min / median / max): | Stack, run | save (7) | submit (5) | approve (3) | publish (3) | |---|---|---|---|---| -| fresh, 1 | 118 / 123 / 137 | 4 / 6 / 7 | 189 / 284 / 303 | 198 / 289 / 300 | -| fresh, 2 | 114 / 125 / 139 | 5 / 6 / 6 | 196 / 281 / 292 | 210 / 297 / 307 | -| upgraded, 1 | 123 / 128 / 131 | 5 / 6 / 10 | 286 / 292 / 302 | 208 / 291 / 299 | -| upgraded, 2 | 118 / 123 / 129 | 4 / 6 / 7 | 198 / 285 / 295 | 211 / 292 / 310 | +| fresh, 1 | 135 / 140 / 149 | 5 / 6 / 7 | 195 / 285 / 290 | 208 / 297 / 315 | +| fresh, 2 | 130 / 139 / 145 | 4 / 5 / 6 | 200 / 286 / 301 | 201 / 285 / 304 | +| upgraded, 1 | 130 / 141 / 156 | 5 / 5 / 6 | 196 / 286 / 296 | 306 / 308 / 318 | +| upgraded, 2 | 132 / 136 / 146 | 4 / 5 / 6 | 210 / 284 / 293 | 204 / 291 / 298 | The core's at-caps fixture is V1-2.2 work; the contract fixes the budgets at the V1-2.3 checkpoint and measures verification (120 s) there. @@ -125,7 +141,7 @@ RPC), then M4+M5 by `supabase migration up`. bytes (sha256 equal to the key); the same editor at aal1, a catalogue reader and an anonymous caller are refused (the historical sheet has no published version). -The rehearsal is reproducible from the repository, re-run on `7eca441` (final decisions pass) +The rehearsal is reproducible from the repository, re-run on `7eca441` and `5620399` (final decisions pass) with the same results, the only diff lines being the bucket limit and the service_role privileges: `bash .claude/audits/2026-10-28-v1-2-1-m7/m7-rehearsal.sh [work dir]` (sandbox only; it applies M4+M5 with `supabase migration up --db-url` on the sandbox port, a step `scripts/db-sandbox.sh` diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index 5895082a..f07fa284 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -478,3 +478,4 @@ R5.4: `draft/{labels,changelog,review_report,drawing,overlay,app_review,svg_comp - V1-2.1 fresh security+verifier gates run on commit 77e5fa4: security PASS (no blocker; lease-token whole-row grant narrowed to omit attempts/lease_token/locked_at). Verifier ECARTS(10) → fixed the real gaps: publish re-checks the approver's reviewer grant (publish.approval.invalid), scope disclaimer enforced at approve+publish (publish.disclaimer.missing, O6), to_confirm split from inherited (publish.to_confirm.open), save requires an active sheet, delete_sheet_asset revoked from service_role, species table comment updated, working-copy 2 MiB check, lock order sheet→version→round in decide/publish, conflict_retry kind (40001/40P01) in sheets.ts. Tests added (pgTAP 016 now 50, 001 census no-other-writer): omitted review_status, separation author-reviewer, revoked-reviewer approval + renewal, ack carry, inactive-species publish refusal, deprecated-delete, schema_version 1 refused, content-write-without-actor, working-copy positive. 871 real-stack pgTAP / 122 PGlite / 4 sandbox green; typecheck+lint+types drift clean. Deferred (noted): at-caps timing (V1-2.2 doc), fuller MFA factor mgmt (V1-2.5), low residuals (existence oracle, write-budget on some admin RPCs). - V1-2.1 corrections after audit (3914eaa CHANGES REQUIRED): M1 approve needs active sheet, M2 base only from published round version, LOW fixes (rights.mfa first, closed codes, budgets, view.asset.unknown at submit, upload policy = registrant, append-only acks, deprecate/working-copy locks). Found+fixed: published round withdrawable, approver-author not refused at publish. Found: jsonb pg_column_size > text size (CHECK binds before contract measure) → closed code; owner decision. pgTAP 1325 fresh+upgraded, sandbox 86/86 x2 both stacks, caps timing max 374 ms, M7 rehearsal object+metadata identical, check:all green. Commits d05f75d..4a82941 pushed. M6 + M7 criterion + size measure → owner. Fresh verifier + security gates dispatched. - V1-2.1 final owner decisions (2af61e7): M6 A grant.self_review dropped, size = octet_length(content::text) (table CHECK replaced in M5), M7 Git fixture wording in contract + evidence. pgTAP 1352 fresh+upgraded, sandbox 86/86 x2 both stacks (concurrency 16/16), caps text 2 076 707 / jsonb 2 346 648 accepted, PGlite 127. DEV metadata identical. BDR-085. +- V1-2.1 review pass on 1281667: verifier ECARTS(6) (missing proofs: AR-1 B matrix, non-owner rights RPCs, publish.species.other; LOW docs), security PASS + MEDIUM number-exponent OOM (9000 x 1e131071 = 1 GiB text, raw OOM). Fixed 3eba6d8: bounded number walk before text measure; pgTAP 020 (449). Re-run 5620399: pgTAP 1807 x2 both stacks, suite 86/86 x2 both. Correction: earlier 'DEV metadata identical' = DEV container state only (ids, start times), no DEV data read. diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index f4bb9b10..4a51f9c9 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -560,7 +560,8 @@ Order (BDR-071): P0 docs + decisions → V1-1 clients and animals → V1-2 sheet - [x] H1 M6 option A: drop `grant.self_review` (M4, sheets.ts kinds); keep author ≠ reviewer at ack/approve/publish, MFA, eligibility; pgTAP: owner self-grants reviewer ok, owner-reviewer approves another's draft ok, owner approving own draft refused, publish after an author's approval refused - [x] H2 M7 Git fixture accepted: contract §12.3/§15/§16.2 + evidence say Git fixture with sha256 = DEV row, bytes/metadata/relations before/after, no DEV Storage read, live DEV object integrity not shown - [x] H3 size measure = contract `octet_length(content::text)` (UTF-8 bytes of the jsonb text form): drop `pg_column_size` from `check_document_structure`, M5 replaces the base table CHECK by the text measure; contract defines the form for SQL, TS, Rust; pgTAP: cap − 1, cap, cap + 1, multibyte, dense (jsonb > cap, text ≤ cap) accepted; refusals `document.too_large` - - [ ] H4 gates: pgTAP fresh + upgraded, PGlite + unit, sandbox suite ×2, concurrency, fresh + M3→M5 (M7 rehearsal), types, check:all; fresh verifier + security on final HEAD; DEV metadata before/after — sandbox done on 7eca441 (pgTAP 1352 ×2 per stack, suite 86/86 ×2 per stack, types match, M7 diff = bucket + service_role only, DEV metadata identical); check:all + reviews on final HEAD pending + - [ ] H4 gates: pgTAP fresh + upgraded, PGlite + unit, sandbox suite ×2, concurrency, fresh + M3→M5 (M7 rehearsal), types, check:all; fresh verifier + security on final HEAD; DEV metadata before/after — sandbox done on 7eca441 (pgTAP 1352 ×2 per stack, suite 86/86 ×2 per stack, types match, M7 diff = bucket + service_role only, DEV containers untouched: same ids, start times, restart counts; nothing on DEV read); check:all + reviews on final HEAD pending + - [x] H6 review findings on 1281667 (verifier ECARTS(6), security PASS + 1 MEDIUM): number-exponent amplification → raw OOM (bounded number-text pre-sum, closed code, pgTAP); AR-1 B §15 matrix (015); rights RPCs refused for non-owners (015); `publish.species.other` alone (017); docs §1, §9.5, §12.2 vectors, evidence §3; then gates again + fresh reviews — done 3eba6d8/5620399: pgTAP 1807 ×2 per stack, suite 86/86 ×2 per stack, PGlite 128, bomb proof on real image; final check:all + fresh reviews pending - [ ] H5 memory (BDR M6/size, journal), commit + push branch, final report - [ ] V1-2.2 core verdict, preview, change list, edit primitives, SVG cleaning · V1-2.3 drawings and worker verification (M6) · V1-2.4 wireframes (editor, review, admin entry) · V1-2.5 catalogue, admin space, rights, species, MFA · V1-2.6 editor level 1 · V1-2.7 preview, review, publication UI · V1-2.8 equine working copy and review preparation · V1-2.9 FR/EN acceptance and closure (owner checkpoints V1-2.3, V1-2.4, V1-2.6, V1-2.7, V1-2.8, V1-2.9 + each DEV operation of contract §16.11)