Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog.d/1394-watchdog-launch-recovery.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Interrupted watchdog launch recovery

- Recover a candidate's launch receipt when the watchdog exits after starting it but before recording success. A running candidate that never produces a heartbeat then reaches the existing startup timeout; missing launch evidence does not count as a failed start.
- Preserve unproven launch intent across health observations before restart. Require comparable saved and current launch evidence so an old serving process cannot acquire a false failed-start timeout when baseline evidence is missing or partial.
19 changes: 19 additions & 0 deletions docs/developer/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,25 @@ This is not real Apple service validation. Physical smoke is optional for normal
publication; official-build registration and runtime Apple authorization remain
distinct. See [release](../operations/provider-release.md).

## Watchdog Launch Evidence

`WatchdogRecoveryIntegrationTests` exercises
`WatchdogRecoveryService.observeHealthyProvider`, the real updater and the
disk-backed recovery store with synthetic bundles, temporary install roots and
loopback release HTTP. Launch snapshots, process liveness and restart callbacks
are injected; no model or MLX kernel runs.

```bash
swift test --skip-build --no-parallel \
--filter 'unprovenLaunchEvidencePreservesIntent|prelaunchHealthObservationRetainsIntent|partialLaunchEvidenceRequiresComparison|interruptedLaunchReceiptTimesOut|unprovenLaunchIntentDoesNotTimeOut|interruptedLaunchReceiptPromotes'
```

It covers missing and partial baseline evidence, intent retention before
restart, later positive run-count or process-identity evidence, the startup
timeout, one-time failure accounting and heartbeat promotion. It does not run
native launchd, the controller cancellation interleaving or a signed release
installation.

## Public Fixtures And Private Qualification

Public protocol JSON and prompt golden vectors contain fixed inputs and expected
Expand Down
16 changes: 15 additions & 1 deletion docs/provider/installation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Install, update, and uninstall the provider

> Last updated: 2026-10-09
> Last updated: 2026-10-20

How to put the `darkbloom` CLI on an Apple Silicon Mac with `scripts/install.sh`,
what the script verifies before it touches an existing install, how the binary
Expand Down Expand Up @@ -211,6 +211,20 @@ that exact version is blocked; a newer release installs normally.
`darkbloom update --override-quarantine` reinstalls it anyway, and
`darkbloom doctor` reports the quarantine under `up to date`.

If the watchdog exits after starting a candidate but before recording the
launch receipt, its next health observations reconcile the saved intent with
launchd's run count or process identity for the same job. For each comparison,
both saved and current values must be known; either a higher run count or a
changed process identity proves a launch. A proven launch receives the existing
startup timeout from reconciliation;
repeated observations do not extend it. Missing or unchanged evidence preserves
the intent for a later observation without arming a failed-start timeout. This
includes a health observation before restart and a previously unreadable process
identity becoming available without other evidence of a launch. This also covers
a candidate that remains running without a heartbeat
(`provider-swift/Sources/ProviderCore/Service/WatchdogRecoveryService.swift`,
`observeHealthyProvider`).

The unprivileged updater never touches the root fan helper; after an update run
`sudo darkbloom fan enable` again if you use [fan control](./fan-control.md).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,29 @@ public struct WatchdogRecoveryService: Sendable {

do {
var state = try session.readState()
let before = state
// The previous watchdog may have exited after kickstart but
// before persisting its launch receipt. Require comparable
// evidence of a new launch; a health tick can precede kickstart.
// Keep unproven intent available for a later observation.
if let baseline = state.candidate?.launchIntent?.baseline,
let snapshot = deps.launchSnapshot(),
snapshot.label == baseline.label
{
let runsAdvanced = if let previous = baseline.runs, let current = snapshot.runs {
current > previous
} else {
false
}
let processChanged = if let previous = baseline.process, let current = snapshot.process {
current != previous
} else {
false
}
if runsAdvanced || processChanged {
_ = state.reconcileLaunchIntent(snapshot: snapshot, now: now)
}
}
guard let candidate = state.candidate else { return .noCandidate }
let freshMatchingHeartbeat: Bool
if let daemonState {
Expand All @@ -629,7 +652,6 @@ public struct WatchdogRecoveryService: Sendable {
freshMatchingHeartbeat = false
}

let before = state
let promoted = state.observeCandidateHealth(
healthySignal: freshMatchingHeartbeat,
processStartedAt: daemonState?.startedAt,
Expand Down
Loading
Loading