Skip to content

fix(gateway): preserve node invoke dispatch provenance - #117139

Merged
omarshahine merged 5 commits into
fix/exec-node-invoke-deadlinefrom
omarshahine-gateway-invoke-provenance
Aug 1, 2026
Merged

omarshahine merged 5 commits into
fix/exec-node-invoke-deadlinefrom
omarshahine-gateway-invoke-provenance

Conversation

@omarshahine

@omarshahine omarshahine commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #116591 at 809a73433fbd7acf4da437e69f1c6aeb9f04a9a0.

Additional instructions

MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.

What Problem This Solves

Node invocation timeouts and disconnects did not preserve enough boundary provenance to distinguish a proven pre-dispatch failure from an ambiguous outcome after a command may already have reached the node. Callers therefore could not determine whether retrying was safe or could duplicate a command.

Why This Change Was Made

This restacked Layer 2 records whether Gateway request bytes crossed socket.send, marks node command dispatch only after the node transport send succeeds, and settles node invocation exactly once across result, timer, abort, idle timeout, disconnect, and late duplicate races.

Hard deadline precedence is preserved when disconnect or abort arrives after the deadline but before the timer callback. Wake-path NOT_CONNECTED remains proven pre-dispatch, while plugin-policy results only mark dispatch through the authoritative post-send onDispatchReady boundary.

Current ownership is preserved: GatewayProtocolRequestError and GatewayProtocolRequestOptions remain canonical in packages/gateway-client/src/protocol-request.ts. This layer ports only request-sent timeout metadata and exact-once timeout handling into the current structure.

User Impact

Gateway consumers can distinguish failures that are safe to retry from timeouts or disconnects where the node command may already have run. Results immediately before the deadline remain accepted; results at or after the deadline consistently time out; late and duplicate results cannot change the recorded terminal outcome.

Evidence

Restack identity:

  • Previous Layer 2 head: a51db74d4f0c134176e9863485944f03e5d4fa90
  • New parent: 809a73433fbd7acf4da437e69f1c6aeb9f04a9a0
  • Rewritten Layer 2 source head: bb83607cc7f7c10fe78e870a8bf740b0d29ce9c5
  • Exact head with required generated output: 8fbbb9cbe13d08894794712455a45e1aca553c9c
  • Changed surface: 15 Gateway client/node registry/invoke files plus the generated browser runtime. No WORKLOG.md or pending-request.ts ownership move.

Focused behavior proof:

node scripts/run-vitest.mjs <gateway-client timeout/watchdog, node registry,
node invoke stream/wake/helpers/abort, exec approvals, and plugin-policy suites>

Result: 239 tests passed. A deterministic deadline/abort/disconnect precedence filter passed 9 tests.

Static and package proof:

  • Production and test tsgo passed.
  • Targeted Oxfmt and Oxlint passed.
  • Dependency deadcode, Plugin SDK API/export/surface, and diff checks passed.
  • Layer 2's Gateway client changes deterministically regenerate extensions/browser/chrome-extension/modules/copilot-runtime.js from SHA-256 f6ff276e6d0eabbdcca7aee7efba585a48644a0b923cf0d172dd54159e73975f to 69c798555bcec32de36904321e74f2c33ab592789e4faa19706371bae3dd6e83. The required generated output is committed at the exact head, and the repository's bundled plugin asset check reports that generated assets match the committed bytes.

Remote proof runs:

  • run_47f374209567: core and core-test tsgo passed.
  • run_53696cf5ff1c: full production/test tsgo and dependency deadcode passed.
  • run_d4510ba3bb64: Plugin SDK API/export/surface and deadcode gates passed.
  • run_ff19fda253cf: exact-head isolated paired-node proof passed.

The paired-node proof used the bundled Canvas plugin through canvas.snapshot over real isolated Gateway and paired-node WebSockets. It covered:

  • successful plugin-policy dispatch;
  • pre-dispatch failure with nodeCommandDispatched: false;
  • post-dispatch timeout and disconnect with nodeCommandDispatched: true;
  • hard deadline precedence;
  • exact-once settlement with late duplicate absorption; and
  • GatewayClientRequestTimeoutError metadata for method, timeoutMs, and requestSent: true.

Final structured Codex autoreview used gpt-5.6-sol with high reasoning and reported no accepted or actionable findings for the source restack (confidence 0.94). A fresh local review of the generated-only addition was also clean (confidence 0.99).

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime 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. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 3:36 PM ET / 19:36 UTC.

ClawSweeper review

What this changes

The PR records whether a Gateway request crossed its socket send and whether a paired-node command was accepted for transport, then returns that provenance with timeout and unavailable outcomes.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open. Current main does not contain the PR’s request-send timeout metadata or its corrected post-send node-dispatch provenance, so the central retry-safety behavior remains necessary. This is an open stack layer on #116591 and carries the protected maintainer label; final Gateway-owner review should follow the parent landing and rebase.

Likely related people: @steipete is the strongest routing candidate (high confidence) because current node-invocation deadline and dispatch-boundary code dates to commit 060a541c92761d7c1eaa5646a27851071d904ac3; Vincent Koc is a secondary recent Gateway-client contributor (medium confidence).

Priority: P1
Reviewed head: 8fbbb9cbe13d08894794712455a45e1aca553c9c
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The implementation and focused evidence are strong; the remaining blocker is final owner confirmation of the stacked Gateway error contract.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body supplies exact-head isolated Gateway and paired-node WebSocket proof covering pre-dispatch failures, post-dispatch timeout/disconnect, deadline precedence, and duplicate-result absorption.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body supplies exact-head isolated Gateway and paired-node WebSocket proof covering pre-dispatch failures, post-dispatch timeout/disconnect, deadline precedence, and duplicate-result absorption.
Evidence reviewed 5 items Current-main gap: Current main still constructs a generic timeout error at this client boundary; it has no requestSent timeout metadata, so the PR’s client-visible provenance has not already landed.
PR transport boundary: The PR records requestSent only after socket.send(...) returns and supplies it to the timeout-error factory, which correctly distinguishes a send failure from a timed-out request that crossed the client transport boundary.
PR node-dispatch boundary: The node registry calls onDispatchReady only after sendEventToSession succeeds, providing the authoritative post-send dispatch fact consumed by the server-method and plugin-policy projections.
Findings None None.
Security None None.

How this fits together

Gateway clients send protocol requests over a socket, while Gateway server methods dispatch command frames through the node registry to paired nodes. The resulting timeout or disconnect outcome informs exec and plugin-policy callers whether retrying could duplicate a command.

flowchart LR
  A[Gateway caller] --> B[Protocol socket request]
  B --> C[Gateway server method]
  C --> D[Node registry]
  D --> E[Paired node transport]
  E --> F[Result, timeout, or disconnect]
  F --> G[Retry-safety response]
Loading

Decision needed

Question Recommendation
After the parent deadline change lands, should OpenClaw standardize requestSent and nodeCommandDispatched as the retry-safety provenance exposed by Gateway timeout and unavailable outcomes? Confirm and merge the rebased contract: Keep the additive provenance fields and merge the stack after a final rebase and Gateway-owner review.

Why: The implementation is mechanically coherent, but the permanent meaning of consumer-visible retry metadata is a Gateway contract choice that automated review cannot safely make.

Before merge

  • Resolve merge risk (P1) - The branch is stacked on the still-open fix(exec): arm the gateway node invoke deadline from exec host=node #116591, so the final merge result must be rebased and reviewed against the parent after it lands.
  • Resolve merge risk (P2) - Gateway consumers observe new requestSent and nodeCommandDispatched provenance in timeout or unavailable outcomes; the additive error-contract change needs an owner to confirm downstream retry behavior remains intentional.
  • Complete next step (P2) - The protected maintainer label, unmerged stack parent, and consumer-visible Gateway contract require human merge review; there is no discrete repair finding for an automated worker.
Agent review details

Security

None.

PR surface

Source +81, Tests +281. Total +362 across 16 files.

View PR surface stats
Area Files Added Removed Net
Source 9 139 58 +81
Tests 7 304 23 +281
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 16 443 81 +362

Review metrics

Metric Value Why it matters
Gateway retry provenance 2 consumer-visible provenance fields added requestSent and nodeCommandDispatched change how callers distinguish retry-safe failures from potentially executed commands.

Merge-risk options

Maintainer options:

  1. Rebase and confirm the contract (recommended)
    Land the parent, rebase this stack layer, and have a Gateway owner confirm that existing consumers may rely on the new retry-safety metadata.
  2. Accept the additive contract now
    Merge after the parent if maintainers explicitly accept the new error metadata as the durable Gateway consumer contract.

Technical review

Best possible solution:

Land the deadline parent first, rebase this layer onto current main, preserve the registry-owned post-send dispatch fact, and merge only after a Gateway owner confirms the final timeout and unavailable response contract.

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

Yes, from source. Current main lacks the post-send provenance propagation, while the PR’s isolated paired-node proof describes pre-dispatch and post-dispatch timeout/disconnect outcomes; this read-only review did not execute the scenario locally.

Is this the best way to solve the issue?

Yes. Recording the fact at the socket-send and node-registry send boundaries is the narrowest maintainable solution because those owners, rather than downstream callers, know whether dispatch was proven.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7c9794b5c65c.

Labels

Label justifications:

  • P1: Incorrect provenance can cause an automatic retry of a paired-node command that may already have executed.
  • merge-risk: 🚨 compatibility: The PR changes Gateway timeout and unavailable outcome details that downstream clients can use for retry decisions.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body supplies exact-head isolated Gateway and paired-node WebSocket proof covering pre-dispatch failures, post-dispatch timeout/disconnect, deadline precedence, and duplicate-result absorption.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies exact-head isolated Gateway and paired-node WebSocket proof covering pre-dispatch failures, post-dispatch timeout/disconnect, deadline precedence, and duplicate-result absorption.

Evidence

What I checked:

  • Current-main gap: Current main still constructs a generic timeout error at this client boundary; it has no requestSent timeout metadata, so the PR’s client-visible provenance has not already landed. (packages/gateway-client/src/client.ts:405, 7c9794b5c65c)
  • PR transport boundary: The PR records requestSent only after socket.send(...) returns and supplies it to the timeout-error factory, which correctly distinguishes a send failure from a timed-out request that crossed the client transport boundary. (packages/gateway-client/src/protocol-client.ts:281, 8fbbb9cbe13d)
  • PR node-dispatch boundary: The node registry calls onDispatchReady only after sendEventToSession succeeds, providing the authoritative post-send dispatch fact consumed by the server-method and plugin-policy projections. (src/gateway/node-registry.ts:1207, 8fbbb9cbe13d)
  • Feature provenance: Blame attributes the current node-invocation send/dispatch boundary to the paired-node deadline implementation, establishing Peter Steinberger as the principal current-main history owner for this surface. (src/gateway/node-registry.ts:1201, 060a541c9276)
  • Stack provenance: The PR head is not reachable from current main; its open parent is locally present at 809a73433fbd7acf4da437e69f1c6aeb9f04a9a0, confirming this remains a necessary unmerged stack layer rather than an implemented-on-main cleanup candidate. (src/gateway/node-registry.invoke-stream.ts:132, 8fbbb9cbe13d)

Likely related people:

  • steipete: Commit 060a541c92761d7c1eaa5646a27851071d904ac3 introduced the current node-registry invocation deadline and post-send dispatch callback that this PR refines. (role: introduced current dispatch/deadline boundary; confidence: high; commits: 060a541c9276; files: src/gateway/node-registry.ts, src/gateway/node-registry.invoke-stream.ts, packages/gateway-client/src/protocol-client.ts)
  • Vincent Koc: Recent history includes Gateway-client protocol work in commit 20e68e01dff5359c3a334271a8cdfaf994743e6b, making this a reasonable secondary reviewer for the client error-contract portion. (role: recent Gateway-client contributor; confidence: medium; commits: 20e68e01dff5; files: packages/gateway-client/src/protocol-client.ts)

Rank-up moves

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

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 (10 earlier review cycles; latest 8 shown)
  • reviewed July 31, 2026, 9:57 PM ET / August 1, 2026, 01:57 UTC sha unknown :: needs real behavior proof before merge. :: [P1] Settle overdue aborts as timeouts
  • reviewed 2026-08-01T07:25:58.885Z sha 8a35996 :: found issues before merge. :: [P2] Move plugin dispatch provenance behind registry send
  • reviewed 2026-08-01T07:58:01.110Z sha 8a35996 :: needs changes before merge. :: [P2] Mark plugin dispatch only after registry send
  • reviewed 2026-08-01T11:32:46.741Z sha 8a35996 :: found issues before merge. :: [P2] Keep plugin dispatch provenance behind the registry send
  • reviewed 2026-08-01T15:21:27.376Z sha 5f24a61 :: found issues before merge. :: [P2] Move plugin dispatch provenance behind the registry send
  • reviewed 2026-08-01T17:53:23.975Z sha a51db74d4f0c134176e9863485944f03e5d4fa90 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T19:19:34.512Z sha bb83607 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T19:24:45.581Z sha bb83607 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Aug 1, 2026
@omarshahine

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot closed this Aug 1, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Aug 1, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed 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. labels Aug 1, 2026
@openclaw-barnacle openclaw-barnacle Bot closed this Aug 1, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Aug 1, 2026
@omarshahine

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot removed the rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. label Aug 1, 2026
@clawsweeper clawsweeper Bot added 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. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 1, 2026
@omarshahine omarshahine self-assigned this Aug 1, 2026
omarshahine and others added 4 commits August 1, 2026 18:45
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 6381c461-11aa-4700-8648-4da1393e1c59
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 6381c461-11aa-4700-8648-4da1393e1c59
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 6381c461-11aa-4700-8648-4da1393e1c59
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 6381c461-11aa-4700-8648-4da1393e1c59
@omarshahine
omarshahine force-pushed the omarshahine-gateway-invoke-provenance branch from a51db74 to bb83607 Compare August 1, 2026 19:13
@omarshahine

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 6381c461-11aa-4700-8648-4da1393e1c59
@omarshahine

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@omarshahine

Copy link
Copy Markdown
Contributor Author

Maintainer decision: accepted. requestSent and nodeCommandDispatched are additive retry-safety provenance. nodeCommandDispatched becomes true only after the authoritative node transport send succeeds; proven pre-send failures remain false, and post-send timeout or disconnect remains ambiguous/true.

This is Layer 2 of the native stack and must land bottom-to-top, only after #116591 lands. Do not merge this layer independently.

@omarshahine
omarshahine merged commit 2b3009f into main Aug 1, 2026
129 of 131 checks passed
@omarshahine
omarshahine deleted the omarshahine-gateway-invoke-provenance branch August 1, 2026 21:22
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* fix(gateway): preserve node invoke dispatch provenance

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 6381c461-11aa-4700-8648-4da1393e1c59

* fix(gateway): preserve timeout precedence

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 6381c461-11aa-4700-8648-4da1393e1c59

* fix(gateway): mark wake-path disconnect as not dispatched

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 6381c461-11aa-4700-8648-4da1393e1c59

* fix(gateway): mark plugin dispatch after send

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 6381c461-11aa-4700-8648-4da1393e1c59

* build(browser): regenerate Copilot runtime

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 6381c461-11aa-4700-8648-4da1393e1c59

---------

Co-authored-by: Omar Shahine <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 6381c461-11aa-4700-8648-4da1393e1c59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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