Skip to content

fix(cli): surface stale-updater launchd scan failures in deep status - #195977

Merged
roboclaw-bot merged 1 commit into
openclaw:mainfrom
shuisadev:fix/status-deep-launchd-stale-scan-365
Nov 9, 2026
Merged

roboclaw-bot merged 1 commit into
openclaw:mainfrom
shuisadev:fix/status-deep-launchd-stale-scan-365

Conversation

@shuisadev

@shuisadev shuisadev commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

openclaw gateway status --deep on macOS reports a clean bill of health when the stale-updater launchd scan fails. Since #195744, findStaleOpenClawUpdateLaunchdJobs throws when launchctl list fails, but gatherLaunchdJobDiagnostics still folds that failure into an empty array with .catch(() => []). if (stale.length) then adds nothing to the diagnostics object and the terminal prints no warning, so "could not inspect" and "no stale jobs left" are byte-for-byte identical to the user.

  • Problem: the deep stale-updater scan failure has no channel into LaunchdJobDiagnostics, even though the sibling findForeignLaunchdJobs branch in the same function writes foreignLaunchdInspectionError and prints Could not inspect foreign launchd jobs: ....
  • Solution: catch the failure explicitly, store it as staleLaunchdInspectionError (redacted through the same redactSupportDiagnosticLine owner used by fix(commands): warn when the macOS stale-updater launchd scan fails instead of reporting healthy #195744), and render it via a shared launchd inspection warning list.
  • What changed: status.launchd.ts (new field plus try/catch), shared.ts (resolveLaunchdInspectionWarnings for both inspection warnings), status.print.ts (one loop replacing one branch), and focused regressions.
  • What did NOT change: shallow status, the successful stale-job path, foreign-job diagnostics, JSON projection, and the scanner itself. No exit-code or auto-repair behavior was added.

Why This Change Was Made

The scanner fix in #195744 made scan failures observable for openclaw doctor, but status --deep is the documented entry point for diagnosing an interrupted update and still swallowed the same error. Reusing the existing printWarning template and the canonical redaction owner keeps the two outputs consistent: both now say the leftovers were NOT checked instead of implying a healthy host.

  • Best fix: mirroring the sibling foreignLaunchdInspectionError channel is the smallest change that gives the failure a durable place in the diagnostics object, including --json output.
  • Alternative: rethrowing from gatherLaunchdJobDiagnostics was rejected because every gateway status invocation would fail for an advisory scan, and a dedicated warning field would still be needed for the print layer.
  • Alternative: an inline printWarning in status.print.ts was rejected because that file is already at its 700-line cap; consolidating both inspection warnings into shared.ts keeps it under the cap.
  • Risk: warning text is new, so downstream log scrapers matching only the old foreign-jobs warning are unaffected but will see one more line when a stale scan fails. The diagnostics field is additive and optional. status.gather.test.ts is also at its line cap, so its launchd cases were extracted into a sibling *.test-support.ts module; this required an exact test-line allocation.

User Impact

macOS operators running openclaw gateway status --deep after a failed or interrupted update now see an explicit warning instead of a false clean result:

Could not inspect stale OpenClaw updater launchd jobs: launchctl list failed (exit 1): Operation not permitted; interrupted-update leftovers were NOT checked. Check launchctl availability and rerun openclaw doctor.

The same detail is available in --json as service.staleLaunchdInspectionError. When the scan succeeds, output is unchanged. The pre-existing foreign-launchd-jobs warning is unchanged.

Evidence

Real runtime verification used node --import tsx with an ESM resolve hook that replaces only the two launchctl IO boundary modules (daemon/launchd.js, daemon/launchd-foreign-jobs.js) with stubs that make launchctl list reject. The production functions gatherLaunchdJobDiagnostics, resolveLaunchdInspectionWarnings, and printDaemonStatus are imported and executed unchanged; process.platform was not patched.

Command (production sources reverted to origin/main for the pre-fix run, then restored for the post-fix run, using the same input):

$ node --import tsx --import ./register.mjs ./probe.mts

Pre-fix, with the production sources at origin/main:

=== gatherLaunchdJobDiagnostics(env, deep=true) ===
{}
staleLaunchdInspectionError present: false
staleUpdateLaunchdJobs present: false
=== printDaemonStatus (human output, --deep) ===
Service: undefined (undefined)
Host desktop: disabled

Runtime: running (pid 4242)
Troubles: run openclaw status
Troubleshooting: https://docs.openclaw.ai/troubleshooting
Support: https://community.openclaw.ai/

Post-fix, same input:

=== gatherLaunchdJobDiagnostics(env, deep=true) ===
{
  "staleLaunchdInspectionError": "launchctl list failed (exit 1): Operation not permitted"
}
staleLaunchdInspectionError present: true
staleUpdateLaunchdJobs present: false
=== resolveLaunchdInspectionWarnings ===
warning count: 1
WARN: Could not inspect stale OpenClaw updater launchd jobs: launchctl list failed (exit 1): Operation not permitted; interrupted-update leftovers were NOT checked. Check launchctl availability and rerun openclaw doctor.
=== printDaemonStatus (human output, --deep) ===
Service: undefined (undefined)
Host desktop: disabled

Runtime: running (pid 4242)
Could not inspect stale OpenClaw updater launchd jobs: launchctl list failed (exit 1): Operation not permitted; interrupted-update leftovers were NOT checked. Check launchctl availability and rerun openclaw doctor.

Troubles: run openclaw status
Troubleshooting: https://docs.openclaw.ai/troubleshooting
Support: https://community.openclaw.ai/

Shipped-entry before/after comparison for the same launchctl list rejection. Both runs use the identical probe and an isolated state dir (HOME and OPENCLAW_STATE_DIR point at a temporary directory); the only difference is the production sources, frozen at origin/main for "Before" versus the candidate commit for "After". Each column was produced by a separate node --import tsx invocation, and the verbatim terminal output for both is pasted above.

Observation Before (frozen origin/main) After (candidate commit)
gatherLaunchdJobDiagnostics(env, true) result {} { "staleLaunchdInspectionError": "launchctl list failed (exit 1): Operation not permitted" }
staleLaunchdInspectionError key present false true
staleUpdateLaunchdJobs key present false false
resolveLaunchdInspectionWarnings warning count 0 1
Human --deep warning line absent Could not inspect stale OpenClaw updater launchd jobs: ...; interrupted-update leftovers were NOT checked ...
--json service.staleLaunchdInspectionError absent present (redacted detail)
Control: successful scan stale jobs reported, no warning stale jobs reported, no warning (unchanged)
Control: foreign-jobs inspection failure Could not inspect foreign launchd jobs: ... same line (unchanged)

The control rows are the regression guard: the fix only adds a failure channel and does not alter the success path or the pre-existing foreign-jobs warning.

Focused tests (both cases now run on Linux; the previous stale-scan case was gated by it.runIf(process.platform === "darwin") and skipped in CI):

$ CI=true vitest run --config test/vitest/vitest.cli.config.ts src/cli/daemon-cli/status.gather.test.ts src/cli/daemon-cli/status.print.test.ts
 Test Files  2 passed (2)
      Tests  82 passed | 1 skipped (83)

Individual cases:

PASS status.print.test.ts > prints stale updater detected jobs guidance
PASS status.print.test.ts > prints stale updater failed inspection guidance
PASS status.gather.test.ts > surfaces stale updater jobs during deep status
PASS status.gather.test.ts > surfaces stale updater scan failure during deep status

Repository gates, all passing after rebasing onto the latest origin/main:

line-cap ratchet OK: 6 changed source files; no new violations or over-cap growth.
Test lines OK: 6597887; ceiling: 6597887; slack: 0.
max-lines ratchet OK: 395 grandfathered suppressions.
assertion SAFETY ratchet OK: 2380 files, 5405 grandfathered assertions.
oxfmt --check: All matched files use the correct format.

Open PR collision check: on the submission-day open-PR snapshot, changed-file lists were compared for status.launchd.ts, status.print.ts, status.gather.ts, daemon-cli/shared.ts, and launchd-update-jobs.ts; no open PR touches them, and no open PR title covers deep-status launchd or stale-updater scans. #195744 (merged) changed the scanner and the doctor warning; this PR only wires the same failure into status --deep, so it is a follow-up consumer fix, not a duplicate.

What was not tested: a real macOS host with a genuinely failing launchctl (the Linux run substitutes only the launchctl IO boundary), and an actual interrupted-update leftover plist. The successful-scan path was covered by the existing regression plus a control case.

@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@shuisadev
shuisadev marked this pull request as ready for review November 9, 2026 12:53
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S labels Nov 9, 2026
@shuisadev
shuisadev force-pushed the fix/status-deep-launchd-stale-scan-365 branch from ace22b8 to 5ac6744 Compare November 9, 2026 13:08
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 9, 2026
@shuisadev
shuisadev force-pushed the fix/status-deep-launchd-stale-scan-365 branch from 5ac6744 to 992caad Compare November 9, 2026 13:22
@shuisadev

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review.

@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 9, 2026
@clawsweeper

clawsweeper Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR makes deep Gateway status report failures to inspect stale macOS updater launchd jobs.

Example: On macOS, launchctl list exits 1 with Operation not permitted.

  • Before: Deep status omits the failed stale-updater inspection.
  • After: Deep status displays an inspection warning and includes service.staleLaunchdInspectionError in JSON.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused implementation appears correct, but mocked internal execution does not satisfy the required real CLI proof.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A macOS operator cannot distinguish a failed stale-updater inspection from an inspection that found no jobs.
Reason: Reporting an incomplete diagnostic restores useful status information without adding configuration, repair authority, or a competing owner.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this PR open: it fixes a current diagnostic failure, and no concrete patch defect was found.

Priority: P2
Reviewed head: 992caad9143ee9b2b237c767e3f6a5f00f25f8c0

Before merge

  • Add real behavior proof - The supplied terminal output exercises the changed collector and printer on Linux through direct imports with scanner modules replaced by stubs, bypassing CLI dispatch, macOS gating, and the real scanner; provide terminal output, a terminal screenshot, or redacted logs from openclaw gateway status --deep and its --json form on macOS with a failed launchctl inspection, removing IPs, API keys, phone numbers, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.

Findings

None.

Tests

  • Missing end-to-end proof: Provide shipped macOS CLI output for a failed launchctl inspection in human and JSON deep status; the supplied red/green internal-function probe does not establish that entry point or a base-failing committed regression run.
Agent review details

How this fits together

Gateway status gathers launchd diagnostics using the installed service environment and projects discovered jobs or inspection errors into terminal and JSON output.

flowchart TD
 A[Gateway status CLI] --> B[Status gatherer]
 B --> C[Launchd diagnostics]
 C --> D[Updater job scanner]
 D --> E[launchctl list]
 E --> C
 C --> F[Terminal and JSON output]
Loading

Technical review

Best possible solution:

Keep the focused error channel and warning in the existing status owners.

Do we have a high-confidence way to reproduce the issue?

Current-main source establishes the failure: the scanner throws on a nonzero launchctl exit, while deep status catches that rejection as an empty result; no target code was executed.

Is this the best way to solve the issue?

The patch restores the missing distinction between an empty scan and a failed scan through existing diagnostics and rendering owners; the small helper and test extraction fit the documented file-cap constraints.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against cbe182f49c4c.

Provenance checked

  • Stale-updater status failure handling changes intended behavior with a stated reason (7acbb22: The original feature surfaced stale updater jobs through best-effort deep status; the later launchd diagnostic extraction retained empty-result failure handling.)
  • Foreign-launchd warning rendering keeps the original intent (fix: diagnose and repair stray macOS Gateway restart jobs #142230: Status reports foreign launchd inspection failures independently of detected lifecycle jobs; the shared warning list retains that output and adds the missing stale-updater counterpart.)
  • Terminal value encoding keeps the original intent (fix(cli): prevent terminal controls in report values #185927: Diagnostic values must be encoded before terminal styling; the extracted warning renderer continues using terminalText.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit cd98a01 adds src/cli/daemon-cli/status.launchd.ts:34 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: cd98a0172368; files: src/cli/daemon-cli/status.launchd.ts)
  • shuisadev: Raw commit d951d62 adds src/daemon/launchd-update-jobs.ts:156 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d951d623b6a1; files: src/daemon/launchd-update-jobs.ts)

PR surface

Source +26, Tests +53, Other +5. Total +84 across 7 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 3 37 11 +26
Tests 3 87 34 +53
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 5 0 +5
Total 7 129 45 +84

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P2: A bounded macOS diagnostic failure hides an incomplete advisory inspection without changing Gateway operation.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P2: A bounded macOS diagnostic failure hides an incomplete advisory inspection without changing Gateway operation.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add redacted macOS CLI evidence showing the failed stale-updater inspection in human and JSON deep status.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 9, 2026, 8:39 AM ET / 13:39 UTC.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 9, 2026
@roboclaw-bot
roboclaw-bot merged commit fee857b into openclaw:main Nov 9, 2026
139 checks passed
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Thanks, @shuisadev, merged as fee857b with your authorship credited. gateway status --deep now says when the stale-updater launchd scan could not run instead of looking clean. Not yet released.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 10, 2026
…penclaw#195977)

On macOS, `openclaw gateway status --deep` showed nothing when the stale-updater launchd scan failed, so "could not inspect" looked identical to "no stale jobs". The failure is now recorded (redacted) and printed alongside the existing foreign-job inspection warning. Follow-up to openclaw#195744.

Co-authored-by: SunnyShu <[email protected]>
shuisadev pushed a commit to shuisadev/openclaw that referenced this pull request Nov 13, 2026
A failing systemd installation probe was swallowed via .catch(() => null), so a
host with a conflicting systemd scope saw 'all good' in 'status --deep' while
'openclaw doctor' would flag it (same silent-swallow class as openclaw#195977).

- Record the redacted error as gateway.duelingScopesWarningError and print a
  warning in 'status --deep' that names the skipped diagnosis and the remedy.
- Stop swallowing the same probe failure in gateway-cli/run.ts: log it with the
  same recovery step instead of dropping it.
- Move the dueling-scope inspection/print logic and its tests into sibling
  modules to stay within the per-file line-cap ratchet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. cli CLI command changes P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants