Skip to content

bug(platform): usage ledger merges the same model ID across providers and attributes all spend to the first provider #3655

Closed

Description

@yannickmonney

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:

  1. Configure two provider catalogs whose valid wire model ID is shared-model. Catalog IDs are unique within a provider file, not across providers.
  2. 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.
  3. 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:

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.ts

Supporting 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions