Repository navigation
Description
Realized savings: measure applied fixes (codeburn act report)
Part of the acting-layer epic. Depends on the journal and --apply issues.
Why
Optimize's savings are estimates, and estimates invite doubt. Once fixes are actually applied we can measure. Every applied action should carry a before-baseline and be re-measured against the after-window, so optimize reports realized numbers next to estimated ones. This closes the loop and is the strongest credibility feature of the acting layer.
What to build
Baselines at apply time
Extend the apply path (src/act/apply.ts) to store a baseline on the ActionRecord, computed per finding kind over the trailing 14 days at apply time:
mcp-remove/mcp-project-scope: estimated schema tokens per session for the removed/rescoped servers (the low-coverage detector already computes per-server overhead; export and reuse), plus sessions/day in the affected scope.archive-skill|agent|command: per-item metadata tokens and sessions/day (same detectors).claude-md-rule(read-edit ratio rule): reads, edits, and ratio over the window.shell-config(bash cap): average bash tool-result tokens per call and calls/day.guard-install: yield split (productive / abandoned percent) and average session cost over the window.
Baselines are plain Record<string, number> plus a windowDays and capturedAt. Missing data stores an empty baseline; report marks those "not measurable".
codeburn act report [--json]
For each applied (not undone) action older than 3 days:
- Re-run the same detector logic over the post-apply window (apply date to now, capped at 30 days).
- Compute the per-kind realized delta:
- MCP/archive kinds: (baseline tokens-per-session minus current tokens-per-session for the same items) x sessions in the window. After a removal the current overhead for those servers should be zero; if the server reappears in config, report "reverted by user" instead of a saving.
- read-edit rule: ratio then vs now, tokens saved from avoided re-edit retries using the same math the detector uses for its estimate.
- bash cap: delta in average bash result tokens x calls.
- guard: abandoned-percent then vs now and average session cost delta, labeled "correlation, not attribution".
- Confidence marker per row:
lowwhen post-window sessions < 20 or overall usage volume shifted more than 2x versus baseline (a usage explosion swamps any fix effect); otherwisenormal. - Output: one row per action (date, description, estimated at apply, realized so far, confidence), then a total line.
--jsonmirrors it.
Surface in optimize
At the top of codeburn optimize output, when at least one measured action exists, add one line: Applied fixes: N active, realized ~X tokens (~$Y) over Z days. Details: codeburn act report. Findings whose finding-id has an active applied action and no longer trigger are simply gone from the list (natural), but if a finding re-triggers despite an active action, append (previously applied <date>, re-flagged) to its title.
Honest accounting rules (encode in code comments and report footer)
- Never attribute cross-signal effects; each kind measures only its own metric.
- Guard numbers are correlation; say so in the output.
- When in doubt, under-claim: round realized numbers down, keep the estimate visible for comparison.
Tests (tests/act-report.test.ts)
- fixture journal + synthetic transcripts: MCP removal shows realized tokens matching the per-session overhead x session count, exact arithmetic asserted
- reverted server (re-added to config post-apply) reports "reverted", zero savings
- fewer than 20 post-window sessions marks confidence low
- 2x volume shift marks confidence low
- undone actions and actions younger than 3 days are excluded
- optimize header line appears only when a measured action exists;
--jsonshape asserted
Acceptance
codeburn act reporton a machine with one applied MCP fix shows a plausible realized number within 30% of the estimate, or a clearly labeled reason why not.- No change to optimize output for users with no applied actions.
- Zero new dependencies.
Part of epic #602.
Activity
feat(act): realized savings measurement (codeburn act report) (getage…
fix(act): report scale, corrupt-journal safety, and under-claim gaps (g…