Skip to content

Extract pending gateway request registry - #1090

Closed
bkudiess wants to merge 5 commits into
openclaw:mainfrom
bkudiess:bkudiess-extract-pending-request-registry
Closed

bkudiess wants to merge 5 commits into
openclaw:mainfrom
bkudiess:bkudiess-extract-pending-request-registry

Conversation

@bkudiess

@bkudiess bkudiess commented Aug 4, 2026 •

Copy link
Copy Markdown
Collaborator

Stack: 1 of 3 for #980

Summary

Behavior-neutral extraction of gateway request ownership from OpenClawGatewayClient into PendingRequestRegistry.

  • Old owner: OpenClawGatewayClient private method, wizard, chat-send, and approval pending stores and locks.
  • New owner: PendingRequestRegistry, with one atomic owner per request ID.
  • Preserved invariant: current wire, API, event, handshake, wizard, approval, chat, health, cancellation, disconnect, disposal, and legacy untracked hello-ok behavior remain unchanged.
  • Added bounded completed-ID tombstones, duplicate/late response suppression, request-ID reuse protection, disconnect registration gating, typed correlated session-snapshot support for later stack layers, and concurrency coverage.
  • Preserved current-main compatibility at the response boundary: active owners route once, tombstoned duplicates are suppressed, and genuinely ownerless payloads retain generic health/session/usage/node/agent routing.
  • Updated the architecture ledger to mark the new owner authoritative and the vacated client bookkeeping responsibility closed.

Default reasoning UI/provider behavior, reasoning reconciliation, and new public sessions.list behavior are intentionally out of scope for this lower PR.

Validation

Exact head: 79b289e0d7d91e05a6f7da507d3cf25ec9927dfd

  • .\build.ps1: 5/5 projects built.
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore: 3,426 passed, 32 skipped.
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore: 2,037 passed.
  • dotnet test .\tests\OpenClaw.Connection.Tests\OpenClaw.Connection.Tests.csproj --no-restore: 535 passed.
  • dotnet test .\tests\OpenClaw.SetupEngine.Tests\OpenClaw.SetupEngine.Tests.csproj --no-restore: 703 passed.
  • dotnet test .\tests\OpenClaw.WinNode.Cli.Tests\OpenClaw.WinNode.Cli.Tests.csproj --no-restore: 126 passed.
  • dotnet test .\tests\OpenClaw.E2ETests\OpenClaw.E2ETests.csproj --no-build --filter FullyQualifiedName~OpenClaw.E2ETests.Setup.RequestRoutingProofCollectorTests: 3 passed.
  • Isolated real-Gateway proof filter RealGateway_TrackedRequestRouting_SurvivesReconnect: 1 passed in 4m20s.
  • Focused protocol, registry, architecture, client, shutdown, and loopback filter: 223 passed.
  • git diff --check: clean.
  • Exact-head Build and Test: passed with no failed checks.
  • Hosted setup-connect job: passed.
  • Hosted redacted proof artifact (e2e-test-results-setup-connect): transcript HEAD=79b289e0d7d91e05a6f7da507d3cf25ec9927dfd, routing RESULT=PASS, cleanup RESULT=PASS.

Real behavior proof

The exact-head hosted real-Gateway proof used E2ESetupFixture with a unique WSL distro, isolated tray data, unique ports, and ephemeral credentials. It made no model or provider calls.

PROOF=REAL_DEPLOYED_GATEWAY_REQUEST_ROUTING
GATEWAY_VERSION=2026.6.11
PROTOCOL=4
GENERATION=1 METHOD=connect ID_HASH=[REDACTED] OWNER=Method RESPONSE=Active STATUS=hello-ok
GENERATION=1 METHOD=health ID_HASH=[REDACTED] OWNER=Method RESPONSE=Active STATUS=response-owned
GENERATION=1 METHOD=sessions.list ID_HASH=[REDACTED] OWNER=Method RESPONSE=Active STATUS=response-owned
GENERATION=1 METHOD=node.list ID_HASH=[REDACTED] OWNER=Method RESPONSE=Active STATUS=response-owned
GENERATION=1 DISCONNECT=OBSERVED
GENERATION=2 METHOD=connect RESPONSE=Active STATUS=hello-ok
GENERATION=2 METHOD=health ID_HASH=[REDACTED] OWNER=Method RESPONSE=Active STATUS=response-owned
GENERATION=2 METHOD=sessions.list ID_HASH=[REDACTED] OWNER=Method RESPONSE=Active STATUS=response-owned
GENERATION=2 METHOD=node.list ID_HASH=[REDACTED] OWNER=Method RESPONSE=Active STATUS=response-owned
REAL_GATEWAY_DUPLICATE_OR_LATE_RESPONSE=NOT_NATURALLY_OBSERVED
SYNTHETIC_DUPLICATE_LATE_PROOF=TrackedHealthResponse_PublishesOnceAndSuppressesDuplicate;SendWizardRequestAsync_LateResponseAfterTimeout_DoesNotChangeOutcomeOrTracking;OwnerlessHealthResponse_PreservesGenericHealthRouting;TombstonedDuplicateStatePayloads_DoNotRepublishGenericState
RESULT=PASS

Cleanup proof:

UNINSTALL=PASS
ISOLATED_DISTRO_REMOVED=PASS
ISOLATED_TRAY_DATA_REMOVED=PASS
ISOLATED_LOCALAPPDATA_REMOVED=PASS
RESULT=PASS

The live Gateway did not naturally replay a duplicate or late response. Deterministic loopback and concurrency coverage proves:

  • tracked wizard, approval, chat-send, health, and method responses route to exactly one owner;
  • tombstoned duplicate, timed-out, canceled, and otherwise late responses cannot republish generic payloads;
  • genuinely ownerless health, sessions, usage, nodes, and agents payloads preserve current-main generic routing without completing typed owners;
  • legacy untracked hello-ok remains accepted;
  • correlated session snapshots complete without mutating the broadcast session cache or firing SessionsUpdated;
  • explicit disconnect closes registration and cancels pending owners before socket close completes;
  • active ID replacement cancels the prior owner, ID reuse removes old tombstones, FIFO eviction remains bounded at 256 IDs;
  • concurrent register/take and disconnect/register stress leave no active request leaks.

No UI behavior changed, so screenshots are not applicable.

Review

  • Independent GPT adversarial re-review: 92% confidence, zero actionable findings.
  • Independent Opus adversarial re-review: 90% confidence, zero actionable findings.
  • One medium disconnect-ordering race found during review was fixed and covered by a discriminating loopback regression test before both clean re-reviews.
  • Proof-update Gemini adversarial review: 100% confidence, zero actionable findings.
  • Proof-update GPT adversarial review: 93% confidence, zero actionable findings.
  • Proof review findings around request/event correlation, reconnect node.list, and same-method background refreshes were fixed with exact registration pinning and deterministic anti-false-pass tests before the final clean reviews.
  • P1 compatibility-fix Codex review: 94% confidence, zero actionable findings.
  • P1 compatibility-fix Opus review: 93% confidence, zero actionable findings.
  • Local structured autoreview blocker: the review bundle was generated successfully, but the local Codex CLI is not authenticated (401 Unauthorized); Claude CLI is not installed. The coordinator accepted this documented environment blocker because both independent reviews are clean.

This PR should remain open and unmerged for maintainer review. Later reasoning behavior PRs will stack above this exact branch.

@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. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. labels Aug 4, 2026
@clawsweeper

clawsweeper Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed August 8, 2026, 11:40 AM ET / 15:40 UTC.

ClawSweeper review

What this changes

This PR moves Gateway request correlation for setup, chat, approvals, health, and other operator calls into a shared pending-request registry with duplicate-response suppression and routing tests.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open for maintainer handling. The collaborator-authored PR remains necessary because current main still uses client-local pending maps, but it is conflict-dirty against later gateway authentication and recovery hardening. Likely related people: Barbara Kudiess (high confidence) and Scott Hanselman (high confidence).

Priority: P1
Reviewed head: 79b289e0d7d91e05a6f7da507d3cf25ec9927dfd
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The extraction has strong routing proof and focused coverage, but current-main conflict resolution is required before its patch quality can be judged for landing.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The PR body provides exact-head hosted real-Gateway routing output and a linked redacted artifact, supplemented by deterministic duplicate and late-response coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The PR body provides exact-head hosted real-Gateway routing output and a linked redacted artifact, supplemented by deterministic duplicate and late-response coverage.
Evidence reviewed 5 items Current main lacks the extraction: Current main still declares separate request-method and chat-send pending maps in the Gateway client, so the central refactor is not implemented there.
Architecture ledger still plans this owner: Current main explicitly records Gateway request tracking and the PendingRequestRegistry extraction as planned.
PR implements an atomic response owner: The PR-head registry atomically removes active owners, records completed IDs, and distinguishes active, tombstoned, and ownerless responses.
Findings None None.
Security None None.

How this fits together

The Gateway client sends operator requests and turns correlated responses into connection, setup, chat, approval, and state updates. The registry sits between incoming responses and those consumers to decide whether a response completes an active request, is late, or should use generic state routing.

flowchart LR
  A[Operator request] --> B[Gateway client]
  B --> C[Request registry]
  D[Gateway response] --> C
  C --> E[Complete active request]
  C --> F[Suppress late response]
  C --> G[Publish generic state]
Loading

Decision needed

Question Recommendation
Should this stacked request-registry extraction be restacked onto current main with the later Gateway authentication and recovery hardening preserved? Restack and reprove: Refresh the extraction onto current main, retain the later handshake and recovery behavior, and rerun the real-Gateway routing proof.

Why: The conflict touches lifecycle and credential-sensitive code, so automation should not choose which current-main contract survives a manual resolution.

Before merge

  • Resolve merge risk (P1) - The branch is merge-dirty against later Gateway handshake, credential-handoff, and disconnect-recovery work; an incorrect manual resolution could lose fail-closed authorization or typed recovery behavior.
  • Resolve merge risk (P1) - The supplied real-Gateway proof is strong for the PR head, but the refreshed merge result needs the same routing proof because the overlapping client lifecycle has changed on main.
  • Complete next step (P2) - Maintainer judgment is required to resolve the dirty overlap without losing current Gateway authentication and recovery hardening.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Patch surface 17 files, +2,113 / -238 lines The extraction spans Gateway behavior, architecture documentation, CI proof collection, and several test suites.
Production versus test delta production +691 / -178, tests +1,400 / -56 Most growth is targeted routing, concurrency, and Gateway proof coverage for a concentrated shared-client refactor.

Merge-risk options

Maintainer options:

  1. Restack and reprove (recommended)
    Rebase onto current main, preserve current handshake authorization and recovery behavior, then rerun the real-Gateway routing proof.
  2. Pause the stacked extraction
    Keep the draft open until maintainers decide whether this refactor should be restacked independently of the related reasoning work.

Technical review

Best possible solution:

Rebase this focused extraction onto current main, preserve the later handshake and recovery contracts, then publish fresh registry, shared/tray, and real-Gateway routing proof for the resolved head.

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

Not applicable as a defect report. The PR supplies a high-confidence exact-head real-Gateway routing run plus deterministic late-response and concurrency coverage.

Is this the best way to solve the issue?

Unclear pending restack. The ownership transfer is a coherent solution, but its current head cannot establish merge safety until it incorporates later Gateway lifecycle hardening.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 9f9a8eda6340.

Labels

Label changes:

  • add merge-risk: 🚨 security-boundary: The conflicting mainline area now includes fail-closed handshake authorization and credential-handoff protections that must survive resolution.

Label justifications:

  • P1: Gateway response correlation affects setup, health, chat, and approval workflows, and a faulty conflict resolution could disrupt active users.
  • merge-risk: 🚨 compatibility: The branch conflicts with later current-main Gateway client changes and must retain established connection behavior.
  • merge-risk: 🚨 availability: Registration, cancellation, disconnect, and reconnect paths determine whether Gateway operations recover or stall.
  • merge-risk: 🚨 security-boundary: The conflicting mainline area now includes fail-closed handshake authorization and credential-handoff protections that must survive resolution.
  • 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 (linked_artifact): The PR body provides exact-head hosted real-Gateway routing output and a linked redacted artifact, supplemented by deterministic duplicate and late-response coverage.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides exact-head hosted real-Gateway routing output and a linked redacted artifact, supplemented by deterministic duplicate and late-response coverage.

Evidence

What I checked:

  • Current main lacks the extraction: Current main still declares separate request-method and chat-send pending maps in the Gateway client, so the central refactor is not implemented there. (src/OpenClaw.Shared/OpenClawGatewayClient.cs:40, 9f9a8eda6340)
  • Architecture ledger still plans this owner: Current main explicitly records Gateway request tracking and the PendingRequestRegistry extraction as planned. (docs/ARCHITECTURE.md:70, 9f9a8eda6340)
  • PR implements an atomic response owner: The PR-head registry atomically removes active owners, records completed IDs, and distinguishes active, tombstoned, and ownerless responses. (src/OpenClaw.Shared/PendingRequestRegistry.cs:226, 79b289e0d7d9)
  • Later mainline gateway hardening overlaps this seam: After the PR base, current main added typed disconnect classification, guarded handshake authorization, and token-persistence controls in the same client; the PR is reported merge-dirty. (src/OpenClaw.Shared/OpenClawGatewayClient.cs:194, 603886a81d34)
  • Current-head real behavior proof: The PR body links an exact-head hosted real-Gateway routing artifact and records reconnect routing for connect, health, sessions.list, and node.list, with deterministic coverage for duplicate and late responses. (79b289e0d7d9)

Likely related people:

  • Barbara Kudiess: Authored current-main gateway credential-handoff hardening in the same client and has substantial adjacent connection-history ownership. (role: recent gateway recovery contributor; confidence: high; commits: 603886a81d34, bc210e048aa9; files: src/OpenClaw.Shared/OpenClawGatewayClient.cs, src/OpenClaw.Connection/GatewayConnectionManager.cs)
  • Scott Hanselman: Authored the current-main managed Gateway restart and typed disconnect-recovery hardening that overlaps the pending-request lifecycle. (role: recent gateway recovery contributor; confidence: high; commits: 01faa6419b42; files: src/OpenClaw.Shared/OpenClawGatewayClient.cs, src/OpenClaw.SetupEngine/GatewayWizardRestartRecoveryPolicy.cs)

Rank-up moves

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

  • Restack onto current main and attach refreshed real-Gateway routing proof for the resolved head.

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 (11 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-04T22:10:33.728Z sha c2fefc7 :: needs changes before merge. :: [P1] Preserve generic parsing for ownerless responses
  • reviewed 2026-08-04T23:05:14.944Z sha 79b289e :: needs maintainer review before merge. :: none
  • reviewed 2026-08-04T23:09:37.585Z sha 79b289e :: needs maintainer review before merge. :: none
  • reviewed 2026-08-05T06:27:33.200Z sha 79b289e :: needs maintainer review before merge. :: none
  • reviewed 2026-08-05T06:31:26.596Z sha 79b289e :: needs maintainer review before merge. :: none
  • reviewed 2026-08-05T06:41:03.384Z sha 79b289e :: needs maintainer review before merge. :: none
  • reviewed 2026-08-05T11:05:10.670Z sha 79b289e :: needs maintainer review before merge. :: none
  • reviewed 2026-08-08T14:24:36.631Z sha 79b289e :: needs maintainer review before merge. :: none

@bkudiess

bkudiess commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

🦞🧹
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 added proof: sufficient Contributor real behavior proof is sufficient. 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 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 4, 2026
@bkudiess

bkudiess commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

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

@clawsweeper clawsweeper Bot added 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. P1 Urgent regression or broken agent/channel workflow affecting real users now. and removed 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. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. labels Aug 4, 2026
@bkudiess

bkudiess commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

🦞🧹
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 added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 4, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 4, 2026
@bkudiess
bkudiess marked this pull request as draft August 5, 2026 06:23
@bkudiess
bkudiess marked this pull request as ready for review August 5, 2026 06:23
@bkudiess
bkudiess marked this pull request as draft August 5, 2026 06:26
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Aug 5, 2026
@bkudiess
bkudiess marked this pull request as ready for review August 5, 2026 06:35
@bkudiess
bkudiess marked this pull request as draft August 5, 2026 06:36
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. label Aug 8, 2026
@bkudiess bkudiess closed this Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P1 Urgent regression or broken agent/channel workflow affecting real users now. proof: sufficient Contributor real behavior proof is sufficient. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant