Skip to content

fix(memory-core): keep short protected-glossary terms past the min-length gate - #96304

Merged
vincentkoc merged 1 commit into
openclaw:mainfrom
ly-wang19:fix/memory-core-glossary-minlen
Jun 24, 2026
Merged

vincentkoc merged 1 commit into
openclaw:mainfrom
ly-wang19:fix/memory-core-glossary-minlen

Conversation

@ly-wang19

Copy link
Copy Markdown
Contributor

Summary

PROTECTED_GLOSSARY (extensions/memory-core/src/concept-vocabulary.ts) exists specifically to preserve short technical terms that the generic stop-word/segmentation filtering would otherwise discard. But every glossary match still flows through normalizeConceptToken (via pushNormalizedTag), which applies a per-script minimum length — latin tokens shorter than 3 chars are rejected. The glossary lists kv and s3 (2-char latin), so they were never emitted as concept tags despite being on the protect-list, defeating the allowlist.

deriveConceptTags is called from short-term recall/promotion (short-term-promotion.ts) for entries without stored conceptTags, so any recalled snippet mentioning these terms lost them.

Changes

  • concept-vocabulary.ts — thread a fromGlossary flag through pushNormalizedTag → normalizeConceptToken that bypasses only the min-length gate for glossary matches; all other gates (empty/non-letter, oversized, pure-number, date, stop-word) still apply. deriveConceptTags passes fromGlossary: true for glossary matches, false for compound/segment tokens.
  • concept-vocabulary.test.ts — regression test that kv/s3 survive.

Real behavior proof

Behavior addressed: 2-char latin glossary terms (kv, s3) were silently dropped by the latin min-length-3 gate. After the fix they are emitted as concept tags.

Real environment tested: Node 22.22.1, macOS, no network/model. Vitest exercises the real exported deriveConceptTags. BEFORE is origin/main's file (swapped via git show).

Exact steps or command run after this patch:

node scripts/run-vitest.mjs extensions/memory-core/src/concept-vocabulary.test.ts

Evidence after fix:

deriveConceptTags({ path: "memory/2026-04-04.md", snippet: "Store the session in kv and back up to s3 nightly." })
  BEFORE: tags do NOT contain "kv" or "s3"   (dropped by the latin min-length-3 gate)
  AFTER:  tags contain "kv" and "s3"          (glossary allowlist honored)

Observed result after fix: short protected-glossary terms survive; 3-char+ latin entries, CJK entries, and all non-glossary filtering are unchanged. The new test fails on origin/main and passes after.

What was not tested: end-to-end short-term recall promotion (the test drives the real exported deriveConceptTags that path calls). Additive only — it surfaces two previously-dropped glossary tags and never removes or reorders existing tags.

Additional checks

  • node scripts/run-vitest.mjs extensions/memory-core/src/concept-vocabulary.test.ts passes; fail-before verified by swapping in origin/main's file. Extension oxlint clean.

@clawsweeper

clawsweeper Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 24, 2026, 9:27 AM ET / 13:27 UTC.

Summary
The PR updates memory-core concept-tag extraction so short protected glossary entries like kv and s3 can bypass only the generic minimum-length filter, with regression tests for standalone and substring cases.

PR surface: Source +39, Tests +26. Total +65 across 3 files.

Reproducibility: yes. Current-main source shows kv and s3 in PROTECTED_GLOSSARY while the shared normalizer rejects Latin tokens shorter than three characters; the contributor also provided direct before/after deriveConceptTags output.

Review metrics: 1 noteworthy metric.

  • Persisted tag derivation: 1 derivation helper changed. deriveConceptTags feeds stored recall entries and conceptual promotion scoring, so this is a state-affecting behavior change.

Stored data model
Persistent data-model change detected: unknown-data-model-change: extensions/memory-core/src/concept-vocabulary.ts, vector/embedding metadata: extensions/memory-core/src/concept-vocabulary.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • none.

Risk before merge

  • [P1] Future recall or grounded entries mentioning standalone kv or s3 will store additional conceptTags, which can slightly change conceptual promotion scores and downstream memory ordering after merge.

Maintainer options:

  1. Land the bounded glossary behavior (recommended)
    Accept the intentional future conceptTags change because the PR preserves standalone kv/s3, blocks mkv/css3 leaks, and keeps longer glossary substring behavior intact.
  2. Ask for promotion-level proof
    Request a short recall or promotion run showing persisted entries gain only standalone kv/s3 if helper-level proof is not enough for this state path.

Next step before merge

  • No automated repair is needed; maintainers need to accept the bounded session-state behavior change before merge.

Security
Cleared: The diff changes memory-core TypeScript tokenization logic and colocated tests only; no dependency, workflow, secret, install, or code-download surface is touched.

Review details

Best possible solution:

Land the focused glossary fix after maintainers accept the bounded future concept-tag scoring change and required checks are green.

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

Yes. Current-main source shows kv and s3 in PROTECTED_GLOSSARY while the shared normalizer rejects Latin tokens shorter than three characters; the contributor also provided direct before/after deriveConceptTags output.

Is this the best way to solve the issue?

Yes. Fixing the owner extraction path is narrower than lowering the global minimum length, and short-only delimiter matching avoids false positives while preserving shipped longer-glossary substring behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 2aa9d6763564.

Label changes

Label justifications:

  • P2: This is a narrow memory-core bug fix with limited blast radius in concept-tag derivation and promotion scoring.
  • merge-risk: 🚨 session-state: The PR changes future derived conceptTags stored on recall entries and used by memory promotion scoring.
  • 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 (live_output): The PR body and follow-up comments provide after-fix live deriveConceptTags output for standalone kv/s3, negative mkv/css3, preserved backup behavior, and targeted command results.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body and follow-up comments provide after-fix live deriveConceptTags output for standalone kv/s3, negative mkv/css3, preserved backup behavior, and targeted command results.
Evidence reviewed

PR surface:

Source +39, Tests +26. Total +65 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 55 16 +39
Tests 2 27 1 +26
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 82 17 +65

What I checked:

Likely related people:

  • vincentkoc: Merged the multilingual memory promotion PR that introduced the concept vocabulary and protected glossary path now being repaired. (role: feature introducer; confidence: high; commits: 0609bf858175; files: extensions/memory-core/src/concept-vocabulary.ts, extensions/memory-core/src/concept-vocabulary.test.ts, extensions/memory-core/src/short-term-promotion.ts)
  • mbelinky: Merged grounded backfill into the same short-term promotion store and stored conceptTags flow affected by this PR. (role: adjacent feature contributor; confidence: medium; commits: e8209e4cf9b8; files: extensions/memory-core/src/short-term-promotion.ts, extensions/memory-core/src/short-term-promotion.test.ts)
  • steipete: Path history shows multiple nearby memory-core promotion and lowercase-helper refactors around the same concept-tagging and short-term recall area. (role: recent adjacent contributor; confidence: medium; commits: dffa88f39615, 9314bb718084, 528868ef7690; files: extensions/memory-core/src/concept-vocabulary.ts, extensions/memory-core/src/short-term-promotion.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jun 24, 2026
@ly-wang19
ly-wang19 force-pushed the fix/memory-core-glossary-minlen branch from ed4f5fe to c183df3 Compare June 24, 2026 07:22
@ly-wang19

Copy link
Copy Markdown
Contributor Author

Addressed the P1 false-positive finding (extensions/memory-core/src/concept-vocabulary.ts:421 — "Constrain short glossary matches to real terms").

The min-length bypass meant a bare substring match could surface kv/s3 from inside longer words (mkv, css3), polluting persisted recall tags. Glossary matching is now whole-token (delimiter-bounded) for latin/space-delimited entries, while CJK entries — which have no word delimiters — keep substring containment. Added a negative regression test alongside the positive one.

Behavior proof (deriveConceptTags direct I/O, Node 22):

Before (substring matcher + bypass):

NEG "Played the mkv recording and tuned the css3 layout."
  -> ["kv","s3","x.md","played","mkv","recording","tuned","css3"]   kv=true  s3=true   ← false positives

After (whole-token matching):

POS "Store the session in kv and back up to s3 nightly."
  -> ["kv","s3","x.md","store","back","nightly"]                    kv=true  s3=true   ← standalone still kept
NEG "Played the mkv recording and tuned the css3 layout."
  -> ["x.md","played","mkv","recording","tuned","css3","layout"]    kv=false s3=false  ← fixed; mkv/css3 retained

Checks green: oxfmt, oxlint, tsgo:extensions (exit 0), colocated vitest. CJK substring behavior and the existing ordered-tag test are preserved.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 24, 2026
@ly-wang19
ly-wang19 force-pushed the fix/memory-core-glossary-minlen branch from c183df3 to 972956b Compare June 24, 2026 08:34
@ly-wang19

Copy link
Copy Markdown
Contributor Author

A self-audit caught a regression in my previous revision — fixed and re-pushed.

The bug I introduced: the previous push switched all latin glossary entries from substring to whole-word matching. That dropped backup from inside backups, breaking the unmodified sibling assertion in short-term-promotion.test.ts ("extracts stable concept tags…": "Move backups to S3 Glacier and sync QMD router notes." → ["backup", "backups", "glacier", "qmd", "router", "sync"]). A hard CI failure, and scope-creep beyond this PR's intent.

Fix: whole-word matching now applies only to entries below their script's minimum length — the ones that actually rely on the bypass (kv, s3). Longer entries keep substring containment, so backup still tags inside backups (shipped behavior preserved); CJK entries (no word delimiters) stay on substring matching. The stable-tags assertion is updated to include s3, which is the intended fix here — s3 is a protected-glossary term that now correctly surfaces as a standalone token.

Verified (function I/O, Node 22): deriveConceptTags("Move backups to S3 Glacier and sync QMD router notes.") → ["backup","backups","glacier","qmd","router","s3","sync"]; standalone kv/s3 surface; mkv/css3 no longer leak kv/s3; the Unicode and CJK assertions are unchanged. concept-vocabulary.test.ts and short-term-promotion.test.ts both pass; oxfmt, oxlint, and tsgo:extensions are green.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@vincentkoc
vincentkoc force-pushed the fix/memory-core-glossary-minlen branch 2 times, most recently from cedd222 to d617093 Compare June 24, 2026 13:05
…ngth gate

PROTECTED_GLOSSARY exists to preserve short technical terms that generic
filtering would discard, but every glossary match still flowed through
normalizeConceptToken's per-script minimum-length gate. The 2-char latin
entries "kv" and "s3" were therefore never emitted as concept tags despite
being on the protect-list. Thread a fromGlossary flag so glossary matches
bypass only that length check; all other gates still apply.

Because that bypass lets short entries through, a bare substring match would
also surface them from inside longer words ("kv" in "mkv", "s3" in "css3").
Match ONLY the short entries (those below their script's min length) as
delimiter-bounded whole tokens; longer entries keep substring containment, so
the shipped behavior of "backup" tagging inside "backups" is preserved. CJK
entries (no word delimiters) always use substring matching. Positive
(standalone kv/s3) and negative (mkv/css3 substrings) regression tests cover
both directions, and the short-term-promotion stable-tags assertion gains "s3".

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@vincentkoc
vincentkoc force-pushed the fix/memory-core-glossary-minlen branch from d617093 to 9f91b95 Compare June 24, 2026 13:18
@vincentkoc
vincentkoc merged commit bea3d29 into openclaw:main Jun 24, 2026
85 checks passed
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 25, 2026
…ngth gate (openclaw#96304)

PROTECTED_GLOSSARY exists to preserve short technical terms that generic
filtering would discard, but every glossary match still flowed through
normalizeConceptToken's per-script minimum-length gate. The 2-char latin
entries "kv" and "s3" were therefore never emitted as concept tags despite
being on the protect-list. Thread a fromGlossary flag so glossary matches
bypass only that length check; all other gates still apply.

Because that bypass lets short entries through, a bare substring match would
also surface them from inside longer words ("kv" in "mkv", "s3" in "css3").
Match ONLY the short entries (those below their script's min length) as
delimiter-bounded whole tokens; longer entries keep substring containment, so
the shipped behavior of "backup" tagging inside "backups" is preserved. CJK
entries (no word delimiters) always use substring matching. Positive
(standalone kv/s3) and negative (mkv/css3 substrings) regression tests cover
both directions, and the short-term-promotion stable-tags assertion gains "s3".

Co-authored-by: ly-wang19 <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: memory-core Extension: memory-core merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

2 participants