Home

# Command Center sync: database part (not live)

What it does
- Adds one table, command_center_boards: one row per signed-in person holding their whole board (projects, tasks, questions, decisions, builds, queue, notes) as one JSON block, plus a version number and a saved-at time.
- Every person sees and changes only their own row. Same for every role, leaders included. The database enforces it, not the screen. Nobody can delete a row, and anon gets nothing. The service key is granted nothing on it.
- Conflict check: stale-save detection only works if the browser sends "where version = <the version it started from>" on every save. That is the module's job and is tested there. A save from an older copy then changes nothing, and the browser reloads first.

What could break or lose data
- It adds a table and a trigger function. It does change one behavior on a shared table: the table points at auth.users with "on delete restrict", so deleting an account that has a saved board is refused. NAF-KET shares auth.users, so Matteo must be told at go-live.
- The Undo box removes the table and refuses while any board is saved, so no board is lost; boards must be copied out first.
- If a person edits on two devices at once, the second save is refused and that device must reload; merging unsaved edits is the module's job.
- A board is capped at 5 MB.

Tested
- Local Postgres 16 with stand-in Supabase roles and auth.uid(), never on Supabase. Install twice. Rules test: A cannot read, write, delete or take B's board, stale save refused, anon refused, a deliberately granted delete is caught, and with no free accounts it fails with a clear FAIL message. Undo refuses with a board saved and works twice when empty.

Not tested
- The real Supabase project, its real auth.uid() and default grants, or the website module.
- The rules test needs two accounts with no board yet; it writes, then rolls back (it is not read only).

Who built and checked it
- Built by a Sonnet helper under Julian's cost rule (no Opus), independently reviewed by the Fable reviewer. Flagged for Matteo at go-live because it decides who sees what.

Needs a yes from Julian or Matteo
- Running Box 1 on the real database (nothing is run yet), the on-delete-restrict behavior on auth.users, and "own board only, leaders included" as the standing rule.