Skip to content

refactor(memory): split LanceDB plugin entry - #113772

Merged
steipete merged 2 commits into
mainfrom
codex/h4-lancedb
Jul 25, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/h4-lancedb

Conversation

@steipete

@steipete steipete commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The LanceDB memory plugin entry had grown to 2,106 lines and mixed manifest registration, embeddings, CLI parsing, capture policy, transport-envelope sanitization, tools, and lifecycle hooks in one file. That made the plugin difficult to review and kept it on the max-lines suppression baseline.

Why This Change Was Made

This behavior-neutral refactor keeps manifest registration, long-lived typed hooks, and live runtime config resolution in extensions/memory-lancedb/index.ts, while moving embeddings, CLI parsing/registration, capture policy, and transport-envelope sanitization into focused modules. The sanitizer remains one intact plugin-owned block because it mirrors private core envelope contracts that bundled plugins cannot import directly.

Beyond the split

  • Removed an impossible defensive branch after the CLI filter regex has already guaranteed the required capture groups.
  • Collapsed equivalent final boolean decisions in capture and envelope policy without changing their predicates.
  • Made extraction-only helpers private after deadcode proof showed they have no external production consumers.
  • Removed syntax-narrating comments while preserving lifecycle, ownership, timeout, sanitization, and security invariants.

User Impact

No user-visible behavior, config, storage schema, protocol, dependency, or lazy-import behavior changes. Maintainers get smaller modules with the same manifest entry contract, hook ownership, and public named exports.

Evidence

  • LOC: production +1479/-1482; tests +0/-0; overall +1479/-1483.
  • node scripts/run-vitest.mjs extensions/memory-lancedb/index.test.ts — 137/137 tests passed.
  • node scripts/run-vitest.mjs src/plugins/contracts/boundary-invariants.test.ts — 13/13 tests passed.
  • node scripts/crabbox-wrapper.mjs run --provider blacksmith-testbox --timing-json -- bash -lc 'corepack pnpm deadcode:exports && corepack pnpm check:changed && corepack pnpm build' — passed on Blacksmith Testbox tbx_01kyd5gqrrqchb3z6twb4qemwb; deadcode exports, extension prod/test typechecks, lint, formatting, max-lines ratchet, plugin boundaries, SDK contracts, import cycles, and full build all green (run). No [INEFFECTIVE_DYNAMIC_IMPORT].
  • .agents/skills/autoreview/scripts/autoreview --mode uncommitted --stream-engine-output — clean, no accepted/actionable findings (0.98 confidence).
  • Clean rebase sanity on origin/main@a1d666fdc3f; numstat unchanged.

The first hosted run correctly caught that typed hook registration must remain in the manifest entry and that extraction-only exports were unused. The final structure incorporates both findings without changing contract inventories or weakening gates.

Bugs Found

None.

Placement Findings

None. The envelope sanitizer intentionally stays plugin-local: its comments identify the private core producer contracts it mirrors, while the extension boundary forbids importing those internals.

Baseline

Removed extensions/memory-lancedb/index.ts from config/max-lines-baseline.txt; every resulting file is under budget (largest: 665 lines).

AI-assisted maintainer-commissioned refactor; the implementation and proof were reviewed before submission.

@openclaw-barnacle openclaw-barnacle Bot added the extensions: memory-lancedb Extension: memory-lancedb label Jul 25, 2026
@steipete
steipete marked this pull request as ready for review July 25, 2026 17:19
@openclaw-barnacle openclaw-barnacle Bot added size: XL maintainer Maintainer-authored PR labels Jul 25, 2026
@steipete

steipete commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Land-ready proof for head d4cd5cded63645de4416a7a4d11519677f8135ed:

  • node scripts/run-vitest.mjs extensions/memory-lancedb/index.test.ts — 137/137 passed.
  • node scripts/run-vitest.mjs src/plugins/contracts/boundary-invariants.test.ts — 13/13 passed.
  • Blacksmith Testbox run 30167922370, lease tbx_01kyd5gqrrqchb3z6twb4qemwb — deadcode:exports, check:changed, and build passed; no ineffective dynamic-import warning.
  • Exact-head GitHub CI run 30168446994, attempt 2 — green after rerunning one unrelated ENOTEMPTY temp-directory flake.
  • Fresh Codex autoreview — clean, no accepted/actionable findings (0.98 confidence).
  • Final numstat: production +1479/-1482; tests +0/-0; overall +1479/-1483.

Known proof gaps: none.

ClawSweeper rank-up move handled: OPENCLAW_TESTBOX=1 scripts/pr prepare-run 113772 refreshed the current-main merge result and passed the hosted exact/recent-parent gate without rewriting the already-green PR head.

@clawsweeper

clawsweeper Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 25, 2026, 1:55 PM ET / 17:55 UTC.

ClawSweeper review

What this changes

This PR splits the bundled LanceDB memory plugin’s 2,106-line entry module into embeddings, CLI, capture/sanitization, and policy modules while retaining manifest registration, lifecycle hooks, and live configuration resolution in the entry file.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for normal maintainer review. The branch is a focused, behavior-neutral internal refactor that preserves the LanceDB plugin entrypoint while extracting cohesive implementation areas; the supplied focused tests, hosted full checks, and PR-local follow-up commit support the intended boundary. Its maintainer label prevents automated cleanup, and the branch should receive a current-main refresh because it was based on a1d666fdc3f while the checkout is now at 6f1950ec1a1b1fac6744fc6779aa2c81a1b71217.

Priority: P3
Reviewed head: d4cd5cded63645de4416a7a4d11519677f8135ed

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong focused and hosted validation supports a clean refactor, with a current-main refresh still needed before merge.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: This is described as a maintainer-commissioned internal refactor, so the external-contributor live-proof gate does not apply; focused entry tests and hosted full checks provide appropriate regression evidence.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is described as a maintainer-commissioned internal refactor, so the external-contributor live-proof gate does not apply; focused entry tests and hosted full checks provide appropriate regression evidence.
Evidence reviewed 4 items Focused refactor surface: The branch reduces extensions/memory-lancedb/index.ts to the manifest-entry and hook/configuration boundary, with extracted modules for embeddings, CLI parsing, policy, and capture-envelope sanitization. The PR description explicitly preserves the public entry contract and reports no config, schema, dependency, or protocol change.
Boundary-preserving follow-up: The follow-up commit is specifically titled refactor(memory): keep hooks in plugin entry, matching the repository policy that plugin entry registration and long-lived typed hooks remain at the plugin-loader boundary rather than moving into a private helper module.
Validation evidence: The PR reports 137 passing LanceDB entry tests, 13 plugin-boundary contract tests, and a Blacksmith Testbox run covering dead exports, changed checks, lint/formatting, max-lines ratchet, plugin boundaries, SDK contracts, import cycles, and the full build. The provided GitHub check state also shows the relevant fast checks and real-behavior-proof gate succeeding, with remaining matrix shards still running.
Findings None None.
Security None None.

How this fits together

The LanceDB memory plugin receives agent lifecycle and CLI inputs, resolves plugin configuration and embeddings, then captures and recalls long-term memory through its storage and tool paths. The entry module is the plugin loader boundary, while the extracted modules implement internal policy and data-processing work.

flowchart LR
  A[Agent lifecycle and CLI inputs] --> B[LanceDB plugin entry]
  B --> C[Configuration and lifecycle hooks]
  C --> D[Embeddings and LanceDB storage]
  C --> E[Capture policy and sanitization]
  D --> F[Recall and memory tools]
  E --> F
Loading

Before merge

  • Add real behavior proof - Not applicable: This is described as a maintainer-commissioned internal refactor, so the external-contributor live-proof gate does not apply; focused entry tests and hosted full checks provide appropriate regression evidence.
  • Resolve merge risk (P1) - The PR is cleanly mergeable but behind current main; rebase or refresh the merge result against 6f1950ec1a1b1fac6744fc6779aa2c81a1b71217 before landing so the large move is reviewed against the current plugin implementation.
  • Complete next step (P2) - This needs normal maintainer merge review and a current-main refresh, not an automated repair; no discrete defect was found in the proposed refactor.
Agent review details

Security

None.

PR surface

Source -3, Other -1. Total -4 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 5 1479 1482 -3
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 6 1479 1483 -4

Review metrics

None.

Stored data model

Persistent data-model change detected: unknown-data-model-change: extensions/memory-lancedb/embeddings.ts, unknown-data-model-change: extensions/memory-lancedb/index.ts, unknown-data-model-change: extensions/memory-lancedb/memory-capture-sanitization.ts, unknown-data-model-change: extensions/memory-lancedb/memory-cli.ts, unknown-data-model-change: extensions/memory-lancedb/memory-policy.ts, vector/embedding metadata: extensions/memory-lancedb/embeddings.ts, and 4 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Rebase or refresh this branch against current main, retain the entrypoint-owned hooks and manifest registration, and land once the current merge result preserves the reported focused-test and boundary-check outcomes.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Rebase or refresh this branch against current main, retain the entrypoint-owned hooks and manifest registration, and land once the current merge result preserves the reported focused-test and boundary-check outcomes.

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

Not applicable: this PR is an internal refactor, not a report of broken runtime behavior. The relevant verification is preservation of existing plugin behavior through focused tests and boundary checks.

Is this the best way to solve the issue?

Yes. Keeping the plugin-loader entry and long-lived hooks in extensions/memory-lancedb/index.ts while extracting cohesive implementation modules is the narrowest maintainable split and follows the repository’s plugin-boundary guidance.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6f1950ec1a1b.

Labels

Label changes:

  • add P3: This is a behavior-neutral internal maintainability refactor with no reported user-facing change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.

Label justifications:

  • P3: This is a behavior-neutral internal maintainability refactor with no reported user-facing change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.

Evidence

What I checked:

  • Focused refactor surface: The branch reduces extensions/memory-lancedb/index.ts to the manifest-entry and hook/configuration boundary, with extracted modules for embeddings, CLI parsing, policy, and capture-envelope sanitization. The PR description explicitly preserves the public entry contract and reports no config, schema, dependency, or protocol change. (extensions/memory-lancedb/index.ts:1, d4cd5cded636)
  • Boundary-preserving follow-up: The follow-up commit is specifically titled refactor(memory): keep hooks in plugin entry, matching the repository policy that plugin entry registration and long-lived typed hooks remain at the plugin-loader boundary rather than moving into a private helper module. (extensions/memory-lancedb/index.ts:1, d4cd5cded636)
  • Validation evidence: The PR reports 137 passing LanceDB entry tests, 13 plugin-boundary contract tests, and a Blacksmith Testbox run covering dead exports, changed checks, lint/formatting, max-lines ratchet, plugin boundaries, SDK contracts, import cycles, and the full build. The provided GitHub check state also shows the relevant fast checks and real-behavior-proof gate succeeding, with remaining matrix shards still running. (extensions/memory-lancedb/index.test.ts:1, d4cd5cded636)
  • Current-main freshness: The PR base is a1d666fdc3fc6828152c041d8fe60930dd7e293f, while the target checkout is at 6f1950ec1a1b1fac6744fc6779aa2c81a1b71217; GitHub reports the PR as mergeable but behind. This needs a review refresh, not a correctness finding or merge-risk label. (extensions/memory-lancedb/index.ts:1, 6f1950ec1a1b)

Likely related people:

  • steipete: Authored both commits in this focused refactor and is also identified in existing LanceDB feature-history context as a current-main contributor for this plugin surface. (role: recent LanceDB feature contributor; confidence: medium; commits: 40b3bcc6c121, d4cd5cded636; files: extensions/memory-lancedb/index.ts, extensions/memory-lancedb/embeddings.ts, extensions/memory-lancedb/memory-cli.ts)
  • Radek Paclt: Existing feature-history evidence attributes the original vector-memory lifecycle and plugin behavior, later moved into the current LanceDB surface, to this contributor. (role: introduced vector-memory behavior; confidence: medium; commits: ebfeb7a6bf53; files: extensions/memory-lancedb/index.ts, extensions/memory-lancedb/index.test.ts)
  • Vignesh Natarajan: Existing feature-history evidence identifies recent auto-capture and recall hardening work in this same plugin-owned path, making this a relevant reviewer for capture-policy extraction. (role: recent retrieval-path contributor; confidence: medium; commits: 61725fb37e33, 8cb0373bc1e7; files: extensions/memory-lancedb/index.ts, extensions/memory-lancedb/config.ts, extensions/memory-lancedb/index.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Rebase or refresh the merge result against current main and confirm the focused LanceDB and plugin-boundary checks remain green.

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.

@steipete
steipete merged commit 822eaa5 into main Jul 25, 2026
172 of 178 checks passed
@steipete
steipete deleted the codex/h4-lancedb branch July 25, 2026 18:21
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: memory-lancedb Extension: memory-lancedb maintainer Maintainer-authored PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant