Skip to content

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

Closed

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

  1. added
    proxyHTTP proxy, routing, reverse-proxy / management auth
    on Sep 15, 2026
  2. lidge-jun commented on Sep 15, 2026

    @lidge-jun
    OwnerAuthor

    리뷰 · 우선순위 70 / 80

    이 이슈는 #4546에서 넣은 durable spend-reservation ledger가 생산 경로에 한 번도 연결되지 않았다는 지적이다. tip 51d577c3f에서 admitWorkflowTurn의 유일한 생산 호출은 src/server/index.ts 약 512행이고, 인자는 rootId·lane·undefined·threadId 네 개다. spend를 넘기지 않으므로 src/lib/workflow-budget.ts 약 428행의 spend ? sharedSpendLedger() : undefined 분기는 ledger를 만들지 않는다. markDispatched/settleWorkflowSpend/abandonWorkflowSpend의 생산 호출자도 없고, SpendReservationPolicy.maxTokens를 공급하는 생산 설정도 검색되지 않는다.

    regressed 동작은 없다. 기능이 문서·유닛 테스트에는 있는데 실트래픽에서는 spend-ledger.jsonl이 생기지 않고, 광고된 token/identity/pool 천장도 프로세스 로컬 count-only로 남는 상태다. 재시작하면 리셋된다. #4546 에픽이 아직 OPEN인 tip 스냅샷과도 맞다. ‘구현은 있는데 배선이 없다’는 부류라, 계약 문서가 active라고 말하면 과장이다.

    고치려면 모델·identity·pool·input tokens·output ceiling이 확정되는 dispatch 경계에서 예약하고, 물리 재시도마다 고유 send id를 쓰며, transport 경계에서 markDispatched, 종료 usage에서 settle/lost 처리, 운영자 설정으로 한도를 노출해야 한다. 유닛만 초록인 채로 structure 문서를 ‘active’로 두지 말 것.

    라인 src/server/index.ts 512 - admitWorkflowTurn이 spend 없이 호출됨.
    라인 src/lib/workflow-budget.ts 422–428 - spend가 없으면 sharedSpendLedger를 구성하지 않음.
    경로 spend-reservation-ledger 생산 호출 - mark/settle/abandon 생산 호출자 없음.
    경로 설정 - maxTokens 정책 생산 공급 경로 없음.

    메인테이너의 판단이 필요한 지점

    • 2.57에서 배선을 필수 후속으로 올릴지, 문서를 ‘not wired’로 먼저 낮출지.
    • 예약을 HTTP 진입 vs 물리 dispatch 중 어디에 둘지(이슈는 dispatch 쪽).
    • 기본 한도 값과 운영자 opt-in 여부.

    너의 추천
    받아라. 당장은 structure/계약 문구를 ‘primitive only / not on production path’로 정정하고, 배선 PR은 #4546 하위 작업으로 연다. 거짓 active 서술을 먼저 걷어라.

    이 댓글은 grok-bot이 작성했습니다

  3. added a commit that references this issue on Sep 16, 2026
  4. lidge-jun commented on Sep 16, 2026

    @lidge-jun
    OwnerAuthor

    Landed via #4756 at ea1e3ee

  5. lidge-jun commented on Sep 16, 2026

    @lidge-jun
    OwnerAuthor

    Landed via #4756 at ea1e3ee.

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