Skip to content

[Bug]: the durable spend ledger has no production caller #4707

Description

@lidge-jun

Client or integration

Other

Area

Proxy and routing

Summary

The #4546 work added a durable spend-reservation ledger so token, identity and pool ceilings survive a restart. Nothing in production reaches it.

The only production call to admitWorkflowTurn() is src/server/index.ts:512, and it passes four arguments, omitting spend. src/lib/workflow-budget.ts:428 therefore never constructs sharedSpendLedger(), no reservation reaches the journal, and markDispatched, settleWorkflowSpend and abandonWorkflowSpend have no production caller. A repository-wide search finds no production configuration supplying SpendReservationPolicy.maxTokens either.

The practical effect: spend-ledger.jsonl is never created by ordinary traffic, and the ceilings the feature advertises remain process-local and count-only, resetting on restart. Nothing regressed — the capability simply is not wired.

Reproduction

  1. Run the proxy and send ordinary traffic.
  2. Look for spend-ledger.jsonl under the OpenCodex home; it is absent.
  3. Read src/server/index.ts:512 against the admitWorkflowTurn signature and the spend branch at src/lib/workflow-budget.ts:422-428.

Suggested fix: reserve at each physical dispatch once model, identity, pool, input tokens and the enforceable output ceiling are known; give every physical retry a unique send id; mark dispatched at the transport boundary and settle or mark lost from terminal usage handling; and expose an operator configuration path for the enforced limits.

Version

2.56.0 (e4a8539)

Operating system

macOS 15.5

Logs or error output

(no output: the code path never runs)

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Activity

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

    bugSomething isn't workinglanded-via-maintainerOriginal PR closed after landing via a maintainer merge trainproxyHTTP proxy, routing, reverse-proxy / management auth

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions