codeburn/tests/providers
Resham Joshi 98051b4263
fix(copilot): bill CLI input and cache tokens from session.shutdown (#684)
* fix(copilot): bill CLI input and cache tokens from session.shutdown

Copilot CLI sessions (~/.copilot/session-state/*/events.jsonl) recorded
only outputTokens, because the parser read assistant.message events and
ignored the session.shutdown rollup. That rollup is the sole on-disk
source of a CLI session's input, cache-read and cache-write tokens, so
cost was underreported (in the reported case 35k+ cache-read tokens were
dropped entirely).

Handle session.shutdown in the CLI (non-transcript) JSONL path and emit
one supplementary call per model from modelMetrics.<model>.usage. The
per-turn assistant.message events keep owning output tokens, tools and
turn structure; the shutdown call contributes only the input and cache
tokens they lack, with output excluded, so no dimension double-counts and
the combined cost equals the full CLI-measured cost. usage.inputTokens is
cache-inclusive (input + cache_read + cache_write), so the cache
components are subtracted to recover the uncached input calculateCost
expects. These are real counts written by the CLI, so costIsEstimated is
false. Sessions without session.shutdown (crashed or still running) keep
the exact previous output-only behavior, and the VS Code, JetBrains and
OTel paths are untouched.

Bump the copilot entry in PROVIDER_PARSE_VERSIONS so already-cached CLI
sessions re-parse and pick up the corrected tokens and cost.

* fix(copilot): never emit an empty-timestamp shutdown call

A session.shutdown without its own timestamp and without sessionStartTime
produced a call with an empty timestamp, which the date-range filters in
parser.ts drop silently, erasing exactly the tokens this feature bills.
Fall back to the last stamped event in the session.

* fix(cache): durable orphans survive provider fingerprint changes

Bumping a durable provider's PROVIDER_PARSE_VERSIONS changed its env
fingerprint, and getOrCreateProviderSection replaced the whole section on
mismatch. For copilot OTel orphans the discarded cache entry is the only
remaining record of pruned spans, so the first post-upgrade run silently
and permanently erased month-to-date history. Carry forward exactly the
entries whose source no longer exists; present sources still drop and
re-parse under the new fingerprint, which is the point of a bump.

Regression test forges a pre-upgrade fingerprint on a pruned-source
orphan and asserts it stays counted and cached across the transition.
2026-07-16 10:37:58 -07:00
..
antigravity.test.ts fix(antigravity): stamp mtime fallback at emission, tighten path classification (#612) 2026-07-16 07:49:54 -07:00
claude-config-dirs.test.ts fix(claude): support Windows Desktop sessions via APPDATA (#615) 2026-07-16 02:13:11 -07:00
cline.test.ts Add Cline provider 2026-05-12 00:31:41 +03:00
codebuff.test.ts Merge origin/main into feat/codebuff-provider and scope sessionId by channel 2026-05-01 00:14:18 +05:30
codewhale.test.ts feat: add CodeWhale provider support (#674) 2026-07-16 03:12:28 -07:00
codex.test.ts Include archived Codex sessions in usage reports (#667) 2026-07-16 01:55:25 -07:00
copilot.test.ts fix(copilot): bill CLI input and cache tokens from session.shutdown (#684) 2026-07-16 10:37:58 -07:00
crush.test.ts fix: fix and improve test isolation and collision with environment (#530) 2026-06-20 13:42:10 +02:00
cursor-agent.test.ts fix(cursor-agent): ingest workspace-less CLI transcript layout (#542) 2026-06-22 00:55:01 +02:00
cursor-bubble-dedup.test.ts Menubar and CLI hardening from multi-agent audit (#257) 2026-05-06 22:15:11 -07:00
cursor-large-db-cap.test.ts fix: fix and improve test isolation and collision with environment (#530) 2026-06-20 13:42:10 +02:00
cursor-real-tokens.test.ts fix(cursor): use Cursor's real context tokens for input (#574) (#575) 2026-07-02 04:53:07 +02:00
cursor-workspace-breakdown.test.ts Cursor: per-project breakdown by workspace (closes per-project half of #196) (#296) 2026-05-10 15:35:57 -07:00
cursor.test.ts fix(cursor): map composers to workspace via composer.composerHeaders 2026-07-02 17:51:23 +00:00
devin.test.ts fix(devin): report friendly GPT model names with effort tier (#585) 2026-07-01 16:01:49 +02:00
droid.test.ts Add Droid CLI provider 2026-04-28 20:16:45 +02:00
forge.test.ts feat(providers): add forge provider support (#401) 2026-05-26 03:36:57 -07:00
gemini.test.ts Track agent calls across providers (#340) 2026-05-18 05:51:01 -07:00
grok.test.ts feat(providers): add Grok Build provider (#521) 2026-06-19 17:21:41 +02:00
hermes.test.ts fix(hermes): use sessions.cwd, flag estimated cost, propagate SQLITE_BUSY 2026-06-21 23:50:10 +02:00
ibm-bob.test.ts Add IBM Bob provider with workspace extraction (#316) 2026-05-11 20:54:13 -07:00
kilo-code.test.ts fix(test): kilo-code tests fail on machines with KiloCode installed 2026-06-03 01:03:39 +02:00
kimi.test.ts Add Kimi provider 2026-05-11 19:02:28 +03:00
kiro.test.ts kiro: price v1 executions from credits; unify fallback across parsers 2026-07-14 22:36:08 +00:00
lingtai-tui.test.ts fix(lingtai): harden manifest parsing against wrong-typed fields 2026-07-09 23:48:46 +02:00
mistral-vibe.test.ts fix: fix and improve test isolation and collision with environment (#530) 2026-06-20 13:42:10 +02:00
mux.test.ts feat(providers): add coder/mux as a datasource (#438) 2026-06-06 03:04:24 +02:00
omp.test.ts Merge main into feat/omp-support-model-aliases 2026-04-21 03:16:28 -07:00
open-design.test.ts feat(providers): add open-design provider for per-model usage tracking (#559) 2026-06-28 19:17:23 +02:00
openclaw.test.ts Add OpenClaw, Roo Code, and KiloCode providers (#175) 2026-04-28 09:24:14 -07:00
opencode-file.test.ts fix(opencode): support custom data dir and db prefix (#620) 2026-07-16 02:18:19 -07:00
opencode.test.ts fix(opencode): support custom data dir and db prefix (#620) 2026-07-16 02:18:19 -07:00
pi.test.ts fix(pi): classify native skill loads as Skill, not Read (#588) (#590) 2026-07-01 15:57:31 +02:00
roo-code.test.ts Add OpenClaw, Roo Code, and KiloCode providers (#175) 2026-04-28 09:24:14 -07:00
vercel-gateway.test.ts fix(vercel-gateway): route network sources through aggregation 2026-06-10 00:09:31 +02:00
vscode-cline-parser.test.ts Add VSCodium storage discovery for VS Code-family providers (#233) 2026-05-24 02:32:32 -07:00
warp.test.ts feat: add Warp provider adapter (#350) 2026-05-21 00:19:53 -07:00
zcode.test.ts feat(providers): add ZCode (z.ai GLM-5.2) usage provider (#537) 2026-06-20 21:37:32 +02:00
zed.test.ts fix(zed): top threads up to the cumulative counter 2026-07-02 05:53:40 +02:00
zerostack.test.ts Add zerostack provider (#519) 2026-06-19 14:44:45 +02:00