Repository navigation
Conversation
…tLedger Move the owned attempts, the closure/settlement entries, their listeners, the failed-reawaken settlements owed and the write-only currentAttemptIdByTaskId (#7664, moved as is) from TaskService into a plain AttemptLedger class in attemptLedger.ts, with the methods that own them: attempt begin/close/settle, the receipt decision and write, the no-report boundary, rotation publication, release of reported attempts, the closure and settlement waits and the resume-failure recheck. TaskService builds it with call-time closures. Stop records, send obligations and stream-end decisions stay with their owners and are reached through those closures. beginOwnedTaskAttempt, closeAttemptAdmission, settleOwnedTaskAttempt, decideSettlementReceipt, writeSettlementReceipt, notifyAttemptSettlementListeners and the public waitForAttemptSettlement stay on TaskService as one-line facades, and the ledger calls the spied ones (and inspectAttemptOutcome) back through TaskService. recordWorkspaceTurnSettled/Superseded and currentTaskAttemptId stay on TaskService. rowSupersedes moves to taskUtils so both files can use it. Tests that cast a moved field change only the cast target. No behavior change: moved code is verbatim, statement order is kept and no await is added. Signed-off-by: Thomas Kosiewski <tk@coder.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
… in AttemptLedger tests
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
🟢 e2e stories (Haiku): 14 passed22 agent steps · 7 replayed from cache · 15 model calls · 46.3k tokens (24% cached) All 14 tests in 9 files
e2e 0.20.0 · 1m 14s · web · run artifacts 🟢 e2e Electron stories (Haiku): 3 passed3 agent steps · 3 model calls · 8.0k tokens (22% cached) All 3 tests in 3 files
e2e 0.20.0 · 21.1s · electron · run artifacts 🟢 e2e agent repros (Haiku): no tests selectedSpend: $0.00 of the $1.00 cap (proxy ledger) e2e 0.20.0 · 5.3s · 2 targets (web, phone) · run artifacts |
Summary
Moves attempt identity and settlement receipts out of
TaskServiceinto a new plain class,AttemptLedger(src/node/services/attemptLedger.ts). The move is move-only.taskService.tsdrops from 21,470 to 20,972 lines. PR 8 of the TaskService split, on top of #7675. PR 9 adds send admission to the same class.Implementation
ownedAttemptByTaskId,attemptSettlementByTaskId,attemptSettlementListenersByTaskId,resumeFailureSettlementByTaskIdandcurrentAttemptIdByTaskId. The last one is still write-only. It moved as it is, and 🤖 refactor: remove the unread currentAttemptIdByTaskId map and an orphaned comment in TaskService #7664 tracks it.attemptCannotStillReport); the settlement listeners and waits (waitForAttemptSettlement,waitForAttemptClosureToSettle,runUnderEventLockBounded);publishAttemptRotation; andrecheckResumeFailureSettlement.waitForAttemptSettlement(public) and for the methods tests spy on or call through casts:closeAttemptAdmission,decideSettlementReceipt,writeSettlementReceipt,beginOwnedTaskAttempt,settleOwnedTaskAttemptandnotifyAttemptSettlementListeners. Inside the ledger, calls to these methods go back through the TaskService facade, so spies see every call. Each such call is one extra synchronous hop, with no new await.recordWorkspaceTurnSettledandrecordWorkspaceTurnSuperseded, which coordinate three owners. AlsocurrentTaskAttemptId,rotateAttemptForStartupRedrive,inspectAttemptOutcomeandreadAttemptOutcome.TaskStopLatchnever callsAttemptLedgerdirectly. Both reach each other through TaskService closures.rowSupersedesmoved totaskUtils.ts, because importing a value fromtaskService.tswould create a runtime import cycle.AttemptSettlementEntryis now exported forimport type.deferChildStreamEndnow callsaddAttemptSettlementListenerinstead of an inline copy of the same three statements.Validation
attemptLedger.test.tshas 43 tests on fake deps. They cover:runUnderEventLockBounded), 12, 10 and 10, under the CI limit of 15.Risks
Medium-low. This code decides whether a task attempt can still report and writes its settlement receipts. A wiring mistake would refuse or lose a report. The settlement, settlement-receipt, attempt-admission and report-decision suites pass, and they changed only their cast targets.
Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:high• Cost:$68.74