Skip to content

refactor(coordinator): extract inference settlement owner - #1027

Closed
Gajesh2007 wants to merge 5 commits into
refactor/coordinator-inference-responsefrom
refactor/coordinator-inference-settlement
Closed

Gajesh2007 wants to merge 5 commits into
refactor/coordinator-inference-responsefrom
refactor/coordinator-inference-settlement

Conversation

@Gajesh2007

@Gajesh2007 Gajesh2007 commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

Inference reservations, refunds and completion accounting were attached to Server across consumer, provider and settlement files. coordinator/inference/settlement now owns those operations through Service, ServiceHolds and Holder, with pricing, finalization, usage and payout files beside their tests. The API keeps HTTP admission, provider-terminal ownership, route observations and consumer-channel signaling.

api/inference_settlement.go binds the existing ledger and startup service-hold map. Store, registry and referral lookups retain their live lookup points, including asynchronous writes. Completion preserves price resolution → reservation finalization → in-memory usage and scheduled durable usage → API observations → referral and concurrent credits → settlement profile stamp → consumer terminal. The durable usage insert remains asynchronous; both credit operations finish before the API signals completion.

Stacked on #1021 (refactor/coordinator-inference-response). Its catalog, HTTP, tool-policy and profiler prerequisites remain inherited. Store transactions, pricing defaults, wire formats and route behavior retain their existing contracts.

Before

flowchart LR
    Request[Inference request] --> Reserve[Server reservation and refund helpers]
    Reserve --> Shared[Shared ledger and hold map]
    Terminal[Provider completion] --> API[api handleCompleteAt and inline accounting]
    API --> Usage[Charge or refund then usage]
    Usage --> Observe[API outcome and timing observations]
    Observe --> Credit[Referral and provider/platform credits]
    Credit --> Client[Consumer completion channels]
    Cancel[Consumer disconnect] --> Park[API settlement holder]
    Park -->|late terminal| API
    Park -->|expiry refund| Reserve
Loading

After

flowchart LR
    Request[Inference request] --> Admission[API admission and spend-cap checks]
    Admission --> Reserve[settlement.Service Reserve / Refund]
    Reserve --> Shared[Shared ledger and ServiceHolds]
    Terminal[Provider completion] --> API[API terminal claim and lifecycle]
    API --> Settle[settlement.Service Complete]
    Settle --> Usage[Same charge/refund and usage order]
    Usage --> Observe[Existing API observation callback]
    Observe --> Credit[Same referral and credit operations]
    Credit --> Client[API signals consumer completion channels]
    Cancel[Consumer disconnect] --> Park[settlement.Holder with API expiry policy]
    Park -->|late terminal| API
    Park -->|expiry refund| Reserve
Loading

Preservation and validation

  • All 1,569 original API/inference test, benchmark, fuzz and example entries remain present once; six accounting/holder tests move beside their owner. Twenty-four production declarations compare token-for-token under explicit ownership mappings, and 4,204 retained declarations compare under the caller mappings. The original pricing, finalization, usage, observation and credit statement blocks retain their order; the new dependency and orchestration boundaries received independent review.
  • Full Go 1.25 API/inference race run: 2,710 passing test/subtest results, API 223.609s, with the same two existing opt-in skips. Command: env -u DATABASE_URL -u EIGENINFERENCE_DATABASE_URL GOTOOLCHAIN=go1.25.0 go test -race ./coordinator/api/... ./coordinator/inference/... -count=1.
  • The new actual-provider-completion fixture pauses real store credit and checks charge/usage before credit, then exact payout before consumer terminal. Its final nonblocking assertions pass against the original refactor(inference): extract response formats and provider-output relays #1021 source via overlay (1.982s) and the candidate (1.621s). A second real ledger/store fixture verifies the observation callback, late referral binding, alias usage, exact credit amounts and reservation finalization.
  • Pinned golangci-lint v2.1.6 / Go 1.25: zero issues. Docs lint: 280 files pass. Current ownership, money-path citations, metric emitters, build/test instructions and the relocated TTFT-calibration citation are updated.

Source 01096c412; final source 641bd53b0. The final source changes only moved-symbol/fee-override comments and the new fixture's bounded terminal assertions after the full race run; all 4,267 other declaration bodies retain exact tokens. Final fixture checks and lint cover that cut.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@vercel

vercel Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
d-inference Ready Ready Preview Sep 14, 2026 7:03pm UTC
d-inference-console-ui-dev Ready Ready Preview Sep 14, 2026 7:03pm UTC
d-inference-landing Ready Ready Preview Sep 14, 2026 7:03pm UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-14T19:06:39.129629Z 5507f10 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Gajesh2007

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 1d11ad8f25

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…/coordinator-inference-settlement

# Conflicts:
#	docs/architecture/cache-aware-routing.md
#	docs/architecture/system-profiler.md
#	docs/developer/build.md
#	docs/developer/test.md
@Gajesh2007

Copy link
Copy Markdown
Member Author

@codex review

Refreshed the parent branch and resolved documentation/source-map conflicts. Existing subsystem implementations and regression tests are preserved. Exact parent composition and independent review pass; all coordinator test packages compile and documentation checks pass.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 5507f10eae

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Gajesh2007

Copy link
Copy Markdown
Member Author

Consolidated into #1056 for review and merge after #1094, #1095 and #1096. #1056 contains this branch's exact head (5507f10eaecb48db90d762f10039f48be4a1dcd2), including its reviewed fixes, with implementations and regressions reconciled into the coordinator subsystem owners. Closing the component PR to collapse the stack; its branch, commits and review history are retained. Follow #1056 for combined validation and merge status.

@Gajesh2007 Gajesh2007 closed this Sep 16, 2026

This branch had an error being deployed

1 failed and 3 active deployments
Preview – d-inference-console-ui-dev — 5507f10e Deployed Sep 14, 2026 by vercel[bot]
Preview – d-inference — 5507f10e Deployed Sep 14, 2026 by vercel[bot]
Preview – d-inference-landing — 5507f10e Deployed Sep 14, 2026 by vercel[bot]
benchmarks — 5507f10e Deployed Sep 14, 2026 by Gajesh2007 via E2E Benchmarks #1304
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant