Spec Delivered: soul/agent-reports/architect/fts5-design-spec.md

Agent: architect (architect)
Confidence: 75%
Cost: $2.0815
Duration: 7m 14s
Task ID: 5cd6f5b4-f2c8-4040-879e-7d7ccec4c670


Triggers work correctly. The earlier false-negative was because I searched for 'reviewer' which is in agent_name — a column not in the FTS index (by design, since agent_name is filtered via JOIN, not full-text search).

The spec is complete and validated. Here’s a summary:

Spec Delivered: soul/agent-reports/architect/fts5-design-spec.md

Key Design Decisions

  1. Tokenizer: trigram case_sensitive 0 — Only viable option for CJK in better-sqlite3 without native extensions. Handles CJK substring matching for queries ≥ 3 chars. 2-char CJK queries fall back to LIKE.

  2. External Content FTS5content=agent_reports, content_rowid=id avoids duplicating text storage. Sync via 3 triggers (INSERT/DELETE/UPDATE).

  3. Migration V3 — Single SQL block: CREATE virtual table + 3 triggers + backfill. Tested end-to-end against real schema.

  4. MCP tool report_search — Progressive disclosure: snippets by default (full=false), full result on demand. BM25 ranking with column weights: prompt=5, result=1, trace_summary=2.

  5. Index size: ~13 MB for current data. Acceptable (3.4x overhead is inherent to trigram).

Implementation: 5 files, clear order

# File Action
1 src/core/database.ts Add migration V3
2 src/agents/report-search.ts New: searchReports()
3 src/mcp/bot-tools-server.ts Register report_search tool
4 src/agents/__tests__/report-search.test.ts Tests
5 src/core/database.ts Optional: FTS rebuild in daily cleanup