Make search copy collapse set-based with an indexed key #103
No reviewers
Labels
No labels
bug
enhancement
epic
needs-info
needs-triage
ready-for-agent
ready-for-human
svd:go
svd:hold
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
dev/mail-mind-mcp!103
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/svd-dev-imap-mailmind-mcp-96-make-the-59-copy-collapse-c-21adcf62"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add schema v10's guarded virtual copy_key column and covering index, with an idempotent migration using table_xinfo. Share set-based collapse queries across search, triage counts and keyword ranking while preserving filters, representative selection, pagination totals and FTS fallback.
Add reference-SQL equivalence, tool-output, migration, unsafe-date and query-plan tests. Update schema assertions and document migration and benchmark usage. Existing copy tests remain unchanged.
Validation: 356 filtered tests passed; make check passed with 658 tests passed, 8 skipped and 18 deselected, plus lint, typing and vulnerability audit.
Benchmark medians on voyager, macOS arm64, Python 3.14.5, SQLite 3.50.4; identical script, 210,000 rows, one warm-up and five runs. Baseline
3af5d34used a temporary source export; new code ran in the dispatch worktree.Search | baseline ms | new ms | ratio
none | 438.660 | 249.447 | 0.569x
account=a | 320.699 | 210.141 | 0.655x
sender=user7@ | 284.263 | 318.800 | 1.121x
All three meet the 1.5x bound. Optional ungated FTS medians: lorem 586.923 -> 714.880 ms; 1234 0.054 -> 0.154 ms. The approved spec-time no-schema prototype missed at 1.66–1.69x, supporting the v10 approach under ruling R1.
Closes #96
Co-Authored-By: gpt-6.1-sol noreply@openai.com
Rework at the gate (architect, 2026-11-01)
Two commits after
30547f1, on the operator's rework rider: build the duplicate-key set from rows that pass the filters, and show the bench inside the image.9602aecapplied the filters insidedup. Inside the image this was slower. SQLite 3.40.1 does not treat the index on the virtualcopy_keycolumn as covering, so grouping a broad filter by key read every row.868e450finds candidate Message-IDs frommessages_copies (message_id, from_addr), which covers. It then groups only their filter-passing rows bycopy_key. The duplicate-key set is built from filter-passing rows only.test_account_plan_looks_up_ranked_copies_by_keynow asserts the covering candidate scan and bans a scan of every key (copy_key>?). It fails on30547f1and on9602aec, and passes on868e450.Bench inside the image
Image built from
868e450(linux/arm64, Python 3.12.16, SQLite 3.40.1). The bench script is unchanged. One container alternated head and3af5d34five times; the podman VM has 2 GiB of memory. Separate containers drifted by up to 2x for the same code, so only same-container pairs count.3af5d34median msAll three ratios of medians are within 1.5x. One sender pair reads 2.54x, in a round where other pairs also swung.
Checks on
868e450make check: ruff, mypy and pip-audit clean; 666 passed, 18 deselected (the model tests ran).make test-integration: 18 passed against GreenMail and Stalwart.The write set is unchanged:
store.pyandtests/test_copy_collapse.pyonly.🤖 Generated with Claude Code