Repository navigation
fix: add FTS trigger awareness to readiness checks and self-healing repair - #554
Conversation
…epair Missing triggers after suspend/resume cycles caused silent index staleness that went undetected by readiness checks and doctor diagnostics. Now readiness verifies all three messages_fts triggers exist, dangling_fts repair recreates them, and ensure_fts_index auto-recovers on connection. Co-Authored-By: Claude Opus 4.7 <[email protected]>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThe changes enhance FTS (Full-Text Search) trigger management by adding trigger presence verification to readiness checks, restoring triggers during index maintenance and repair operations, and updating test stubs to reflect conditional schema queries. These modifications ensure missing FTS triggers are detected and reported during readiness assessments and restored as part of repair workflows. Changes
Sequence Diagram(s)sequenceDiagram
actor Client
participant Readiness
participant FTS Lifecycle
participant Database
Client->>Readiness: Check index readiness
Readiness->>FTS Lifecycle: message_fts_readiness_sync()
FTS Lifecycle->>Database: Query sqlite_master for FTS triggers
Database-->>FTS Lifecycle: Returns trigger presence status
FTS Lifecycle-->>FTS Lifecycle: Compute readiness with triggers_present
FTS Lifecycle-->>Readiness: Return {ready, triggers_present, ...}
alt Triggers Missing
Readiness-->>Client: Return stale index warning + dangling_fts repair action
else Triggers Present
Readiness-->>Client: Return standard warning or ready status
end
sequenceDiagram
actor Client
participant Repair
participant Database
participant FTS Lifecycle
Client->>Repair: repair_dangling_fts()
Repair->>Database: INSERT INTO messages_fts (repaired rows)
Repair->>FTS Lifecycle: restore_fts_triggers_sync(conn)
FTS Lifecycle->>Database: Create/verify FTS triggers exist
Database-->>FTS Lifecycle: Triggers restored
FTS Lifecycle-->>Repair: Complete
Repair->>Database: conn.commit()
Repair-->>Client: Repair complete
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
## Summary Add NotebookEdit tool dispatch to `extract_file_changes` in semantic_capture.py. ## Problem The function handled Read, Write, and Edit tool invocations but silently dropped NotebookEdit operations from Claude Code sessions. ## Solution Added NotebookEdit branch that extracts `new_source` content and records it as an edit operation. Note: the other two items from #552 (FTS suspend outside try block, missing embed stage dispatch) were already fixed in #554 and #558. Closes #552 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.7 <[email protected]>
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…epair (#554) ## Summary FTS triggers could be silently missing after suspend/resume cycles, causing index staleness that went undetected by readiness checks and doctor diagnostics. ## Problem When `suspend_fts_triggers` ran and the process terminated before `restore_fts_triggers` (crash, interrupt, or exception between the two calls), triggers stayed dropped permanently. Readiness checks only verified row counts — they never checked whether the FTS triggers actually existed. `ensure_fts_index` also didn't recreate triggers, so any code path that created FTS tables via that function left them triggerless. ## Solution Three-layer fix: 1. **`fts_lifecycle.py`**: Split `_FTS_TRIGGER_NAMES` into `_MESSAGE_FTS_TRIGGER_NAMES` and `_ACTION_EVENT_FTS_TRIGGER_NAMES`. Added `_triggers_present_sync/async` helpers that query `sqlite_master` for trigger existence. Updated `message_fts_readiness_sync/async` to check triggers and return `triggers_present` in the result dict. `ensure_fts_index_sync/async` now call `restore_fts_triggers` after creating FTS tables. 2. **`repair.py`**: `repair_dangling_fts` now calls `restore_fts_triggers_sync` after fixing orphaned rows, using `CREATE TRIGGER IF NOT EXISTS` for idempotency. 3. **`readiness/__init__.py`**: Doctor reads `triggers_present` from the readiness result and reports a specific WARNING when triggers are missing. ## Verification - `devtools verify --quick` (format, lint, mypy, render-all, topology checks) - Unit tests: `pytest -q --ignore=tests/integration` — 3963 passed - `test_fts5.py` stub updated to return proper trigger count 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.7 <[email protected]>
## Summary Add NotebookEdit tool dispatch to `extract_file_changes` in semantic_capture.py. ## Problem The function handled Read, Write, and Edit tool invocations but silently dropped NotebookEdit operations from Claude Code sessions. ## Solution Added NotebookEdit branch that extracts `new_source` content and records it as an edit operation. Note: the other two items from #552 (FTS suspend outside try block, missing embed stage dispatch) were already fixed in #554 and #558. Closes #552 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.7 <[email protected]>
Summary
FTS triggers could be silently missing after suspend/resume cycles, causing index staleness that went undetected by readiness checks and doctor diagnostics.
Problem
When
suspend_fts_triggersran and the process terminated beforerestore_fts_triggers(crash, interrupt, or exception between the two calls), triggers stayed dropped permanently. Readiness checks only verified row counts — they never checked whether the FTS triggers actually existed.ensure_fts_indexalso didn't recreate triggers, so any code path that created FTS tables via that function left them triggerless.Solution
Three-layer fix:
fts_lifecycle.py: Split_FTS_TRIGGER_NAMESinto_MESSAGE_FTS_TRIGGER_NAMESand_ACTION_EVENT_FTS_TRIGGER_NAMES. Added_triggers_present_sync/asynchelpers that querysqlite_masterfor trigger existence. Updatedmessage_fts_readiness_sync/asyncto check triggers and returntriggers_presentin the result dict.ensure_fts_index_sync/asyncnow callrestore_fts_triggersafter creating FTS tables.repair.py:repair_dangling_ftsnow callsrestore_fts_triggers_syncafter fixing orphaned rows, usingCREATE TRIGGER IF NOT EXISTSfor idempotency.readiness/__init__.py: Doctor readstriggers_presentfrom the readiness result and reports a specific WARNING when triggers are missing.Verification
devtools verify --quick(format, lint, mypy, render-all, topology checks)pytest -q --ignore=tests/integration— 3963 passedtest_fts5.pystub updated to return proper trigger count🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Tests