Skip to content

provider: say what darkbloom status served counts cover (current run, output tokens, ended-early, paid vs free) - #1605

Merged
Gajesh2007 merged 4 commits into
masterfrom
fix/status-served-session-breakdown
Oct 27, 2026
Merged

Gajesh2007 merged 4 commits into
masterfrom
fix/status-served-session-breakdown

Conversation

@jonathan308

@jonathan308 jonathan308 commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

For provider 0.10.4. 0.10.3 shipped as a hotfix (#1618), and v0.10.2 is tagged, so this can merge. Base: master at f9d1af3d0, the 0.10.2 release source.

Summary

darkbloom status now says what its served counts cover. The counters do not change, only the wording, plus one breakdown line.

  • Status prints Requests served since the daemon started (<uptime> ago): N | output tokens: M.
  • Once N > 0, status adds two lines:
    • K of them ended early on a coordinator cancel or a dropped connection and may be unpaid. (only when K > 0)
    • Paid jobs are listed under Earnings in the console; requests to your own machine are free.
  • Doctor uses the same window. daemon connected ends with N requests served since the daemon started. The usage reporting pass line reads N requests / M output tokens completed since the daemon started, all with usage; the console's Earnings page lists the paid ones. (It used to say reported this session.)
  • Daemon state (daemon-state.json) now records cancellations_partial_complete beside the served totals. The daemon already counted this for the heartbeat.
  • Unchanged: the heartbeat, the protocol, telemetry and the counters themselves.

Why

An operator compared darkbloom status (Requests served: 78 | tokens: 84k) with the console and found none of those requests in Earnings.

We checked the provider, the coordinator (platform master 10b8b4fab) and fleet-wide numbers. The coordinator ledger is correct. The provider's status line had no label, and it counts more than paid work:

  • Window. The counter belongs to the provider loop. It starts at zero on every start, update, crash relaunch or reboot, and when a scheduled availability window opens. ProviderLoop creates AtomicProviderStats and started_at together.
  • Tokens. Output (completion) tokens only, reasoning included; no prompt tokens.
  • What counts. +1 each time the provider settles a coordinator request with inference_complete (ProviderLoop+InferenceHandler.swift, incrementRequestsServed). Two kinds of request the coordinator does not pay for are included:
    • Ended early. A coordinator cancel or a dropped connection after output had been delivered (incrementCancellationsPartialComplete, same path). The coordinator does not pay for a request it has already abandoned, and a terminal sent on a dead socket reaches no coordinator. This is about 1% of serves fleet-wide (per-provider median 0.94%, p90 3.87%).
    • Free. Requests the owner sends to their own machine: "Use my machine" in the console chat, or a self-route key.
  • What does not count. Refusals, errors, cancels before any output (499), local-endpoint requests and internal warmups.
  • The console. Earnings and "Last 24h" list only paid jobs. The machine card shows lifetime totals:
    • JOBS is the coordinator's count;
    • TOKENS/reqs is this same provider counter, summed across restarts and rounded to 3 significant digits.

No systematic loss. The operator's own machine card shows 27.6K provider-reported requests against 27,584 coordinator jobs over the machine's life. The 78 were most likely the operator's own free requests, requests that ended early, or a window mismatch. Only the operator can say which.

Before

Behavior

%%{init: {"flowchart": {"wrappingWidth": 400}}}%%
flowchart LR
    classDef ctx fill:#f1f5f9,stroke:#64748b,color:#0f172a
    classDef bad fill:#fee2e2,stroke:#b91c1c,color:#7f1d1d
    R["One daemon run (5h12m):<br/>78 coordinator requests finished,<br/>3 ended early, some free"]:::ctx
    R -->|"darkbloom status"| S["Requests served: 78 #124; tokens: 84000<br/>(no window, no breakdown)"]:::bad
    R -->|"darkbloom doctor"| D["78 requests / 84000 tokens<br/>reported this session"]:::bad
    S -.->|"operator compares"| E["console Earnings:<br/>paid jobs only"]:::ctx
Loading

Code flow

%%{init: {"flowchart": {"wrappingWidth": 400}}}%%
flowchart LR
    classDef code fill:#e0e7ff,stroke:#4f46e5,color:#1e1b4b
    classDef data fill:#fef3c7,stroke:#b45309,color:#451a03
    classDef ctx fill:#f1f5f9,stroke:#64748b,color:#0f172a
    classDef bad fill:#fee2e2,stroke:#b91c1c,color:#7f1d1d
    H["handleInferenceRequest<br/>sends inference_complete"]:::code
    H -->|"served +1, output tokens;<br/>ended early +1 if cancelled mid-stream"| A["AtomicProviderStats<br/>(one per loop, with started_at)"]:::code
    A -->|"heartbeat: every counter"| C["coordinator"]:::ctx
    A -->|"currentDaemonState()"| F[("daemon-state.json stats:<br/>requests_served, tokens_generated,<br/>usage_gaps")]:::data
    F --> S["Status:<br/>one unlabeled line"]:::bad
    F --> D["DoctorRunner:<br/>reported this session"]:::bad
Loading

After

Behavior

%%{init: {"flowchart": {"wrappingWidth": 400}}}%%
flowchart LR
    classDef ctx fill:#f1f5f9,stroke:#64748b,color:#0f172a
    classDef good fill:#dcfce7,stroke:#15803d,color:#14532d
    R["One daemon run (5h12m):<br/>78 coordinator requests finished,<br/>3 ended early, some free"]:::ctx
    R -->|"darkbloom status"| S["Requests served since the daemon started<br/>(5h12m ago): 78 #124; output tokens: 84000<br/>3 of them ended early … may be unpaid.<br/>Paid jobs are listed under Earnings …;<br/>requests to your own machine are free."]:::good
    R -->|"darkbloom doctor"| D["78 requests / 84000 output tokens<br/>completed since the daemon started;<br/>Earnings lists the paid ones"]:::good
    S -.->|"points to"| E["console Earnings:<br/>paid jobs only (unchanged)"]:::ctx
Loading

Code flow

%%{init: {"flowchart": {"wrappingWidth": 400}}}%%
flowchart LR
    classDef code fill:#e0e7ff,stroke:#4f46e5,color:#1e1b4b
    classDef new fill:#cffafe,stroke:#0e7490,color:#083344
    classDef data fill:#fef3c7,stroke:#b45309,color:#451a03
    classDef ctx fill:#f1f5f9,stroke:#64748b,color:#0f172a
    classDef good fill:#dcfce7,stroke:#15803d,color:#14532d
    H["handleInferenceRequest<br/>(unchanged)"]:::code
    H --> A["AtomicProviderStats<br/>(unchanged)"]:::code
    A -->|"heartbeat (unchanged)"| C["coordinator"]:::ctx
    A -->|"currentDaemonState()"| F[("daemon-state.json stats<br/>+ cancellations_partial_complete<br/>(optional)")]:::data
    F --> SR["Status.servedRequestLines(state:now:)<br/>StatusCommand+ServedRequests.swift"]:::new
    SR --> S["window, ended-early line,<br/>Earnings pointer"]:::good
    F --> D["DoctorRunner:<br/>since the daemon started"]:::good
Loading

Colors: grey = situation or unchanged, indigo = existing code, cyan = new code, amber = daemon state, red = unlabeled output, green = new operator-visible output.

Real-binary darkbloom status excerpt (crafted daemon state: 78 served, 84,000 output tokens, 3 ended early)
Daemon: running (pid 28266, up 5h12m)
Trust: awaiting coordinator status
Warm models: EigenLabs/Qwen3.8-27B-4bit-mtp
Most recently used: EigenLabs/Qwen3.8-27B-4bit-mtp
Requests served since the daemon started (5h12m ago): 78  |  output tokens: 84000
  3 of them ended early on a coordinator cancel or a dropped connection and may be unpaid.
  Paid jobs are listed under Earnings in the console; requests to your own machine are free.
Slot posture: not reported by this daemon (state written 0s ago; upgrade and restart to see KV backends)

Rendered by the debug darkbloom binary in a throwaway HOME with DARKBLOOM_STATE_FILE pointing at the crafted file. The output before and after the refactor pass is identical apart from the pid.

Interface effects

  • Status line wording. The line still starts with Requests served, and | still separates the two counts. The changelog fragment tells script authors what still works:

    Parser Old line New line
    grep '^Requests served' (one line; the hint lines are indented) found found
    awk -F'|', last word of field 1 / field 2 78 / 84000 78 / 84000
    split('|')[0].split(':')[1] 78 78
    regex tokens: (\d+) 84000 84000
    regex Requests served: (\d+) 78 no match
    awk '{print $3}' 78 since
  • Doctor messages. The pass texts of daemon connected and usage reporting change as above. Their levels and checks do not.

  • Daemon state. There is one new optional key, stats.cancellations_partial_complete (UInt64?).

    • An older daemon with this CLI: the key is absent and decodes as nil, so status prints no ended-early line.
    • This daemon with an older CLI: JSONDecoder ignores the unknown key.
    • Only status reads it; the desktop app ignores it. The scheduled-drain and standalone-server state writers leave it nil.
  • No changes to: the heartbeat, the protocol, telemetry, billing or the counters. No console mirror is involved: console-ui/src/lib/telemetry-types.ts mirrors the heartbeat, which is unchanged, and the daemon state is local. No prompt content or new data leaves the machine.

  • Docs:

    • docs/provider/cli-reference.md: the status output entry, which names the window and the restart triggers, links self-route.md for free requests and cites the platform's cumulativeDelta for the machine card's sum;
    • docs/provider/troubleshooting.md: the doctor usage reporting row, and a new row for "served is higher than Earnings".
  • Changelog: changelog.d/status-served-session-counts.md.

Validation

Setup. CPU only (MLX_DEVICE=cpu). Each run used a temporary CFFIXED_USER_HOME, HOME, DARKBLOOM_STATE_FILE, loaded-models file and verified-weights file. The sha256 of ~/.darkbloom/usage-history.json (29cd1d59…) was unchanged before and after every run.

"Before" is the tests-only commit 325befc95 on the f9d1af3d0 code. "After" is this PR's head, 639027569.

Suite Before After
StatusCommandRunTests (window, ended-early line, Earnings pointer) 2 tests fail, 3 issues 3/3
DoctorOperatorDiagnosisTests (doctor window wording) 2 tests fail, 3 issues 4/4
DaemonStateServedCountTests (ProviderCore: the daemon writes the key; the reader decodes it) 1 test fails, 1 issue 1/1
New and updated tests 5 tests fail, 7 issues all pass
Every CLI Status*/Doctor* suite, plus DesktopUsageHistoryTests — 63/63 in 12 suites
Full DarkbloomCLITests — 689/690 (see below)
cd provider-swift && swift build --build-tests
swift test --skip-build --no-parallel --filter 'DarkbloomCLITests\.(Status|Doctor|DesktopUsageHistory|statusLoadReadiness|bootSecurityStatusLine)|ProviderCoreTests\.DaemonStateServedCountTests'
swift test --skip-build --no-parallel --filter 'DarkbloomCLITests'
make docs-check                            # 196 file(s) OK
make docs-impact-check BASE=origin/master  # 11 changed file(s), canonical documentation coverage OK
make changelog-check                       # 2 valid fragment(s)
make changelog-preview                     # renders this entry
  • Full CLI target: 689 of 690 pass. The one failure is ModelsLocationCommandTests.missingEnvironmentImportRefusesWithoutMutation. The isolated HOME has no hub directory, and the test fails the same way on the base code.
  • ProviderCore subset, on f4e9675bb: diagnostics, protocol, heartbeat, coordinator client and Autopilot daemon state pass 178 + 9. The refactor pass changed no ProviderCore code.

Limitations

  • Ended-early is not all unpaid work. A request the coordinator has abandoned can still finish cleanly on the provider before the cancel arrives. It then counts as served but not as ended early. Status cannot say which requests were paid, so it points to Earnings.
  • Free requests are not counted separately. Status only says they are free.
  • Other cancels. A forced stop or restart, or a shutdown drain that times out, also cancels requests in flight. Requests cancelled after output count as ended early, but that process is about to exit.
  • Desktop app unchanged. Its "Requests served" activity panel still shows the session count without the breakdown.
  • Not run: the GPU and native suites, and the full make provider-test.

Refactor pass

Refactor pass: CHANGED (639027569, independent refactor subagent, behavior-preserving).

  • Code. Status.servedRequestLines now takes (state:now:), like its neighbour placementLines(state:now:), and formats the uptime itself. The call site is now one line. The real-binary status output is identical apart from the pid.
  • Docs. Four corrections:
    • the count also restarts when a scheduled availability window opens, because each window starts a new provider loop;
    • "ended early" means after output was delivered;
    • free requests link to self-route;
    • the machine card's sum across restarts cites the platform's cumulativeDelta at its current master.
  • Changelog. The fragment shows the old line as it was printed and says which script patterns still match.
  • Checks. No test changed. Focused tests pass 63/63 + 1/1; the full CLI target passes 689/690 (the known temp-HOME case). docs-check, docs-impact-check (origin/master) and changelog-check pass.

Proposed follow-ups (not in this PR; platform repo)

  1. Console: say what AVG TTFT measures. Label it as recent; it is an EWMA (α = 0.2) of prompt-adjusted committed requests, so the last 5–10 requests dominate. Show large values in seconds: "82.1 s" instead of "82118ms".
  2. Console: label the machine card's TOKENS/reqs as provider-reported lifetime counters, next to the coordinator's JOBS.

Commits

All three are SSH-signed and show as Verified on GitHub.

Commit What
325befc95 Tests only; they fail on the old code (5 tests, 7 issues)
f4e9675bb The fix, the docs and the changelog fragment
639027569 Refactor pass

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

…served counts

darkbloom status prints "Requests served: N | tokens: M" with no window and
no distinction, and doctor calls the same numbers "reported this session".
An operator read them as work the coordinator recorded and paid, and found
none of it in the console ledger.

The counters are this daemon process's own completions since it started.
They count output tokens only and include requests that ended early on a
coordinator cancel or a dropped connection, which the coordinator may not
pay for, and free requests routed to the owner's own machine.

These tests pin the new wording: the status line names the daemon-session
window and output tokens, separates requests that ended early (read from
the daemon state key cancellations_partial_complete) and points at the
console's Earnings page; doctor uses the same window. A ProviderCore test
checks that the daemon writes the early-end count to its state file. All
of them fail on the current code.
An operator compared "Requests served: 78 | tokens: 84k" in darkbloom status
with the console and found none of it in the ledger. The counters are this
daemon process's own completions since it started: every coordinator request
it sent inference_complete for, output tokens only. They include requests
that ended early on a coordinator cancel or a dropped connection, which the
coordinator pays only when it still owns the request (and never after a
coordinator restart), and free requests routed to the owner's own machine.
The console's Earnings page lists only paid jobs, and the machine card shows
lifetime totals.

Status now prints "Requests served since the daemon started (<uptime> ago):
N | output tokens: M", the number of those that ended early, and a pointer
to Earnings for paid jobs (both hint lines only once something was served).
The line keeps its "Requests served" prefix and "|" separator for scripts
that parse it. Doctor describes the same counts as completed since the daemon
started instead of "reported this session".

The daemon now writes cancellations_partial_complete (already counted for the
heartbeat) into the daemon state file; older state files decode it as absent
and print no breakdown. The heartbeat and its counters are unchanged.

Docs: the status output in the CLI reference, the doctor usage-reporting row
and a troubleshooting row for served-versus-Earnings. Changelog fragment
status-served-session-counts.md.
Refactor pass on the served-count wording. Output is unchanged.

Status.servedRequestLines now takes the daemon state and the current time,
like placementLines(state:now:), and formats the uptime itself, so the whole
block is composed in one place and the call site is one line like its
neighbours. A real-binary render of the crafted 78-served state is identical
to the earlier one apart from the pid.

Docs: the count also restarts when a scheduled availability window opens,
because each window starts a new provider loop with fresh counters and start
time. Requests that ended early are counted only after output was delivered.
Free requests to your own machine link to the self-route page. The machine
card's sum across restarts cites the platform's cumulativeDelta at its current
master, and "across sessions" becomes "across restarts". The troubleshooting
row names the window the line shows.

Changelog fragment: show the old line as it was printed, and tell script
authors what still matches (the "Requests served" prefix and the "|") and
what does not (the literal "Requests served:" and fixed word positions).
@vercel

vercel Bot commented Oct 26, 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 Oct 26, 2026 1:32am UTC
d-inference-console-ui-dev Ready Ready Preview Oct 26, 2026 1:32am UTC
d-inference-landing Ready Ready Preview Oct 26, 2026 1:32am UTC
darkbloom-status Ready Ready Preview Oct 26, 2026 1:32am UTC
eigen-homepages-darkbloom Ready Ready Preview Oct 26, 2026 1:32am UTC

Request Review

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Threat model review — advisory

Reviewed head 85083dfe43d4 against base bab16fe8aacb.

Reviewers: anthropic/claude-sonnet-5.5: first pass completed; anthropic/claude-opus-5.5: not needed by escalation policy; openai/gpt-6.1-sol: not needed by escalation policy

No actionable findings in the reviewed text. This is not a security approval.

Models: budgeted Sonnet / selective Opus / selective Sol 6.1. Findings require human validation; this review never requests changes or blocks merging.

Scan completed.

Coverage: 53/53 source units; cross-file integration complete. 0 selected depth batch(es) pending. All threat definitions indexed; relevant full definitions selected. Unchanged callers are not scanned.

Cost this run: $0.0000 reported, $0.0000 reserved with unknown cost; 0 paid request(s), 0 reused batch(es), 0 provider cache-hit tokens.

Saved findings and earlier report · Historical findings are not confirmed resolved.

Bedrock: 11 request(s), 520085 uncached + 0 cache-read + 0 cache-write input / 7607 output tokens; 0 request(s) with unknown usage. OpenRouter backup used 0 time(s). Dollar amounts above cover OpenRouter only; AWS billing is reconciled separately.
Workload allowance: 12 native request(s), including one shared response repair; 500 emergency ceiling. Selected depth and integration rounds are admitted as their scope becomes known.

Brings in #1615, #1618 (provider 0.10.3 hotfix), #1617, #1619 and #1620
(reversible add-on hold).

Conflicts and resolutions:
- docs/provider/cli-reference.md: only the "Last updated" stamp
  conflicted (2026-10-26 here, 2026-10-27 on master). Kept the one
  2026-10-27 stamp; both texts are kept (this branch's served-count lines
  and master's `darkbloom addon` section merged cleanly).

No semantic interplay with #1620: the served counts and the add-on hold's
"Not serving: held by add-on" status line are independent.
@Gajesh2007
Gajesh2007 merged commit 3b88adf into master Oct 27, 2026
24 checks passed
@Gajesh2007
Gajesh2007 deleted the fix/status-served-session-breakdown branch October 27, 2026 18:08
jonathan308 added a commit that referenced this pull request Oct 27, 2026
Brings in #1605 and #1606 (merged), #1566, #1591, #1602 and #1625.

Conflict resolved:
- docs/provider/troubleshooting.md: only the "Last updated" stamp
  conflicted; kept one stamp (2026-10-27). Both sides' text is kept.
jonathan308 added a commit that referenced this pull request Oct 27, 2026
Brings in #1606 (stalled coordinator reconnect; `stop` finishes without a
session) and #1605. Resolutions:

- provider-swift/Sources/ProviderCore/ProviderLoop+Lifecycle.swift
  (conflict): took master's (#1606's) version whole. This branch's changes
  to the file were only the no-session drain (`drainReconnectGrace`, the
  250 ms reconnect poll and `sessionDown`), which #1606 supersedes with its
  `coordinatorSettled` rule; no auto-merged hunk of that drain is kept.
  This branch's other changes are in other files and are unchanged: the
  15 s per-model shutdown bound (`ProviderLoop.shutdownUnloadWait`,
  ProviderLoop+StartupShutdown.swift) and the add-on hold cancelling a
  selected-model recovery load in progress (ProviderLoop+AddonHold.swift,
  from 4b513e5).
- ProviderLifecycleTests: deleted
  `aDrainWithTheCoordinatorConnectionDownFinishes`; it duplicates #1606's
  `drainWithoutARegisteredCoordinatorSessionCompletes`.
  `shutdownDoesNotWaitForeverForAnUnloadThatNeverFinishes` stays.
- docs/provider/cli-reference.md (`darkbloom stop`): deleted the sentence
  saying a drain with the connection down waits up to 10 seconds for the
  session; kept the 15-second per-unload shutdown sentence. #1606 documents
  the no-session drain.
- docs/provider/troubleshooting.md (drain-did-not-complete row): replaced
  "waits 10 seconds for it" with "needs no acknowledgement"; the 15-second
  unload clause stays.
- changelog.d/selected-models-recover.md: cut the drain half of the
  stop/restart/start bullet (#1606's fragment covers it); kept the 15 s
  shutdown bound.
Gajesh2007 added a commit that referenced this pull request Oct 27, 2026
Resolve conflicts with #1605/#1606/#1607 and later master changes:
- docs freshness stamps take the later date;
- cli-reference.md keeps master's status bullets and adds this PR's
  App Attest lease bullet after the trust-verdict bullet;
- StatusCommandRunTests.swift keeps master's trafficVerdict and
  heldProviderHasNoTrafficVerdict tests and this PR's
  lateLeaseRenewalStillAuthorizes test.
No behavior change beyond the two sides.
davidtai added a commit that referenced this pull request Oct 28, 2026
The merge adds #1566, #1591, #1602, #1605, #1606, #1607, #1612, #1621,
#1622, #1623, #1625, #1629, #1630, #1631, #1632 (provider 0.10.4),
#1633, #1644, #1652 and #1653 to this branch.

Conflicts and resolutions:
- CoordinatorClient+Connection.swift: #1606 moves the transport setup
  out of connectAndRun into the static function connectionParameters(for:),
  and puts the connectAndRun header below it. This branch adds the
  session parameter to the same header. The merge keeps the layout of
  master. The moved header has the signature of this branch:
  connectAndRun(_ session: CoordinatorSessionRecorder). Git merged the
  other changes without a conflict: the bounded handshake of master
  (CoordinatorConnectionHandshake.start) and the session recorder of
  this branch (markOpened after register, the session parameter of
  sessionLoop and receiveLoop, and the close-code read).
- docs/provider/cli-reference.md: the runtime constants table. The merge
  keeps the three reconnect rows and the ping/pong row of this branch.
  It adds the handshake deadline row of master after the ping/pong row,
  where master has it.
- docs/provider/troubleshooting.md: only the "Last updated" stamp had a
  conflict (2026-10-26 on this branch, 2026-10-27 on master). The merge
  keeps one stamp, 2026-10-27. Git merged the rows: the backoff citation
  of this branch and the new rows of master.

Each decision has one owner after the merge:
- CoordinatorReconnectPolicy chooses the wait before the next connection
  attempt, after each end of a session or of an attempt.
- CoordinatorConnectionHandshake (#1606) cancels a handshake that does
  not complete in 30 s. runLoop catches the timeout error. That attempt
  did not send register, so the policy gives the next backoff range, as
  on master.
- UnauthorizedConnectionRecovery (#1607, #1633) decides when to start a
  re-registration of a connection that the coordinator refuses. Its
  retry backoff counts re-registrations, not connection attempts, and an
  authorized verdict sets that count to zero. The re-registration closes
  the session. Then the policy chooses the wait, as for each other end.

Checks: against master, the merge has only the changes of this branch,
in its 15 files. The troubleshooting stamp is the one exception: it has
the date of master. Against this branch, the merge has only the changes
of master, in 651 files. The one exception is the connectAndRun header,
which has the session parameter. The gitlinks do not change: libs/mlx
31f550af, libs/mlx-swift 4926d3d9, libs/mlx-swift-lm aee6ebb6.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.

2 participants