Repository navigation
feat(knowledge): bundle the Knowledge memory plugin - #180139
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 bundles Knowledge as an optional memory plugin with evidence-backed records, retrieval, shared stores, and a Control UI explorer. Example: An operator selects plugins.slots.memory: "knowledge".
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this maintainer-authored PR open: optional Knowledge bundling has clear value, and the previously reported physical-store pinning defect is fixed. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherKnowledge consumes host-issued agent and operator authority, resolves the authorized store and partition, and serves memory operations through plugin-owned workers and vault files. flowchart TD
A[Agent tools] --> C[Knowledge service]
B[Control UI] --> C
C --> D[Host authority and store resolution]
D --> E[Storage worker]
E --> F[SQLite journal and search index]
E --> G[Markdown vault and evidence]
Technical reviewBest possible solution: Bundle Knowledge through the existing plugin owners while preserving live authority checks, existing stores, and the documented standalone transition. Do we have a high-confidence way to reproduce the issue? This is a feature import; source inspection confirms that Knowledge is absent from fetched main and registered by this PR. Is this the best way to solve the issue? The implementation fits the existing feature-plugin, memory-provider, worker, and config-writer owners without introducing a competing core memory system. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ec3cfa5f72da. Provenance checked
TestingProof path: shipped entry point. 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 HistoryReview history (10 earlier review cycles; latest 8 shown)
Reviewed October 25, 2026, 1:06 PM ET / 17:06 UTC (Revision 11). |
d78ac96 to
7e02dc7
Compare
5f50cb4 to
64a8959
Compare
|
Subject inference ( When the agent passes In the example, "Atlas acquired nimbus." links to Atlas, which is the claim's subject. A claim only ever links to a page its text names, and keyword search still finds the claim through "nimbus". Removing inference means claims saved without |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
What Problem This Solves
Knowledge, the evidence-backed memory plugin, ships separately from OpenClaw, so it can drift from core and users have to install and load it themselves.
User Impact
User impact: Knowledge ships with OpenClaw as a bundled plugin, off by default. Setting
plugins.slots.memory: "knowledge"turns it on. Existing stores keep working: the bundled build opened a copy of a real standalone-Knowledge store without a migration step.People who installed the standalone plugin need a manual switch, because an installed copy takes precedence over the bundled one.
openclaw plugins uninstall knowledgealso clearsplugins.entries.knowledge.config, includingstores. The Knowledge guide lists a safe save, uninstall, enable and restore order. No vault data is touched.Why This Change Was Made
The plugin moves into
extensions/knowledgeand now follows the repository rules for bundled plugins:knowledge_attach_filetool attaches a file from the agent's workspace by path, reusing the durable chunked-upload path, so the model no longer copies attachment bytes through its context.One part needs maintainer review: keyword search keeps its SQLite FTS5 index.
scripts/database-dialect-inventory.mtsnow excludesfts5,temp-schemaandrowidinextensions/knowledge/src/retrieval.tsonly, through the same mechanism as the existing SQLite-only exclusions. The reasons:state.sqliteand is never opened through the PostgreSQL-capable database layer.docs/reference/database-schemas/storage-changes.mddocuments the exclusion. Tests prove that other constructs in that file, andfts5anywhere else, still fail the ratchet. If this exclusion isn't acceptable, the fallback is scoring search in TypeScript inside Knowledge.The config-surface baseline grows by 28 entries. They are Knowledge's own config schema (
stores, write and read policy, maintenance), now part of the bundled inventory.The plugin's tests count toward the repository's test-lines ceiling (
config/test-lines-baseline.txt). They put the total 3,027 lines over it, so the suite was trimmed by about 2,750 net lines:delegated-access.test.ts(the same denials are proven inreal-vault.test.tsandmemory-provider.test.ts),search-detail.test.ts(folded into the realgreptool path inretrieval.test.ts), and the document and meeting port tests inworkflows.test.ts.it.eachtables, and repeated hand-built vaults now use the shared fixtures.Every authority, partition-isolation, path-escape, crash-recovery, integrity and regression test is kept. Main's own test removals have since brought the total under the unchanged ceiling (6,349,139 of 6,362,000), so this PR leaves the ceiling alone.
Evidence
Upgrade on real data. I took a consistent copy (SQLite online backup) of a live standalone-Knowledge state directory: 487 MB, 2 stores, about 76k state pages. An isolated Gateway built from this branch opened it on port 19390 with Knowledge as the memory slot:
status: the store isreadyand live watching is on.readyand returns ranked hits.records,timeline,history(gitcommitted) andconnectionsall succeed.createKnowledgeServiceand saved a claim withremember. The receipt came backpublished, the claim count went from 1,097 to 1,098, and keyword search found the new claim.Authority at the final effect, bundled Gateway. An isolated Gateway built from this branch, plus the memory-audience fixes (fix(memory): memory tools fail for owner sessions started by sessions_send and cross-agent subagents #181359), with a real model and agents
main/fm-know. Probe sessions saved claims withknowledge_remember, and the vault path shows the partition:sessions_send, and owner cross-agentsessions_spawnchild all published tostores/<id>/vault/private/claims/….vault/conversations/<sessionId>/claims/…. The sameknowledge_grepquery returnedno hitsfor it and the three private probe claims for the owner. A non-adminknowledge_recordon a private claim's exact ID returned not found.agent_query status) andmemory.searchrefuseoperator.read/operator.writeand succeed foroperator.admin.storage-worker.test.ts(authority revoked mid-operation publishes nothing),stores.test.ts(the cutover fences old-assignment access),live-state.test.ts(in-flight operations leave no accepted write),session-activity.test.ts(revoked authority fails delivery). Gap: there is no live trace of a reset racing a queued write.knowledge_attach_filethrough a bundled Gateway. An isolated Gateway ran this branch'sdistat46415c3e63cwith Knowledge as the memory slot andopenai/gpt-5.6-sol. The turn ran in a direct session created withsessions.create, which the host granted an owner-private memory audience. The agent workspace heldproof/notes.md(87 bytes);outside/secret.txtsat next to the workspace, with a symlink to it atproof/link-out.txt. Tool calls and results from the session transcript:The retained
vault/private/artifacts/e5807468-…/notes.mdis byte-identical to the workspace original (same SHA-256). Neithersecret.txtnor its marker text appears anywhere under the Knowledge state directory. The agent's first attempt at the allowed file passedexpectedVaultId: "", copied from the status of a store that did not exist yet, and the input schema rejected it; the retry omitted the field.Review fixes, now on head
e7c62d534a2(rebased ontomain93a374a9c95, which includes fix(memory): memory tools fail for owner sessions started by sessions_send and cross-agent subagents #181359; the core commits it carried were dropped as identical to the merged code; the only conflicts were the generated config baseline and worker inventory, regenerated with their generators). Each regression test fails without its fix and passes with it:allowsAgent()andisSharedGateway()checks (fix(memory): memory tools fail for owner sessions started by sessions_send and cross-agent subagents #181359). Knowledge calls them each time it re-resolves the principal.real-vault.test.ts > a role or roster change after admission refuses the operator read before disclosureadmits under the old policy and is refused at the recheck before records are returned.memory-index-hook.test.ts > keeps the rendered index byte-stable when a record is renamed mid-sessionfails without the pin. A Gateway restart re-renders once (accepted).74f001f8ec1, state databases were admitted once perdevice:inode, so a recreated or restored database on a recycled inode skipped schema creation (no such table). Admitted inodes must now also carry the current schema stamp.storage-schema.test.ts > a legacy database written into an already admitted inode is admitted againreproduces it deterministically by rewriting an admitted file in place.extensions/knowledgesuite: 51 files, 405 tests pass (49 files, 364 tests after the test trim described above). Plugin contract, host-hook and memory-provider tests pass;tsgo:extensions,tsgo:core,config:docs:checkanddb:worker-inventory:checkpass.Registry sentinel recovery.
2ac79915156completes an emptyregistry.idfrom the verified registry ID before comparing it. Its regression test,stores.test.ts > an interrupted sentinel write is completed; a sentinel naming another registry is refused, fails with the previousstore-registry.ts(1 failed / 24) and passes with the fix (24 / 24).Build.
pnpm buildpasses, and Knowledge loads fromdistwith originbundled.Rebased onto current
main(0843b940a56, which includes fix(plugins): reload edited bundled code without restarting the gateway #180466). Two real conflicts:mainadded a v31rowidexclusion toscripts/database-dialect-inventory.mtsand its test in the same spots as this PR's FTS5 exclusion, so both exclusions are kept and the test covers both files. The config baseline and worker inventory were regenerated with their generators. On head64a8959f4cb: the dialect ratchet (against0843b940a56), its 39 tests, the worker-inventory, config-baseline, plugin-inventory and skill-reference checks,tsgo:extensions, Knowledge oxlint, the import-cycle check andpnpm buildall pass.Tests. Under Node (the CI runtime),
OPENCLAW_VITEST_RUNTIME=node pnpm test:extension knowledgepassed on3a28571f0ae(the rebase before the attachment commits): 48 files, 385 tests, in 13m7s. On head64a8959f4cb(49 files, 391 tests), 390 passed. The one failure waspublication.test.ts > cross-process publishers fence competing edits and never lose the winner, which saw revision 4 instead of 2 while the winner's hash was correct. It passed 3 of 3 runs alone, and passed in the earlier full run. The attachment commits don't touch publication, so I'm treating it as a rare timing-sensitive failure under load, tracked as a follow-up, not a regression from this head.fix(knowledge): bound Markdown block runs before link lexingfixes the Bun-only slowness inrecord-capacity.test.ts > near-limit records…: JavaScriptCore gave up onmarked's paragraph regexp after ~49K lines and fell back to line-by-line lexing. CI runs Node, so CI wasn't affected.Control UI. Screenshots from an isolated Gateway on this build (origin
bundled), seeded with the synthetic sample vault. Knowledge is a new page, so there's no "before".Gates.
pnpm check:changedpasses every gate that covers Knowledge, including typecheck, the dialect, worker and assertion ratchets, and import cycles. The dead-export scan flagged two of this PR's re-exports. I removed them, and the scan is now clean. Three gates fail only on files this PR doesn't touch:ui/,src/andextensions/{telegram,crabbox}max-linessuppression ratchet, forui/filesReview. Autoreview (Codex
gpt-6.1-sol, branch mode, P0 threshold) returnedscoped-cleanacross 5 passes.Simplify.
pr-simplifyremoved a test-onlyPublisherrename alias and two unusedMAX_ENTRIESre-exports. Two things remain by design:includeMetadatatool input stays, because agents already use it with the published plugin.Diff against the merge base: about 53.7k lines added. Roughly 26.5k is production TypeScript and 3.3k CSS. The rest is tests (14.7k), docs (8.1k) and fixtures, ontology and skills.