feat(audit): cost-trace truthfulness audit script (Theme 5 Layer 5)#325
Draft
mitwilli-create wants to merge 1 commit into
Draft
feat(audit): cost-trace truthfulness audit script (Theme 5 Layer 5)#325mitwilli-create wants to merge 1 commit into
mitwilli-create wants to merge 1 commit into
Conversation
Closes Theme 5 Layer 5 from the 2026-05-29 task-audit. New standalone
script that statistically audits the polish-cost-trace JSONL ledgers
for plausibility, sum coherence, and outlier detection.
scripts/audit-cost-trace.mjs (~210 LOC)
Reads:
data/polish-cost-trace-*.json (one per day, append-only JSONL)
data/cost-trace-suspicious.jsonl (if present)
Dimensions:
D1 per-day totals — sums per cost-trace file (last 7 days)
D2 cost bands — % calls in [0, $0.50] / [$0.50, $2] / [$2, $5] / >$5
D3 outliers (>$5) — top 20 entries flagged for review
D4 model-cost plausibility — Haiku >$0.50 / Sonnet >$2 / Opus >$5 flagged
D5 suspicious file — count + summary of already-flagged entries
Smoke validation:
--dry-run scanned 897 entries from 7 files. Grand total $125.60.
Zero outliers, zero model-band violations, zero pre-flagged entries.
All dimensions PASS or INFO. Healthy cost-trace state confirmed.
Cross-fork-leak hardening:
Output frontmatter: [PERSONAL — DO NOT PUBLISH]
assertNoLeak() guard at render time.
Closes the bug-class entry:
"cost-tracker-implausible-entry-poisoning-pre-flight-check"
in ~/.claude/knowledge/brain/bug-class-catalog.md by giving Mitchell
a recurring audit lens, not just a write-time check.
Defaults: ~$0.05-0.15 per run (Sonnet 4.6 narrative synthesis).
--council adds 7-model adjudication for ~$20-40.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
Theme 5 Layer 5 from the 2026-05-29 task-audit. Standalone script that statistically audits the polish-cost-trace JSONL ledgers for plausibility, sum coherence, and outlier detection. Closes the bug-class catalog entry
cost-tracker-implausible-entry-poisoning-pre-flight-checkby giving Mitchell a recurring audit lens, not just a write-time check.Smoke validation
Healthy state across the board: no >$5 single-call outliers, no model-cost mismatches (Haiku >$0.50 / Sonnet >$2 / Opus >$5), no entries in
data/cost-trace-suspicious.jsonl. Total tracked spend across 7 trace files is $125.60.Dimensions
data/cost-trace-suspicious.jsonlTunable model bands
MODEL_BANDSconstant in the script. Adjust if a vendor changes pricing:Test plan
node --checkpasses--dry-runproduces audit report in.claude/audit/<DATE>/cost-trace-audit-<DATE>.md--counciltriggers 7-model adjudication🤖 Generated with Claude Code