Skip to content

refactor(browser,memory): consolidate repeated handlers and lifecycle work - #167734

Merged
steipete merged 2 commits into
mainfrom
deslop/d18-p2-20261007
Oct 9, 2026
Merged

steipete merged 2 commits into
mainfrom
deslop/d18-p2-20261007

Conversation

@steipete

@steipete steipete commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

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.

  • Full-directory consolidation proof on AWS: 3,307 Browser tests in 119.67s, 1,712 Memory Core tests in 601.56s, and 275 executions across 19 related host-SDK/provider files in 123.65s. Existing skips are unchanged.
  • After the final private-helper placement adjustment: 57 batch/error, curated-query, OpenAI, and Voyage tests passed locally. After rebasing: 219 integration tests across 10 files passed, including timeout propagation, cross-agent ownership, legacy pruning, authority expiry, and cleanup/CAS settlement.
  • Core production and all 27 core test graphs passed at the consolidation checkpoint; core/package graphs were repeated after the SDK follow-up, and extension production/test graphs were repeated after rebase. Both final cycle checks report zero cycles. All three lint-suppression tests, three wrapper-source-closure tests, and the selected wrapper-inventory test passed.
  • The supported five-facade Memory SDK comparison reports no entrypoint, export, or reachable-declaration changes. The SDK follow-up is patch-identical after rebase. Fresh independent review of the rebased branch completed all three partitions with no P0–P2 findings.

The local node scripts/check-changed.mjs run passed its earlier guards and typechecks, then stopped at four inherited Knip unused exports: bindCliQuestionAnswerAuthority, prepareSessionEventTargetForHost, readSessionEntryCreationTransition, and RESTART_CONTINUATION_CONTEXT_PREFIX. All four also fail in scheduled main check-dependencies at 53868c16088fd9cc86e84340178d8291c7a6f133. 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:extensions then 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 under CI=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.

@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 9, 2026 08:59
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 9, 2026
@clawsweeper

clawsweeper Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR consolidates repeated browser request handling and memory indexing, ranking, and cleanup code while preserving existing behavior.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful consolidation with no actionable finding, supported primarily by test and harness validation.
Proof confidence 🦐 gold shrimp (3/6) This established area-owner internal refactor is outside the ordinary external-contributor proof gate. The body records Browser, real-manager, SDK, ownership, and cleanup validation, but no new shipped-entry-point demonstration; source inspection supports unchanged stored formats and migration outcomes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes
Reason: The established area owner continues the previously merged consolidation direction. Removing repeated private orchestration lowers maintenance cost without expanding product surface.

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
Reviewed head: 590e4d1ecc426fd45baf50ccbc1e7a8fb92919d5

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied validation exercises tests and preservation harnesses; it does not establish a new shipped CLI or live-browser demonstration for this internal refactor.
Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Applicable repository policy: Read the full root and extensions AGENTS.md files. Applied shared ownership, private plugin boundaries, preservation of stored contracts, and meaningful-test guidance; no applicable deeper AGENTS.md or maintainer-notes directory was found. (AGENTS.md:1, 590e4d1ecc42)
  • Pinned introduced changes: Inspected the merge-base-to-head changes across Browser, Memory Core, and the memory host SDK, including the paths omitted from prompt metadata. The changes consolidate private implementations rather than add configuration or dependency surface. (590e4d1ecc42)
  • Distinct follow-up work: refactor: consolidate browser and memory plugin internals #166973 merged as 80e08db and describes the same established consolidation direction. This PR builds on that implementation; the earlier merge does not implement its remaining private-handler and lifecycle changes. (80e08db71014)
  • Main and merge context: Verified the test merge's recorded parents are the supplied base and exact PR head. Main changes in the touched memory modules occupy separate hunks, and subsequent changes between that base and fetched main do not touch this PR's production files. (fec7f6938886)
  • Stored-format compatibility: The FTS builder retains the six trigger definitions, names, columns, row identities, and SQL text. Markdown chunking retains version 5, hashes, entry spans, and remapping; Doctor consolidation retains migration IDs and existing import, preservation, and cleanup decisions. (packages/memory-host-sdk/src/host/memory-schema-fts.ts:105, 590e4d1ecc42)
  • Publication lifecycle preservation: Publication lifetime moves into the database owner while retaining the canonical worker execution, run-before-close ordering, aggregated failures, and final lifecycle reset. The retry owner distinguishes successful publication from a declined preparation before discarding staged input. (extensions/memory-core/src/memory/manager-database-context.ts:629, 590e4d1ecc42)

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

Metric Value Why it matters
Production versus tests Production +2,123/-3,185; tests +33/-40 The consolidation removes 1,062 net production lines, and test edits adapt existing private interfaces without adding cases.

Labels

Label changes:

  • add P3: This is internal maintenance with no intended user-visible change or demonstrated urgent regression.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This is internal maintenance with no intended user-visible change or demonstrated urgent regression.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

Reviewed October 9, 2026, 5:07 AM ET / 09:07 UTC.

@steipete
steipete merged commit 51de49c into main Oct 9, 2026
223 of 224 checks passed
@steipete
steipete deleted the deslop/d18-p2-20261007 branch October 9, 2026 09:14
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 10, 2026
… 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: browser extensions: memory-core Extension: memory-core P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL 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