Skip to content

refactor: split systemd into concept modules - #122002

Merged
steipete merged 1 commit into
mainfrom
steipete/split-systemd
Aug 11, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/split-systemd

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

src/daemon/systemd.ts was a 1,912-line grandfathered file whose size obscured the separate ownership boundaries for generated service files, systemctl execution, installed scopes, runtime inspection, installation, and lifecycle actions.

Why This Change Was Made

This splits the implementation along those existing concept seams while keeping systemd.ts as a pure 32-line compatibility facade for its 27 production and test import sites. The new modules are:

  • systemd-exec.ts — 348 lines
  • systemd-install.ts — 623 lines
  • systemd-lifecycle.ts — 242 lines
  • systemd-runtime.ts — 191 lines
  • systemd-scope.ts — 230 lines
  • systemd-service-files.ts — 350 lines

The generated unit contents, environment-file serialization, systemctl command arguments, ownership checks, dynamic inspection boundary, and public exports are unchanged. The obsolete systemd.ts max-lines suppression and baseline entry are removed.

User Impact

None. This is a behavior-neutral internal refactor of Linux managed-gateway service ownership.

Evidence

  • node scripts/run-vitest.mjs src/daemon — 54 files passed; 1,575 tests passed; 10 skipped.
  • Focused major-importer suites across daemon services, doctor flows, CLI lifecycle/logs, linger, health contributions, and wizard setup — 9 files and 395 tests passed.
  • pnpm build — passed, with no [INEFFECTIVE_DYNAMIC_IMPORT] diagnostic.
  • node --import tsx scripts/check-export-name-collisions.mts — passed without baseline growth.
  • 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 — passed after removing the systemd.ts entry.
  • git diff --check — passed.
  • .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main — clean; no accepted/actionable findings.

@clawsweeper

clawsweeper Bot commented Aug 11, 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 size: XL maintainer Maintainer-authored PR labels Aug 11, 2026
@steipete
steipete marked this pull request as ready for review August 11, 2026 10:57
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 11, 2026
@clawsweeper

clawsweeper Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 11, 2026, 7:02 AM ET / 11:02 UTC.

ClawSweeper review

What this changes

This PR splits Linux systemd gateway-service logic into focused daemon modules while preserving the existing systemd.ts import surface.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. Current main still has the monolithic systemd module, while this branch preserves its complete public facade and separates the existing service ownership boundaries without a concrete regression found.

Priority: P3
Reviewed head: 2232294c650c69fc002c169d3098ec4e63170fcc

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent owner-boundary refactor with preserved exports and relevant existing coverage.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored, behavior-neutral refactor is exempt from the external contributor proof gate; its PR body supplies focused test and build evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored, behavior-neutral refactor is exempt from the external contributor proof gate; its PR body supplies focused test and build evidence.
Evidence reviewed 5 items Current-main baseline: Current main still contains the 1,912-line consolidated systemd implementation, so the PR’s central refactor is not already implemented.
Public compatibility: The proposed facade re-exports every existing public systemd symbol, retaining current import paths for callers and tests.
Service owner and callers: The Linux service adapter consumes the stable facade, while CLI and Doctor flows consume lifecycle, inspection, and scope behavior through that same boundary.
Findings None None.
Security None None.

How this fits together

OpenClaw’s daemon service layer installs, controls, and inspects Linux systemd units that keep the Gateway running. CLI, Doctor, setup, and service-audit flows consume this layer for lifecycle actions and status.

flowchart LR
  CLI[CLI and Doctor flows] --> Facade[Systemd compatibility facade]
  Facade --> Install[Installation and service files]
  Facade --> Lifecycle[Start stop restart]
  Facade --> Runtime[Runtime inspection]
  Install --> Systemd[systemd manager]
  Lifecycle --> Systemd
  Runtime --> Systemd
  Systemd --> Gateway[Managed Gateway]
Loading

Before merge

  • Resolve merge risk (P1) - Exact-head CI is still in progress; landing should wait for its required checks to finish green.
  • Complete next step (P2) - No mechanical repair is identified; exact-head CI completion is the remaining merge gate.
Agent review details

Security

None.

PR surface

Source +104, Other -1. Total +103 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 7 2015 1911 +104
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 8 2015 1912 +103

Review metrics

Metric Value Why it matters
Production versus test LOC production net +103 after relocating 1,984 lines; tests net 0 The growth is attributable to explicit module boundaries and a compatibility facade rather than new runtime capability.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain systemd.ts as the canonical compatibility facade and land the concept modules once exact-head CI completes.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain systemd.ts as the canonical compatibility facade and land the concept modules once exact-head CI completes.

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

Not applicable: this PR refactors an existing implementation rather than reporting a behavior defect; the existing systemd suite covers the affected service boundary.

Is this the best way to solve the issue?

Yes. Keeping one stable facade avoids expanding caller imports while the extracted files align execution, install, lifecycle, runtime, scope, and unit-file responsibilities.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 63bba283a675.

Labels

Label changes:

  • add P3: This is behavior-neutral internal maintenance work without a reported user-facing regression.
  • 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: This maintainer-authored, behavior-neutral refactor is exempt from the external contributor proof gate; its PR body supplies focused test and build evidence.

Label justifications:

  • P3: This is behavior-neutral internal maintenance work without a reported user-facing regression.
  • 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: This maintainer-authored, behavior-neutral refactor is exempt from the external contributor proof gate; its PR body supplies focused test and build evidence.

Evidence

What I checked:

  • Current-main baseline: Current main still contains the 1,912-line consolidated systemd implementation, so the PR’s central refactor is not already implemented. (src/daemon/systemd.ts:1, 63bba283a675)
  • Public compatibility: The proposed facade re-exports every existing public systemd symbol, retaining current import paths for callers and tests. (src/daemon/systemd.ts:2, 2232294c650c)
  • Service owner and callers: The Linux service adapter consumes the stable facade, while CLI and Doctor flows consume lifecycle, inspection, and scope behavior through that same boundary. (src/daemon/service.ts:48, 63bba283a675)
  • Regression coverage: The existing systemd suite imports the public facade and covers service availability, installation, lifecycle, scope detection, runtime inspection, and environment-file behavior. (src/daemon/systemd.test.ts:89, 63bba283a675)
  • Feature history: Recent systemd lifecycle and dotenv work establishes the ownership seams being extracted; this is a follow-on refactor rather than a new service model. (src/daemon/systemd.ts:1, 36554c282008)

Likely related people:

  • steipete: Introduced the managed-service lifecycle consolidation and authored this focused follow-on refactor. (role: feature owner and recent area contributor; confidence: high; commits: 36554c282008, 2232294c650c; files: src/daemon/systemd.ts, src/daemon/service.ts)
  • Sally O'Malley: Authored the recent systemd dotenv restart repair in the installation behavior now extracted. (role: recent adjacent contributor; confidence: medium; commits: 4cbbfc215953; files: src/daemon/systemd.ts)
  • joshavant: Most recent current-main change touching the original systemd module revision. (role: recent area contributor; confidence: medium; commits: bb873c8806d6; files: src/daemon/systemd.ts)

Rank-up moves

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

  • Wait for the in-progress exact-head CI checks to finish green 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.

@steipete
steipete merged commit 8327504 into main Aug 11, 2026
186 checks passed
@steipete
steipete deleted the steipete/split-systemd branch August 11, 2026 11:09
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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