Skip to content

fix: protect live Gateways sharing an update installation - #160663

Merged
steipete merged 10 commits into
mainfrom
codex/shared-install-stop-first-150153
Sep 29, 2026
Merged

steipete merged 10 commits into
mainfrom
codex/shared-install-stop-first-150153

Conversation

@steipete

@steipete steipete commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Related: #150153

What Problem This Solves

Fixes package and source updates replacing a shared installation while another managed Gateway is still serving it.

User Impact

An observed live sibling blocks the update before the selected Gateway is stopped. The updater rechecks at artifact publication. Operators stop siblings through their own service managers or exact Startup entries; this updater does not control them.

Package --no-restart permits publication while the selected service runs. The Gateway's installation-change watcher can independently restart it. If delegated Doctor maintenance stops it, common finalization adopts that recorded stop, verifies the service identity, and restores it with an advisory. Unknown current identity keeps recovery pending; cleanup uncertainty and lost authority cannot grant a restart.

Discovery covers installed managed-service definitions and the invoking selector. It does not establish absence of every foreground process or undiscovered systemd template instance. Already-running published updaters retain their shipped behavior.

Why This Change Was Made

The existing build fence protected dist writes, but artifact publication also replaces dependencies and other installation files. The common publication boundary checks positively identified live consumers of those physical roots while retaining selected-service authority. On macOS it reads the loaded definition in the appropriate GUI or System domain. A running job remains visible when its loaded plist differs from the discovered file; the separate selected-service exception still requires an exact corresponding definition.

The maintainer decision is to retain manual sibling control: its operator stops the service before publication and restarts it after success through that service’s own manager. This implements the authorized stop-first scope of #150153.

Native proof exposed three related lifecycle defects. Staged settlement replayed an already-delivered refusal; an untouched activation journal blocked a later update; and runtime retention hardlinked that private journal. The existing owners now preserve the original refusal, retire only known pre-effect preparation, and exclude activation control state from runtime dependencies. Retirement applies to the same invocation's retained prepared operation, before transaction handoff or live mutation. Journal schemas and existing pending-journal admission are unchanged; foreign replacements, unknown cleanup, and separate database recovery evidence remain protected.

An earlier run published successfully but left the selected Gateway stopped: delegated Doctor wrote a stop receipt that only migrated finalization consumed. Ordinary and migrated finalization now share that existing adoption owner. Observed partial stops survive later joined errors, and recovery uses the established failure/result path. A predecessor stop is considered recorded only when the existing writer returns the same running run with its completed receipt. Receipt failures and uncertain process cleanup propagate before Doctor; ordinary joined later failures retain their existing warning behavior.

Evidence

The composed recovery source passed 211 tests across seven files in 156.81 seconds, including pre-stop refusal, the final publication race check, selected identity, ordinary/migrated stop adoption, partial-stop failures, unknown inspection, authority loss, and terminal settlement. Causal failures preceded their repairs. Production and 26 test type graphs, export scans, lints, structural guards, and independent P2 review passed.

The final macOS correction removes a three-line false-absence branch. Four causal mismatch cases failed before the correction; 252 sibling cases passed with one existing skip, and the exact receiving table passed 24/24 in 36.56 seconds. Scoped types/lint/format and fresh independent P2 review passed. Final source: 1cf29ef534a10873dc44d357e7db5b519bce0815, incorporating fixed canonical main bb869836e98ba61610cc2033e60f9685832f49db after an actual retained-runtime test conflict. Both regressions are preserved.

Fixed-main receiving passed 244 tests across nine files in 361.91 seconds. Review then identified two predecessor-stop settlement defects; the real producer/ledger and actual Doctor-entry regressions failed before repair. The repaired boundary suites passed 104 cases, followed by seven final affected controls, scoped lint/format and fresh P2 review. Type qualification combines 20 unchanged graphs with final production, affected CLI and six remaining graphs; the initial fixture type error remains recorded. The full fixed-base changed checks and final correctly scoped line-cap ratchet passed. Isolated migrated/rollback process suites: passed 78/78 on the signed 4cb4a243 production checkpoint in isolated run36533171811, with runtime preparation and natural settlement (225.91 seconds for the test wrapper).

Native macOS GUI component proof verified that querying another plist retains the actual loaded job's PID/start identity/path/arguments while selected correspondence refuses. Edited-definition and generated-wrapper checks also passed. Eight native commands joined; both synthetic jobs and processes retired, and the scratch directory was removed. This is component evidence. A prior System-domain observation had no running PID, and isolated guest execution was unavailable; positive-live System-domain proof remains unqualified.

Linux proof used the independently verified 307a594a281735de81ec00d170c67d0f4ba3fefd tree and its authenticated packed candidate. The earlier macOS-only successor left Linux owners unchanged. The final composition additionally incorporates canonical recovery owners and the scoped predecessor error-path repair, with receiving proof above. The native observations apply to their inspected paths; they are not a claim that the final merged binary or package archive is identical.

  • Live shared sibling: update refused before stopping the selected Gateway; selected generation and the sibling's complete captured snapshot remained unchanged.
  • Stopped shared sibling: update returned success and the exact target became healthy with unchanged service definition/environment. The journal attributes the generation change to the existing installation watcher. The strict Doctor-stop/adoption assertion remained unqualified because that run recorded no Doctor stop. It is retained as a failed maintenance-specific cell, not relabeled as a full campaign pass. Real producer-to-ordinary/migrated-finalizer controlled proof covers adoption separately.
  • Live disjoint installation: a separate normal update passed in 194.485 seconds. The selected Gateway gained a new process/native invocation and served the exact target; peer PID 31220, its complete captured snapshot, and its package stayed unchanged. All 55 commands joined and cleanup passed.
  • Published [email protected] to candidate: the maintained base survivor scenario passed in manual-restart mode in 330.284 seconds, including updater installation, package identity, migration/preservation, post-update Doctor, Gateway start, health, readiness, and status. The bounded report lacks a complete internal post-core exit snapshot; it does not qualify that internal delegation or the native managed-parent restart path.

The Linux source-bound run is 36523514530. The failed maintenance attempt and two independent continuations have separate authenticated archives: a5689ca7afc5b05bc483c5e0b60218fdd4caadc485f2e95c366c09ec3673ca0e, eea4f587740084092153f4a83372766fdeadb7c1b881719113deac0da945090c (disjoint), and 320be7de014a12eeb4433d0dac56452218155715890c121d5cb73657047b2bef (published manual upgrade). Every command joined; the guest is completed. Earlier journal, hardlink, unhealthy-Gateway, and observer-bootstrap failures remain preserved.

A later CI run on 4cb4 exposed one introduced fixture-intake omission: the explicit VM module graph did not load the adoption owner now called by common finalization. The two-line correction loads both actual production owners, preserving all 19 backup-retirement/verification assertions and deadlines. The original 9 failures became 19/19 passes; the exact Vitest wrapper, scoped lint/format and fresh P2 review also passed. Production bytes are identical to the fully qualified 4cb4 checkpoint.

CI on 307a failed on an unchanged canonical Cron fixture's no-map-spread diagnostic; 112 cancelled jobs remain unrun coverage. The canonical fix is 743c2ceb72e7d1372845ea6f834bb82993fc9e0e, independently verified with typed lint and ten owning tests. No introduced failure is waived. Successor CI is pending.

This PR does not claim automatic Windows 9.3/9.4 completion, unchanged-generation --no-restart continuity, positive-live macOS System-domain proof, or completion of the umbrella's separate reference-script and foreground-process obligations. Published 9.6's same-schema managed parent has a distinct post-core authority limitation; changing candidate common finalization does not patch that in-memory parent.

@clawsweeper

clawsweeper Bot commented Sep 28, 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 docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes scripts Repository scripts size: XL labels Sep 28, 2026
@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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 29, 2026, 3:38 AM ET / 07:38 UTC (Revision 10).

ClawSweeper review

What this changes

The branch checks for live managed Gateways sharing an installation before updates publish files, extends macOS service observation, and coordinates update recovery with service restoration.

Merge readiness

⛔ Blocked before merge - 6 items remain

Keep open. Current main does not protect package and source publication from a live Gateway sharing the installation, and this focused branch has meaningful work. The remaining blocker is native proof of the service authority boundary.

Priority: P1
Reviewed head: 1cf29ef534a10873dc44d357e7db5b519bce0815

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch has focused boundary checks and substantial validation, while two native authority outcomes remain unproven.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: Authority-chain proof required: The PR body reports after-fix Linux shared-sibling refusal and disjoint-install success, with native macOS GUI component observations. It expressly leaves positive-live System-domain refusal and native Doctor-stop restoration with stale-authority rejection unqualified. The activation journal schema is unchanged, and the new retirement applies to same-invocation pre-effect preparation rather than changing a stored-data format. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: Authority-chain proof required: The PR body reports after-fix Linux shared-sibling refusal and disjoint-install success, with native macOS GUI component observations. It expressly leaves positive-live System-domain refusal and native Doctor-stop restoration with stale-authority rejection unqualified. The activation journal schema is unchanged, and the new retirement applies to same-invocation pre-effect preparation rather than changing a stored-data format. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 10 items Introduced publication boundary: The branch checks managed consumers before stopping the selected service and again before mutation.
Selected-service exception: A live overlapping binding is exempted only after comparison with the selected service; unavailable binding reads are skipped, so the guard protects positively observed consumers.
macOS domain selection: The new reader queries discovered LaunchDaemons in the system domain and other LaunchAgents in the invoking GUI domain.
Findings None None.
Security Needs attention Unqualified native restart authority: A Doctor stop receipt can cause finalization to restart a service. Source checks its current identity, but available native evidence does not yet show rejection of a stale or reassigned service before that final effect.

How this fits together

The update CLI stages a package or Git candidate and checks which managed Gateway services use the target installation before replacing files. Finalization then uses Doctor stop records to decide whether to restore the selected Gateway.

flowchart LR
A[Update request] --> B[Target installation]
B --> C[Managed service inventory]
C --> D{Live sibling shares files?}
D -->|Yes| E[Refuse before stop]
D -->|No| F[Publish update]
F --> G[Doctor and service recovery]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: Authority-chain proof required: The PR body reports after-fix Linux shared-sibling refusal and disjoint-install success, with native macOS GUI component observations. It expressly leaves positive-live System-domain refusal and native Doctor-stop restoration with stale-authority rejection unqualified. The activation journal schema is unchanged, and the new retirement applies to same-invocation pre-effect preparation rather than changing a stored-data format. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve security concern: Unqualified native restart authority - A Doctor stop receipt can cause finalization to restart a service. Source checks its current identity, but available native evidence does not yet show rejection of a stale or reassigned service before that final effect.
  • Resolve merge risk (P1) - No positive-live macOS System-domain trace shows a sibling being refused before final installation replacement; a failed native observation could leave files in use exposed.
  • Resolve merge risk (P1) - No native Doctor-triggered stop trace shows restoration of the same selected service and rejection of stale or reassigned service authority before restart.
  • Resolve merge risk (P1) - The materially changed tests have aggregate timings but no per-file wall time and CI seconds, leaving their recurring CI cost unqualified under repository policy.
  • Complete next step (P2) - Add native terminal output or logs for live System-domain sibling refusal and Doctor-triggered restoration, including stale or reassigned identity rejection; report per-file test wall time and CI seconds. Redact addresses, keys, phone numbers, and private endpoints. Update the PR body to trigger re-review, or ask a maintainer to comment @clawsweeper re-review if it does not.

Findings

  • [medium] Unqualified native restart authority — src/infra/update-candidate-predecessor-stop.ts:275
Agent review details

Security

Needs attention: The diff adds no dependency or workflow execution change, but native service restart authority still needs final-effect proof.

PR surface

Source +686, Tests +1716, Docs +18, Other -3. Total +2417 across 39 files.

View PR surface stats
Area Files Added Removed Net
Source 19 866 180 +686
Tests 18 1991 275 +1716
Docs 1 21 3 +18
Config 0 0 0 0
Generated 0 0 0 0
Other 1 49 52 -3
Total 39 2927 510 +2417

Review metrics

Metric Value Why it matters
Production and test growth production +686, tests +1716, tooling -3, docs +18 net lines The production growth has a stated cross-platform safety and recovery rationale; the enlarged test surface makes per-file cost evidence useful.

Merge-risk options

Maintainer options:

  1. Qualify native final effects (recommended)
    Capture redacted native traces showing System-domain sibling refusal before publication, matching-service restoration after a Doctor stop, and stale or reassigned service rejection before restart.

Technical review

Best possible solution:

Keep the stop-first publication fence and unified Doctor-stop recovery, then qualify the native final effects for a live System-domain sibling and for current versus stale selected-service authority.

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

Yes. Two managed Gateways sharing one physical installation provide a concrete path, and current-main source lacks the branch's shared-consumer publication check; this read-only review did not execute the failure.

Is this the best way to solve the issue?

Yes in principle. The update and service owners are the appropriate boundaries for the guard and restoration, with native final-effect proof still needed before merge.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P1: Replacing an installation used by another live Gateway can interrupt an active update and serving workflow.
  • merge-risk: 🚨 compatibility: The documented stop-first behavior makes updates of a shared live installation require operators to stop sibling services manually.
  • merge-risk: 🚨 security-boundary: Doctor stop adoption can authorize a native restart, and final-effect rejection of stale or reassigned service identity is not yet proven.
  • merge-risk: 🚨 availability: A missed live sibling or an unverified Doctor restoration could disrupt Gateways during an update.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Authority-chain proof required: The PR body reports after-fix Linux shared-sibling refusal and disjoint-install success, with native macOS GUI component observations. It expressly leaves positive-live System-domain refusal and native Doctor-stop restoration with stale-authority rejection unqualified. The activation journal schema is unchanged, and the new retirement applies to same-invocation pre-effect preparation rather than changing a stored-data format. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

Security concerns:

  • [medium] Unqualified native restart authority — src/infra/update-candidate-predecessor-stop.ts:275
    A Doctor stop receipt can cause finalization to restart a service. Source checks its current identity, but available native evidence does not yet show rejection of a stale or reassigned service before that final effect.
    Confidence: 0.78

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • DonnieFi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Show final-effect refusal for a positively live macOS System-domain sibling before installation replacement.
  • Show a native Doctor stop restoring only the matching service and rejecting stale or reassigned identity before restart.
  • Add per-file wall time and available CI seconds for materially changed tests.

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 (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-28T21:19:08.856Z sha 13d79b3 :: blocked before merge. :: [P1] Check live siblings before stopping the selected Gateway
  • reviewed 2026-09-28T21:47:11.908Z sha 13d79b3 :: needs real behavior proof before merge. :: [P1] Check live siblings before stopping the selected Gateway
  • reviewed 2026-09-28T23:12:20.095Z sha d4ba848 :: needs real behavior proof before merge. :: [P1] Check live siblings before stopping the selected Gateway
  • reviewed 2026-09-29T01:24:25.231Z sha bea9dec :: needs real behavior proof before merge. :: [P1] Check live siblings before stopping the selected Gateway
  • reviewed 2026-09-29T02:37:28.209Z sha bea9dec :: needs real behavior proof before merge. :: [P1] Check live siblings before stopping the selected Gateway | [P2] Update the macOS fence test to use the loaded service reader
  • reviewed 2026-09-29T04:17:25.273Z sha 307a594 :: needs real behavior proof before merge. :: [P1] Keep a running launchd job visible when its plist path differs
  • reviewed 2026-09-29T05:52:15.518Z sha 52f959e :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-29T07:09:09.042Z sha 4cb4a24 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 28, 2026
@steipete
steipete marked this pull request as ready for review September 28, 2026 21:38
@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 28, 2026
Use the retained publication owner to disarm and retire a known pre-effect refusal, allowing the next update to enter. Preserve recovery evidence on unknown cleanup or a foreign replacement, including both failure causes. Receive the real fence dependency into declaration fixtures without invalidating relocation cache identities, and keep legacy refusal assertions aligned with the all-artifact diagnostic.
@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 28, 2026
Check known shared consumers before stopping the selected Gateway and retain the publication recheck. Adopt delegated Doctor stops in common finalization, preserve partial-stop failures, and keep uncertain recovery fenced. Update the native-reader fixture and document maintenance restoration.
Keep the native loaded command and PID available for shared-install publication refusal when the discovered plist differs. Selected-service correspondence still requires the exact current definition and grants no control over the other job.

Four causal regressions, 252 sibling cases, receiving 24 cases, scoped types/lint and independent review passed. Native synthetic GUI jobs preserved loaded identity across mismatched queries, refused selected correspondence, and retired cleanly.
@clawsweeper clawsweeper Bot added the rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. label Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant