Skip to content

No validation of token/cost totals against real sessions or an external reference #74

Closed

Description

@axisrow

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.

Что сделать

  1. Добавить анонимизированную реальную сессию как golden-фикстуру: несколько моделей, стриминг-фрагменты с одним requestId, compaction, subagent/sidechain, 1h cache write.
  2. Посчитать эталонные итоги независимо (отдельный простой скрипт и/или ccusage на той же сессии) и зафиксировать их в тесте с описанием, откуда они взяты.
  3. Проверять, что calculateMetrics, CLI (analyzeSession) и hook дают те же токены и стоимость.
  4. Привести .claude/rules/testing.md в соответствие с фактическим положением (какие фикстуры реальные, какие синтетические).

Acceptance

  • Golden-тест на реальной сессии входит в pnpm test
  • Источник эталонных чисел задокументирован рядом с фикстурой
  • Фикстура не содержит личных данных (пути, промпты, токены)
  • testing.md актуален

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions