Skip to content

fix(provider): reconcile interrupted watchdog launch receipts - #1394

Merged
Gajesh2007 merged 7 commits into
Layr-Labs:masterfrom
darkbloombugs:bugfix/watchdog-launch-receipt-20261008
Oct 21, 2026
Merged

Gajesh2007 merged 7 commits into
Layr-Labs:masterfrom
darkbloombugs:bugfix/watchdog-launch-receipt-20261008

Conversation

@darkbloombugs

@darkbloombugs darkbloombugs commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Recover a candidate's durable launch receipt when the watchdog exits after starting it but before recording success. observeHealthyProvider now persists positively proven launch evidence under the existing update lease, so a running candidate without a heartbeat reaches the existing startup timeout.

The health observation requires a higher known run count or a change between two known process identities for the same job. Missing, partial or unchanged evidence preserves the intent. This prevents an old serving process from acquiring a false timeout and lets a health observation before kickstart retain evidence for the subsequent launch. Shared reconciliation and down-provider recovery behavior are unchanged.

This extends the launch-intent mechanism introduced in #534. No public interface, persistent schema, configuration, version or protocol changes.

Before — reviewed head 5f1b0785

flowchart TD
  I[("Durable launchIntent")] --> H["observeHealthyProvider"]
  H --> R["reconcileLaunchIntent with available snapshot"]
  R --> M{"Saved evidence missing or partial?"}
  M -->|Yes| F["Old process may count as a launch"]
  F --> T["False startup timeout and failure"]
  M -->|No, unchanged before kickstart| D["Intent deleted"]
  D --> L["Later silent launch cannot recover receipt"]
  L --> S["Stabilizing indefinitely"]
  classDef data fill:#fef3c7,stroke:#b45309,color:#78350f
  classDef code fill:#dbeafe,stroke:#2563eb,color:#1e3a8a
  classDef failure fill:#fee2e2,stroke:#dc2626,color:#7f1d1d
  class I data
  class H,R,M code
  class F,T,D,L,S failure
Loading

After

flowchart TD
  I[("Durable launchIntent")] --> H["observeHealthyProvider holds update lease"]
  H --> P{"Same job: known count rises or known identity changes?"}
  P -->|No| R["Retain intent for a later observation"]
  P -->|Yes| C["reconcileLaunchIntent"]
  C --> W[("Persist receipt once with original intent ID")]
  W --> B{"Matching fresh heartbeat?"}
  B -->|Yes| G["Existing stabilization and promotion"]
  B -->|No, startup timeout expires| T["inactiveCandidate enters recovery"]
  T --> F["Charge the pending attempt once"]
  classDef data fill:#fef3c7,stroke:#b45309,color:#78350f
  classDef code fill:#dbeafe,stroke:#2563eb,color:#1e3a8a
  classDef safe fill:#dcfce7,stroke:#16a34a,color:#14532d
  class I,W data
  class H,P,C,B,T code
  class R,G,F safe
Loading

Blue denotes code/control flow, amber durable state, red the reproduced defects, and green preserved intent or bounded recovery.

Validation — October 10

Correction commit: a7631c4e2eca3a9b0a38facc023ec3bcae09ba54, directly following reviewed head 5f1b0785af1d6cbc5d62e633bf0d4e2532ccda67; master remains cea374e88c1fd970859fccc949e3bb5f51513874. Contributor commits are preserved.

  • Baseline at 5f1b0785 with regression tests only: six failing cases, 44 failed assertions, five passing controls. Four cases establish false launch attribution from missing/partial saved evidence; two establish intent loss before a later silent launch. Raw logs and source/binary hashes are retained.
  • Final focused selection: 17 cases in six test functions pass, including all unchanged baseline regressions and controls plus six partial-evidence/job-comparison controls.
  • Affected watchdog/recovery, recovery-state, auto-update controller, cycle and claim suites: 153 test functions, 168 expanded cases, 23 suites pass, with no selected-case skips.
  • swift build --build-tests --jobs 2 --force-resolved-versions passes. Tests use swift test --skip-build --no-parallel --jobs 2 --force-resolved-versions; the focused selector is documented in docs/developer/test.md under “Watchdog launch evidence.”
  • make docs-impact-check BASE=cea374e88c1fd970859fccc949e3bb5f51513874: six changed files pass. make docs-check: 368 files pass.
  • Independent baseline evidence review, dedicated refactor pass, and separate exact-final-patch correctness review passed. The refactor pass clarified one documentation sentence; source/tests needed no cleanup. Reviewers inspected source, callers and retained failing/passing logs without independently rerunning tests.

Environment: Apple Swift 6.3.2, macOS 27.0.1 (26A434), arm64. Existing dependency pins and Package.resolved are unchanged: MLX cb77239b, MLX-Swift 6923a80f, MLX-Swift-LM 3fd4944c; nested MLX-C remains the package-pinned 02cf6f4d rather than independently upgrading its upstream tip. Each command has a 590-second work bound plus ten seconds for teardown, with at most two build jobs and serial test execution. Existing SwiftPM dependency warnings remain in the logs.

The signed correction passed normal hooks and was pushed non-force to private staging first, then this existing public branch; GitHub verifies the signature. Latest-head CI and human review remain separate gates. The PR stays ready for review; no merge, deployment, release or issue closure is requested.

Validation limits

The regression executes the actual WatchdogRecoveryService, updater, update lease and disk-backed recovery store through temporary synthetic installs and loopback release HTTP. Launch snapshots, liveness and restart effects are injected; fixture code-signature verification is disabled. It proves this recovery boundary, not an observed deployed incident or a physical launchd interruption.

The real controller cancellation interleaving, detached update monitor, process-kill lock tests, reaped-child identity test, full provider/native/model suite and signed provider-release installation were not run. A missing saved baseline cannot by itself establish a later silent launch; the stricter healthy path conservatively retains intent until other existing confirmation or recovery paths act. The shared down-provider policy is intentionally outside this correction.


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

@vercel

vercel Bot commented Oct 8, 2026

Copy link
Copy Markdown

@darkbloombugs is attempting to deploy a commit to the EigenLabs Team on Vercel.

A member of the Team first needs to authorize it.

@darkbloombugs
darkbloombugs marked this pull request as ready for review October 10, 2026 14:56
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Threat model review — advisory

Reviewed head 3d7de26dd79e against base b32e90082c3a.

Review not completed for this head. Previous findings are superseded, not confirmed resolved.
Service returned HTTP 409; no automatic paid retry

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

Failure diagnostics: HTTP_ERROR

Coverage: 0/0 source units; cross-file integration pending. 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.

@jonathan308 jonathan308 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed exact head 5f1b078 against current master cea374e. Approval is blocked by two launch-intent ownership cases in the new healthy-path reconciliation. Both were reproduced offline with the verbatim base/head health methods and unchanged production state/snapshot/identity code. Session and daemon dependencies were in-memory stubs, so this is state/method evidence, not full disk or launchd qualification. Documentation coverage and lint pass. No live provider, launchd, hardware or Apple attestation operation was performed.

@darkbloombugs

Copy link
Copy Markdown
Contributor Author

Maintenance refresh published at 8c4f54846af5f9ced10026ab7ff0c37a90192b1c, incorporating master 52b8fd9b. The positive-evidence watchdog correction is preserved. Its two pending changelog bullets now live in changelog.d/1394-watchdog-launch-recovery.md; current master history and both watchdog/App Attest documentation are preserved.

Validation: six watchdog functions / 17 cases rerun from the hash-verified retained executable. No fresh provider build or combined-source compilation. Fourteen changelog tests, fragment validation/preview, 368 documentation checks and the final six-file docs-impact check passed. Historical broader tests remain retained evidence, not a new run.

The existing human changes-requested review and unresolved threads still require re-review. CI approval/results remain separate gates; no passing-CI claim. These CPU fixture tests do not qualify native launchd, Apple operations, a signed release installation or the complete provider suite.

@jonathan308

Copy link
Copy Markdown
Collaborator

Re-reviewed exact head 8c4f54846af5f9ced10026ab7ff0c37a90192b1c against current master 5dc5313e5201e8d84db15adc153ceaf56147cc71. Both earlier findings appear corrected: unknown/unchanged evidence preserves intent, and receipt recovery requires a comparable positive change for the same job. Independent standards and spec/caller reviews found no new blocking defect.

Fresh CPU-only differential replay compiled the verbatim health method plus unchanged production state/snapshot/identity code: 17 scenarios / 87 assertions, with 36 failures at reviewed head 5f1b0785 and zero at this head. The current method/state bytes are unchanged in the locally prepared master refresh. The unchanged recovery-state suite also passed 8 tests. Session persistence/lease and daemon dependencies in the replay are in-memory substitutes; this is not a fresh full-provider build, disk integration rerun, real controller cancellation schedule, or native launchd qualification.

A local conflict resolution preserves master's documentation plus this PR's six-file delta. Both exact-delta docs-impact and full docs lint (374 files) pass; changelog validation passes. It is not pushed: the current pull_request_target/synchronize threat-review workflow can incur paid calls, which this review task is not authorized to trigger. No signing or CI controls were changed.

Remote conflicts and the existing changes-requested review/two unresolved threads remain. CI, Contribution Policy, Integration Tests and E2E Benchmarks are action_required; Vercel requires authorization. Advisory job success still reports incomplete coverage. This evidence does not clear those gates or any separate Gaj review requirement.

@jonathan308

Copy link
Copy Markdown
Collaborator

Refreshed onto master b32e9008 and re-validated.

Conflicts fixed: docs/developer/build.md, docs/developer/test.md, docs/provider/installation.md. Master rewrote build/test docs (#1410), so the test selector now sits in a short "Watchdog Launch Evidence" section of the new test.md, and the obsolete build.md note is gone. No production code changed in the merge.
Cleanup: removed leftover print("LAUNCH_REVIEW …") diagnostics and an unreachable if case .inactiveCandidate block from the tests.

Proof (Swift 6.3.2, macOS arm64):

  • With the fix: the six launch-evidence tests pass, and the full WatchdogRecoveryIntegrationTests suite passes (38 tests).
  • Without the fix (only WatchdogRecoveryService.swift reverted to master, same tests): 6 tests run, 42 assertions fail, for example pendingAttemptID == intentID, attemptStartedAt == 200 and failureCount == 1.
  • make docs-check, docs-impact-check and changelog check all pass.

Independent code review found no correctness issues. Reconciliation runs under the update lease, requires comparable positive evidence for the same label, can't double-charge an attempt, and doesn't extend the timeout. It also works with master's dev-build launchd labels.

@jonathan308
jonathan308 dismissed their stale review October 21, 2026 03:40

Both findings were fixed in later commits and re-proven on head 3d7de26 after merging current master (6/6 targeted tests pass; 42 assertions fail with the fix reverted).

@davidtai davidtai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the current head. The two earlier P2 findings are addressed: reconciliation now requires a baseline, a snapshot for the same label, and comparable evidence (runs advanced with both known, or process identity changed with both known) before calling reconcileLaunchIntent, so an unchanged or partial snapshot can neither arm an attempt for the serving predecessor nor clear an unproven intent. Reads under the existing update session, one write per observation. Tests cover the missing/partial/different-job cases. Resolved the two outdated threads accordingly. Approving; merge once the approved CI run is green.

@Gajesh2007
Gajesh2007 merged commit 927172b into Layr-Labs:master Oct 21, 2026
13 of 18 checks passed
Gajesh2007 added a commit that referenced this pull request Oct 21, 2026
Brings in master through 927172b (#1394, #1524) and the merged-dependency pins through the parent: mlx 71271f08 (Layr-Labs/mlx#36) and mlx-swift 81f58d79 (Layr-Labs/mlx-swift#57). The libs/mlx-swift-lm conflict resolves to 8df7bb62, the squash-merged Layr-Labs/mlx-swift-lm#317 on main (same tree as the SDK this branch's fixes were tested against, a00f4730).
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.

4 participants