Repository navigation
feat(doop): append-only page author ledger on every frame write (CHE-7082) [squash] - #70
Merged
Merged
Conversation
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.
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Nov 18, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to no response for status checks
Nov 18, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to no response for status checks
Nov 18, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to no response for status checks
Nov 19, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to no response for status checks
Nov 19, 2026
congvc-dev
previously approved these changes
Nov 19, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
CHE-7082, slice S3 of CHE-7064 (plan r3, D1.5): an append-only
page_authorsledger written on every frame mutation.0044_page_authors— D1.5 columns, unique keypage_authors_writer_uniq, indexpage_authors_page_idxon(canvas_id, page_id).createFrame,updateFrame,deleteFrameappend the writer row in the same tick, afterassertWritable, before the frame save is queued. A move (patch.pageId) writes the writer on both pages.system,user, oragent(only withverified+agentId+taskId); any other agent isunknown.store.backfillPageAuthors()fromserver/index.ts): every page that holds frames and has no row gets onelegacy/unknownrow. Idempotent.writePolicyscan test fails for anypage_authorswrite outsidestore.ts,db/persist.tsanddb/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 orflush()retries both (a deleted frame whose delete failed is retried byflush()with its rows). Tests:createFrame/updateFramecases intests/pageAuthors.test.tsand 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):
Green (same files, after the implementation):
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 --checkon changed files: clean. Pre-commit hook (oxlint, eslint, prettier): passed.rate-limit-wiring(timeout),legacyPagesMigration,claudeExtension, and puppeteer navigation timeouts in several*Browsertests. Re-run alone on this branch,rate-limit-wiring,legacyPagesMigration,claudeExtension,rulersBrowser,componentLayerLintandelementPanelBrowserpass. Not confirmed:elementContextMenuBrowserstill failed 1 test in a 5-file parallel run and was not re-run alone; the other*Browserfiles (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 cleanmain. CI is the check./verify(gstack-checks, includes a fullvite build) exceeded the 600 s foreground limit and was stopped; typecheck, lint and the targeted tests above were run by hand instead.vi.mock('../server/db/persist.ts')factories now includeappendPageAuthor.Out of scope / not done
source: 'copy') is left to S4. Only the column and kind exist here.design_card_guarduntouched.provider/modelonWriteContextare 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 --noEmitandoxlint --type-aware --deny-warningsclean.settlePageAuthorsis removed (rows ride the frame write); tests usepersist.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'andexpected [ '' ] 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-warningsclean.Rebase onto
main(plan r5 route, head 922576f)PR 71 (CHE-7062) took migration
0043_frame_pinsand addedsaveFrameNow. Mergedmain(1f728eb) into this branch; PR is[squash].server/db/persist.ts(keptsaveFrameNowfrom main, routed through the serial queuewriteFrame, so lock and unlock writes also carry pending ledger rows),server/index.ts(pin boot first, thenbackfillPageAuthors), migration journal and snapshot.drizzle-kit generate --name page_authorsafter taking main's journal:0044_page_authors.sqlis byte-identical to the old0043_page_authors.sql;0044_snapshot.jsonchains from0043_frame_pins.tsgo --noEmitexit 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).2e5b1ebdand the cancelled review on69a9392are stale.