4.3 KiB
4.3 KiB
Tasks — @suaveplan/api-2pc
Every checkbox MUST reflect work actually done in this change.
0. Pre-flight (non-negotiable)
- 0.1 Confirm clean working tree (
git statusreports nothing) and no in-flight worktrees with uncommitted work (git worktree listthengit statusin each) - 0.2 If any worktrees exist under
.claude/worktrees/, account for each one: still-active agent, work-pending-merge, or stale-and-prune. Stale worktrees MUST be removed (git worktree remove) before opening a new one — code that has been lost twice on main is the failure mode this guards against. - 0.3 Confirm the package set in
MANIFEST.mdmatchesfind packages -maxdepth 3 -name package.jsoncount. Drift here means a prior change archived without regenerating the manifest.
1. Spec authoring
- 1.1 Read design doc §9.2 (2PC) and §9.3 (engine choice)
- 1.2 Read umbrella
openspec/changes/api-plugin-foundation/proposal.md(Stage 6 acceptance) - 1.3 Read
openspec/AGENTS.mdSections 13 and 14 - 1.4 Draft
proposal.mdfromopenspec/templates/proposal.md - 1.5 Draft
specs/api-2pc/spec.mdfromopenspec/templates/spec-delta.md - 1.6 Every requirement carries a
**Verified by:**line
2. Implementation
- 2.1 Scaffold
packages/api/api-2pc/("version": "0.1.0","sideEffects": false) - 2.2
src/coordinator/coordinator.ts—createTwoPcCoordinator+run2pc - 2.3
src/registry/participant-registry.ts— refusal of non-preparable engines as writers, read-only voter path - 2.4
src/phases/prepare.ts— Phase 1: collect votes; emit2pc.preparespans + histogram - 2.5
src/phases/commit.ts— Phase 2 commit:COMMIT PREPAREDagainst every participant; emit2pc.commitinstruments - 2.6
src/phases/rollback.ts— Phase 2 abort path:ROLLBACK PREPAREDeverywhere; idempotent - 2.7
src/persistence/persistence.ts— CRUD oversuaveplan_2pc_transactions(schema owned byapi-host) - 2.8
src/recovery/recovery.ts— boot-time orphan resolution viapg_prepared_xacts; commit / rollback per ledger state - 2.9
src/limits/outstanding-cap.ts— enforce default 256 outstanding-prepared cap; configurable via host config - 2.10
src/limits/timeout-ceiling.ts— refusetimeoutMs > 30000at call time - 2.11
src/instruments/instruments.ts— span/counter/histogram/gauge per design §9.2 - 2.12
src/error-codes.ts— 10TWOPC_*codes - 2.13
./testingsubpath —run2pcParticipantConformance - 2.14
src/index.ts— explicit named re-exports
3. Tests
- 3.1 Unit tests per module, every
it(...){ timeout: 5000 } - 3.2
src/coordinator/coordinator.spec-conformance.test.ts— conformance suite - 3.3
src/recovery/recovery.test.ts— Postgres integration via@suaveplan/testing-integration-postgres({ timeout: 30000 }) - 3.4
tests/integration/postgres-2pc.test.ts— full commit + abort + recovery ({ timeout: 60000 }) - 3.5 All test files import runner primitives from
@suaveplan/testing/runner
4. Documentation
- 4.1 Sibling
.mdfor every implementation.ts - 4.2
README.mdlisting## Modules; call out the Postgres-only writer constraint at the top
5. Pre-archive verification (the 5-gate triple)
- 5.1
bun run check— 0/0/0 - 5.2
bunx turbo lint typecheck test --filter=@suaveplan/api-2pc— green - 5.3
bunx turbo test:coverage --filter=@suaveplan/api-2pc— 100/100/100/100 - 5.4
bun scripts/openspec-conformance.ts @suaveplan/api-2pc— exit 0 - 5.5
bunx turbo build --filter=@suaveplan/api-2pc— green
6. Pre-archive 7-row checklist
- 6.1 Generics threaded;
expectTypeOfon every literal-type claim - 6.2 Zod schemas wired at every boundary
- 6.3 Every
TWOPC_*code thrown by production paths - 6.4 Strict-mode behaviour tested both on and off (timeout ceiling, outstanding cap)
- 6.5 OTel instruments asserted against an in-memory
MeterProvider - 6.6 Lifecycle dedup: re-running
recoveryis a no-op once orphans are resolved - 6.7 No retroactive tick — every box reflects work in this change
7. Archive
- 7.1 Fold spec delta into
openspec/specs/api-2pc/spec.md - 7.2 Move to
openspec/archive/<yyyy-mm-dd>-api-2pc/ - 7.3 Tick Stage-6 row in umbrella tasks
- 7.4 Refresh
MANIFEST.md