FORGE-88: BATCH and READ sites on atomic() (Phase 3 step 3) #736
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
gmackie/ForgeGraph!736
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "FORGE-88-read-evidence"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
FORGE-88 step 3 of 7 (FORGE-69 D1 migration, Phase 3): the BATCH and READ sites move from
db.transaction()toatomic()(#720). There are three commits, grouped by area; review them commit by commit.insertInChunks(), work-itemaddArtifactand rollbackcreatewith pre-generated ids.overrideWorkItemStatus()touches the row first (a row lock on Postgres), so the activity'sfromValueis the status actually overwritten. In the race test, 8 concurrent overrides produce one consistent chain; with the touch removed, all 8 recordfromValue = draft.loadEffectiveEvidencereads its nine queries as one snapshot batch:atomic(..., { snapshot: true }), which is REPEATABLE READ, READ ONLY on Postgres. The latest-per-group reads use the new lazylatestPerGroupQuery(), and id lists go throughinList(), so a page over 100 ids stays one parameter on D1.retryOnAssertion()for a concurrent first insert.Adapter additions:
insertInChunks,rawStatement,rawRows,retryOnAssertion,atomic(..., { snapshot }).atomic()now accepts any thenable, so route test doubles keep working.Unique indexes for T18/T40 (one current artifact) and T28 (test_artifacts) need production duplicate checks and land with the GUARD/UNIQUE step. work_item_artifacts has 1 duplicate group, and its repair is awaiting approval.
Tests
atomic-batch-sites.database.test.ts(T11, T16 with 40 nodes and an all-or-nothing failure, T18, T21, T1 with 151 ids) andevidence-batch.database.test.ts(T27, plus T28 with 30 chunked artifacts).work-item-status.concurrency.test.ts(T38).tscare clean.Remaining: step 4 GUARD sites (4a stacked on this PR), 5 RepositoryCoordinator DO, 6 deploy route guards, 7 lint.
🤖 Generated with Claude Code
Phase 3 step 3c (FORGE-69 inventory T1, T27, T28). - T1 loadEffectiveEvidence: the nine reads are one atomic() batch with the new { snapshot: true } option (REPEATABLE READ, READ ONLY on Postgres; a batch is already a snapshot on D1). latestHeadBuilds/TestRuns/Reviews use latestPerGroupQuery(), the unexecuted form of latestPerGroup(), so they can join the batch; awaiting them still works. Changeset id lists go through inList(), so a page over 100 ids stays one parameter on D1. - T27/T28 evidence route: build (by run_id) and test-run (by source + external_run_id) upserts, their artifacts and the timeline event commit in one batch. A conflict keeps the existing row id, so the id is read first and asserted inside the batch; a concurrent first insert fails the assertion and retryOnAssertion() re-reads the winner's id. Artifacts are chunked by insertInChunks(); recordActivity() runs after the commit, as it always wrote outside the transaction. Adapter: atomic(db, build, { snapshot }), rawRows(b, sql) for raw statements whose rows you need, and retryOnAssertion(). The test_artifacts unique index (T28 bug) needs a production duplicate count first and lands with the GUARD/UNIQUE step. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>0bb6c525304d9d75cb1c4d9d75cb1c79bdb54e2bPreview environment is live: https://pr-736-forgegraph.forgegraf.com
Deployed
79bdb54ewith the beta stage's environment. It redeploys on every push and is destroyed when this PR closes.