chore(memory): BDR-075, EVAL-037, V1-1.2 journal, TODO, gate contract
This commit is contained in:
1 parent
a945e79131
commit
5bc6631b6e
6 files changed
+90
-10
No files matched your search
@@ -550,3 +550,11 @@ M1 as built (`20261025100000_workspaces.sql`): creation = server init in sign-up
|
||||
Deviations: `packages/supabase/src/workspaces.ts` → V1-1.2 (no consumer); `db:reset && db:test` on DEV replaced by isolated sandbox (owner kept DEV untouched).
|
||||
Alt: workspace created at first authorised login (client-triggered, forgeable timing, partial-state risk); invariant only by grants (owner-role bugs undetected); per-actor budget (cabinet-blind).
|
||||
Status: active. M1 not applied to DEV (owner action, SUPABASE.md §3.3). Contract §5.3, §8.1, §9, §10, §13.2.
|
||||
|
||||
## BDR-075 | 2026-10-25 | V1-1.1 validated; V1-1.2 M2 clients built: budget counter, divergent replay, C-lower fold, sandbox tool
|
||||
|
||||
Decision (owner brief « Validation V1-1.1 et autorisation V1-1.2 Données clients »): V1-1.1 accepted (M1, grants, RLS, tests); MEDIUM scanner findings non-blocking, trust boundary kept documented; service_role / GoTrue admin indirect access never claimed closed. Sandbox tool kept in repo: `scripts/db-sandbox.sh` (`pnpm db:sandbox`), rootless, loopback, own ports, no volume, generated secrets outside Git, CLI runners via `--db-url`. M1 on DEV = owner procedure (SUPABASE.md §3.3), not Claude.
|
||||
M2 as built (`20261025110000_clients.sql`): budget = owner's transactional counter per workspace: `private.workspace_write_budgets` row upserted by `private.consume_write_budget`, fixed UTC hour/day windows (restart at 1 in a new window; 1000th passes, 1001st `rate_limited`; up to 2000 across an hour boundary, day 5000 holds), called LAST in every write RPC → lock order workspace → (animal → client in M3) → budget, no cycle; refused / replayed / no-op not counted (rollback). Divergent replay: `create_request_digest` (sha256 of normalised content, not API-readable) → `request_conflict`. Fold = unaccent then `lower(... collate "C")` (ASCII only) for PGlite/ICU parity. `search_clients` without `current_animal_count` until M3. Text rule via `private.is_clean_text`. Access layer → V1-1.5.
|
||||
Measured: search 20k clients p95 21 ms (no trigram index); held budget row delays only its workspace.
|
||||
Alt: count audit rows per workspace (needs index on metadata, count+insert race without extra lock); rolling windows (owner chose UTC windows); accept divergent replay as replay (silent divergence).
|
||||
Status: active. M1+M2 not on DEV.
|
||||
@@ -260,3 +260,11 @@ Method: fresh verifier on contract `.claude/tasks/contracts/2026-10-25-v1-1-1-wo
|
||||
Result: security PASS (2 MEDIUM scanner false positives: policy via helper, not raw auth.uid(); LOWs = table names in 42501, residual admin paths, NOT VALID CHECK, pre-existing bounded revoke reason). Verifier C1-C8 MET, C9 UNVERIFIABLE (forbidden to read DEV) → closed by `supabase migration list --local` (M1 remote empty).
|
||||
Anomalies: first mutation run misread (sed indentation miss, crash not printed) → rerun with crash capture; concurrency script pipefail printed false "UNEXPECTED" after real ERROR → fixed. GoTrue 500 on same-email concurrent sign-up = GoTrue race on users_email_partial_key, not M1.
|
||||
Action: contract for gates should name a read-only way to check DEV state (migration list) so C9-type clauses are verifiable.
|
||||
|
||||
## EVAL-037 | 2026-10-25 | V1-1.2 M2 clients: gates, mutations, sandbox hardening
|
||||
|
||||
Method: fresh verifier (contract 2026-10-25-v1-1-2-clients.md) + fresh security auditor; 5 M2 mutations (divergent replay, workspace auth, `_` escape, N9 filter, hourly limit) all caught by 013; real image fresh + upgrade (M2 alone, M1+M2 together).
|
||||
Result: security PASS (MEDIUM: secrets on argv in db-sandbox.sh, fixture password literal, policy false positive; LOW: empty-secret fallback risk, state dir in repo, uncapped cursor, no read limit). Verifier ECARTS(2): BDR-075 uncommitted (committed after), fresh-mode real run not reproducible by it (rerun after hardening: 661 PASS, types match, 28/28).
|
||||
Fixes applied: secrets via env files + PGPASSWORD name only, password-free --db-url, load_secrets refuses incomplete file, state dir refused in repo. Accepted: fixture password literal (sandbox only), uncapped cursor (bounded by name_key compare), read rate limit (deploy notes RR-5).
|
||||
Anomalies: Write tool turned `
/
` escapes into raw chars (broke a JS regex) → check new files for raw line separators; prettier over tests/ touched 3 unrelated files → restored; real image adds GRANT hint to table denials.
|
||||
Action: write Unicode escapes via shell/python when exact bytes matter.
|
||||
@@ -405,3 +405,7 @@ R5.4: `draft/{labels,changelog,review_report,drawing,overlay,app_review,svg_comp
|
||||
- Owner validated V1-1 architecture + N1-N9 (BDR-074; N4 voiding, N6 budget per workspace, N9 ids-only audit). Built M1 `20261025100000_workspaces.sql` + pgTAP 012 (85) + config test; commits 7bf4fb6 (code), 0f8c983 (docs).
|
||||
- Isolated sandbox (DEV images, own net, loopback ports, no volume): fresh + upgrade paths, 531 pgTAP, concurrency, 33 HTTP checks; types generated there (sslmode=disable). DEV untouched (migration list: M1 local only).
|
||||
- Gates: security PASS (0 HIGH), verifier ECARTS(1) = C9 unverifiable by it, closed by read-only migration list. rust:check + check:all green. STOP at checkpoint; M1 on DEV = owner action (SUPABASE.md §3.3).
|
||||
|
||||
## 2026-10-25 (V1-1.2 clients, branch feature/v1-1-clients-animals)
|
||||
- Owner validated V1-1.1, authorised V1-1.2 + kept sandbox. M1 closure: official `gen types` against sandbox = 0 diff; `scripts/db-sandbox.sh` committed (08abe42), DEV procedure rehearsed incl. backup/restore (5ed1f01); LRN-080/081.
|
||||
- M2 clients (4adbfcb): RPCs, search, budget counter, N9 filter; pgTAP 013 (130), parity test, sandbox suite 28; real image adds a GRANT hint on table denials (PGlite not) → tests compare state+message there. Prettier over tests/ reformatted 3 unrelated files → restored before commit.
|
||||
@@ -401,17 +401,17 @@ Order (BDR-071): P0 docs + decisions → V1-1 clients and animals → V1-2 sheet
|
||||
- Security: no platform-role branch; no `using (true)`; helpers `search_path = ''`, EXECUTE only where evaluated; email confirmation checked in SQL; `log_event` callers unchanged
|
||||
- Stop if: `auth.users` join behaves differently on PGlite and the real stack; the profiles trigger interferes with `handle_new_auth_user` or sign-up; an existing policy would need editing beyond the `log_event` redefinition
|
||||
- [ ] V1-1.2 Clients data (owner brief 2026-10-25; isolated stack only; DEV untouched; stop at checkpoint before V1-1.3)
|
||||
- [ ] M1 closure: types re-checked with the official generator against an isolated DB holding M1 (diff 0); sandbox tool committed (`scripts/db-sandbox.sh`, `pnpm db:sandbox`: rootless, loopback, own ports, no volume, generated secrets outside Git, fresh + upgrade, official `supabase test db` / `gen types` via `--db-url`); owner DEV procedure for M1 (target, history, backup incl. auth, restore check, `db:test` non-destructive check) rehearsed on the sandbox; LRN-080/081
|
||||
- [ ] M2 `<ts>_clients.sql`: unaccent, `private.fold_text`, `client_kind`, `clients` (+ `create_request_digest` for divergent replays), budget table + `private.consume_write_budget` (UTC fixed hour/day windows, row lock, last lock taken), RPCs create/update/set_archived/search, N9 audit policy, grants, RLS
|
||||
- [ ] pgTAP 013; harness loads unaccent; `field-limits.ts` + behavioural parity test; types; census
|
||||
- [ ] sandbox suite (vitest, real GoTrue/PostgREST sessions): M1 regression, clients HTTP, concurrency (creates, replay, divergent replay, stale revision, archive/restore race, budget limits, no deadlock), 20 000-client search timing
|
||||
- [ ] docs: contract (budget, divergent replay, search_clients without current_animal_count until M3), SUPABASE.md, TEST_STRATEGY, BDR-075, journal
|
||||
- [ ] fresh verifier + security audit; rust:check, check:all; checkpoint
|
||||
- [x] M1 closure: types re-checked with the official generator against an isolated DB holding M1 (diff 0); sandbox tool committed (`scripts/db-sandbox.sh`, `pnpm db:sandbox`: rootless, loopback, own ports, no volume, generated secrets outside Git, fresh + upgrade, official `supabase test db` / `gen types` via `--db-url`); owner DEV procedure for M1 (target, history, backup incl. auth, restore check, `db:test` non-destructive check) rehearsed on the sandbox; LRN-080/081
|
||||
- [x] M2 `<ts>_clients.sql`: unaccent, `private.fold_text`, `client_kind`, `clients` (+ `create_request_digest` for divergent replays), budget table + `private.consume_write_budget` (UTC fixed hour/day windows, row lock, last lock taken), RPCs create/update/set_archived/search, N9 audit policy, grants, RLS
|
||||
- [x] pgTAP 013; harness loads unaccent; `field-limits.ts` + behavioural parity test; types; census
|
||||
- [x] sandbox suite (vitest, real GoTrue/PostgREST sessions): M1 regression, clients HTTP, concurrency (creates, replay, divergent replay, stale revision, archive/restore race, budget limits, no deadlock), 20 000-client search timing
|
||||
- [x] docs: contract (budget, divergent replay, search_clients without current_animal_count until M3), SUPABASE.md, TEST_STRATEGY, BDR-075, journal
|
||||
- [x] fresh verifier + security audit (PASS; ECARTS closed); sandbox hardened; rust:check, check:all green; checkpoint
|
||||
- Deviation: access layer `clients.ts` + workspace read move to V1-1.5 (first consumer; brief §6 scope lists no access layer)
|
||||
- Objective: clients created, edited, archived, restored and searched through RPCs with the D15 guards, isolated per workspace, proven on the real stack
|
||||
- Depends: V1-1.1; N2, N3, N6, N9 decided
|
||||
- Files: `supabase/migrations/<ts>_clients.sql`; `supabase/tests/013_clients.sql`; `packages/supabase/tests/db/harness.ts` (load `unaccent`); `packages/supabase/src/field-limits.ts` + `tests/db/field-limits.test.ts` (behavioural parity, code points); `packages/supabase/src/clients.ts` (accessors, closed failure kinds) + unit tests; `packages/supabase/tests/e2e/clients-animals.e2e.ts` (seed and teardown through the existing psql helper), `scripts/clients-animals-e2e.sh`, root script (name to confirm); types regenerated
|
||||
- Migration M2: `unaccent` in `extensions`; `private.fold_text`; `private.require_write_budget(p_workspace_id)` (N6: per workspace, 1 000/h, 5 000/day, counted under a per-workspace lock; document counter + lock order in contract §9.3); enum `client_kind`; `clients` (`name_key`, `search_key`, `phone_digits`, `create_request_id`); `create_client`, `update_client`, `set_client_archived`, `search_clients`; N9 condition on `audit_logs_select_admin`; grants; RLS
|
||||
- Migration M2: `unaccent` in `extensions`; `private.fold_text`; `private.consume_write_budget(p_workspace_id)` (N6: per workspace, UTC hour/day windows, budget row lock taken last; contract §9.3, §10); enum `client_kind`; `clients` (`name_key`, `search_key`, `phone_digits`, `create_request_id`); `create_client`, `update_client`, `set_client_archived`, `search_clients`; N9 condition on `audit_logs_select_admin`; grants; RLS
|
||||
- Tests: contract §12.1 rows for clients (whole-error identity, no lock outside the workspace, archived before conflict, replayed request id, caps, budgets, audit without values, search accents/case/backslash/phone formats/keyset); parity test; e2e cross-account + service key refused + GoTrue admin delete; search time on 20 000 clients recorded
|
||||
- Acceptance: gates green; e2e green on the local stack; measurement written in the contract
|
||||
- Security: constraint and parse errors caught inside RPCs; text parameters parsed in the body; search through POST; definer census
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
# CONTRACT: V1-1.2 Clients data (M2) + M1 closure, owner brief 2026-10-25 « Validation V1-1.1 et autorisation V1-1.2 Données clients »
|
||||
|
||||
- branch `feature/v1-1-clients-animals`, base 6bf6978 (V1-1.1 validated); commits 08abe42 (sandbox tool + M1 suite),
|
||||
5ed1f01 (DEV procedure docs), 2c0531d (memory), 4adbfcb (M2 code), f8bd1b6 (docs)
|
||||
- diff under review: `git diff 6bf6978..f8bd1b6 -- scripts supabase packages package.json docs`
|
||||
- functional contract `docs/development/V1-1_OWNERS_ANIMALS.md` §5, §5.1, §8.2, §9, §10, §12, §13.2
|
||||
- isolated stack: `pnpm db:sandbox` (scripts/db-sandbox.sh, SUPABASE.md §5.1) is UP (upgrade mode, M1+M2 applied over
|
||||
older data). Allowed: `pnpm db:sandbox test-db`, `pnpm db:sandbox types --check`, `pnpm db:sandbox test`,
|
||||
`echo "<read-only SQL>" | pnpm db:sandbox sql`. The DEV stack (`supabase_*_faunosteo`) must not be touched except
|
||||
`pnpm supabase migration list --local` (read-only).
|
||||
|
||||
## Clauses
|
||||
|
||||
C1. **Scope.** M2 only: `supabase/migrations/20261025110000_clients.sql`. No M3 object (animals, relations, species
|
||||
rows, animal enums), no React screen or route, no V1-1.3 tooling (Playwright, Dialog), no change to crates/, no edit of an
|
||||
existing migration, no change to existing tables' grants or policies except the N9 condition on `audit_logs_select_admin`.
|
||||
|
||||
C2. **M1 closure.** The committed `database.types.ts` equals the official generator's output (`supabase gen types
|
||||
typescript --schema public`, through Prettier) against an isolated database holding the migrations; no hand edit; types
|
||||
cover exactly the public schema objects of M1 and M2.
|
||||
|
||||
C3. **Sandbox tool.** `scripts/db-sandbox.sh`: rootless Docker, ports on 127.0.0.1 only and distinct from DEV, no volume
|
||||
created or removed, cleanup by literal `faunosteo_dbsandbox_*` names only, secrets generated outside the repository and
|
||||
never printed or committed, image versions pinned and documented, fresh and upgrade modes, every Supabase CLI call with
|
||||
an explicit sandbox `--db-url` (none can reach DEV).
|
||||
|
||||
C4. **DEV procedure (doc only).** SUPABASE.md §3.3: target check, migration history, only V1-1 migrations pending,
|
||||
accounts count, backup including auth data stored outside Git and checked, application without reset and without
|
||||
`db push`, `migration repair` or destructive command, `db:test` shown non-destructive, post-checks (history, workspaces,
|
||||
duplicates, privileges, types, e2e:avatar), stop conditions, no secret printed. Claude applied nothing to DEV.
|
||||
|
||||
C5. **Clients model.** person | organization; `display_name` required, no first/last name, no notes; optional contacts;
|
||||
no default country; workspace FK `on delete restrict`; text rules and bounds as contract §5/§5.1; no sensitive extra
|
||||
field; `field-limits.ts` constants proven equal to the SQL CHECKs by a behavioural parity test (bounds, code points,
|
||||
control ranges, patterns; TypeScript never accepts what SQL refuses).
|
||||
|
||||
C6. **RPCs.** `create_client`, `update_client`, `set_client_archived` (definer) and `search_clients` (invoker): identity
|
||||
from `auth.uid()` only via `writable_workspace_ids` / RLS (active profile, confirmed email); same whole error for a
|
||||
foreign and an unknown id; parse errors and constraint violations → `invalid_input` without echo; idempotent create,
|
||||
divergent replay → `request_conflict`; stale revision → `conflict`; archived read-only (`archived` before `conflict`);
|
||||
restore allowed; no-op writes nothing; EXECUTE only for authenticated; search_path empty; owner postgres; audit rows
|
||||
ids only (`{workspace_id}`), hidden from platform staff (N9).
|
||||
|
||||
C7. **Budget and caps.** Transactional counter per workspace (owner §9): UTC hour/day windows documented (zone, reset,
|
||||
boundaries); 1 000/h, 5 000/day, 20 000 clients; increment and write in one transaction; refused, replayed and no-op
|
||||
calls not counted; concurrency-safe; stable lock order documented (workspace, animal, client, budget last); lock scope
|
||||
per workspace, measured.
|
||||
|
||||
C8. **Search.** POST RPC, 25 default / 100 max page, ≤ 100-character term, deterministic order `(name_key, id)` with
|
||||
keyset, LIKE wildcards escaped, phone search, no leak of another workspace through rows, counts or pages; index exists;
|
||||
20 000-client timing recorded.
|
||||
|
||||
C9. **Tests.** pgTAP `013_clients.sql` + `001` census green on PGlite and on the isolated real image (fresh and upgrade);
|
||||
sandbox suite: real authenticated sessions per role (A, B, anon key, service key, deactivated, unconfirmed), concurrent
|
||||
creates, replays, divergent replay race, stale revision race, archive/restore race, budget at the limit under
|
||||
concurrency, no deadlock; M1 regression (workspaces, backfill, auth/profile). `pnpm test:run` green.
|
||||
|
||||
C10. **Docs and limits.** Contract §8.2 as built + deviations, SUPABASE.md §3.4/§5.1, TEST_STRATEGY, BDR-075, LRN-080/081
|
||||
(scoped, no duplicate). No merge, main and release/0.2.0 untouched, no deploy, fixtures fictitious.
|
||||
@@ -50,8 +50,8 @@ Product roadmap (owner, 2026-10-25): P0 docs, then V1-1 clients and animals, V1-
|
||||
V1-3 cloud bilans, V1-4 stored PDF and sharing, V1-5 mobile and accessibility pass
|
||||
(`docs/development/IMPLEMENTATION_PLAN.md` §0; V1-1 contract `docs/development/V1-1_OWNERS_ANIMALS.md`:
|
||||
business decisions ratified 2026-10-25, BDR-073; architecture and N1-N9 validated, BDR-074; on
|
||||
`feature/v1-1-clients-animals` only V1-1.1 is built: migration `20261025100000_workspaces.sql`, tested on PGlite and an
|
||||
isolated stack, not applied to Supabase DEV).
|
||||
`feature/v1-1-clients-animals` V1-1.1 (validated) and V1-1.2 are built: migrations `20261025100000_workspaces.sql` and
|
||||
`20261025110000_clients.sql`, tested on PGlite and the isolated stack `pnpm db:sandbox`, not applied to Supabase DEV).
|
||||
|
||||
---
|
||||
|
||||
@@ -123,6 +123,7 @@ pnpm db:reset # replay from zero
|
||||
pnpm db:test # pgTAP on the real stack
|
||||
pnpm db:types # regenerate packages/supabase/src/database.types.ts
|
||||
pnpm db:types:check # CI diff
|
||||
pnpm db:sandbox up fresh|up upgrade <version>|test-db|types [--check]|test|down # throwaway stack (SUPABASE.md §5.1): migrations tested without touching DEV
|
||||
|
||||
# Reference sheet in the app: the dev server bundles the curated draft; a build does not
|
||||
pnpm build:preview # SHEET_BUNDLE=draft build (manual validation, preview deployments)
|
||||
@@ -275,7 +276,7 @@ faunosteo/
|
||||
│ └─ tests/{client,anatomical-sheets}.test.ts, tests/db/ ← PGlite harness, shim, pgTAP runner, schema↔types test
|
||||
├─ supabase/
|
||||
│ ├─ config.toml, seed.sql ← CLI config (public schema only), local dev accounts
|
||||
│ ├─ migrations/*.sql ← forward-only; foundation, profiles, platform_roles, anatomical_sheets, storage, sheet_document_schema_v2, profiles_professional, files_foundation (assets, buckets, avatar policies, purge queue, RPCs), workspaces (V1-1.1: personal workspace per account, access helpers)
|
||||
│ ├─ migrations/*.sql ← forward-only; foundation, profiles, platform_roles, anatomical_sheets, storage, sheet_document_schema_v2, profiles_professional, files_foundation (assets, buckets, avatar policies, purge queue, RPCs), workspaces (V1-1.1: personal workspace per account, access helpers), clients (V1-1.2: client RPCs and search, write budget per workspace)
|
||||
│ ├─ seed/anatomical-sheets/equine/
|
||||
│ │ ├─ legacy-sources/ ← the historical Horse.svg, Horse_head.svg, pathologies.json, vertebrae.ts (importer input, never edited)
|
||||
│ │ ├─ legacy-import/ ← GENERATED baseline: document, id map, IMPORT-REPORT, SVG copies (no SQL)
|
||||
|
||||
Reference in new issue
Block a user