Skip to content

feat(core): drop English stop words from keyed query trapdoors - #910

Open
p-diogo wants to merge 1 commit into
mainfrom
feat/core-keyed-query-stop-words
Open

p-diogo wants to merge 1 commit into
mainfrom
feat/core-keyed-query-stop-words

Conversation

@p-diogo

@p-diogo p-diogo commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

The keyed search path (index scheme 1) now gets the same English query stop-word filter that the unkeyed path already has.

search::generate_search_trapdoors_keyed built its stem part with BlindIndexer::stem_tags, which tags every token. After the keyed cutover (internal#573) that would have lost the filter that #877 (MCP) and #875 (Python) added on the unkeyed path. The fix is in core: clients that call generateSearchTrapdoorsKeyed / generate_search_trapdoors_keyed get it with no code change.

Rules (the same as generate_query_blind_indices)

  • One stop list: QUERY_STOP_WORDS (153 entries). No second list.
  • The token is tested, not its stem.
  • A token in the list gives no stem tag. Every other token gives exactly the tag stem_tags gives it.
  • A query made only of stop words ("who am I") keeps every tag.
  • An empty query gives an empty list. The result is sorted and deduplicated.
  • Writes are unchanged: stem_tags, prepare_fact_v1_keyed and every store path keep tagging every token. Only query trapdoors filter. Entity tags and keyed LSH tags are unchanged.

New bindings

  • WASM: WasmBlindIndexer.queryStemTags(query)
  • PyO3: BlindIndexer.query_stem_tags(query)

Tests

Every new test was seen failing before its implementation existed.

  • cd rust/totalreclaw-core && cargo test: 918 passed; 0 failed (7 new unit tests in blind.rs, 1 new search test, 2 new tests in tests/keyed_blind_indices.rs).
  • python scripts/check-pyfunction-parity.py: OK: all #[pyfunction] declarations are registered.
  • Fixture reproducibility: generate-keyed-blind-indices-v1.py (new key query_stem_vectors, 6 cases; the 11 existing keys are byte-identical; the generator reads the stop list from query-blind-indices-v1.json), generate-query-blind-indices-v1.py and generate-same-fact-judge-v1.py: output identical on re-run.
  • PyO3 leg (maturin wheel on Python 3.12): test_keyed_blind_indices_parity.py + test_query_blind_indices_parity.py: 14 passed.
  • WASM leg (wasm-pack build --target nodejs --out-dir pkg --features wasm): keyed-blind-indices-parity.test.ts: 106 passed, 0 failed; query-blind-indices-parity.test.ts: 17 passed, 0 failed.

No version bump and no client change. Core is in the Halborn audit scope; this goes to them as a delta review.

🤖 Generated with Claude Code

`search::generate_search_trapdoors_keyed` built its word part with
`BlindIndexer::stem_tags`, which tags every token, so the keyed cutover
(index scheme 1, internal#573) would have lost the query stop-word
filter that #877 (MCP) and #875 (Python) added on the unkeyed path.

New `BlindIndexer::query_stem_tags(query)`, the keyed twin of
`generate_query_blind_indices`: the same stop list (`QUERY_STOP_WORDS`),
the token is tested and not its stem, a query made only of stop words
keeps every tag, and the result is sorted and deduplicated. Writes are
unchanged: `stem_tags`, `prepare_fact_v1_keyed` and every store path
keep tagging every token.

Bindings: WASM `WasmBlindIndexer.queryStemTags`, PyO3
`BlindIndexer.query_stem_tags`. Clients that call
`generateSearchTrapdoorsKeyed` / `generate_search_trapdoors_keyed` get
the filter with no code change.

Tests: unit tests in `blind.rs`, a search test, and the fixture key
`query_stem_vectors` in `keyed-blind-indices-v1.json` (its generator
reads the stop list from `query-blind-indices-v1.json`), checked by the
Rust, WASM and PyO3 legs.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@p-diogo

p-diogo commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator Author

Independent review (GLM 5.3) approved: rules match the unkeyed filter, writes unchanged, legs green. Core is in the Halborn scope, so this goes to them as a delta review; merge is yours.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant