codeburn/tests
Justin Gheorghe 8ded6ad6fd feat(cli): track local-model cost savings against a paid baseline (#421)
Add a new `localModelSavings` config and `codeburn model-savings` CLI
that maps a local-model name (e.g. llama3.1:8b) to a paid baseline
(e.g. gpt-4o). The local call still costs $0; the new `savingsUSD`
field tracks the counterfactual spend avoided by running locally and
is reported separately from `costUSD` everywhere a number is shown.

* Parser normalization (`applyLocalModelSavings`) runs on Claude
  parse, direct provider calls, and the cached-call path. It forces
  `costUSD` to 0 and attaches `savingsUSD` + `savingsBaselineModel`
  + `isLocalSavings` on the `ParsedApiCall`. Local-savings wins for
  actual cost even when the same model is also in `modelAliases`.
* Session, project, day, model, category, activity, skill, and
  subagent rollups all carry `savingsUSD` alongside `costUSD`.
* `status --format json` adds `today.savings` and `month.savings`.
* `status --format menubar-json` adds a `current.localModelSavings`
  block (totalUSD, calls, byModel, byProvider) plus savings on
  topModels, topProjects, topSessions, topActivities, and history
  daily entries. Schema fields default-decode for backward compat.
* `report --format json` adds savings across overview/daily/
  projects/models/activities/skills/subagents/topSessions, with
  the active paid baseline name on each model row.
* `models` command gains a `Saved` column on table/markdown/CSV
  and a `savingsUSD`/`savingsBaselineModel` pair in JSON. Default
  `--min-cost 0.01` filter now ORs in `savingsUSD >= minCost` so
  local models with $0 actual cost but >0 savings still surface.
* CSV/JSON exports add a `Saved (CODE)` column on summary/daily/
  models/projects/sessions.
* Dashboard TUI shows a green 'saved $X by local models' footer
  line in the overview when any savings are present.
* macOS Swift payload gains a `LocalModelSavings` Codable block
  and savings fields on every model/activity/session/daily
  struct. Hero shows a green leaf 'Saved $X' caption, models
  section gets a green `Saved` column. `swift build` clean.
* GNOME indicator adds 'saved $X' to the hero meta line and a
  `codeburn-model-saved` column to the model row.
* Daily cache schema bumped to v8 (`savingsUSD` on day/model/
  category/provider). `savingsConfigHash` invalidates the cache
  when the user changes their baseline mapping so historical
  saved-spend numbers never lie about a stale baseline.
* Defensive `Object.hasOwn` lookup in `getLocalSavingsBaseline`
  blocks the prototype-pollution test that previously surfaced via
  the savings path with a hostile `__proto__` model name.
* New tests (5 files, 25 tests, 549 lines) cover pricing helpers,
  end-to-end parser normalization, day aggregator savings,
  menubar payload savings, CLI set/list/remove, and
  daily-cache hash invalidation. Existing tests for daily-cache
  / day-aggregator / models-report updated for the new fields.
  Full vitest suite: 1028/1028 passing across 73 test files.
  `tsc --noEmit` clean. `npm run build` clean.
  (Note: `mac/Tests` has a pre-existing `no such module 'Testing'`
  environment error on the installed Swift toolchain, confirmed
  on `main` before this PR; not caused by these changes.)
2026-06-01 11:06:39 +03:00
..
fixtures/security test(security): add failing test for HIGH-1 prototype pollution 2026-04-17 08:32:18 +02:00
providers feat(providers): add forge provider support (#401) 2026-05-26 03:36:57 -07:00
security feat(mac): native Swift menubar app + one-command install 2026-04-17 16:55:56 -07:00
antigravity-statusline.test.ts refactor(cli): share persistent-codeburn resolver; tighten Antigravity hook ownership 2026-05-31 20:07:57 -07:00
bash-commands.test.ts chore: hoist Pi model sort + cover bash-utils edge cases 2026-04-16 02:02:32 -07:00
blob-to-text.test.ts Merge main into feat/multi-provider-plans, remove dead tautology 2026-05-16 10:42:03 -07:00
classifier.test.ts File-aware retry detection with typed ToolCall (#379) 2026-05-22 01:21:42 -07:00
cli-date.test.ts Reject invalid --format and --period values instead of silently falling back (#258) 2026-05-06 23:03:41 -07:00
cli-deepseek-v4-pricing.test.ts fix: DeepSeek v4 Claude pricing through stale runtime cache (#367) 2026-05-21 00:34:53 -07:00
cli-export-date-range.test.ts feat(export): support custom date ranges 2026-05-05 23:18:48 -07:00
cli-json-daily.test.ts Add multi-day calendar selection with custom popover UI (#393) 2026-05-24 09:49:59 -07:00
cli-model-savings.test.ts feat(cli): track local-model cost savings against a paid baseline (#421) 2026-06-01 11:06:39 +03:00
cli-plan.test.ts Merge main into feat/multi-provider-plans, remove dead tautology 2026-05-16 10:42:03 -07:00
cli-status-menubar.test.ts Add multi-day calendar selection with custom popover UI (#393) 2026-05-24 09:49:59 -07:00
compare-stats.test.ts fix(classifier): surface skill name as subCategory for general turns (#203) 2026-05-04 06:26:45 +08:00
currency-rounding.test.ts Menubar and CLI hardening from multi-agent audit (#257) 2026-05-06 22:15:11 -07:00
daily-cache.test.ts feat(cli): track local-model cost savings against a paid baseline (#421) 2026-06-01 11:06:39 +03:00
dashboard.test.ts Merge main into feat/multi-provider-plans, remove dead tautology 2026-05-16 10:42:03 -07:00
date-range-filter.test.ts Add multi-day calendar selection with custom popover UI (#393) 2026-05-24 09:49:59 -07:00
day-aggregator-savings.test.ts feat(cli): track local-model cost savings against a paid baseline (#421) 2026-06-01 11:06:39 +03:00
day-aggregator.test.ts feat(cli): track local-model cost savings against a paid baseline (#421) 2026-06-01 11:06:39 +03:00
export.test.ts feat(report): add per-model efficiency metrics 2026-05-05 23:36:59 -07:00
fs-utils.test.ts Merge main into feat/multi-provider-plans, remove dead tautology 2026-05-16 10:42:03 -07:00
local-model-savings.test.ts feat(cli): track local-model cost savings against a paid baseline (#421) 2026-06-01 11:06:39 +03:00
mcp-coverage.test.ts Add MCP project profile advisor (#356) 2026-05-24 01:57:59 -07:00
menubar-installer.test.ts Fix menubar installer CLI path lookup (#387) 2026-05-24 01:01:09 -07:00
menubar-json.test.ts feat(mac): native Swift menubar app + one-command install 2026-04-17 16:55:56 -07:00
menubar-savings.test.ts feat(cli): track local-model cost savings against a paid baseline (#421) 2026-06-01 11:06:39 +03:00
minimax.test.ts feat: add MiniMax-M2.7 and MiniMax-M2.7-highspeed model pricing 2026-04-21 05:50:52 -07:00
model-efficiency.test.ts feat(report): add per-model efficiency metrics 2026-05-05 23:36:59 -07:00
models-hoist.test.ts Merge main into feat/multi-provider-plans, remove dead tautology 2026-05-16 10:42:03 -07:00
models-report.test.ts feat(cli): track local-model cost savings against a paid baseline (#421) 2026-06-01 11:06:39 +03:00
models.test.ts feat(models): derive Claude names and fast multipliers automatically 2026-05-31 05:17:14 -07:00
optimize-fs.test.ts Merge main into feat/multi-provider-plans, remove dead tautology 2026-05-16 10:42:03 -07:00
optimize.test.ts Add MCP skill reliability optimizer 2026-05-24 01:43:54 -07:00
parser-claude-cwd.test.ts fix: group Cowork sessions by space name and unify cross-provider project entries (#398) 2026-05-25 13:41:53 -07:00
parser-compact-entry.test.ts Merge main into feat/multi-provider-plans, remove dead tautology 2026-05-16 10:42:03 -07:00
parser-filter.test.ts test: cover filterProjectsByName include/exclude semantics 2026-04-16 15:49:57 -07:00
parser-gemini-cache.test.ts Track agent calls across providers (#340) 2026-05-18 05:51:01 -07:00
parser-large-json-scanner.test.ts Merge main into feat/multi-provider-plans, remove dead tautology 2026-05-16 10:42:03 -07:00
parser-large-session.test.ts Track agent calls across providers (#340) 2026-05-18 05:51:01 -07:00
parser-local-savings.test.ts feat(cli): track local-model cost savings against a paid baseline (#421) 2026-06-01 11:06:39 +03:00
parser-mcp-inventory.test.ts feat(optimize): MCP tool coverage detector with cache-aware costing 2026-05-05 04:13:04 +03:00
parser-skip-line.test.ts Merge main into feat/multi-provider-plans, remove dead tautology 2026-05-16 10:42:03 -07:00
plan-usage.test.ts Track multiple provider plans 2026-05-11 16:33:33 +03:00
plans.test.ts Track multiple provider plans 2026-05-11 16:33:33 +03:00
provider-registry.test.ts feat(providers): add forge provider support (#401) 2026-05-26 03:36:57 -07:00
provider-turn-grouping.test.ts Fix one-shot rate detection for all non-Claude providers (#355) 2026-05-18 15:56:14 -07:00
session-cache.test.ts Normalize Copilot MCP tool names (#374) 2026-05-24 01:35:46 -07:00