Repository navigation
feat(gateway): idempotent start, non-interactive stop guard, unified lifecycle audit - #110323
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1a29054839
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!isTerminalInteractive() && !opts.force) { | ||
| const { fail } = createDaemonActionContext({ action: "stop", json: Boolean(opts.json) }); | ||
| fail(NON_INTERACTIVE_GATEWAY_STOP_MESSAGE); |
There was a problem hiding this comment.
Add --force for scripted gateway stop paths
In non-interactive release automation this guard now exits before the service stop runs: scripts/lib/cross-os-release-checks/runtime.ts:109-117 still invokes gateway stop without --force, and runInstalledCli runs it through runCommandInvocation with stdio: ["ignore", "pipe", "pipe"] and check defaulting true (scripts/lib/cross-os-release-checks/process.ts:274-279, scripts/lib/cross-os-release-checks/installed.ts:371-377). That makes the managed lifecycle release check fail every time it reaches the stop phase instead of proceeding to the following gateway start; update those owned scripted stop calls to pass --force or otherwise exempt this trusted lane.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 14e7c7d654
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (state.loaded && state.running) { | ||
| return { | ||
| outcome: "already-running", | ||
| state, |
There was a problem hiding this comment.
Check repair issues before reporting already running
When the service is loaded and currently running, this new early return bypasses the repairIssues check below, so openclaw gateway start will report success without repairing a stale service definition. This hits real upgrade/config-change cases such as OPENCLAW_SERVICE_VERSION drift, temporary/missing program paths, or a managed port that no longer matches the current config; the existing repair path only runs when readRuntime() is not running, so a healthy-but-stale gateway keeps running on the old command instead of being reinstalled/restarted.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f674cc69d8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| action: GatewayLifecycleAction; | ||
| }): ((mutation: GatewayLifecycleMutation) => void) | undefined { | ||
| return params.serviceNoun === "Gateway" | ||
| ? createGatewayLifecycleMutationAudit({ action: params.action }) |
There was a problem hiding this comment.
Write lifecycle audits to the service state dir
When the installed service carries its own OPENCLAW_STATE_DIR or OPENCLAW_PROFILE, managed start/stop/restart run the platform adapter with the merged service environment, but this audit callback is created without that env and falls back to process.env. In that scenario the lifecycle mutation succeeds against the selected service while the new gateway-restart.log entry is written under the caller's default state dir, so status/debug hints that point at the service state dir won't contain the documented audit record.
Useful? React with 👍 / 👎.
|
Codex review: needs real behavior proof before merge. Reviewed July 18, 2026, 1:58 AM ET / 05:58 UTC. Summary PR surface: Source +478, Tests +603, Docs +3. Total +1084 across 35 files. Reproducibility: not applicable. as a conventional bug reproduction: this PR introduces a new lifecycle safety policy, and the supplied evidence is tests and typechecks rather than an observed before/after operator run. Review metrics: 1 noteworthy metric.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Confirm the non-interactive safety policy, update every supported automation caller and migration note, then demonstrate idempotent start, refused unforced stop, deliberate forced stop, and guarded Do we have a high-confidence way to reproduce the issue? Not applicable as a conventional bug reproduction: this PR introduces a new lifecycle safety policy, and the supplied evidence is tests and typechecks rather than an observed before/after operator run. Is this the best way to solve the issue? Unclear. The implementation is a plausible safety design, but it is not the best solution until maintainers confirm that breaking existing non-interactive stop callers is preferable to preserving their current behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8178cf10385d. Label changesLabel justifications:
Evidence reviewedPR surface: Source +478, Tests +603, Docs +3. Total +1084 across 35 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
Review history (1 earlier review cycle)
|
f674cc6 to
fe2330f
Compare
|
Merged via squash.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fe2330fb8e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| if (opts.force) { | ||
| const describeNonInteractiveGatewayOwner = () => { | ||
| const gatewayPids = findVerifiedGatewayListenerPidsOnPortSync(port); |
There was a problem hiding this comment.
Verify fuser victims before non-interactive force-kill
When openclaw gateway run --force is non-interactive on a minimal Linux host where lsof is missing or denied, this check returns no gateway PIDs because findVerifiedGatewayListenerPidsOnPortSync uses the lsof-backed path that returns [] on ENOENT (src/infra/restart-stale-pids.ts:367-368). forceFreePortAndWait then falls back to fuser (src/cli/ports.ts:343-355) and the beforeSignal callback re-runs the same blind check, so an operator Gateway listener can still be SIGTERM/SIGKILLed despite the new refusal; verify the fuser PID passed to beforeSignal before allowing the signal.
Useful? React with 👍 / 👎.
…lifecycle audit (openclaw#110323) * feat: guard gateway lifecycle mutations * fix: harden gateway lifecycle mutation guards * fix: harden gateway lifecycle audit safety * fix(cli): repair gateway lifecycle checks * fix(cli): satisfy lifecycle CI gates
…lifecycle audit (openclaw#110323) * feat: guard gateway lifecycle mutations * fix: harden gateway lifecycle mutation guards * fix: harden gateway lifecycle audit safety * fix(cli): repair gateway lifecycle checks * fix(cli): satisfy lifecycle CI gates
Summary
Agents (and scripts) have been fighting over operators' running gateways:
gateway starton a loaded service silently restarted it, non-interactivegateway stopcould bootout a production service or SIGTERM a dev gateway it never started, andgateway run --forcekilled whatever held the port. Most restarts also bypassed thegateway-restart.logaudit trail.Changes
gateway startis now idempotent: loaded + running -> "already running (pid N)", exit 0. No hidden restart.gateway stopin a non-interactive shell requires--force; the refusal teaches the isolated-dev-gateway path (run --dev/--profile+ free port). Interactive behavior unchanged. Applies to managed bootout and the unmanaged port-SIGTERM fallback. The system-agent approval flow suppliesforce(its approval gate is the consent).gateway run --forcein a non-interactive shell refuses to kill a verified existing gateway listener, with per-signal revalidation (no check-then-kill race); fuser fallback resolves and validates concrete PIDs (stdout only) before signaling.gateway-restart.log, immediately after each successful mutation, best-effort.Proof
Docs:
docs/cli/gateway.mdupdated. Policy context: AGENTS.md "Tests" live-gateway rules (2ca4d92).