Skip to content

fix: repair stale Gateway service definitions during updates - #152120

Merged
steipete merged 16 commits into
mainfrom
upd/service-definition-update-repair
Sep 19, 2026
Merged

steipete merged 16 commits into
mainfrom
upd/service-definition-update-repair

Conversation

@steipete

@steipete steipete commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Related: #151691, #151325; series B of the stale-service-definition repair, after #151777

What Problem This Solves

Fixes upgrades leaving older managed Gateway service definitions stale, including the Discord report of missing systemd KillMode=mixed on 2026.9.4 and the Windows task with zero crash-restart retries in #151325.

User Impact

After package activation, update repairs recognized stale definitions through the existing platform installer, backs up the previous files first, and records the changed keys in the update outcome, status, and bounded report. Operator edits and unknown or foreign definitions stay intact, with warnings that name the affected keys. Inspection or repair hiccups remain warnings; recovery refuses replacement when it cannot verify the retained bytes or current owner.

When published 2026.9.4 owns rollback, it restores the old package and uses that release’s install/restart flow, regenerating its previous definition with that release’s preservation behavior. Candidate-owned rollback restores the captured definition files byte for byte and restarts the verified previous runtime.

Why This Change Was Made

The existing service audit remains the drift owner, now comparing the actual prepared install plan for settings the rewrite would discard. The existing systemd, launchd, and Scheduled Task installers remain the writers. Their publication hooks bind the audit to captured files, verify the installer’s output, and retain a private backup receipt for rollback; later operator changes prevent replacement. Warning projection uses the existing update ledger and report converter. Install path discovery recognizes the public shim and direct updater entrypoint of the same package, preserving PATH order without admitting a foreign installation.

B also retires updater-only Doctor writes and ensures updater restart retries preserve the definition, so neither can bypass the backup transaction. Standalone Doctor repair and the series documentation remain Part C. No new options, environment variables, dependencies, or database schema changes are included.

Net production growth is 1,221 lines (+2,047/−826), within B’s 1,225-line umbrella share: backup/receipt/reconciliation adds 676 lines, audit adds 355, native installers and shared installation identity add 241, update integration adds 121, and removing updater-only Doctor writers saves 172. Tests/support add 2,287 net lines (+3,054/−767). Round four is production +16/−19 (net −3) and tests +131/−0. Existing receipt compensation absorbs all transactional restoration; removing redundant installer recovery plumbing pays for the explicit delegation. No assertions, suppressions, or baselines were removed to fit the change.

The atomic-publication follow-up fixes a failed-write window in the Windows launcher and launchd environment/wrapper installers: truncating the live file before recording publication could leave recovery refusing an empty or partial launcher. Those installers now use the existing atomic-file primitive through the shared service publication hook. Systemd retains its existing atomic writer. Each replacement is prepared beside the target and renamed only after the backup receipt records the prepared file identity; publication is acknowledged after rename. After checkpoint I/O, the same backup owner revalidates live files and native inventory before publication without discarding prepared evidence. Recovery accepts unchanged original files or the exact prepared publication, while refusing later operator replacements, including identical bytes on another inode.

Windows uses Node’s native rename-over operation. If an open launcher prevents replacement (EPERM, EBUSY, or EEXIST), the old file stays intact and existing warning/compensation handling runs; there is no unlink/copy fallback or retry loop. The retained private receipt is a backup artifact replayable by the existing restore API, not a new whole-updater automatic-resume protocol.

Scheduled Task XML replacement now checkpoints its intended XML before /Create /F, both during installation and rollback. Recovery uses the existing task audit to recognize Scheduler’s SID/default normalization, records whether it found the previous or prepared policy, and rejects foreign policy before changing launchers. The systemd restore path also repeats its guarded daemon-reload when a prior attempt restored the unit but stopped before refreshing the manager; it reloads before removing old inputs.

Evidence

Codex round-four validation at f2a56ab4bf2e8239e7266a153cc0cf8534894e41:

  • 691 distinct focused tests passed across seven files, covering receipt recovery/ordering, systemd mutation/control, launchd and Scheduled Task installation, and the real CLI repair boundary. The five new regressions all fail against the pre-fix production files: three systemd cases lose the generated environment file while the candidate unit still references it; two actual launchd-installer cases restore artifacts before receipt compensation receives control. They pass with the fix, including failed unit restoration followed by safe receipt replay and cached launchd unload before input retirement.
  • pnpm check:changed: passed, exit 0. Formatting, both typechecks, all unused-export scans, core lint, schema/storage guards, and runtime/request boundaries passed. Only existing warning-only line-count and asynchronous database-fixture advisories remain; no suppressions or baseline edits were added.
  • Fresh committed-branch API-route Codex review (--mode branch --base origin/main --max-priority P1, private Darwin TMPDIR): scoped-clean, confidence 0.84. The local pre-commit review was also clean (0.93). One intervening finding was rejected against source evidence: it conflated the candidate package transaction, which restores package files/global CLI shims, with the separate published 2026.9.4 rollback orchestrator that calls the old service installer. The fresh review included both exact implementations and confirmed the distinction; receipt identity checks were not weakened.
  • Exact-head CI run 35430346960, attempt 1: completed/success, independently verified through REST on f2a56ab4bf2e8239e7266a153cc0cf8534894e41. All 156 jobs completed: 141 successful, 15 skipped, zero failures. The native watcher attached, then hit shared GraphQL quota; the authorized exact-run REST watcher exited 0. The long extension bundle also passed. Campaign red-main class #116 did not recur. No CI job was rerun.

The post-completion exact-head check snapshot contains 210 completed checks: 165 successful, 42 skipped, one neutral, two failed. Both failures are earlier security-review dependency gates, not test or security findings:

Failed check in the snapshot Classification
review job 105863699427 Ran at 07:49 UTC, before CI completed at 08:15 UTC. Log: “The current CI gate has not passed. CI completion will automatically reevaluate security review.” No security finding is reported.
review job 105863721795 Same earlier CI-dependency refusal at 07:50 UTC; no security finding is reported.

All seven Security High jobs and security-fast passed. The PR is open, non-draft, and mergeable; GitHub reported aggregate mergeable_state=unstable at that snapshot, alongside the earlier failed checks. This does not change the exact CI workflow’s terminal success above.

Exact-head ClawSweeper review also found no actionable findings (readiness/quality 4/6, proof 5/6). Its config/data compatibility reminders are addressed by the retained published-driver upgrade/rollback and operator-preservation evidence, plus the current regression proof; this round changes no config surface, receipt shape, or SQLite schema. Native Windows/launchd coverage remains helper-based.

The accepted P1 escaped the receipt owner's ordering through systemd's own catch handler, which could delete a newly generated environment file after restoration of the referencing unit failed. Its lower publication helper could also independently restore a file after acknowledgement failure. Both now propagate errors unchanged to receipt compensation when a transaction exists. Standalone systemd installation retains its own recovery contract and stops before input cleanup if restoring the unit throws.

Platform Single restoration owner for update transactions
systemd restoreGatewayServiceDefinitionBackup: restore existing inputs and unit, perform guarded daemon-reload, then retire new environment files. The installer catch and mutation helper no longer compensate independently.
launchd The same receipt owner: unload the cached candidate, restore inputs and plist, then retire new env/wrapper files. Both actual-installer catches now defer; their unreachable receipt-hook plumbing was removed. The lower plist publisher already deferred correctly.
Scheduled Task The same receipt owner: restore original launcher bytes, restore and verify task XML, then retire new VBS files. Audit found no inner-handler bypass: transaction installs already exclude /Change, direct fallback, and Startup migration; finalizers remove only temporary XML input. No Scheduled Task code change was needed.

The recorded four Linux live cells below remain attributed to 9f3902454, run 35422060057. This round's additional installer-failure paths have current-head filesystem/native-helper proof; no new Linux live run or native Windows/launchd execution is claimed. No config/env/CLI option, schema, dependency, receipt shape, or second writer was introduced. No landing or Part C work was performed.

Round-three validation and previously recorded native proof

Codex round-three validation at 341f1c436dda936226970b428fed99441896fc33:

  • 935 focused tests passed across 14 files, including the full backup/retirement, native installer, update integration, receiver, and rollback suites. The two launchd directory cases also passed under an actual shell umask 077; the publisher regressions run isolated child processes under 000 and 077.
  • Demonstrated pre-fix failures: six task retirement/interruption cases, a compensation warning case, two rollback warning projections, and the XML mode case (0666 instead of 0600 under umask 000). They pass after the fixes. Existing operator-edit refusals and non-service rollback diagnostics remain intact; warnings retain the ledger’s existing home-path redaction.
  • pnpm check:changed: passed, exit 0, including both typechecks, lint, export scans, storage and boundary guards. Only existing warning-only line-count and asynchronous database-fixture advisories remain; no suppressions or baseline edits were added.
  • Fresh committed-branch Codex review through the API route, --mode branch --base origin/main --max-priority P1 with private Darwin TMPDIR: scoped-clean, no actionable P0/P1 findings, confidence 0.90.
  • Exact-head CI run 35427821145, attempt 1: completed/failure, REST-verified on 341f1c436dda936226970b428fed99441896fc33. All 156 jobs completed: 139 successful, 15 skipped, two failed. The extension bundle completed successfully. The native watcher hit shared GraphQL quota; the exact-run REST watcher and final REST inventory supplied the terminal result. No job was rerun.

The final exact-head inventory contains 210 completed checks: 163 successful, 42 skipped, one neutral, four failed. Every failed check is classified below; no numbered campaign flake class is assigned without evidence.

Failed check Classification and evidence
checks-node-compact-small-10 Unrelated upstream integration failure: the two plugin-state tests “shares lifecycle custody with an overlapping host owner during observe/compareDelete” hit StateDatabaseCoordinatorContentionError after 5,311/5,283 ms. CI tested merge 4b8a7167f6381fe2eed5c0c098df996c2e914f54, combining this head with main c75457234770789f759079728c1c7406bba72c8f. #152361 added the fixtures; #152377 moved fresh lifecycle acquisition into the worker. The fixtures hold a host coordinator inside intercepted Worker.postMessage until the worker operation finishes, so the worker now waits on the fixture-held lock while the fixture awaits worker completion. The responsible owners are SQLite worker lifecycle admission and its plugin-state custody fixture; B changes neither those owners nor their shared test infrastructure.
openclaw/ci-gate Aggregate failure caused by the core-test shard above; all other selected groups passed.
review job 105857103180 Security-review dependency gate: “The current CI gate has not passed. CI completion will automatically reevaluate security review.” No security finding is reported in its log.
review job 105857229968 Same security-review dependency gate on this head; no security finding is reported in its log.

Exact-head ClawSweeper revision 17 found no actionable correctness or security findings (readiness/quality 4/6; proof 5/6). Its native-platform coverage reminder retains the lead’s explicit acceptance of helper-based Windows/launchd coverage plus refreshed Linux proof. Its compatibility reminder is covered by the published 2026.9.4 upgrade/rollback observations and operator-edit preservation below; this round adds no config/default surface. These reminders do not turn the failed CI run green. The PR remains open, non-draft and mergeable, with mergeable_state=unstable; no landing or Part C work was performed.

The accepted Windows finding was a dangling-reference window: generic file restoration removed a candidate-only VBS launcher before native task XML stopped referencing it. The compensation owner now restores the old input bytes, restores and verifies task XML at the primary-reference phase, and only then retires newly introduced files. A failed, interrupted, or unverified XML replacement preserves the new launcher and warns with its path and the backed-up XML to restore before cleanup. Candidate rollback records the same diagnostic as a warning in the existing update result/history surfaces.

Platform Restoration order before deleting new inputs
Scheduled Task Restore original CMD/preexisting launcher bytes → restore native task XML through /Create /F → verify/checkpoint through the existing task audit → delete the new VBS launcher. Unchanged primary bytes still require native-reference verification.
launchd Unload the cached candidate job → restore existing env/wrapper inputs → restore plist → delete newly introduced env/wrapper files. The lifecycle owner subsequently loads the restored plist.
systemd Restore existing inputs → restore unit → guarded daemon-reload, including interrupted-reload replay → delete newly introduced environment files.

The launchd and systemd ordering contracts were already correct and remain unchanged. No new writer, public option, environment variable, dependency, or SQLite schema was added; receipt shape is unchanged in this round.

Mode audit: the shared publisher already delegates to the installed fs-safe primitive’s temporary-descriptor chmod before rename; systemd independently applies its explicit mode through its temporary descriptor. Launchd plist uses 0644; its shell wrapper uses 0700; env files, Windows CMD/VBS launchers, and backup receipts use 0600. The systemd installer restricts the unit to owner-only bits (normally 0600), while receipt restoration preserves the captured mode. This corrects the earlier summary’s 0644 claim for systemd installation; no mode code changed in round four. Temporary task XML was the missing class and now uses that same atomic publisher with explicit 0600. Windows POSIX-mode tests do not claim native ACL coverage.

The live prelude’s 0700 versus 0755 failure was the newly created LaunchAgents directory, not a published file. Its fixture now separately proves tightening writable existing directories and preserving private ones, while accounting for umask when creating a new directory. Production directory permissions are not widened. The new mode regression observes temporary-file modes before rename as well as final modes (0600, 0644, 0700, 0755) under umask 077.

The lead accepts the four Linux live cells on 9f3902454 for this round’s Windows reference-ordering and mode work. The saved addendum follows; its earlier helper-fixture failure is now addressed by the strict-umask test above. Windows/launchd native lifecycle evidence remains helper-based. No landing or Part C work is included.

Final-head Linux live addendum — 2026-09-19

Codex reran each of the four requested Linux cells once on unchanged head 9f3902454088a39d2f64e4c371a9f80f3f4a1f97. This refreshes the four Linux flows described in the earlier baseline; Windows/launchd native service-manager coverage remains helper-based. No product source or test source changed (production/test LOC delta: 0/0), no commit or push was made, and Part C was not started.

Provider: Blacksmith Testbox, run 35422060057, lease tbx_01m2vzkxyjbzmgypksj2837sda, pinned to the PR branch. The existing repository wrapper transferred one source-capsule file with targeted sync in 74.611 seconds and verified source tree 0005b65637cb74b856d8f7dcfe801437d6da73e9 before building. The candidate tarball passed package checks; SHA-256: 4004cc5a94001d8c4ab0cb26d3be44325d8c09ba72518c0bd9d5cbe21f4d8f99.

The original rig's helper prelude stopped before any live cell: 685 tests passed, one failed, 26 skipped, with the remaining installer-helper group not run. The failure was launchd install tightens writable bits on launch agent dirs and plist at src/daemon/launchd.test.ts:2558: the real filesystem helper inherited the rig's umask 077, so the newly created LaunchAgents directory was 0700, while the assertion expected 0755 (expected 448 to be 493). The directory owner deliberately removes writable bits without broadening stricter permissions. This fixture assumption is retained as a failure, not converted to a passing test or retried.

A single live-only continuation reused the same lease and unchanged verified tarball, asserted that none of the live cells had started, and ran the unchanged cell scripts. Its required one-file targeted sync took 28.591 seconds. No provisioning or sync failure was retried, no helper test was rerun, and no live cell was replayed. The live matrix completed exit 0 in 10m24.419s.

Live cell Observed outcome
Published 2026.9.4 → candidate PASS. Healthy candidate; systemd KillMode=mixed, NeedDaemonReload=no. Backup matches the stale original. Changed-key warnings survive outcome, update status, CLI text, and the 1,153-character bounded report.
Operator Nice=7 edit PASS. Entire unit and definition-file manifest remain byte-identical; effective policy remains control-group. Exact Service.Nice warning survives the reporting surfaces and 952-character bounded report; candidate is healthy.
Published-driver forced rollback PASS. After 10 scoped candidate crashes, the old package and runtime return healthy. The full definition matches the independent old-installer-and-restart control; backup matches the stale original. Effective KillMode=mixed, no pending reload; warning retained in the 1,109-character report.
Candidate-owned forced rollback PASS. After 8 scoped candidate crashes, the same-code older-version fixture 2026.9.4-l685b.0 returns healthy. The previous unit and live definition files restore byte-for-byte from backup. Effective KillMode=control-group, no pending reload; warning retained in the 1,500-character report.

The fault injector waited for the exact run's durable reconciliation warning and verified backup, targeted only its synthetic service account's candidate process, and stopped on package restoration. Each cell used an isolated state directory and a free port. All four database inventories remained unchanged at core schema 17. The target tarball hash was rechecked after the matrix; downloaded terminal outcome JSON independently matches all four run IDs and expected terminal states.

Redacted per-cell proof output:

L685B_CELL_PASS mode=update runId=09b8270a-b661-4dbb-a58c-4c3e724aff93
L685B_CELL_PASS mode=unknown runId=9b5a4ac6-4f34-4c52-971d-8667152ab195
L685B_PUBLISHED_FULL_SERVICE_DEFINITION_MATCH
L685B_CELL_PASS mode=published-rollback runId=3414efb9-6260-4d3c-b88c-072e0090d6a0
L685B_CANDIDATE_EXACT_DEFINITION_MATCH
L685B_CELL_PASS mode=candidate-rollback runId=82d7d882-5812-4221-8881-c7c3ef73385e

All four fixture services were stopped and linger disabled. The only lease created for this rerun was stopped, and the provider independently reports completed. The local and remote PR heads were verified unchanged. No landing was performed.

Historical PR B evidence through 9f39024

Codex validation for native publication recovery at 9f3902454088a39d2f64e4c371a9f80f3f4a1f97:

  • Current integrated head: 228 tests passed across six files (199 daemon, 29 CLI), covering receipt replay, Windows lifecycle, installer compensation, child-process execution, and receipt/warning delivery. Earlier attributed runs in this follow-up passed 824 tests across 13 files after the first main integration, 77 backup/installer/receiver tests after strict compensation, 59 backup tests after the receipt helper extraction, and 405 focused tests at e59d648430e after systemd cleanup (386 daemon, 19 CLI). These runs overlap and are not an additive test count.
  • Pre-fix boundary proof: five failures, one passing foreign-policy refusal. Three successful-but-unacknowledged /Create cases refused recovery (after-create, normalized export, and rollback create); interrupted systemd reload broke replay; unchanged native policy restored but had no recorded decision. All six cases pass after the owner fixes, and existing operator-edit refusal cases remain intact.
  • Fresh committed-branch Codex review through the API route (--mode branch --base origin/main --max-priority P1, private Darwin TMPDIR): scoped-clean, no actionable P0/P1 findings, confidence 0.89. The earlier Windows PATH finding was rejected against the actual renderer, which deliberately omits PATH; all nine existing Scheduled Task preservation cases pass, including the hand-edited PATH case.
  • Integrated-tree pnpm check:changed --staged --base 0cbbec0272859b4700ce48179fb2c4a96625d576: passed for the exact tree later committed as the current head. Both typechecks, lint, all dead-export scans, storage and boundary guards passed. The earlier unqualified pnpm check:changed at e59d648430e also passed. Warning-only line-count advisories in untouched src/cron/service/timer.test.ts and src/infra/sqlite-worker-broker.ts remain; no suppression or baseline edit was added. The existing temp-fixture advisory remains because rollback fixtures await database closure.
  • Exact-head CI run 35419738114, attempt 1: completed/success, independently verified through REST on 9f3902454088a39d2f64e4c371a9f80f3f4a1f97. All 157 jobs completed: 142 successful, 15 skipped, zero failures. The required native watcher attached to that run, then encountered the shared GraphQL quota; the exact-run REST watcher completed successfully under the lane’s quota fallback. No job was rerun.
  • Final REST check inventory: 219 completed check runs — 170 successful, 47 skipped, one neutral, one canceled; zero failed. The canceled ClawSweeper Dispatch job was superseded by a higher-priority queued request for this PR, as its cancellation annotation confirms. This is automation concurrency, not a test or lint failure; it was not rerun. GitHub reports the PR as mergeable and non-draft, with aggregate mergeable_state=unstable at that read. The product CI run above is terminal green, and the subsequent exact-head ClawSweeper review is complete.
  • Main advanced while e59d648430e was being validated; the native watcher stopped immediately with CONFLICTING, so no completed CI is claimed for that intermediate head. The current head integrates main 0cbbec0272859b4700ce48179fb2c4a96625d576: the import-only conflict retains both B’s recovery receipt and main’s Gateway-marker stripping. All 228 affected tests across six files pass after integration (199 daemon, 29 CLI), including the managed child-environment cases. The final B LOC totals are unchanged.
  • The preceding a28aa71b565 head completed CI run 35415970508 successfully; the native watcher returned GREEN and REST independently confirmed completed/success on that SHA. ClawSweeper then found the late systemd deletion issue below, so that green run is not presented as final-head validation.
  • Earlier head 1657f786ecb hit an unrelated memory-core lock-contention assertion in CI run 35409720880: a workspace-lock timeout appeared where the unchanged test expected SQLITE_BUSY/LOCKED. The native watcher then stopped with CONFLICTING-MID-WAIT after fix(mac): preserve LaunchAgent bytes and permissions on rollback #152195 landed. No failed job was rerun; the final head integrates that main change.
  • Integration retains main’s binary bytes and captured permission modes through the shared atomic publisher, adapts both snapshot readers, and removes the redundant filesystem mock. Two integration regressions were red before adaptation: a canonical wrapper was falsely classified as an edit, and rollback lost special permission bits; both now pass.
  • Compensation now requires recorded writer identity even when an operator replacement contains the original bytes. Its new regression failed before removing the byte/mode-only shortcut, then passed. Actual ENOSPC installer output and a real child-response test also confirm that verified compensation clears definitionRecovery.unverified; failed compensation remains blocked. All assertions and cases are retained, with a shared receipt-reading test helper keeping the file below its line cap.

ClawSweeper revision 13’s late P1 is fixed: an originally absent generated systemd environment file is now removed through the existing receipt-aware remove() operation during internal compensation. The real installer regression first creates that file, then injects ENOSPC into the following unit write. It failed before the fix with UPDATE_NATIVE_AUTHORITY; it now restores the original unit, records the generated file’s absence, and emits the normal preserved-definition warning. The inline-only sibling and operator-edit refusals remain intact. This fix adds three net production lines and 18 test lines. Compared with the previous atomic-publication report, the PR totals grow by six net production lines and 120 test/support lines after excluding integrated upstream changes.

Live task policy at recovery Recorded decision and action
Matches the last admitted native policy Record previous, clear pending intent, and resume restoration. Skip another /Create when the task already matches its backup.
Matches the intended XML through the existing audit Record prepared, pin the observed native policy hash, then restore the backed-up XML and launcher bytes.
Matches neither Refuse as a foreign/operator edit before changing any live file or task; retain the prepared receipt and the diagnostic.

Native steps checked: both installer /Create /F paths and rollback /Create /F now prepare receipts. Task /Run and /End change runtime state; /ENABLE and /DISABLE remain lifecycle-owned and excluded from the policy comparison, while transactional /Change /TR is disabled. Launchd bootout/unload, enable, and bootstrap have no stale native-policy checksum gate: recovery probes loaded/absent state and unloads a cached job before restoring files. Systemd daemon-reload now repeats safely during restoration, including replay after primary-file publication; enable, start, and restart have no receipt-policy acknowledgement window. Existing platform helpers and the new cached-manager regression cover these boundaries.

The existing private receipt artifact gains optional preparedXml and recoveredPolicy facts; there is no SQLite schema, option, environment variable, or dependency change. Older receipts without these facts remain valid. The intended XML is retained because native exports can normalize account names, default fields, and metadata; the existing audit remains the comparison owner. Completed publication clears pending XML, and interrupted recovery retains its observed decision. Published 2026.9.4 rollback continues through its old installer, as described above.

Exact-head ClawSweeper revision 15 confirms the prior systemd compensation P1 is fixed and identifies no new actionable code finding: 4/6 overall and patch quality, 5/6 proof confidence. Its native-evidence landing decision remains explicit below. Compatibility is recorded above: no new config/CLI options or SQLite schema change, optional backward-compatible facts in the existing private receipt, and published-driver rollback retains the old installer contract. The attributed native baseline and current receipt regressions are retained; no new native-platform claim is made.

Native Linux lifecycle evidence remains the attributed fd25b2320 baseline below; this follow-up adds local native-boundary helper regressions and CI, not a new Testbox run. Windows/launchd service-manager behavior remains helper-based. No landing or Part C work is included.

Historical file-publication follow-up at b566357

Codex validation for the atomic-publication follow-up at b566357a4153f82a593c10850037b4ca3c33896b:

  • 780 tests passed across 12 focused daemon/installer, receiver, and rollback files: 51 backup, 9 installer boundary, 622 sibling daemon, 43 rollback, 8 receiver, and 47 program-argument/native-authority tests. The last two files were rerun after their fixture corrections; production code is unchanged from the 733-test run.
  • With the exact old production files restored temporarily, five regressions failed on live-byte loss: four partial-write ENOSPC cases across Windows and launchd, plus a real process kill during launcher writing. The fixed branch passes those cases, a kill before rename, and serialized receipt replay after rename but before acknowledgement across Windows, launchd, and systemd.
  • The actual installer boundary records ENOSPC recovery as a warning in JSON and the update ledger, preserves the previous unit and backup, and does not restart. Windows sharing-error regressions preserve all live bytes without unnecessary task creation or activation. A separate red/green regression rejects an identical operator replacement before publication acknowledgement.
  • A subsequent committed-branch review exposed operator edits during checkpoint I/O. All five new regressions failed before the fix, then passed across Windows script/VBS and launchd plist/environment/wrapper publication. Installation and compensation both preserve the injected edit.
  • pnpm check:changed: passed. Fresh committed-branch Codex review through the API route, with --mode branch --base origin/main --max-priority P1 and private Darwin TMPDIR: scoped-clean, no actionable P0/P1 findings, confidence 0.86. The warning-only temp-fixture advisory remains because the rollback fixtures await database closure before removing their isolated homes.
  • Exact-head CI run 35407010335, attempt 1, is terminal: failure, independently verified through REST: 158 completed jobs — 141 successful, 15 skipped, 2 failed. check-lint-core-2 is an infrastructure interruption: the runner received a shutdown signal and exited 143 during lint stripe 4, with no lint diagnostic. openclaw/ci-gate is the dependent aggregate failure. Every executed test job passed, including the corrected fixture job. Both required exact-head watching and terminal CI-run watching completed; no failed job was rerun.
  • Earlier follow-up CI run 35405578505 exposed two diff-caused fixture failures in checks-node-compact-small-20: an unimplemented directory stat in the program-argument test and authority revocation tied to the previous temporary-file suffix. The current tests use real directory stats and revoke after the actual asynchronous write, preserving their original assertions. Their 47-test run passes. That run finished with 158 completed jobs: only this test job and the aggregate openclaw/ci-gate failed. No failed job was rerun.

Data-model compatibility: the follow-up adds no SQLite schema or migration. Its optional prepared fact belongs to the private backup receipt and is removed when publication is acknowledged; completed installer receipts retain their prior shape. Existing completed-receipt restoration tests and the new serialized interrupted-receipt replay tests pass. The published-driver upgrade and both rollback-owner cells below remain the Linux compatibility evidence, with core schema 17 unchanged; the supported old-runtime agent-database creation is disclosed in that baseline record.

Exact-head ClawSweeper revision 9 reports no actionable code findings, 4/6 overall and patch quality, and 5/6 proof confidence. Its compatibility reminder is addressed by the receipt and published-driver evidence above. Its native-proof merge-risk reminder is retained explicitly: this follow-up order requested installer/failure regressions, changed checks, API review, and CI; a new native Testbox run was not performed. The lead must decide that remaining merge risk before landing. No landing is attempted here.

The native Linux Testbox evidence below is from the prior fd25b2320 baseline, not the new atomic-publication head. This follow-up was validated locally with injected filesystem failures and process crashes; Windows/launchd service-manager behavior remains helper-based.

Historical PR B proof at fd25b23

Codex validation for fd25b2320c7d2a592d60dda2c46463e1f1058c4e:

  • Baseline-head pnpm check:changed: passed. Fresh committed-branch review with --mode branch --base origin/main --max-priority P1 and private Darwin TMPDIR: scoped-clean. The warning-only temp-fixture advisory is retained because rollback fixtures await canonical asynchronous database closure before removing their homes.
  • 137 Windows, backup, and fallback tests passed after fixing the ClawSweeper finding: ordinary installs warn and activate when XML policy refresh fails, while transactional repair still fails and compensates. The ordinary-install regression failed before the fix.
  • 83 focused tests passed across five files after the final recovery-error fix. Its subprocess regression failed before the fix: a nested SERVICE_DEFINITION_UNKNOWN hid the outer failed-compensation error. The receiver now retains UPDATE_NATIVE_AUTHORITY and leaves rollback unverified.
  • 512 tests passed across the full update CLI and reader-settlement suites before the final receiver and Windows compatibility fixes. CI had exposed stale installer-capability and restart fixtures; their corrections retain coverage and explicitly prohibit reinstalling during rollback. The suffix-assertion cleanup then passed its three affected cases and reduced the oversized test file without suppressions or baseline edits.
  • Earlier focused installer/planning proof: 134 passed across four files, including a demonstrably red/green public-shim → updater-entrypoint PATH regression. Other boundary coverage exercises stale policy, unknown/foreign definitions, backup restoration, warning persistence, concurrent edits, and native-cache restoration.

Baseline-head Linux systemd proof passed in one native command (24m20s, exit 0) on Testbox run 35396907470, lease tbx_01m2v6pn69qn4sgf13t198mjsq. The wrapper verified tree 72d32b36a007fb5dbfdbeed9877c896a76de0d5e and all 77 changed-file hashes before the canonical build and package checks. Tarball SHA-256: 8e5516b4a00646fa8da58e7452e4460b6324b2a47eda865824c1ed1970f3b7ab. Remote focused validation passed 660 tests across 16 files, with 26 existing launchd skips; this includes both final regression fixes.

Live case Observed result
Published 2026.9.4 → candidate Succeeded; all 10,054 installed dist files match the candidate. KillMode=mixed, no pending daemon reload, healthy runtime. Backup byte-matches the stale definition. Unit.StartLimitBurst, Unit.StartLimitIntervalSec, and Service.KillMode warnings survive outcome, status, CLI text, and the 1,050-character bounded report.
Operator Nice=7 edit Succeeded; entire unit and definition-file manifest remain byte-identical. Exact Service.Nice warning survives every reporting surface; bounded report is 976 characters.
Published-driver forced rollback Previous package/build/runtime restored healthy after 10 scoped candidate crashes. The complete unit matches the independent old install-and-plain-restart control captured before the update; backup matches the stale original.
Candidate-owned forced rollback Previous fixture 2026.9.4-l685b.0 restored healthy after 8 scoped crashes. Unit and live definition files restore byte for byte from backup; systemd uses the restored control-group policy with no reload pending. Warnings persist in the 1,475-character bounded report.

Fault injection waits for the durable reconciliation warning and verified backup, targets only the fixture-owned candidate, and stops when the previous package returns. The candidate-owned cell uses the same code in an older-version fixture; the target tarball remains unchanged. Core schema stayed at 17 in all four cells. After published rollback, the restored runtime naturally created an agent database at schema 19, matching the published release’s OPENCLAW_AGENT_SCHEMA_VERSION; the other three database inventories were unchanged. An extra post-download inventory-equality assertion flagged that supported creation; the original snapshots and its failure are retained. No schema markers were edited, and no update was replayed. These completed observations satisfied the remaining Linux proof reminder in ClawSweeper’s review of that baseline head, which found no additional blocking code defect.

All fixture-owned services were stopped, linger was disabled, and every command/download was joined. The Testbox lease was stopped and independently verified completed; the native proof command’s exit 0 above is separate from lease-workflow cleanup.

Sanitized native proof output:

L685B_CELL_PASS mode=update runId=b8f7aee7-8d77-407e-bc7d-208558cc0978
L685B_CELL_PASS mode=unknown runId=70baf6a2-2e7c-4fc5-9023-3a3b97e54afd
L685B_PUBLISHED_FULL_SERVICE_DEFINITION_MATCH
L685B_CELL_PASS mode=published-rollback runId=7b8725a3-58e6-4f31-ab4b-e3a30a9343b4
L685B_CANDIDATE_EXACT_DEFINITION_MATCH
L685B_CELL_PASS mode=candidate-rollback runId=b5129255-3888-42ff-b000-c019c68b8727

Baseline-head CI run 35396446317 completed successfully: 158 jobs completed, zero failures. The required native watcher also returned STATUS rollup=green github_rollup=SUCCESS pending=0 and GREEN. No failed job was rerun. Earlier CI exposed stale B fixtures and unrelated upstream duplicate declarations; B’s fixture failures were corrected, and the final run is green.

Windows and launchd lifecycle evidence is helper-based; no native Windows or launchd service lifecycle claim is made.

@clawsweeper

clawsweeper Bot commented Sep 18, 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.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime cli CLI command changes commands Command implementations size: XL maintainer Maintainer-authored PR labels Sep 18, 2026
@clawsweeper

clawsweeper Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 19, 2026, 4:26 AM ET / 08:26 UTC (Revision 20).

ClawSweeper review

What this changes

Updates repair recognized stale Gateway service definitions through existing installers, preserve operator edits, and retain verified backups for recovery.

Merge readiness

⛔ Blocked before merge - 1 item remains

This remains useful, unsuperseded work. No blocking defect was found, and the recorded upgrade, preservation, and rollback evidence addresses the previous compatibility reminder.

Priority: P1
Reviewed head: f2a56ab4bf2e8239e7266a153cc0cf8534894e41

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent repair with strong attributed upgrade/rollback evidence and no remaining actionable finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Recorded Linux Testbox output exercises the real updater, candidate installer, systemd, and both rollback owners at 9f39024, showing healthy recovery and preserved operator edits. Current-head fault regressions cover subsequent compensation changes; the recorded acceptance retains helper-based Windows/launchd coverage without claiming native execution there.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): Recorded Linux Testbox output exercises the real updater, candidate installer, systemd, and both rollback owners at 9f39024, showing healthy recovery and preserved operator edits. Current-head fault regressions cover subsequent compensation changes; the recorded acceptance retains helper-based Windows/launchd coverage without claiming native execution there.
Evidence reviewed 8 items Pinned implementation and ordinary-install boundary: The installer invokes reconciliation for update-owned commands or the existing published-updater marker; ordinary installations retain their direct installer path. Review used the pinned merge-base-to-head delta, not current-main endpoint drift.
Preservation and recovery owner: Reconciliation checks current installation ownership and the prepared plan before publication. Receipt recovery validates backup contents and current artifacts, restores native references before removing generated inputs, and refuses later operator replacements.
Previous compensation finding addressed: Transactional systemd and launchd failures now defer restoration to the receipt owner. The ordering regressions exercise failed unit restoration, retained environment inputs, and cached LaunchAgent unloading; the earlier generated-file deletion concern is not still present.
Findings None None.
Security None None.

How this fits together

Gateway service definitions tell systemd, launchd, or Windows Task Scheduler how to run OpenClaw. Update finalization compares the installed definition with the candidate installer’s plan, then repairs or preserves it and records the outcome.

flowchart TD
  A[Package update] --> B[Inspect installed service]
  B --> C{Recognized managed definition?}
  C -->|No| D[Preserve definition and warn]
  C -->|Yes| E[Capture verified backup]
  E --> F[Existing platform installer]
  F --> G{Installation succeeds?}
  G -->|Yes| H[Verify Gateway and record outcome]
  G -->|No| E
Loading

Before merge

  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
Agent review details

Security

None.

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +1,221 lines; tests/support net +2,287 lines Measured against the pinned base; the body justifies production growth through cross-platform preservation, backup verification, and recovery while retiring competing Doctor writes.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor-service-repair-policy.ts, migration/backfill/repair: src/commands/doctor-update.ts, serialized state: src/daemon/launchd-install.ts, serialized state: src/daemon/launchd-service-files.ts, serialized state: src/daemon/schtasks-install.ts, serialized state: src/daemon/schtasks-layout.ts, and 5 more. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Technical review

Best possible solution:

Keep one audit and backup owner coordinating the existing platform installers, with verified restoration before generated-input cleanup.

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

No independent current-main reproduction was run in this read-only review; the supplied native evidence demonstrates the published 2026.9.4 stale-unit upgrade scenario and its repaired outcome.

Is this the best way to solve the issue?

Yes. The patch extends the existing audit and installers, preserves ordinary-install behavior, and consolidates transactional compensation instead of adding another service writer.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: Stale service policy can leave an upgraded Gateway without effective crash recovery, affecting existing installations.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): Recorded Linux Testbox output exercises the real updater, candidate installer, systemd, and both rollback owners at 9f39024, showing healthy recovery and preserved operator edits. Current-head fault regressions cover subsequent compensation changes; the recorded acceptance retains helper-based Windows/launchd coverage without claiming native execution there.
  • proof: sufficient: Contributor real behavior proof is sufficient. Recorded Linux Testbox output exercises the real updater, candidate installer, systemd, and both rollback owners at 9f39024, showing healthy recovery and preserved operator edits. Current-head fault regressions cover subsequent compensation changes; the recorded acceptance retains helper-based Windows/launchd coverage without claiming native execution there.

Evidence

What I checked:

  • Pinned implementation and ordinary-install boundary: The installer invokes reconciliation for update-owned commands or the existing published-updater marker; ordinary installations retain their direct installer path. Review used the pinned merge-base-to-head delta, not current-main endpoint drift. (src/cli/daemon-cli/install.ts:512, f2a56ab4bf2e)
  • Preservation and recovery owner: Reconciliation checks current installation ownership and the prepared plan before publication. Receipt recovery validates backup contents and current artifacts, restores native references before removing generated inputs, and refuses later operator replacements. (src/daemon/service-definition-backup.ts:375, f2a56ab4bf2e)
  • Previous compensation finding addressed: Transactional systemd and launchd failures now defer restoration to the receipt owner. The ordering regressions exercise failed unit restoration, retained environment inputs, and cached LaunchAgent unloading; the earlier generated-file deletion concern is not still present. (src/daemon/systemd-install.ts:380, f2a56ab4bf2e)
  • Complete captured proof inspected: The retrieved 41,496-unit body matched captured SHA-256 a65aba2b70b8d4064d87c451218c37f86d0efbf6abe1e8645408a425c91d4fde. It records four Linux Testbox cells at 9f39024: published 2026.9.4 upgrade, byte-preserved Nice=7 edits, published-driver rollback, and exact-definition candidate rollback. https://github.com/openclaw/openclaw/actions/runs/35422060057. Later recovery changes have current-head fault regressions; Windows/launchd lifecycle coverage is explicitly helper-based and its acceptance is recorded. (9f3902454088)
  • Authority and forbidden-effect checks: Original-root information remains inside live delegated authority. Receiver tests cover foreign roots and substituted lineage, while publication and recovery tests reject revoked authority and preserve files before forbidden effects. No new dependency, workflow permission, or credential-access change was found. (src/daemon/service-update-authority.ts:39, f2a56ab4bf2e)
  • Still necessary on main: Fetched main still calls the installer directly and regenerates definitions during candidate-owned rollback. The merged prerequisite fix: report stale Gateway service policy in Doctor and update status #151777 explicitly supplies reporting only. Neither fetched main nor the supplied latest release tree contains the new reconciliation and definition-backup owners. (src/cli/daemon-cli/install.ts:478, ec7c47a6d508)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • Jason (Json): Raw commit c06f21d adds src/daemon/service-update-authority.ts:16 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c06f21ddfad2; files: src/daemon/service-update-authority.ts)

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 (19 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-19T00:50:14.843Z sha 1657f78 :: blocked before merge. :: none
  • reviewed 2026-09-19T02:41:34.690Z sha a28aa71 :: blocked before merge. :: [P1] [P1] Record generated-file deletion during systemd compensation
  • reviewed 2026-09-19T03:43:07.414Z sha e59d648 :: blocked before merge. :: none
  • reviewed 2026-09-19T04:00:37.359Z sha 9f39024 :: blocked before merge. :: none
  • reviewed 2026-09-19T04:35:30.314Z sha 9f39024 :: blocked before merge. :: none
  • reviewed 2026-09-19T07:01:44.841Z sha 341f1c4 :: blocked before merge. :: none
  • reviewed 2026-09-19T07:28:09.019Z sha 341f1c4 :: blocked before merge. :: none
  • reviewed 2026-09-19T07:58:00.475Z sha f2a56ab :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 Sep 18, 2026
@clawsweeper clawsweeper Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 18, 2026
@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. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Sep 18, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Sep 19, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 20, 2026
…w#152120)

Updates could leave managed Gateway service definitions on stale policies, including missing systemd KillMode=mixed and Windows tasks with no crash-restart retries. Series B follows PR A openclaw#151691 and the reporting prerequisite openclaw#151777.

Extend the existing service audit and platform installers to repair recognized drift after package activation, preserve operator edits and foreign definitions, and back up definitions before publication. One verified receipt owner restores native references before retiring generated inputs. Inspection and repair hiccups become recorded warnings; recovery refuses replacement when retained bytes or live ownership cannot be verified. Updater-only Doctor writes are retired so they cannot bypass the backup transaction.

Published 2026.9.4 rollback retains its old installer behavior; candidate-owned rollback restores captured definition bytes and the verified previous runtime. There are no new public options, dependencies, or SQLite schema changes. Standalone Doctor repair and series documentation remain Part C.

Thanks to the Discord reporter of the stale 2026.9.4 systemd policy and @Andapeng for the Windows crash-recovery report in openclaw#151325.

Validation: 691 focused tests and check:changed passed. Exact-head CI run 35430346960 completed with 141 successful jobs, 15 skipped, and zero failures. The two earlier security-review dependency refusals reported no security finding. The review of record is scoped-clean; ClawSweeper found no actionable correctness or security findings. Its compatibility reminder is satisfied by the published-driver upgrade, operator-edit preservation, and both rollback-owner evidence. Four recorded Linux live cells passed at 9f39024; later compensation changes have current-head fault regressions. Windows and launchd lifecycle proof remains helper-based, as accepted for this landing.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 20, 2026
…nclaw#152717)

Restore node-host workspace downloads on hosts using umask 0002. The runtime, contained-directory, and seed-cache owners now create directories at 0700 and repair existing 0775 ancestry through the shared descriptor-based permission helpers. Filesystem safety validation and transferred payload permissions remain unchanged.

Cover fresh private-directory creation and legacy reopening through a child process and real HTTP workspace transfer. Give related test fixtures explicit private modes and document recovery without changing the host umask.

Validation: 30 transfer/startup tests under umask 0002, 28 seed/retention tests, 32 shared-state tests, hosted Testbox 70 passed, selected changed-file gates, and scoped-clean Codex review. Exact-head CI verified by the campaign lead.

Related: openclaw#152120
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations gateway Gateway runtime maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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