Skip to content

refactor: SQL dedup — import from core/common, remove 138 lines of duplication (#784, #781) - #798

Merged
Sinity merged 1 commit into
masterfrom
feature/fix/remaining-audit-gaps
May 4, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/fix/remaining-audit-gaps

Conversation

@Sinity

@Sinity Sinity commented May 4, 2026

Copy link
Copy Markdown
Owner

Remove 8 duplicated SQL constants from _models.py. Import from canonical core/common.py. Linter exits 0. _models.py: 233→104 lines.

…_sort (#784, #781)

- #784: Remove 8 duplicated SQL constants from _models.py, import from
  canonical polylogue/core/common.py instead. Add _IDENTITY_LEDGER_UPSERT_SQL
  to core/common.py. verify_sql_templates.py linter now exits 0.
- #781: _models.py at 104 lines (down from 233). Package structure enables
  future incremental splits.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
Copilot AI review requested due to automatic review settings May 4, 2026 03:26
@Sinity
Sinity merged commit bce5d49 into master May 4, 2026
@Sinity
Sinity deleted the feature/fix/remaining-audit-gaps branch May 4, 2026 03:26
@coderabbitai

coderabbitai Bot commented May 4, 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 41 minutes and 12 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: 3b8cda2b-9824-4e02-9971-12e7001225c0

📥 Commits

Reviewing files that changed from the base of the PR and between f9c8cf8 and 57aa956.

📒 Files selected for processing (3)
  • polylogue/core/common.py
  • polylogue/pipeline/services/ingest_batch/_core.py
  • polylogue/pipeline/services/ingest_batch/_models.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/remaining-audit-gaps

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 41 minutes and 12 seconds.

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

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

Refactors the batch ingest pipeline to eliminate duplicated SQLite SQL template strings by centralizing them in polylogue/core/common.py, reducing drift risk between write paths and shrinking _models.py.

Changes:

  • Removed duplicated SQL template constants from polylogue/pipeline/services/ingest_batch/_models.py.
  • Updated polylogue/pipeline/services/ingest_batch/_core.py to import the canonical SQL templates from polylogue/core/common.py.
  • Added _IDENTITY_LEDGER_UPSERT_SQL to the canonical SQL template set in polylogue/core/common.py.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
polylogue/pipeline/services/ingest_batch/_models.py Deletes duplicated SQL constants; leaves a trailing “re-export” comment.
polylogue/pipeline/services/ingest_batch/_core.py Switches SQL template imports from _models.py to core.common.
polylogue/core/common.py Introduces the identity-ledger upsert SQL template into the shared canonical module.
Comments suppressed due to low confidence (2)

polylogue/pipeline/services/ingest_batch/_models.py:105

  • The file no longer re-exports any SQL constants, but this trailing comment says they are “Re-exported from canonical source polylogue/core/common.py”. Either remove this comment or add explicit re-exports/imports so the statement is accurate.
# Re-exported from canonical source polylogue/core/common.py

polylogue/core/common.py:157

  • IDENTITY_LEDGER_UPSERT_SQL is added here but (unlike the other SQL templates) there is no corresponding SQL* public export or all entry. If this statement is intended to be part of the canonical shared SQL surface, add a SQL_IDENTITY_LEDGER_UPSERT alias and include it in all (then consumers can import the public name).
_IDENTITY_LEDGER_UPSERT_SQL = """
INSERT OR IGNORE INTO identity_ledger (
    provider, source, source_path, provider_conversation_id, raw_hash, current_conversation_id
) VALUES (?, ?, ?, ?, ?, ?)
"""


# Public exports — both sync and async write paths import these directly.
SQL_CONVERSATION_UPSERT = _CONVERSATION_UPSERT_SQL
SQL_MESSAGE_UPSERT = _MESSAGE_UPSERT_SQL
SQL_CONTENT_BLOCK_UPSERT = _CONTENT_BLOCK_UPSERT_SQL
SQL_STATS_UPSERT = _STATS_UPSERT_SQL
SQL_ACTION_EVENT_INSERT = _ACTION_EVENT_INSERT_SQL
SQL_ATTACHMENT_UPSERT = _ATTACHMENT_UPSERT_SQL
SQL_ATTACHMENT_REF_INSERT = _ATTACHMENT_REF_INSERT_SQL


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

Comment on lines +26 to +33
_ACTION_EVENT_INSERT_SQL,
_ATTACHMENT_REF_INSERT_SQL,
_ATTACHMENT_UPSERT_SQL,
_CONTENT_BLOCK_UPSERT_SQL,
_CONVERSATION_UPSERT_SQL,
_IDENTITY_LEDGER_UPSERT_SQL,
_MESSAGE_UPSERT_SQL,
_STATS_UPSERT_SQL,
Sinity added a commit that referenced this pull request May 7, 2026
…plication (#784, #781) (#798)

Remove 8 duplicated SQL constants from _models.py. Import from canonical
core/common.py. Linter exits 0. _models.py: 233→104 lines.

Co-authored-by: Claude Opus 4.7 <[email protected]>
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