Repository navigation
fix(intromarkers): detect markers again after a file's markers are invalidated - #3086
Conversation
…validated A rematch or a new modification time clears a file's derived markers, but the scheduled detection run kept skipping the season group or movie because nothing its analysis reads had changed. invalidate_file_markers now records when it clears a file's markers. Season input signatures include that time, and a movie's credits tail records the time it was stored with and settles the movie only while the file keeps it, so the next run writes the markers again from cached fingerprints and tails.
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Record marker invalidations migrations/sql/20261025203537_track_marker_invalidation.sql, migrations/track_marker_invalidation_test.go, internal/intromarkers/repository_movie_db_test.go |
The migration adds invalidation timestamp columns, stamps identity changes, clears non-manual marker data, and backfills eligible files. Database tests cover invalidation timing and backfill results. |
Propagate invalidation timestamps internal/intromarkers/types.go, internal/intromarkers/repository.go, internal/mediaartifact/*, internal/intromarkers/analyzer_test.go, docs/architecture/intro-detection.md, scripts/ci/db-contracts.txt |
Candidates and artifacts carry invalidation timestamps. Season-group signatures include candidate timestamps. Tests cover reanalysis when invalidation occurs after or during analysis. |
Restore movie credits from stored tails internal/intromarkers/repository_movie.go, internal/intromarkers/analyzer_movie.go, internal/intromarkers/analyzer_credits_tail.go, internal/intromarkers/analyzer_movie_test.go, internal/intromarkers/repository_movie_db_test.go, docs/architecture/intro-detection.md, scripts/ci/db-contracts.txt |
Movie settlement checks compare artifact and file timestamps. Analysis reuses a cached tail after invalidation, places credits, and stores the current timestamp with the artifact. Tests cover tail reuse and timeout behavior. |
Priority:
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix
Sequence Diagram(s)
sequenceDiagram
participant Repository
participant analyzeMovie
participant movieTail
participant ArtifactStore
Repository->>analyzeMovie: provide eligible movie candidate
analyzeMovie->>movieTail: request cached tail and stale status
movieTail->>ArtifactStore: load stored tail artifact
ArtifactStore-->>movieTail: return tail and stored invalidation timestamp
movieTail-->>analyzeMovie: return tail and stale status
analyzeMovie->>ArtifactStore: store tail with current invalidation timestamp
Possibly related issues
- Silo-Server/silo-apple#311: The issue validates skip-intro and skip-credits behavior, which uses markers restored by the server.
- Silo-Server/silo-apple#312: The issue validates tvOS skip-intro and skip-credits behavior, which uses markers restored by the server.
Possibly related PRs
- Silo-Server/silo-server#2971: Defines credits placement rules used by the movie analysis path that restores stale cached tails.
- Silo-Server/silo-server#2974: Changes the movie analysis path that this change updates to reuse and restamp cached tails.
Suggested reviewers: quick104
Merge Risk: 
Minimal · up to 9e863
-
The backfill enables eligible files with missing markers to be reconsidered on a scheduled run. No outstanding issue identified here prevents merging after normal checks.
Security architecture risk: 
Low · up to 9e863
-
The change restores derived markers while preserving existing file-identity and manual-marker controls. No introduced security weakness was established. Remaining uncertainty concerns deployment and rollback coordination, which were assessed statically rather than exercised.
Retained concerns
No architecture-level concerns identified.Security review details
-
Security Blast Radius
- observed — The upgrade backfill applies database-wide to unstamped, non-extra files missing credits or episodes missing intros. Its scope is broader than files proven to have lost markers previously, because that history was not recorded. It schedules renewed analysis rather than directly replacing marker ranges.
Trust Boundaries and Controls
- observed — The existing marker writer locks the media-file row and rejects a supplied expected-file identity that differs from current state. These controls are unchanged by the PR and constrain renewed analysis from writing results onto a replacement file.
Resilience and Maintainability Implications
- inferred — Per-row serialization and freshness comparison provide complementary containment: an identity change can reject an older marker write or clear markers written before that change, while an older artifact timestamp does not settle the newly invalidated file. This conclusion is based on static control flow, not an executed concurrent-transaction test.
-
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 73.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 11 files. (2 skipped: 2 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
|
The visible playback change lacks reviewable captures. The Evidence section describes a before/after for credits in one touched episode, but includes no screenshots or recording and does not show the other affected behavior:
Please attach the captures for desktop and phone-width web, plus any native surfaces the PR says are affected, and identify the exact build or commit for each. Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
| ALTER TABLE media_files ADD COLUMN markers_invalidated_at timestamptz; | ||
| ALTER TABLE media_intro_fingerprints ADD COLUMN markers_invalidated_at timestamptz; |
There was a problem hiding this comment.
Missing invalidation stamps in migrations/sql/20261025203537_track_marker_invalidation.sql leave existing files whose markers were cleared before this migration with NULL stamps, so InputSignature preserves their settled season signature and ListMovieCandidates still treats their complete NULL-stamped tails as settled. Initialize invalidation stamps for existing files during the migration, or explicitly invalidate existing season and movie settlement state once, so upgrades also restore markers already lost to the reported bug.
Prompt for LLM
File migrations/sql/20261025203537_track_marker_invalidation.sql:
Line 8 to 9:
Missing invalidation stamps in migrations/sql/20261025203537_track_marker_invalidation.sql leave existing files whose markers were cleared before this migration with NULL stamps, so InputSignature preserves their settled season signature and ListMovieCandidates still treats their complete NULL-stamped tails as settled. Initialize invalidation stamps for existing files during the migration, or explicitly invalidate existing season and movie settlement state once, so upgrades also restore markers already lost to the reported bug.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
Agreed, fixed in 9e86344 (with b9b88f4 and 7bf75ff). The migration now stamps existing files once: every episode missing an intro or credits range and every movie missing credits, outside extras. Those seasons get a new input signature, and those movies no longer match their tail's stamp, so the next scheduled run re-analyzes them from cached fingerprints and tails. Movies with credits and episodes with both ranges stay settled, so the upgrade doesn't re-analyze the whole library. The migration runs without a wrapping transaction, so the ALTER TABLE lock does not last the backfill. TestTrackMarkerInvalidationBackfillPostgres covers which rows are stamped.
There was a problem hiding this comment.
Thanks—the backfill you described addresses the original finding: previously affected files receive an invalidation stamp, making their settled signatures or tails stale so the next scheduled run restores markers from cached analysis.
Keeping movies with credits and episodes with both ranges settled avoids a library-wide re-analysis. TestTrackMarkerInvalidationBackfillPostgres covers the relevant upgrade behavior.
Based on your description, this suggestion is addressed; I haven’t independently verified those commits.
|
#1148 C1 is ready for a focused re-test after merge. Its October 25 task comment reports that the scheduled run left locally detected markers empty after a rematch or touch on main and identifies this PR's retest for that behavior. Human acceptance is pending, and the accuracy target remains unresolved, so this is not an accepted result. The existing I could not read Silo-Apple #311/#312 or Silo-Android #321/#322 because those repositories are inaccessible in this run; their client cases remain unclassified. Suggested fix: No diff — re-test the invalidation scenario after merge and record it once the accuracy target is agreed. Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
Stamp every file missing an intro or credits range once during the migration, so the next scheduled run detects those seasons and movies again from their cached fingerprints and tails.
Commit each statement on its own so the ALTER TABLE lock does not last the backfill, and stamp only files missing a range local detection places, so movies with credits are not analyzed again.
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
The before/after captures are on the evidence page linked in the Evidence section; this check can't open that page. The movie path shows the same restored credits control in the same player, and the change is server-side only, so phone-width web and native clients get the same markers without client changes. |
|
Web #1149 C1 needs re-validation after merge. Its recorded result is from server build Suggested Validation tasks line: Suggested fix: No diff — after merge, have a human re-run #1149 C1 with a touched or rematched marker fixture and record the build-specific result. Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
Problem
Related issue: #1147
Validation tasks: unblocks #1148 C1
Intros and credits that Silo detects locally disappear for good when a file's identity changes without its contents changing. Re-identifying a series or movie (fixing a match, adding an ID to an NFO) or touching a file so a rescan sees a new modification time is enough. The database clears the file's derived markers, as designed, but the nightly Detect markers on this server task never writes them back. Admins see skip prompts vanish from episodes and movies that had them, and nothing brings them back short of re-detecting each episode by hand. Playing an episode restores its intro, but not its credits.
The task skips a season group whose stored analysis is settled with an unchanged input signature, and a movie whose credits tail is stored for the file's hash, size, and duration. A rematch or a touch changes none of those, so both stay settled after their markers are gone.
This change records when the database invalidates a file's markers, and makes both checks notice that time, so the next run writes the markers again from the cached fingerprints and tails without decoding the files again.
Approach
media_files.markers_invalidated_at.invalidate_file_markers()sets it after its existing identity check, so the time is stamped exactly when markers are cleared. The migration also adds the same column to the media analysis artifact table.docs/architecture/intro-detection.mddescribes both rules.Server only; no API, client, or jellycompat change.
Validation
mainwith synthetic episodes and movies: after touching an episode or re-identifying a series or movie, the scheduled run left its intro and credits empty (3 of 3 runs).scripts/ci/db-contracts.txt.go build ./...,gofmt,go vet,make lint-changed,make migrate-validate,make verify-migration-ledger,make verify-migrations,make verify-local-paths: pass. The migration's Down and Up both apply cleanly on a migrated database.make test-go: everything passes exceptTestPlaybackInfoWithoutStripOrToneMapStillHasNoRouteandTestPlaybackInfoSkipsStripWhenRPUCannotBeStrippedininternal/jellycompat, which fail the same way onmainon the test host.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/pr-3086/
The web player at 5:17 in the credits of a touched episode after the scheduled detection run, on
mainand on this branch with the same library and data. Before, no credits control appears because the credits were cleared and never detected again; after, the restored credits show the Up next countdown. The change is server-side, so phone-width web and native clients change the same way.Risks
Migration: one nullable column on
media_filesand one onmedia_intro_fingerprints, aCREATE OR REPLACEofinvalidate_file_markers()that only adds one assignment, and a one-time stamp of the files described below. It runs without a wrapping transaction, so theALTER TABLElock does not last the backfill, which takes only row locks; every statement is safe to re-run. Down restores the previous function and drops the columns.Markers lost before this upgrade come back too. Nothing records which files lost them, so the migration stamps every episode missing an intro or credits range and every movie missing credits, outside extras. The next scheduled run re-analyzes those seasons over cached fingerprints and those movies from cached tails; a movie's audio is read again only where its tail places credits. Movies with credits and episodes with both ranges stay settled.
Checklist
AI Disclosure
invalidate_file_markers(). Round two found no correctness issues and asked for a test of the timeout case, which was added.Note
Track marker invalidation timestamps so intro markers are detected again after file identity changes
markers_invalidated_atcolumn tomedia_filesandmedia_intro_fingerprints, and theinvalidate_file_markerstrigger now stamps it on identity changes while preserving manual markers and clearing derived ones (20261025203537_track_marker_invalidation.sql)InputSignatureincludes each file's invalidation timestamp, so groups re-analyze when a file is invalidated (repository.go)ListMovieCandidatesnow re-includes settled movies whose artifact timestamp differs from the file's invalidation time; migration is non-transactional with a full rollback path for the trigger function and new columnsMacroscope summarized 9e86344.