Repository navigation
fix(notetaker): match the partial jobs index in enqueueJob's upsert - #185
Conversation
Migration 00065 replaced UNIQUE(type, payload) on jobs with a partial index
over live jobs (status IN ('pending','running')). SQLite only accepts a
partial index as an ON CONFLICT target when the clause repeats its WHERE, so
enqueueJob's bare ON CONFLICT(type, payload) has failed to prepare since then:
"ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint".
Every notetaker transcribe/summarize enqueue errored.
Repeat the predicate, and only refresh a *pending* duplicate: the old DO
UPDATE would also have reset a running job to pending and run it twice.
Finished jobs no longer conflict, so a regenerate inserts a fresh run.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change aligning notetaker job enqueueing with the partial unique index.
No open issues 🎉
What changed in this PR
Fixes #184 by aligning notetaker job enqueueing with the partial unique index introduced in migration 00065, restoring transcription and summarization scheduling.
Changes:
- Matches the upsert conflict target to the index’s pending/running predicate.
- Pulls pending duplicates forward, leaves running jobs unchanged, and inserts fresh jobs after completion.
- Adds regression coverage for initial enqueue, pending duplicates, completed-job requeueing, and running duplicates.
| File | Description |
|---|---|
internal/handler/notetaker.go |
Corrects the upsert and documents job deduplication behavior. |
internal/handler/notetaker_enqueue_internal_test.go |
Adds regression tests for enqueueing across job states. |
Review effort: Balanced
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
enqueueJobconflict target — repeats the partial index predicate (WHERE status IN ('pending','running')) so SQLite actually usesux_jobs_type_payload_live; the bare target failed to prepare from migration 00065 onward.- Live duplicate semantics —
DO UPDATE … WHERE jobs.status = 'pending'pulls a pending duplicate forward while leaving a running one untouched, closing the double-run the oldstatus = 'pending'reset caused. - Finished-job re-enqueue — done/failed rows no longer conflict, so a regenerate inserts a fresh run instead of resurrecting history.
- Regression test —
TestEnqueueJob_upsertsLiveJobsAndRequeuesFinishedOnescovers first enqueue, pending duplicate, re-run afterdone, and duplicate-while-running.
Verified: the new test and the full ./internal/handler/ suite pass, go vet and gofmt are clean. Other job producers are unaffected (reminders use INSERT OR IGNORE, webhook jobs carry a unique delivery id), and no query assumes cross-status uniqueness on (type, payload).
One non-blocking observation: because a running duplicate is now a silent no-op, a second recording finalizing for the same booking while a notetaker.summarize is already running would not queue another summarize. That matches the PR's stated tradeoff and needs two recordings on one booking within a tight window; the manual regenerate path calls summarizeBooking directly and is unaffected.
deepseek-v4.1-flash | 𝕏

Fixes #184
ON CONFLICT(type, payload) WHERE status IN ('pending','running'), matching the index.DO UPDATE … WHERE jobs.status = 'pending': a pending duplicate is pulled forward, a running one is left alone. Finished jobs no longer conflict, so a regenerate inserts a fresh run, which is what the old full-index behaviour amounted to.Tests:
TestEnqueueJob_upsertsLiveJobsAndRequeuesFinishedOnescovers first enqueue, pending duplicate, re-run after done, and duplicate while running. It fails onmainwith the error above.