Skip to content

fix(daemon): preserve structured command termination outcomes - #130634

Merged
steipete merged 3 commits into
mainfrom
codex/sweep-systemctl-availability-20260826
Aug 27, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/sweep-systemctl-availability-20260826

Conversation

@steipete

@steipete steipete commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where operators checking or repairing Gateway services could have an interrupted or unavailable service-manager command treated as proof that a service was absent or stopped. Doctor could then hide a detected service or proceed with a repair without knowing the service state.

Why This Change Was Made

The daemon command boundary now preserves normal exit, spawn failure, timeout and signal outcomes instead of discarding that information. Service classifiers consume those facts directly. The Systemd activity helper returns the existing Result type; both Doctor paths and the competing-service check preserve unknown outcomes rather than translating them into inactivity.

The detached launchd guard uses one query classifier before and after its existing filesystem scan. Execution failures and signal-range shell statuses cannot become absence merely because partial output contains familiar text. The generated shell remains independent of the installed JavaScript package. The shared handoff test fixture now confines its service scan, state, plist and temporary paths to an owned fixture directory.

User Impact

Doctor retains uncertain service findings and explains why it cannot safely repair them. Normal active, inactive and missing-service results retain their intended behavior. A failed ownership probe no longer permits cleanup or restart decisions based on partial output.

No new configuration, dependency, schema, service policy, timeout, public API or compatibility path is introduced. Production changes are +147/-166 (net -19); tests are +647/-286; the pre-existing assertion-baseline relocation remains net zero.

Evidence

  • Captured failing regressions before each repair. The complete owner and sibling selection passes 614 tests across 13 files, with six unchanged platform skips. After mechanical lint corrections, both affected owner suites were rerun: 279 tests passed. It covers Systemd, launchd, scheduled-task command execution, process execution, Doctor, noninteractive installation, detached handoff, process respawn and updater restart helpers.
  • Real inert child-process proof passes 14 cases across user/system scopes: normal activity exits, an ordinary manager error, missing/non-executable commands, and SIGTERM after partial output. This exercises the actual process adapter and activity classifier; it does not claim a native Linux service deployment.
  • The actual rendered shell failed four regression cases before the classifier repair and passes all 23 cases afterward, including initial/final interrupted queries and executable failures. No operator service was installed, stopped or changed. A separate read-only native launchctl query confirmed normal missing-service exit 113 on this host.
  • The shell classification matches the POSIX exit-status contract. Numeric diagnostics preserve uncertainty rather than claiming a particular signal from an overlapping numeric status.
  • All 29 full changed checks passed on the final 18-file patch, including production/test types, lint, dead-code scans and architecture guards. Fresh cumulative Codex autoreview reports no P0 findings. Independent source review of the process/result consumers and both generated-shell consumers reports no actionable findings. Exact published-head CI remains required before landing.

The latest completed ClawSweeper finding and both rank-up moves are addressed: unknown is-active outcomes remain structured, and timeout/signal coverage reaches the activity boundary and both Doctor consumers. The detached shell classifier is an additional repair of the same invariant. Native Linux deployment, a real detached launchd activation, and packaged installation are not claimed by these isolated proofs.

@steipete steipete self-assigned this Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime commands Command implementations size: M maintainer Maintainer-authored PR labels Aug 27, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 27, 2026, 11:12 AM ET / 15:12 UTC.

ClawSweeper review

What this changes

The PR preserves timeout, signal, and launch-failure outcomes from systemd and launchd commands so Doctor does not mistake interrupted probes for known inactive or absent services.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This maintainer-authored, protected PR remains necessary: the exact head repairs the prior unknown-service-state blocker, with no new actionable defect found. Exact-head CI and normal maintainer merge judgment remain pending.

Priority: P2
Reviewed head: 06c0b291ebcaf4d0185d477b38fb68f13643e31e
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch addresses the prior blocker at the correct owner boundary with focused sibling coverage; remaining gates are normal exact-head CI and maintainer merge review.
Proof confidence 🌊 off-meta tidepool Not applicable: The repository state identifies a maintainer-authored PR, so the external-contributor proof gate does not apply; the PR body nevertheless records inert-process and rendered-shell after-fix evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The repository state identifies a maintainer-authored PR, so the external-contributor proof gate does not apply; the PR body nevertheless records inert-process and rendered-shell after-fix evidence.
Evidence reviewed 5 items Shared termination owner: The command wrapper preserves normal exit versus timeout, signal, and launch-error outcomes, and forces abnormal termination away from success even if a child supplied zero.
Doctor callers fail closed: The Systemd activity owner returns Result<boolean, string>; Doctor leaves repair metadata unchanged on an unknown result and retains uncertain extra services.
Platform sibling coverage: Launchd absence detection now requires a normal exit, while the rendered ownership-probe tests cover partial absence output followed by signals and execution failures.
Findings None None.
Security None None.

Live Verification

Command: pnpm test src/daemon/systemd-unavailable.test.ts

Result: PASS (completed)

$ node --import tsx scripts/test-projects.mts src/daemon/systemd-unavailable.test.ts
[test] starting test/vitest/vitest.daemon.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130634-AxvBhX/target

 ✓  daemon  src/daemon/systemd-unavailable.test.ts (11 tests) 1252ms
     ✓ rejects partial status after timeout  1022ms

 Test Files  1 passed (1)
      Tests  11 passed (11)
   Start at  15:13:09
   Duration  2.94s (transform 1.35s, setup 1.04s, import 262ms, tests 1.25s, environment 0ms)

[test] passed 1 Vitest shard in 9.50s

Assertions:

  • NOT OBSERVED expect_output: systemd process availability — command exited successfully; expected output was not observed in the captured pane

How this fits together

Gateway service maintenance invokes platform service managers, then Doctor and lifecycle flows classify the response before reporting or changing a service. This PR changes the shared command-result boundary that feeds those classifications.

flowchart LR
  A[Service manager command] --> B[Daemon command result]
  B --> C{Normal exit?}
  C -->|Yes| D[Known service classifier]
  C -->|No| E[Uncertain service result]
  D --> F[Doctor and lifecycle flow]
  E --> F
Loading

Decision needed

Question Recommendation
After exact-head CI completes, should this maintainer-authored daemon repair be merged as the canonical fix for uncertain service-manager probes? Merge after green exact-head gates: Accept the reviewed owner-boundary repair once CI and GitHub mergeability confirm the published head against current main.

Why: The PR carries the protected maintainer label and its final merge decision cannot be automated by this review.

Before merge

  • Resolve merge risk (P1) - The supplied exact-head CI is incomplete, and this review checkout could not resolve current main/base objects for an additional local three-way comparison because its promisor remote has no DNS access.
Agent review details

Security

None.

PR surface

Source -19, Tests +361, Other 0. Total +342 across 18 files.

View PR surface stats
Area Files Added Removed Net
Source 10 147 166 -19
Tests 7 649 288 +361
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 18 797 455 +342

Review metrics

Metric Value Why it matters
Production versus test delta production -19 net; tests +361 net The PR body reports net-negative production code while adding boundary and rendered-shell regression coverage.

Stored data model

Persistent data-model change detected: migration/backfill/repair: config/assertion-safety-baseline.txt, migration/backfill/repair: src/commands/doctor-gateway-services.ts, unknown-data-model-change: src/commands/doctor-gateway-services.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the shared structured-outcome repair after exact-head CI and mergeability confirm it against current main.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the shared structured-outcome repair after exact-head CI and mergeability confirm it against current main.

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

Yes, at source level: abnormal command termination previously collapsed into an inactive/absent interpretation, while the current head preserves it through the activity and ownership classifiers. The reviewer did not execute the tests because this is a read-only checkout.

Is this the best way to solve the issue?

Yes: the repair belongs at the shared command-result and service-classification owners, and the Doctor consumers now receive an explicit unknown outcome rather than adding downstream guards.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 9c2b86362030.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The repository state identifies a maintainer-authored PR, so the external-contributor proof gate does not apply; the PR body nevertheless records inert-process and rendered-shell after-fix evidence.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: The PR prevents bounded but consequential false service-state classifications during Gateway maintenance.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The repository state identifies a maintainer-authored PR, so the external-contributor proof gate does not apply; the PR body nevertheless records inert-process and rendered-shell after-fix evidence.

Evidence

What I checked:

  • Shared termination owner: The command wrapper preserves normal exit versus timeout, signal, and launch-error outcomes, and forces abnormal termination away from success even if a child supplied zero. (src/daemon/exec-file.ts:25, 06c0b291ebca)
  • Doctor callers fail closed: The Systemd activity owner returns Result<boolean, string>; Doctor leaves repair metadata unchanged on an unknown result and retains uncertain extra services. (src/daemon/systemd-exec.ts:333, 06c0b291ebca)
  • Platform sibling coverage: Launchd absence detection now requires a normal exit, while the rendered ownership-probe tests cover partial absence output followed by signals and execution failures. (src/daemon/launchd-exec.ts:20, 06c0b291ebca)
  • Prior finding provenance: Exact-head blame attributes the repaired command and activity boundaries to the final repair commit. (src/daemon/systemd-exec.ts:345, 06c0b291ebca)
  • Current-main comparison gap: The local partial checkout cannot resolve the supplied main/base revisions or preceding PR heads because its promisor remote is unreachable; final merge handling should perform the normal exact-head CI and mergeability check.

Likely related people:

  • steipete: Exact-head blame attributes the shared command-result and Systemd activity boundary to this repair; the local readable history also identifies the same final daemon commit. (role: current daemon repair author; confidence: high; commits: 06c0b291ebca; files: src/daemon/exec-file.ts, src/daemon/systemd-exec.ts, src/commands/doctor-gateway-services.ts)

Rank-up moves

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

  • Wait for exact-head CI and GitHub mergeability before landing.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-08-27T03:12:08.757Z sha 9ffcbadb1802632bab6a1178b604435cf0ca24e2 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-27T03:55:56.942Z sha 9c043871ca9bb785e7ac256eedbe65292e78bbbe :: found issues before merge. :: [P2] Preserve unknown is-active outcomes
  • reviewed 2026-08-27T06:04:06.554Z sha 3f5c7f7 :: needs changes before merge. :: [P2] Preserve unknown is-active outcomes

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 27, 2026
Interpret service state only after a normal command exit. Carry timeout, signal and spawn failures through the shared command owner, and reuse that boundary in doctor before removing legacy service files.
@steipete
steipete force-pushed the codex/sweep-systemctl-availability-20260826 branch from 9c04387 to 3f5c7f7 Compare August 27, 2026 05:54
@steipete

Copy link
Copy Markdown
Contributor Author

Final repair pushed at 06c0b291ebcaf4d0185d477b38fb68f13643e31e. The reported unknown is-active regression is fixed at the activity owner with Result<boolean, string>; both Doctor consumers retain uncertain findings and avoid rewrites. Normal active/inactive/missing states remain covered.

The same invariant also exposed a detached launchd shell path: partial absence output from a terminated command previously passed the ownership guard. One classifier now runs before and after the filesystem scan and rejects command-execution/signal-range failures before interpreting text. Four captured failures now pass, with all 23 rendered-shell cases green. The shared handoff fixture is confined to owned directories; production handoff behavior is otherwise unchanged.

Validation: 614 owner/sibling tests passed with six existing platform skips before the final mechanical lint correction; both affected suites were then rerun, 279/279 passed. All 29 full changed checks passed on the final cumulative 18-file patch. Real inert-process proof covers 14 user/system cases. Fresh cumulative Codex autoreview found no P0 blockers; independent source review found no actionable issues. Production +147/-166 (net -19); tests +647/-286. Final cumulative patch SHA256: 09cfc75e32ea0e1f2423cc51f38a21f40433a908f9060c1e59030367b9515828.

These are actual process and rendered-shell proofs, not a native Linux deployment, packaged installation or real detached launchd activation. Hosted checks on this exact published head and native prepare/merge remain pending.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 27, 2026
@steipete

steipete commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor Author

The final published head is 06c0b291ebcaf4d0185d477b38fb68f13643e31e. CI run 33085917413 is completed successfully, and a fresh GitHub check reports clean mergeability. The full patch still matches the independently verified process and rendered-shell proof, all 29 changed checks, and the final review.

I read the latest ClawSweeper review and its rank-up list. Its remaining CI/current-main checks are satisfied; no actionable source finding remains. The static stored-data warning does not represent a schema or format change: the assertion baseline changes an existing source-location entry, and Doctor preserves uncertain service state instead of rewriting it. No database, migration, new option, timeout, or public API was added. The canonical owner repair removes 19 net production lines.

Native preparation and merge are proceeding under the authorized maintainer sweep. The earlier Git transport stall was recovered only after its owned processes exited; the successful retry used per-invocation HTTP/2 and a bounded low-speed timeout (the earlier HTTP/1.1 attempt also stalled), with no persistent Git, authentication, or gate changes. Actual native Linux service deployment and detached launchd activation are not claimed; the retained evidence exercises actual subprocesses and the rendered shell without changing operator services.

@steipete
steipete merged commit b426268 into main Aug 27, 2026
216 checks passed
@steipete
steipete deleted the codex/sweep-systemctl-availability-20260826 branch August 27, 2026 16:02
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 28, 2026
…aw#130634)

* fix(daemon): preserve structured command termination outcomes

Interpret service state only after a normal command exit. Carry timeout, signal and spawn failures through the shared command owner, and reuse that boundary in doctor before removing legacy service files.

* test(daemon): cover interrupted service decisions

* fix(daemon): preserve uncertain service probe outcomes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant