Skip to content

fix(intent): mirror 'expired' predicate in roux_ingest ON CONFLICT - #118

Merged
chitcommit merged 1 commit into
mainfrom
fix/intent-on-conflict-expired-predicate
Jun 10, 2026
Merged

chitcommit merged 1 commit into
mainfrom
fix/intent-on-conflict-expired-predicate

Conversation

@chitcommit

@chitcommit chitcommit commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

What

Adds AND status <> 'expired' to the ON CONFLICT inference predicate in createRouxIngestIntentIdempotent (meta/intent.ts), mirroring the partial unique index.

Why

PR #115 (Roux intent decay cron, migration 0018_intent_decay.sql) recreated cc_intents_roux_ingest_message_id_uidx with a narrowed predicate:

WHERE intent_type = 'roux_ingest'
  AND payload->'source'->>'message_id' IS NOT NULL
  AND status <> 'expired';

The idempotent-insert path's ON CONFLICT (...) WHERE ... was not updated to match. Postgres requires the ON CONFLICT inference predicate to exactly match a partial unique index's WHERE. Without this clause, every createRouxIngestIntentIdempotent call would fail with:

there is no unique or exclusion constraint matching the ON CONFLICT specification

i.e. the Roux ingest idempotency path was broken the moment #115 deployed.

Verification

Predicate confirmed against the authoritative migration source migrations/0018_intent_decay.sql:20-24 — the code WHERE now matches the live index WHERE exactly (3 clauses, same order).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Fixed ingestion conflict handling to exclude expired entries from duplicate detection, enabling re-creation of expired records instead of blocking new entries.

…LICT

PR #115 / migration 0018 added `AND status <> 'expired'` to the partial
unique index `cc_intents_roux_ingest_message_id_uidx` but did not update
the upsert's ON CONFLICT WHERE clause in createRouxIngestIntentIdempotent.

PostgreSQL requires predicate equality to match an index to ON CONFLICT —
the mismatch caused the upsert to fail with "no unique or exclusion
constraint matching the ON CONFLICT specification", breaking the Roux
ingest path. Verified against a fresh Neon branch:
  - pre-fix: SQLSTATE 42P10 (no matching constraint)
  - post-fix: ON CONFLICT resolves cleanly to the index

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 10, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
chittycommand 0c6a8ff Jun 10 2026, 07:01 AM

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown
  1. @coderabbitai review
  2. @copilot review
  3. @codex review
  4. @claude review
    Adversarial review request: evaluate security, policy bypass paths, regression risk, and merge-gating bypass attempts.

@chitcommit
chitcommit merged commit 24e86c8 into main Jun 10, 2026
27 of 28 checks passed
@chitcommit
chitcommit deleted the fix/intent-on-conflict-expired-predicate branch June 10, 2026 07:05
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 978d64d3-716e-48e1-94ad-6d92778f127b

📥 Commits

Reviewing files that changed from the base of the PR and between e858de1 and 0c6a8ff.

📒 Files selected for processing (1)
  • meta/intent.ts

📝 Walkthrough

Walkthrough

Modified the ON CONFLICT clause in the roux ingest idempotent upsert operation to exclude rows with status = 'expired' from conflict resolution. Expired intents are no longer considered conflict targets, allowing new intents to insert instead of updating expired entries.

Changes

Roux Ingest Idempotency

Layer / File(s) Summary
Exclude expired intents from conflict resolution
meta/intent.ts
The ON CONFLICT ... WHERE predicate adds status <> 'expired' condition to prevent expired intent rows from being the conflict target during roux ingest upsert operations.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • chittyos/chittycommand#115: Introduces the 'expired' status and updates the filtered unique index to ignore expired intents, coordinating with this PR's exclusion of expired rows from conflict resolution.

Poem

🐰 A tiny tweak, so sly and small,
Where expired intents skip conflict's call!
Old intentions rest in peace,
While fresh ones find release. ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/intent-on-conflict-expired-predicate

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.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

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.

1 participant