Current tests prove the code agrees with itself (e.g. the golden parity test across hook / CLI / renderer in test/shared/turnAccounting.parity.test.ts), but nothing proves the numbers are right. A wrong formula or price that all consumers share passes every test — see #72.
- All fixtures are hand-written (
test/fixtures/turn-accounting/session.jsonl, test/mocks/*), while .claude/rules/testing.md states fixtures use real JSONL data from ~/.claude/projects/.
- Token and cost totals are never cross-checked against an independent source (ccusage, the Usage & Cost Admin API, or an actual invoice).
Related: #72, #73.
Что сделать
- Добавить анонимизированную реальную сессию как golden-фикстуру: несколько моделей, стриминг-фрагменты с одним
requestId, compaction, subagent/sidechain, 1h cache write.
- Посчитать эталонные итоги независимо (отдельный простой скрипт и/или ccusage на той же сессии) и зафиксировать их в тесте с описанием, откуда они взяты.
- Проверять, что
calculateMetrics, CLI (analyzeSession) и hook дают те же токены и стоимость.
- Привести
.claude/rules/testing.md в соответствие с фактическим положением (какие фикстуры реальные, какие синтетические).
Acceptance
Current tests prove the code agrees with itself (e.g. the golden parity test across hook / CLI / renderer in
test/shared/turnAccounting.parity.test.ts), but nothing proves the numbers are right. A wrong formula or price that all consumers share passes every test — see #72.test/fixtures/turn-accounting/session.jsonl,test/mocks/*), while.claude/rules/testing.mdstates fixtures use real JSONL data from~/.claude/projects/.Related: #72, #73.
Что сделать
requestId, compaction, subagent/sidechain, 1h cache write.calculateMetrics, CLI (analyzeSession) и hook дают те же токены и стоимость..claude/rules/testing.mdв соответствие с фактическим положением (какие фикстуры реальные, какие синтетические).Acceptance
pnpm testtesting.mdактуален