Skip to content

provider: recover from a stalled coordinator reconnect, and let stop finish without a session - #1606

Merged
Gajesh2007 merged 5 commits into
masterfrom
fix/coordinator-reconnect-stall
Oct 27, 2026
Merged

Gajesh2007 merged 5 commits into
masterfrom
fix/coordinator-reconnect-stall

Conversation

@jonathan308

@jonathan308 jonathan308 commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Draft for 0.10.3. Do not merge before v0.10.2 is tagged.

Summary

After a coordinator restart, some providers stayed Ready but never registered again, and received no requests until their operator restarted them. This PR fixes two provider bugs behind that:

  • A stalled reconnect now gives up and retries. The client waited for the coordinator connection to become ready with no deadline, so one stalled TLS handshake or WebSocket upgrade blocked the reconnect loop for good. CoordinatorConnectionHandshake now bounds TCP, TLS and the WebSocket upgrade to 30 s (defaultTimeout = 30). On timeout it cancels the connection, and the client backs off and retries like any failed connection.
  • A graceful stop works without a session. With a coordinator client but no registered session, darkbloom stop, restart and start failed with coordinator acknowledgement false even with 0 requests, and left the daemon draining with automatic restart disabled. A drain now completes when no work is left and no session is registered, and the CLI reports coordinator acknowledgement: not needed (no coordinator connection). A registered session must still acknowledge.

Base: master f9d1af3d0 (provider 0.10.2 source).

Why

Operator report. Operators reported providers that kept running and showed Ready, but got no traffic, sometimes for hours, until a manual restart. Their darkbloom status showed Trust: awaiting coordinator status. A graceful darkbloom stop then failed with Drain did not complete: 0 unfinished request(s), coordinator acknowledgement false … pass --force, so they had to restart with --force.

Root cause.

  • Trust: awaiting coordinator status is printed only when the daemon holds no trust_status at all, and the daemon clears it on every connect and disconnect. A registered session normally gets one within seconds, and App Attest sessions get a renewal every 5 s. So these providers were not "connected but unrouted": they had no registered coordinator session.
  • A (fixed here). connectAndRun waited for NWConnection .ready with no deadline. Ping/pong (30 s pong timeout) and heartbeats start only after .ready and registration. A standalone Network.framework harness using the provider's exact parameters showed that a peer that accepts TCP but never answers the TLS handshake or the WebSocket upgrade keeps the connection .preparing for the whole 150 s observation window. Only an unanswered SYN ends on its own, as .waiting(ETIMEDOUT) after 75 s, which the client already handled. One stalled exchange in the restart herd stranded the daemon:
    • runLoop never reached its backoff;
    • the state file stayed fresh, so status, doctor and the watchdog all said "running";
    • the logs went silent;
    • only a process restart recovered it.
  • Stop. performLifecycleDrain counted as drained only when the coordinator acknowledged, or when there was no client object at all. With a client but no registered session, acknowledgeDrain returns false at once, so the outcome was .timedOut. Nothing needs that acknowledgement: a disconnect already cancelled accepted work (cancelAllInflight), and messages produced while disconnected are dropped, not carried to a later connection. The planned-reconnect path already treats "no registered connection" as "no barrier needed". The failed stop left the daemon draining and refusing work with automatic restart disabled, which extended the outage until --force.

Before

Behavior

%%{init: {"flowchart": {"wrappingWidth": 380}}}%%
flowchart LR
    classDef ctx fill:#f1f5f9,stroke:#64748b,color:#0f172a
    classDef bad fill:#fee2e2,stroke:#b91c1c,color:#7f1d1d
    R["Coordinator restart:<br/>every provider reconnects"]:::ctx --> H["Peer accepts TCP, never answers<br/>the TLS handshake or WebSocket upgrade"]:::ctx
    H --> W["Waits for .ready forever:<br/>no deadline, no backoff, no retry"]:::bad
    W --> S["status: Ready, Trust: awaiting coordinator status<br/>no requests until a manual restart"]:::bad
    S -->|"darkbloom stop"| D["Drain did not complete:<br/>0 unfinished request(s),<br/>coordinator acknowledgement false"]:::bad
    D --> F["Left draining, automatic restart<br/>disabled; only --force recovers"]:::bad
Loading

Code flow

%%{init: {"flowchart": {"wrappingWidth": 380}}}%%
flowchart LR
    classDef code fill:#e0e7ff,stroke:#4f46e5,color:#1e1b4b
    classDef bad fill:#fee2e2,stroke:#b91c1c,color:#7f1d1d
    RL["runLoop"]:::code --> CR["connectAndRun"]:::code
    CR --> WC["inline continuation: resumes only on<br/>.ready, .failed, .waiting or .cancelled"]:::bad
    WC -->|"none arrives"| X["suspended forever;<br/>catch and backoff never run"]:::bad
    PLD["performLifecycleDrain"]:::code --> AD["acknowledgeDrain<br/>(false at once without a session)"]:::code
    AD --> C["drained only if acknowledged<br/>or coordinatorClient == nil"]:::bad
    C --> TO[".timedOut with 0 requests"]:::bad
Loading

After

Behavior

%%{init: {"flowchart": {"wrappingWidth": 380}}}%%
flowchart LR
    classDef ctx fill:#f1f5f9,stroke:#64748b,color:#0f172a
    classDef good fill:#dcfce7,stroke:#15803d,color:#14532d
    classDef same fill:#e0e7ff,stroke:#4f46e5,color:#1e1b4b
    R["Coordinator restart:<br/>every provider reconnects"]:::ctx --> H["Peer accepts TCP, never answers<br/>the TLS handshake or WebSocket upgrade"]:::ctx
    H --> T["Gives up after 30 s<br/>and cancels the connection"]:::good
    T --> B["Logs a failed connection, backs off<br/>(1 s doubling to 30 s, jittered), retries"]:::good
    B --> OK["Registers on the next answered attempt;<br/>trust status and traffic return"]:::good
    N["No registered session,<br/>no unfinished work"]:::ctx -->|"darkbloom stop"| ND["Drain drained, 0 unfinished request(s),<br/>coordinator acknowledgement:<br/>not needed (no coordinator connection)"]:::good
    G["Registered session"]:::ctx -->|"darkbloom stop"| GA["Waits for the coordinator<br/>acknowledgement (unchanged)"]:::same
Loading

Code flow

%%{init: {"flowchart": {"wrappingWidth": 380}}}%%
flowchart LR
    classDef code fill:#e0e7ff,stroke:#4f46e5,color:#1e1b4b
    classDef new fill:#cffafe,stroke:#0e7490,color:#083344
    classDef good fill:#dcfce7,stroke:#15803d,color:#14532d
    CR["connectAndRun"]:::code --> HS["CoordinatorConnectionHandshake.start<br/>timeout: config.handshakeTimeout (30 s)"]:::new
    HS -->|".ready"| RDY["onReady installs the session's<br/>failure handler, then registration"]:::code
    HS -->|"terminal state"| TE["CoordinatorError(terminalState:)<br/>(one mapping, also used after .ready)"]:::new
    HS -->|"deadline"| TO["clear handler, cancel,<br/>CoordinatorError.handshakeTimeout"]:::new
    TE --> RL["runLoop catch: .disconnected,<br/>backoff.nextDelay(), retry"]:::code
    TO --> RL
    PLD["performLifecycleDrain"]:::code --> SET["coordinatorSettled = acknowledged, or no client,<br/>or no hasRegisteredConnection()"]:::new
    SET --> DR[".drained only if nothing remains, native owners<br/>and the App Attest worker retired"]:::good
Loading

Colors: grey = situation, red = failure, green = new outcome, indigo = existing or unchanged code and behavior, cyan = new code.

Changes

  • Coordinator/CoordinatorConnectionHandshake.swift (new):
    • CoordinatorConnectionHandshake.start(_:on:timeout:onReady:) starts the connection and returns at .ready. onReady runs on the connection queue before it returns, so the post-ready failure handler is installed with no gap, as before. A terminal state throws as before. The deadline clears the state handler, cancels the connection and throws CoordinatorError.handshakeTimeout(seconds:). A lock-guarded one-shot hands the continuation to exactly one of the state handler and the deadline, so a late state update cannot resume it twice.
    • CoordinatorError(terminalState:) maps .failed, .waiting and .cancelled to connectionClosed in one place, for the handshake and for the session's failure monitor.
  • CoordinatorClient+Connection.swift: connectAndRun uses the helper. The transport setup moved unchanged into CoordinatorClient.connectionParameters(for:), so the tests use the production stack.
  • CoordinatorClientTypes.swift: CoordinatorClientConfig.handshakeTimeout (an optional init argument, defaulting to defaultTimeout; production does not set it) and the handshakeTimeout(seconds:) error case.
  • ProviderLoop+Lifecycle.swift (performLifecycleDrain): when the drain is not acknowledged and not cancelled, the coordinator side counts as settled if the client has no registered session. Everything else that a drain waits for is unchanged.

Interface effects

  • Protocol, heartbeat, daemon state and uploaded telemetry: unchanged.
  • Local drain record: the stderr provider_drain event can now report reason = drained with coordinator_acknowledged = false for a provider that is reconnecting. The fields are unchanged.
  • Logs: a handshake timeout appears as the existing Coordinator connection failed; reconnecting warning and the reconnect telemetry count. There are no new log lines and no prompt content.
  • Swift API: the public CoordinatorError gains a case, which affects exhaustive switches outside ProviderCore (there are none in this repository), and CoordinatorClientConfig.init gains a defaulted argument.
  • Timing: the 30 s deadline is a total budget for TCP, TLS and the upgrade. A connect that never completes now fails after 30 s instead of 75 s; both paths retry with the same backoff.

Merge order with the stuck-provider work

This PR does not duplicate the related stuck-provider work: unauthorized connections, the Traffic: status line, the doctor check and re-registration.

  • Coordinator, fix/stuck-provider-authorization-recovery: in darkbloom-platform, so no shared files.
  • Provider, fix/stuck-provider-wip: not on origin yet. Checked against its latest local commit 0b666e201 (fix/stuck-provider-serving-readiness, also off f9d1af3d0).
    • Only shared file: docs/provider/cli-reference.md, in different sections. This PR changes the drain rule under "Graceful stop and restart" and the runtime-constants row; that branch changes the darkbloom status output list. Both set the stamp to 2026-10-26, and each adds its own changelog fragment.
    • No shared Swift files.
      • This PR: CoordinatorClient+Connection.swift, CoordinatorClientTypes.swift, ProviderLoop+Lifecycle.swift and the new CoordinatorConnectionHandshake.swift.
      • That branch: StatusCommand.swift, DoctorRunner.swift, DaemonStateFile.swift, ProviderLoop.swift, ProviderLoop+Serve.swift, ProviderLoop+Trust.swift, ProviderLoop+Capacity.swift, plus new files.
      • The two branches introduce no conflicting identifiers.
    • Either order works. git merge-tree --write-tree 960747dfe 0b666e201 merges cleanly. Recheck once that branch is pushed, especially if it touches ProviderLoop+Lifecycle.swift, CoordinatorClient* or CoordinatorClientTypes.swift.
    • Complementary, not overlapping. A provider stuck in the handshake (cause A) has no registered session, so that branch's re-registration cannot recover it, because the planned reconnect needs a registered connection; this PR's deadline does.
    • Interaction to review in that branch. noteCoordinatorConnection(connected: false) restarts since on every .disconnected event. A failing reconnect loop emits one .disconnected per attempt, about every 30–60 s with this PR, and every ≤30 s for cause B or a refused port. Its Traffic: line would then say "disconnected 20s ago" during an hour-long outage. Keeping since while the connection stays down avoids that.

Validation

Setup.

  • All runs were CPU-only, on the final head 960747dfe.
  • 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…) and of every other top-level file in ~/.darkbloom was unchanged before and after every run.
  • To fit the disk, the tests were built with swift build --build-tests -debug-info-format none --disable-index-store; this changes only debug info and indexing.

What "before" means. "Before" is the final head with both production fixes reverted to f9d1af3d0 behavior: the original inline .ready wait and the original drain condition. The new tests were kept. The helper file stayed compiled, so the helper-level test still passes there. "Author" is the branch before the refactor pass, c1be71399.

Suite Before Author c1be71399 Final 960747dfe
CoordinatorHandshakeDeadlineTests clientRetriesAfterAStalledHandshake fails for ws and wss: the 60 s time limit is exceeded, there are 0 disconnects, and the client stays in its first handshake (1 accept), with 6 issues 2/2 (ws only) 2/2 tests, 4/4 cases (ws, wss)
ProviderLifecycleTests the 2 no-session tests fail (.timedOut instead of .drained, 3 issues); drainWithARegisteredSessionStillRequiresTheAcknowledgement passes 13/13 14/14 (adds the guard test below)
Coordinator client: connection, registration, reconnect, heartbeat and drain barrier (15 suites plus the free-function tests in CoordinatorClientTests, CapacityEventHeartbeatTests and the heartbeat and registration codec tests) n/a 127/127 127/127
CLI: ServiceDrainTests, ServiceDrainWaitTests, LifecycleRecoveryPublicationTests, LifecycleRecoveryRollbackTests, RestartCommandTests, LogoutCommandTests, StatusLifecycleDrainLineTests n/a 39/39 in 7 suites 39/39 in 7 suites

The 15 coordinator suites:

  • connection and reconnect: CoordinatorIntegrationTests, ServeLoopConnectionTests, AppAttestResumeTransportTests, AppAttestShadowReplyTests, ChunkSenderTests;
  • drain barrier and planned disconnects: UpdateDrainAwarenessTests, CoordinatorLifecycleBarrierTests, PlannedProviderDisconnectTests, CoordinatorModelSwitchTests, ProviderModelSwitchTests, AutopilotModelSwitchOwnershipTests;
  • local drain: StandaloneServerDrainTests, LocalDrainHTTPTests;
  • heartbeat: HeartbeatIdlePolicyTests, PerformanceHeartbeatMaterialityTests.

The two primary suites passed 5 times on the final tree, with no flakes.

New and changed tests:

  • CoordinatorHandshakeDeadlineTests.stalledHandshakeTimesOutAndCancelsTheConnection(scheme:) checks that a silent loopback peer that accepts TCP gets exactly 1 accept, then .handshakeTimeout, then a .cancelled connection, for ws (stalled upgrade) and wss (stalled TLS).
  • CoordinatorHandshakeDeadlineTests.clientRetriesAfterAStalledHandshake(scheme:) checks that the real CoordinatorClient reports two .disconnected events with at least two accepts, never .connected, for ws and wss.
  • ProviderLifecycleTests.drainWithoutARegisteredCoordinatorSessionCompletes: .drained, 0 remaining, not acknowledged.
  • ProviderLifecycleTests.drainWithoutARegisteredSessionStillWaitsForAcceptedWork (guard): with an accepted request and no session, a drain times out with 1 remaining and admission stays closed. After the request finishes, the next drain completes.
  • ProviderLifecycleTests.drainWithARegisteredSessionStillRequiresTheAcknowledgement (guard): a registered session whose coordinator never acknowledges still gives .timedOut, and the mock coordinator received the barrier.
cd provider-swift
swift build --build-tests -debug-info-format none --disable-index-store
swift test --skip-build --no-parallel -debug-info-format none --disable-index-store \
  --filter 'ProviderCoreTests\.(CoordinatorHandshakeDeadlineTests|ProviderLifecycleTests)/'
swift test --skip-build --no-parallel -debug-info-format none --disable-index-store \
  --filter 'DarkbloomCLITests\.(ServiceDrainTests|LifecycleRecoveryPublicationTests|LifecycleRecoveryRollbackTests|ServiceDrainWaitTests|RestartCommandTests|LogoutCommandTests|StatusLifecycleDrainLineTests)/'
# plus the coordinator suites and free functions listed above, in one --filter
cd ..
make docs-check                             # 196 file(s) OK (submodules initialized; no broken links)
make docs-impact-check BASE=origin/master   # 10 changed file(s), canonical documentation coverage OK
make changelog-check                        # 2 valid fragment(s)
make changelog-preview                      # renders this entry

The investigation also checked the handshake helper against the real Network.framework, outside this repository. Compiled unchanged with swiftc -swift-version 6, it gave:

  • a timeout against silent ws and wss peers;
  • .ready at once, with onReady first, against an upgrading peer;
  • an immediate failure against a refused port.

The original inline wait hung against the silent peers.

Limitations

  • Not run: the GPU and native suites, the full make provider-test, and a real coordinator restart. CI must run the full Provider Unit Tests.
  • Cause B, not fixed here (coordinator, platform-owned). At registration, invalid prefix-cache capabilities close the socket with 1008 invalid prefix-cache capabilities: the aggregate hash must equal models[].weight_hash, and the model must be in models. In a heartbeat, the same mismatch is only logged and the cache evidence cleared. So a provider whose live advertisement drifts stays connected until its next reconnect, and from then on every identical re-registration is closed before any trust_status: a reconnect loop about every 30 s, with the same awaiting coordinator status. No concrete 0.10.1 trigger was found.
    • Proposal: in the registration path (coordinator/api/provider/session.go), a capability-only failure should drop PrefixCacheV2Models and PrefixCacheMemoryModels and continue, exactly as the heartbeat path does. It should revalidate so that non-cache errors, such as duplicate or blank model IDs, still close the session. Cache routing stays fail-closed and the provider stays routable. This needs a composed-router contract test in darkbloom-platform.
  • Cause C, not fixed here (provider, security-sensitive). Every registration and re-registration rebuilds the Secure Enclave attestation synchronously on the CoordinatorClient actor. The rebuild runs csrutil (twice), rdma_ctl, diskutil info /, system_profiler SPHardwareDataType, ioreg and an SE signature (AttestationBuilder) through SecurityCommandRunner.live, which has no timeout. If one tool hangs:
    • the actor blocks after .ready, so this PR's deadline does not cover it;
    • the register frame never goes out;
    • stop hangs at sendEventHeartbeat() until the CLI's deadline and still needs --force.
    • Proposals: capture the boot-constant posture (serial, chip, system-volume hash, SIP, ARV, RDMA) once per process, as the "Capture immutable claims" comment in ProviderLoop+Serve.swift intends, and only re-sign on reconnect. Or, at minimum, use SecurityCommandRunner.bounded(timeout:) and build the attestation off the actor with a deadline. The attestation and trust owner should decide.
  • Observability.
    • A stalled handshake now logs Coordinator connection failed; reconnecting on every attempt. The detailed error line uses localizedDescription, and CoordinatorError is not a LocalizedError, so it reads The operation couldn’t be completed. (ProviderCore.CoordinatorError error N.) rather than the timeout text. This is unchanged for every CoordinatorError case.
    • Follow-ups: record the connection state (connecting, transport ready, registered, time of the last trust_status) in the daemon state file, where DaemonState.connectivity exists but is never written. Have status warn "no coordinator session for N min" instead of the neutral awaiting coordinator status.

How to spot a stuck provider

