Skip to content

fix(search): repair FTS during live ingest - #1502

Merged
Sinity merged 1 commit into
masterfrom
feature/fix/live-fts-freshness
May 24, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/fix/live-fts-freshness

Conversation

@Sinity

@Sinity Sinity commented May 24, 2026

Copy link
Copy Markdown
Owner

Summary

Make live ingest maintain FTS freshness as a hard write-side contract instead of relying on trigger timing alone.

Problem

#1500 fixed daemon startup readiness, but live catch-up on the production archive still drifted while the daemon was running. With the daemon stopped, exact invariant evidence showed:

messages_fts: source_rows=986362 indexed_rows=975948 missing_rows=10414
 action_events_fts: source_rows=354184 indexed_rows=350407 missing_rows=3777

The missing message rows were block-only messages whose searchable content lives in content_blocks; missing action rows were normal action_events. Live full/append ingest had been opting out of conversation-scoped repair unless triggers were explicitly suspended, and write effects ignored an explicit repair request when triggers were present.

Closes #1501.

Solution

  • commit_archive_write_effects now treats repair_message_fts=True and repair_action_fts=True literally: changed conversations are repaired even when triggers exist.
  • Live full ingest and append ingest explicitly request message/action FTS repair for changed conversations.
  • Daemon stale-startup recovery refreshes trigger definitions before rebuilding, so stale trigger bodies cannot survive a rebuild.
  • Exact FTS invariant snapshots run inside one read transaction so source counts and shadow-table counts describe the same DB moment.

Verification

  • pytest tests/unit/archive/test_write_gateway.py tests/unit/daemon/test_daemon_cli.py tests/unit/sources/test_live_batch_support.py tests/unit/storage/test_retrieval_readiness_laws.py tests/unit/storage/test_perf_rescue_1314.py tests/unit/pipeline/test_ingest_batch.py tests/unit/pipeline/test_ingest_batch_wal_checkpoint.py tests/unit/storage/test_fts_trigger_lifecycle.py -q
    • 87 passed in 1.93s
  • devtools verify --quick
    • exit_code: 0, total_duration_s: 35.97
  • Pre-push devtools verify --quick
    • exit_code: 0, total_duration_s: 34.78
  • Live archive repair with the daemon stopped:
    • missing_message_conversations=11 missing_action_conversations=10 union=11
    • ready=True
    • messages_fts 986362 986362 0 0 0 True
    • action_events_fts 354184 354184 0 0 0 True
    • session_work_events_fts 10192 10192 0 0 0 True
    • work_threads_fts 1922 1922 0 0 0 True

Problem: exact startup readiness from #1500 proved the archive could start ready, then live catch-up still left message and action-event FTS rows missing before the next restart. The live paths opted out of conversation-scoped repair unless triggers were suspended, and write effects ignored explicit repair requests when triggers were present.

What changed: live full and append ingest now request message/action FTS repair for changed conversations, write effects honor explicit repair requests unconditionally, stale startup rebuild refreshes trigger definitions before rebuilding, and exact invariant snapshots use a single read transaction.

Verification: pytest tests/unit/archive/test_write_gateway.py tests/unit/daemon/test_daemon_cli.py tests/unit/sources/test_live_batch_support.py tests/unit/storage/test_retrieval_readiness_laws.py tests/unit/storage/test_perf_rescue_1314.py tests/unit/pipeline/test_ingest_batch.py tests/unit/pipeline/test_ingest_batch_wal_checkpoint.py tests/unit/storage/test_fts_trigger_lifecycle.py -q; devtools verify --quick; live archive targeted FTS repair reported all surfaces ready with zero missing/excess/duplicates.

Closes #1501
@coderabbitai

coderabbitai Bot commented May 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Sinity, we couldn't start this review because you've used your available PR reviews for now.

Your plan currently allows 1 review/hour. Refill in 32 minutes and 55 seconds.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more review capacity refills, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4ec9756c-0db8-4eeb-b660-b0a2538c59c5

📥 Commits

Reviewing files that changed from the base of the PR and between ee5a507 and 1efe901.

📒 Files selected for processing (8)
  • polylogue/archive/write_effects.py
  • polylogue/daemon/cli.py
  • polylogue/sources/live/append_ingest.py
  • polylogue/sources/live/batch.py
  • polylogue/storage/fts/fts_lifecycle.py
  • tests/unit/archive/test_write_gateway.py
  • tests/unit/daemon/test_daemon_cli.py
  • tests/unit/sources/test_live_batch_support.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/live-fts-freshness

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Sinity
Sinity merged commit ff0fcc9 into master May 24, 2026
6 checks passed
@Sinity
Sinity deleted the feature/fix/live-fts-freshness branch May 24, 2026 16:28
Sinity added a commit that referenced this pull request Aug 17, 2026
polylogue-gibn1, decisive: instrumented the sole consumer of
summary.fts_repair_session_ids (_commit_sync_ingest_side_effects) and it never
printed across five sessions and sixty messages in the failing
convergence-evidence test. The repair is nested inside `if transaction_started`,
so a route with an externally managed transaction skips FTS repair along with
every other post-write side effect.

Eliminated: repair_message_fts (defaults True everywhere, no daemon override),
the repair queue itself (content_changed appends unconditionally), the invariant
reader, and the triggers. Three independent places each assume another will
populate the index: replay defers the reinsert, ingest-side repair never runs,
and the path-scoped convergence check is a hardcoded `return False`.

Read the #1498 cascade retro as CLAUDE.md requires; its closed list names the
adjacent history (#1462, #1469, #1472, #1500, #1502), several of which narrowed
FTS repair to avoid redundant work. Those PR bodies are the place to start.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HWcPJJJvuF25CqVwTFgSQC
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.

fix(search): keep FTS fresh across live ingest writes

1 participant