Skip to content

fix(gateway): safely defer agent-approved Gateway restarts - #117530

Merged
steipete merged 4 commits into
mainfrom
codex/fix-115475-safe-agent-gateway-restart
Aug 2, 2026
Merged

steipete merged 4 commits into
mainfrom
codex/fix-115475-safe-agent-gateway-restart

Conversation

@steipete

@steipete steipete commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Bug

An approved agent-triggered Gateway restart can terminate its own host before the operator sees completion, or be silently rejected after the original request root is released.

Fix

Route Gateway-hosted approved restarts through the existing cooperative safe-restart RPC. Admit delayed approval work under an independent live root and keep it in the tracked command lane until actual execution, durable SQLite audit, visible completion, and restart drain complete. Preserve explicit operator approval, sandbox capability gating, and standalone CLI behavior. No new config, product surface, or schema version.

Review and verification status

  • Exact nine-file independently reviewed owner patch SHA256: 5332a66efc0e3d7c6c69f053e224dea4d0ca26a3befc5a50575690f720eeb4b7.
  • Two independent source/security reviews and a separately self-invoked authenticated substantive Codex review passed after correcting both actual approval lifecycle races.
  • git diff --check passes.
  • Validation:
    • All 13 CI shards pass; focused Gateway operator-approval/restart tests pass.
    • The native Windows workflow passes five real Scheduled Task restart tests (proof artifact).
    • Real Gateway processes restarted through PIDs 6400 → 8980 → 8200 and rebound port 53497; InteractiveToken and least-privilege Scheduled Task principals were verified, and cleanup completed.
    • Scope limitation: the native workflow exercises service.restart directly; the full hosted human-approval path is covered by focused Gateway tests, not a live native approval session.
    • Maintainer disposition: the repository owner acknowledges and accepts the bounded restart availability/security and owner-boundary risk.

Fixes #115475

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Aug 1, 2026
@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 1, 2026, 10:21 PM ET / August 2, 2026, 02:21 UTC.

ClawSweeper review

What this changes

The PR routes approved Gateway-hosted system-agent restarts through the cooperative local restart coordinator, retains delayed approval work under tracked Gateway admission, and updates restart guidance and coverage.

Merge readiness

⛔ Blocked until real behavior proof is added - 4 items remain

Keep this PR open. The source change is a coherent repair for the released-root restart race, but the PR body still supplies no after-fix runtime artifact for the native Windows Scheduled Task path and the protected maintainer label requires explicit maintainer handling before merge.

Priority: P2
Reviewed head: 51fed946d3adaf3ebf877cd38dd44cb5f16d9892

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation and focused source coverage are credible, but absent real restart proof remains a merge gate for this availability-sensitive change.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: The PR body explicitly says native Windows Scheduled Task proof and hosted focused validation have not run, and no after-fix runtime artifact is present; add redacted terminal output, logs, or a recording showing approval through Gateway recovery. 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 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body explicitly says native Windows Scheduled Task proof and hosted focused validation have not run, and no after-fix runtime artifact is present; add redacted terminal output, logs, or a recording showing approval through Gateway recovery. 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 6 items Current-main gap: Current main resolves a delayed approval directly after the original request has returned; it does not establish the independent tracked root that the PR adds, so the central behavior is not already implemented on main.
Patch owner boundary: The PR wraps the delayed approval callback in independent Gateway root admission and the existing system-agent command lane before resolving the approval, retaining the work through restart scheduling and audit.
Restart routing: For the Gateway surface only, the PR uses the in-process safe restart coordinator rather than the standalone daemon lifecycle command, preserving local-process ownership when remote Gateway configuration is present.
Findings None None.
Security None None.

How this fits together

A system-agent conversation can propose a persistent Gateway action that an operator approves later through the Gateway approval registry. The delayed decision must re-enter tracked Gateway work before it performs the audited restart, so the restart coordinator can defer safely until active work drains.

