Repository navigation
feat(runtime): make server mutations atomic and safe to retry - #432
Conversation
Astra reviewReviewed One pass, no subagents. Merge blockers only. StandardsNo merge-blocking method or YAGNI findings. The transaction owner, storage adapter, explicit retry path, and commit reconciliation address the requirements of this issue. SpecNo merge-blocking intent findings found. Verification run: pnpm exec vitest run --config vitest.postgres.config.ts \
packages/runtime/src/MutationTransaction.postgres.test.ts \
packages/runtime/src/MutationDisconnect.postgres.test.tsBoth files passed: 17 tests. These exercise real Postgres transaction behavior, key races at insert and commit, rollback, uncertain-commit recovery, dropped callers in all three handler kinds, and nested mutation database-time accounting. I did not rerun the full suite, typecheck, or lint. Summary: Standards 0 findings, no blocking issue; Spec 0 findings, no blocking issue. |
Opus reviewReviewed 1. A committed mutation can be reported
|
|
Addressed all three Opus findings in Fixed
Kept as is
Verification
CI harness correctionsThe first CI run exposed two test issues, not failures in the new commit/wake regressions:
Final statusThe harness corrections are pushed in All eight configured checks pass on latest head Refreshed the conversation comments, Reviews-tab bodies, and inline comments after CI completed. No additional findings or Grok review are present. All reported findings are addressed; none were dismissed as false positives. Not merged. |
1177d5f to
033c5b2
Compare
027bf0d to
5224203
Compare
…y before launch (#503) Before launch (#416) no database we need to keep exists, yet the platform record carried 15 migrations, and several tests and code paths existed only to upgrade databases built by older steps (decision O1 from the test audit). This squashes each capability into one baseline that builds exactly today's schema, and deletes the upgrade-only code and tests with it. - **One baseline per capability**, ids 1–8 in foreign-key order: companies, auth, patches, company_database, runtime, integrations, limits, execution. The names drop `_baseline`, so an old ledger can never match the new history by name. - **Faithfulness proof** (run outside the repo, `/tmp/lane-e-proof`): databases built from main's record and from this record have identical `pg_dump --schema-only`, identical data apart from the ledger, and an identical catalog listing (columns, defaults, constraints, indexes, functions, triggers, grants). That holds for the platform database, a Postgres company inventory and a PGlite company directory. - **The ledger guard** (`packages/sql`): `migrate` now refuses a ledger whose history differs from the record's, up to the lower of the two highest ids. The Migrator only applies ids above the ledger's highest, so a pre-squash database would otherwise silently skip the baselines and every future migration with an id up to 15. Ids above the record's highest still pass, so an older build can start after a newer one migrated (the rollback in OPERATIONS.md). The dev runner now writes the refusal to `dev.log`. - **Removed upgrade paths:** `Inventory.upgrade` and its calls in both `ensureReady`s, the mutation-key lookup's missing-table retry (added in #432 for databases created before mutation keys), and the upgrade-only tests: `runtime` and `patches` `migrations.test.ts`, the directory migration block, two inventory-upgrade tests, and an orphan-sweep case for retained inventories. Docs: DEVELOPMENT.md, `packages/sql` README and CONTEXT (new **Baseline** term), ADR-0003/0009/0012, product.md, API.md. **After this merges:** - Every existing local dev instance, in every worktree, needs `pnpm dev reset`, which wipes its local data. An instance that isn't reset refuses to start and says why in `dev.log`. - The disposable tier 2 spike database needs recreating before its next deploy. - `patchy dev` data in patch repos made by a CLI older than #449 needs `patchy dev reset`. Upgrade tests start again with the first migration that has to keep retained state. Made by Claude Opus 5.5 via Claude Code --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Tier 2 handlers could run queries and actions, but mutations had no atomic execution path or safe way to recover a lost reply.
Run mutations in host-owned SERIALIZABLE transactions with bounded conflict retries. Writes, mutation keys, results, and revisions commit together; explicit
retry()preserves the key and captured arguments. Nested mutations, disconnected-client cleanup, database-time accounting, and late-commit reconciliation are covered. Includes migration0012_runtime_mutation_commit_proofand the API, ADR, and skill updates. Tier 2 publishing remains refused.Stacked on
tier2/399-metering; this PR targets that branch and contains only the #400 changes.Closes #400.
Verification
pnpm typecheckandpnpm lintpassed.pnpm test: 1,375 tests passed.pnpm test:postgres-concurrency: 24 tests passed, including mutation races and disconnect cleanup.Authored with GPT-6 Astra in the omp harness.