Skip to content

fix(setup): verify gateway listener service ownership - #1382

Merged
shanselman merged 7 commits into
mainfrom
pr/1349
Sep 9, 2026
Merged

shanselman merged 7 commits into
mainfrom
pr/1349

Conversation

@shanselman

@shanselman shanselman commented Sep 9, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Current-main replacement for #1349 (fix(setup): recognize the gateway service on its own port after install), preserving Peter Steinberger's diagnosis and PID-based ownership design without carrying the stale September 7 branch history.

The installer may start openclaw-gateway.service before StartGatewayStep. The real listener process is commonly named node, so process-name matching falsely reports that setup's own service is a foreign port conflict.

This replacement:

  • queries the exact configured listener with ss -H -ltnp 'sport = :<port>';
  • requires a positive systemd user-service MainPID;
  • accepts the occupied port only when every parsed listener PID exactly matches that MainPID;
  • fails closed for command failure, invalid service state, missing ownership, or mixed/foreign listeners;
  • surfaces distinct diagnostics and captured command details for those failure classes;
  • includes process names and foreign PIDs in genuine conflict messages;
  • exercises the production InstallGatewayServiceStep followed by StartGatewayStep in the real WSL E2E path.

Required proof pools

  • windows-wsl-gateway-e2e: required for the real install-service, listener-ownership, health, pairing, and setup path.
  • windows-wsl-mxc: requested setup/connect closeout. Local and prior Azure attempts are blocked because no available host combines working WSL setup with the required unaugmented MXC BaseContainer tier.

Validation

Current head: e5684501.

  • focused StartGateway and PreflightPort tests: 20 passed
  • .\build.ps1: passed
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore: 3,944 passed, 32 environment-gated skips
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore: 2,865 passed
  • dotnet test .\tests\OpenClaw.SetupEngine.Tests\OpenClaw.SetupEngine.Tests.csproj --no-restore: 1,134 passed
  • dotnet build .\tests\OpenClaw.E2ETests\OpenClaw.E2ETests.csproj -c Debug -r win-x64 --no-restore: passed, 0 warnings/errors
  • git diff --check: passed
  • final autoreview against current origin/main: clean, no actionable findings, confidence 0.87

Two unrelated baseline timing tests each failed once during repeated local full-suite runs: McpHttpServerTests.Dispose_DuringInFlightHandler_DoesNotSurfaceObjectDisposedException and OpenClawChatDataProviderTests.QueuedSend_LifecycleStartBeforeAck_PromotesByIdempotencyKey. Each passed five consecutive focused reruns; the final complete closeout above is green.

The first hosted run also hit unrelated tray integration failures in CanvasNavigate_ReturnsNavigated and SystemRun_Where_ReturnsExpectedOutput. Neither surface is changed by this five-file setup PR.

Real behavior proof

Prior exact-head #1349 proof on Gateway 2026.6.34 passed both production-path behaviors:

  • service-owned listeners were accepted only when every listener PID matched MainPID;
  • a foreign WSL Node listener was rejected before openclaw gateway start.

This replacement rebases the behavior onto main after #1312 (improve(setup): install latest stable Gateway from npm) and #1381 (fix(setup): complete npm latest Gateway landing). Its E2E reruns openclaw gateway install --force through InstallGatewayServiceStep, waits only until a listener exists, then invokes StartGatewayStep, which remains the code that proves ownership. The first hosted run exposed and fixed an E2E timing gap where the step ran before the installed service had opened its port.

Local .\scripts\validate-mxc-e2e.ps1 remains blocked before distro creation because WSL cannot attach its temporary swap.vhdx (E_ACCESSDENIED). The ownership behavior itself is covered by the current production-path unit tests and must pass the hosted setup/connect shard before merge.

Adversarial review

  • Codex review: no CRITICAL, HIGH, MEDIUM, or LOW correctness/security findings.
  • Opus review: no fail-open path; accepted improvements for distinct diagnostics, service-query/dual-stack/invalid-PID coverage, and the real install→start E2E sequence.
  • Rejected as out of scope: replacing exact MainPID equality with speculative future cgroup topology support, and changing the separate runtime provenance service in this setup-only PR.

Security impact

No credential authority changes. The check runs before bootstrap minting and pairing. Unknown, unreadable, or conflicting listeners remain blocked; process names are diagnostics only and never authorize ownership.

Supersedes #1349 (fix(setup): recognize the gateway service on its own port after install).

steipete and others added 6 commits September 9, 2026 14:51
Compare listener PIDs with the managed systemd gateway MainPID so a gateway reported as node is accepted without exempting foreign Node.js listeners. Include available owner names in conflict diagnostics and cover install/start sequences. Related context: #547.
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 4f97b3a3-def7-4f33-b7d5-ece171b4fd0b
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 4f97b3a3-def7-4f33-b7d5-ece171b4fd0b
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 4f97b3a3-def7-4f33-b7d5-ece171b4fd0b
Dispose the setup logger before reading its JSONL proof, matching the service-owned E2E path and avoiding Windows file sharing failures.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 4f97b3a3-def7-4f33-b7d5-ece171b4fd0b
Keep listener ownership fail closed while separating inspection, service, unknown-owner, and foreign-listener failures, and exercise the real install-service to start-gateway sequence.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 4f97b3a3-def7-4f33-b7d5-ece171b4fd0b
@clawsweeper

clawsweeper Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

🦞👀
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.

@shanselman shanselman added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. labels Sep 9, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 9, 2026
@clawsweeper

clawsweeper Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Codex review: blocked before merge. Reviewed September 9, 2026, 6:52 PM ET / 22:52 UTC (Revision 2).

ClawSweeper review

What this changes

The PR checks whether occupied Gateway ports belong to the installed WSL service, improves conflict diagnostics, and adds unit and real-WSL regression coverage.

Merge readiness

⛔ Blocked before merge - 3 items remain

This remains a useful fix: main and the latest release retain the faulty process-name check. The previous E2E timing finding is resolved, and no new actionable defect was found. Required current-head runtime validation remains incomplete.

Priority: P0
Reviewed head: e5684501ce9ea0726827a995318fe43159388f91

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused implementation and repaired regression test are sound, while current-head runtime evidence remains incomplete.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Evidence reviewed 9 items Current main still contains the defect: Main accepts occupied listeners only when ss output contains 'openclaw'; a service reported as 'node' is rejected before startup. The replacement therefore remains necessary.
Latest release also retains name matching: The supplied latest release, v2026.7.1-4, contains the same process-name heuristic. Neither this release nor inspected main implements the proposed ownership check.
Previous finding resolved: The pinned head adds a bounded listener-readiness wait after service installation and before invoking production StartGatewayStep. This addresses the earlier occupied-port assertion race without duplicating ownership validation in the test. Immediate startup remains exercised by the existing full setup fixture.
Findings None None.
Security None None.

How this fits together

Windows setup installs the Gateway inside a managed WSL distribution, then checks its listener before starting health checks and pairing. The listener check distinguishes setup's own service from conflicting processes.

flowchart TD
  A[Configured Gateway port] --> B[Windows port preflight]
  B --> C[Install WSL Gateway service]
  C --> D[Inspect listener PIDs]
  E[Systemd service MainPID] --> F{Every owner matches?}
  D --> F
  F -->|Yes or port free| G[Start and check health]
  F -->|Foreign or unknown| H[Stop setup with diagnostics]
Loading

Before merge

  • Resolve merge risk (P1) - Failed or unreadable listener inspection now stops setup where the former shell pipeline could silently proceed; current-head fresh setup and already-installed-service proof must establish compatibility with the selected Gateway version.
  • Resolve merge risk (P1) - Repository-required non-skipping MXC validation remains blocked by the reported lack of a host combining working WSL setup and the required containment tier.
  • Complete next step (P2) - Provide current-head setup/connect runtime results and complete the repository-required non-skipping MXC validation before merge.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Net code growth production +54 lines; tests +307 lines; docs +8 lines Production growth implements explicit ownership diagnostics, with most added code devoted to regression coverage.

Root-cause cluster

Relationship: canonical
Canonical: #1382
Summary: This is the active replacement for the closed, unmerged listener-ownership proposals; their closure does not establish implementation on main.

Members:

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

Merge-risk options

Maintainer options:

  1. Complete managed-startup compatibility proof (recommended)
    Retain the intentional fail-closed behavior and obtain current-head fresh setup, installed-service acceptance, foreign-listener rejection, and required non-skipping MXC results.

Technical review

Best possible solution:

Retain exact service ownership checks and independent pairing authorization, with fresh-setup and already-installed-service compatibility demonstrated before landing.

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

Yes, source establishes the trigger: install starts the service, ss reports its listener as node, and main rejects it for lacking an openclaw name. Historical real-WSL evidence supports this path; this review did not execute it.

Is this the best way to solve the issue?

Yes. Comparing listener PIDs with the installed service is a focused repair that preserves conflict rejection; the existing runtime provenance service remains responsible for credential authorization.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 61ccb91e49b8.

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
  • remove merge-risk: 🚨 automation: Current PR review merge-risk labels are merge-risk: 🚨 compatibility.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P0: The existing heuristic can reject the Gateway installed by first-run setup and trigger failure or rollback, leaving users needing technical intervention.
  • merge-risk: 🚨 compatibility: Strict inspection failures now block setup, and compatibility evidence for the current head and current Gateway selection remains outstanding.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.

Evidence

What I checked:

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • bkudiess: 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.

  • Attach current-head production-path setup/connect results and complete non-skipping MXC validation on a suitable host; redact credentials, private endpoints, and other private data. Updating the PR body should trigger review, or a maintainer can request @clawsweeper re-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 (1 earlier review cycle)
  • reviewed 2026-09-09T22:28:52.755Z sha d9dc78c :: blocked before merge. :: [P2] Wait for listener readiness before asserting the occupied-port branch

Poll only for listener availability after service installation so StartGatewayStep remains the code that proves listener ownership.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 4f97b3a3-def7-4f33-b7d5-ece171b4fd0b
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 9, 2026
@shanselman
shanselman merged commit 1977368 into main Sep 9, 2026
40 of 42 checks passed
@shanselman
shanselman deleted the pr/1349 branch September 9, 2026 23:13
@shanselman shanselman removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants