Skip to content

fix(pipeline): commit sync ingest side effects - #707

Merged
Sinity merged 1 commit into
masterfrom
feature/fix/sync-ingest-search-side-effects
May 2, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/fix/sync-ingest-search-side-effects

Conversation

@Sinity

@Sinity Sinity commented May 2, 2026

Copy link
Copy Markdown
Owner

Summary

Commit the sync-ingest FTS teardown phase and invalidate cached search results after changed conversations are written through the direct sqlite batch path.

Problem

#618 identified that _process_ingest_batch_sync() committed the main ingest transaction, then restored FTS triggers and repaired message/action FTS rows outside any explicit committed unit. If sqlite opened an implicit transaction for that teardown work, closing the connection could lose the trigger restoration or repaired FTS rows. The same direct write path also bypassed search cache invalidation, so a cached empty search could stay stale in the same process after ingest.

Solution

Add a committed sync-ingest side-effect phase that:

  • restores FTS triggers after the suspended-trigger batch write;
  • repairs changed-conversation message and action-event FTS rows;
  • commits the teardown DDL/DML before closing the connection;
  • invalidates the search cache when conversations changed.

The regression exercises _process_ingest_batch_sync() with a fake worker result, verifies message/action FTS rows and triggers from a fresh connection, and proves the same cached search query sees the new conversation after ingest.

Verification

  • ruff check polylogue/pipeline/services/ingest_batch.py tests/unit/pipeline/test_ingest_batch.py
  • ruff format --check polylogue/pipeline/services/ingest_batch.py tests/unit/pipeline/test_ingest_batch.py
  • pytest -q tests/unit/pipeline/test_ingest_batch.py
  • git push pre-push hook: devtools verify --quick passed

Ref #618

Problem: the sync ingest path suspended FTS triggers during batch writes, then restored triggers and repaired changed-conversation FTS rows after the main commit without committing that teardown work. It also bypassed search cache invalidation, so same-process cached searches could stay stale after direct ingest writes.

What changed: move sync-ingest teardown into a committed side-effect phase that restores FTS triggers, repairs changed message/action FTS rows, commits that work, and invalidates the search cache when conversations changed.

Verification: ruff check polylogue/pipeline/services/ingest_batch.py tests/unit/pipeline/test_ingest_batch.py; ruff format --check polylogue/pipeline/services/ingest_batch.py tests/unit/pipeline/test_ingest_batch.py; pytest -q tests/unit/pipeline/test_ingest_batch.py

Ref #618
Copilot AI review requested due to automatic review settings May 2, 2026 15:18
@coderabbitai

coderabbitai Bot commented May 2, 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 38 minutes and 38 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ 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: bf2bf7b2-b4c2-4d1b-bfd0-e7c4eebc2a15

📥 Commits

Reviewing files that changed from the base of the PR and between 48476cd and b1157db.

📒 Files selected for processing (2)
  • polylogue/pipeline/services/ingest_batch.py
  • tests/unit/pipeline/test_ingest_batch.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/sync-ingest-search-side-effects

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
Review rate limit: 0/1 reviews remaining, refill in 38 minutes and 38 seconds.

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

@github-actions

github-actions Bot commented May 2, 2026

Copy link
Copy Markdown
Contributor

Polylogue Proof Pack

Refs: origin/master..HEAD
Changed paths: 2

Affected Domains

  • none with affected claims

Focused Gates

  • none

Required PR Gates

  • devtools verify --quick — full PR gate remains explicit
  • devtools verify — full PR gate remains explicit

Optional Confidence Gates

  • devtools build-package — deployment readiness gate; run when packaging or release confidence matters
  • nix flake check — deployment readiness gate; run when packaging or release confidence matters

Known Gaps

  • none for domains with affected claims

Oracle / Cost

  • oracle mix: {}
  • cost tier: {}
  • stable affected obligations: 0
  • agent judgment cells: 0

@Sinity
Sinity merged commit 981fbb3 into master May 2, 2026
15 checks passed
@Sinity
Sinity deleted the feature/fix/sync-ingest-search-side-effects branch May 2, 2026 15:19

@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: b1157dbd96

ℹ️ 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".

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 fixes correctness gaps in the synchronous ingest write path by ensuring FTS teardown/repair work is committed as an explicit unit and that in-process search result caching is invalidated when conversations change.

Changes:

  • Add a committed “sync-ingest side effects” phase that restores FTS triggers, repairs FTS rows for changed conversations, and commits before closing the SQLite connection.
  • Invalidate the in-process search cache when sync ingest writes changed conversations.
  • Add a regression test that proves FTS repairs/triggers persist across a fresh connection and that cached searches observe newly ingested content after invalidation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
polylogue/pipeline/services/ingest_batch.py Introduces a committed post-ingest side-effect phase (FTS trigger restore + FTS repair + cache invalidation).
tests/unit/pipeline/test_ingest_batch.py Adds a regression test covering committed FTS teardown/repair persistence and search cache invalidation behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sinity added a commit that referenced this pull request May 7, 2026
Summary: Commit the sync-ingest FTS teardown phase and invalidate cached search results after changed conversations are written through the direct sqlite batch path.

Problem: #618 identified that _process_ingest_batch_sync() committed the main ingest transaction, then restored FTS triggers and repaired message/action FTS rows outside any explicit committed unit. If sqlite opened an implicit transaction for that teardown work, closing the connection could lose the trigger restoration or repaired FTS rows. The same direct write path also bypassed search cache invalidation, so same-process cached searches could stay stale after ingest.

Solution: Add a committed sync-ingest side-effect phase that restores FTS triggers after suspended-trigger batch writes, repairs changed-conversation message and action-event FTS rows, commits the teardown DDL/DML before closing the connection, and invalidates the search cache when conversations changed. The regression exercises _process_ingest_batch_sync() with a fake worker result, verifies message/action FTS rows and triggers from a fresh connection, and proves the same cached search query sees the new conversation after ingest.

Verification: ruff check polylogue/pipeline/services/ingest_batch.py tests/unit/pipeline/test_ingest_batch.py; ruff format --check polylogue/pipeline/services/ingest_batch.py tests/unit/pipeline/test_ingest_batch.py; pytest -q tests/unit/pipeline/test_ingest_batch.py; git push pre-push hook ran devtools verify --quick and passed.

Ref #618
@Sinity

Sinity commented Oct 1, 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