feat(delivery): make ledger attempts transactional - #515
Open
Conversation
agent-identity: dev3.direct.omp.9exwnk6h agent-persona: generalist agent-supervisor: unavailable agent-tool: OMP agent-tool-version: 18.1.7 agent-runtime: OMP 18.1.7 tooling-profile: dotfiles@931583a
schickling-assistant
marked this pull request as ready for review
September 8, 2026 10:33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The delivery ledger used mutable in-memory state and split authorization from persistence. Concurrent pumps, recovery, retargeting, and late receipts could therefore act on stale state or let evidence for one attempt affect a later attempt. Operators also had no audited, fenced way to resolve a provably absent attempt, and the roster did not expose delivery holds as their own actionable axis.
Goal
Make one durable ledger transaction the sole transport permit. Fence every later action to the exact attempt, expose held delivery state to operators, and provide a narrow audited absence command without changing inbox archive authority.
Decisions
delivery-ledger.lock. Open it with no-follow semantics, serialize every mutation with the kernel lock, and publish through atomic file-and-directory fsync.claimthe only transport permit. It re-reads under lock, preserves FIFO, mints a fresh 128-bit token, persistsattempted, and only then returns a permit.doctornever backfill. DELTA-007 counts the remaining rows.delivery-negativeas an evidence-only operator boundary. It requires exact token and ledger digest preconditions, same-UID ownership, a bounded reason, and records a complete audit. It never transports, recovers, initializes, or backfills.absent | idle | held | indeterminateroster axis. Provider-private binding and correlation values remain private.Verification
Focused behavior and regression coverage passed:
Independent review found five P2 defects: provider retries ignored operator evidence, Codex retained a stale in-memory pending request, operator audit could outlive its receipt, non-adjacent duplicate filenames passed validation, and a repaired Codex ledger left a stale diagnostic. Each defect now has a focused regression. The reviewer re-read the fixes and reported no remaining correctness issue.
The repository-owned full gate passed with bounded host concurrency:
Production evidence:
The resulting OpenCode ledger retained one tokenized, correlated
persistedattempt and a permanent lock. Starting the P2 Codex driver against the retained P1 tokenless ledger also durably backfilled its attempt token before transport.Pre-flip deviations
devenv.nix, sodevenv tasks run check:allis unavailable on both this branch and the merge base. The repository-ownedchecks.x86_64-linux.st2derivation is the full local gate.Complexity
The ledger core is larger because it now owns the complete transaction protocol, attempt identity, compatibility read, read-only observation, and operator preconditions. Keeping those rules in one provider-neutral module avoids five subtly different authorization implementations. No external dependency was added.
Concerns
Friction & bottlenecks
Follow-ups
References
Refs #506
Depends on #514
Posted on behalf of @schickling
agent_identitysessionagent_personaagent_supervisoragent_toolagent_tool_versionagent_runtimetooling_profile