Skip to content

fix: match machine join commands to the Gateway release - #168680

Merged
obviyus merged 2 commits into
mainfrom
fix/join-gateway-version
Oct 11, 2026
Merged

obviyus merged 2 commits into
mainfrom
fix/join-gateway-version

Conversation

@obviyus

@obviyus obviyus commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes machine enrollment silently running an old cached npm release when the Gateway is newer.

User Impact

devices join-code and the Control UI now suggest the Gateway's published npm version, not the invoking CLI's version. Both also show the short alternative for an existing OpenClaw installation. The default remains a background service with explicit session-host consent; command-only services remain available.

Source checkouts and unpublished builds prefer a resolvable matching channel tag. If npm cannot confirm a target, the command stays unpinned and a one-line note asks for a matching Gateway build. JSON keeps joinUrl and command, adding serviceCommand, installedCommand, and optional versionNote.

Why This Change Was Made

#168623 / 8f91e4bb65f established the one-paste service/session-host default but deliberately left npm unpinned. npm can reuse an old cached package. The Gateway now owns version selection and command formatting in the same RPC that mints the URL; CLI and UI consume its commands instead of independently rebuilding them.

The existing update owners supply install identity and channel policy. Joining does not run a full update/dependency inspection. This composes with the durable service installation work in #168644; it does not change node execution, service lifecycle, or upgrade commands.

Evidence

  • Regressions on 8f91e4bb65f: eight Gateway/CLI-boundary cases and three CLI text/JSON cases fail for missing authoritative commands; the real browser regression reaches the setup RPC and fails waiting for the pinned command.
  • Focused Gateway and CLI suites: 84 tests passed after the final lightweight-install-discovery refinement. The Gateway suite took 173.85s and CLI suite 43.42s on the loaded local host (including transform/setup); assertions took about 1.7s and 15.5s respectively.
  • All five browser flows passed. After the final template simplification, the real bundled UI mint/refresh flow passed again (46.41s, including setup), covering the pinned command, installed alternative, and development fallback note. The Control UI Lit ratchet also passed.
  • Real isolated Gateway text/JSON: baseline printed unpinned npm commands; candidate printed [email protected], matching the Gateway release, plus the existing-installation alternative. Both exited successfully. This proof exercises command generation, not installation on a second machine; durable service installation is covered separately by fix(node): keep npx-installed services outside the npm cache #168644.
  • The built CLI bootstrap guard passed. The local changed gate stopped at an unrelated existing mock-export violation in src/model-picker/apply-session-model-selection-placement.test.ts; the rebase picked up its existing mock-isolation explanation. Hosted exact-head CI is the final check.
  • Inherited CI failure: the final-head job failed plugin-sdk-surface-report.test.ts on SDK export-budget drift: 3672 > 3656 exports, 2133 > 2122 callables, 158 > 154 deprecated exports, and two deprecated-entrypoint budgets. Clean origin/main at dd4b258a3cfa6fdef41535e5518fe260f5665a9c reproduces the same budget failures (2 failed, 3 passed, 1 Linux-only test skipped on macOS; 18.84s). The aggregate CI gate reports this failure; fail-fast cancelled the other unfinished lanes. This PR changes no plugin SDK surface or budget.

Production: +105/-17 lines; tests: +188/-27; documentation: +23/-2. The added production logic replaces independent CLI/UI formatting with one Gateway decision owner.

Real isolated Gateway terminal output (redacted)

Gateway: OpenClaw 2026.9.9. Both text and JSON commands exited 0. Only the ephemeral loopback port and single-use code are redacted.

Before (devices join-code):

npx -y openclaw connect http://127.0.0.1:<port>/j/<code> --service --session-host

After (devices join-code):

npx -y [email protected] connect http://127.0.0.1:<port>/j/<code> --service --session-host
Already have OpenClaw installed? Run: openclaw connect http://127.0.0.1:<port>/j/<code> --service --session-host

After (devices join-code --json):

{
  "joinUrl": "http://127.0.0.1:<port>/j/<code>",
  "command": "npx -y [email protected] connect http://127.0.0.1:<port>/j/<code> --service --session-host",
  "serviceCommand": "npx -y [email protected] connect http://127.0.0.1:<port>/j/<code> --service",
  "installedCommand": "openclaw connect http://127.0.0.1:<port>/j/<code> --service --session-host"
}

Connect a machine

Before After
Before: unpinned npm join command After: Gateway-selected npm version and installed alternative

The screenshots use synthetic Gateway data and the actual bundled Control UI.

Bounded cost

Only explicit join-code creation performs registry work: at most two npm metadata GETs, each with a one-second deadline including the response body. No background polling, model calls, package-manager subprocesses, retries, or new caches. Existing prepared install identity is reused; if absent, the update owner's lightweight local classifier runs without dependency inspection, with its Git probe bounded to one second. No registry lookup is performed by CLI or UI.

Compatibility and Risk

The RPC fields are additive. A new CLI needs a Gateway that returns the authoritative commands and explains how to update if it connects to an older Gateway. Published npm releases use exact versions; development/unpublished/offline results are explicitly marked as requiring a matching build. Shell quoting remains owned by the existing CLI argument helper.

Two-way door: reverting changes future suggestions and added response fields only. It does not change existing pairings, service state, or session-host consent. The blast radius is enrollment instructions and their presentation.

@clawsweeper

clawsweeper Bot commented Oct 10, 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.

@obviyus

obviyus commented Oct 10, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime cli CLI command changes size: M labels Oct 10, 2026
@obviyus
obviyus marked this pull request as ready for review October 10, 2026 22:43
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 309bf088390acecf28cbcccc80e09f60275ea132
  • Maintainer: @obviyus
  • Repository role: maintain

These security sensitive changes were made:

  • src/gateway/server-methods/device-pair-setup.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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. labels Oct 10, 2026
@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The Gateway selects and formats version-matched machine join commands for the CLI and Control UI.

Example: Create a machine join command from a Gateway running published OpenClaw 2026.9.9.

  • Before: The command uses unpinned npx -y openclaw, which can select a different release.
  • After: The command uses npx -y [email protected] and also displays an existing-installation alternative.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) The focused repair has shipped-entry-point command proof, inspected visual evidence, a justified owner boundary, and no actionable findings; pending CI does not change the evidence rating.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The real isolated Gateway and CLI text/JSON output exercise version-selected command generation, while inspected bundled-browser screenshots prove presentation of the pinned and installed commands; second-machine installation belongs to separate work.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A generated machine join command can run a package release that differs from the Gateway and cannot support its enrollment workflow.
Reason: The maintainer-directed change addresses a concrete release mismatch without adding configuration, changing hosting consent, or creating another installation owner.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it fixes a concrete enrollment-version problem that remains on current main, and no introduced correctness defect was found. Current-head CI is still pending.

Priority: P2
Reviewed head: 309bf088390acecf28cbcccc80e09f60275ea132

Before merge

None.

Findings

None.

Agent review details

How this fits together

The administrator-only pairing RPC receives join-code requests, consults existing installation and npm metadata owners, and returns a single-use URL with commands consumed by the CLI and browser.

flowchart LR
  A[Administrator] --> B[CLI or Control UI]
  B --> C[Gateway pairing RPC]
  C --> D[Installation identity]
  C --> E[Npm metadata]
  C --> F[Pairing worker]
  C --> G[Join commands]
  G --> B
Loading

Technical review

Best possible solution:

Land the Gateway-owned command selection while preserving explicit hosting consent and the documented matching-build fallback.

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

Current-main source still produces an unpinned command, consistent with the supplied baseline terminal output; this read-only review ran no target code.

Is this the best way to solve the issue?

Centralizing version selection in the Gateway is appropriate because it knows the enrolling release and prevents CLI and browser formatting from drifting.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 76bfd5a284be.

Provenance checked

  • Service/session-host command defaults and unpinned npm selection changes intended behavior with a stated reason (8f91e4b: The previous change established explicit background-service and session-host consent while deliberately leaving the npm package unpinned.)
  • Pairing RPC ownership and worker registration keeps the original intent (ade3456: One-paste onboarding reused canonical setup credentials and single-use join URLs; later worker refactoring retained live authority at registration.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +88, Tests +161, Docs +21. Total +270 across 11 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 105 17 +88
Tests 3 188 27 +161
Docs 2 23 2 +21
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 316 46 +270

Review metrics

Metric Value Why it matters
Production versus tests Production +105/-17; tests +188/-27 Production growth adds bounded version selection under one existing owner; tests cover selection, CLI output, and browser presentation as distinct boundaries.
Wire contract 4 optional response fields; 0 new configuration options The RPC adds command, serviceCommand, installedCommand, and versionNote without changing persisted formats.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: Version-mismatched enrollment instructions affect a bounded machine-joining workflow without changing existing enrolled devices.
  • merge-risk: 🚨 compatibility: The new CLI intentionally refuses older Gateways that omit authoritative commands; the maintainer explicitly accepts this update requirement.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • 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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-10T22:47:56.685Z sha 98d57afc490557e36400593c55a88259b17b7e5b :: needs maintainer review before merge. :: none
  • reviewed 2026-10-10T23:57:10.704Z sha 662c65fe40abd942397e36b9f5084fbae1e16b44 :: needs maintainer review before merge. :: none

Reviewed October 10, 2026, 8:19 PM ET / October 11, 2026, 00:19 UTC (Revision 3).

@obviyus

obviyus commented Oct 10, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus

obviyus commented Oct 10, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. labels Oct 10, 2026
@obviyus
obviyus force-pushed the fix/join-gateway-version branch from 662c65f to 309bf08 Compare October 11, 2026 00:12
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 11, 2026
@obviyus
obviyus merged commit 9a165c4 into main Oct 11, 2026
136 checks passed
@obviyus
obviyus deleted the fix/join-gateway-version branch October 11, 2026 00:28
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 11, 2026
)

## What Problem This Solves

Fixes machine enrollment silently running an old cached npm release when the Gateway is newer.

## User Impact

`devices join-code` and the Control UI now suggest the Gateway's published npm version, not the invoking CLI's version. Both also show the short alternative for an existing OpenClaw installation. The default remains a background service with explicit session-host consent; command-only services remain available.

Source checkouts and unpublished builds prefer a resolvable matching channel tag. If npm cannot confirm a target, the command stays unpinned and a one-line note asks for a matching Gateway build. JSON keeps `joinUrl` and `command`, adding `serviceCommand`, `installedCommand`, and optional `versionNote`.

## Why This Change Was Made

[openclaw#168623](openclaw#168623) / `13d3847f108` established the one-paste service/session-host default but deliberately left npm unpinned. npm can reuse an old cached package. The Gateway now owns version selection and command formatting in the same RPC that mints the URL; CLI and UI consume its commands instead of independently rebuilding them.

The existing update owners supply install identity and channel policy. Joining does not run a full update/dependency inspection. This composes with the durable service installation work in [openclaw#168644](openclaw#168644); it does not change node execution, service lifecycle, or upgrade commands.

No overlap with Pash/Sarah changes.

## Evidence

- Regressions on `13d3847f108`: eight Gateway/CLI-boundary cases and three CLI text/JSON cases fail for missing authoritative commands; the real browser regression reaches the setup RPC and fails waiting for the pinned command.
- Focused Gateway and CLI suites: 84 tests passed after the final lightweight-install-discovery refinement. The Gateway suite took 173.85s and CLI suite 43.42s on the loaded local host (including transform/setup); assertions took about 1.7s and 15.5s respectively.
- All five browser flows passed. After the final template simplification, the real bundled UI mint/refresh flow passed again (46.41s, including setup), covering the pinned command, installed alternative, and development fallback note. The Control UI Lit ratchet also passed.
- Real isolated Gateway text/JSON: baseline printed unpinned npm commands; candidate printed `[email protected]`, matching the Gateway release, plus the existing-installation alternative. Both exited successfully. This proof exercises command generation, not installation on a second machine; durable service installation is covered separately by openclaw#168644.
- The built CLI bootstrap guard passed. The local changed gate stopped at an unrelated existing mock-export violation in `src/model-picker/apply-session-model-selection-placement.test.ts`; the rebase picked up its existing `mock-isolation` explanation. Hosted exact-head CI is the final check.
- Inherited CI failure: [the final-head job](https://github.com/openclaw/openclaw/actions/runs/38096158809/job/114342554800) failed `plugin-sdk-surface-report.test.ts` on SDK export-budget drift: 3672 > 3656 exports, 2133 > 2122 callables, 158 > 154 deprecated exports, and two deprecated-entrypoint budgets. Clean `origin/main` at `39900fc906e66ff0e4bf61ef11ad531883ea979f` reproduces the same budget failures (2 failed, 3 passed, 1 Linux-only test skipped on macOS; 18.84s). The aggregate CI gate reports this failure; fail-fast cancelled the other unfinished lanes. This PR changes no plugin SDK surface or budget.

Production: +105/-17 lines; tests: +188/-27; documentation: +23/-2. The added production logic replaces independent CLI/UI formatting with one Gateway decision owner.

<details>
<summary>Real isolated Gateway terminal output (redacted)</summary>

Gateway: `OpenClaw 2026.9.9`. Both text and JSON commands exited 0. Only the ephemeral loopback port and single-use code are redacted.

Before (`devices join-code`):

```text
npx -y openclaw connect http://127.0.0.1:<port>/j/<code> --service --session-host
```

After (`devices join-code`):

```text
npx -y [email protected] connect http://127.0.0.1:<port>/j/<code> --service --session-host
Already have OpenClaw installed? Run: openclaw connect http://127.0.0.1:<port>/j/<code> --service --session-host
```

After (`devices join-code --json`):

```json
{
  "joinUrl": "http://127.0.0.1:<port>/j/<code>",
  "command": "npx -y [email protected] connect http://127.0.0.1:<port>/j/<code> --service --session-host",
  "serviceCommand": "npx -y [email protected] connect http://127.0.0.1:<port>/j/<code> --service",
  "installedCommand": "openclaw connect http://127.0.0.1:<port>/j/<code> --service --session-host"
}
```

</details>

### Connect a machine

| Before | After |
| --- | --- |
| ![Before: unpinned npm join command](https://github.com/user-attachments/assets/f9af80a8-039d-4b95-8102-1dd943a89672) | ![After: Gateway-selected npm version and installed alternative](https://github.com/user-attachments/assets/9b627f4b-5bf8-49a9-ae0b-3e222aa9652f) |

The screenshots use synthetic Gateway data and the actual bundled Control UI.

## Bounded cost

Only explicit join-code creation performs registry work: at most two npm metadata GETs, each with a one-second deadline including the response body. No background polling, model calls, package-manager subprocesses, retries, or new caches. Existing prepared install identity is reused; if absent, the update owner's lightweight local classifier runs without dependency inspection, with its Git probe bounded to one second. No registry lookup is performed by CLI or UI.

## Compatibility and Risk

The RPC fields are additive. A new CLI needs a Gateway that returns the authoritative commands and explains how to update if it connects to an older Gateway. Published npm releases use exact versions; development/unpublished/offline results are explicitly marked as requiring a matching build. Shell quoting remains owned by the existing CLI argument helper.

Two-way door: reverting changes future suggestions and added response fields only. It does not change existing pairings, service state, or session-host consent. The blast radius is enrollment instructions and their presentation.

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

Labels

app: web-ui App: web-ui cli CLI command changes docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. security-sensitive-changed size: M 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