Repository navigation
refactor(daemon): centralize managed service lifecycle ownership - #119647
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 5, 2026, 11:21 AM ET / 15:21 UTC. ClawSweeper reviewWhat this changesThe PR consolidates managed gateway and node-service identity, environment handling, mutation guards, and systemd lifecycle dispatch without intended behavior changes. Merge readinessKeep this maintainer-owned PR open: current main does not contain the refactor, the prior proof request is now met by a controlled production-owner trace, and no actionable correctness finding was found. Priority: P3 Review scores
Verification
How this fits togetherDaemon service code converts gateway and node settings into launchd, systemd, or Scheduled Task definitions, then performs guarded lifecycle actions. It protects ownership, config-version, environment-source, and secret-file rules before reaching each platform manager. flowchart LR
Config[Gateway and node settings] --> Env[Managed environment policy]
Env --> Definition[Platform service definition]
Definition --> Guards[Ownership and config guards]
Guards --> Actions[Lifecycle actions]
Actions --> Platforms[launchd, systemd, Task Scheduler]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -104. Total -104 across 9 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Retain the single canonical daemon-policy owners and merge this behavior-preserving cleanup after normal maintainer review. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR refactors existing service-management behavior rather than fixing a separately reported failure; its controlled trace verifies preserved lifecycle behavior on the exact head. Is this the best way to solve the issue? Yes. Centralizing the repeated identity, normalization, guard, and dispatch policy at their existing daemon owners removes duplicate behavior without adding a parallel path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4511c9b71f78. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
…cope * origin/main: (70 commits) fix(clickclack): preserve MIME extension for unnamed uploads (openclaw#119646) fix(memory): keep post-ready RPCs responsive (openclaw#119710) fix(browser): preserve locale, timezone, and device overrides (openclaw#119695) fix(agents): stop messaging dedupe from dropping final replies that quote a short tool send (openclaw#118178) test(agents): batch code mode budget proof (openclaw#119699) fix(memory): keep gateway RPCs responsive during startup (openclaw#119676) improve(ui): trail transient session status beside row actions (openclaw#119560) refactor(msteams): consolidate channel action target resolution (openclaw#119632) fix: tail context answers the current user message (openclaw#117364) fix(whatsapp): exercise descriptor-safe credential persistence (openclaw#119621) fix(diagnostics-otel): route OTLP endpoints by signal (openclaw#101655) refactor(skills): consolidate workshop transcript and record normalization (openclaw#119643) fix(video): harden DashScope task and media lifecycle (openclaw#117303) refactor(transcripts): consolidate persistence and export ownership (openclaw#119634) fix: preserve ClickClack discussion state contracts (openclaw#118851) fix(matrix): retire shared E2EE clients safely (openclaw#119570) refactor(cron): unify catch-up persistence and payload encoding (openclaw#119636) refactor(ui): centralize composer attachment and capability controls (openclaw#119650) refactor(daemon): consolidate managed service lifecycle ownership (openclaw#119647) fix(browser): honor explicit navigation timeouts across browser drivers (openclaw#119654) ...
What Problem This Solves
Managed gateway and node services repeated lifecycle-ownership checks, portable environment-key normalization, inline secret/proxy auditing, and native service identity in separate implementation paths. That duplication made launchd, systemd, and Windows Scheduled Task behavior harder to keep aligned while maintaining service-account, secret, and mutation safety.
Why This Change Was Made
This maintainer-requested refactor establishes one canonical node-service identity, managed service environment-key/source policy, guarded gateway mutation flow, and scope-aware systemd action dispatcher. It removes 104 production lines (98 additions and 202 deletions across nine daemon files) while preserving ambient and explicit supervision checks, future-config guards, portable case-insensitive key validation, exact platform identities, system/root ownership authorization, reset-failed ordering, mutation notifications, operator output, rollback behavior, PATH sanitization, symlink safety, and 0600 secret-file permissions.
User Impact
No intended user-visible, configuration, default, public API, or service-management behavior changes. Gateway and node install, repair, start, stop, restart, status, and environment auditing retain their existing behavior on macOS launchd, Linux user/system systemd scopes, and Windows Scheduled Tasks.
Evidence
Trusted Blacksmith Testbox
tbx_01kz93h6y9kazx4ycmy32f8c1h: https://github.com/openclaw/openclaw/actions/runs/31012882109. The single owned lease was stopped and verifiedcompleted.Focused existing coverage: 574 tests passed across 13 files, with 24 existing platform-specific skips. Command:
pnpm test src/daemon/constants.test.ts src/daemon/service.test.ts src/daemon/service-env.test.ts src/daemon/service-audit.test.ts src/daemon/systemd.test.ts src/daemon/systemd-system.test.ts src/daemon/launchd-system.test.ts src/daemon/launchd.test.ts src/daemon/schtasks.install.test.ts src/infra/host-env-security.test.ts src/infra/gateway-supervision.test.ts src/commands/daemon-install-helpers.test.ts src/commands/node-daemon-install-helpers.test.ts.Unmodified full
pnpm check:changedpassed, including production/full-tree/script dead-export scans, core and core-testtsgo, changed-file lint, formatting, plugin boundaries, import cycles, dependency/security guards, and native schema safeguards.207 baseline-versus-refactor source differential comparisons covered invalid/mixed-case keys, managed secrets, inline/file proxy sources, exact node identities on all three platforms, all six mutation guards and their failures, and system/user systemd ownership, reset, action, callback, output, and failure ordering.
Fresh independent
.agents/skills/autoreview/scripts/autoreview --mode local --engine codex --model gpt-5.6-sol --thinking xhigh: clean; zero actionable findings; confidence 0.97.Production LOC: -104; test LOC: 0. AI-assisted, maintainer-requested owner-boundary cleanup; no operator gateway or service action was executed.
Controlled committed-production Linux service lifecycle: Executed the actual
stageSystemdService,readSystemdServiceExecStart,startSystemdService,stopSystemdService, andrestartSystemdServiceproduction owners against real isolated temporary service/config artifacts and a real spawned, fail-closed syntheticsystemctlexecutable. The production system-scope ownership guard also executed against that synthetic manager. No native operator service manager, gateway, real credentials, tracked source, or PR head was touched; temporary artifacts were removed afterward.