Skip to content

fix(provider): 0.10.12 — the watchdog restores an enabled provider job launchd lost (port of staging #47) - #1945

Merged
jonathan308 merged 3 commits into
devfrom
fix/watchdog-absent-provider-job
Nov 12, 2026
Merged

jonathan308 merged 3 commits into
devfrom
fix/watchdog-absent-provider-job

Conversation

@jonathan308

@jonathan308 jonathan308 commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Ready for review, for 0.10.12. Head b8d937a47d; CI (dev) run 42694536597: success (attempt 2; attempt 1
lost one unrelated SSD race test). Independent review: approve (2026-11-09; on Mac A, ~/build/merge/mainnet/earnings/review-ports.md
§6): no path found that starts a single-Mac provider beside a running pair, overrides a stop, or fights an update,
Only me or a me-first pause; each new guard has a test that fails without it (three mutants). The remaining race (a
pair starting within seconds of the bootstrap, after a job was gone ≥ 5 min) is acceptable: the serving lock admits
one server, and dev's loaded path has a larger window. Red first, then green, both in CI and locally (see Test plan);
refactor pass done. Port of jonathan308/d-inference-pr-staging#47 (2026-10-03), which never landed, adapted to dev's
pair rules.

Summary

Issue #1104: the watchdog does not restore the provider when launchd boots its job out. On dev the watchdog decides from
"is the job loaded": an absent job is notManaged, so it never enters the outage grace and nothing restarts it until
someone runs darkbloom start. darkbloom stop disables the job, so launchd's override database tells a deliberate
stop apart from a lost job.

This restores an absent job when all of these hold: auto_restart on, the provider's own RunAtLoad plist installed,
an explicit enabled override for its label, and no live provider identity. It then follows the crash path: the
same grace, then a bounded launchctl bootstrap under the lifecycle lease that stop and update hold. A disabled job is
never enabled. Adapted to dev: never for a cluster member's job, or while the pair runs on this Mac
(ClusterService.pairServesHere), which own that job, as the loaded path's pairOwnsServing already does. Both are
checked when the tick starts (Watchdog.recoversAbsentJob) and again under the lease each time the job is sampled, the
last time just before the bootstrap, so a pair that starts during journal replay or a rollback is left alone.

Before

flowchart LR
  A["provider job booted out (still enabled)"] --> B["watchdog: job loaded?"]
  B -- no --> C["notManaged: no grace, no restart"]
  C --> D["provider stays down until darkbloom start"]
  classDef bad fill:#fee2e2,stroke:#b91c1c,color:#7f1d1d
  class C,D bad
Loading

After

flowchart TD
  A["watchdog tick"] --> P{"pair runs here, or a member's job? (recoversAbsentJob)"}
  P -- yes --> L["dev's loaded path, unchanged"]
  P -- no --> R["AbsentProviderRecovery: lifecycle lease"]
  R --> B{"job loaded?"}
  B -- yes --> L
  B -- no --> E{"auto_restart, own single-Mac RunAtLoad plist, enabled override, no live provider, pair not running?"}
  E -- no --> S["stopped or ineligible: nothing (state saved)"]
  E -- yes --> G["replay the update journal; grace"]
  G --> C["candidate: charge once, verified rollback or backoff"]
  C --> E2{"the same checks again, just before the bootstrap"}
  E2 -- no --> S
  E2 -- yes --> K["save launch intent; bounded launchctl bootstrap"]
  K --> I["issued: restart counted / uncertain: guard kept, nothing counted"]
  classDef good fill:#dcfce7,stroke:#15803d,color:#14532d
  class R,G,C,K,I good
Loading

Linked issue

Refs #1104. Original: jonathan308/d-inference-pr-staging#47 (private).

Test plan

  • Red first (48dc8ec11c): AbsentProviderRecovery and its 37 tests, with dev's decision
    (providerLoaded: snapshot.loaded). Locally (Xcode 27.2, CPU sandbox, dev 0f11fbe01a): AbsentProviderRecoveryTests
    13 tests, 30 issues; AbsentProviderRecoveryIntegrationTests 21 tests, 60 issues; the adapter's 3 pass.
    CI (dev) run 42683477962 on the red commit: the same two suites failed (30 and 60 issues), plus one unrelated
    lifecycle test (shutdownWaitsForAppAttestWorkerRetirement, which this commit can't reach: nothing calls the new type).
  • Fix (079817e31e, local): all 37 pass; WatchdogCommandTests (13), PairVersionSplitTests (4),
    UnpairedMacServesNormallyTests (14), WatchdogCrashLoopGuardTests (43), WatchdogDecisionTests (6) pass.
    CI (dev) run 42686401012 on the fix 079817e31e: success (both shards).
  • Refactor pass (b8d937a47d, local): AbsentProvider* 39 tests (adds a cluster member's plist, never
    bootstrapped, and a pair that starts at each of the tick's three samples, which stops the bootstrap);
    UnpairedMacServesNormallyTests|PairVersionSplitTests|WatchdogCommandTests|SoloStopSticksTests 36 (adds
    watchdogAbsentJob); WatchdogCrashLoopGuardTests|WatchdogDecisionTests 49: pass. A mutant without the new checks
    fails exactly the four new tests. CI (dev) run 42694536597 on b8d937a47d: success on attempt 2; attempt 1 lost
    only SSDCheckpointRemovalRaceTests (an SSD checkpoint-store race test this PR can't reach), and the rerun of the
    failed jobs passed.
  • make docs-check (211 files), docs-impact-check --base dev (9 files), changelog check, git diff --check.
  • Not run: a real boot-out on a Mac (the integration tests intercept launchctl and use real files and the real
    lifecycle lock; nothing touches launchd).

Components touched

  • provider-swift (Swift CLI)
  • docs

Protocol / interface changes

  • None. No new configuration key.

Documentation impact

  • docs/provider/cli-reference.md (darkbloom watchdog), docs/developer/test.md;
    changelog.d/watchdog-restores-a-lost-provider-job.md.

Notes for reviewers

  • Door: two-way; the watchdog only adds a restart path for an absent, enabled, installed job.
  • Blast radius: the watchdog tick on single Macs. Extra bounded launchctl calls per tick: one print when the job
    is loaded (two more, print-disabled and print, only while an update's launch intent is pending); when it is
    absent, three for a stopped or ineligible job (print, then print and print-disabled under the lease), five while
    the grace runs, and seven plus the bootstrap on a restart tick. None on a Mac whose pair runs here or whose job is a
    cluster member's.
  • From the original: an uncertain bootstrap keeps staged crash-loop protection and records no restart; a confirmed
    candidate attempt is charged once; rollback errors reload durable state. This path downloads no update.

Refactor pass

The original had an independent final review. The port's independent refactor pass (2026-11-09, b8d937a47d):

  • should-fix, fixed: the pair/member guard ran once, before the lifecycle lease, while the tick then replays the
    journal and may roll back before launchctl bootstrap; nothing the pair does takes that lease. Every snapshot under
    the lease now treats a --cluster-member plist as not the provider's own job and ClusterService.pairServesHere as
    ineligible.
  • should-fix, fixed: the adaptation's routing rule was an untested inline boolean; it is
    Watchdog.recoversAbsentJob, tested beside pairOwnsServing and updates.
  • nits, fixed: the tests' never-compiled ABSENT_JOB_BASELINE / ABSENCE_LABEL_BASELINE branches, a stray MARK
    note, blank lines, a comment that told history instead of the rule.
  • left as is: the pair's start still doesn't take the lifecycle lease, so a pair starting in the milliseconds between
    the last check and launchctl bootstrap can't be excluded here; the serving lock then keeps the single-Mac provider
    from serving beside the part, and the loaded path doesn't revive it while the pair runs (dev's loaded path has the
    same window).

AI usage: ported by Claude Opus 5.5 (S-DINF sweep) at the owner's request. Not for merge until reviewed.

jonathan308 and others added 2 commits November 9, 2026 11:22
…g's grace and restart (red)

Port of jonathan308/d-inference-pr-staging#47 onto dev (issue #1104), in two
steps. This commit adds AbsentProviderRecovery and its 37 tests, with the
decision the watchdog makes on dev: `providerLoaded: snapshot.loaded`. An
installed, explicitly enabled job that launchd no longer holds (booted out,
not stopped) is then `notManaged`, so it never enters the outage grace and
nothing restarts it.

Locally (Xcode 27.2, CPU sandbox) on this tree:
- AbsentProviderRecoveryTests: 13 tests, 30 issues;
- AbsentProviderRecoveryIntegrationTests: 21 tests, 60 issues (grace,
  issuance under the real lifecycle lease, candidate attribution and
  rollback backoff after an absent bootstrap);
- AbsentProviderRecoveryAdapterTests (launchctl result parsing): 3 pass.
Nothing calls the type yet; the next commit makes the decision see an
eligible absent job as managed and wires the watchdog.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lost

Port of jonathan308/d-inference-pr-staging#47 onto dev, for 0.10.12
(issue #1104).

- AbsentProviderRecovery.decision sees an eligible absent job as managed
  (`snapshot.loaded || snapshot.eligible`): auto_restart on, the provider's
  own RunAtLoad plist installed, an explicit "enabled" launchd override, and
  no live provider identity. A job `darkbloom stop` disabled stays stopped:
  the watchdog never enables a disabled job.
- Watchdog.runTick calls AbsentProviderRecovery.handleTick first, under the
  lifecycle lease stop and update hold, with bounded (3 s) launchctl calls.
  Adapted to dev: never for a cluster member's job, or while the pair runs
  on this Mac (ClusterService.pairServesHere), which own that job as the
  loaded path's pairOwnsServing does. A loaded job falls through to dev's
  path unchanged.
- cli-reference.md (darkbloom watchdog), test.md and the changelog fragment
  say so.

Tests: the previous commit's 37 fail with dev's loaded-only decision (90
issues) and pass here. WatchdogCommandTests, PairVersionSplitTests,
UnpairedMacServesNormallyTests, WatchdogCrashLoopGuardTests and
WatchdogDecisionTests pass unchanged (local, CPU sandbox).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
d-inference-landing Ready Ready Preview Nov 9, 2026 8:37pm UTC
darkbloom-status Ready Ready Preview Nov 9, 2026 8:37pm UTC
eigen-homepages-darkbloom Ready Ready Preview Nov 9, 2026 8:37pm UTC

Request Review

…s job again under the lease

Independent refactor pass of this port (#1945).

- The watchdog's tick-start rule (never a cluster member's job, never while
  the pair runs here) is a named, tested predicate,
  `Watchdog.recoversAbsentJob`, beside `pairOwnsServing` and `updates`.
- `AbsentProviderRecovery`'s snapshot checks both again under the lifecycle
  lease: a cluster member's plist is not the provider's own job, and
  `ClusterService.pairServesHere` makes the job ineligible. The last snapshot
  comes just before the bootstrap, so a pair that starts, or a member job
  installed, while journal replay or a rollback runs is left alone. Tests: a
  member's plist is never bootstrapped; a pair that starts at each of the
  tick's three samples stops the bootstrap.
- Removes the tests' ABSENT_JOB_BASELINE / ABSENCE_LABEL_BASELINE branches
  (never compiled), a stray MARK note and blank lines; the decision's comment
  states the rule instead of its history.
- cli-reference.md and test.md say so.

Local (Xcode 27.2, CPU sandbox): AbsentProvider* 39 tests;
UnpairedMacServesNormallyTests, PairVersionSplitTests, WatchdogCommandTests,
SoloStopSticksTests 36; WatchdogCrashLoopGuardTests, WatchdogDecisionTests 49:
pass. A mutant without the new checks fails exactly the four new tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

3 active deployments
Preview – d-inference-landing — b8d937a4 Deployed Nov 9, 2026 by vercel[bot]
Preview – eigen-homepages-darkbloom — b8d937a4 Deployed Nov 9, 2026 by vercel[bot]
Preview – darkbloom-status — b8d937a4 Deployed Nov 9, 2026 by vercel[bot]
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