docs(docs): Step 8 / R1 — files foundation, worker loop, avatar: CLAUDE, DEPLOY (.env.worker, CSP), SUPABASE, RUST, TEST_STRATEGY, WORKSPACE, IDENTITY §5, design README, plan as-built note, CHANGELOG; R1 plan and verifier contract
This commit is contained in:
1 parent
0c6053c174
commit
62eb4e5d82
13 files changed
+235
-35
No files matched your search
@@ -0,0 +1,58 @@
|
||||
# CONTRACT — step-08 / Rust R1: files foundation, worker job loop, avatar
|
||||
- date: 2026-10-13 | flow: orchestrator + 2 forks, verifier gate | branch: feature/step-08-files-foundation (cut from the R0 tip 3f1105b)
|
||||
- status: dispatched after the implementation commits
|
||||
- spec: docs/development/STORAGE.md (contract), docs/development/STEP8_FILES_ANALYSIS.md (D1–D9, D1 = Rust worker), RUST_ARCHITECTURE_REVIEW.md Part IV, owner brief 2026-10-13 (sections 2–7)
|
||||
- diff range: 3f1105b..HEAD (run every CHECK from the repository root)
|
||||
|
||||
## REQUEST (IMMUTABLE)
|
||||
Step 8 = R1: `assets` table as the authority over user files, eight private buckets (only `avatars` open through policies evaluated on `assets`), quarantine upload path, deferred purge queue, browser and worker RPCs with closed error codes; the Rust worker's keyed job loop + sweeper on the R0 sandboxed decode child (unchanged); the avatar in Mon compte, the sidebar, the drawer and the top bar (link to Mon compte, no dropdown, no redesign); tests at every layer; real-stack e2e; docs. Out: other buckets' flows, SVG upload, PDF/anatomy ports, CI runner, deploy, release, merge into develop.
|
||||
|
||||
## ACCEPTANCE CRITERIA
|
||||
1. The SQL foundation applies on PGlite and every pgTAP file passes, including the new 010 (125 checks) and the extended 001 census.
|
||||
CHECK: pnpm --filter @faunosteo/supabase exec vitest run tests/db/pgtap.test.ts 2>&1 | grep -E "^ +Tests "
|
||||
EXPECT: Tests 11 passed (11)
|
||||
2. Exactly three policies are created by the migration (assets own-row SELECT, avatars read, avatars upload), the two Storage ones pin the bucket literal, and no UPDATE / DELETE policy exists on storage.objects.
|
||||
CHECK: grep -c "^create policy" supabase/migrations/20261013100000_files_foundation.sql; grep -c "on storage.objects" supabase/migrations/20261013100000_files_foundation.sql; grep -cE "for (update|delete)" supabase/migrations/20261013100000_files_foundation.sql
|
||||
EXPECT: 3 / 2 / 0
|
||||
3. The owner's column grant on assets excludes every lease and quarantine column.
|
||||
CHECK: sed -n '/^grant select ($/,/to authenticated;/p' supabase/migrations/20261013100000_files_foundation.sql | grep -c "lock_token\|quarantine_key\|locked_at\|attempts"
|
||||
EXPECT: 0
|
||||
4. Both worker verdict RPCs refuse a stale lease token (status uploaded AND token match).
|
||||
CHECK: grep -c "lock_token is distinct from lock_token" supabase/migrations/20261013100000_files_foundation.sql
|
||||
EXPECT: 2
|
||||
5. The eight scenarios of the owner's brief are named as pgTAP descriptions (cross-user read, cross-user replace/delete, anon, quarantine never readable, final key never written by the browser, superseded / removed row never completes, stale lease refused, late bytes swept) — at least 12 descriptions carry the `scenario:` marker.
|
||||
CHECK: grep -c "scenario:" supabase/tests/010_files_foundation.sql
|
||||
EXPECT: 13
|
||||
6. The R0 sandboxed child is untouched by R1 (decode, sandbox, spawn, webp_check unchanged in the range).
|
||||
CHECK: git diff 3f1105b..HEAD --stat -- crates/worker/src/decode.rs crates/worker/src/sandbox.rs crates/worker/src/spawn.rs crates/worker/src/webp_check.rs | wc -l
|
||||
EXPECT: 0
|
||||
7. The worker links no async runtime and no aws-lc-rs (ureq on rustls + ring, review deviation recorded).
|
||||
CHECK: . scripts/rust-env.sh && cargo tree -p faunosteo-worker --prefix none 2>/dev/null | grep -cE "^(tokio|reqwest|aws-lc-rs) "
|
||||
EXPECT: 0
|
||||
8. Keys from the database are validated before any URL (http, job, sweep all call the key validators) and no log or print site exposes the service key.
|
||||
CHECK: grep -n "validate_any_key\|validate_object_key\|validate_quarantine_key" crates/worker/src/http.rs crates/worker/src/job.rs crates/worker/src/sweep.rs | wc -l; grep -rn "println!\|eprintln!\|format!" crates/worker/src/ | grep -c "expose()"
|
||||
EXPECT: 5 / 0
|
||||
9. The native Rust gate is green (fmt, clippy -D warnings, core + worker tests including the 11 job-loop tests, ts-rs export, cargo deny).
|
||||
CHECK: bash scripts/rust-check.sh > /tmp/rust-check-verify.log 2>&1; echo "exit $?"; grep -cE "^test result: ok" /tmp/rust-check-verify.log
|
||||
EXPECT: exit 0 / at least 6
|
||||
10. The browser never selects `*` on assets and never holds a service role reference.
|
||||
CHECK: grep -n "from('assets')" -A2 packages/supabase/src/assets.ts | grep -c "'\*'"; grep -rn "SERVICE_ROLE\|service_role" apps/app/src packages/supabase/src | grep -v database.types | wc -l
|
||||
EXPECT: 0 / 0
|
||||
11. The Node gate is green with the new tests (supabase package 37, app 300).
|
||||
CHECK: pnpm --filter @faunosteo/supabase test:run 2>&1 | grep -E "^ +Tests "; pnpm --filter @faunosteo/app test:run 2>&1 | grep -E "^ +Tests "; pnpm typecheck > /dev/null 2>&1 && pnpm lint > /dev/null 2>&1 && echo GATE_OK
|
||||
EXPECT: Tests 37 passed (37) / Tests 300 passed (300) / GATE_OK
|
||||
12. The avatar transport refuses SVG by content and the UI section exists with the mockup's elements (change, save, cancel, remove, processing), strings in both dictionaries.
|
||||
CHECK: grep -c "svg" apps/app/tests/unit/account.avatarTransport.test.ts; grep -c "'account.avatar\." apps/app/src/i18n/fr.ts; grep -c "'account.avatar\." apps/app/src/i18n/en.ts
|
||||
EXPECT: 4 / 29 / 29
|
||||
13. The compose worker service is hardened and opt-in (profile), reads its own env file, joins the external Supabase network.
|
||||
CHECK: grep -c 'profiles: \["worker"\]\|read_only: true\|cap_drop: \[ALL\]' docker-compose.yml; grep -c "\.env\.worker" docker-compose.yml; docker compose --profile worker config --no-interpolate 2>&1 | grep -c "container_name: faunosteo_worker"
|
||||
EXPECT: 3 / 1 / 1
|
||||
14. The real-stack end-to-end suite and its runner exist, typecheck, and are documented; the e2e is not part of the default vitest include.
|
||||
CHECK: test -f packages/supabase/tests/e2e/avatar-flow.e2e.ts && test -x scripts/avatar-e2e.sh && grep -c "e2e:avatar" package.json docs/development/STORAGE.md | tr '\n' ' '; grep -c "e2e" packages/supabase/vitest.config.ts
|
||||
EXPECT: package.json:1 docs/development/STORAGE.md:1 / 0
|
||||
15. Docs updated: STORAGE.md present; CLAUDE.md, DEPLOY.md, SUPABASE.md, RUST.md, TEST_STRATEGY.md, WORKSPACE.md, IDENTITY.md, docs/design/README.md and CHANGELOG.md reference the step.
|
||||
CHECK: for f in CLAUDE.md DEPLOY.md docs/development/SUPABASE.md docs/development/RUST.md docs/development/TEST_STRATEGY.md docs/development/WORKSPACE.md docs/development/IDENTITY.md docs/design/README.md CHANGELOG.md; do printf '%s:%s ' "$f" "$(grep -cE 'STORAGE.md|Step 8|avatar' "$f")"; done
|
||||
EXPECT: every count ≥ 1
|
||||
|
||||
## FILE SCOPE
|
||||
supabase/migrations/20261013100000_files_foundation.sql, supabase/tests/{001_schema,010_files_foundation}.sql, packages/supabase/{src,tests,package.json,vitest.e2e.config.ts}, apps/app/src/{account,components/account,components/shell,state/authStore.ts,i18n}, apps/app/tests, crates/worker/**, Cargo.toml, Cargo.lock, deny.toml, docker-compose.yml, scripts/avatar-e2e.sh, package.json, docs/**, CLAUDE.md, README.md, DEPLOY.md, CHANGELOG.md.
|
||||
Reference in new issue
Block a user