Skip to content

feat(report-lane-outcome): record each run's list-price cost as costUsd - #872

Merged
kyle-sexton merged 1 commit into
mainfrom
feat/lane-outcome-cost-usd
Oct 23, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
feat/lane-outcome-cost-usd

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

No related issue: G6 part 2 of the lane-funding plan (owner-approved 2026-10-23).

Summary

The lane-outcome record now carries an optional costUsd: the run's cost at list price, as the Claude Code CLI estimates it in the result message's total_cost_usd. It is an estimate for attribution and trends, not what was billed. Until now that value stayed in run-claude-cli's runner-local JSONL, so nothing outside the runner could read per-run spend. The claude-code-plugins morning brief will read it to print a per-role spend line.

Fix

  • readRunRecord reads total_cost_usd from the execution file's result message, keeping it only when it is a finite number of at least 0, the same guard run-claude-cli/lane.cjs applies. runFacts carries it and factRecord writes it as costUsd on every outcome, failures included, and omits it when unknown. Both emit paths (the claude-code-action review lanes and run-claude-cli callers) go through readRunRecord, so both gain the field.
  • The legacy key=value tokens are unchanged: no cost= token.
  • schemas/lane-outcome.v1.schema.json adds costUsd (number, minimum: 0) and describes it as a list-price estimate, not billing. docs/lane-outcome.md § Fields adds its row. This is an optional field added within v1, which § Compatibility allows.

Verification

  • node --test .github/actions/report-lane-outcome/classify.test.cjs: 43 pass. New cases: costUsd comes from total_cost_usd and drops a negative, string, null, boolean or object value; the record carries it on a success and on a credit-stop failure and omits it when unknown; no legacy token mentions cost; past 1,024 characters models is dropped and costUsd is kept.
  • node --test .github/actions/report-lane-outcome/outcome-step.test.cjs: 34 pass. New: the action step writes costUsd on a success and a failure, and the record validates against the schema; the schema rejects a negative and a string costUsd. With classify.cjs reverted to main, 5 of the 77 report-lane-outcome tests fail.
  • node --test .github/actions/run-claude-cli/lane.test.cjs: 72 pass; node --test .github/scripts/*.test.cjs: 644 pass; markdownlint-cli2 docs/lane-outcome.md: 0 issues.
  • Left out: no live lane run. The field reaches records once a release is cut and callers re-pin.

Related

🤖 Generated with Claude Code

The lane-outcome record gains an optional costUsd: the execution file's
result message total_cost_usd, the CLI's own list-price estimate, on every
outcome. It is not billing. The schema, docs/lane-outcome.md Fields and
the classify and outcome-step tests cover it; the legacy tokens are
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kyle-sexton
kyle-sexton marked this pull request as ready for review October 23, 2026 21:08
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T21:10:04.618615Z 1de5632 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude

claude Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Claude finished @kyle-sexton's task in 1m 41s —— View job


Code review complete

  • Gather context (diff, PR body, rule files)
  • Review classify.cjs / classify.test.cjs changes
  • Review outcome-step.test.cjs changes
  • Review schema and docs changes
  • Check path-scoped rules (pr-body-contract.md) and PR body contract
  • Post findings

No findings. The change is small, consistent, and well covered:

  • readRunRecord's costUsd guard in classify.cjs#L354-L357 is byte-for-byte the same predicate run-claude-cli/lane.cjs's amount() helper uses (typeof === "number" && Number.isFinite && >= 0), so the "same guard" claim in the PR body holds.
  • factTokens (legacy key=value sentence) correctly omits costUsd — verified no cost= token is emitted, matching the "no cost= token" claim.
  • factRecord writes costUsd unconditionally (not gated by failed/outcome), so it rides on both success and failure records as intended; the 1,024-char truncation only drops models, never costUsd, matching the new test and the PR body.
  • Schema (minimum: 0, no upper bound) and docs/lane-outcome.md field-table row agree with the code's guard and with each other.
  • costUsd is a net-new optional field in schema v1 — allowed per the doc's own "Compatibility" section (fields may be added within a major version).
  • PR body satisfies pr-body-contract.md: opens with No related issue: <reason>, and includes ## Summary, ## Fix, ## Verification, ## Related.
  • Security lane is enabled in this repo (pr-review-security.yml exists), so security scope is correctly left to that lane; nothing here touches security-relevant surface regardless.

Spot-checked the author's verification claims against the diff (guard parity, omitted legacy token, truncation behavior, schema/doc agreement) — all consistent with what's described. Did not independently re-run the test suites; the described node --test runs are author-claimed.

manifest <field>: n/a (no .claude-plugin/plugin.json or marketplace.json change in this diff).

findings: 0

claude-lane-summary: lane=claude-review sha=1de56320b0cb377c1ed341437790fb217b8f2b8b run=40024600208

@claude

claude Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Claude finished @kyle-sexton's task in 1m 8s —— View job


Security review — claude-security-review

  • Gather context (PR diff, changed files, repo instructions)
  • Apply skip gate
  • Review changed files for security-relevant issues
  • Check for instruction-surface deletions / manifest changes
  • Adversarially verify any candidate findings
  • Post results

Scope: classify.cjs, its two test files, docs/lane-outcome.md, and schemas/lane-outcome.v1.schema.json. No workflow files, manifests, or instruction files (CLAUDE.md/AGENTS.md/rules) are touched, so the manifest and instruction-surface-deletion checks don't apply here.

Analysis: The change reads one more field (total_cost_usd) out of the execution-file JSON that readRunRecord already parses (readMessages, classify.cjs#L100-L104) — the same file turns and modelUsage already come from, so no new trust boundary is crossed. The new costUsd extraction uses the identical type-narrowing guard already used for turns (typeof === "number" && Number.isFinite(...) && >= 0), so a non-numeric, negative, NaN, or Infinity value is dropped to null rather than flowing into the written record. The value is only ever written into the JSON outcome record (never interpolated into a shell command, path, or template), and it carries no secret or credential material. The schema addition mirrors this with "type": "number", "minimum": 0.

No CRITICAL, IMPORTANT, or SUGGESTION findings. No manifest fields were touched (manifest checklist: not applicable — no plugin/marketplace manifest in this diff).

claude-lane-summary: lane=claude-security-review sha=1de56320b0cb377c1ed341437790fb217b8f2b8b run=40024600208

@github-actions

Copy link
Copy Markdown

claude-security-review has reviewed this pull request through 1de5632; a later push is reviewed from there.

@github-actions

Copy link
Copy Markdown

claude-review has reviewed this pull request through 1de5632; a later push is reviewed from there.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Oct 23, 2026
Merged via the queue into main with commit d02b869 Oct 23, 2026
56 of 58 checks passed
@kyle-sexton
kyle-sexton deleted the feat/lane-outcome-cost-usd branch October 23, 2026 21:18
kyle-sexton added a commit to melodic-software/standards that referenced this pull request Oct 23, 2026
…and pr-review-cli contracts (#856)

No related issue: G6 part 2 of the lane-funding plan (owner-approved
2026-10-23).

## Summary

Registers `intake-triage.yml@d02b8697e092705153f0996549b05f95a446bb52`
and `pr-review-cli.yml@d02b8697e092705153f0996549b05f95a446bb52`
(ci-workflows
[v0.65.0](https://github.com/melodic-software/ci-workflows/releases/tag/v0.65.0)),
so claude-code-plugins' intake and review callers can re-pin to the
release whose lane-outcome record carries `costUsd`.

## Fix

v0.65.0 changes only report-lane-outcome's `classify.cjs`
([ci-workflows#872](melodic-software/ci-workflows#872)).
Both reusables reach that action through `$/`. Neither workflow file
changed since its last registered SHA (`git log 2fe38c03..v0.65.0 --
.github/workflows/intake-triage.yml` and `git log v0.64.2..v0.65.0 --
.github/workflows/pr-review-cli.yml` list no commits), so both contracts
copy their prior entries forward verbatim.

## Verification

- `node --test runner-policy.test.mjs` in `components/runner-policy`:
341 pass. That count includes the new copy-forward test, which checks
both entries deep-equal their prior SHAs' entries and that exactly two
contracts name the new SHA.
- Left out: nothing.

## Related

- Same shape as
[#853](#853)
(v0.64.2).
- Next: the standards sync into claude-code-plugins, then that
repository's caller re-pin.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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