diff --git a/.claude/memory/blockers.md b/.claude/memory/blockers.md index 4be75453..c21193b2 100644 --- a/.claude/memory/blockers.md +++ b/.claude/memory/blockers.md @@ -57,4 +57,4 @@ Status: resolved (commit 990c8e7). Friction: `supabase start` → "permission denied … /var/run/docker.sock"; daemon up (`docker info` client OK), user not in `docker` group. No psql/postgres on host either. Root: host group membership; needs `sudo usermod -aG docker $USER` + re-login (user runs, not Claude). Workaround: PGlite harness (BDR-028) executes migrations + 81 pgTAP checks; CLI config parses (`supabase start` fails only at Docker inspect). -Status: open — real-stack run (`pnpm db:start && pnpm db:test && pnpm db:types:check`, manual curl script SUPABASE.md §8) pending user Docker access or CI runner. +Status: resolved 2026-10-08 (same day) — user added docker group; `supabase start` pulled postgres 17.11.0.004, applied 3 migrations + seed; `supabase test db` 81/81 after scoping counts to fixture ids (seed rows broke 6 absolute counts, PGlite had no seed); `gen types` adopted (CLI output unformatted → piped through prettier); REST script §8 matched expectations; `db reset` from zero OK. diff --git a/.claude/memory/evals.md b/.claude/memory/evals.md index 3a3d6ebd..02aa2d67 100644 --- a/.claude/memory/evals.md +++ b/.claude/memory/evals.md @@ -49,3 +49,10 @@ Method: 4 pgTAP files (81 checks: schema/privileges 24, profiles RLS 17, platfor Result: all green first run except plan count (27→28) and pgtap-in-public polluting function census; 278 app + 13 package tests. Zero app behaviour change. Anomalies: `set_config` rows appear in TAP line capture (noise, filtered by regex). `now()` constant in tx broke naive updated_at>created_at assertion. Action: LRN-035/036. Not executed: real Supabase image (`supabase test db`), `gen types` diff, seed.sql (needs auth.identities + extensions.crypt), REST manual script. Flagged in report + BLK-006. + +## EVAL-007 | 2026-10-08 | Step 3 on the real Supabase stack + +Method: `supabase start` (postgres 17.11.0.004), `supabase test db`, `gen types --local` diff, REST curl script (SUPABASE.md §8) with seed users, psql on audit, `db reset`. +Result: migrations + seed apply from zero; pgTAP 81/81 after fix; REST: alice 1 row, anon 42501, self-deactivate 42501 (column grant), self-grant 42501 (RPC message), cross-row PATCH 0 rows, owner grant → uuid, alice sees her role, owner reads 3 profiles; audit shows system bootstrap + owner grant. +Anomalies: (1) 6 pgTAP counts assumed empty DB — seed rows on real stack (PGlite runs no seed) → scoped to fixture ids + neutralise foreign owners before last-owner test. (2) CLI gen output unformatted + `ComputedFields: never`, no `__InternalSupabase` → hand-written file replaced by generated+prettier; scripts pipe prettier. PGlite harness had hidden both: environment parity gap, not logic gap. +Action: LRN-037 (tests must be seed-agnostic; generated files via deterministic formatter). BLK-006 resolved. diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index 552acb16..0b7efb3e 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -176,3 +176,4 @@ SaaS migration kickoff. Step 0: 8 docs in docs/development/ (27-step plan, domai ## 2026-10-08 (session 3 — Step 3) Step 3 Supabase foundation on feature/step-03-supabase-foundation (9 commits, pushed). Docker socket denied (BLK-006) → PGlite+pgtap harness (BDR-028). 3 migrations: foundation (private/audit, set_updated_at, append-only audit_logs, log_event), profiles (auth trigger, own-row RLS, column grants), platform_roles (4-value enum BDR-026, RPC-only writes audited BDR-027, helpers hierarchy). 81 pgTAP checks allowed+denied; packages/supabase (client PKCE, types in gen format BDR-029, schema↔types test); app env.supabase null-safe, lib/supabase.ts, entrypoint/env.example; CI supabase job; SUPABASE.md. 278+13 tests, typecheck/lint/build green. Not run: real stack, gen types, seed. LRN-035/036, EVAL-006. Next: user validation; Step 4 (sheet model) parallelizable; Docker access for real-stack proof. +- Same day, Docker access granted by user: real stack up, pgTAP 81/81 after seed-agnostic fix, gen types adopted (prettier pipe), REST script verified, db reset OK. BLK-006 resolved, EVAL-007, LRN-037. Branch still awaiting user validation before finish. diff --git a/.claude/memory/learnings.md b/.claude/memory/learnings.md index b723b66d..8a3e34b9 100644 --- a/.claude/memory/learnings.md +++ b/.claude/memory/learnings.md @@ -281,3 +281,10 @@ Apply: any Supabase project needing SQL tests in CI without Docker. Hosted/local Supabase: `alter default privileges … grant all on tables/functions to anon, authenticated, service_role`. New table or RPC = anon can SELECT/EXECUTE until revoked (RLS still filters rows, but RPC runs). Pattern per migration: `revoke all on from public, anon, authenticated;` then exact grants (column-level for partial UPDATE); `revoke all on function … from public, anon`. Also Postgres default EXECUTE to PUBLIC on functions in own schemas → `alter default privileges in schema private revoke execute on functions from public`. Shim replicates defaults so pgTAP `has_table_privilege('anon',…)` catches omissions. Apply: every migration; pin with pgTAP privilege checks. + +--- + +## LRN-037 | 2026-10-08 | SQL tests seed-agnostic; generated files through a deterministic formatter + +Real stack applies `seed.sql` before `supabase test db`; PGlite harness applies migrations only → absolute `count(*)` and "last owner" assertions passed on PGlite, failed on real stack (6/81). Fix: filter every count by fixture ids; neutralise foreign rows inside the rolled-back tx before invariants like "last owner". `supabase gen types` (CLI 2.120) emits unformatted TS and suggests oxfmt → pipe through project prettier in both `db:types` and `db:types:check`, else CI diff flaps. +Apply: any dual-runner test setup (shim vs real); any CI diff on generated code. diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index bdc572dd..18c0c298 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -49,7 +49,7 @@ feat/findings-tree-v2 merged (FindingsTreePicker tracked in HEAD); all work belo - [x] Step 0 — preparation docs in docs/development/ (2026-10-08, validated) - [x] Step 1 — characterisation tests: 7 files / 91 cases, 2 golden fixtures, docs/development/CHARACTERIZATION_REPORT.md; 271/271, typecheck, lint, build green (2026-10-08, branch feature/step-01-characterisation-tests, awaiting validation) - [x] Step 2 — monorepo workspace: apps/app via git mv (144 files), root scripts, Node 24 + pnpm 10.13.1 pins, Dockerfile node:24 + filtered build, CI .gitea/workflows/ci.yml, WORKSPACE.md; 271/271, typecheck, lint, build green from root (2026-10-08, branch feature/step-02-monorepo-workspace, uncommitted, awaiting validation) -- [x] Step 3 — Supabase foundation (2026-10-08, branch feature/step-03-supabase-foundation, awaiting validation; real-stack run pending Docker access BLK-006) +- [x] Step 3 — Supabase foundation (2026-10-08, branch feature/step-03-supabase-foundation, awaiting validation; real stack verified: start/reset, pgTAP 81/81, gen types diff, REST script — BLK-006 resolved) - [x] 3.0 context: plan Step 3, BACKEND_ARCHITECTURE §2-§9, business §4.1/§17/§29; Docker socket denied to user → PGlite harness as executable proof, pgTAP kept for `supabase test db` - [x] 3.1 supabase/config.toml (CLI pinned as root devDependency) + `supabase/seed.sql` (local users only) - [x] 3.2 migration 0001 foundation: schemas private/audit, set_updated_at, audit.audit_logs append-only, private.log_event diff --git a/docs/development/SUPABASE.md b/docs/development/SUPABASE.md index 2f1851bb..ae9b6312 100644 --- a/docs/development/SUPABASE.md +++ b/docs/development/SUPABASE.md @@ -71,7 +71,9 @@ Seed accounts (local only, password `LocalDev-only-password-1`): `revoke all ... from public, anon, authenticated` then the exact grants, separate SELECT / INSERT / UPDATE / DELETE policies, indexes, comments. 3. Add or extend a pgTAP file under `supabase/tests/`: the allowed path and - every denied path (other user, anon, direct write bypassing an RPC). + every denied path (other user, anon, direct write bypassing an RPC). Scope + counts to the fixture ids: on the real stack the seed accounts exist, in + PGlite they do not. 4. `pnpm --filter @faunosteo/supabase test:run` (PGlite, seconds), then `pnpm db:reset && pnpm db:test` on the real stack. 5. `pnpm db:types` and commit `packages/supabase/src/database.types.ts`. @@ -109,8 +111,10 @@ pnpm db:types # regenerate packages/supabase/src/database.types.ts (loc pnpm db:types:check # CI: fail on any diff ``` -The schema-types test checks tables, columns, enum labels and RPC argument -names against the migrated schema, so a stale file fails before CI. +The CLI emits unformatted TypeScript; both scripts pipe it through Prettier +(repo config) so the committed file is stable byte for byte. The schema-types +test checks tables, columns, enum labels and RPC argument names against the +migrated schema, so a stale file fails before CI. ## 7. First platform owner in a real environment