Skip to content

fix(update): verify launchd job identity during handoff - #188226

Merged
vincentkoc merged 3 commits into
mainfrom
fix/update-launchd-job-identity-20261030
Oct 30, 2026
Merged

vincentkoc merged 3 commits into
mainfrom
fix/update-launchd-job-identity-20261030

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

What problem does this PR solve?

The update helper extracted launchd state and PIDs with flat regular expressions. Nested coalition data or a foreign job could be mistaken for the selected service generation and authorize recovery.

User impact

Managed updates inspect the selected launchd job consistently with daemon commands. Ambiguous or oversized inspections refuse recovery with a visible diagnostic.

Why this change?

Move the existing pure job parser to one shared owner; use it in daemon callers and the captured helper. Remove the helper's duplicate flat parser. Invalid recovery identity remains a terminal refusal.

Retain complete launchctl print stdout up to 1,048,576 characters; refuse overflow without discarding native stderr. Other command tails remain unchanged. The helper captures the parser before package replacement and requires no new export from an older installed runtime. The recovery-source split is byte-identical.

Production +25 lines; tests +318 lines, 16 files. Growth supplies complete bounded inspection and the shared ownership contract. No config, schema, protocol or public SDK change.

Validation

  • Current signed head: 6f68371b376e0d2cc8127a4148288ee4605279fd. The final commit adds only generated-helper proof and extracts existing test preload setup to respect the fixture line cap. Production bytes are unchanged from 59003b5c3dacb5b3da00a2e401d183d780a2e3c3.
  • Current-head CI passed, including all three PostgreSQL conformance stripes.
  • Prior production-identical CI passed: 413 focused cases passed, zero failed, seven skipped across 16 suites. All three general PostgreSQL conformance jobs passed.
  • Actual focused coverage: daemon parser/runtime and callers; command-source VM/command/cross-process; native lifecycle/runtime/ownership; foreground/lifecycle; launchd/systemd/shared recovery; terminal/termination/triage. Skips: five lifecycle PostgreSQL cases, one cross-process case and one native ownership platform fixture. Skipped execution is not claimed.
  • Root directly verified complete 9,000-character inspection and 1,048,577-character overflow refusal and selected-job parser/caller results.
  • Generated-helper native-lifecycle job: 42/42 cases passed. The selected launchd case checks print → disable → bootout → enable → bootstrap/kickstart → print and restored readiness. Four wrong-parent/nested-parent/foreign-job/duplicate-PID cases record only the selected-target inspection, with no mutation. Six malformed-restoration cases refuse before readiness; both 9,000-character framing cases recover successfully.
  • New real-lease generation case passed: 489 ms, native lifecycle 43/43 passed. the actual helper holds the real successful selected-target inspection close. After the parent observes it, the helper advances its real SQLite lease through canonical store.bind, verifies the captured generation is stale and the replacement is owned, then forwards the original native close arguments. Assertions require only print, a live parent, empty manager state, no updater, and preservation of the replacement until canonical cleanup after helper close. No mocked authority, fabricated lease rows, cancellation override or process-signal override is used.
  • Those cases execute the actual generated helper and child processes on Ubuntu with a fixture launchctl, not macOS launchd; macOS execution is not claimed. The unchanged universal pre-spawn lease guard remains at src/infra/update-managed-service-handoff-command-source.ts:6. Earlier lease-loss coverage used a mocked-authority Scheduled Task VM case and a real repair claim; the new generated launchd generation-invalidation case passed current CI. This PR does not change lease ownership or dispatch authorization.
  • Prior production-identical Package Acceptance passed, including package build, integrity, npm 12 install/CLI acceptance and latest-stable [email protected] authenticated restart. The targeted job passed its lane in 1,489 seconds. Frozen admission binds SHA 59003b5c to package SHA-256 e6fbd7669650df5a9e209de3e070fd1b7a15a50927afda56549b6976d54dff8c.
  • The receipt artifact records candidate full-payload identity passed at 16:10:45.994Z, actual updater installation passed at 16:20:58.645Z, installed full-payload identity passed at 16:20:59.475Z and settings/data survival passed at 16:23:05.196Z. The candidate-to-future authenticated restart succeeded; readiness/status checks passed, failures are empty and cleanup joined. The first-hop post-core exit snapshot is unavailable, so its original exit outcome is not claimed. Bounded diagnostic excerpts have recorded omissions; phase/identity/restart receipts remain available.
  • Earlier complete-output and native-stderr findings are implemented. The latest prior-head ClawSweeper review found no code defects but held landing for real-lease invalidation after inspection. The new test passed and addresses that exact proof request. Final exact-head ClawSweeper review accepted the real-lease proof: no findings, no before-merge request and no remaining rank-up move. Normal exact-head CI passed.
  • Separate follow-up recorded during earlier CI: config-archive backup symlink ownership. That surface is unchanged here; current CI's PostgreSQL stripes are green.

No local dependency-backed execution or live operator service mutation is claimed.

@vincentkoc vincentkoc self-assigned this Oct 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 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 size: L labels Oct 30, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review October 30, 2026 09:43
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. 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. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR shares the selected launchd job parser with the update helper and preserves complete, bounded inspection output.

Example: The selected job has root PID 4243, but its nested coalition reports the expected parent PID 4242.

  • Before: The helper can accept nested PID 4242 and proceed with service parking.
  • After: The helper reads root PID 4243 and refuses parking before native mutation.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The authorized production-helper authority harness addresses the prior blocker, supported by production-identical package upgrade acceptance; native launchd execution remains outside the evidence.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (linked_artifact): The generated production helper exercises allowed parking/restoration and rejects foreign, nested, duplicate, and stale-lease identities through real child processes with fixture launchctl on Ubuntu; the new exact-head successful case replaces the real SQLite lease after inspection and verifies no subsequent service mutation or successor release. This satisfies the previous authority-proof request; native macOS execution is not claimed, and hosted log downloads were allowlist-blocked.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A managed update can mistake nested or foreign launchd identity for the selected Gateway generation.
Reason: The maintainer-authored repair restores the existing exact-service contract without adding configuration, persisted formats, or a public API.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR fixes a current-main identity-checking defect, and no actionable introduced defect remains.

Priority: P2
Reviewed head: 6f68371b376e0d2cc8127a4148288ee4605279fd

Before merge

None.

Findings

None.

Agent review details

How this fits together

The detached update helper consumes launchctl inspection output and the current update lease to decide whether it may park or restore the selected Gateway service.

flowchart TD
  A[Managed update request] --> B[Detached helper]
  B --> C[Current lease owner]
  B --> D[Bounded launchctl inspection]
  D --> E[Shared selected job parser]
  E --> F[Identity and authority checks]
  C --> F
  F --> G[Park or restore service]
Loading

Technical review

Best possible solution:

Land the shared-parser repair through the existing update owner once the normal exact-head gates pass.

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

Current main's flat expression can select a nested PID before the root PID; supplied generated-helper cases exercise that input, although no target code was executed during this review.

Is this the best way to solve the issue?

The smallest complete fix is to reuse the existing selected-job parser, preserve its complete bounded input, and terminate invalid-identity recovery without retrying through the outer failure handler.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Selected-job parser and daemon consumers keeps the original intent (e694fa7: Loaded service inspection must identify the selected job; subsequent daemon work explicitly reused this parser to ignore nested coalition state.)
  • Managed service parking and restoration keeps the original intent (fix(update): keep managed handoff as successor owner #128212: Only the exact service generation and current successor owner may stop or restore the Gateway.)
  • Inspection output capture changes intended behavior with a stated reason (d264306: Existing command collection retained bounded output tails; the PR explains why launchctl identity inspection instead needs the header and all root fields with a finite overflow refusal.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 76bf977 adds src/infra/update-managed-service-handoff.ts:1 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 76bf977faefe; files: src/infra/update-managed-service-handoff.ts)
  • Vincent Koc: Raw commit 514b336 adds src/infra/update-managed-service-handoff.ts:12 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 514b3365b54c; files: src/infra/update-managed-service-handoff.ts)

PR surface

Source +25, Tests +318. Total +343 across 16 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 8 249 224 +25
Tests 8 378 60 +318
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 16 627 284 +343

Review metrics

Metric Value Why it matters
Production versus test growth Production net +25 lines; tests and support net +318 lines Production growth provides bounded complete inspections and terminal parser-error handling; test growth covers distinct framing, identity, restoration, and stale-lease boundaries.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This repairs a limited macOS managed-update identity path without evidence of an ongoing widespread outage.
  • merge-risk: 🚨 compatibility: Malformed or oversized inspections now refuse recovery deliberately, as explicitly accepted in the maintainer-authored direction.
  • merge-risk: 🚨 security-boundary: Parsed job identity participates in authorization for native service effects; selected-job rejection and stale-lease final-effect proof cover that boundary.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-30T10:01:52.574Z sha f9be864 :: needs real behavior proof before merge. :: [P2] Preserve the inspection header before using the strict parser | [P2] Include the recorded failure detail in restoration expectations
  • reviewed 2026-10-30T16:44:26.509Z sha 59003b5 :: needs real behavior proof before merge. :: none

Reviewed October 30, 2026, 1:13 PM ET / 17:13 UTC (Revision 3).

@vincentkoc
vincentkoc force-pushed the fix/update-launchd-job-identity-20261030 branch from 4b7c311 to 59003b5 Compare October 30, 2026 15:45
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 30, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 30, 2026
@vincentkoc
vincentkoc merged commit 1034356 into main Oct 30, 2026
187 checks passed
@vincentkoc
vincentkoc deleted the fix/update-launchd-job-identity-20261030 branch October 30, 2026 17:23
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 31, 2026
)

* fix(update): verify launchd job identity during handoff

* fix(update): retain complete launchd inspection identity

* test(update): reject stale launchd lease after inspection

Co-authored-by: Vincent Koc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime 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. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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