Repository navigation
POC: fold a turn's spend through spendAfterWrite - #4425
Closed
cursor[bot] wants to merge 16 commits into
Closed
cursor[bot] wants to merge 16 commits into
cursor[bot] wants to merge 16 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDfgRv9riWiVVdj8JG
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDfgRv9riWiVVdj8JG
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDfgRv9riWiVVdj8JG
…t (FIX-2398) - taskSpendView gains costUsd: the sum of vendor-reported charges, null when none (a subscription run reports none; never an estimate). - harnessSessionFlow records each turn's spend (taskSpendView's shape) and endedAt at turn end, however the turn ended; hands harnesses an onUsage feed into the usage record; carries a harnessUsage action (usageReaders). - ui registry gains a spend item, lifted from Claude Code-style's Spend; Kitchen Sink installs its byte copy. - Goal check goals/harness-manager/a-turn-records-what-it-spent: PASS on real Claude Code; GOAL_CONTROL=no-turn-spend FAILs t and s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDfgRv9riWiVVdj8JG
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDfgRv9riWiVVdj8JG
Turn spend joins FIX-2384's turn-end sequencer as one more step; the flow keeps one onFinished. Kitchen Sink installs run-changes.tsx so its registry drift check passes on the stacked branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDfgRv9riWiVVdj8JG
…e request publishes its end (FIX-2398) onFinished runs after runAction emits the terminal status, so a page that refreshes on the end could read the turn before its spend landed (Codex, spec PR #4398). The spend now lands in a tap after the harness step, or in recordFailure's write for a turn that threw. A test captures session state when request.completed is persisted. The goal's control is now main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDfgRv9riWiVVdj8JG
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDfgRv9riWiVVdj8JG
Codex: onFinished runs after the terminal status is published, so D2's write moves inside the turn and the goal's control becomes main. Cursor's scope notes answered in DECISIONS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDfgRv9riWiVVdj8JG
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDfgRv9riWiVVdj8JG
…to claude/project-thread-t857lk # Conflicts: # apps/kitchen-sink/test/harness-turn.test.ts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDfgRv9riWiVVdj8JG
…updated run-changes The parent branch moved both registry files without updating the byte copies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDfgRv9riWiVVdj8JG
… requestSpendView Review on #4423: the session flow no longer hand-builds a task spend entry; orchestration owns the request-to-view step. The turn-end write happens once (a record that already ended keeps its end), and onUsage needs no cast. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDfgRv9riWiVVdj8JG
|
The latest updates on your projects. Learn more about Vercel for GitHub. 4 Skipped Deployments
|
Turn spend stays a step inside the turn, before 2384's in-turn head write. Kitchen Sink takes the parent's run-changes and run-checks copies; the drift count is 40 with spend. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDfgRv9riWiVVdj8JG
The hand-built entry repeated spendAfterWrite. The export and turnEndOnce stay. Co-authored-by: Jake Hoffner <jhoffner@users.noreply.github.com>
cursor
Bot
force-pushed
the
poc/shorter-turn-spend
branch
from
November 1, 2026 00:03
62c911b to
78a103c
Compare
Contributor
Mechanism check (advisory, never blocks)Rows from
If an export is a new mechanism, add a row. CI filled the mechanical fields; - id: TODO
job: TODO
package: "@flow-state-dev/orchestration"
anchor: requestSpendView
file: packages/orchestration/src/tasks/spend.ts
builtOn: [] # TODO
overlaps: [] # TODO
status: canonical
doc: TODO |
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.
Draft. This PR does not merge.
What this subtracts
turnSpendOfwas building a one-request task row by hand: the last harness run, the last model key, and the blankwriter/admittedAt/recoveredfields.spendAfterWriteon a blank row withpart: "settle"is that row.taskSpendViewstill folds it, withstatus: "completed", so a turn still reads like a finished task.Diff vs
7b7e828:packages/harness-manager/src/session-flow.ts+4/−16.What still passes
pnpm --filter @flow-state-dev/harness-manager exec vitest run --root . test/turn-spend.spec.ts— 6 passed.The hand-built row and this fold return the same view for an empty ledger, an API-key run, a subscription run, model calls only, a harness run mixed with model calls, and two api-key runs of one harness plus a subscription run. That check was local and is not in this branch.
Do not merge
Fold the subtraction into #4423. Close this PR unmerged after that lands.