flowchart LR
  A[Operator approval] --> B[Approval registry]
  B --> C[Independent Gateway work root]
  C --> D[System-agent command lane]
  D --> E[Local restart coordinator]
  E --> F[Audit and visible scheduled result]
  F --> G[Gateway drain and restart]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body explicitly says native Windows Scheduled Task proof and hosted focused validation have not run, and no after-fix runtime artifact is present; add redacted terminal output, logs, or a recording showing approval through Gateway recovery. 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 merge risk (P1) - A Gateway restart is availability-sensitive, and the supplied PR material has no redacted after-fix runtime proof that an approved restart survives the native Windows Scheduled Task path through visible recovery.
  • Resolve merge risk (P1) - The PR is marked maintainer; even a source-coherent patch needs explicit maintainer review of the operational restart behavior before landing.
  • Complete next step (P2) - Maintain the PR for human merge review after the contributor adds the missing real restart proof; the protected maintainer label prevents automated cleanup or repair routing.
Agent review details

Security

None.

PR surface

Source +17, Tests +75, Config +1. Total +93 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 5 31 14 +17
Tests 4 244 169 +75
Docs 0 0 0 0
Config 1 1 0 +1
Generated 0 0 0 0
Other 0 0 0 0
Total 10 276 183 +93

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #115475
Summary: This PR is the candidate repair for the closed report describing agent-initiated Gateway restarts that fail when the host tears down the active request.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Prove the full restart path before merge (recommended)
    Run the native Windows Scheduled Task scenario on this exact head and attach redacted terminal output, logs, or a recording from approval through Gateway recovery.
  2. Accept an unproven operational path
    A maintainer may merge on source confidence alone, accepting that the host-restart behavior has not yet been observed in the affected runtime.

Technical review

Best possible solution:

Obtain a redacted real Windows Scheduled Task transcript or recording that shows approval, the scheduled completion result, Gateway recovery, and the persisted audit outcome, then land only after maintainers accept the restart-availability behavior on the exact head.

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

Yes, from source: the added focused test drives a delayed operator approval after its original Gateway request has finished and observes the command-lane and restart-preflight state. This read-only review did not execute that test or the native Windows scenario.

Is this the best way to solve the issue?

Yes, provisionally: the patch repairs the lifecycle issue at the Gateway admission and local restart-owner boundaries rather than retrying downstream. Its claimed real-world behavior still needs direct runtime proof.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This repairs an operator-visible Gateway restart reliability defect without evidence of data loss, security bypass, or a broad runtime outage.
  • merge-risk: 🚨 availability: The patch changes how a running Gateway schedules its own restart, so an integration failure could leave the Gateway unavailable.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body explicitly says native Windows Scheduled Task proof and hosted focused validation have not run, and no after-fix runtime artifact is present; add redacted terminal output, logs, or a recording showing approval through Gateway recovery. 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

What I checked:

Likely related people:

  • Sasan: Current-main blame attributes the delayed approval flow to the system-agent implementation introduced in commit 13a52c5; this is the boundary the PR changes. (role: introduced current approval-flow behavior; confidence: high; commits: 13a52c59cf3b; files: src/gateway/server-methods/system-agent.ts)

Rank-up moves

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

  • Attach redacted native Windows Scheduled Task evidence from approval through Gateway recovery and audit completion.
  • Let the exact-head hosted focused validation finish successfully before maintainer merge review.

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 (4 earlier review cycles)
  • reviewed 2026-08-01T17:18:28.947Z sha 7bd16a3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-01T17:37:14.183Z sha d0b5908 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-01T17:51:20.165Z sha 6555dd1 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-01T23:01:00.694Z sha 6555dd1 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 1, 2026
@steipete
steipete merged commit b886594 into main Aug 2, 2026
130 checks passed
@steipete
steipete deleted the codex/fix-115475-safe-agent-gateway-restart branch August 2, 2026 02:30
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
…117530)

* fix(gateway): safely defer agent-approved Gateway restarts

* fix(gateway): pin approved restarts to the local owner

* test(gateway): keep approved restart lifecycle coverage focused

* fix(gateway): clear Windows probe lint

---------

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

Labels

agents Agent runtime and tooling gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

1 participant