Repository navigation
refactor(browser): simplify relay lifecycle helpers - #133706
Conversation
Remove duplicate profile admission and terminal handling, reuse RPC result schemas and deferred completion, and make announcement recipients and request-local action guards explicit. Preserve authentication, asynchronous ownership checks, cleanup acknowledgements, and action error precedence. Make the Gateway upgrade-head fixture deterministic at its existing input boundary instead of depending on TCP coalescing. Keep its assertions. Maintainer-requested follow-up to the standalone relay in #128379. Production LOC -75; test LOC -11. Validated with 203 focused tests, changed checks, full build, and fresh scoped-clean Codex autoreview at P0.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 9:58 PM ET / August 31, 2026, 01:58 UTC. ClawSweeper reviewWhat this changesRefactors browser relay lifecycle and existing-session action helpers while making the Gateway upgrade-head integration fixture deterministic. Merge readinessKeep open. Current main does not contain this maintainer-requested browser-relay cleanup, and the introduced changes preserve the existing lifecycle lease, CDP recipient, and navigation-guard boundaries; normal maintainer approval and exact-head CI completion remain required. Priority: P3 Review scores
Verification
How this fits togetherThe browser plugin accepts extension relay connections and exposes authenticated CDP access to Gateway browser actions. Relay lifecycle state controls whether Gateway owns or borrows that connection, while existing-session actions apply navigation policy after browser interaction. flowchart LR
Extension[Browser extension] --> Relay[Extension relay]
Gateway[Gateway browser service] --> Lifecycle[Relay lifecycle]
Lifecycle --> Relay
Relay --> CDP[Authenticated CDP clients]
Agent[Agent browser action] --> Guard[Navigation guard]
Guard --> CDP
Decision needed
Why: The PR is maintainer-authored and carries the protected maintainer label, so repository policy requires explicit maintainer handling even though no source-level defect was found. Before merge
Agent review detailsSecurityNone. PR surfaceSource -75, Tests -11. Total -86 across 7 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the owner client as the single profile-lease enforcement point and land the cleanup once the browser owner accepts it and exact-head checks are green. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR is a requested refactor, not a report of a current user-facing defect; the fixture change is source-scoped and its claimed test run was not independently executed in this read-only review. Is this the best way to solve the issue? Yes. Consolidating the duplicate registry check into the already-adopted owner-client lease keeps one canonical lifecycle authority without changing public configuration, protocol, or storage behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c29f34dc5312. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Land-ready verification for 626ca3dc158871e8007412a7a5a9feb5adcd9d3e. This is the explicitly requested maintainer cleanup: production +161/-236, net -75 lines; tests/support +34/-45, net -11. It retains the owner client as the single adopted profile-lease enforcement point, preserves asynchronous fencing and cleanup acknowledgement, and keeps CDP announcement order and post-action navigation-error precedence. The only fixture repair replaces an unreliable TCP-coalescing assumption with the existing Gateway upgrade-head boundary; authentication, hello, inventory and length assertions remain. Proof: 203 focused tests passed, complete changed-scope checks passed, and Exact-head hosted proof completed successfully, both on attempt 1: CI run 33348914007 and OpenGrep run 33348914071. The native exact-head watcher returned The latest ClawSweeper review and rank-up move are addressed: the PR is ready, the explicit maintainer landing decision is to accept this cleanup, and the exact-head checks have passed. The maintainer label remains; this proceeds through ordinary native preparation and pinned-head merge gates. No new installed/live-Chrome or Windows runtime acceptance is claimed for this bounded behavior-preserving refactor. No operator browser/Gateway was touched. Previously recorded cross-client cleanup isolation and Windows symlink-rejection follow-ups remain separate; this PR does not claim to repair them. |
|
Merged via squash.
|
Remove duplicate profile admission and terminal handling, reuse RPC result schemas and deferred completion, and make announcement recipients and request-local action guards explicit. Preserve authentication, asynchronous ownership checks, cleanup acknowledgements, and action error precedence. Make the Gateway upgrade-head fixture deterministic at its existing input boundary instead of depending on TCP coalescing. Keep its assertions. Maintainer-requested follow-up to the standalone relay in openclaw#128379. Production LOC -75; test LOC -11. Validated with 203 focused tests, changed checks, full build, and fresh scoped-clean Codex autoreview at P0.
Consolidate image traversal, request observation ownership, bus waiters, Slack response classification, Node selection and WebSocket decoding. Retire the generic Windows executable export after its Node caller moved; keep trusted taskkill/PowerShell paths and all environment validation. Remove duplicate planner validation and unsupported private lifecycle guards. Keep external evidence validation, security authority, resource limits and ordinary write-capable shutdown settlement. Also preserve WhatsApp audio preflight when enabling message actions and avoid recording a POSIX pipe-drain failure during the normal TERM grace. Best-effort tradeoffs accepted: - Bus cloning trusts its private typed event union. 0ebeee8 added the unsupported-kind throw only for lint; fabricated internal kinds now fail naturally, and a new typed variant must update this owner at compile time. - Overlapping private QA driver transitions are unsupported; callers await them. #113855 introduced synthetic interleavings, not a human incident. - Canonical smoke selection is trusted instead of revalidated; #114055 was an ownership cutover. A future selector defect belongs at that owner. - Wire image inputs are parsed JSON trees. #71311 introduced no human cyclic-input incident; unsupported internal cyclic objects are best effort. - Fabricated cyclic/BigInt tool outputs now fail clearly instead of becoming empty evidence. 195e721 added stabilization, not a human incident. - Reinstalling the private AIMock mount is unsupported. bdc9c60 added speculative guards; the actual owner installs it once before start. - Obsolete repeated observer disposal after port reuse can remove the newer QA lookup. 6386dc4 was an affinity repair, not a disposal incident; normal unique-port ownership and stop ordering prevent that lifecycle. - Local non-federated Matrix joins fail immediately on setup errors; #64489 added initial coverage, not a reported transient-join incident. Rerun the QA command after an unusual setup fault. - Artifact publication is trusted after its awaited atomic writer. #92606 added suite execution, not a missing-write incident; deletion afterward is reported by normal readers. - Native browser JSON needs no branded rawJSON surrogate workaround. #140882 added that generality without a human incident; a future branded producer must own its serialization contract. - Insertion-only pending caches clear directly on settlement. #113926 and #128379 supplied no human successor-eviction incident; no replacement can precede these finalizers. Real close-time successor checks stay. - Re-registering the identical private borrowed-relay handle is unsupported. #128379/#133706 introduced no such incident; the owner creates fresh handles and current authority and distinct-successor comparisons remain. - Inconclusive Linux process snapshots conservatively stay alive until the next check. #132230/#131643 used controlled fault injection, not a human actual-use incident. Final unconfirmed settlement retains state for retry.
…0889) Consolidate image traversal, request observation ownership, bus waiters, Slack response classification, Node selection and WebSocket decoding. Retire the generic Windows executable export after its Node caller moved; keep trusted taskkill/PowerShell paths and all environment validation. Remove duplicate planner validation and unsupported private lifecycle guards. Keep external evidence validation, security authority, resource limits and ordinary write-capable shutdown settlement. Also preserve WhatsApp audio preflight when enabling message actions and avoid recording a POSIX pipe-drain failure during the normal TERM grace. Best-effort tradeoffs accepted: - Bus cloning trusts its private typed event union. f993a27 added the unsupported-kind throw only for lint; fabricated internal kinds now fail naturally, and a new typed variant must update this owner at compile time. - Overlapping private QA driver transitions are unsupported; callers await them. openclaw#113855 introduced synthetic interleavings, not a human incident. - Canonical smoke selection is trusted instead of revalidated; openclaw#114055 was an ownership cutover. A future selector defect belongs at that owner. - Wire image inputs are parsed JSON trees. openclaw#71311 introduced no human cyclic-input incident; unsupported internal cyclic objects are best effort. - Fabricated cyclic/BigInt tool outputs now fail clearly instead of becoming empty evidence. 5929e9a added stabilization, not a human incident. - Reinstalling the private AIMock mount is unsupported. e98e098 added speculative guards; the actual owner installs it once before start. - Obsolete repeated observer disposal after port reuse can remove the newer QA lookup. ace0e05 was an affinity repair, not a disposal incident; normal unique-port ownership and stop ordering prevent that lifecycle. - Local non-federated Matrix joins fail immediately on setup errors; openclaw#64489 added initial coverage, not a reported transient-join incident. Rerun the QA command after an unusual setup fault. - Artifact publication is trusted after its awaited atomic writer. openclaw#92606 added suite execution, not a missing-write incident; deletion afterward is reported by normal readers. - Native browser JSON needs no branded rawJSON surrogate workaround. openclaw#140882 added that generality without a human incident; a future branded producer must own its serialization contract. - Insertion-only pending caches clear directly on settlement. openclaw#113926 and openclaw#128379 supplied no human successor-eviction incident; no replacement can precede these finalizers. Real close-time successor checks stay. - Re-registering the identical private borrowed-relay handle is unsupported. openclaw#128379/openclaw#133706 introduced no such incident; the owner creates fresh handles and current authority and distinct-successor comparisons remain. - Inconclusive Linux process snapshots conservatively stay alive until the next check. openclaw#132230/openclaw#131643 used controlled fault injection, not a human actual-use incident. Final unconfirmed settlement retains state for retry.
Related: standalone browser relay and native-host wake-up.
Additional instructions
Maintainer-requested cleanup. This same-repository branch remains editable by maintainers.
What Problem This Solves
The landed standalone browser relay and adjacent action handling contain repeated lifecycle bookkeeping and action wrappers that make their ownership boundaries harder to maintain. This follows an explicit maintainer request to simplify that code and reduce production LOC.
The focused baseline also exposed a flaky Gateway ingress fixture: it assumed corked TCP writes would arrive entirely in Node's WebSocket upgrade
head, but received zero head bytes instead of the expected 243.Why This Change Was Made
Keep the existing owners and remove duplication: the owner client alone enforces its adopted profile admission; retirement and disconnection share terminal invalidation without conflating acknowledgement; immutable RPC result schemas are reused; unused retained owner metadata is removed; target announcements receive explicit recipient snapshots; daemon completion uses the existing deferred helper; existing-session actions bind their navigation guard once.
The ingress fixture supplies its encoded bytes at the existing production upgrade-head boundary, as the pre-auth boundary tests already do. It still exercises real HTTP/WebSocket authentication, buffered-frame consumption, hello promotion and inventory publication. Node's
OutgoingMessage.end()fully uncorks the socket, and TCP writes cannot guarantee parser head boundaries. No retry, timeout increase or weakened assertion was added.User Impact
No intended user-visible behavior change. Authentication, live-key checks, checks across asynchronous boundaries, reference and registration identity, cleanup acknowledgements, recipient ordering, action error precedence and cancellation remain unchanged. No new configuration, protocol, storage, dependency or public SDK surface.
Production: +161/-236, net -75 lines across six files. Tests/support: +34/-45, net -11 lines in one file. This does not claim to repair separately tracked correctness issues in unchanged relay code.
Evidence
This is a bounded behavior-preserving refactor. No operator browser/Gateway was touched, no new installed/live-browser claim is made, and no visual behavior changed.
Exact local validation commands