Repository navigation
refactor(browser,memory): consolidate repeated handlers and lifecycle work - #167734
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. What this changesThis PR consolidates repeated browser request handling and memory indexing, ranking, and cleanup code while preserving existing behavior. Review scores
ProductKind: Refactor · Worth it: Yes Merge readiness✅ Ready for maintainer review Keep open: this is a useful follow-up to established area-owner consolidation work, with distinct changes beyond the earlier merged refactor. No actionable introduced correctness or security defect was found. Priority: P3 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe Browser plugin turns agent and CLI requests into browser operations. Memory Core indexes notes and session content, retrieves relevant passages, and publishes background memory updates through its existing storage owners. flowchart TD
A[Agent and CLI requests] --> B[Browser request handlers]
B --> C[Browser transport and session owners]
C --> D[Browser results]
E[Notes and session content] --> F[Memory indexing and retrieval]
F --> G[SQLite publication owner]
G --> H[Search results and memory updates]
Technical reviewBest possible solution: Keep the consolidation within the existing Browser and Memory owners while preserving their public and stored-data contracts. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR claims behavior-preserving consolidation rather than a bug fix, and no failing-base regression is claimed. Is this the best way to solve the issue? Yes: the inspected changes move repeated work into existing owners, remove retired private paths, and preserve explicit transport and lifecycle differences. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against fec7f6938886. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfacePR surface statistics unavailable: the file list is incomplete. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 9, 2026, 5:07 AM ET / 09:07 UTC. |
… work (openclaw#167734) Share private Browser request, CLI, transport, and lifecycle handling and Memory indexing, ranking, promotion, and publication logic across variants. Preserve existing features, messages, SDK contracts, wire formats, stored data, permissions, and budgets. Remove 1,062 net production lines. Full subsystem tests, focused integration tests, typechecks, cycle checks, SDK declaration comparison, lint, and exact-head hosted CI passed; local timing failures and inherited Knip findings are recorded in the PR.
Related: #166973
What Problem This Solves
Browser and Memory repeat request dispatch, lifecycle handling, and indexing logic across variants.
User Impact
No user-visible change. Features, CLI flags, configuration, messages, SDK contracts, wire and stored-data shapes, permissions, and timing budgets stay the same. No dependency or schema change, migration, or operator action is introduced by this PR.
Why This Change Was Made
Browser now shares command/route families, selected client transports, CDP discovery, native-process cleanup, and session-tab operations. Memory shares retrieval/ranking projections, promotion and reflection processing, publication ownership, and pause-aware deadlines. The adjacent Memory host SDK shares Markdown boundaries, FTS trigger construction, and batch response parsing. Real differences remain explicit parameters at the owning implementation.
This removes 1,062 net production lines: Browser 501, Memory Core 492, and its host SDK 69, excluding tests, fixtures, test support, generated files, and declarations. The pass re-evaluated prior retained/partial files largest first and measured implemented candidates.
FTS construction emits the same six SQL strings and readonly literal declarations. Markdown chunks, hashes, annotation spans, and remapped line ranges remain identical; chunking version stays 5. The URL glob change replaces tokenization while retaining the existing range-based matcher and backtracking protections. The conflict-only rebase preserves main's authored CLI timeout handling and agent-qualified tab ownership.
Evidence
The remaining selected guards and scripts lint passed on the rebased head; extension-lint proof is recorded separately below.
The local
node scripts/check-changed.mjsrun passed its earlier guards and typechecks, then stopped at four inherited Knip unused exports:bindCliQuestionAnswerAuthority,prepareSessionEventTargetForHost,readSessionEntryCreationTransition, andRESTART_CONTINUATION_CONTEXT_PREFIX. All four also fail in scheduled main check-dependencies at53868c16088fd9cc86e84340178d8291c7a6f133. Their definitions, consumers, and Knip configurations were verified unchanged by the lane and at the inspected main snapshot. The local full-tree scan repeats the final two; main's job stopped after the production scan. Remaining commands were run separately without disabling the failing check. The safety baseline only shrinks the five assertions this change removes.Two local extension-lint attempts stopped in SDK declaration generation at the existing 300-second limit, before lint rules ran. On the exact published head, full
pnpm lint:extensionsthen passed on AWS in 355.17s with zero warnings and errors. The four existing edited test files passed all 41 tests through the canonical Vitest wrapper with--maxWorkers=1: 70.65s wall time / 70.65 CI runner-seconds for that command underCI=1. No timeout or retry policy was changed.Earlier local Browser focus passed 1,137 tests and failed one CDP PID assertion with 100ms probe budgets. A clean pinned baseline passed 22/22 Chrome tests but did not reproduce the cause. Earlier local Memory focus hit a 120-second real-index reset/rebuild timeout under approximately 190 load on 16 CPUs; that run was then intentionally interrupted. The isolated full suites passed both cases (PID check 8ms; reset/rebuild 8.45s), but those replays do not establish the original cause or prove a fixture fix. Assertions, skips, retries, timers, and budgets remain unchanged.
Supplemental preservation checks
Exact-source differential comparisons passed 98,304 complete Browser description strings, 648 tab-store admission/CAS/result/cleanup traces, 96 durable-reader cases, 4,371 Memory reflection cases, 162,047 tokenization cases plus 961 similarity pairs, 108,573 URL token streams plus 20,008 matching cases, and 66,336 Markdown chunk-setting cases. Twelve failure/retry traces also preserve failed-close quarantine behavior. These supplement owner tests; they are not new committed tests or live-browser claims.
Only four existing test files adapt retired private seams. Their assertions and budgets are retained; no test cases or CI jobs are added.