Skip to content

fix(gateway): promote nodes that connect during approval - #177944

Merged
steipete merged 1 commit into
mainfrom
fix/node-exec-advertisement-20261019
Oct 20, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/node-exec-advertisement-20261019

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

A node can finish connecting while its first capability approval is being written. node.pair.approve previously captured the live connection before that wait. When it captured absence, the approval committed but skipped the newly registered connection, leaving an approved, connected node with an empty command list.

Select the live session in the existing committed-approval callback. Keep the exact pairing identity, previous generation, connection, and declared-surface checks before promoting it. This also removes the redundant pre-write pending lookup; no command registration, authorization policy, protocol, timeout, or retry behavior changes.

The regression registers a real NodeRegistry session while the handler enters its real pairing write. Before the fix, approval succeeds but the session still has commands: []; after the fix it must have system.run and the committed pairing generation. Existing token-rotation and replacement refusal assertions remain intact.

Evidence

  • Investigated hourly 39351108236, job 118395379563: the worker e2e observed an approved executor with commands: [].
  • The original native worker e2e passed twice on macOS before the fix. The exact CI timing is therefore not claimed as reproduced. The deterministic approval-owner regression reproduces the same empty-command state on the original source.
  • Compared the direct manifest, catalog, reconciliation and approval owners across 87692eba0956..353c6989892e: unchanged. The pre-write snapshot predates that window; none of the listed suspects is attributed as a deterministic registration regression.
  • Red: pnpm test src/gateway/server-methods/nodes.test.ts --maxWorkers=1 -t 'connects while its first surface approval is pending' fails with expected ["system.run"], received [] before the fix.
  • Green: OPENCLAW_VITEST_RUNTIME=bun pnpm test src/gateway/server-methods/nodes.test.ts test/e2e/qa-lab/runtime/gateway-node-exec-routing.e2e.test.ts --maxWorkers=1 passes 16 tests. This includes the original native command-routing/effect proof and existing token-rotation/replacement refusals.
  • E2E runtime build, focused typecheck, type-aware lint, formatting, and git diff --check pass.
  • Production diff: +4/-6 lines; test diff: +42 lines. The temporary e2e diagnostic change was removed; its assertions and waits are unchanged.
  • Independent P2 autoreview: scoped-clean.

@clawsweeper

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

@steipete
steipete marked this pull request as ready for review October 20, 2026 02:00
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T02:03:36.711196Z 9aaf5e4 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

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: 9aaf5e425c2486bbc1d0c8e74291303b82db5a96
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/server-methods/nodes.pairing.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 clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 20, 2026
@clawsweeper

clawsweeper Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR selects the connected node when capability approval commits so connections established during approval receive their approved commands.

Example: Node node-connect-during-approval connects with system.run declared while its first capability approval is pending.

  • Before: Approval succeeds, but the connected session retains commands: [].
  • After: The matching session receives commands: ["system.run"] and the committed pairing generation.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused repair and owner regression are convincing source evidence; final-effect authority validation remains incomplete.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A successfully approved, connected node can remain unable to run its approved commands.
Reason: The maintainer-authored change restores the existing approval contract without adding options, protocols or another state owner.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open: this maintainer-authored PR addresses a current-main approval race with a focused change; no concrete patch defect was found.

Priority: P2
Reviewed head: 9aaf5e425c2486bbc1d0c8e74291303b82db5a96

Before merge

  • Add real behavior proof - Authority-chain proof required: the reported regression exercises real pairing and registry owners, and native E2E exercises command effects, but neither establishes command dispatch for the late-selected session followed by rejection of its revoked or reassigned authority before I/O; provide sanitized terminal output or logs covering that boundary and redact credentials, IPs and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Resolve security review attention item - No concrete bypass was found, but commit-time authority promotion needs final-effect validation.
  • Resolve merge risk - Commit-time selection can promote a connection absent at approval entry; rejection of a subsequently revoked or re-paired session at command I/O remains unproven.

Findings

None.

Tests

  • Missing end-to-end proof: Supplied evidence does not demonstrate late-connection promotion followed by allowed command execution and rejection before command I/O after token rotation or re-pairing.
Agent review details

How this fits together

The Gateway pairing handler consumes operator approval and committed pairing facts, updates the authenticated NodeRegistry session, and publishes approval notifications before subsequent node command dispatch.

flowchart TD
  A[Operator approval] --> B[Pairing mutation owner]
  B --> C[Committed approval callback]
  D[Connecting node] --> E[NodeRegistry]
  C --> E
  E --> F[Current authority checks]
  F --> G[Node command transport]
Loading

Technical review

Best possible solution:

Retain the existing committed-approval owner and exact registry checks, with allowed and revoked-session command effects verified through that path.

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

Current-main source exposes the stale-absence path, and the added regression deterministically registers a connection after the old snapshot point; its reported red/green result was inspected but not rerun.

Is this the best way to solve the issue?

This is the smallest complete source fix: resolve the session in the existing committed callback, remove the redundant lookup, and retain the registry's authority and capability checks.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 07e3328ed3f7.

Merge-risk options

Maintainer options:

  1. Verify dispatch after commit-time promotion (recommended)
    Show the newly connected session executing an approved command, then show token rotation or re-pairing preventing command transport or execution through the same production owners.

Provenance checked

  • Live-session selection and committed approval publication keeps the original intent (94f180d: The earlier repair moved live-surface publication into the committed callback so background readers could not mistake reapproval for device replacement; this PR preserves that ordering. The pre-write snapshot predates that repair and was carried through the behavior-neutral split.)

Testing

Proof path: in-process harness.

Security

Needs attention: No concrete bypass was found, but commit-time authority promotion needs final-effect validation.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 94f180d adds src/gateway/server-methods/nodes.pairing.ts:170 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 94f180d9ab19; files: src/gateway/server-methods/nodes.pairing.ts)

PR surface

Source -2, Tests +42. Total +40 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 4 6 -2
Tests 1 42 0 +42
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 46 6 +40

Labels

Label changes:

  • add P2: A timing-dependent capability approval can leave a connected node unable to execute approved commands.
  • add merge-risk: 🚨 security-boundary: The change selects the session receiving persistent pairing-generation authority later in the lifecycle, requiring final-effect validation against retired authority.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P2: A timing-dependent capability approval can leave a connected node unable to execute approved commands.
  • merge-risk: 🚨 security-boundary: The change selects the session receiving persistent pairing-generation authority later in the lifecycle, requiring final-effect validation against retired authority.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

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

  • Add final-effect proof that the late-promoted session can execute system.run and that token rotation or re-pairing invalidates that authority before command I/O.

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 execution lanes are retired.

Reviewed October 19, 2026, 10:16 PM ET / October 20, 2026, 02:16 UTC.

@steipete
steipete merged commit a8bb50f into main Oct 20, 2026
216 of 219 checks passed
@steipete
steipete deleted the fix/node-exec-advertisement-20261019 branch October 20, 2026 02:36
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. security-sensitive-changed size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant