Repository navigation
Description
Usage ledger merges the same model ID across providers and attributes all spend to the first provider. Confirmed locally at 44e0dcf254975286c0e9dea443b5cd1ca6b23347.
Provider breakdowns and filters lose real usage and attribute another provider's spend to whichever provider was booked first. Overall totals remain 100 cents.
Steps to reproduce:
- Configure two provider catalogs whose valid wire model ID is shared-model. Catalog IDs are unique within a provider file, not across providers.
- For the same organization, member and day, book one request for shared-model through provider-a at 10 cents, then one through provider-b at 90 cents.
- Read Usage metrics and inspect Top models or filter the metrics read by provider-b.
Expected: Provider-specific model rows preserve each request and its provider: provider-a has one request/10 cents, and provider-b has one request/90 cents.
Actual: The unique upsert key omits provider and the conflict update keeps the first non-null provider. The actual read reports a single provider-a row with two requests/100 cents; a provider-b filter reports zero.
Controls: The real writer and PostgreSQL reader/fold run with the current index expression. Distinct model IDs preserve both providers. Both same-ID catalog fixtures pass the actual modelCatalogFileSchema separately, while duplicate IDs within one catalog are rejected. The real chat ledger passes provider and model as separate dimensions.
Source:
- services/platform/backend/domains/governance/service.ts:232-264
- services/platform/backend/db/migrations/0020_governance_usage.sql:30-37
- services/platform/backend/core/governance/get_org_usage_metrics.ts:232-241
- packages/shared/src/schemas/providers.ts:470-478,575-587
- services/platform/backend/domains/chat/store.ts:613-634
Proof: /Users/yannick/.codex/notes/tale-100-findings/governance-proof/frozen/batch-02/usage-ledger-boundaries.ts. Output: /Users/yannick/.codex/notes/tale-100-findings/governance-proof/frozen/batch-02/usage-ledger.log. All real PostgreSQL assertions and catalog-schema controls passed.
python3 /Users/yannick/.codex/notes/tale-100-findings/governance-proof/run-usage-ledger.py
/Users/yannick/.npm/_npx/22f2fe8d8bc13000/node_modules/.bin/bun /Users/yannick/.codex/notes/tale-100-findings/governance-proof/provider-catalog-control.tsSupporting frozen artifacts:
/Users/yannick/.codex/notes/tale-100-findings/governance-proof/frozen/batch-02/usage-ledger-results.json/Users/yannick/.codex/notes/tale-100-findings/governance-proof/frozen/batch-02/run-usage-ledger.py/Users/yannick/.codex/notes/tale-100-findings/governance-proof/frozen/batch-02/provider-catalog-control.ts/Users/yannick/.codex/notes/tale-100-findings/governance-proof/frozen/batch-02/provider-catalog-control.log
Limits: Retained isolated DB tale_gov_usage_20260928_mul03f4q. No provider network calls and no real chat execution; reachable catalog shape and writer inputs are validated locally. No production or real member data changes.
Deduplication: Parent review included the all-state issue index, the accepted audit ledger and focused live GitHub searches; no matching root cause was found.
Independent parent verification: eight component controls passed across the login, legal matter, DSAR and usage UI probes (parent-batch-02-ui.log). The real governance API, usage-ledger PostgreSQL fixture and provider-catalog schema proofs also passed in fresh retained local fixtures.
Activity