Skip to content

feat(knowledge): agents can no longer grow pages past a read-sized budget, and can extract sections instead - #186270

Merged
roboclaw-bot merged 10 commits into
mainfrom
openclaw/knowledge-page-budgets
Oct 28, 2026
Merged

roboclaw-bot merged 10 commits into
mainfrom
openclaw/knowledge-page-budgets

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Knowledge page bodies grow without limit when agents append to a page instead of integrating or splitting it. In the Team vault the OpenClaw project page reached 135,706 characters (about 95k in State across 37 subsections), more than eleven default knowledge_record reads, even though the knowledge-capture skill already asks agents not to do this.

User Impact

User impact: agents can no longer grow a page past its body budget: 12,000 characters for hub pages (one default record read) and 24,000 for other pages. Such a write saves nothing and returns a receipt with state: "rejected" that names the page's size, budget, hub degree, largest sections and connected pages the content could move to. Edits that keep a body the same size or smaller always succeed, including on pages that are already over budget, so existing large pages need no migration and can only shrink. Facts can always be saved as claims; claims are never limited.

A new knowledge_extract_section tool moves one heading section to a new or connected page in one revision-fenced publication.

New optional config: plugins.entries.knowledge.config.pageBudgets.hubPercentile (default 90), which josh asked to be configurable. This raises the plugin config-surface count from 4,887 to 4,889 (pageBudgets and pageBudgets.hubPercentile); docs/.generated/config-baseline.counts.json is updated for that.

This PR does not change the test-line ceiling: main has since raised it to 6,300,000, and the merged tree is under it (see Evidence).

Why This Change Was Made

Every page-body write already reaches StoragePublication.accept as a prepared record plus its previous revision, so the budget is enforced there once, against the same vault snapshot the publication is fenced on. That one check covers knowledge_save_page creates and edits, knowledge_edit_body, knowledge_publish_batch page items (and the ingest, scribe and memory-flush flows that use them), knowledge_merge with a combined body, and the destination of knowledge_extract_section. The rule is: reject when the body would be larger than before and larger than its budget. Corrections cannot replace pages (claims and relationships only), and withdraw, unmerge, annotate, recall, evidence reconciliation and knowledge_supersede never change a body. Markdown edited directly on disk is observed rather than gated; that is the one deliberate exception.

Budget, hub classification and extraction details
  • Budgets derive from TEXT_PAGE_DEFAULT_CHARS (12,000): hubs get one read, other pages two (24,000). Sizes are body UTF-16 code units, as record windows count them.
  • Hub signal: a page's degree is the number of distinct current pages linked to or from it by wikilinks or Markdown links. Typed relationships and claims do not count. A page is a hub when its percentile (the share of current pages in the partition with a lower degree) is at or above hubPercentile (default 90), the partition has at least 20 current pages, and the degree is at least 10. The top decile keeps hubs to a small set of routing pages. Below 20 pages one page spans five or more percentile points, and the degree floor keeps small or sparsely linked vaults from naming hubs.
  • Rejections are not journaled (no receipt or draft is stored, and replaying the request ID re-evaluates it). id/path/revision/hash describe the unchanged target (empty for a create). budget.pages[] has current and attempted sizes, the budget, hub status (degree, percentile, hubPercentile, minPages, minDegree), the six largest heading sections with offsets and subsection counts, and up to three connected pages per section that the section links to or names, with their remaining headroom. The message points to extraction and knowledge_remember, and says not to truncate.
  • Extraction takes source fences, the heading's sectionStart, a destination (fences of an existing page connected to the source by a link either way or a typed relationship, or {title, type} for a new page), a one-line summary and a reason. The section moves verbatim. Relative Markdown links are rewritten for the destination directory, and any other link that would resolve differently rejects the request. Source evidence whose quote, path or filename appears in the section is copied, and the source keeps all its evidence. The source keeps the heading line plus the summary and a [[id|title]] link. Claims the section links to that name the source as an entity get the destination as first entity, and keep the source only when the claim names it. The destination, the shrunk source and the relinked claims are validated together in a preview scan, and the destination's link targets and evidence are verified, before one publication is accepted, so a failure changes no file. The receipt has operation: "extract" and history keeps the old revisions. The destination's own budget applies.
  • Bundled skills (shared publish.md/publication.md synced into each skill, plus knowledge-capture, knowledge-claim-consolidation step 5, knowledge-entities and knowledge-ingest) and the Knowledge docs describe the budget and the extract tool. The docs tool count is 38: main's 37 registered tools (including knowledge_supersede) plus knowledge_extract_section.

Evidence

  • node scripts/run-vitest.mjs run extensions/knowledge on the tree merged with main at 3bcca4f: 56 of 57 files passed. The exception, live-state.test.ts, fails locally on this shared host because the user's inotify instance limit is exhausted (fs.watch returns EMFILE even in a fresh process). The file is unchanged by this PR, and PR CI runs it.
  • New page-budget.test.ts (pure contracts): hub percentile with the vault-size and degree floors and backlink degree; hub budget, nested sections outside code fences, connected candidates a section names; same-size rewrites and claims are never budgeted.
  • New page-budget-writes.test.ts (isolated test vaults through the tool handlers and storage worker):
    • rejections on edit_body, save_page edit and create, publish_batch and merge, with the full payload checked on one, no file change and no stored receipt;
    • knowledge_remember and knowledge_create_claim still publish against an oversized page;
    • same-size and shrinking edits pass on an oversized page, and extraction shrinks it further (the ratchet);
    • extraction round trip: verbatim move, relative link rewrite, summary link, carried evidence, claim entities moved or kept, history, identical replay;
    • unconnected destination, non-heading offset, stale fence and an over-budget destination all leave the source byte-identical.
  • Updated existing tests that grew pages past 24,000 characters (body-edit.test.ts large-page edits now replace at the same size; publication.test.ts fixture body 28,672 → 23,800 characters) and the policy default in stores-config.test.ts.
  • Test-line ceiling. Main at 3bcca4f raised its own ceiling to 6,300,000 and totals 6,296,883 lines (3,117 of slack). This PR adds a net 338 test lines, so the merged tree totals 6,297,221, still 2,779 under main's ceiling, and this PR leaves config/test-lines-baseline.txt at main's value. The 338 lines are the two new budget test files above (332 lines) plus small edits to three existing tests. They prove the six budget and extraction rules end to end through the storage worker, which no cheaper layer covers. I trimmed them from 474 lines by dropping assertions on static constants and merging overlapping cases.
  • pnpm tsgo:extensions, pnpm check:test-lines-ratchet, pnpm config:docs:check and skill reference sync --check on the 3bcca4f merge; earlier on this branch also pnpm tsgo:extensions:test, oxlint on extensions/knowledge/src, test/scripts/type-suppression-inventory.test.ts, pnpm check:assertion-safety, docs format and markdownlint, git diff --check: clean.
  • Local autoreview (branch mode against origin/main, P1 threshold): no actionable findings.
  • Read-only check of the live Team vault (207 current pages), with no writes: at the default percentile 20 pages are hubs (degree 26 or more): OpenClaw (degree 88), seven person pages, six meeting pages, five source pages (channel digests and a meeting archive) and one concept page. 11 pages are over budget today and are held by the ratchet: OpenClaw (135,706 of 12,000), ClawSweeper (28,298 of 24,000) and nine others between 12,239 and 27,760 characters. The largest OpenClaw State subsection is 8,449 characters, so each subsection fits a new page.
  • Not done: no isolated-Gateway run with a live model. The tool path is covered through the real service and storage worker in test vaults.

Work sessions

Worked on by

roboclaw-bot and others added 2 commits October 27, 2026 20:01
Page bodies now have a write-time size budget derived from one default
knowledge_record read: hub pages (top link-degree percentile, default 90,
with a 20-page and 10-link floor) get 12,000 characters, other pages twice
that. Every page-body write is checked once at acceptance; growth past the
budget returns a rejected receipt with section sizes and connected
candidates, while same-size and shrinking edits always succeed. Claims are
never gated.

knowledge_extract_section moves one heading section to a new or connected
page in one fenced publication, carrying links, quoted evidence and claim
subjects, and leaving a summary line and link on the source.

Co-authored-by: jalehman <[email protected]>
…dget, and can extract sections instead

Worked on by:
- @jalehman

Co-authored-by: jalehman <[email protected]>
OpenClaw-Publication: 34deb92f-04b7-44f3-bc8f-1a8eef59f5eb
@clawsweeper

clawsweeper Bot commented Oct 27, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation plugin: knowledge size: XL labels Oct 27, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 27, 2026
@clawsweeper

clawsweeper Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR limits Knowledge page-body growth and adds an atomic tool for extracting sections into other pages.

Example: An agent appends 100 characters to a non-hub page containing 24,000 characters.

  • Before: The page grows to 24,100 characters.
  • After: The write returns a rejected receipt with splitting guidance and preserves the existing 24,000 characters.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Service/worker coverage supports the design, but extraction correctness and existing-state compatibility prevent a pass.
Proof confidence 🦐 gold shrimp (3/6) This collaborator-authored PR is outside the ordinary contributor proof gate; supplied tests exercise the real service and storage worker, while the reported live-vault inspection performs no changed writes.
Patch quality 🦪 silver shellfish (2/6) 3 actionable review findings remain.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Repeated appends produce Knowledge pages that require many reads and become difficult for agents to maintain.
Reason: The collaborator-authored direction addresses observed oversized pages through one existing publication boundary, retains existing content, and provides a recovery operation.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep open: this maintainer-directed feature remains useful and absent from main, but section extraction has three content-preservation defects that need repair.

Priority: P2
Reviewed head: a6e323a57aac2aacc178ac917f3a5488cf1abbb0

Before merge

  • Validate extraction links in their full Markdown documents (P2) - The checks parse the section independently of both complete documents. For a source containing ## Billing\nSee [Ledger][ledger].\n\n## Notes\n[ledger]: ledger.md, extracting Billing loses the reference definition, but carryLinks records no original link and verification accepts the broken destination. Conversely, appending a section containing links to a connected destination ending in an unclosed code fence passes this isolated-text check even though those links become code in the actual destination. Derive expected links from the complete source and verify their occurrences in the complete resulting destination, carrying reference definitions or rejecting before publication.
  • Rewrite only parsed link spans when moving relative links (P2) - When a section contains an actual [Ledger](ledger.md) link and the same text inside a code sample, moving it to another directory makes this global replacement rewrite both occurrences. The parsed link still resolves, so verification accepts the publication while silently changing the literal code sample. Use token/span-aware replacements from the existing Markdown owner and preserve code, escaped text and other non-link bytes.
  • Preserve established claim subjects without mention-based inference (P2) - This removes the source entity before deciding whether to restore it using pageMentions, which ignores titles and aliases shorter than three characters. A claim with entities: [sourceId] and body AI uses local inference. therefore loses its AI subject when extracted from an AI page, despite explicitly naming it; with no owner/source_page reference, it disappears from that page's claim connections. More generally, literal name matching cannot establish whether an existing subject remains semantically relevant. Preserve established subjects and let the agent make explicit entity changes through the existing annotation operation.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P2] Validate extraction links in their full Markdown documents — extensions/knowledge/src/storage-edits.ts:331-336
  • [P2] Rewrite only parsed link spans when moving relative links — extensions/knowledge/src/page-extract.ts:40-42
  • [P2] Preserve established claim subjects without mention-based inference — extensions/knowledge/src/page-extract.ts:81-85

Tests

  • Low-value test extensions/knowledge/src/page-budget.test.ts: Remove the 'derives budgets from one default record read' case: it repeats the constant assignment expressions rather than exercising a distinct behavior.
  • Missing end-to-end proof: No fresh-install and latest-stable upgrade exercise demonstrates the new budget and extraction behavior while preserving existing settings, oversized pages, claims, evidence and history.
Agent review details

How this fits together

The optional Knowledge memory plugin resolves callers to authorized store partitions, runs mutations in its storage worker, and publishes Markdown records through a SQLite-backed journal.

flowchart LR
  A[Agent tools] --> B[Scoped Knowledge service]
  B --> C[Storage worker]
  C --> D[Section preparation]
  D --> E[Publication budget check]
  E --> F[Journal and Markdown vault]
Loading

Technical review

Best possible solution:

Keep the centralized budget check, use the existing Markdown parser to preserve document context and exact non-link text, and leave semantic subject changes to explicit agent annotations.

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

Current-main body edits have the existing record-byte ceiling but no read-sized page budget; the extraction failures are directly traceable through the introduced code, without executing target code.

Is this the best way to solve the issue?

The existing publication owner is the right enforcement boundary, but extraction should preserve parsed Markdown and established claim subjects rather than reconstructing their meaning through string matching.

Full review comments:

  • [P2] Validate extraction links in their full Markdown documents — extensions/knowledge/src/storage-edits.ts:331-336
    The checks parse the section independently of both complete documents. For a source containing ## Billing\nSee [Ledger][ledger].\n\n## Notes\n[ledger]: ledger.md, extracting Billing loses the reference definition, but carryLinks records no original link and verification accepts the broken destination. Conversely, appending a section containing links to a connected destination ending in an unclosed code fence passes this isolated-text check even though those links become code in the actual destination. Derive expected links from the complete source and verify their occurrences in the complete resulting destination, carrying reference definitions or rejecting before publication.
    Confidence: 0.99
  • [P2] Rewrite only parsed link spans when moving relative links — extensions/knowledge/src/page-extract.ts:40-42
    When a section contains an actual [Ledger](ledger.md) link and the same text inside a code sample, moving it to another directory makes this global replacement rewrite both occurrences. The parsed link still resolves, so verification accepts the publication while silently changing the literal code sample. Use token/span-aware replacements from the existing Markdown owner and preserve code, escaped text and other non-link bytes.
    Confidence: 0.99
  • [P2] Preserve established claim subjects without mention-based inference — extensions/knowledge/src/page-extract.ts:81-85
    This removes the source entity before deciding whether to restore it using pageMentions, which ignores titles and aliases shorter than three characters. A claim with entities: [sourceId] and body AI uses local inference. therefore loses its AI subject when extracted from an AI page, despite explicitly naming it; with no owner/source_page reference, it disappears from that page's claim connections. More generally, literal name matching cannot establish whether an existing subject remains semantically relevant. Preserve established subjects and let the agent make explicit entity changes through the existing annotation operation.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 9a0458cf6952.

Provenance checked

  • Page-body growth and publication acceptance changes intended behavior with a stated reason (65ad180: The bundling PR preserved existing Knowledge stores and publication behavior; main allows bounded edits up to the record-byte ceiling. The earlier standalone origin is unknown.)
  • Publication transaction and recovery ownership keeps the original intent (bd90ea5: The prior storage repair shortened database lock ownership while explicitly preserving publication atomicity, exact content and crash recovery.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • node scripts/run-vitest.mjs run extensions/knowledge/src/page-budget-writes.test.ts extensions/knowledge/src/page-budget.test.ts extensions/knowledge/src/body-edit.test.ts extensions/knowledge/src/publication.test.ts --maxWorkers=1
  • pnpm tsgo:extensions
  • pnpm tsgo:extensions:test
  • node extensions/knowledge/scripts/sync-skill-references.mjs --check
  • git diff --check

What I checked:

Likely related people:

  • Josh Lehman: Raw commit 65ad180 adds extensions/knowledge/src/storage-publication.ts:454 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 65ad18005286; files: extensions/knowledge/src/storage-publication.ts)

PR surface

Source +871, Tests +480, Docs +432, Generated 0. Total +1783 across 46 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 14 882 11 +871
Tests 5 490 10 +480
Docs 25 474 42 +432
Config 0 0 0 0
Generated 2 3 3 0
Other 0 0 0 0
Total 46 1849 66 +1783

Labels

Label changes:

  • add P2: The feature improves an optional memory plugin, while extraction defects can alter stored content and associations within that surface.
  • add merge-risk: 🚨 compatibility: Previously accepted page growth now returns rejected receipts, and a new tool/config contract is added; the collaborator-authored PR accepts that direction, while upgrade compatibility remains unproven.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: The feature improves an optional memory plugin, while extraction defects can alter stored content and associations within that surface.
  • merge-risk: 🚨 compatibility: Previously accepted page growth now returns rejected receipts, and a new tool/config contract is added; the collaborator-authored PR accepts that direction, while upgrade compatibility remains unproven.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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 execution lanes are retired.

Reviewed October 27, 2026, 4:23 PM ET / 20:23 UTC.

roboclaw-bot and others added 8 commits October 27, 2026 23:14
…ge-budgets

# Conflicts:
#	docs/.generated/config-baseline.sha256
Replace the untyped extract destination with ExtractSectionInput, drop
assertions on static constants and unit cases the write-path tests already
cover, and fold the extract failure paths into the round-trip test.

Co-authored-by: jalehman <[email protected]>
Worked on by:
- @jalehman

Co-authored-by: jalehman <[email protected]>
OpenClaw-Publication: 933115de-dfd9-4753-9ba8-39e84b852cb5
…ge-budgets

# Conflicts:
#	docs/.generated/config-baseline.counts.json
#	docs/.generated/config-baseline.sha256
#	docs/plugins/knowledge.md
#	extensions/knowledge/skills/knowledge-unlinked-claims/SKILL.md
#	extensions/knowledge/src/mutation-contract.ts
#	extensions/knowledge/src/storage-host.ts
#	extensions/knowledge/src/storage-publication.ts
#	extensions/knowledge/src/storage-types.ts
Main had 248 lines of slack at the merged commit; the page budget and
section extraction tests add a net 338 lines.

Co-authored-by: jalehman <[email protected]>
Worked on by:
- @jalehman

Co-authored-by: jalehman <[email protected]>
OpenClaw-Publication: b73fa91a-3541-49e2-828b-03f8372d914a
…ge-budgets

# Conflicts:
#	config/test-lines-baseline.txt
#	docs/.generated/config-baseline.sha256
Worked on by:
- @jalehman

Co-authored-by: jalehman <[email protected]>
OpenClaw-Publication: 21d5a543-8d39-43a4-a3cd-414c7708da1c
@roboclaw-bot
roboclaw-bot merged commit ff2d718 into main Oct 28, 2026
108 checks passed
@roboclaw-bot
roboclaw-bot deleted the openclaw/knowledge-page-budgets branch October 28, 2026 05:30
steipete added a commit that referenced this pull request Oct 30, 2026
…88556)

## What Problem This Solves

Knowledge currently walks valid store keys twice and makes an extra array copy before three explorer projections. Let the existing schema validator own key validation, and let filter/toSorted/toReversed provide the arrays they already allocate.

## User Impact

No user-visible behavior change. The malformed-membership path still makes affected agents unavailable. Store-key syntax, membership/authority checks, sorting, rendering, pagination, and source-array ownership stay unchanged. No SQL, schema, SDK, or provider-request change.

## Why This Change Was Made

The validated schema owns key syntax; the native array methods own the required copies. Keep those owners and delete the redundant work.

## Evidence

### Acceptance and counts

This is a four-site cleanup, using the final-small-batch exception; production +4/-5 lines (net -1), net test lines unchanged. Count acceptance: one redundant key scan and its regex allocation removed; three explicit array copies removed. No wall-clock, CPU, SQL, or Gateway latency claim; no timing experiment. Existing nonmutating methods remain, with no new lint suppression.

- Focused existing stores-config suite: 4/4 passed, including malformed-key invalidation, revision stability, policy rejection, and conversation grants.
- Changed-file oxfmt, oxlint, and git diff --check passed.
- Two isolated Codex P0–P2 reviews of the full four-file diff against 8f1ef6c: both scoped-clean; no findings. Initial temporary-directory preflight refusals were corrected before either reviewer executed.
- Initial exact-head CI run 41097808042 exposed a storage-schema replacement-fixture failure (expected three indexes, got two). The unchanged file passes 10/10 on both base and candidate; inode reuse was not reproduced locally. Earlier fixture cleanup can leave freed inode IDs in the module admission set. The replacement test now uses a freshly imported owner, preserves both warm-file/replacement index assertions, and passes 10/10 locally. Net test lines remain zero.
- One additional isolated Codex P0–P2 delta review found no actionable issue in the fixture repair; the final import alias also passes no-shadow lint.
- Final exact-head CI 41099978168 at 31f0f63: all applicable test, type, lint, source-contract, architecture, extension-boundary and baseline-ratchet gates passed, including the previously failing extensions-config shard. Security/dependency review passed. GitHub status requests intermittently returned 502/504; no test rerun or bypass was used.

Open-PR overlap comparison used base and candidate merge-tree output against #186270 (2a8f1cc) and #184755 (e1a7985). Conflict blocks are identical: 51→51 and 1→1 respectively; no new conflict. Final shared-index refresh also checked the test file and found no further peers. #186270 is now merged; the remaining open #184755 still has the identical single unrelated generated-baseline conflict. Broader scan candidates needing mutable-sort lint exceptions, uncertain input contracts, or another owner were retained rather than included here.

Release-note context: reduce redundant Knowledge config validation and explorer array copying without changing user-visible behavior.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 31, 2026
…enclaw#188556)

## What Problem This Solves

Knowledge currently walks valid store keys twice and makes an extra array copy before three explorer projections. Let the existing schema validator own key validation, and let filter/toSorted/toReversed provide the arrays they already allocate.

## User Impact

No user-visible behavior change. The malformed-membership path still makes affected agents unavailable. Store-key syntax, membership/authority checks, sorting, rendering, pagination, and source-array ownership stay unchanged. No SQL, schema, SDK, or provider-request change.

## Why This Change Was Made

The validated schema owns key syntax; the native array methods own the required copies. Keep those owners and delete the redundant work.

## Evidence

### Acceptance and counts

This is a four-site cleanup, using the final-small-batch exception; production +4/-5 lines (net -1), net test lines unchanged. Count acceptance: one redundant key scan and its regex allocation removed; three explicit array copies removed. No wall-clock, CPU, SQL, or Gateway latency claim; no timing experiment. Existing nonmutating methods remain, with no new lint suppression.

- Focused existing stores-config suite: 4/4 passed, including malformed-key invalidation, revision stability, policy rejection, and conversation grants.
- Changed-file oxfmt, oxlint, and git diff --check passed.
- Two isolated Codex P0–P2 reviews of the full four-file diff against 5fe865c: both scoped-clean; no findings. Initial temporary-directory preflight refusals were corrected before either reviewer executed.
- Initial exact-head CI run 41097808042 exposed a storage-schema replacement-fixture failure (expected three indexes, got two). The unchanged file passes 10/10 on both base and candidate; inode reuse was not reproduced locally. Earlier fixture cleanup can leave freed inode IDs in the module admission set. The replacement test now uses a freshly imported owner, preserves both warm-file/replacement index assertions, and passes 10/10 locally. Net test lines remain zero.
- One additional isolated Codex P0–P2 delta review found no actionable issue in the fixture repair; the final import alias also passes no-shadow lint.
- Final exact-head CI 41099978168 at 31f0f63: all applicable test, type, lint, source-contract, architecture, extension-boundary and baseline-ratchet gates passed, including the previously failing extensions-config shard. Security/dependency review passed. GitHub status requests intermittently returned 502/504; no test rerun or bypass was used.

Open-PR overlap comparison used base and candidate merge-tree output against openclaw#186270 (2a8f1cc) and openclaw#184755 (e1a7985). Conflict blocks are identical: 51→51 and 1→1 respectively; no new conflict. Final shared-index refresh also checked the test file and found no further peers. openclaw#186270 is now merged; the remaining open openclaw#184755 still has the identical single unrelated generated-baseline conflict. Broader scan candidates needing mutable-sort lint exceptions, uncertain input contracts, or another owner were retained rather than included here.

Release-note context: reduce redundant Knowledge config validation and explorer array copying without changing user-visible behavior.
RomneyDa added a commit that referenced this pull request Oct 31, 2026
…88556)

## What Problem This Solves

Knowledge currently walks valid store keys twice and makes an extra array copy before three explorer projections. Let the existing schema validator own key validation, and let filter/toSorted/toReversed provide the arrays they already allocate.

## User Impact

No user-visible behavior change. The malformed-membership path still makes affected agents unavailable. Store-key syntax, membership/authority checks, sorting, rendering, pagination, and source-array ownership stay unchanged. No SQL, schema, SDK, or provider-request change.

## Why This Change Was Made

The validated schema owns key syntax; the native array methods own the required copies. Keep those owners and delete the redundant work.

## Evidence

### Acceptance and counts

This is a four-site cleanup, using the final-small-batch exception; production +4/-5 lines (net -1), net test lines unchanged. Count acceptance: one redundant key scan and its regex allocation removed; three explicit array copies removed. No wall-clock, CPU, SQL, or Gateway latency claim; no timing experiment. Existing nonmutating methods remain, with no new lint suppression.

- Focused existing stores-config suite: 4/4 passed, including malformed-key invalidation, revision stability, policy rejection, and conversation grants.
- Changed-file oxfmt, oxlint, and git diff --check passed.
- Two isolated Codex P0–P2 reviews of the full four-file diff against 8f1ef6c: both scoped-clean; no findings. Initial temporary-directory preflight refusals were corrected before either reviewer executed.
- Initial exact-head CI run 41097808042 exposed a storage-schema replacement-fixture failure (expected three indexes, got two). The unchanged file passes 10/10 on both base and candidate; inode reuse was not reproduced locally. Earlier fixture cleanup can leave freed inode IDs in the module admission set. The replacement test now uses a freshly imported owner, preserves both warm-file/replacement index assertions, and passes 10/10 locally. Net test lines remain zero.
- One additional isolated Codex P0–P2 delta review found no actionable issue in the fixture repair; the final import alias also passes no-shadow lint.
- Final exact-head CI 41099978168 at 31f0f63: all applicable test, type, lint, source-contract, architecture, extension-boundary and baseline-ratchet gates passed, including the previously failing extensions-config shard. Security/dependency review passed. GitHub status requests intermittently returned 502/504; no test rerun or bypass was used.

Open-PR overlap comparison used base and candidate merge-tree output against #186270 (2a8f1cc) and #184755 (e1a7985). Conflict blocks are identical: 51→51 and 1→1 respectively; no new conflict. Final shared-index refresh also checked the test file and found no further peers. #186270 is now merged; the remaining open #184755 still has the identical single unrelated generated-baseline conflict. Broader scan candidates needing mutable-sort lint exceptions, uncertain input contracts, or another owner were retained rather than included here.

Release-note context: reduce redundant Knowledge config validation and explorer array copying without changing user-visible behavior.

(cherry picked from commit cd8290c)
Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. plugin: knowledge rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant