Skip to content

A resumed conversation restores its late receipts, so it never saves less than it charged - #2414

Merged
AbirAbbas merged 4 commits into
workstreams/mainfrom
workstreams/l-spend-replay
Nov 5, 2026
Merged

AbirAbbas merged 4 commits into
workstreams/mainfrom
workstreams/l-spend-replay

Conversation

@AbirAbbas

@AbirAbbas AbirAbbas commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A late provider receipt (a stream cut before its usage block, priced afterwards by Agent.reconciled) is banked with late: true, outside every turn seal, and leaves only a journal call line marked with an arm (reconciled or hedge). Since the late charge is saved to meta.json at once, but replay summed usage seals only, a restart forgot it: .25 sealed + .125 late saved .375; after a resume the meter read .25, and a .01 turn saved .26 — below what had already been charged.

  • Replay (sessionfile.go) restores a call line that carries an arm as one call and no turn, with its money and tokens, exactly as Agent.reconciled banked it. Ordinary call lines stay evidence and are never billed.
  • Digest.Spend() counts the same lines (a separate late sum), so a meta row rebuilt from the transcript (cellindex Derive/Behind) agrees; Digest.Usage still lists only usage lines for its ledger readers.
  • A receipt that arrives after Close (pending receipt accounting may finish after quit) keeps its arm line: the closed-file exception that already admitted usage seals now admits a paid arm call line too.
  • Comments and the manual now say the restored total is usage seals plus late-receipt call lines.

Checked by reading: every arm line comes from Agent.reconciled, which banks late exactly once; no seal or abandoned line holds that money; no supported path mirrors a duplicate arm into one journal; late banking (#631) predates arm lines (#1015) and nothing before #631 banked late money, so no older journal double counts. Out of scope and unchanged: an abandoned turn (abandon.go) writes an abandoned record without a seal, so its ordinary calls are also absent from replay — a separate gap.

Part of the Workstreams plan's spend follow-ups.

Validation contract

Behaviour Test
(a) Seal .25 + reconciled arm .125 restores .375 with tokens and calls; turns unchanged TestLateCallLinesRestoreSpendWithoutAddingTurns
(b) After a restart the next .01 turn saves .385, never .26 TestALateReceiptSurvivesResumeAndTheNextSpendStamp
(b) The same when the receipt arrives after Close (the closed journal now admits a paid arm line; ordinary call lines stay refused) TestALateReceiptAfterCloseSurvivesResumeAndTheNextSpendStamp
(c) A hedge arm counts the same; an ordinary call line adds nothing TestLateCallLinesRestoreSpendWithoutAddingTurns; existing TestCallLinesAreNotReadBackAsSpend unchanged
(d) Digest.Spend answers .375 while Digest.Usage keeps only the usage line TestDigestSpendIncludesLateReceiptsWithoutAddingUsageLines

No wire change.

🤖 Generated with Claude Code

AbirAbbas and others added 4 commits November 5, 2026 11:08
…less than it charged

A late provider receipt (a cut stream priced after the fact) is banked
outside every turn seal and leaves only its call line with an arm mark.
Replay summed usage seals alone, so after a restart the meter forgot every
late charge, and the next turn could stamp meta.json below the total a late
receipt had already saved (.25 + .125 saved .375; resumed, a .01 turn saved
.26). Replay now restores a call line that carries an arm (reconciled or
hedge) as one call and no turn, exactly as Agent.reconciled banked it, and
Digest.Spend counts the same lines so a meta row rebuilt from the
transcript agrees. Ordinary call lines stay evidence and are never billed;
Digest.Usage still lists only usage lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ll restores it

Close lets pending receipt accounting finish after quit, and the closed
journal already admitted usage seals for that reason, but it refused the
arm call line a late receipt writes. The charge then reached meta.json and
vanished on resume again. The closed-file exception now admits a paid arm
call line too; ordinary call lines stay refused after close.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The broader rewrite moved the manual's question ranking (TestTheChatManual-
AnswersTheQuestionsPeopleAsk); keep the original sentences and add the
late-receipt exception beside them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@AbirAbbas
AbirAbbas merged commit 0c5e76d into workstreams/main Nov 5, 2026
8 of 11 checks passed
@AbirAbbas
AbirAbbas deleted the workstreams/l-spend-replay branch November 5, 2026 17:24
AbirAbbas added a commit that referenced this pull request Nov 13, 2026
…red; turn.tool carries live spend (#2612)

* turn.tool carries the conversation's live spend so far

Carries #2413 from the closed integration PR #2306 (workstreams/main);
it never reached dev.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>

* A resumed conversation restores its late receipts, so it never saves less than it charged

Carries #2414 from the closed integration PR #2306 (workstreams/main);
it never reached dev. The one conflict, Digest's fields, keeps dev's
folded-usage total beside the late-receipt sum.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>

* session: an abandoned turn's paid steps survive a restart

Carries #2440 from the closed integration PR #2306 (workstreams/main);
it never reached dev.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>

* changes: the carried spend entries name this pull request (#2612)

Co-Authored-By: Claude Mythos 5.2 <[email protected]>

* manual: a late receipt's call line is the one a resume adds up (#2612)

The transcript-format section of sessions-and-rewind.md still said every
`call` line is never added up. Since this pull request a resume adds a
call line marked with an `arm` once, as the usage and call-line sections
of the same page already say. The section now names that exception, and
a test keeps every paragraph that says call lines are not added up
naming the arm beside it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* session: a step seal saves the total Home reads, as a turn seal does (#2612)

The abandoned tool-batch, settle-bound and final stage-report exits wrote
their step seal to the journal but never stamped meta.json. Their steps
bank as turn calls, which Agent.bank leaves for the seal to stamp, so
meta.json kept the figure from before them. After a restart the meter
(/cost, the status row, agents.budget.get) restored the journal's total
while meta.json (agents.list spent_usd, Home) kept the older one, because
stampRestoredSpend fills only a missing figure. A .01 title followed by a
.25 step at any of the three exits read $0.26 on the meter and $0.01 in
meta.json until the next ordinary turn sealed.

The three exits now share sealSteps, which writes the step seal without
duration and owes the deferred spend stamp. The stamp reads the live
books and writes only the spend fields, so it changes nothing a
replacement turn owns. The manual and the change entry say so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Mythos 5.2 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant