Repository navigation
fix(daemon): prevent PAM rejection restart cascades - #11911
Conversation
📝 WalkthroughWalkthroughThe macOS login-session death watch now requires a minimum rejection span before retirement. It tracks the first rejection, defers early probes, preserves pending schedules, and resets tracking after successful probes or delayed timer gaps. The daemon configures a 2-second minimum span. Tests use a 120-second window and cover sustained rejection, recovery, resolver suppression, cancellation, and deferred probes. An experimental reliability gate documents the feature and its validation criteria. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR hardens
Confidence Score: 5/5Safe to merge — the change tightens the retirement predicate and adds deterministic coverage; no new code paths can accelerate daemon shutdown. The fix is strictly conservative: it adds a time-floor check before retirement and blocks external triggers from shortening the boundary probe. The deferred path sets consecutiveRejections to REQUIRED-1 and schedules a boundary probe at exactly firstRejectionAtMs + minimumRejectionSpanMs. Timer-gap detection resets the window correctly when sleep/App Nap fires a timer late. All external activity guards consistently check consecutiveRejections > 0 before allowing any probe that could shorten the backoff. The existing convergence path for genuine session death is preserved. Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| src/main/daemon/macos-login-session-death-watch.ts | Core state-machine change; adds minimumRejectionSpanMs guard, firstRejectionAtMs tracking, timer-gap reset, and scheduleProbeNoLaterThan guard. Logic is correct and all external-trigger guards are consistent. |
| src/main/daemon/macos-login-session-death-watch.test.ts | Comprehensive fake-clock test suite covering wake recovery, timer-gap rebaselining, sustained death, resolver suppression, event preemption, and shutdown cancellation. |
| src/main/daemon/daemon-entry.ts | Adds minimumRejectionSpanMs: 2_000 to the E2E timing seam, proportional to the 2 s periodicProbeMs override. No production-path logic changed. |
| config/reliability-gates.jsonc | New experimental gate documents the invariant, oracle, test commands, evidence run, performance budget, and promotion/demotion criteria. |
Reviews (2): Last reviewed commit: "fix(daemon): rebaseline PAM evidence aft..." | Re-trigger Greptile
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/daemon/macos-login-session-death-watch.ts (1)
105-105: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winAlign the e2e death-watch timing with the 120-second retirement contract.
The e2e block overrides
timingwithminimumRejectionSpanMs: 2_000, while the default retirement contract isMINIMUM_REJECTION_SPAN_MS = PERIODIC_PROBE_MS = 120_000. If the e2e probe times are intentionally faster, either setminimumRejectionSpanMsto 120_000 or include fast-recheck logic in this same override.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b8e6757e-688f-49eb-a6a6-67de3a573e5f
📒 Files selected for processing (3)
config/reliability-gates.jsoncsrc/main/daemon/macos-login-session-death-watch.test.tssrc/main/daemon/macos-login-session-death-watch.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- config/reliability-gates.jsonc
- src/main/daemon/macos-login-session-death-watch.test.ts
|
CodeRabbit timing note: no change needed. The E2E-only seam already scales the full cadence together ( |
* fix(daemon): back off transient PAM rejection retirement * fix(daemon): rebaseline PAM evidence after sleep
ELI5
The daemon used PAM and DNS checks like two smoke alarms. After a Mac wakes, both alarms can briefly report trouble even though the login session is still alive. Orca treated three reports over only 20 seconds as proof the session was dead, shut the daemon down, restarted it, and could repeat the same mistake.
This keeps the quick confirmation probes, but they can no longer shut the daemon down unless failures persist across a full, uninterrupted two-minute observation window. Client reconnects and PTY exits cannot shorten that backoff. A sleep/App Nap timer gap restarts the evidence window instead of making the evidence look older. If PAM recovers, the daemon stays alive; if the login session is genuinely dead and DNS is still explicitly unhealthy, the existing cold-recovery path still converges.
Closes #11749.
Root cause
MacosLoginSessionDeathWatchretired after three conclusive rejections at 10-second intervals.onRetirethen crash-exited the daemon; a replacement could encounter the same transient state and repeat the renderer restart cascade.Fix
Reproduction and proof
The deterministic regression reproduces the field-shaped sequence: accepted PAM probe, three conclusive rejections over 20 seconds, unhealthy resolver, then recovery. Before this fix that sequence reached
onRetire; now it performs zero resolver reads and zero retirements until the 120-second boundary, where acceptance preserves the daemon.A second regression advances wall time by one hour without executing the scheduled timer, simulating sleep/App Nap. It proves that the overdue callback resets the rejection window, collects fresh evidence after wake, and recovers without retirement. The sustained-death test separately proves that uninterrupted rejections plus an explicitly unhealthy resolver still retire exactly once.
Freeze and performance analysis
Reliability contract
terminal-provider.login-session-retirement— a GUI-spawned macOS daemon retires for PAM rejection only after prior acceptance, three conclusive rejections spanning at least one uninterrupted 120-second window, and explicitly unhealthy in-process resolver state.config/reliability-gates.jsonc.Verification
pnpm exec vitest run --config config/vitest.config.ts src/main/daemon/macos-login-session-death-watch.test.ts src/main/daemon/daemon-entry.test.ts src/main/providers/macos-tcc-login-shell.test.ts src/main/providers/macos-login-session-pty-probe.test.ts src/main/network/macos-system-resolver-health.test.ts --reporter=dot— 80 passedpnpm typecheck— passedpnpm lint— passed, including reliability manifest, max-lines ratchet, bundled skill, and localization checksoxfmt --checkandgit diff --check— passedProduction readiness scan
Verdict: PASS for branch span
edb5607e28fb587be44079eb4f77efe90b3841ff..f722eaa61909d59585117ea1d2f1c54d4c7a88b2.Residual gaps