Repository navigation
refactor(daemon): split launchd into concept modules - #121929
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 11, 2026, 4:03 AM ET / 08:03 UTC. ClawSweeper reviewWhat this changesThe PR splits macOS LaunchAgent installation, runtime inspection, lifecycle, stop, updater-job, and plist work into focused daemon modules while retaining the existing launchd import facade. Merge readinessKeep this maintainer-authored, maintainer-labeled refactor open for normal merge review. The exact-head facade preserves the existing launchd import surface and the split follows current lifecycle ownership; no concrete patch defect was found. Priority: P3 Review scores
Verification
How this fits togetherOpenClaw’s daemon service layer translates Gateway CLI lifecycle operations into LaunchAgent plist and launchctl work on macOS. Service callers consume the launchd facade, which then installs, inspects, starts, stops, and recovers the managed Gateway. flowchart LR
A[Gateway CLI] --> B[Daemon service registry]
B --> C[LaunchAgent facade]
C --> D[Service-file module]
C --> E[Runtime and lifecycle modules]
E --> F[launchctl]
D --> G[LaunchAgent plist and environment files]
F --> H[Managed Gateway]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +122, Other -1. Total +121 across 8 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the focused module split only after exact-head CI is green, retaining the facade and existing lifecycle test coverage as the compatibility boundary. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a structural refactor; preservation is assessed through the facade, existing daemon tests, and exact-head CI rather than a new bug reproduction. Is this the best way to solve the issue? Yes: splitting by plist ownership, runtime inspection, lifecycle, stopping, installation, and updater cleanup keeps the public facade while aligning code with the existing operational boundaries. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a8839a89239a. 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)
|
df355d0 to
5663df3
Compare
|
Land-ready proof:
ClawSweeper rank-up moves are addressed: exact-head CI is green and this is proceeding through normal maintainer review/landing. No behavior, config, protocol, storage, or public import contract changed. Proof gap: no separate local Testbox run ID. The local wrapper stopped before allocation because the checked Crabbox binary could not be safely rebuilt from its unrelated dirty checkout; exact-head hosted CI supplied the required build and macOS proof instead. |
|
Merged via squash.
|
* refactor(agents): split launchd into concept modules * fix(daemon): restore launchd service environment type * refactor(daemon): keep launchd probe result internal
What Problem This Solves
src/daemon/launchd.tshad grown to 2,013 lines and required a grandfathered max-lines suppression, making macOS managed-gateway lifecycle code difficult to navigate safely.Why This Change Was Made
This behavior-neutral refactor follows the file's independently evolved concept seams: service-file generation/publication, stale updater jobs, launchctl runtime inspection, transactional install/rollback, stop/maintenance parking, and start/restart recovery. The original module remains a pure public re-export facade so existing callers and test mocks retain the same import surface.
New module line counts:
launchd-service-files.ts: 439launchd-install.ts: 423launchd-lifecycle.ts: 404launchd-runtime.ts: 366launchd-update-jobs.ts: 264launchd-stop.ts: 209launchd.tsfacade: 30The max-lines suppression and
config/max-lines-baseline.txtentry are removed.User Impact
None. Generated plist bytes, environment-wrapper content, launchctl command strings, lifecycle ordering, and error text are unchanged.
Evidence
node scripts/run-vitest.mjs src/daemon— 54 files passed; 1,575 tests passed, 10 skipped before the stale-base rebase; post-rebase daemon proof passed 20 files and 737 tests with 5 skipped.node --import tsx scripts/check-export-name-collisions.mts— passed.node --import tsx scripts/check-wrapper-shadowing.mts— passed without baseline growth.node --import tsx scripts/check-import-cycles.ts— 0 runtime value cycles.node --import tsx scripts/check-max-lines-ratchet.mts --base origin/main— passed; baseline shrank by one.node --import tsx scripts/check-deadcode-exports.mts— passed with 0 unused exports.git diff --check— passed.--mode branch --base origin/main) — clean, no accepted/actionable findings.Raw numstat is +2,132/-2,011. Discounting pure moves and module import scaffolding, behavior-bearing production LOC is net -1 (the removed suppression); tests and production importers are unchanged.