Open
Conversation
`computePlanUsage` now annotates each cycle with a `fidelity:
{ confidence, summary }` block computed over its contributing turns.
`confidence === 'high'` only when every turn is `full` or `usage-only`
with both per-turn input and output token coverage; otherwise `low`.
Records without a `fidelity` field stay best-effort high (matches the
codebase's existing backward-compat policy). Spend totals continue to
include `partial` / `aggregate-only` / `cost-only` contributions —
under-counting silently is worse than annotating low-confidence — so
the cycle's `spentUsd` is the lower bound the consumer renders against
the new flag.
`burn plans` (list view) renders a `confidence` column and a footer
note (e.g. `note: claude-pro: 3 of 412 turns this cycle lack per-turn
token data — totals are a lower bound.`) when at least one plan has
any low-confidence cycle. Full-fidelity cycles render exactly as
before. `--json` gains a per-plan `usage.fidelity` block.
`PlanUsageFidelity` is exported from `@relayburn/analyze`. The
`limits.test.ts` mocks now include `fidelity` because `PlanUsage`
gained a required field.
Tests cover the high/low/cost-only/partial cycle paths in analyze,
and the rendered-note + JSON shape in cli.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Devin Review found 1 potential issue.
⚠️ 1 issue in files not directly in the diff
⚠️ Missing root CHANGELOG entry for cross-package change (AGENTS.md violation) (CHANGELOG.md:7-11)
This PR touches both packages/analyze (new PlanUsageFidelity type + deriveFidelity logic) and packages/cli (fidelity column + footer in burn plans list view + JSON). AGENTS.md states: "Update [Unreleased] only when the work spans packages or warrants a top-level summary; single-package work belongs only in that package's CHANGELOG." Since the work spans two packages, the root CHANGELOG.md's [Unreleased] section should have an entry for #108, but it does not (CHANGELOG.md:7-11).
View 3 additional findings in Devin Review.
This was referenced Apr 26, 2026
Open
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.
Summary
computePlanUsagenow annotates each cycle with afidelity: { confidence, summary }block.confidence === 'high'only when every contributing turn isfullorusage-onlywith both per-turn input and output token coverage; otherwiselow. Records without afidelityfield stay best-effort high (matches the codebase's existing pre-Coverage and fidelity metadata: distinguish missing, zero, aggregate-only, and partial usage #41 backward-compat policy). Spend totals continue to includepartial/aggregate-only/cost-onlycontributions — under-counting silently is worse than annotating low-confidence — sospentUsdbecomes the lower bound the consumer renders against the new flag.burn plans(list view) gains aconfidencecolumn when at least one plan has any low-confidence cycle, and a footer note naming the affected plan + lower-bound caveat (note: claude-pro: 3 of 412 turns this cycle lack per-turn token data — totals are a lower bound.). Full-fidelity cycles render exactly as before — no extra column, no footer.--jsonemits a per-planusage.fidelity: { confidence, summary }block carrying the sameFidelitySummaryshapesummarizeFidelityproduces elsewhere.PlanUsageFidelityis exported from@relayburn/analyze.Rebase consideration for PR #131
PR #131 (issue #91) is migrating
burn plansto read fromarchive.sqlite. This PR targets the currentqueryAll-based path onmain. When #131 lands, the rebaser needs to apply the same fidelity-collection + low-confidence rule to the archive-backed path so the new annotations don't disappear. The annotation logic itself lives entirely incomputePlanUsage(analyze) — it walks whatever turns the caller hands it — so the fidelity data only needs to keep flowing through to the renderer. Concretely, the conflicts will be inpackages/cli/src/commands/plans.tsrunListand the helper that loads turns; everything inpackages/analyze/src/plan-usage.tsshould rebase cleanly.Test plan
pnpm run buildclean.pnpm run test:ts— 523 passing (10 new).cost-onlycontributions counted toward spend + flagged low-confidence, empty cycle, and out-of-cycle turns ignored.confidencecolumn + footer note when any cycle is low-confidence, and--jsonemits theusage.fidelityblock with the rightconfidence/summaryshape.Refs
Closes #108 — refs #41, #76 (which shipped
summarizeFidelity/hasMinimumFidelity).