fix: the headline adds only streamed session cost; cache writes without a 5m key

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
garrytanandcapy-ai[bot] committed 2026-10-29 04:50:30 +00:00
1 parent 8364871096
commit 8b572eefec
5 files changed
+17 -10

No files matched your search

+9
View File
@@ -137,6 +137,15 @@ describe('a case shard\'s result records are its one case\'s cost (2026-10-26 tr
expect(r.out).toContain('cost $1.25 known + 5 of 7 trial(s) cost unknown');
});
test('a billed session\'s cost is already in its collector total, so the verdict never adds it again (Codex host, unbound label record)', () => {
const r = report('periodic', dir => {
results(dir, 'skill-e2e-cso', [{ name: '/cso full audit', suite: 'cso', tier: 'e2e', passed: true, duration_ms: 1, cost_usd: 0.5 }]);
fs.writeFileSync(path.join(shard(dir, 'skill-e2e-cso'), 'session-ledger.jsonl'),
JSON.stringify({ key: 'k', runner: 'codex', started_at: 't', elapsed_ms: 1, end: 'completed', billed: true, cost_usd: 0.5 }) + '\n');
});
expect(collector(r.dir).verdict.costUsd).toBe(0.5);
});
// Value: protects=a failed case shard's trial reads its failure class, exit reason, error and cost from the display-labelled record the shard
// wrote, not a generic 'assertion' with the JUnit message (the same attribution the cost fix made; train-gate's INFRA/VERDICT class follows failure_class);
// fails_when=failedRecord is looked up through the old name/case_id-only filter again so the record's class and error are dropped;
+2
View File
@@ -23,6 +23,8 @@ describe('pricing usage', () => {
.toBeCloseTo(4 + 20 + 0.2 + 5, 6);
expect(anthropicUsageCostUsd({ cache_creation_input_tokens: 3_000_000, cache_creation: { ephemeral_5m_input_tokens: 1_000_000, ephemeral_1h_input_tokens: 2_000_000 } }, 'claude-opus-5-5'))
.toBeCloseTo(5 + 16, 6);
expect(anthropicUsageCostUsd({ cache_creation_input_tokens: 3_000_000, cache_creation: { ephemeral_1h_input_tokens: 2_000_000 } }, 'claude-opus-5-5'))
.toBeCloseTo(5 + 16, 6);
expect(anthropicUsageCostUsd({ input_tokens: 10 }, 'no-such-model')).toBeUndefined();
});