Repository navigation
fix(memory): keep curated annotation indexing linear - #138995
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 real behavior proof before merge. Reviewed September 5, 2026, 6:13 AM ET / 10:13 UTC. ClawSweeper reviewWhat this changesThe PR changes how Memory Core recognizes trailing annotation comments to reduce backtracking and adds focused matcher tests. Merge readiness⛔ Blocked before merge - 7 items remain Keep open: current main still needs this repair, but the replacement changes existing recall results and the supplied proof does not exercise real memory indexing. Priority: P2 Review scores
Verification
How this fits togetherMemory Core indexes workspace memory files and extracts annotation metadata used for search ranking and automatic recall. This matcher selects the comments from which trigger phrases and importance scores are read. flowchart TD
A[Workspace memory files] --> B[Chunking and path classification]
B --> C{Curated root file}
C -->|Yes| D[Trailing annotation parser]
C -->|No| E[Chunks without trigger metadata]
D --> F[Agent memory index]
E --> F
F --> G[Search and automatic recall]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +11, Tests +30. Total +41 across 2 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Fold suffix recognition into the existing metadata pass for a bounded, preferably net-neutral repair that preserves recall results and uses indexing-level regression coverage. Do we have a high-confidence way to reproduce the issue? Yes, from source: the reported line reaches the original matcher during curated-file indexing, and the contributor supplies failing helper measurements. No real indexing reproduction was executed in this read-only review. Is this the best way to solve the issue? No, not yet: bounding individual comments addresses one backtracking cause, but changes suffix selection and leaves ambiguous whitespace ownership; a single bounded metadata pass is more complete. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a61fcf82f604. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Use forward-only annotation scans and reuse metadata across fragments of the same source span. Preserve trailing recall grammar and invalid project isolation. Co-authored-by: lzhan011 <[email protected]>
775185b to
4e2ad3d
Compare
|
Landed as e55f25b15ea6 from verified head 4e2ad3d06424. Thanks @lzhan011!
Verification commands: node scripts/run-vitest.mjs packages/memory-host-sdk/src/host/curated-annotations.test.ts extensions/memory-core/src/memory/index.test.ts
node scripts/run-vitest.mjs packages/memory-host-sdk/src/host/internal.test.ts
node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json packages/memory-host-sdk/src/host/curated-annotations.ts packages/memory-host-sdk/src/host/curated-annotations.test.ts src/plugin-sdk/memory-core-host-engine-curated.ts
node scripts/run-oxlint.mjs --tsconfig extensions/tsconfig.json extensions/memory-core/src/memory/index.test.ts extensions/memory-core/src/memory/manager-embedding-ops.ts
node --import ./scripts/tsx.mjs scripts/build-all.mts qaRuntime
node openclaw.mjs memory index --force --verboseSemantic proof used a local deterministic HTTP embedding endpoint, not an external live provider. Source digests bound the rebuilt runtime to the reviewed commit; inherited runtime version metadata was not used as identity. |
Fixes openclaw#138994. ## What Problem This Solves A short incomplete annotation in `MEMORY.md` can block memory indexing for seconds. The original repeated suffix expression explores many ways to divide comments before rejecting an incomplete final marker. The initial repair removed exponential backtracking but retained quadratic work and changed recall metadata when ordinary comments appeared between annotations. ## Why This Change Was Made Use the existing curated-annotation owner for one forward-only scanner shared by carrier stripping, project extraction, and recall metadata parsing. Reuse metadata for fragments with the same source span. Keep the existing grammar: - Trailing recall metadata can span intervening ordinary comments and text. - Trigger phrases retain their order and deduplication; importance retains the largest valid value from 1 through 10. - Project extraction stays independent, including project markers nested inside other annotation payloads. - Incomplete and invalid project annotations remain scoped but unsatisfiable. - Existing multiline-prefix and line-scoped carrier-body behavior stays unchanged. This removes the manager-owned parser and the proposed test-only matcher export. No configuration, schema, migration, or stored representation changes. ## User Impact Curated memory indexing stays responsive with incomplete or long annotation-shaped input in both keyword-only and semantic modes. Reindexing preserves existing recall metadata and project isolation. Thanks @lzhan011 for the report, initial repair, and short reproduction. ## Evidence Baseline: `8a1577ea1470073eef9823529bf9428a11f02da7`. Verified candidate: `4e2ad3d06424b17f769df6b2724d7d7250e16b92`. ### Real indexing Ran the built CLI against isolated workspaces and databases: ```sh node openclaw.mjs memory index --force --verbose ``` The reported 403-byte payload was placed inside a 432-byte curated entry. On main, the command took 25.38 seconds and the event loop stalled for 20.19 seconds. The baseline control had a 1.62-second startup delay. On the candidate, the same keyword-only witness took 5.01 seconds including startup, with maximum event-loop delay 1.54 seconds. A 300 KB version took 4.99 seconds. Valid mixed-comment metadata remained intact. Separate runs used deliberately unfinished project openers: | Input | Keyword-only command | Semantic command | Embedding requests | |---|---:|---:|---:| | 120 KB | 4.78 s | 5.40 s | 38 | | 240 KB | 4.88 s | 5.53 s | 76 | | 480 KB | 5.03 s | 5.79 s | 151 | | 960 KB | 5.08 s | 6.06 s | 301 | These times include CLI startup. Semantic runs used a local deterministic HTTP embedding endpoint through the real provider, chunking, indexing, and SQLite publication path. They are not live external-provider tests. Embedding requests increased with input size; repeated identical fragments naturally share persisted chunk identities. Both modes also passed valid trigger/importance/project controls, nontrailing-annotation controls, the original witness, and a 160 KB incomplete whitespace tail. Stored metadata and embedding rows were inspected. ### Regression and compatibility - New indexing regression fails on baseline in both modes: 3.80/3.88 seconds against a 3-second bound. - Candidate: 16 shared-owner grammar tests and all 72 index tests pass; the new cases take about 0.11 seconds each. - 50,000 bounded generated cases match baseline carrier stripping, project extraction, and all recall/project eligibility combinations. - Shared-owner incomplete-input medians across seven samples: 120 KB 0.90 ms; 240 KB 1.85 ms; 480 KB 3.13 ms; 960 KB 8.78 ms; 1.92 MB 18.76 ms. - Existing invalid-project isolation, curated/daily/user eligibility, search, and oversized-fragment inheritance tests pass. - Exact pinned formatter, type-aware lint for both changed lanes, runtime build, and independent code review pass. The runtime build used the baseline source archive plus the candidate's committed files, with source digests checked after commit. Baseline dependency build artifacts were reused; the runtime was rebuilt from the repaired source. The runtime-only build's inherited version metadata is not used as candidate identity. ### Diff accounting - Production: +123 / -84, net +39. - Tests: +117 / -0. - Much of the parser moved to its existing owner. Remaining growth implements a shared forward-only scanner and per-source-span reuse. A shorter suffix-only regex change leaves the other incomplete-input scans and repeated-fragment work unresolved. The existing review's mixed-comment, whitespace, long-input, real-indexing, and compatibility requests are covered above. Co-authored-by: Ayaan Zaidi <[email protected]>
…150260) Keep incomplete and mixed annotation indexing coverage while timing the historical backtracking witness at the parser owner. Related: openclaw#150236, openclaw#138995.
Fixes #138994.
What Problem This Solves
A short incomplete annotation in
MEMORY.mdcan block memory indexing for seconds. The original repeated suffix expression explores many ways to divide comments before rejecting an incomplete final marker.The initial repair removed exponential backtracking but retained quadratic work and changed recall metadata when ordinary comments appeared between annotations.
Why This Change Was Made
Use the existing curated-annotation owner for one forward-only scanner shared by carrier stripping, project extraction, and recall metadata parsing. Reuse metadata for fragments with the same source span.
Keep the existing grammar:
This removes the manager-owned parser and the proposed test-only matcher export. No configuration, schema, migration, or stored representation changes.
User Impact
Curated memory indexing stays responsive with incomplete or long annotation-shaped input in both keyword-only and semantic modes. Reindexing preserves existing recall metadata and project isolation.
Thanks @lzhan011 for the report, initial repair, and short reproduction.
Evidence
Baseline:
49ecde890905fa601cafc9cfbf6ea0cfe9aab824.Verified candidate:
4e2ad3d06424b17f769df6b2724d7d7250e16b92.Real indexing
Ran the built CLI against isolated workspaces and databases:
The reported 403-byte payload was placed inside a 432-byte curated entry. On main, the command took 25.38 seconds and the event loop stalled for 20.19 seconds. The baseline control had a 1.62-second startup delay.
On the candidate, the same keyword-only witness took 5.01 seconds including startup, with maximum event-loop delay 1.54 seconds. A 300 KB version took 4.99 seconds. Valid mixed-comment metadata remained intact.
Separate runs used deliberately unfinished project openers:
These times include CLI startup. Semantic runs used a local deterministic HTTP embedding endpoint through the real provider, chunking, indexing, and SQLite publication path. They are not live external-provider tests. Embedding requests increased with input size; repeated identical fragments naturally share persisted chunk identities.
Both modes also passed valid trigger/importance/project controls, nontrailing-annotation controls, the original witness, and a 160 KB incomplete whitespace tail. Stored metadata and embedding rows were inspected.
Regression and compatibility
The runtime build used the baseline source archive plus the candidate's committed files, with source digests checked after commit. Baseline dependency build artifacts were reused; the runtime was rebuilt from the repaired source. The runtime-only build's inherited version metadata is not used as candidate identity.
Diff accounting
The existing review's mixed-comment, whitespace, long-input, real-indexing, and compatibility requests are covered above.