Keep semantic vector scans on their keyset ranges #107

Merged
Collaborator

Exclude account terms from index selection only in vector keyset scans. Select copy representatives once per scan through copy_key, bound scans by their initial maximum ID, and skip hidden copies without yielding empty chunks.

Add query-plan, scan-stream and byte-for-byte tool-output equivalence tests, plus an opt-in semantic benchmark and README usage note.

Validation: focused suite 382 passed, 5 skipped; make check 754 passed, 8 skipped, with lint, types and audit green. Host benchmarks show a 22.09% reduction in unfiltered scan time with Part 2.

Closes #102
Co-Authored-By: gpt-6.1-sol noreply@openai.com

Architect gate (2026-11-02): Part 2 dropped

Gate ruling R3 makes the image numbers binding. The image is built from 0003f3e (linux/arm64, SQLite 3.40.1). One container alternated three trees five times, each running scripts/bench_search.py --semantic from this PR. The three trees: base 170127c, Part 1 alone (170127c plus the keyset account term), and 0003f3e (Parts 1 and 2). Medians, ms:

Case base Part 1 Parts 1+2
plain (floor) 240.8 254.3 254.2
vector none 996.0 955.3 923.1
vector account=a 20,767.8 995.9 705.3
vector since= 489.2 647.6 570.8
  • Gate 1 passes. With Part 1, vector account=a costs 1.04x vector none (paired 0.89 0.97 1.05 1.02 0.85). On base it costs 20.85x.
  • Gate 2 fails. With Part 2, vector none costs 0.97x Part 1 alone (paired 1.76 1.04 0.91 0.77 1.07). The gate asks for 0.8x or less. The host measured a 22% cut, but the host is advisory under R3.

Commit e1a8304 removes Part 2 from store.py: _vector_copies, the copy maps, the high bound and the kept-row filter. The per-row copy probes stay. The keyset account term, the bench and all 96 tests in tests/test_vector_scans.py stay. The tests pass on Part 1 alone.

Part 2 also cut vector account=a by about 29% and vector since= by about 12%. These cases are outside the gate as ruled.

Checks on e1a8304:

  • make check: ruff, mypy and pip-audit clean; 762 passed, 18 deselected (the model tests ran).
  • make test-integration: 18 passed against GreenMail and Stalwart.

🤖 Generated with Claude Code

Exclude account terms from index selection only in vector keyset scans. Select copy representatives once per scan through copy_key, bound scans by their initial maximum ID, and skip hidden copies without yielding empty chunks. Add query-plan, scan-stream and byte-for-byte tool-output equivalence tests, plus an opt-in semantic benchmark and README usage note. Validation: focused suite 382 passed, 5 skipped; make check 754 passed, 8 skipped, with lint, types and audit green. Host benchmarks show a 22.09% reduction in unfiltered scan time with Part 2. Closes #102 Co-Authored-By: gpt-6.1-sol <noreply@openai.com> ## Architect gate (2026-11-02): Part 2 dropped Gate ruling R3 makes the image numbers binding. The image is built from 0003f3e (linux/arm64, SQLite 3.40.1). One container alternated three trees five times, each running `scripts/bench_search.py --semantic` from this PR. The three trees: base 170127c, Part 1 alone (170127c plus the `keyset` account term), and 0003f3e (Parts 1 and 2). Medians, ms: | Case | base | Part 1 | Parts 1+2 | |---|---|---|---| | plain (floor) | 240.8 | 254.3 | 254.2 | | vector none | 996.0 | 955.3 | 923.1 | | vector account=a | 20,767.8 | 995.9 | 705.3 | | vector since= | 489.2 | 647.6 | 570.8 | - **Gate 1 passes.** With Part 1, `vector account=a` costs 1.04x `vector none` (paired 0.89 0.97 1.05 1.02 0.85). On base it costs 20.85x. - **Gate 2 fails.** With Part 2, `vector none` costs 0.97x Part 1 alone (paired 1.76 1.04 0.91 0.77 1.07). The gate asks for 0.8x or less. The host measured a 22% cut, but the host is advisory under R3. Commit e1a8304 removes Part 2 from `store.py`: `_vector_copies`, the copy maps, the `high` bound and the kept-row filter. The per-row copy probes stay. The `keyset` account term, the bench and all 96 tests in `tests/test_vector_scans.py` stay. The tests pass on Part 1 alone. Part 2 also cut `vector account=a` by about 29% and `vector since=` by about 12%. These cases are outside the gate as ruled. Checks on e1a8304: - `make check`: ruff, mypy and pip-audit clean; 762 passed, 18 deselected (the model tests ran). - `make test-integration`: 18 passed against GreenMail and Stalwart. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Exclude account terms from index selection only in vector keyset scans. Select copy representatives once per scan through copy_key, bound scans by their initial maximum ID, and skip hidden copies without yielding empty chunks.

Add query-plan, scan-stream and byte-for-byte tool-output equivalence tests, plus an opt-in semantic benchmark and README usage note.

Validation: focused suite 382 passed, 5 skipped; make check 754 passed, 8 skipped, with lint, types and audit green. Host benchmarks show a 22.09% reduction in unfiltered scan time with Part 2.

Closes #102
Co-Authored-By: gpt-6.1-sol <noreply@openai.com>
Inside the image (SQLite 3.40.1), with head and Part 1 alternating in
one container, unfiltered vector_chunks with the copy maps was 0.97x of
Part 1 alone, not 0.8x or less. The #102 gate ruling R3 makes the image
numbers binding, so the per-row copy probes stay. The keyset account
term and every test remain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No description provided.