Repository navigation
provider: say what darkbloom status served counts cover (current run, output tokens, ended-early, paid vs free) - #1605
Conversation
…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).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Threat model review — advisoryReviewed head 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. |
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.
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.
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.
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>
Summary
darkbloom statusnow says what its served counts cover. The counters do not change, only the wording, plus one breakdown line.Requests served since the daemon started (<uptime> ago): N | output tokens: M.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.daemon connectedends withN requests served since the daemon started.Theusage reportingpass line readsN requests / M output tokens completed since the daemon started, all with usage; the console's Earnings page lists the paid ones.(It used to sayreported this session.)daemon-state.json) now recordscancellations_partial_completebeside the served totals. The daemon already counted this for the heartbeat.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
master10b8b4fab) and fleet-wide numbers. The coordinator ledger is correct. The provider's status line had no label, and it counts more than paid work:ProviderLoopcreatesAtomicProviderStatsandstarted_attogether.inference_complete(ProviderLoop+InferenceHandler.swift,incrementRequestsServed). Two kinds of request the coordinator does not pay for are included: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%).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"]:::ctxCode 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"]:::badAfter
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)"]:::ctxCode 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"]:::goodColors: grey = situation or unchanged, indigo = existing code, cyan = new code, amber = daemon state, red = unlabeled output, green = new operator-visible output.
Real-binary
darkbloom statusexcerpt (crafted daemon state: 78 served, 84,000 output tokens, 3 ended early)Rendered by the debug
darkbloombinary in a throwawayHOMEwithDARKBLOOM_STATE_FILEpointing 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:grep '^Requests served'(one line; the hint lines are indented)awk -F'|', last word of field 1 / field 2split('|')[0].split(':')[1]tokens: (\d+)Requests served: (\d+)awk '{print $3}'sinceDoctor messages. The pass texts of
daemon connectedandusage reportingchange as above. Their levels and checks do not.Daemon state. There is one new optional key,
stats.cancellations_partial_complete(UInt64?).JSONDecoderignores the unknown key.statusreads 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.tsmirrors 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, linksself-route.mdfor free requests and cites the platform'scumulativeDeltafor the machine card's sum;docs/provider/troubleshooting.md: the doctorusage reportingrow, 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 temporaryCFFIXED_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
325befc95on thef9d1af3d0code. "After" is this PR's head,639027569.StatusCommandRunTests(window, ended-early line, Earnings pointer)DoctorOperatorDiagnosisTests(doctor window wording)DaemonStateServedCountTests(ProviderCore: the daemon writes the key; the reader decodes it)Status*/Doctor*suite, plusDesktopUsageHistoryTestsDarkbloomCLITestsModelsLocationCommandTests.missingEnvironmentImportRefusesWithoutMutation. The isolatedHOMEhas nohubdirectory, and the test fails the same way on the base code.f4e9675bb: diagnostics, protocol, heartbeat, coordinator client and Autopilot daemon state pass 178 + 9. The refactor pass changed no ProviderCore code.Limitations
make provider-test.Refactor pass
Refactor pass: CHANGED (
639027569, independent refactor subagent, behavior-preserving).Status.servedRequestLinesnow takes(state:now:), like its neighbourplacementLines(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.cumulativeDeltaat its currentmaster.HOMEcase).docs-check,docs-impact-check(origin/master) andchangelog-checkpass.Proposed follow-ups (not in this PR; platform repo)
Commits
All three are SSH-signed and show as Verified on GitHub.
325befc95f4e9675bb639027569Need help on this PR? Tag
@codesmith-botwith what you need.