Skip to content

refactor(storage): remove unused session profile FTS tables and triggers (#817) - #919

Merged
Sinity merged 1 commit into
masterfrom
feature/refactor/fts-cleanup-817
May 7, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/refactor/fts-cleanup-817

Conversation

@Sinity

@Sinity Sinity commented May 7, 2026

Copy link
Copy Markdown
Owner

Removed 4 unused session FTS tables + 12 triggers. 14 files +94/-396.

…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]>
Copilot AI review requested due to automatic review settings May 7, 2026 15:23
@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Sinity has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 32 minutes and 31 seconds before requesting another review.

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 @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 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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: fff3d639-19e3-42f5-90eb-18743ffb9ac1

📥 Commits

Reviewing files that changed from the base of the PR and between 40b9f6e and 554879b.

📒 Files selected for processing (4)
  • polylogue/storage/derived/derived_status.py
  • polylogue/storage/sqlite/schema_ddl_insight_profiles.py
  • tests/unit/cli/test_insights.py
  • tests/unit/storage/test_backend.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/refactor/fts-cleanup-817

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 0f19458 into master May 7, 2026
5 checks passed
@Sinity
Sinity deleted the feature/refactor/fts-cleanup-817 branch May 7, 2026 15:23

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread tests/unit/storage/test_backend.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines 1642 to +1646
# 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
Comment on lines +1557 to +1563
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)
Comment on lines +1587 to +1592
# 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
Comment on lines +129 to 132
"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,
}
Comment on lines 824 to +832
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
Comment on lines 1641 to 1643

# FTS should have both messages (the original m1 via repair,
# and m2 via active trigger after restore)
Sinity added a commit that referenced this pull request May 7, 2026
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
Sinity added a commit that referenced this pull request May 7, 2026
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
@Sinity

Sinity commented Sep 30, 2026

Copy link
Copy Markdown
Owner Author

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.

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.

2 participants