Skip to content

feat(doop): append-only page author ledger on every frame write (CHE-7082) [squash] - #70

Merged
congvc-bot-x99[bot] merged 6 commits into
mainfrom
agent/tofu/che-7082-c5581e5e27f5
Nov 25, 2026
Merged

congvc-bot-x99[bot] merged 6 commits into
mainfrom
agent/tofu/che-7082-c5581e5e27f5

Conversation

@congvc-bot-x99

@congvc-bot-x99 congvc-bot-x99 Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

What

CHE-7082, slice S3 of CHE-7064 (plan r3, D1.5): an append-only page_authors ledger written on every frame mutation.

  • Drizzle migration 0044_page_authors — D1.5 columns, unique key page_authors_writer_uniq, index page_authors_page_idx on (canvas_id, page_id).
  • createFrame, updateFrame, deleteFrame append the writer row in the same tick, after assertWritable, before the frame save is queued. A move (patch.pageId) writes the writer on both pages.
  • Kind comes from the write context, never from client text: system, user, or agent (only with verified + agentId + taskId); any other agent is unknown.
  • One-time boot backfill (store.backfillPageAuthors() from server/index.ts): every page that holds frames and has no row gets one legacy / unknown row. Idempotent.
  • writePolicy scan test fails for any page_authors write outside store.ts, db/persist.ts and db/schema.ts.

Persist path that makes "row no later than the frame" true

Pending ledger rows are keyed by frame in server/db/persist.ts (pendingAuthors). Every frame write and delete runs on one serial queue (serial); each job takes the rows pending for its frame in the same tick it reads the frame, and commits them in ONE transaction with the frame upsert or delete (withAuthors). So the row is durable exactly when the frame state is, never later. A failed commit rolls both back and puts the rows back; the next write or flush() retries both (a deleted frame whose delete failed is retried by flush() with its rows). Tests: createFrame/updateFrame cases in tests/pageAuthors.test.ts and a real restart on the same pglite dir (tests/pageAuthorsRestart.test.ts).

Test-first evidence

Red (observed before the writer was wired; every failure is an assertion on an empty ledger, not a compile error):

 ❯ tests/pageAuthors.test.ts (19 tests | 16 failed)
     × createFrame appends the writer to the frame page
     × updateFrame appends the writer, for any field
     × deleteFrame appends the writer to the page the frame was on
     × a frame moved to another page puts the writer on both pages
     × the same writer twice is one row; a second task is a second row
     × agent with a verified task / signed-in member / the server itself
     × agent over MCP with no task / agent with no task / verified flag without agent or task ids
     × createFrame: the moment the frame row is readable, the ledger row is
     × updateFrame: a flush writes the frame and its ledger row
     × boot backfill: gives each page … one legacy unknown row, once
     × boot backfill: a frame with no page id counts for the first page
     × the scan really sees a writer
 ❯ tests/pageAuthorsRestart.test.ts (1 test | 1 failed)
     × keeps the writer row across a restart and backfills once
 AssertionError: expected [] to deeply equal [ { kind: 'agent', … } ]   (x several)
 Test Files  2 failed (2)
      Tests  17 failed | 3 passed (20)

Green (same files, after the implementation):

 Test Files  2 passed (2)
      Tests  20 passed (20)

Coverage maps to the acceptance list: one case per mutator (create, update, delete, move), one per kind (agent, user, system, unknown ×3), backfill + idempotence, restart on the same pglite, and the scan.

Other checks

  • tsgo --noEmit: exit 0. oxlint --type-aware --deny-warnings .: exit 0. prettier --check on changed files: clean. Pre-commit hook (oxlint, eslint, prettier): passed.
  • Full suite in 4 shards. Failures: rate-limit-wiring (timeout), legacyPagesMigration, claudeExtension, and puppeteer navigation timeouts in several *Browser tests. Re-run alone on this branch, rate-limit-wiring, legacyPagesMigration, claudeExtension, rulersBrowser, componentLayerLint and elementPanelBrowser pass. Not confirmed: elementContextMenuBrowser still failed 1 test in a 5-file parallel run and was not re-run alone; the other *Browser files (elementResize, interactionsPanel, pageCanvas, prototype, drawing) were not re-run alone. None of them touch the ledger path; I have not proven they pass or that they fail on clean main. CI is the check.
  • /verify (gstack-checks, includes a full vite build) exceeded the 600 s foreground limit and was stopped; typecheck, lint and the targeted tests above were run by hand instead.
  • 14 existing test files got one line each: their vi.mock('../server/db/persist.ts') factories now include appendPageAuthor.

Out of scope / not done

  • Copy inheritance of the ledger (source: 'copy') is left to S4. Only the column and kind exist here.
  • No G5 lock/pin, no C00 config/secret/build/deploy, no write to a real doop canvas, design_card_guard untouched.
  • provider/model on WriteContext are optional and populated only when a verified task assertion sets them.

Refs CHE-7082. Parent CHE-7064.

Review round 1 fix (head c24d955)

Cross-lab CHANGES (x99-codex-terra, head 9c5707c): two P1 failure-path findings (failed insert swallowed and hidden by a later append; delete and in-flight update not coupled to their writer rows). Fixed by the transactional coupling above.

New tests/pageAuthorsFailure.test.ts (failure injected with a pglite trigger that raises on one writer's insert).

Red (before the fix, same test file): Tests 3 failed | 1 passed (4). Failing: failed insert on an update leaves the frame durable without its row (expected ['v1'] to deeply equal ['v0']); failed insert on a delete still deletes the frame (expected [] to deeply equal ['v0']); delete behind a pending update leaves the frame (expected ['v1'] to deeply equal []). The in-flight ordering case is green on old code too: pglite serialises queries, so the old ordering is not observable; it stays as a regression guard.

Green (after the fix): Test Files 6 passed (6) / Tests 103 passed (103) for pageAuthorsFailure, pageAuthors, pageAuthorsRestart, writePolicy, frameVersionBursts, storePages, stable over 3 reruns; 27 persist/flush-touching non-browser test files: 265 passed. tsgo --noEmit and oxlint --type-aware --deny-warnings clean.

settlePageAuthors is removed (rows ride the frame write); tests use persist.flush.

Review round 2 fix (head 69a9392)

Cross-lab CHANGES (head c24d955): P1, flush() did not wait for a save already running, so SIGTERM could exit before its transaction committed, and a job failing after the snapshot was never retried. Fix: flush() awaits the frame queue first, then snapshots timers and pending rows, then logs any failed flush job.

Red (c24d955 flush, same tests): Tests 2 failed | 4 passed (6): expected [ '' ] to include 'u-inflight' and expected [ '' ] to include 'u-late-fail'. Both cases delay or fail the transaction in JS (pglite runs on the main thread, so a SQL sleep freezes the test).

Green: Test Files 6 passed (6) / Tests 105 passed (105) (pageAuthorsFailure, pageAuthors, pageAuthorsRestart, writePolicy, frameVersionBursts, storePages), 3 reruns. tsgo --noEmit, oxlint --type-aware --deny-warnings clean.

Rebase onto main (plan r5 route, head 922576f)

PR 71 (CHE-7062) took migration 0043_frame_pins and added saveFrameNow. Merged main (1f728eb) into this branch; PR is [squash].

  • Conflicts resolved: server/db/persist.ts (kept saveFrameNow from main, routed through the serial queue writeFrame, so lock and unlock writes also carry pending ledger rows), server/index.ts (pin boot first, then backfillPageAuthors), migration journal and snapshot.
  • Migration regenerated with drizzle-kit generate --name page_authors after taking main's journal: 0044_page_authors.sql is byte-identical to the old 0043_page_authors.sql; 0044_snapshot.json chains from 0043_frame_pins.
  • Observed on this head: tsgo --noEmit exit 0; bun run lint (oxlint + eslint) exit 0; vitest run tests/pageAuthors tests/writePolicy tests/frameLock tests/storePages: Test Files 9 passed (9) / Tests 182 passed (182).
  • Earlier red/green evidence above stands; the rebase added no new behavior. Full required checks run in CI on this head. A new cross-lab review on this exact head is required; the PASS on 2e5b1ebd and the cancelled review on 69a9392 are stale.

congvc-bot[bot] added 3 commits November 18, 2026 05:27
…7082)

Add page_authors (migration 0042). createFrame, updateFrame and deleteFrame append the
writer row after assertWritable and before the frame save is queued. The ledger runs on one
serial queue that writeFrame and flush await, so the row lands no later than the frame.
Kind comes from the write context; an unverified agent is unknown. A boot backfill gives
every page with frames and no row one legacy unknown row.
@congvc-bot-x99 congvc-bot-x99 Bot changed the title feat(doop): append-only page author ledger on every frame write (CHE-7082) feat(doop): append-only page author ledger on every frame write (CHE-7082) [squash] Nov 17, 2026
@congvc-bot-x99
congvc-bot-x99 Bot marked this pull request as ready for review November 17, 2026 23:07
@congvc-bot-x99
congvc-bot-x99 Bot requested a review from congvc-dev November 17, 2026 23:08
@congvc-dev
congvc-dev added this pull request to the merge queue Nov 18, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 18, 2026
@congvc-bot-x99
congvc-bot-x99 Bot marked this pull request as draft November 18, 2026 03:23
@congvc-bot-x99
congvc-bot-x99 Bot marked this pull request as ready for review November 18, 2026 05:20
@congvc-dev
congvc-dev added this pull request to the merge queue Nov 18, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Nov 18, 2026
@congvc-dev
congvc-dev added this pull request to the merge queue Nov 18, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Nov 18, 2026
@congvc-dev
congvc-dev added this pull request to the merge queue Nov 19, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Nov 19, 2026
@congvc-dev
congvc-dev added this pull request to the merge queue Nov 19, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Nov 19, 2026
@congvc-dev
congvc-dev added this pull request to the merge queue Nov 19, 2026
congvc-dev
congvc-dev previously approved these changes Nov 19, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 19, 2026
@congvc-bot-x99
congvc-bot-x99 Bot marked this pull request as draft November 24, 2026 17:18
@congvc-bot-x99
congvc-bot-x99 Bot marked this pull request as ready for review November 24, 2026 17:28
@congvc-bot-x99
congvc-bot-x99 Bot merged commit 9eec359 into main Nov 25, 2026
12 of 14 checks passed
@congvc-bot-x99
congvc-bot-x99 Bot deleted the agent/tofu/che-7082-c5581e5e27f5 branch November 25, 2026 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant