test: describe reportDailyByDate as the durable.days oracle

Extra High MERGE AFTER FIX on 1fa284f. The parity helper is an
independent per-call oracle for durable.days, not a mirror of a
live dailyMap fallback that no longer exists. Helper and test
unchanged.
This commit is contained in:
Aditya Vikram Singh 2026-08-21 22:45:29 +05:30
parent 1fa284fff8
commit 7e51413e21

View file

@ -463,18 +463,19 @@ describe('buildPeriodDataFromDays', () => {
}) })
describe('daily-cache ↔ report daily-bucket parity', () => { describe('daily-cache ↔ report daily-bucket parity', () => {
// The daily cache (history.daily + provider breakdown) and the live report / // The daily cache (history.daily + provider breakdown) and JSON-report
// headline (main.ts daily rollup) must bucket days by the SAME rule, or their // headlines (durable.days from buildDurablePeriod) must bucket days by the
// per-day totals drift and their period sums diverge from current.cost at // SAME rule, or their per-day totals drift and their period sums diverge from
// window boundaries — the V1 audit's constant -$3.45/-81-calls finding. Both // current.cost at window boundaries — the V1 audit's constant -$3.45/-81-calls
// are now PER-CALL for cost/savings/calls (issue #852) with turn-level stats // finding. Both are now PER-CALL for cost/savings/calls (issue #852) with
// still turn-anchored: this asserts per-day equality against a reference // turn-level stats still turn-anchored: this asserts per-day equality against
// that mirrors main.ts buildJsonReport's dailyMap fallback (each call on its // an independent per-call oracle for the durable day aggregation used by
// own date), plus the invariant history.daily Σ == report.daily Σ == total // durable.days (each call on its own date), plus the invariant
// call cost. // history.daily Σ == report.daily Σ == total call cost.
// Mirrors the live report/headline daily rollup fallback in src/main.ts // Independent per-call reference for durable.days (cost/savings/calls bucket
// (cost/savings/calls bucket under each call's own date). // under each call's own date). Not a live buildJsonReport fallback — that
// path was deleted in #1067.
function reportDailyByDate(projects: ProjectSummary[]): Record<string, number> { function reportDailyByDate(projects: ProjectSummary[]): Record<string, number> {
const byDate: Record<string, number> = {} const byDate: Record<string, number> = {}
for (const p of projects) { for (const p of projects) {