You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(playback): a seek resumes with 206 after inode churn or chmod - #5870
Related issue: N/A
Validation tasks: none changed. Reaches #1231 C2, #1232 C1, #1168 C2 and #1177 C3, all passed on builds 1804 and 2970. Board read 2026-12-05; the cases were not walked again.
Other clients: Apple N/A and Android N/A (no client change needed: each handles a changed tag as it does today, and this change makes tags change less often); Roku N/A (the app reads no media ETag; media plays through the platform Video node); Web N/A (the player identifies a file by size and Last-Modified, not ETag)
Seeking in a direct-play video can restart the download from byte 0. A resume sends Range with If-Range set to the ETag of the earlier response, and that ETag came from the file's device number, inode and change time. On a FUSE or FAT mount that renumbers inodes, after a chmod, after a hardlink is removed, or when the resume lands on another host, the tag differs and the server answers 200 with the whole file instead of 206. Windows and other platforms without a filesystem revision sent no ETag at all. The autoscan debounce had the same dependence: its token for a file included the inode, so inode churn, or a report handled by another node, queued a second scan of an unchanged file.
This change makes the direct-play ETag depend on the file's size, modification time and content, and sends it on every platform. It also makes the autoscan debounce token size and modification time only.
Approach
ETag. The tag is a SHA-256 of the file's size, its modification time to the microsecond, and its first and last 64 KiB (the whole file under 128 KiB). It holds no device, inode or change time, so it survives inode churn, chmod and hardlink removal, and matches across API servers that see the same size and modification time. A process-wide cache of 4,096 tags, keyed on the path, the local filesystem revision and the hashed size and time, means the file is read only on a miss. The tag changes once at upgrade (dsr1 to dsr2).
Read failure.DirectPlayEntityTag now returns an error. When the sampled bytes cannot be read, or the read comes up short, ServeDirectPlay and the two local download routes (Jellyfin compatibility and Audiobookshelf, through serveLocalFile) log a warning without the media path and serve the file with no ETag. Nothing is cached, so the next request reads again.
Autoscan. The debounce token is file:<size>:<mtime in microseconds>, the inputs the scan itself decides change by. fileidentity_unix.go and fileidentity_other.go are deleted.
Alternatives. Size and modification time alone survive churn but cannot tell apart same-size replacements whose date is restored. Hashing the whole file was removed from feat(playback): formalize resumable direct streams and stall observability #464 for its per-request cost. A weak tag would answer every resume with 200, because Go's If-Range compares strongly.
Docs and generated files.docs/admin-api.md, docs/architecture/direct-stream-resume.md and docs/architecture/worker-http-protocol.md describe the new rules. The proxy's OpenAPI description no longer calls the tag "file-derived strong"; make verify-apiv2-openapi passes.
Tests. The platformRequiresDirectPlayValidator skips are gone because the tag now exists everywhere. No nolint lines and no CI test-list changes; the new tests need no Postgres.
Jellyfin compatibility. Its stream and download routes call the same function, so it needs no separate change.
Translations. No new keys. One catalog key changes its English in place: the debounce help text said "Changed or deleted files are still scanned", which is no longer true for a same-size, same-time replacement. The catalog change is fix(web): autoscan debounce help says when a file counts as unchanged silo-translations#228, merged with its translation pass. The locale files here are synced with --version 2026.12.05-1ec18ef, the release it published; in the generated files only that key's value in each language and the version stamp change.
The tag no longer proves the bytes are equal. A same-size edit that keeps or restores the modification time and leaves both 64 KiB ends unchanged keeps the old tag. On a mount whose stat hides a write (rclone reports change time equal to modification time), an edit at a sampled end keeps the cached tag until the next stat change, restart or eviction; the lab reproduced this (see Validation). For either, a stale If-Range gets 206 of the current file, If-Match passes, and If-None-Match answers 304. This narrows what Formalize resumable direct streams and expose stalled-write reaping #443 and feat(playback): formalize resumable direct streams and stall observability #464 promised: a changed tag for same-size replacements even when the modification time is preserved (docs/architecture/direct-stream-resume.md). The tag is strong in form only, a departure from RFC 9110 section 8.8.1.
Why: sampling removes the inode dependence for at most 128 KiB per cache miss. Exact identity needs a stored per-file version or digest, which is a larger change than this fix.
To approve: accept the narrower promise. If you want exact identity, say so and I will propose the stored-version design separately.
A failed sample read serves the file without an ETag. This applies to direct play and to the Jellyfin and Audiobookshelf download routes. A Range request with no validator gets 206 as it would with a tag. With no tag, http.ServeContent answers an If-Range that carries an entity tag with the full 200, fails an If-Match entity tag with 412, and never matches an If-None-Match entity tag. Each request repeats the read until it succeeds.
Why: a file whose last 64 KiB cannot be read (a bad block, or a remote mount failing that range), or a network mount whose cached size is stale, stays playable and downloadable. A 500 would refuse every range of that file, as the maintainer review on this pull request pointed out.
To approve: accept serving without a tag.
Every tag changes once at upgrade, and old and new servers disagree during a rolling upgrade. A resume that crosses them gets 200. From reading its code, Android treats a changed tag as an error, as it does today when a file changes.
Why: the old tag held host-local values, so no shim can map it to the new one.
To approve: accept the one-time change and the mixed-version window.
An ETag is now sent where none was. Windows sent no tag before and now sends one. A build with no usable filesystem revision (the fallback build, a failed Windows handle query, a Unix FileInfo without Sys()) reads the sampled bytes on every request, HEAD included, because it cannot use the cache.
Why: resume protection should not depend on the platform.
To approve: accept the per-request read on those builds.
A cache cap and a read before the first byte. The cache holds 4,096 tags and evicts the least recently used. A miss reads up to 128 KiB first, on HEAD too. Concurrent misses on one file each read; the Web player starts a head request and a one-byte probe in parallel. Measured cost is under Validation and Risks.
Why: the cap bounds memory, and reads happen only on a miss. Sharing one read between concurrent misses is not added, because nothing fails without it.
To approve: accept the cap and the read.
Autoscan drops a repeat report of a same-size, same-microsecond-modification-time replacement. This applies inside debounce_seconds (default 60). Other work on that row (repair of a missing file, probe repair, sidecar subtitles) waits for the next report or scheduled scan. This reverses the inode check fix(autoscan): stop the debounce from dropping real file changes #1931 added. During a rolling upgrade the two token formats replace each other's claim, so the cluster scans more, not less.
Why: the scan a report queues decides change by size and microsecond modification time, so the inode check could not change what the scan finds. Inode churn and reports handled on another node stop queuing duplicate scans.
To approve: accept the reversal. The help text and the manual change with it.
Validation
Red: tree 788aa7a87, which is base 1026b8e5a385397a5960c76cc50d84b8de426271 plus the new tests and the signature change that lets a tag fail. The behavior hunks were absent: the sampled tag, the read-failure handling in ServeDirectPlay, the download hook move and the autoscan token. Five tests failed, each on an assertion and none on a panic or build error: 200 where 206 was expected after a same-bytes rename, no error from a short sample read, an empty tag without a revision, Content-Disposition set when the tag fails, and an autoscan state that still held the inode. A mutation that moves the tail sample one byte fails only the changed-last-byte row.
Red, serving without a tag: the two read-failure tests (TestServeDirectPlaySampleReadFailureServesWithoutETag, TestServeLocalFileEntityTagErrorServesWithoutETag) ran against the production files of 4e17c2d86, which answered 500. All four subtests failed on assertions, for example ServeDirectPlay error = direct play entity tag: read 15 bytes at offset 0: EOF, want nil and serveLocalFile error = entity tag: sample read failed, want nil.
Green: tree f6bc2e58a (the code before the locale files were re-synced to the catalog commit). go test for internal/playback, internal/autoscan, internal/downloads and internal/proxy pass, with make verify-apiv2-openapi, make lint-changed (0 issues) and make verify-local-paths. Tests that need Postgres or Redis skip in these runs; the new tests need neither. G2, the full gate from CONTRIBUTING.md (37 steps: web lint, format check, build, budget and tests; Go build, gofmt, go mod tidy, go vet, make lint-changed, make test-go; the verify-* targets; migrations; DB pins; Prometheus rules), passed on base 1026b8e5a and tree f6bc2e58a. The branch was then rebased onto main at cdf344f9d; the code and doc hunks did not change, and only the generated locale files were synced again. G2 on that final tree, base cdf344f9d: all 37 steps passed. After the change to serve without a tag (tree 9ba923e09), go build ./..., go vet and go test -v for internal/playback, internal/downloads, internal/jellycompat and internal/audiobooks/... pass, with make lint-changed and make verify-local-paths; G2 on that tree passed all 37 steps.
Real path: a real Silo server built from tree 53a8e1bcf, serving through its Jellyfin stream route from rclone v1.76.0 mounts of a local directory. Later commits changed one test, comments, docs and the locale files, not product logic.
Inode churn: on rclone mount2 the inode changed (11 to 21) after vfs/forget, and a Range request with the pre-churn If-Range got 206, the same tag, and a body whose hash matched the file's range. On rclone mount v1.76.0 the inode does not change after forget or remount, so that run is void and not counted as a pass.
Hidden write: on rclone mount, a 4 KiB edit inside the last 64 KiB of an 8 MiB file, with the modification time restored, left stat unchanged while the mount served the new bytes. The warm server returned 206 with the new bytes under the old tag; after a restart the tag changed. This is the miss in item 1.
Read cost, local disk, the same six 1 GiB files before and after: mean time to first byte for a cold request 19.7 ms before and 21.6 ms after (+1.9 ms), warm 3.4 ms and 4.1 ms (+0.8 ms). These are single samples while other load on the host differed between the runs (mean 1.3% before, 6.1% after), so read them as the size of the effect, not a measured spread.
Read cost, rclone on a local directory (after only): cold 24.5 ms, warm 3.4 ms. Two parallel cold requests, as the Web player sends, ran +6.3 ms (head) and +14.2 ms (one-byte probe) over one cold request. A local directory has no backend latency, so this is not the cost of a remote backend.
Read cost, remote backend: a read-only probe of six files on an rclone mount of a remote store read both 64 KiB ends in 111.9 to 212.3 ms the first time and 0.06 to 0.19 ms on a repeat.
Not covered: no run on Windows or macOS, and none of the Android, Apple, Web or Roku clients against a response with no tag or a changed tag. No second API server or proxy sharing one library, no FAT mount, no chmod or hardlink removal on a mount; the rename-over test row stands in for the inode change. Concurrent cold misses were measured only as the parallel pair above, and local SSD or HDD cost under load was not. Autoscan runs only through unit tests, not two nodes on a shared Redis. Rolling-upgrade behavior was not run.
The page holds the red run, the green runs with both mutation runs, the G2 gate log, and the inode-churn, hidden-write and read-cost runs behind the Validation bullets, with the per-file read-cost tables. Visible change: the debounce help text on the Web admin autoscan settings page. The page shows it before and after.
Surface and build: server (direct play, local downloads, autoscan intake) and one Web admin help string.
Build: head ff25de169 on base cdf344f9d238ee5e11e04a581538ab14f85b96c8. The red, green and lab runs used base 1026b8e5a. Lab runs used change tree 53a8e1bcf071e6307648ac034727d33a577fafb8; the base build ran the "before" arm of the local read-cost comparison.
Risks
Read cost. A first request for a file in a process pays up to 128 KiB of reads before the first byte: 111.9 to 212.3 ms on a remote-backed rclone mount in the probe above. On a mount where inodes churn, an entry lives only until the next churn, so a seek after a pause can pay one cold sample.
mtime-only changes still restart a stream. Radarr or Sonarr date resets of unchanged bytes, snapraid touch, and two mounts that date one file differently each give a new tag, as today.
Continuity across origins needs equal size and modification time. API servers already must agree on both (docs/architecture/transcode-nodes.md). A node or proxy mount that dates a file differently sends another tag, so a resume that switches to it gets 200, as every host switch did before.
Old autoscan claims. A claim written by the old token can match a new one only when its old nanosecond value equals the new microsecond value, which no real file reaches. The suppress.go comment says so; there is no code change.
Nearby, not changed here. Two other places key on the inode and share its cause. An artwork read after an inode change can be recorded as "not a regular file", retried after 7 days and parked after 8 tries (internal/metadata/image_cache_processor.go). Theme-song discovery rejects a directory on an inode-only change (internal/themesongs/themes.go). Both stay out of this PR.
Checklist
I read and can explain the complete diff.
This pull request addresses one concern.
Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
The Evidence section shows every change a user can see, or how I checked a change nobody sees.
AI Disclosure
Harness: T3 Code running Claude Code and Codex
Tool(s): Claude Code, Codex, GitHub CLI, rclone v1.76.0 (lab runs)
Adversarial review: Claude Opus 5.5 drafted the design and the spec and audited both. GPT-6.2 Sol reviewed the design (eight findings, all folded in: the cache key now includes the hash header, the download hook moves before the response headers, the OpenAPI wording, the stale help text and manual, the cross-origin condition, the client recovery paths, and two lab measurements) and the spec. Claude Sonnet 5.5 wrote the code and the fixes and checked Phase 1 against a 14-item list, all passing. GPT-6.2 Sol then reviewed the finished change: five findings, no Critical or High. Four were fixed (a missing test for the 500 on a failed sample read, a comment about old autoscan tokens, docs that called the tag "strong", and a test comment) and one was handled by re-running the locale sync from the catalog commit. The old-token case in Risks is disclosed, not fixed. After the maintainer review, Claude Sonnet 5.5 changed a failed sample read to serve without a tag. GPT-6.2 Sol reviewed that change and Claude Sonnet 5.5 checked it independently. The reviewer's wording finding is fixed: the docs and comments had described the outcome of every conditional header, not only those that carry an entity tag. Its other finding is left as it is on main: when a file shrinks between stat and the read, a 416 names the size from stat. A human chose each design option.
Note
Fix direct-play seek-resume after inode churn by using sampled ETags
Replaces inode-based ETags with strong quoted SHA-256 tags built from file size, microsecond mtime, and sampled file bytes (whole file under 128 KiB, otherwise first and last 64 KiB) in directplay_etag.go. Tag results are reused from a process-wide LRU cache of 4,096 entries.
Removes inode identity from autoscan debounce state in suppress.go; regular-file state is now size and normalized microsecond mtime, and the inode helpers are deleted.
ETag callbacks can now return errors: direct-play and local-file downloads fail with a generic 500 or a wrapped error before response headers when tag sampling fails.
Behavioral Change: same-size, same-mtime replacements with unchanged sampled bytes keep the same ETag and can satisfy range resumes with 206; a change to sampled bytes forces a full response. Autoscan may now treat same-size, same-mtime replacements as repeats instead of new scans. ETag version moved from dsr1 to dsr2, and conditional-request tests no longer skip on platforms without validators.
Added warning logging to playback.ServeDirectPlay when DirectPlayEntityTag fails. [4e17c2d]
Updated the direct-stream-resume documentation and the playback.TestServeDirectPlayChangedEntityRejectsOldValidators test wording. [4e17c2d]
Removed the windowsGOOS constant from the GOOS constants block in the playback package. [4e17c2d]
Changed playback.ServeDirectPlay to serve content without an ETag when entity-tag computation fails, and replaced the corresponding test [450ff9b]
Changed downloads.Service.serveLocalFile to serve the file without an ETag when entity-tag computation fails, and replaced the corresponding test [450ff9b]
Updated comments and the direct-stream-resume architecture document to describe serving without an ETag on tag-computation failure [450ff9b]
Reworded the localized message about repeated reports in the web locale JSON files for 39 languages, so repeat reports are ignored only when both file size and modification time are unchanged. [4890ad8]
Updated the translation version identifier and SHA-256 value in the translation build metadata, and the generated header in the locale key declarations to reference the new translation version. [4890ad8]
A direct-play resume sends Range with If-Range. The ETag it carried came
from the file's device, inode and change time, so a FUSE or FAT mount
that renumbers its inodes, a chmod, a removed hardlink, or a switch to
another host made the tag differ and the server answered 200 from byte
0. On Windows and other platforms without a filesystem revision the
response had no ETag at all.
The direct-play ETag is now sent on every platform, Windows included. It
is a SHA-256 of the file's size, its modification time to the
microsecond, and its first and last 64 KiB (the whole file under
128 KiB). It holds no device, inode or change time, so it survives
inode churn, chmod and hardlink removal, and matches across API servers
that see the same size and modification time. A process-wide cache of
4,096 entries, keyed on the path, the local filesystem revision and the
hashed size and time, means the file is read only on a miss. The tag
changes once at upgrade (dsr1 to dsr2).
Changed answers:
- A failed or short read of the sampled bytes answers 500 with no ETag,
as a failed open does, on direct play and on the local download routes
that share the function. Nothing is cached.
- The tag does not prove byte equality. Two changes keep the old tag: a
same-size edit that keeps or restores the modification time and leaves
both sampled ends unchanged, and, on a mount whose stat hides a write
(rclone), an edit at a sampled end until the next stat change, restart
or eviction. A stale If-Range then gets 206, If-Match passes, and
If-None-Match answers 304.
- A node or proxy mount that dates a file differently sends another
tag, so a resume that switches to it gets 200.
Autoscan's debounce token drops the inode too. It is now
file:<size>:<mtime in microseconds>, the same inputs the scan decides
change by, so inode churn and a report handled on another node no longer
queue a second scan. In exchange, a replacement with the same size and
the same microsecond modification time, reported again inside
debounce_seconds, is not rescanned, and other work on that row (repair
of a missing file, probe repair, sidecar subtitles) waits for the next
report or scheduled scan. This reverses the inode check that Silo-Server#1931
added for same-size replacements. The admin API reference, the
stream-resume architecture note, the proxy's OpenAPI description and the
autoscan help text now describe these rules.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: Codex (gpt-6.2-sol) <noreply@openai.com>
Signed-off-by: Anagh Kumar Baranwal <6824881+darthShadow@users.noreply.github.com>
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
No actionable comments were generated in the recent review.
Walkthrough
Autoscan state comparison now uses file size and modification time to microsecond precision. Direct-play ETags use SHA-256 tags based on file metadata and sampled bytes. Serving paths log tag-generation errors and continue without an ETag. Related tests and descriptions were updated.
Changes: Autoscan debounce
Layer / File(s)
Summary
File-state comparison and descriptions internal/autoscan/*, docs/admin-api.md, web/src/locales/*, .silo-translations
Regular-file debounce state now uses size and modification time to microsecond precision. Tests and descriptions specify that unchanged values can produce the same observed state, while deletions or changed values trigger scans.
Direct-play ETags
Layer / File(s)
Summary
Sampled ETag generation and validation internal/playback/directplay_etag.go, internal/playback/directplay_test.go
Direct-play ETags use file size, normalized modification time, and whole-file or sampled bytes. A 4,096-entry LRU cache stores eligible tags. Tests cover conditional requests, replacements, missing revision data, and read failures.
API and architecture descriptions specify that ETags use file size, modification time, and sampled bytes, and do not prove byte equality. Resume documentation describes cache behavior and conditional-request outcomes.
sequenceDiagram
participant ServeDirectPlay
participant DirectPlayEntityTag
participant TagCache
participant MediaFile
participant HTTPResponse
ServeDirectPlay->>DirectPlayEntityTag: Request entity tag
DirectPlayEntityTag->>TagCache: Look up tag when revision data is available
alt Cache hit
TagCache-->>DirectPlayEntityTag: Return cached tag
else Cache miss or no revision data
DirectPlayEntityTag->>MediaFile: Read whole file or sampled bytes
MediaFile-->>DirectPlayEntityTag: Return bytes or read error
end
DirectPlayEntityTag-->>ServeDirectPlay: Return tag or error
ServeDirectPlay->>HTTPResponse: Set ETag when available and serve file
Loading
Suggested reviewers:quick104
Merge Risk: Low · up to 4890a
Resumed direct-play requests can, in rare cases, receive a mix of old and new file content after a hidden same-size edit that keeps the modification time. The behavior is documented and accepted by the maintainers. The lint CI job still needs a runner that can finish or a maintainer override before merge.
Architecture risk: Low · up to 4890a
File-state and direct-play validator contracts now rely on explicit metadata and sampled-content criteria, with direct-play serving falling back to responses without an ETags when tag generation fails.
Direct-play clients must treat the new ETag as a validator based on sampled bytes rather than proof of byte equality; if the server cannot generate it, the server omits the ETag and serves the full response.
observed — contracts (api) was modified; 1 changed file maps to changed impact.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: direct-play seek resumes return 206 after inode churn or chmod. The changeset replaces inode-based ETags with content-sampled tags and removes inode identity from auto…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description check
The description is detailed and directly related to the changeset. It explains the direct-play ETag change (SHA-256 of size, microsecond mtime, and sampled bytes), the removal of inode-based identity …
Full details: Title check
Explanation
The title names the main change: direct-play seek resumes return 206 after inode churn or chmod. The changeset replaces inode-based ETags with content-sampled tags and removes inode identity from autoscan debounce, which the title captures as the user-facing outcome. It is specific and concise, and it uses a conventional commit prefix.
Full details: Description check
Explanation
The description is detailed and directly related to the changeset. It explains the direct-play ETag change (SHA-256 of size, microsecond mtime, and sampled bytes), the removal of inode-based identity from autoscan debounce, the read-failure handling that serves without an ETag, the affected files, tests, and validation. It is not generic or off-topic.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Tools execution failed with the following error:
Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error)
Recent review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: ffacd2c3-0ce8-4b31-b074-9e0702380d37
Commits
Reviewing files that changed from the base of the PR and between 450ff9b and 4890ad8.
Files selected for processing: 40
.silo-translations
web/src/locales/ar.json
web/src/locales/bg.json
web/src/locales/ca.json
web/src/locales/cs.json
web/src/locales/da.json
web/src/locales/de.json
web/src/locales/el.json
web/src/locales/es.json
web/src/locales/et.json
web/src/locales/fi.json
web/src/locales/fr.json
web/src/locales/he.json
web/src/locales/hi.json
web/src/locales/hr.json
web/src/locales/hu.json
web/src/locales/id.json
web/src/locales/it.json
web/src/locales/ja.json
web/src/locales/keys.ts
web/src/locales/ko.json
web/src/locales/lt.json
web/src/locales/lv.json
web/src/locales/ms.json
web/src/locales/nb.json
web/src/locales/nl.json
web/src/locales/pl.json
web/src/locales/pt-BR.json
web/src/locales/pt-PT.json
web/src/locales/ro.json
web/src/locales/ru.json
web/src/locales/sk.json
web/src/locales/sl.json
web/src/locales/sv.json
web/src/locales/th.json
web/src/locales/tr.json
web/src/locales/uk.json
web/src/locales/vi.json
web/src/locales/zh-Hans.json
web/src/locales/zh-Hant.json
Files skipped from review as they are similar to previous changes: 1
web/src/locales/keys.ts
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Local translation pin prevents reproducible synchronization
A normal scripts/sync-translations invocation fails because it rejects local-* pins without --local or --version. Restore a published release version and checksum so the repository can reproduce the translation assets.
Prompt for LLM
File .silo-translations, lines 2-3:
Local translation pin prevents reproducible synchronization
The committed local version makes a normal `scripts/sync-translations` invocation fail because the script explicitly rejects `local-*` pins without `--local` or `--version`. Restore a published release version and its checksum so the translation assets can be reproduced from the repository alone.
The reason will be displayed to describe this comment to others. Learn more.
This is expected while Silo-Server/silo-translations#228 is unmerged. Silo's translation rules have a client pull request sync with --local until the catalog change merges, then re-sync with --version <release> before it merges. That re-sync replaces this pin with the published release and its checksum. The PR body says so under Translations.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification. I agree the local-* pin is expected while the catalog PR is unmerged, so my suggestion does not account for the documented workflow.
The remaining merge prerequisite is to re-sync with the published release and checksum after Silo-Server/silo-translations#228 merges. I can also save this workflow as a repository convention if you’d like.
The reason will be displayed to describe this comment to others. Learn more.
Sampled content produces identical strong ETags for different files
A same-size replacement with the same modification time but different unsampled bytes can cause If-Range to combine revisions or If-None-Match to return 304 incorrectly. Use a validator that changes for every representation change, such as a persisted full-content digest or authoritative content revision.
Prompt for LLM
File internal/playback/directplay_etag.go, lines 110-113:
Sampled content produces identical strong ETags for different files
A same-size replacement with a preserved modification time and different bytes between the sampled ends receives the same strong ETag, so `If-Range` can combine revisions and `If-None-Match` can incorrectly return 304. Use a validator that changes for every representation change, such as a persisted full-content digest or an authoritative content revision.
The reason will be displayed to describe this comment to others. Learn more.
Correct, and it is the first item under "Needs maintainer approval" in the PR body: a same-size edit that keeps the modification time and leaves both 64 KiB ends unchanged keeps the old tag, so a stale If-Range gets 206 and If-None-Match gets 304. The design accepts this in exchange for resumes that survive inode churn, chmod, hardlink removal and a switch between API servers. A full-content digest costs a read of the whole file per cache miss, and an authoritative content revision needs a stored per-file version; the PR offers that as a separate design if the maintainer wants exact identity.
The reason will be displayed to describe this comment to others. Learn more.
Agreed. The suggestion identifies a real correctness limitation, and the PR already discloses it as a maintainer approval item. The sampled ETag can preserve resumes across inode churn, but it cannot guarantee byte-for-byte identity—and the hidden-write cache case can retain an old tag even when a sampled end changes.
The decision is whether to accept that risk for this fix or require an authoritative revision or full-content digest before merging. Maintainer approval is still needed; documenting the tradeoff does not make the validator strong under HTTP semantics.
The documented sampling tradeoff makes seeks survive inode churn without hashing entire files. It also lets a prior strong-form validator match a distinct representation: where the merge-base filesystem revision would change, a same-size file with the same normalized mtime and sampled bytes can still pass If-Match, yield a resumable 206, or return a stale 304. Resampling does not resolve that equivalence, so clients that require byte identity cannot rely on the match alone.
Playback and the Jellyfin and Audiobookshelf local download routes generate the tag before HTTP evaluates the method or preconditions. On a cache miss, even a HEAD, a request that would return 304 or 412, or a range that does not need the sampled tail can now depend on that read and return 500 if it fails. The 4,096-entry cache bounds memory, not concurrent misses; a mount without a usable revision bypasses it, and local download bandwidth throttling starts only after sampling.
1
To avoid duplicate scans across mounts and nodes, autoscan now treats a same-size, same-microsecond replacement as the earlier observation, even where a changed inode would have triggered a scan at the merge base. A later report can be suppressed and the poll marker advanced after the earlier scan has already finished. The scanner can skip byte-change work on matching size and mtime, but it also checks independent update reasons such as missing state and probe repair when a scan actually runs. Claim expiry permits a future report; it does not replay an acknowledged one.
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: e3a1dbd1-2637-474a-92fe-96e3d54bb39f
Commits
Reviewing files that changed from the base of the PR and between cdf344f and ff25de1.
Files selected for processing: 20
.silo-translations
contracts/api/v2/openapi.json
docs/admin-api.md
docs/architecture/direct-stream-resume.md
docs/architecture/worker-http-protocol.md
internal/autoscan/debounce_test.go
internal/autoscan/fileidentity_other.go
internal/autoscan/fileidentity_unix.go
internal/autoscan/suppress.go
internal/downloads/serve_observer.go
internal/downloads/service.go
internal/downloads/service_read_error_test.go
internal/playback/directplay.go
internal/playback/directplay_etag.go
internal/playback/directplay_test.go
internal/proxy/direct_protocol.go
web/src/locales/ar-XB.json
web/src/locales/en-XA.json
web/src/locales/en.json
web/src/locales/keys.ts
Files with no reviewable changes: 2
internal/autoscan/fileidentity_other.go
internal/autoscan/fileidentity_unix.go
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Major · Data Integrity & Integration · Heavy lift
Do not use sampled fingerprints as strong resume validators.
For a 192 KiB file, replace bytes 80000 and 120000 while preserving size and mtime. Neither edit enters these samples. A different inode/ctime correctly causes a cache miss, but resampling still returns the old tag.
If a client retained the first 100000 bytes, its matching If-Range now receives 206 from byte 100000. The combined file contains bytes from both revisions. Previously, the changed filesystem revision changed the tag and forced a full 200 response.
The documented caveat does not prevent this data-integrity failure. Use a complete-content digest or an authoritative content revision for the strong validator. Sampling alone cannot safely authorize range recombination.
The reason will be displayed to describe this comment to others. Learn more.
The case is real and is the miss listed first under "Needs maintainer approval". One correction to the comparison: before this change, an edit in place also changed the tag only because it changed the change time; the same old tag restarted every resume after inode churn on FUSE mounts, chmod, hardlink removal and a switch between API servers, which is the bug this fixes. Whether that trade is acceptable, or a stored per-file version is wanted instead, is the maintainer's call.
The reason will be displayed to describe this comment to others. Learn more.
@darthShadow You’re right. The previous revision-based tag could restart resumes even when the file bytes had not changed, including after inode churn or metadata-only changes.
The sampled tag avoids those invalidations, but it can allow a mixed-revision resume in the case described above. I’m not marking the finding as addressed. A maintainer needs to decide whether to accept that trade-off.
📝 Learnings were not changed: only organization members or users with write access to this repository can add or remove learnings.
Learnings used
Learnt from: rangoDJ
Repo: Silo-Server/silo-server PR: 1770
File: internal/playback/keyframes/coverage.go:297-299
Timestamp: 2026-10-02T03:31:18.800Z
Learning: In internal/playback/keyframes/matroska.go, the Go keyframe reader intentionally rejects video tracks with TrackTimestampScale other than 1. firstVideoTrack flags these tracks, and readMatroska returns ErrNoIndex so playback retains FFmpeg's playlist. Do not recommend applying TrackTimestampScale only to BlockDuration; rejection avoids inconsistent conversion of cue, block, and duration times.
Learnt from: Quick104
Repo: Silo-Server/silo-server PR: 1325
File: :0-0
Timestamp: 2026-09-23T01:35:45.723Z
Learning: In `internal/playback/auto_transcode_pipeline.go`, the automatic-transcode cache stores the successful video execution path for a source, not the complete playback recipe. Its cache key intentionally excludes audio codec, audio and subtitle track indexes, seek position, and segment length because those fields do not determine GPU video decode or encode viability. `SeekSeconds` must remain excluded so seeks and restarts can reuse a successful safer video path.
Learnt from: Quick104
Repo: Silo-Server/silo-server PR: 2457
File: internal/playback/subtitle_stream.go:173-174
Timestamp: 2026-10-14T13:47:51.351Z
Learning: In the Go playback implementation in internal/playback/subtitle_stream.go, FFmpeg's .sup demuxer emits each PGS display-set segment as a separate packet with the same timestamp. An input seek exactly at that timestamp can omit the initial presentation segment. Matroska stores a display set as one block, so this packet-boundary concern does not apply in the same way to Matroska source-container extraction. A stray trailing segment from a preceding display set does not require complete-display-set filtering because a PGS decoder ignores it.
Learnt from: Quick104
Repo: Silo-Server/silo-server PR: 1358
File: internal/api/handlers/playback_service.go:0-0
Timestamp: 2026-09-24T03:14:30.634Z
Learning: In `internal/api/handlers/playback_service.go`, the Go playback code uses the published external or downloaded SRT representation when one exists to distinguish original SRT from WebVTT for cross-surface checks. When no SRT URL has been published, it uses the stored `subrip_sidecar_v1` feature token; `internal/api/handlers/playback_v3.go` removes that token from every `/api/v1` start. This distinction accommodates older attempts that stored the token but published WebVTT.
Learnt from: Quick104
Repo: Silo-Server/silo-server PR: 1313
File: internal/naming/episode.go:23-23
Timestamp: 2026-09-22T22:40:27.760Z
Learning: In `internal/naming/episode.go`, the `technicalXTokenRe` fragment `\d\.\d+` already recognizes technical aspect-ratio tokens with multiple decimal digits, such as `2.35x1`. Do not request a change to `\d{1,2}` for this case.
Learnt from: Quick104
Repo: Silo-Server/silo-server PR: 2412
File: migrations/sql/20261013170245_requeue_trickplay_hdr_and_repairable_sheets.sql:11-20
Timestamp: 2026-10-13T20:24:53.323Z
Learning: In internal/trickplay/service.go, trickplay generation extracts chunks independently and stores the last chunk's decoder in Published.Decoder. This can hide earlier hardware-decoded chunks. The admin regenerate action can regenerate an affected file.
Learnt from: Quick104
Repo: Silo-Server/silo-server PR: 2195
File: internal/scanner/matroska_track_backfill.go:306-320
Timestamp: 2026-10-09T22:12:00.520Z
Learning: In the Go scanner, internal/scanner/matroska_tracks.go's readMatroskaTracksFile should use f.Stat() for post-read metadata because mediaprobe.ReadMatroskaTracks reads from that open file. If a rename replaces the path, the open file can still represent the stored media_files revision. A later rescan detects the replacement and rewrites the row, which invalidates the backfill check.
Learnt from: CR
Repo: Silo-Server/silo-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-11-12T19:04:00.627Z
Learning: Source excerpt:
# Silo Server
## What Silo is
Taste: KISS and YAGNI win — the simple design beats the clever one, provided it survives both
the single-node and the multi-node deployment. The 1.0 feature set is essentially complete;
prefer correctness and polish over new feature sprawl.
Learnt from: Quick104
Repo: Silo-Server/silo-server PR: 2413
File: web/src/contexts/BrandingProvider.tsx:98-99
Timestamp: 2026-10-13T20:09:31.279Z
Learning: The web client's admin accent intentionally recolors only `primary`, `ring`, and `sidebar-primary`. In PR #2413, `web/src/contexts/BrandingProvider.tsx` preserves the token mapping previously defined in `web/src/lib/accentMapping.ts` so saved accents retain their appearance after upgrade. The Cinema Dark foreground tokens remain unchanged. Dark-accent contrast is a pre-existing issue, not a regression introduced by moving accent application to BrandingProvider.
Learnt from: CR
Repo: Silo-Server/silo-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-11-12T19:04:00.627Z
Learning: Source excerpt:
# Silo Server
## What Silo is
A modern, open-source media server built from the ground up on current infrastructure —
Postgres, S3, Redis — rather than SQLite and local disk. The foundational bet is horizontal
scale: Silo deploys as a cluster (Kubernetes, remote transcode nodes) and stays fast on large
libraries, whether it's one node serving a household or a deployment streaming to thousands of
users. Weigh every design against that full spectrum; treat a node dying mid-stream as a normal
event, not an edge case.
Learnt from: CR
Repo: Silo-Server/silo-server PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-11-17T15:42:21.993Z
Learning: Source excerpt:
# Silo Server
## What Silo is
A modern, open-source media server built from the ground up on current infrastructure —
Postgres, S3, Redis — rather than SQLite and local disk. The foundational bet is horizontal
scale: Silo deploys as a cluster (Kubernetes, remote transcode nodes) and stays fast on large
libraries, whether it's one node serving a household or a deployment streaming to thousands of
users. Weigh every design against that full spectrum; treat a node dying mid-stream as a normal
event, not an edge case.
Learnt from: Quick104
Repo: Silo-Server/silo-server PR: 950
File: internal/jellycompat/playback_sessions_list.go:80-80
Timestamp: 2026-09-05T17:44:11.302Z
Learning: In the Go Jellyfin compatibility implementation, `PlaybackSession.ExpiresAt` is an absolute playback-grant lifetime aligned with the stream-token TTL. `PlaybackSessionStore.TouchActiveForToken` and `DurableCompatPlaybackStore.TouchActiveForToken` must update `UpdatedAt` without extending `ExpiresAt`; after expiry, clients must perform fresh playback negotiation because stream-token re-mint is not implemented.
Learnt from: RXWatcher
Repo: Silo-Server/silo-server PR: 532
File: docs/superpowers/plans/2026-08-02-instant-external-srt-switching-server.md:195-205
Timestamp: 2026-08-02T16:47:37.503Z
Learning: In Go playback handlers, treat the canonical combined subtitle index as ordered by external subtitles first, using each entry’s models.MediaFile.ExternalSubtitles range index. Embedded subtitles follow after len(file.ExternalSubtitles), and downloaded subtitles follow after the embedded range. Accordingly, attachExternalTextSidecarsV3 should use an external subtitle’s range index directly as its canonical combined index.
Learnt from: NeurekaSoftware
Repo: Silo-Server/silo-server PR: 634
File: internal/downloads/remote_preparer.go:0-0
Timestamp: 2026-08-14T01:37:42.416Z
Learning: When implementing or reviewing Go clients for protected transcode-node endpoints, including `GET /hw-capabilities`, send the configured `cfg.Auth.JWTSecret` as the raw bearer credential in `Authorization: Bearer <secret>`. Do not generate or send a signed JWT, because the current `Server.requireBearer` authentication contract accepts the configured secret directly.
During a rolling upgrade, servers still on the older dsr1 tag and
servers on the new tag send different tags for the same file, so a
resume that crosses them gets a full 200. The stream-resume note now
says so beside its claim that the tag survives a switch between API
servers.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: Codex (gpt-6.2-sol) <noreply@openai.com>
Signed-off-by: Anagh Kumar Baranwal <6824881+darthShadow@users.noreply.github.com>
Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.
Reviewing changes in Silo
Include the related issue, expected behavior, and validation steps in the PR description.
For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
Follow this repository's AGENTS.md and CONTRIBUTING.md.
Request another review with @kody start-review in a PR comment.
React with 👍 or 👎 to give feedback on individual suggestions.
Review settingsReview Options
The following review options are enabled or disabled:
Options
Enabled
Bug
✅
Performance
✅
Security
✅
Business Logic
❌
⚠️ 5 Kody Rule(s) were not evaluated
These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:
Preserve optional store capabilities through production wrappers
Detach mandatory cleanup from request cancellation and bound its lifetime
Preserve durable media identity and share identity-evidence precedence
Bound decoder throughput trades and share direct-play eligibility
Make capability responses reflect effective permissions
The reason will be displayed to describe this comment to others. Learn more.
Review of 9e9764fc15. Findings are inline. A summary comment with the scores follows once the fixes are pushed.
The same fix commit also covers two small things outside the diff's lines:
windowsGOOS in internal/playback/gpudetect.go has no users once platformRequiresDirectPlayValidator is gone.
The comment above the retry loop in TestServeDirectPlayChangedEntityRejectsOldValidators still says the change time is the only thing that tells the two files apart. The bytes do that now. The loop is still needed because the tag cache sees the rewrite only through the filesystem revision.
Most ServeDirectPlay callers discard its error, so a storage error in
the sample read answered 500 with nothing in the server log. Log it as
a warning without the media path.
Also correct the resume doc: the dsr1 to dsr2 change restarts old
resumes after any upgrade, and a cached tag can outlive a same-size
rewrite on a local disk within one change-time tick. Update the stale
test comment and drop the windowsGOOS constant that lost its last user.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reviewed head: 4890ad8d46 (the PR's 9e9764fc15, one review commit, the author's 450ff9bb56, and a translations sync).
The fix works. TestServeDirectPlayReplacementAtSamePath's same-bytes row, run alone against main (cdf344f9d2), fails with status = 200, want 206 and passes on this branch. The other new tests call the changed DirectPlayEntityTag signature and can't build on main. go test for internal/playback, internal/autoscan, internal/downloads and internal/proxy passes on 450ff9bb56, and make lint-changed reports 0 issues locally. In CI, Go lint has died twice after about 48 minutes with no log. Deleting the two fileidentity_*.go files sends lint-changed into a whole-tree run, and this PR's jobs run on a GitHub-hosted runner, which appears to run out of memory on it. The code isn't at fault.
A failed sample read is now logged. The proxy, Jellyfin-compat and Audiobookshelf routes discard ServeDirectPlay's error, so the failure left nothing in the server log. The warning strips the file path, as the rest of the direct-stream log does.
direct-stream-resume.md: the dsr1 to dsr2 change restarts old resumes after any upgrade, not only a rolling one. A cached tag can also outlive a same-size rewrite on a local disk inside one change-time tick, not only on a network mount.
A stale test comment, and the windowsGOOS constant that lost its last user.
Maintainer decisions
The maintainers took the author's option on each item under "Needs maintainer approval":
The sampled tag and the narrower promise it makes. feat(playback): formalize resumable direct streams and stall observability #464 started from size and modification time and moved to the filesystem revision after its review reproduced a same-size, same-time splice. Sampling both 64 KiB ends keeps that protection for real replacements, because a different encode of the same size almost always differs in its header or index. Only mid-file edits slip through.
A failed sample read serves the file without an ETag (the author's 450ff9bb56), so a file with an unreadable tail stays playable. With no tag, every conditional request fails safe.
The one-time tag change at upgrade, the tag on every platform, and the cache cap with its read on a miss.
Concurrent cold misses each read the file, and the read has no deadline on a stalled mount. The PR body discloses both, and they stay as they are.
Before merge
Done. Silo-Server/silo-translations#228 got its translation pass and merged, and this branch is synced to its release 2026.12.05-1ec18ef (4890ad8d46). Each locale changes only the debounce help text.
The one open item is the Go lint job above. It needs a runner that can finish the whole-tree run, or a maintainer override.
Validated features
Validation tasks: none changed, matching the PR body. #1231 C1/C2, #1232 C1, #1168 C2 and #1177 C3 reach this code. Each behaves as recorded: repeats of an unchanged file are still dropped, and deletes and changes still scan. A Jellyfin download resume with If-Range still gets 206, and node removal during playback is untouched. The changes they don't cover are the ones listed above.
Other clients: the server-only change sends the same tag shape, so no client change is needed. I agree with the PR's Other clients: line.
Council
One round on 9e9764fc15: Sol (gpt-6.2-sol, medium) 5/10, Opus (claude-opus-5-5, medium) 6/10, Gemini (gemini-4-neon, medium) 7/10. I fixed the missing log and the doc gaps. The reviewers' main concern, a stale tag from a write racing the sample, exists on main too: any tag taken from a stat before the read has it. They also flagged the translation pin and the choice between a sampled tag and a size and modification-time tag, both settled above. I read 450ff9bb56 and ran its tests myself, with no second council round. It implements the alternative this review proposed.
Fit: 8/10 · Readiness: 9/10 — conditional (assuming CI is green)
Fit: resumes that survive a switch between API servers serve Silo's clustered deployment, where a node going away mid-stream is normal. Held at 8 by a new read on the request path at each cache miss, on the remote mounts this targets.
Readiness: the fix is shown by a test that fails on main, the validation check ran, the maintainer decisions are settled, and the translations are pinned to a release. The verdict stays conditional because Fit is below 9.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments
2
Enqueue-failure cleanup compares the observation token, not the identity of the claimant. If concurrent reports claim one file state, then a different state, then a replacement whose size and mtime match the first state, delayed cleanup from the first report can delete the latest report's live claim. The compare-and-delete rule predates the PR, but the coarser token makes this history possible even when the final replacement has a different Unix inode. The supported consequence is lost debounce and possible redundant queue work, not cancellation of a scan already queued.
A non-EOF sampling error can add the media filesystem path to API, Jellyfin compatibility, and Audiobookshelf download logs. Playback strips the path from its own new warning, but returns the original wrapped error; the API can log that error again, and the download handlers log the equivalent wrapped error. The merge-base tag calculation did not read media bytes and could not generate this error. HTTP callers receive generic errors; the added disclosure is to log readers, and depends on log access and retention.
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 9b848fe0-1ff0-4936-90e2-dfd49b54f3fb
Commits
Reviewing files that changed from the base of the PR and between 9e9764f and 4e17c2d.
Files selected for processing: 4
docs/architecture/direct-stream-resume.md
internal/playback/directplay.go
internal/playback/directplay_test.go
internal/playback/gpudetect.go
Files skipped from review as they are similar to previous changes: 2
docs/architecture/direct-stream-resume.md
internal/playback/directplay_test.go
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
Both points checked against 4e17c2d866. Neither needs a change in this PR.
Media path in logs. On main, these handlers already log the path for open failures. serveLocalFile wraps fspath.Open's *fs.PathError as opening file: %w, and the Jellyfin-compat (jellycompat download failed) and Audiobookshelf (abs download failed) handlers log it from their default branch. The native stream route's handleTransportStartFailure logs open and stat errors the same way. The path-free rule covers the direct stream ended diagnostic, and the new warning follows it. A failed sample read is a new way to reach those existing log lines, not a new kind of disclosure.
Enqueue-failure cleanup. The compare-and-delete on the observed state predates this PR, as the review says. The coarser state token makes one more A, B, A history possible. Even then, the worst outcome is a dropped debounce and one extra scan, with no lost or cancelled scan.
A failed or short read of the sampled bytes answered 500 on direct play
and on the local download routes that share the tag function. The tag
is only a validator, so one unreadable sample cost the viewer or the
download the whole file.
Both paths now log a warning without the media path and serve the file
with no ETag. Nothing is cached, so the next request samples again.
Download serving had no log of its own for this failure; it does now.
With no tag, http.ServeContent answers a resume that sends If-Range with
an entity tag with the full 200, fails an If-Match entity tag with 412,
and never matches an If-None-Match entity tag. Date-form If-Range and
the * wildcard keep their standard handling. The stream-resume note
describes the new behavior in place of the 500.
The sample-read tests now expect a 200 with no ETag, for a plain GET and
for Range with If-Range. The direct-play and download error unwrapping
uses errors.AsType.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: Codex (gpt-6.2-sol) <noreply@openai.com>
Signed-off-by: Anagh Kumar Baranwal <6824881+darthShadow@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments
1
A Redis claim is visible before enqueue succeeds. Another node can now treat the same observation as covered and advance its poll marker or complete its webhook delivery even when differing local inodes would have let it enqueue at the merge base. If the original claimant is interrupted before enqueue and no separate retry recovers that work, expiry does not restore the second delivery. Distinguishing a pending claim from confirmed queue coverage would address this independently of how replacements are identified.
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 5e840853-eec5-4f94-a0d9-e28fd7960ce4
Commits
Reviewing files that changed from the base of the PR and between 4e17c2d and 450ff9b.
Files selected for processing: 7
docs/architecture/direct-stream-resume.md
internal/downloads/serve_observer.go
internal/downloads/service.go
internal/downloads/service_read_error_test.go
internal/playback/directplay.go
internal/playback/directplay_etag.go
internal/playback/directplay_test.go
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
Pin the published catalog release that carries the autoscan debounce
help text in every language (Silo-Server/silo-translations#228).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.
Reviewing changes in Silo
Include the related issue, expected behavior, and validation steps in the PR description.
For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
Follow this repository's AGENTS.md and CONTRIBUTING.md.
Request another review with @kody start-review in a PR comment.
React with 👍 or 👎 to give feedback on individual suggestions.
Review settingsReview Options
The following review options are enabled or disabled:
Options
Enabled
Bug
✅
Performance
✅
Security
✅
Business Logic
❌
⚠️ 5 Kody Rule(s) were not evaluated
These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:
Preserve optional store capabilities through production wrappers
Detach mandatory cleanup from request cancellation and bound its lifetime
Preserve durable media identity and share identity-evidence precedence
Bound decoder throughput trades and share direct-play eligibility
Make capability responses reflect effective permissions
Checked against internal/autoscan/service.go (claimTarget, releaseClaims). The gap is real and predates this PR. claimTarget writes the Redis claim before the cycle enqueues its targets. Only a failed enqueue releases it (releaseClaims); a process that dies between the claim and the enqueue leaves it in place until the debounce window ends. On main, a repeat report with the same state on any node is dropped in that window: the same node, or nodes whose mounts agree on inode numbers. This PR makes the state agree across nodes whose mounts number inodes differently, so more of those repeats now match.
The trigger is a node dying in the milliseconds between the Redis write and the queue insert, with a repeat report inside the window (60 seconds by default). The scan is lost until the next report or scheduled scan. Fixing it means telling a pending claim from a confirmed enqueue, as the review suggests. That belongs in its own change, not this PR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Related issue: N/A
Validation tasks: none changed. Reaches #1231 C2, #1232 C1, #1168 C2 and #1177 C3, all passed on builds 1804 and 2970. Board read 2026-12-05; the cases were not walked again.
Other clients: Apple N/A and Android N/A (no client change needed: each handles a changed tag as it does today, and this change makes tags change less often); Roku N/A (the app reads no media ETag; media plays through the platform Video node); Web N/A (the player identifies a file by size and Last-Modified, not ETag)
Seeking in a direct-play video can restart the download from byte 0. A resume sends
RangewithIf-Rangeset to the ETag of the earlier response, and that ETag came from the file's device number, inode and change time. On a FUSE or FAT mount that renumbers inodes, after achmod, after a hardlink is removed, or when the resume lands on another host, the tag differs and the server answers200with the whole file instead of206. Windows and other platforms without a filesystem revision sent no ETag at all. The autoscan debounce had the same dependence: its token for a file included the inode, so inode churn, or a report handled by another node, queued a second scan of an unchanged file.This change makes the direct-play ETag depend on the file's size, modification time and content, and sends it on every platform. It also makes the autoscan debounce token size and modification time only.
Approach
chmodand hardlink removal, and matches across API servers that see the same size and modification time. A process-wide cache of 4,096 tags, keyed on the path, the local filesystem revision and the hashed size and time, means the file is read only on a miss. The tag changes once at upgrade (dsr1todsr2).DirectPlayEntityTagnow returns an error. When the sampled bytes cannot be read, or the read comes up short,ServeDirectPlayand the two local download routes (Jellyfin compatibility and Audiobookshelf, throughserveLocalFile) log a warning without the media path and serve the file with no ETag. Nothing is cached, so the next request reads again.file:<size>:<mtime in microseconds>, the inputs the scan itself decides change by.fileidentity_unix.goandfileidentity_other.goare deleted.200, because Go'sIf-Rangecompares strongly.docs/admin-api.md,docs/architecture/direct-stream-resume.mdanddocs/architecture/worker-http-protocol.mddescribe the new rules. The proxy's OpenAPI description no longer calls the tag "file-derived strong";make verify-apiv2-openapipasses.platformRequiresDirectPlayValidatorskips are gone because the tag now exists everywhere. Nonolintlines and no CI test-list changes; the new tests need no Postgres.--version 2026.12.05-1ec18ef, the release it published; in the generated files only that key's value in each language and the version stamp change.Needs maintainer approval
stathides a write (rclone reports change time equal to modification time), an edit at a sampled end keeps the cached tag until the next stat change, restart or eviction; the lab reproduced this (see Validation). For either, a staleIf-Rangegets206of the current file,If-Matchpasses, andIf-None-Matchanswers304. This narrows what Formalize resumable direct streams and expose stalled-write reaping #443 and feat(playback): formalize resumable direct streams and stall observability #464 promised: a changed tag for same-size replacements even when the modification time is preserved (docs/architecture/direct-stream-resume.md). The tag is strong in form only, a departure from RFC 9110 section 8.8.1.Rangerequest with no validator gets206as it would with a tag. With no tag,http.ServeContentanswers anIf-Rangethat carries an entity tag with the full200, fails anIf-Matchentity tag with412, and never matches anIf-None-Matchentity tag. Each request repeats the read until it succeeds.500would refuse every range of that file, as the maintainer review on this pull request pointed out.200. From reading its code, Android treats a changed tag as an error, as it does today when a file changes.FileInfowithoutSys()) reads the sampled bytes on every request,HEADincluded, because it cannot use the cache.HEADtoo. Concurrent misses on one file each read; the Web player starts a head request and a one-byte probe in parallel. Measured cost is under Validation and Risks.debounce_seconds(default 60). Other work on that row (repair of a missing file, probe repair, sidecar subtitles) waits for the next report or scheduled scan. This reverses the inode check fix(autoscan): stop the debounce from dropping real file changes #1931 added. During a rolling upgrade the two token formats replace each other's claim, so the cluster scans more, not less.Validation
788aa7a87, which is base1026b8e5a385397a5960c76cc50d84b8de426271plus the new tests and the signature change that lets a tag fail. The behavior hunks were absent: the sampled tag, the read-failure handling inServeDirectPlay, the download hook move and the autoscan token. Five tests failed, each on an assertion and none on a panic or build error:200where206was expected after a same-bytes rename, no error from a short sample read, an empty tag without a revision,Content-Dispositionset when the tag fails, and an autoscan state that still held the inode. A mutation that moves the tail sample one byte fails only the changed-last-byte row.TestServeDirectPlaySampleReadFailureServesWithoutETag,TestServeLocalFileEntityTagErrorServesWithoutETag) ran against the production files of4e17c2d86, which answered500. All four subtests failed on assertions, for exampleServeDirectPlay error = direct play entity tag: read 15 bytes at offset 0: EOF, want nilandserveLocalFile error = entity tag: sample read failed, want nil.f6bc2e58a(the code before the locale files were re-synced to the catalog commit).go testforinternal/playback,internal/autoscan,internal/downloadsandinternal/proxypass, withmake verify-apiv2-openapi,make lint-changed(0 issues) andmake verify-local-paths. Tests that need Postgres or Redis skip in these runs; the new tests need neither. G2, the full gate from CONTRIBUTING.md (37 steps: web lint, format check, build, budget and tests; Go build,gofmt,go mod tidy,go vet,make lint-changed,make test-go; theverify-*targets; migrations; DB pins; Prometheus rules), passed on base1026b8e5aand treef6bc2e58a. The branch was then rebased ontomainatcdf344f9d; the code and doc hunks did not change, and only the generated locale files were synced again. G2 on that final tree, basecdf344f9d: all 37 steps passed. After the change to serve without a tag (tree9ba923e09),go build ./...,go vetandgo test -vforinternal/playback,internal/downloads,internal/jellycompatandinternal/audiobooks/...pass, withmake lint-changedandmake verify-local-paths; G2 on that tree passed all 37 steps.53a8e1bcf, serving through its Jellyfin stream route from rclone v1.76.0 mounts of a local directory. Later commits changed one test, comments, docs and the locale files, not product logic.rclone mount2the inode changed (11 to 21) aftervfs/forget, and aRangerequest with the pre-churnIf-Rangegot206, the same tag, and a body whose hash matched the file's range. Onrclone mountv1.76.0 the inode does not change after forget or remount, so that run is void and not counted as a pass.rclone mount, a 4 KiB edit inside the last 64 KiB of an 8 MiB file, with the modification time restored, leftstatunchanged while the mount served the new bytes. The warm server returned206with the new bytes under the old tag; after a restart the tag changed. This is the miss in item 1.chmodor hardlink removal on a mount; the rename-over test row stands in for the inode change. Concurrent cold misses were measured only as the parallel pair above, and local SSD or HDD cost under load was not. Autoscan runs only through unit tests, not two nodes on a shared Redis. Rolling-upgrade behavior was not run.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/pr-5870/
The page holds the red run, the green runs with both mutation runs, the G2 gate log, and the inode-churn, hidden-write and read-cost runs behind the Validation bullets, with the per-file read-cost tables. Visible change: the debounce help text on the Web admin autoscan settings page. The page shows it before and after.
Surface and build: server (direct play, local downloads, autoscan intake) and one Web admin help string.
Build: head
ff25de169on basecdf344f9d238ee5e11e04a581538ab14f85b96c8. The red, green and lab runs used base1026b8e5a. Lab runs used change tree53a8e1bcf071e6307648ac034727d33a577fafb8; the base build ran the "before" arm of the local read-cost comparison.Risks
snapraid touch, and two mounts that date one file differently each give a new tag, as today.docs/architecture/transcode-nodes.md). A node or proxy mount that dates a file differently sends another tag, so a resume that switches to it gets200, as every host switch did before.suppress.gocomment says so; there is no code change.internal/metadata/image_cache_processor.go). Theme-song discovery rejects a directory on an inode-only change (internal/themesongs/themes.go). Both stay out of this PR.Checklist
AI Disclosure
500on a failed sample read, a comment about old autoscan tokens, docs that called the tag "strong", and a test comment) and one was handled by re-running the locale sync from the catalog commit. The old-token case in Risks is disclosed, not fixed. After the maintainer review, Claude Sonnet 5.5 changed a failed sample read to serve without a tag. GPT-6.2 Sol reviewed that change and Claude Sonnet 5.5 checked it independently. The reviewer's wording finding is fixed: the docs and comments had described the outcome of every conditional header, not only those that carry an entity tag. Its other finding is left as it is onmain: when a file shrinks betweenstatand the read, a416names the size fromstat. A human chose each design option.Note
Fix direct-play seek-resume after inode churn by using sampled ETags
dsr1todsr2, and conditional-request tests no longer skip on platforms without validators.Changes since #5870 opened
playback.ServeDirectPlaywhenDirectPlayEntityTagfails. [4e17c2d]playback.TestServeDirectPlayChangedEntityRejectsOldValidatorstest wording. [4e17c2d]windowsGOOSconstant from the GOOS constants block in theplaybackpackage. [4e17c2d]playback.ServeDirectPlayto serve content without an ETag when entity-tag computation fails, and replaced the corresponding test [450ff9b]downloads.Service.serveLocalFileto serve the file without an ETag when entity-tag computation fails, and replaced the corresponding test [450ff9b]direct-stream-resumearchitecture document to describe serving without an ETag on tag-computation failure [450ff9b]Macroscope summarized 9e9764f.