Check Healthy A: stalled handshake (fixed here) B: re-registration rejected C: blocked registration
darkbloom status Authorization: App Attest authorizes this connection … Trust: awaiting coordinator status for more than 1 min same same
darkbloom logs --last 10m a […:coordinator] line every 30 s (the coordinator's transport ping) before: silent since the last Disconnected from coordinator; with this PR: Coordinator connection failed; reconnecting about every 30–60 s while the peer stalls Coordinator connection failed; reconnecting every ≤30 s silent
pgrep -lP <daemon pid> (pid from Daemon: running (pid …)) nothing long-lived nothing nothing a hung diskutil, system_profiler, csrutil, rdma_ctl or ioreg
public /v1/stats listed absent absent absent

sample <daemon pid> 3 tells A from C, and contains no prompt content. With no registered session there is no accepted work to lose, so darkbloom stop --force && darkbloom start (or darkbloom restart --force) is safe. With this PR, a graceful darkbloom stop also works for A and B; C still needs --force.

Components touched

  • provider-swift (Swift CLI)
  • docs

Protocol / interface changes

  • No protocol/interface changes on the wire (Swift API effects above).

Documentation impact

  • Canonical documentation updated:
    • docs/provider/cli-reference.md: the handshake-deadline runtime constant, and the drain rule under "Graceful stop and restart";
    • docs/reference/protocol-messages.md: a drain with no registered session needs no barrier;
    • docs/reference/telemetry-schema.md: when coordinator_acknowledged = false can accompany a drained outcome.

Changelog

  • changelog.d/coordinator-reconnect-stall.md; make changelog-check passes. CHANGELOG.md is untouched.

Refactor Pass

An independent refactor subagent reviewed c1be71399 (behavior-preserving, per AGENTS.md). It found the fix correct:

  • no double resume or leaked handler on timeout;
  • ready, failed, refused and cancelled behave as before;
  • the timeout composes with the existing backoff;
  • the drain completes only with no registered session and nothing in flight.

It pushed 3804763f4:

  • one terminal-state mapping, CoordinatorError(terminalState:);
  • the transport setup moved unchanged into CoordinatorClient.connectionParameters(for:), so the handshake tests use the production stack for ws and wss;
  • coordinatorSettled names the drain condition, with equivalent outcomes;
  • one guard test for accepted work without a session.

It also pushed 960747dfe, a docs-accuracy commit (protocol and telemetry references, the CLI drain rule, the changelog). The focused, coordinator and CLI suites and the docs checks above were rerun on 960747dfe. All commits are signed and GitHub-verified.


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

A coordinator restart makes every provider reconnect at once. The connection
wait in CoordinatorClient.connectAndRun had no deadline, and Network.framework
leaves an NWConnection in .preparing for as long as the peer holds the TLS
handshake or the WebSocket upgrade open. Ping/pong and heartbeats start only
after .ready, so one stalled handshake stranded the reconnect loop: the daemon
kept writing fresh state, status showed "Trust: awaiting coordinator status",
no request arrived, and only a process restart recovered it.

CoordinatorConnectionHandshake bounds the wait to 30 seconds and cancels the
stalled connection, so the reconnect loop backs off and retries.

A provider in that state also could not stop gracefully: the lifecycle drain
required a coordinator acknowledgement even when no session was registered,
so stop, restart and start failed with "coordinator acknowledgement false" and
needed --force. Without a registered session nothing can acknowledge, accepted
work was already cancelled at the disconnect and outbound messages are never
carried to a later connection, so the drain now completes when no work
remains. A registered session still requires the acknowledgement.
Refactor pass over the handshake deadline and the no-session drain; no
behavior change.

- CoordinatorError(terminalState:) maps .failed, .waiting and .cancelled
  once, for both the handshake wait and the session's failure monitor.
- CoordinatorClient.connectionParameters(for:) is the unchanged transport
  setup moved out of connectAndRun, so the handshake tests use the
  production stack and cover the TLS stall (wss) as well as the stalled
  WebSocket upgrade (ws).
- performLifecycleDrain names the condition coordinatorSettled
  (acknowledged, no client, or no registered session); same outcomes.
- New guard test: without a session, accepted work still keeps the drain
  open and a timeout leaves it in place.
- protocol-messages.md: a lifecycle drain with no registered session
  completes without the barrier once accepted work and local response
  writes finish.
- telemetry-schema.md: a reconnecting process, not only a starting or
  schedule-idle one, can drain with coordinator_acknowledged = false.
- cli-reference.md: the no-acknowledgement drain also needs no work left.
- Changelog: a failed stop also left the provider draining.
@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 5:51am UTC
d-inference-console-ui-dev Ready Ready Preview Oct 26, 2026 5:51am UTC
d-inference-landing Ready Ready Preview Oct 26, 2026 5:51am UTC
darkbloom-status Ready Ready Preview Oct 26, 2026 5:51am UTC
eigen-homepages-darkbloom Ready Ready Preview Oct 26, 2026 5:51am UTC

Request Review

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Threat model review — advisory

Reviewed head ae37ee64c9b2 against base bab16fe8aacb.

Reviewers: anthropic/claude-sonnet-5.5: first pass completed; anthropic/claude-opus-5.5: selected depth completed (3 batches); openai/gpt-6.1-sol: selected depth completed (1 batches)

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; human review required.
Cross-file reviewer requests further review; independent human review required; Final reviewer requests further review; independent human review required

Coverage: 55/55 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: 19 request(s), 838591 uncached + 0 cache-read + 44803 cache-write input / 15559 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: 20 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.
- docs/reference/protocol-messages.md: only the "Last updated" stamp
  conflicted. Kept the one 2026-10-27 stamp; this branch's no-session
  drain text and master's busy_reason/busy_since_ms/busy_addon fields
  merged cleanly.

provider-swift/Sources/ProviderCore/ProviderLoop+Lifecycle.swift merged
cleanly: #1620 changes beginServingDrain and the lifecycle monitor, this
branch only the end of performLifecycleDrain (coordinatorSettled).

Interplay with #1620, reviewed: an add-on hold keeps its registered
connection, so the stop path still waits for the coordinator's drain
acknowledgement while held; only a stop without a registered session
skips it. A planned reconnect under a hold goes through the bounded
handshake, and its fresh register still carries the busy fields.
@Gajesh2007
Gajesh2007 merged commit 4ca12a9 into master Oct 27, 2026
24 checks passed
@Gajesh2007
Gajesh2007 deleted the fix/coordinator-reconnect-stall branch October 27, 2026 18:10
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.
jonathan308 added a commit that referenced this pull request Oct 27, 2026
Master moved the coordinator connection handshake into CoordinatorConnectionHandshake.start with a deadline (#1606). The member's attempt hooks (noteMemberAttemptStarted, noteMemberAttemptUnreachable) now wrap that helper; the inline handshake and its HandshakeResumption are gone. CoordinatorClientConfig carries the member role and claim beside master's handshakeTimeout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
jonathan308 added a commit that referenced this pull request Nov 8, 2026
…r another model blocked them

A selected model left cold by memory (skipped by the startup preload, or
unloaded by an Autopilot operation to place another model) is retried from
the capacity tick until it is resident again, evicting only idle models
outside the selection within Autopilot's victim rules. `darkbloom status`
says why it waits and when a saved `enabled_models` differs from the
running selection. Shutdown waits at most 15 s per unload instead of
forever for a slot whose native retirement never finishes.

Rebased onto dev as one commit (was 17 commits plus four master merges on
master). The merges carried the #1606 drain and #1620 add-on hold
resolutions, so the branch's net change is re-applied instead of replaying
each commit. Resolved against dev: #1730's operator model filter
(`operatorModelFilter`) is kept beside this PR's `savedEnabledModels` and
`enabledModelsAtLastSwitch`; `DaemonState.registeredModels` is kept beside
the new optional keys; the add-on hold calls dev's `publishBusy()`; the
recovery invariant in model-autopilot.md is numbered 11 after dev's
operator-filter invariant 10.
jonathan308 added a commit that referenced this pull request Nov 8, 2026
…r another model blocked them

A selected model left cold by memory (skipped by the startup preload, or
unloaded by an Autopilot operation to place another model) is retried from
the capacity tick until it is resident again, evicting only idle models
outside the selection within Autopilot's victim rules. `darkbloom status`
says why it waits and when a saved `enabled_models` differs from the
running selection. Shutdown waits at most 15 s per unload instead of
forever for a slot whose native retirement never finishes.

Rebased onto dev as one commit (was 17 commits plus four master merges on
master). The merges carried the #1606 drain and #1620 add-on hold
resolutions, so the branch's net change is re-applied instead of replaying
each commit. Resolved against dev: #1730's operator model filter
(`operatorModelFilter`) is kept beside this PR's `savedEnabledModels` and
`enabledModelsAtLastSwitch`; `DaemonState.registeredModels` is kept beside
the new optional keys; the add-on hold calls dev's `publishBusy()`; the
recovery invariant in model-autopilot.md is numbered 11 after dev's
operator-filter invariant 10.
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