You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Overhead attribution is the surface added in #236: it answers "how much of this session's spend went to system overhead (CLAUDE.md / AGENTS.md context loaded into every prompt) vs actual user-asked work?" Small in source LoC (~122) but it's the fresh divergence-risk surface called out in #244's acceptance: per-file, per-section USD totals must match TS within 1e-9 USD.
This is a leaf module — it doesn't compose other detectors — so it can land independently of the other sub-issues, in parallel with the detector PRs.
Port findOverheadFiles(projectPath) — discovers CLAUDE.md and AGENTS.md files across the project tree, including parent directories and .claude/ / .codex/ subdirs.
Port attributeOverhead(input) — the 1e-9-precision-sensitive core. Computes per-section USD attribution by weighting input-token cost by section token share.
Port describeAppliesTo(applies_to) — returns the human-readable label ("Claude Code only", "Codex + OpenCode", etc.).
Port overheadTrim() if exported (check index.ts re-exports — surface lives in this module per the parent issue scope).
Precision contract
The 1e-9 USD gate is the headline acceptance criterion of #244. Concretely:
Use f64 arithmetic, same operation order as TS (token-share × per-token rate, summed in section-iteration order).
Section iteration must be deterministic: order by (file_path, section_index) ascending — match TS sort key exactly.
Avoid intermediate rounding. Round only at the serialization boundary if the consumer requests a fixed precision; the in-memory f64 carries the full double precision.
A regression test computes overhead for a multi-file fixture corpus and asserts (rust_total_usd - ts_total_usd).abs() < 1e-9 per (file, section) pair.
Parent: #244
Depends on: #242, #266 (foundation)
Context
Overhead attribution is the surface added in #236: it answers "how much of this session's spend went to system overhead (CLAUDE.md / AGENTS.md context loaded into every prompt) vs actual user-asked work?" Small in source LoC (~122) but it's the fresh divergence-risk surface called out in #244's acceptance: per-file, per-section USD totals must match TS within 1e-9 USD.
This is a leaf module — it doesn't compose other detectors — so it can land independently of the other sub-issues, in parallel with the detector PRs.
Scope
overhead.rs(port ofoverhead.ts, ~122 LoC)OverheadFileKind(claude-md | agents-md),OverheadHarness(claude-code | codex | opencode).OverheadFile,ParsedOverheadFile,OverheadFileAttribution,OverheadAttribution,AttributeOverheadInput(already enumerated in [Rust port] relayburn-analyze: pricing, hotspots, overhead #244's scope).OverheadResult,OverheadSection,OverheadFileSummary,OverheadPerFileEntry,OverheadAttributionDetail,OverheadSectionCost,OverheadTrimResult,OverheadTrimRecommendation.findOverheadFiles(projectPath)— discoversCLAUDE.mdandAGENTS.mdfiles across the project tree, including parent directories and.claude//.codex/subdirs.loadOverheadFile(file)— reads + parses a single overhead file via the shared markdown parser (reuseparseClaudeMdfrom [Rust port] relayburn-analyze: subagent-tree + claude-md attribution #272'sclaude_md.rs).attributeOverhead(input)— the 1e-9-precision-sensitive core. Computes per-section USD attribution by weighting input-token cost by section token share.describeAppliesTo(applies_to)— returns the human-readable label ("Claude Code only","Codex + OpenCode", etc.).overheadTrim()if exported (checkindex.tsre-exports — surface lives in this module per the parent issue scope).Precision contract
The 1e-9 USD gate is the headline acceptance criterion of #244. Concretely:
f64arithmetic, same operation order as TS (token-share × per-token rate, summed in section-iteration order).(file_path, section_index)ascending — match TS sort key exactly.f64carries the full double precision.(rust_total_usd - ts_total_usd).abs() < 1e-9per(file, section)pair.Conformance gate
packages/analyze/src/overhead.test.ts(230 lines).Acceptance
cargo test -p relayburn-analyzegreen for overhead.attributeOverhead,describeAppliesTo,findOverheadFiles,loadOverheadFile, plus the full attribution type tree listed above.findOverheadFilestraversal order deterministic and matches TS (BFS by directory depth, alphabetical within depth).Files
packages/analyze/src/overhead.ts+overhead.test.ts