Repository navigation
fix(intromarkers): stop re-refining unchanged silence backfill files - #1342
Conversation
A chapter silence refinement that finds no better intro end, or fails, leaves the chapter:v1 marker unchanged, so intro_markers_detected_at never moves and the backfill picks the same files ahead of everything else on every run. Record each such attempt in intro_silence_refinement_attempts with the file identity, the refined range, and a hash of the silence settings. The backfill skips a file while its attempt still matches: until the inputs change after a clean no-improvement result, and until retry_after (12h doubling, capped at 7 days) after a failure. Files never attempted are picked first. Fixes #1272 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
Quick104 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (7)
Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe silence backfill now stores refinement outcomes and uses configuration, file, chapter, and intro inputs to identify unchanged attempts. Candidate selection skips matching no-improvement attempts and defers matching failures during node-specific retry windows. ChangesSilence refinement backfill
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Analyzer
participant Repository
participant BoundaryRefiner
Analyzer->>Repository: List candidates with config and node identity
Analyzer->>BoundaryRefiner: Refine chapter boundary
BoundaryRefiner-->>Analyzer: Return result or error
Analyzer->>Repository: Load prior attempt
Analyzer->>Repository: Upsert refinement attempt
Merge Risk: ⚪ Minimal · up to Chapter-silence backfill now remembers files whose refinement made no difference or failed, so later runs stop reprocessing them. Files become eligible again when settings, chapters, file identity, or intro markers change, and failures retry with bounded backoff. No outstanding defect remains after review, and the change looks ready to merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 26.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 5 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 72d05da543
ℹ️ 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".
… window Scheduled tasks run per process, so every API server runs the nightly marker job over the same files. A failure recorded while an earlier failure is still backing off is a duplicate run (or a forced episode analysis), not a retry, and no longer escalates the failure count or moves retry_after. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dfa1f0fe87
ℹ️ 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".
The refined intro segment comes from the file's chapters, and a re-probe can rewrite them without changing the file identity or the stored marker. Record a SHA-256 of the chapters loaded with the candidate and require it to match mf.chapters before skipping a file. The column lands in its own migration because a development deployment already applied the table migration. Existing rows get an empty hash, so those files are refined once more. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 49f3435b55
ℹ️ 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".
… server Every server runs the nightly marker job against its own ffmpeg and media mounts. A failure recorded by one server (missing ffmpeg, lost mount) no longer defers the file on other servers: the attempt records the host that wrote it, the backfill honors retry_after only for its own failures, and backoff escalates only on the same server. No-improvement results still apply everywhere. The unapplied follow-up migration now adds recorded_by next to chapters_hash and is renamed to cover both. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 958c6ae556
ℹ️ 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".
media_files.id is bigint, so an int4 media_file_id would reject attempts for files past the int32 range and leave them in the backfill loop. The table migration now creates the column as bigint, and the follow-up migration widens it on a database that already applied the integer version. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Problem
Related issue: #1272
Validation tasks: none
The marker job's chapter silence backfill refines up to 2,000 scanner
chapter:v1intro markers per run, oldestintro_markers_detected_atfirst. When a refinement finds no better intro end, or ffmpeg fails, the marker write is a no-op andintro_markers_detected_atstays the same, so those files sort first again on the next run. On a development deployment with about 54,000chapter:v1markers, each of the six nightly runs I checked filled its 2,000-file budget, yet the front of the queue still held files detected on 2026-08-08. The other ~51,800 were never reached.Approach
A new table,
intro_silence_refinement_attempts, keeps one row per file whose last refinement kept the chapter boundary. It stores the file hash, size and duration, a SHA-256 of the file's chapters as loaded for the refinement, the intro range that was refined, a hash of the silence settings (Config.SilenceConfigHash), the status (no_improvementorfailed), the host that recorded it, the failure count andretry_after.Analyzer.refineChapterSegmentrecords the outcome whenever a refinement does not apply, in both the first chapter pass and the backfill. A cancelled run records nothing.no_improvementresult stands until one of those changes. A failure is retried after 12 hours, doubling per consecutive failure up to 7 days. Scheduled tasks run on every server, each with its own ffmpeg and media mounts, so a failure only defers retries on the server that recorded it, and backoff escalates only on that server's own failures after its previousretry_afterpassed. A forced episode analysis that fails inside the window keeps the existing schedule. Files never attempted sort first, then the oldest attempts.intro_markers_detected_atcan't hold this state: the marker write path ignores it for unchanged markers on purpose, to avoid audit noise. A separate table matches how Chromaprint season analysis already cachescompleteandnot_foundresults.The attempt lookup is a
LEFT JOINfor a planner reason. The planner estimates the candidate filter at a handful of rows. Written asNOT EXISTS, it chose a nested-loop anti-join that rescans the attempts table for every candidate (about 20 s with 2,000 attempt rows, growing with the table). A per-row subquery avoided that but lost the parallel scan (37 s). TheLEFT JOINprobes the primary key per file inside the parallel scan: 2.4 s on that deployment, against 6.3 s for the current query under the same load.baseCandidateSelectis split into its select/from and where parts so this query can add the join; the other queries are unchanged.Migration
20260923000630creates the table and sorts before main's20260923181331; the runner allows out-of-order versions.20260923203213addschapters_hashandrecorded_byand widensmedia_file_idtobigint(a no-op on fresh databases, where the table migration already creates it asbigint). It is a separate migration because a development deployment had already applied the first version of the table migration with anintegercolumn. Existing rows get an empty hash, which never matches, so those files are refined once more.Validation
TestSilenceBackfillSkipsUnchangedAttemptsPostgresruns the backfill twice against Postgres: the second run skips both recorded files, and a settings change, an elapsed retry time, rewritten chapters and a moved marker each make a file eligible again, and a file inside one server's backoff stays eligible for another server. One fixture file has an ID above the int32 range. It also confirms that the Go and SQL chapters hashes agree. It fails without the skip clause. It needsSILO_TEST_DATABASE_URL, which CI does not set for this package; I ran it locally against a fresh database, which the test migrates.integercolumn (rows and foreign key kept).no_improvementrow whose range matches the current marker. The next batch is 2,000 different files, none recorded yet, starting where the old batch ended.go build ./...,gofmt,go vet ./...,make lint-changed,make migrate-validateandscripts/check-local-path-leaks.shpass.make test-goon macOS: every package passes exceptinternal/apiv2, whereTestAdminResourceCapabilitiesAndScopefails because cgroup resources reportunsupportedon macOS. It fails the same way onmain.Risks
media_files(ON DELETE CASCADE), then two columns and abigintwidening on it. No existingmedia_filesrows are rewritten.RefineChapterEndthat should re-run recorded files needs aChapterSilenceAlgorithmbump; a code comment says so.No API, client or jellycompat change.
Checklist
AI Disclosure
gh)claude-opus-5-5[1m]for the main session;claude-opus-5-5for the review subagentpr-review-toolkit:code-reviewer,claude-opus-5-5) read the full diff and the code it depends on (the scanner marker write path,CanWriteMarkerUpdate, themedia_files_invalidate_markerstrigger, the silence refiner). It checked skip and retry semantics, float and NULL comparisons, races between candidate load, attempt record and marker write, the trigger interaction and migration safety. It found no correctness bugs. It flagged that the Postgres test assumed an already-migrated database (fixed: the test now runs migrations) and suggested documenting that the settings hash does not cover the refiner's code (comment added). The query moved fromNOT EXISTStoLEFT JOINafter that review, based on plans measured on the development deployment; the Postgres test covers the final form. After opening, Codex review flagged that duplicate runs across servers could multiply the failure backoff; fixed in dfa1f0f. A second pass flagged that a chapters-only change left the skip in place; fixed in 49f3435. A third flagged that one server's local failure deferred the file on healthy servers; fixed in 958c6ae. A fourth flagged theintegerfile ID after the core ID widening; fixed in ec697f6.🤖 Generated with Claude Code
Summary by CodeRabbit