diff --git a/src/hermes-session-ledger.ts b/src/hermes-session-ledger.ts index a935f9be..b05a7bb1 100644 --- a/src/hermes-session-ledger.ts +++ b/src/hermes-session-ledger.ts @@ -22,8 +22,11 @@ import type { CachedCall, ProviderSection } from './session-cache.js' // dropped: sealed days are not re-read. This slice does not bump // DAILY_CACHE_VERSION (one cold re-parse for every user) to recover history. -export const HERMES_SESSION_LEDGER_FILENAME = 'hermes-session-ledger.v2.json' -export const HERMES_SESSION_LEDGER_VERSION = 2 as const +// v3 discards the local-only v2 migration candidate. Seeding v2 from the warm +// session cache could preserve lifetime totals while assigning historical +// observations to the migration day, inflating that day's scoped Hermes spend. +export const HERMES_SESSION_LEDGER_FILENAME = 'hermes-session-ledger.v3.json' +export const HERMES_SESSION_LEDGER_VERSION = 3 as const export type HermesCostBasis = 'actual' | 'estimated' | 'calculated' | 'included' diff --git a/src/main.ts b/src/main.ts index b9c38ee7..89e3993d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -55,7 +55,7 @@ const { version } = require('../package.json') // Bump when the menubar payload's rendering semantics change without a package // release or daily-cache version change. The envelope version in session-cache // protects record shape; this protects the meaning of an otherwise valid one. -const STATUS_SNAPSHOT_RENDER_VERSION = 3 +const STATUS_SNAPSHOT_RENDER_VERSION = 4 const STATUS_SNAPSHOT_SEMANTIC_KEY = `${version}:render-${STATUS_SNAPSHOT_RENDER_VERSION}:daily-${DAILY_CACHE_VERSION}` import { loadCurrency, getCurrency, isValidCurrencyCode } from './currency.js' import { CodexThroughputReader, newestCodexSession, renderCodexThroughput } from './codex-throughput.js' diff --git a/src/session-cache.ts b/src/session-cache.ts index abcadb0a..85feccf6 100644 --- a/src/session-cache.ts +++ b/src/session-cache.ts @@ -373,9 +373,11 @@ export const PROVIDER_PARSE_VERSIONS: Record = { // replays (double-counted before), takes the model from the reporting // assistant/message, and keeps agent-injected context out of the preview. dsh: 'seed-aware-v1', - // cost-provenance-v2: preserve Hermes included/estimated/actual status and - // rebuild the provider section alongside the v2 lifetime ledger. - hermes: 'reasoning-output-accounting-v1-est-cost-routed-ids-workspace-pr-v5-cost-provenance-v2', + // cost-provenance-v3: preserve Hermes included/estimated/actual status and + // rebuild the provider section alongside the v3 lifetime ledger. The parse + // bump is required with the ledger bump: seeding a new ledger from a section + // produced under v2 can turn historical accounting deltas into today's use. + hermes: 'reasoning-output-accounting-v1-est-cost-routed-ids-workspace-pr-v5-cost-provenance-v3', 'lingtai-tui': 'token-ledger-registry-activity-v3', 'ibm-bob': 'worktree-project-grouping-v1', // project-path-v1: the parser now records the session's full working diff --git a/tests/hermes-session-ledger.test.ts b/tests/hermes-session-ledger.test.ts index aeb7b84a..4bf207e5 100644 --- a/tests/hermes-session-ledger.test.ts +++ b/tests/hermes-session-ledger.test.ts @@ -245,9 +245,9 @@ describe('hermes session ledger unit', () => { expect(isHermesLedgerPublicationError(caught)).toBe(true) }) - it('does not adopt a v1 ledger after the cost-provenance contract changes', async () => { - await writeFile(join(cacheDir, 'hermes-session-ledger.v1.json'), JSON.stringify({ - version: 1, + it('does not adopt a v2 ledger whose migration could re-date historical observations', async () => { + await writeFile(join(cacheDir, 'hermes-session-ledger.v2.json'), JSON.stringify({ + version: 2, cursors: { default: { corrupt: {