Skip to content

refactor(plugins): deslop browser and memory-core second pass - #158172

Merged
steipete merged 2 commits into
mainfrom
deslop/l47-browser-memory2
Sep 25, 2026
Merged

steipete merged 2 commits into
mainfrom
deslop/l47-browser-memory2

Conversation

@steipete

@steipete steipete commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Second-pass cleanup of repeated browser and memory-core orchestration and internal forwarding layers, following #156742 and #156867.

User Impact

No intended user-visible change. Browser launch/attach, profile isolation, navigation/SSRF and transfer-path checks, screenshot/snapshot shapes, and model-facing tool definitions are preserved. Memory schemas, persistence, retention, provider selection, indexing/recall order, and bounded dreaming/compaction output are unchanged. This refactor adds no migration or operator action.

Why This Change Was Made

  • Browser registration and execution share the same tool definition and lazy CLI registration. CLI commands, Doctor profile collection, and node timeout projection reuse their existing owners.
  • Browser routes share guarded action responses, download-mode preparation, tab listing/focus, and disposable abort propagation. SDK consumers import the canonical seam directly instead of plugin-internal forwarding barrels.
  • Playwright dispatch forwards the normalized action contract while retaining narrower resize/close policy inputs. The page owner initializes page state; callers no longer repeat that work. Operation, cookie, and device types come from their owners.
  • Chrome discovery shares the existing ordered candidate lists; profile decoration edits each nested preference object once. Installation paths and snapshot conversion use canonical helpers.
  • Memory's targeted-session queue owns its state instead of receiving eleven forwarding accessors. Provider-result projection and repeated search call shapes share one implementation; redundant search preflight and inherited state declarations are removed.
  • Runtime ingestion and Doctor share checkpoint codecs/writers, preserving namespaces, chunking and ordering. REM scoring preserves ordered weights, and dreaming/consolidation share bounded formatting and normalization helpers.

Production reduction: 1,344 net lines (+1,406 / -2,750): 911 in browser and 433 in memory-core. Tests and test support: 189 net lines removed. All 187 production files over 200 lines were read largest-first and recorded with changes or reasons for retention; smaller production files and callers were also read. No SDK exports changed. The model-facing schema source files are unchanged.

Compatibility review

The config and stored-data flags are path-based detections, not contract changes. Browser config keys and defaults are unchanged; the shared headless-source type retains the same six values. Memory Core still writes the same daily/session ingestion namespaces, state versions, key formats, hash chunks, and ordering. No SQL schema, table, retention, or transaction contract changes. The published 2026.9.6 updater → candidate Doctor proof below verifies migration, backup, idempotence, and installed Gateway convergence against existing synthetic state.

Fixes found along the way

No independent product bug or flaky test was established. Initial proof caught refactor-related mock bindings, an obsolete duplicate page-initialization assertion, dependency type mismatches, and lint issues; those were corrected at their owners without weakening safety or lifecycle assertions. The initial hosted CI run found a type-only dependency cycle introduced by importing the shared headless-source type from runtime config. Moving the unchanged type to the existing profile-types leaf and migrating all three consumers fixed the cycle. Fail-fast cancelled the other CI jobs; they were not independent Windows or build failures.

Evidence

Task-run validation used Linux Blacksmith Testbox. Browser behavior, live smoke, and memory proof were retained across the final type-only relocation; architecture, changed-file checks, and the full build cover the repaired type graph. The final staged Git tree (5fa520d8cb8ec2c3b4de0d4ec273290ace560fa4) exactly matches the hash-verified Testbox source.

Completed proof:

  • Hosted CI on db716b408fb: passed. Architecture 337s; build 375s; selected changed-extension test jobs 160–308s; Windows test shards 308–505s (job wall time, including setup and uploads). The aggregate passed after an approximately nine-minute Blacksmith runner-assignment wait; no tests were rerun for that wait.
  • node scripts/check-changed.mjs --base 21ce88bcff93f243b9d3ffe90a38a045295dc55d: passed (618s), including formatting, type lanes, plugin boundaries, all three dead-export scans, lint, storage and runtime guards.
  • Explicit-path node scripts/check-changed.mjs for the four repaired browser files: passed (722s) on the final tree. Explicit file selection avoids the Testbox clone's missing published-branch history; all selected type, lint, export, storage, and runtime guards ran.
  • pnpm test:extensions:batch browser: 4,840 passed, 116 existing skips; 97s; retained across the final type-only relocation.
  • pnpm build: passed (637s on the final clean build), including declaration emission, SDK exports, and CLI bootstrap validation.
  • pnpm test:extensions:batch memory-core: 2,079 passed, 4 existing skips; 433s.
  • Affected cross-area consumer selection: 49 passed and 1 opt-in browser proof skipped across four shards; 69s. The opt-in browser authority proof was run explicitly afterward and passed (46s).
  • Browser tool-definition and Chromium capability parity against the pinned base: 652 configurations passed, including driver, loopback, and attach-only combinations.
  • Real CLI → isolated Gateway → Chromium smoke: start, isolated user-data directory, snapshot, click, evaluate, timezone, locale, screenshot, close, and stop passed (85s). Explicit authority proof also verified revoked startup/navigation cannot reach its destination.
  • Public runtime API guard: 7 cases passed (18s). No SDK export changes.
  • pnpm test:docker:dreaming-cron-doctor: passed (965s), using the published [email protected] updater and a hash-verified candidate. Verified the updater-owned Doctor child, backup, idempotence, and installed Gateway convergence without changing authored or inactive cron rows.
  • GOGC=30 GOMEMLIMIT=3GiB pnpm check:architecture: passed (278s), including zero Madge cycles, wrapper ownership, Kysely, and storage guards.
  • Independent Codex review: the full refactor and subsequent type-only repair are complete and clean through P2.

Validation used blacksmith-testbox leases tbx_01m3c42f9n9mz6deamnrbpxjxs (initial run) and tbx_01m3c9zn5wpfmxx8ezexd4ndq9 (completion run). The first job was cancelled during upgrade-package preparation after the completed checks above; its cancellation cause was not established. Missing checks were resumed on the second lease. Both initial leases are stopped. The type-only CI repair used tbx_01m3chfhkgv6cxav7jks0ajkjq (repair proof run); its final wrapper command exited 0. That lease is also stopped.

Changed-test command costs

Measured on Linux Testbox with pnpm test <file> --maxWorkers=1; wall time includes process startup. No test cases were added.

Test file Wall
extensions/browser/src/browser/bounded-utf8-tail.test.ts 2s
extensions/browser/src/browser/chrome-mcp.test.ts 16s
extensions/browser/src/browser/control-auth.auto-token.test.ts 16s
extensions/browser/src/browser/pw-tools-core.browser-ssrf-guard.test.ts 35s
extensions/browser/src/browser/routes/agent.existing-session.test.ts 16s
extensions/browser/src/browser/routes/agent.shared.test.ts 16s
extensions/browser/src/browser/routes/agent.snapshot.local-managed.test.ts 15s
extensions/browser/src/browser/routes/agent.snapshot.timeout.test.ts 15s
extensions/browser/src/browser/server.agent-contract-core.test.ts 16s
extensions/browser/src/cli/browser-cli-actions-input/register.batch.test.ts 16s
extensions/browser/src/cli/browser-cli-actions-input/register.element.test.ts 15s
extensions/browser/src/cli/browser-cli-actions-input/register.files-downloads.test.ts 15s
extensions/browser/src/cli/browser-cli-actions-input/register.form-wait-eval.test.ts 16s
extensions/browser/src/cli/browser-cli-actions-input/register.navigation.test.ts 16s
extensions/browser/src/cli/browser-cli-actions-observe.test.ts 20s
extensions/browser/src/cli/browser-cli-cookie-sync.test.ts 20s
extensions/browser/src/cli/browser-cli-debug.test.ts 18s
extensions/browser/src/cli/browser-cli-extension.posix-upgrade.test.ts 19s
extensions/browser/src/cli/browser-cli-extension.test.ts 17s
extensions/browser/src/cli/browser-cli-extension.windows-setup.test.ts 17s
extensions/browser/src/cli/browser-cli-inspect.test.ts 18s
extensions/browser/src/cli/browser-cli-shared.test.ts 2s
extensions/browser/src/cli/browser-cli-state.option-collisions.test.ts 16s
extensions/browser/src/cli/browser-cli.lazy.test.ts 16s
extensions/browser/src/gateway/browser-request.profile-from-body.test.ts 17s
extensions/browser/src/gateway/browser-request.timeout.test.ts 18s
extensions/browser/src/gateway/session-browser-request.test.ts 17s
extensions/browser/src/plugin-service.test.ts 17s
extensions/memory-core/src/cli.test.ts 21s
extensions/memory-core/src/dreaming-phases.test.ts 32s
extensions/memory-core/src/memory-forget.test.ts 28s
extensions/memory-core/src/memory/index.test.ts 79s
extensions/memory-core/src/memory/manager-provider-state.test.ts 18s
extensions/memory-core/src/memory/manager-session-update-race.test.ts 36s
extensions/memory-core/src/memory/manager-sync-control.test.ts 2s
extensions/memory-core/src/session-backfill.test.ts 28s
test/scripts/lint-suppressions.test.ts 5s
Cross-shard consumer proof
node scripts/run-vitest.mjs \
  test/plugins/browser-session-authority.gateway.test.ts \
  packages/memory-host-sdk/src/host/session-memory-sync.test.ts \
  src/plugins/memory-runtime.owners.test.ts \
  src/agents/bootstrap-files.memory-core.test.ts \
  src/state/openclaw-memory-write-admission.test.ts \
  src/gateway/server-methods/memory-search.test.ts \
  src/plugins/contracts/plugin-sdk-runtime-api-guardrails.test.ts
OPENCLAW_BROWSER_SNAPSHOT_E2E=1 node scripts/run-vitest.mjs \
  test/plugins/browser-session-authority.gateway.test.ts
node scripts/check-changed.mjs -- \
  extensions/browser/src/browser/chrome.ts \
  extensions/browser/src/browser/client.types.ts \
  extensions/browser/src/browser/config.ts \
  extensions/browser/src/browser/profile.types.ts

Share browser registration, route orchestration, and documented SDK owners.
Consolidate memory queue state, search preparation, and ingestion checkpoints.

Preserve browser safety and tool definitions, memory schema and ordering,
and existing dreaming and compaction output. Remove 1,344 net production lines.
@clawsweeper

clawsweeper Bot commented Sep 25, 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 September 25, 2026 14:53
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. labels Sep 25, 2026
@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 25, 2026, 12:44 PM ET / 16:44 UTC (Revision 4).

ClawSweeper review

What this changes

The branch consolidates Browser plugin registration, guarded actions, and CLI wiring, and moves Memory Core queue and checkpoint logic to shared owners.

Warning

SQLite table change

This PR modifies persisted SQLite tables in extensions/memory-core/src/migration/doctor-dreaming-state.ts. Prefer a design that avoids changing persisted SQLite tables. Migration or upgrade compatibility proof is recorded, but maintainers should still confirm that the schema change is necessary.

Merge readiness

⛔ Blocked before merge - 1 item remains

The cleanup remains useful: current main lacks its shared Browser tool definition and Memory Core checkpoint writers. The earlier config compatibility concern is resolved by the source comparison and recorded upgrade proof; this review found no blocking defect.

Priority: P3
Reviewed head: db716b408fb1f60d8d4f913d09b9cee29117e605

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The branch has strong real-path and upgrade evidence, green exact-head CI, and no blocking defect found in the inspected refactor.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The Browser registration and action refactor is covered by the recorded real CLI → Gateway → Chromium start, interaction, snapshot, and stop results; the moved Memory Core checkpoint writer is covered by the recorded published-updater → candidate Doctor convergence and by source comparison. The checkpoint format remains compatible without a migration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The Browser registration and action refactor is covered by the recorded real CLI → Gateway → Chromium start, interaction, snapshot, and stop results; the moved Memory Core checkpoint writer is covered by the recorded published-updater → candidate Doctor convergence and by source comparison. The checkpoint format remains compatible without a migration.
Evidence reviewed 8 items Browser config compatibility: The PR replaces an alias with the same list normalizer and references the existing timeout constants directly; the six headless-source values move unchanged to the profile type.
Checkpoint compatibility: The moved session writer retains the prior namespaces, chunk size, entry keys, and write calls; Doctor now calls that writer.
Browser action boundary: Existing-session actions still pass admission and the guarded action wrapper before dispatch; navigation verification remains in that wrapper.
Findings None None.
Security None None.

How this fits together

The Browser plugin receives agent and CLI requests, checks profiles and navigation policy, then controls Chromium. Memory Core ingests workspace and conversation data into local state and an index used for recall.

flowchart LR
A[Agent or CLI request] --> B[Browser plugin]
B --> C[Profile and navigation checks]
C --> D[Browser action and result]
E[Workspace and conversation data] --> F[Memory Core]
F --> G[SQLite checkpoints and index]
G --> H[Recall result]
Loading

Before merge

  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
Agent review details

Security

None.

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

None.

Stored data model

Persistent data-model change detected: unknown-data-model-change: extensions/memory-core/src/dreaming-consolidation-artifacts.ts, unknown-data-model-change: extensions/memory-core/src/dreaming-ingestion-state.ts, unknown-data-model-change: extensions/memory-core/src/dreaming-phases.ts, unknown-data-model-change: extensions/memory-core/src/memory/manager-embedding-ops.ts, unknown-data-model-change: extensions/memory-core/src/memory/manager-index-generation-lease.ts, unknown-data-model-change: extensions/memory-core/src/memory/manager-provider-lifecycle.ts, and 29 more. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Technical review

Best possible solution:

Keep the verified browser safety, configuration, and stored-state contracts intact when this owner-level cleanup is merged.

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

Not applicable: the PR claims behavior-preserving cleanup rather than a reported bug; its Browser and Memory Core validation checks parity.

Is this the best way to solve the issue?

Yes. The inspected changes remove forwarding and duplicate ownership while keeping the relevant Browser guards, config values, and checkpoint format.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 478cb42bf138.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is an internal cleanup with no intended user-visible behavior change.
  • 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 (terminal): The Browser registration and action refactor is covered by the recorded real CLI → Gateway → Chromium start, interaction, snapshot, and stop results; the moved Memory Core checkpoint writer is covered by the recorded published-updater → candidate Doctor convergence and by source comparison. The checkpoint format remains compatible without a migration.
  • proof: sufficient: Contributor real behavior proof is sufficient. The Browser registration and action refactor is covered by the recorded real CLI → Gateway → Chromium start, interaction, snapshot, and stop results; the moved Memory Core checkpoint writer is covered by the recorded published-updater → candidate Doctor convergence and by source comparison. The checkpoint format remains compatible without a migration.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Kimi Yu: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • WhatsSkiLL: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (3 earlier review cycles)
  • reviewed 2026-09-25T15:02:17.006Z sha 57b70cf :: blocked before merge. :: none
  • reviewed 2026-09-25T16:14:11.237Z sha db716b4 :: blocked before merge. :: none
  • reviewed 2026-09-25T16:31:24.524Z sha db716b4 :: blocked before merge. :: none

Move the unchanged headless-source union to the existing profile contract
and migrate config, Chrome, and client types directly to that leaf owner.
This removes the type-only cycle caught by the architecture gate.
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Config compatibility review is complete for db716b408fb1f60d8d4f913d09b9cee29117e605:

  • config.ts removes the normalizeStringList alias and calls the same normalizeOptionalTrimmedStringList function directly. Both hostname normalization and MCP argument normalization retain the same implementation.
  • The five timeout fields now reference the same DEFAULT_BROWSER_* constants directly instead of equivalent local variables. No timeout value, config key, default, precedence, or migration behavior changes.
  • ManagedBrowserHeadlessSource moves unchanged to the existing profile.types.ts leaf; all three consumers use that owner. Its six string literals are identical, and no runtime code changes in the CI correction.
  • Chromium capability projection passed the recorded baseline parity comparison across driver, loopback, and attach-only combinations. The browser batch and real CLI → Gateway → Chromium proof passed.

The SQLite warning is also a path-based classification: no table definition, SQL schema, state version, retention policy, or transaction contract changes. doctor-dreaming-state.ts delegates the same checkpoint writes to the shared owner. The published 2026.9.6 updater → candidate Doctor proof passed with backup, idempotence, and installed Gateway convergence; full architecture/Kysely guards also passed.

The PR body's Compatibility review and Evidence sections contain the completed proof. Please assess the remaining config checklist item against this source comparison and compatibility confirmation.

@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete merged commit b976624 into main Sep 25, 2026
207 checks passed
@steipete
steipete deleted the deslop/l47-browser-memory2 branch September 25, 2026 17:12
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 26, 2026
…aw#158172)

* refactor(plugins): deslop browser and memory-core second pass

Share browser registration, route orchestration, and documented SDK owners.
Consolidate memory queue state, search preparation, and ingestion checkpoints.

Preserve browser safety and tool definitions, memory schema and ordering,
and existing dreaming and compaction output. Remove 1,344 net production lines.

* fix(browser): break headless source type import cycle

Move the unchanged headless-source union to the existing profile contract
and migrate config, Chrome, and client types directly to that leaf owner.
This removes the type-only cycle caught by the architecture gate.
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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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