feat(agent): durable execution ledger and kill recovery cases (S08)

Merged
CO
25d ago
+1154-0

Part of #4997.

Summary

Adds the S08 execution endpoint ledger over DurableStore. The ledger commits each transition before returning, binds identities to issuer/command/generation/scope, preserves immutable terminal outcomes, retains dedup identity after ACK, and handles lease renewal and restart recovery.

This is an inert foundation. The agent loop does not call it yet. S18a is a separate stacked PR.

Acceptance and evidence

At head 889b94d038f3f084ed15d5222b83c229a6bfcad4, the gated push ran:

ObligationEvidenceResult
R19/F42, S08 projectioncd packages/agent && bun run test -- test/execution test/durable/store-conformance.test.ts test/conformance5 files, 124 tests passed
Endpoint rulesLEDGER-01..12Identity, effect boundary, consent wait, at-most-once dispatch, terminal ordering, renewal, ACK, restart and epoch fencing
KILL-LEDGER64 cases: 16 transitions, each cut before commit, at both writes, and after durabilityAll passed in the targeted run
Static checksbun check --no-script --all -p tsconfig.jsonNo type errors in 7,672 files
Scoped lint and formatoxlint --deny-warnings, oxfmt --check, all changed TypeScript filesBoth exit 0
Z1.GNo default-path caller added; runtime EQ remains a parent-owned phase gateNot claimed as an EQ pass
Z3.prNew modules are reachable from the conformance export; no ignores, suppressed diagnostics or weakened testsFull knip and CI-equivalent checks remain parent-owned
MA-DPortable StoreConformanceAdapter cases and exported kill declarationsFull DO/Bun comparison, mutation proof and conformance review remain parent-owned

At that same head, the actual Bun SQLite host also passed the entire registered conformance suite through CONFORMANCE_HOST=bun-sqlite bun ../../node_modules/vitest/vitest.mjs run test/conformance/run-suite.test.ts (6 wrapper tests passed, including the host test that runs every registered case). This proves this host run, not the separate phase-level DO/Bun comparison gate.

RED: the new endpoint test failed because src/execution/ledger.ts did not exist. The first GREEN run exposed the expected stale public-export inventory; that test and the host implementation map were updated to include the new public conformance cases.

Contract decisions

The ledger receives authenticated actor identities and the store owner's shared admission line; it does not invent a second writer lock or transport authorization layer. Only an applied response whose state is dispatched permits body execution. Expired requests return their terminal lease outcome instead.

Prepared, consent-waiting and released calls survive restart. Preparing calls terminate rather than rerun hooks. Reconcilable dispatched calls get one durable 30-second grace window, bounded by the lease; another restart cannot extend it.

Remaining integration gates

Review and merge are parent-owned. This PR does not claim phase-level EQ, whole-suite CI, DO comparison or mutation evidence. The tracking issue stays open until those acceptance obligations are proven.