FORGE-88: guard readiness transitions, bootstrap and manual receipts (Phase 3 step 4b) #740

Merged
gmackie merged 1 commit from FORGE-88-guards-b into main 2026-10-12 08:13:10 +00:00
Owner

FORGE-88 step 4b (FORGE-69 D1 migration, Phase 3): GUARD conversions on top of main, independent of #736/#737.

  • T5 readiness verdict → outbox intent. One atomic() batch: a conditional verdict UPDATE stamps a new work_item_links.readiness_token, an assertion checks our token, then the outbox row is inserted. A caller whose UPDATE matched nothing aborts before writing an intent. Race coverage comes from the existing notification-outbox.concurrency.test.ts (two concurrent initial transitions → one intent), which fails if the assertion checks the verdict instead of the token. Migration 0123 (ADD COLUMN IF NOT EXISTS readiness_token).
  • T35 bootstrap. A permanent resource_locks marker plus NOT EXISTS (users) makes the first-admin batch exclusive. Any other request aborts and leaves no admin, token or marker; a database test checks this. Before, two parallel requests could both count zero users and both insert.
  • Kanbanger manual-deploy receipts. This is an inventory addition: FORGE-86 added FOR UPDATE on deployment_targets after the T1–T43 doc was written. A replay is answered from its fixed-identity row. A new invocation runs: assert nothing newer serves the lane, retire the server, insert. A stale receipt aborts, and a racing one hits the primary key or deployment_active_unique_idx; both are answered from what was recorded.
  • classifyDbError() (from #706) now recognises CHECK violations: Postgres 23514, and SQLite CHECK constraint failed: <name>, plain or D1-wrapped. atomic() uses it to detect assertInBatch() failures.
  • atomic() accepts any thenable. This is the same hunk as in #736, so it merges cleanly in either order.

Local, on real Postgres 17: api database lane 49 files / 372 tests, concurrency lane 18/18, web database lane 13 files / 53 tests, web unit 256 files / 1771 tests, db unit 128. api, db and web tsc are clean.

🤖 Generated with Claude Code

FORGE-88 step 4b (FORGE-69 D1 migration, Phase 3): GUARD conversions on top of main, independent of #736/#737. - **T5 readiness verdict → outbox intent.** One `atomic()` batch: a conditional verdict UPDATE stamps a new `work_item_links.readiness_token`, an assertion checks our token, then the outbox row is inserted. A caller whose UPDATE matched nothing aborts before writing an intent. Race coverage comes from the existing `notification-outbox.concurrency.test.ts` (two concurrent initial transitions → one intent), which fails if the assertion checks the verdict instead of the token. Migration **0123** (`ADD COLUMN IF NOT EXISTS readiness_token`). - **T35 bootstrap.** A permanent `resource_locks` marker plus `NOT EXISTS (users)` makes the first-admin batch exclusive. Any other request aborts and leaves no admin, token or marker; a database test checks this. Before, two parallel requests could both count zero users and both insert. - **Kanbanger manual-deploy receipts.** This is an inventory addition: FORGE-86 added `FOR UPDATE` on `deployment_targets` after the T1–T43 doc was written. A replay is answered from its fixed-identity row. A new invocation runs: assert nothing newer serves the lane, retire the server, insert. A stale receipt aborts, and a racing one hits the primary key or `deployment_active_unique_idx`; both are answered from what was recorded. - **`classifyDbError()`** (from #706) now recognises CHECK violations: Postgres 23514, and SQLite `CHECK constraint failed: <name>`, plain or D1-wrapped. `atomic()` uses it to detect `assertInBatch()` failures. - **`atomic()` accepts any thenable.** This is the same hunk as in #736, so it merges cleanly in either order. Local, on real Postgres 17: api database lane 49 files / 372 tests, concurrency lane 18/18, web database lane 13 files / 53 tests, web unit 256 files / 1771 tests, db unit 128. api, db and web `tsc` are clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
FORGE-88: guard readiness transitions, bootstrap and manual receipts; classify CHECK violations
All checks were successful
CI / gitleaks (pull_request) Successful in 18s
CI / unit-api (pull_request) Successful in 2m13s
CI / unit-web (pull_request) Successful in 3m50s
CI / storybook (pull_request) Successful in 2m10s
CI / go (pull_request) Successful in 1m26s
CI / checks (pull_request) Successful in 2m21s
CI / database (pull_request) Successful in 3m29s
CI / web-build (pull_request) Successful in 4m5s
forgegraph/ci CI passed
CI / ci (pull_request) Successful in 58s
b529fdafe0
Phase 3 step 4b (FORGE-69 inventory T5, T35, and the kanbanger receipts lock
that FORGE-86 added after the inventory was written).

- T5 persistReadinessNotification: one atomic batch [conditional verdict
  UPDATE that stamps work_item_links.readiness_token; assert our token;
  outbox insert]. A caller whose UPDATE matched nothing aborts before writing
  an outbox row. The existing concurrency test (two initial transitions, one
  intent) fails when the assertion checks the verdict instead of the token.
  Migration 0123 adds readiness_token.
- T35 bootstrap: a permanent resource_locks marker plus an assertion that no
  user exists make the first-admin batch exclusive; any other request aborts
  and leaves no admin, token or marker. Before, two parallel requests could
  both count zero users.
- kanbanger receipts (FOR UPDATE on deployment_targets): a replay is answered
  from its fixed-identity row; a new invocation runs [assert nothing newer
  serves the lane; retire the server; insert]. A stale receipt aborts and a
  racing one hits the primary key or deployment_active_unique_idx, and both
  are answered from what was recorded.
- classifyDbError() now recognises CHECK violations (Postgres 23514, SQLite
  "CHECK constraint failed: <name>"), and atomic() detects assertion failures
  through it.
- atomic() accepts any thenable (the same change as step 3), so route test
  doubles work here too.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
gmackie force-pushed FORGE-88-guards-b from b529fdafe0
All checks were successful
CI / gitleaks (pull_request) Successful in 18s
CI / unit-api (pull_request) Successful in 2m13s
CI / unit-web (pull_request) Successful in 3m50s
CI / storybook (pull_request) Successful in 2m10s
CI / go (pull_request) Successful in 1m26s
CI / checks (pull_request) Successful in 2m21s
CI / database (pull_request) Successful in 3m29s
CI / web-build (pull_request) Successful in 4m5s
forgegraph/ci CI passed
CI / ci (pull_request) Successful in 58s
to fe7361feb0
Some checks failed
CI / superseded (pull_request) Successful in 2s
CI / gitleaks (pull_request) Successful in 19s
CI / go (pull_request) Successful in 1m20s
CI / storybook (pull_request) Successful in 1m47s
CI / web-build (pull_request) Successful in 2m12s
CI / unit-api (pull_request) Successful in 2m18s
CI / unit-web (pull_request) Successful in 2m56s
CI / database (pull_request) Successful in 3m8s
CI / checks (pull_request) Successful in 3m50s
forgegraph/ci CI passed
CI / ci (pull_request) Successful in 44s
CI / database-d1 (pull_request) Failing after 7m7s
2026-10-12 06:56:09 +00:00
Compare
gmackie force-pushed FORGE-88-guards-b from fe7361feb0
Some checks failed
CI / superseded (pull_request) Successful in 2s
CI / gitleaks (pull_request) Successful in 19s
CI / go (pull_request) Successful in 1m20s
CI / storybook (pull_request) Successful in 1m47s
CI / web-build (pull_request) Successful in 2m12s
CI / unit-api (pull_request) Successful in 2m18s
CI / unit-web (pull_request) Successful in 2m56s
CI / database (pull_request) Successful in 3m8s
CI / checks (pull_request) Successful in 3m50s
forgegraph/ci CI passed
CI / ci (pull_request) Successful in 44s
CI / database-d1 (pull_request) Failing after 7m7s
to bf072d227f
Some checks failed
CF executor smoke / smoke (pull_request) Successful in 20s
CI / superseded (pull_request) Successful in 2s
CI / go (pull_request) Successful in 1m26s
CI / gitleaks (pull_request) Successful in 16s
CI / checks (pull_request) Successful in 1m57s
CI / storybook (pull_request) Successful in 2m16s
CI / unit-api (pull_request) Successful in 1m25s
CI / web-build (pull_request) Successful in 3m2s
CI / database (pull_request) Successful in 3m25s
CI / unit-web (pull_request) Successful in 2m31s
forgegraph/ci CI passed
CI / ci (pull_request) Successful in 37s
CI / database-d1 (pull_request) Failing after 7m9s
2026-10-12 07:42:51 +00:00
Compare
gmackie force-pushed FORGE-88-guards-b from bf072d227f
Some checks failed
CF executor smoke / smoke (pull_request) Successful in 20s
CI / superseded (pull_request) Successful in 2s
CI / go (pull_request) Successful in 1m26s
CI / gitleaks (pull_request) Successful in 16s
CI / checks (pull_request) Successful in 1m57s
CI / storybook (pull_request) Successful in 2m16s
CI / unit-api (pull_request) Successful in 1m25s
CI / web-build (pull_request) Successful in 3m2s
CI / database (pull_request) Successful in 3m25s
CI / unit-web (pull_request) Successful in 2m31s
forgegraph/ci CI passed
CI / ci (pull_request) Successful in 37s
CI / database-d1 (pull_request) Failing after 7m9s
to edca74f691
Some checks failed
CI / superseded (pull_request) Successful in 1s
CI / gitleaks (pull_request) Successful in 16s
CI / go (pull_request) Successful in 58s
CI / web-build (pull_request) Successful in 1m49s
CI / unit-api (pull_request) Successful in 2m2s
CI / storybook (pull_request) Successful in 2m7s
CI / database (pull_request) Successful in 2m37s
CI / unit-web (pull_request) Successful in 3m2s
CI / checks (pull_request) Successful in 3m11s
forgegraph/ci CI passed
CI / ci (pull_request) Successful in 42s
CI / database-d1 (pull_request) Failing after 6m1s
2026-10-12 07:59:33 +00:00
Compare
Sign in to join this conversation.
No description provided.