Repository navigation
refactor(storage): remove unused session profile FTS tables and triggers (#817) - #919
Conversation
…triggers (#817) Drop session_profiles_fts, session_profile_evidence_fts, session_profile_inference_fts, and session_profile_enrichment_fts. These had zero consumer-facing MATCH queries — only session_work_events_fts is actively searched. Their 12 triggers added per-row overhead to every session profile write. Replace FTS MATCH in list_session_profiles with LIKE on search_text columns, preserving tier-based column selection. Remove all associated status checks, readiness specs, repair targets, artifact definitions, and operation specs (13 files, -397/+102 lines). Add FTS safety regression tests: trigger restoration after normal ingest commit and after exception during ingest. Co-Authored-By: Claude Opus 4.7 <[email protected]>
|
Warning Rate limit exceeded
To continue reviewing without waiting, purchase usage credits in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 554879bdda
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
There was a problem hiding this comment.
Pull request overview
This PR removes now-unused session-profile FTS tables/triggers and updates status/reporting code and tests to reflect the simplified session-insight storage layout.
Changes:
- Updates unit tests that exercise FTS lifecycle behavior and session-insight readiness reporting.
- Simplifies derived retrieval-band metrics to stop depending on removed profile-FTS counters/readiness flags.
- Minor cleanup to session insight profile DDL formatting.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| tests/unit/storage/test_backend.py | Updates FTS trigger lifecycle tests for the new schema/FTS lifecycle expectations. |
| tests/unit/cli/test_insights.py | Adjusts CLI session-insight status assertions after removing profile FTS status fields. |
| polylogue/storage/sqlite/schema_ddl_insight_profiles.py | Minor DDL string formatting cleanup. |
| polylogue/storage/derived/derived_status.py | Removes profile-FTS readiness dependencies from retrieval-band derived statuses and recalculates metrics accordingly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # FTS should have both messages (the original m1 via repair, | ||
| # and m2 via active trigger after restore) | ||
| ||||||| parent of e895ccf5 (refactor(storage): remove 4 unused session profile FTS tables and 12 triggers (#817)) | ||
| """FTS triggers must be active even after an exception during ingest (#817).""" | ||
| import sqlite3 |
| from polylogue.storage.sqlite.schema_ddl_actions import ACTION_EVENT_DDL | ||
| from polylogue.storage.sqlite.schema_ddl_archive import ARCHIVE_STORAGE_DDL, MESSAGE_FTS_DDL | ||
|
|
||
| db = tmp_path / "fts_commit.db" | ||
| conn = sqlite3.connect(str(db)) | ||
| conn.executescript(ARCHIVE_STORAGE_DDL) | ||
| conn.executescript(ACTION_EVENT_DDL) |
| # Restore BEFORE commit (the fix for #817) | ||
| restore_fts_triggers_sync(conn) | ||
| conn.commit() | ||
| # Rebuild FTS to catch messages inserted with triggers suspended | ||
| rebuild_fts_index_sync(conn) | ||
| conn.commit() |
| "expected_evidence_retrieval_rows": expected_evidence_rows, | ||
| "evidence_retrieval_ready": session_status.profile_evidence_fts_ready | ||
| and bool(action_status["action_fts_ready"]), | ||
| "evidence_retrieval_ready": True and bool(action_status["action_fts_ready"]), |
| "inference_retrieval_rows": inference_rows, | ||
| "expected_inference_retrieval_rows": expected_inference_rows, | ||
| "inference_retrieval_ready": session_status.profile_inference_fts_ready | ||
| "inference_retrieval_ready": True |
| "enrichment_retrieval_rows": int(metrics["profile_rows"]), | ||
| "expected_enrichment_retrieval_rows": int(metrics["profile_rows"]), | ||
| "enrichment_retrieval_ready": session_status.profile_enrichment_fts_ready, | ||
| "enrichment_retrieval_ready": True, | ||
| } |
| def test_targeted_session_insight_rebuild_does_not_duplicate_profile_fts(cli_workspace: CliWorkspace) -> None: | ||
| _seed_products(cli_workspace) | ||
|
|
||
| with open_connection(cli_workspace["db_path"]) as conn: | ||
| rebuild_session_insights_sync(conn, conversation_ids=["conv-root"]) | ||
| status = session_insight_status_sync(conn) | ||
|
|
||
| assert status.profile_row_count == 2 | ||
| assert status.profile_merged_fts_count == 2 | ||
| assert status.profile_merged_fts_duplicate_count == 0 | ||
| assert status.profile_merged_fts_ready is True | ||
| assert status.profile_rows_ready is True |
|
|
||
| # FTS should have both messages (the original m1 via repair, | ||
| # and m2 via active trigger after restore) |
Closes the #817 FTS-bloat slice by removing four `session_*` FTS virtual tables and their twelve sync triggers that never had a live consumer after the session-insight rewrite. The tables shadowed `messages_fts` semantics on the session-profile rows, doubled write load on every profile rebuild, and contributed indirectly to the FTS startup-scan symptoms reported in #845/#858. - `polylogue/storage/sqlite/schema_ddl_insight_profiles.py`: removes the four FTS virtual tables and their triggers. - `storage/derived/derived_status.py`: removes the readiness shape that referenced the dropped tables. - `tests/unit/cli/test_insights.py`, `tests/unit/storage/test_backend.py`: tests updated to the new insight-profile shape. Net effect across the wider PR diff: 14 files +94/-396 lines. Refs #817
Closes the #817 FTS-bloat slice by removing four `session_*` FTS virtual tables and their twelve sync triggers that never had a live consumer after the session-insight rewrite. The tables shadowed `messages_fts` semantics on the session-profile rows, doubled write load on every profile rebuild, and contributed indirectly to the FTS startup-scan symptoms reported in #845/#858. - `polylogue/storage/sqlite/schema_ddl_insight_profiles.py`: removes the four FTS virtual tables and their triggers. - `storage/derived/derived_status.py`: removes the readiness shape that referenced the dropped tables. - `tests/unit/cli/test_insights.py`, `tests/unit/storage/test_backend.py`: tests updated to the new insight-profile shape. Net effect across the wider PR diff: 14 files +94/-396 lines. Refs #817
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Removed 4 unused session FTS tables + 12 triggers. 14 files +94/-396.