Claude Code subagent imported from Rah-Rah-Mitra/Arcane (
.claude/agents/search-index-auditor.md). Copyright stays with the author.
Search Index Auditor Agent
Focus files
src/search/indexer.rs— schema,index_source,remove_source, index lifecyclesrc/search/query.rs—search, project/source filter constructionsrc/pdf/text.rs—extract_all,extract_rangesrc/cli/commands/workflow.rs— cmd_reindex, cmd_freq, cmd_search
Responsibilities
Schema alignment (indexer.rs)
- Verify 6 fields match between schema definition and document building:
source_id(STRING),project(STRING),title(STRING),chapter(STRING),page(U64 STORED),body(TEXT) - Audit that
source_idformat"project_name:source_title"is consistent acrossindex_source,remove_source, and search filter construction
index_source idempotency
- Verify pattern:
remove_source(source_id)called beforeindex_sourceincmd_reindex - Check that
remove_sourcedeletes ALL documents for a source_id, not just the first - Audit Tantivy writer commit — must call
writer.commit()after all docs added
remove_source correctness
- Audit
DeleteTermquery onsource_idfield — must use exact STRING match - Verify writer is committed after delete (otherwise delete is not visible to readers)
search query (query.rs)
- Audit
BooleanQueryconstruction for project/source filters:Must(TermQuery(project = "MyProject"))narrows to projectMust(TermQuery(title = "MySource"))narrows to source
- Verify score computation — body TEXT field should dominate ranking
- Check that empty query string returns no results (not all documents)
Text extraction (text.rs)
- Audit
extract_allfor lopdf encoding edge cases:- PDFDocEncoding vs UTF-16BE in
/ToUnicodeCMaps - Ligatures (fi, fl, ff) may appear as single glyphs
- CID fonts without /ToUnicode map → garbled text (log warning, don't panic)
- PDFDocEncoding vs UTF-16BE in
- Verify
extract_rangepage indices are 0-based (matching lopdfget_pages()) - Check that empty pages (images only) produce empty strings, not errors
Frequency dictionary (freq.rs)
- Audit
build_frequency_dict: must aggregate across all pages for the project - Verify stop-word filtering is applied before sorting
- Check output format: one
word\tcountpair per line, sorted descending - Audit
write_freq_file: file should be truncated on overwrite, not appended
Performance targets
extract_allon a 500-page PDF: < 10s on release buildreindexfor 10 sources × 300 pages each: < 60s on release buildsearchwith project filter: < 100ms for any query
Edge cases to test
- Source with 0 pages (empty PDF) — should index gracefully with 0 pages
- Source title containing
:— source_id delimiter; verify escaping - Unicode title with non-ASCII characters — Tantivy STRING field must store verbatim
- Very large source (1000+ pages) — memory usage should stay bounded