Repository navigation
perf(browser): count encoded envelopes without a second serialization - #140882
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 7, 2026, 2:14 AM ET / 06:14 UTC. ClawSweeper reviewWhat this changesThe browser plugin measures encoded node responses without serializing them twice and adds exact-limit coverage while consolidating existing tests. Merge readiness✅ Ready for maintainer review The optimization remains useful: current main and the latest release still allocate the second JSON string. No actionable correctness or security defect was found in the introduced patch. Priority: P2 Review scores
Verification
How this fits togetherThe browser plugin executes delegated browser commands on a connected node and packages results and downloaded files for the Gateway. Its encoded-size check limits responses before transport; the Gateway validates files before saving them. flowchart LR
A[Delegated browser command] --> B[Node browser routes]
B --> C[Result and bounded files]
C --> D[Native JSON serialization]
D --> E{Encoded size within limit}
E -->|Yes| F[Gateway framing and file validation]
E -->|No| G[Payload limit error]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +34, Tests 0. Total +34 across 2 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep size accounting private to the browser response producer while preserving native serialization, exact admission limits, and existing transport validation. Do we have a high-confidence way to reproduce the issue? Yes, source establishes that every successful response through this admission path creates a second JSON string solely to count bytes; no runtime reproduction was executed during this read-only review. Is this the best way to solve the issue? Yes, the private counter removes the discarded serialization while retaining native object traversal, serialization errors, and the existing wire contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d8b597be60c4. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
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.
Closes #140881
Additional instructions
Maintainer edits are enabled on this repository-owned branch.
What Problem This Solves
Browser node responses build a second full JSON string solely to measure the serialized payload inside the outer node frame. That allocation is discarded after budget admission.
Why This Change Was Made
Keep native serialization once, then count its exact quoted byte length with UTF-8 byteLength, statics-free quote/backslash scans and typed toUSVString handling for raw lone surrogates. The private helper accepts native compact JSON output; actual final framing and receiver validation stay unchanged.
User Impact
Twenty actual delegated-command/framing/receiver flows preserve returned and wire hashes, native errors, file handling and exact 24 MiB admission. Sampled allocation falls by about 22.55 MB per owner operation for an 8 MiB PDF and 44.79 MB for 16 MiB aggregate files; corresponding framing/receiver observations are consistent.
Owner retention matches baseline. Malformed raw JSON can still require a replacement string, with no demonstrated allocation saving in that control. No small-output throughput, strict non-regression, peak/RSS or whole-Gateway claim is made.
Evidence
Related #103328 established the budget. Active #128289 and #126870 change independent invocation authority/lifecycle behavior; preserve those guards if they land first.