Skip to content

fix(cli): block gateway-owned package updates#75819

Merged
hxy91819 merged 1 commit into
openclaw:mainfrom
ai-hpc:fix/update-block-gateway-service
May 3, 2026
Merged

fix(cli): block gateway-owned package updates#75819
hxy91819 merged 1 commit into
openclaw:mainfrom
ai-hpc:fix/update-block-gateway-service

Conversation

@ai-hpc

@ai-hpc ai-hpc commented May 1, 2026

Copy link
Copy Markdown
Member

Summary

Validation

  • pnpm exec oxfmt --check --threads=1 src/cli/update-cli/update-command.ts src/cli/update-cli.test.ts src/infra/restart-stale-pids.ts
  • git diff --check
  • pnpm test src/cli/update-cli.test.ts src/infra/restart-stale-pids.test.ts -- --reporter=verbose
  • Live VPS smoke: simulated gateway service context with OPENCLAW_SERVICE_MARKER=openclaw OPENCLAW_SERVICE_KIND=gateway pnpm openclaw update --channel stable --tag latest --yes and confirmed the update aborts before package install/service stop.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: M labels May 1, 2026
@clawsweeper

clawsweeper Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Summary
The PR exports the existing PID ancestry walker, uses it in openclaw update to abort package-manager updates when the active Gateway runtime PID is in the caller ancestry, adds a CLI regression test, and updates the changelog.

Reproducibility: yes. #75691 gives a concrete systemd plus agent-exec no-marker path, and current main source still stops/updates based on service state without checking whether the active Gateway PID is in the caller ancestry.

Next step before merge
No repair job: the branch already contains the focused code, test, and changelog changes; remaining work is normal maintainer review plus exact-head CI/rebase reconciliation.

Security
Cleared: The diff changes updater control flow and exports an existing internal PID helper, with no new dependency, workflow, package-source, secret-handling, or supply-chain execution surface.

Review details

Best possible solution:

Land the narrow ancestry guard after rebase and exact-head CI, preserving the merged #75729 service-marker guard and the changelog entry.

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

Yes. #75691 gives a concrete systemd plus agent-exec no-marker path, and current main source still stops/updates based on service state without checking whether the active Gateway PID is in the caller ancestry.

Is this the best way to solve the issue?

Yes. Reusing the existing bounded ancestry walker and refusing before service stop/package replacement is the narrow maintainable fix for this failure mode; a detached restart helper would be a larger separate design.

What I checked:

Likely related people:

Remaining risk / open question:

  • Provided PR context marks the branch mergeable: false against an older base while current main has moved to 0135071833b439e5782252857504058dc6f17230, so exact-head CI and rebase state need maintainer reconciliation before merge.
  • This read-only review did not rerun the PR's targeted Vitest or formatter commands; validation rests on source inspection plus the PR's reported targeted and live VPS proof.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 0135071833b4.

@ai-hpc
ai-hpc force-pushed the fix/update-block-gateway-service branch from 112ec87 to 44fb766 Compare May 1, 2026 21:37
@ai-hpc

ai-hpc commented May 1, 2026

Copy link
Copy Markdown
Member Author

I reviewed/tested the related service-marker approach and found the critical lifecycle risk in live VPS testing: an updater launched from a Gateway-owned exec lane can stop the service that owns its process tree and then be SIGTERM’d before package replacement/restart completes.

This PR fixes the underlying #75691 failure mode more directly by blocking before any service stop or package mutation when the active Gateway PID appears in the caller’s PPID ancestry.

Live proof: targeted tests passed for src/cli/update-cli.test.ts and src/infra/restart-stale-pids.test.ts; then a real Gateway-owned agent exec ran with service-marker env explicitly unset and reported self=1447931 ppid=1443416 gateway_pid=1443416. openclaw update exited 1 with openclaw update detected it is running inside the gateway process tree, and the Gateway stayed healthy afterward: MainPID=1443416 ActiveState=active SubState=running.

So this is intentionally narrower than the service-marker PR: it does not try to redesign the post-core marker/runtime-state flow, it just closes the unsafe in-lane update path before the Gateway can kill its own updater.

@ai-hpc

ai-hpc commented May 1, 2026

Copy link
Copy Markdown
Member Author

Live VPS validation on commit 44fb7668ce:

  • Gateway before repro: MainPID=1443416 ActiveState=active SubState=running.
  • Targeted tests passed: pnpm test src/cli/update-cli.test.ts src/infra/restart-stale-pids.test.ts -- --reporter=verbose.
  • Test details: src/infra/restart-stale-pids.test.ts passed 48 tests; src/cli/update-cli.test.ts passed 69 tests; total 2 Vitest shards passed in 11.18s.
  • Gateway path sanity check passed: openclaw agent --agent main --message 'Reply with OK only.' returned OK.
  • Strict no-marker live repro ran from a real Gateway-owned agent exec with OPENCLAW_SERVICE_MARKER and OPENCLAW_SERVICE_KIND unset.
  • Repro process proof: self=1455610 ppid=1443416 gateway_pid=1443416.
  • openclaw update exited 1 with openclaw update detected it is running inside the gateway process tree.
  • Gateway after repro stayed healthy: MainPID=1443416 ActiveState=active SubState=running.

This validates the #75691 failure mode directly: a package update launched from inside the active Gateway process tree is refused before service stop/package mutation, so the Gateway does not kill the updater or keep running stale code silently.

image

@hxy91819

hxy91819 commented May 2, 2026

Copy link
Copy Markdown
Member

Thanks for opening this and for the live VPS proof.

My read is that this PR is not a duplicate of #75729. They cover related but different safety signals:

Plan from my side:

  1. Land fix(cli): block package updates from inside running gateway service #75729 first, since it is the broader service-marker/runtime-state guard and has already absorbed the review feedback there.
  2. Rebase this PR on top of fix(cli): block package updates from inside running gateway service #75729.
  3. Keep the PPID-ancestry guard from this PR, add the requested changelog entry, and then proceed with review/merge.

So please keep this PR open. After rebase, it should remain intentionally narrow: block restartful package updates before service stop/package replacement when the active Gateway PID appears in the caller ancestry.

@hxy91819
hxy91819 force-pushed the fix/update-block-gateway-service branch from eb7f46f to acdf73e Compare May 3, 2026 03:39
@hxy91819
hxy91819 merged commit c81c017 into openclaw:main May 3, 2026
78 checks passed
@hxy91819

hxy91819 commented May 3, 2026

Copy link
Copy Markdown
Member

Merged via squash.

Thanks @ai-hpc!

lxe pushed a commit to lxe/openclaw that referenced this pull request May 6, 2026
Merged via squash.

Prepared head SHA: acdf73e
Co-authored-by: ai-hpc <[email protected]>
Co-authored-by: hxy91819 <[email protected]>
Reviewed-by: @hxy91819
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
Merged via squash.

Prepared head SHA: acdf73e
Co-authored-by: ai-hpc <[email protected]>
Co-authored-by: hxy91819 <[email protected]>
Reviewed-by: @hxy91819
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
Merged via squash.

Prepared head SHA: acdf73e
Co-authored-by: ai-hpc <[email protected]>
Co-authored-by: hxy91819 <[email protected]>
Reviewed-by: @hxy91819
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
Merged via squash.

Prepared head SHA: acdf73e
Co-authored-by: ai-hpc <[email protected]>
Co-authored-by: hxy91819 <[email protected]>
Reviewed-by: @hxy91819
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
Merged via squash.

Prepared head SHA: acdf73e
Co-authored-by: ai-hpc <[email protected]>
Co-authored-by: hxy91819 <[email protected]>
Reviewed-by: @hxy91819
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: openclaw update should detect when invoked from inside the gateway process tree (PPID-ancestry guard)

2 participants