Skip to content

feat(nodes): let transcode nodes read sources through the API servers - #4338

Merged
Quick104 merged 40 commits into
mainfrom
feat/thin-nodes-core-source-access
Nov 15, 2026
Merged

Quick104 merged 40 commits into
mainfrom
feat/thin-nodes-core-source-access

Conversation

@Quick104

@Quick104 Quick104 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: #1176
Validation tasks: changes #1178 C1 (a transcode node's edit dialog gains a Source access field; the default keeps today's behavior)

Other clients: N/A (no client-visible change; the setting is on the web admin Nodes page)

A transcode node must mount the media library at the exact paths the catalog uses. A self-hoster whose GPU box cannot reach the storage, such as a machine at another site or a rented GPU, cannot use it as a node.

This adds a Source access setting to each transcode node. With "Through the API servers", the node needs no library mount: it reads source files over HTTP from the API servers. "Library mount on the node" stays the default.

Follows #4337, now merged, which removed the database, Redis and shared secrets from the node.

Approach

  • The setting. stream_nodes.source_access is local or core. The admin API and the web dialog accept it for transcode nodes only. The node receives it in its configuration and applies it to its next job without a restart.
  • Source bytes route. GET and HEAD /api/internal/nodes/sources on the API servers take a request signed with the node's key and the job's grant in a signed header. The server opens the granted path, checks size and modification time on the open file, and serves ranges from it. A read runs no catalog query. Each node gets 512 concurrent streams on each API server, then 429. Streams end when an API server begins shutting down, and the node resumes against another server or after the restart.
  • On the node. A relay on 127.0.0.1 gives FFmpeg and ffprobe one URL for each source revision. It resumes interrupted reads and gives up after 30 seconds without progress. Go code that reads the file directly, such as the Matroska index and subtitle staging, uses a paged reader over the same route.
  • FFmpeg guard. A launch with a relayed input gets protocol and format whitelists and no HTTP proxy. The guard sits where commands are launched, not at each call site.
  • Subtitle burn-in. The node stages a text subtitle track from the file's index over the relay. Where FFmpeg would need the whole file on disk, as for MP4 mov_text, the node refuses the start with 409 and the job runs on a node with a mount or on the API server.
  • Grants. A grant now carries its issue time, and renewals stop 24 hours after it.
  • Logs. Relay URLs are redacted to the source's revision tag.

One related fix is included: a subtitle rendition's source is compared between hosts at microseconds, the catalog's precision, instead of nanoseconds.

The cost is that every source byte a node in this mode reads passes through the API servers, so they need the bandwidth. On loopback the median time to first segment was 0.550 s against 0.382 s from a mount, and a seek 0.227 s against 0.150 s. A slower link was not measured. On shared dev, with the node on a different host than the API server, the medians were 1.32 s against 1.96 s and 0.73 s against 1.13 s: reading through the API server was faster there, probably because of its page cache, which the run did not isolate. A copy remux is not paced, so it pulls the rest of the file from the API server within seconds of each start or seek; one copy session read 1.5 GiB that way.

docs/architecture/transcode-nodes.md has the route, the relay, the metrics and the failure table for this mode.

Validation

  • The full gate in CONTRIBUTING passes on this branch merged with main at c11b0a968f, with the same exceptions as feat(nodes): run transcode nodes without database, Redis or shared secrets #4337 had: two real-FFmpeg tests that also fail on main with FFmpeg 6.1, backup tests skipped without pg_dump, and ShellCheck and the Prometheus rules check not run. The only commits since are the locale syncs, now pinned to silo-translations release 2026.11.15-0d604d4; the web typecheck passes on them.
  • New tests cover the bytes route (signature, grant, ranges, revision change, stream cap, shutdown), the relay's resume and stall handling, the paged reader, the FFmpeg guard and proxy removal, and relayed concat. A Linux test starts an API server and a node with no library access and plays through them.
  • A run on a real local stack traced a node with no library mount under strace, its FFmpeg children included: about 519,000 file opens, none of a library path. Copy remux, progressive remux, ASS burn-in, subtitle renditions, downloads, trickplay sheets, chapter thumbnails and theme conversion produced the same bytes as a node with a mount. Transcodes differed only as much as two runs on the mounted node differ. The evidence page has the table.
  • An independent review and that run found five problems, all fixed in 05004a09dd: FFmpeg sent loopback reads to a configured http_proxy, a node could open unlimited source streams, one open stream held API server shutdown for 33 s, the bytes metric moved only when a stream ended, and one 416 answer lacked no-store.
  • Two runs on shared dev, at 0bb7f9a314 and again at 5f9ffeb1c0, put one of two Intel GPU nodes (FFmpeg 8.1.3-Jellyfin), on a different host than the API server, in this mode. GPU transcode, HDR10 and Dolby Vision tone mapping in hardware, PGS and text burn-in, copy remux, the keyframe-planned copy playlist, progressive remux through a proxy and a Jellyfin-surface transcode passed. FFmpeg's input was the loopback relay URL with the protocol and format whitelists. Copy-remux segments and the first 64 MiB of a progressive remux were byte-identical to the mounted mode. MP4 mov_text burn-in was refused by the node and ran on the API server. Four simultaneous transcodes served 120 of 120 segments in each of three runs, slowest 1.61 s. One transcode ran 27 minutes, renewed its source grant at 20 minutes and had no failed segment. A killed node rebuilt its session with a new relay URL. Shared dev is back on main.
  • Bot reviews after opening raised 12 findings. Nine are fixed in c9b3f3b219, 51308e5ffc, 6c2ac0288d, feaa249246 and 5f9ffeb1c0: a renewal judged by a stale grant expiry, an FFmpeg without http passing the relayed-list check, a failed relayed read taken for a missing keyframe index (in three places), a cancelled start that kept waiting on a relayed hash read, a missing 416 in the HEAD contract, and three test findings about a sleep or an exact inotify count. The others were not defects.
  • The second shared-dev run found that a refused burn-in start left an empty session directory on the node. Fixed in 5a7bcd1639, after that run.
  • Not run: VobSub burn-in in this mode (it fails in the hardware overlay with a mount too, as on main), 4K tone mapping (disabled on shared dev), trickplay and chapter thumbnails on real hardware (off in every shared-dev library), and a link slower than a LAN.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/thin-nodes-core-source-access/

Surface and build: web admin Nodes page on desktop, and the end-to-end run, both at d61b65421f of this branch on a local stack. The shared-dev run is linked from that page.

Risks

  • API server load. Source reads in this mode use API server bandwidth and file descriptors. silo_node_source_streams_active, silo_node_source_bytes_sent_total and silo_node_source_stream_ends_total show it.
  • Migration. Adds stream_nodes.source_access with a check constraint, default local.
  • Relay URL. While a job runs, any process on the node host can read that source through the loopback URL.
  • Outages. When the API servers are unreachable for more than about 30 seconds, the read fails and the viewer gets 404 for segments until the server is back. The session then serves again.
  • Limits of a node without a mount. MP4 mov_text burn-in runs elsewhere. The macOS Firefox HEVC resume primer from fix(playback): start macOS Firefox HEVC resumes and seeks on an IDR frame #3213 is skipped. A Jellyfin audio switch on a session whose burn-in cannot be staged returns an error instead of moving.
  • File replaced in place. A session open on a file that is replaced at the same path rebuilds from the new file with the old recipe. This happens with a mount too and on main; the design doc lists it.

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: Claude Code in T3 Code
  • Tool(s): Claude Code subagents for implementation, review and the local end-to-end run; the silo-translations translation pass
  • Model(s): claude-fable-5-2 (design decisions, integration, this description); claude-opus-5-5 (subagents, translation pass)
  • Involvement: Fully AI-generated at the maintainer's direction; the maintainer has not yet reviewed the diff
  • Adversarial review: One independent agent reviewed the finished branch, and another ran the end-to-end plan above against nodes with no library mount, traced with strace and an FFmpeg wrapper that refuses library paths. Together they found the five problems listed under Validation, all fixed. Neither found a way to read a file without a valid grant for it or with another node's grant.

🤖 Generated with Claude Code

Note

Add core source access mode so transcode nodes read sources through the API servers

  • Adds a source_access node setting (local or core, transcode nodes only) with admin UI, API bodies, nodepool validation, and a DB migration; changes take effect for jobs started after the change
  • In core mode the node serves FFmpeg a loopback relay URL backed by a signed source-bytes route (GET/HEAD on PathSources) with grant-checked, ranged reads, per-node stream cap of 512, retry/backoff, and a page cache
  • Source grants move to version 2 with an issue time and a 24-hour maximum lifetime; legacy version-1 grants decode with an inferred issue time
  • Relay URLs are redacted from logs, error responses, and FFmpeg command lines via nodesource.RedactingHandler; launches through fspath.CommandContext strip proxy environment variables
  • Relayed inputs cannot stage text subtitle burn-in; such starts return HTTP 409 with ErrRelayedSubtitleBurnIn
  • Risk: core-access nodes without a library mount depend on the new streaming route — reverse proxies must pass the X-Silo-Source-Grant header and avoid buffering source responses; check docs/update-to-1.0.md

Macroscope summarized 5d08067.

Quick104 and others added 17 commits November 14, 2026 19:16
Adds the per-node credential that thin transcode nodes will sign with.
Nothing signs with it yet, so existing nodes behave as before.

- stream_nodes.node_key_ciphertext holds the key encrypted under the row
  AAD. It is a credential, not configuration: issuing one moves neither
  the admin revision nor the pool generation.
- POST /api/v2/admin/nodes/{id}/key issues or rotates a key and returns it
  once. Node rows gain key_issued, and the node capabilities gain
  node_keys. Proxies take no key (409).
- nodepool.KeyRegistry holds every node's credential, disabled nodes
  included, on API servers and proxies. It reloads on node_pool_changed,
  every minute, and on a lookup miss at most once a second. A proxy that
  starts before the column is migrated keeps running and loads it later.
- Two transcode nodes can no longer be saved at one canonical URL, since
  the registry finds a node by that address.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The core now signs every request to a transcode node with that node's key,
and the node verifies with the same key from SILO_NODE_KEY. The shared
secret signs only requests to proxies.

- nodeauth splits signing by direction: core to node and node to core use
  separate HKDF labels and canonical versions, so a request captured in
  one direction never verifies in the other. The node-to-core signature
  also covers the source grant header.
- Senders name the kind of node they target. The registry's keyring gives
  a transcode target only that node's key and gives a proxy target the
  shared secret only for a URL registered as a proxy. An unknown URL and a
  keyless node are errors; neither falls back to the shared secret.
- A transcode node without a usable key stays listed and health-checked
  but takes no new work.
- The node's signed routes accept no legacy bearer.
- HTTP clients that call a node refuse redirects explicitly.

The node still holds its database and Redis; later commits remove them.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Adds the routes a thin transcode node will call instead of reading the
database and Redis itself. Nodes do not call them yet.

- nodecontrol.RequireNode verifies a node-signed request against the key
  registry and puts the node id in the request context. Handlers take the
  node's identity only from there. A disabled node is accepted; a deleted,
  keyless or proxy row gets 401.
- GET /api/internal/nodes/self/config returns the calling node's settings
  with its row overrides applied, with the revision as a strong ETag. A
  test fails when the node reads a config field the document lacks.
- POST .../self/report replaces the node's session records and telemetry
  snapshot, fenced on (boot_id, seq) so a replayed or older report changes
  nothing. Keys are scoped by the authenticated node id.
- POST .../self/logs stores a log batch under the authenticated node and
  clamps entry timestamps to the core's clock.
- POST .../self/health-changed publishes node_drain_changed.
- Report, logs and health-changed share a per-node request budget.
- The routes stay out of the request log, the activity log and response
  compression, and the worker protocol contract lists them as node_signed.

miniredis is added for tests: CI has no Redis, and the report fence and
session replacement are Lua scripts.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Each transcode node shows whether it has a key, with a warning that a node
without one takes no work. On a server that can issue keys, an admin can
issue or rotate the key. Rotation asks for confirmation and says the
node's running streams fail until it restarts with the new key.

The new key is shown once, with the SILO_CORE_URL and SILO_NODE_KEY
settings the node starts with. It is kept in the dialog's state only, and
the dialog cannot be closed while the request is in flight. A refusal
shows the server's reason; a lost answer says the key may have rotated.

Creating a transcode node offers to issue its key.

The translation pin names a local catalog commit. Re-sync to a published
release before this merges.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The core now makes the decisions a transcode node made from Redis and the
shared secret. Nodes do not call the new routes yet.

- POST /api/internal/nodes/self/resolve answers the recipe and playback
  identity for a node rebuilding a lost HLS session or serving a
  progressive remux: deny checks, token verification, and a recipe bound
  to the calling node. A complete stored card wins over a complete token,
  because a move rewrites the card while the client keeps its old token.
  A recipe store read error is 503.
- POST /api/internal/nodes/self/revoke-recipes revokes the calling node's
  recipes, for the node to call inside its own force-reload teardown.
- A remote stop deletes the transport's stored recipe before it tells the
  node, unless the recipe names another node URL. A release deletes
  nothing. jellycompat reuses a transport id across start candidates, so a
  late stop on one must not remove the next one's recipe.
- Every dead-node move writes the stored recipe naming the new executor,
  for sessions whose URLs carry a token too. jellycompat recipes bind the
  node they started on.
- Every relay that signs a request to a transcode node checks the deny
  marker first, and a move rechecks it before it commits and before it
  serves.
- A node's 401 and a failure to sign for a node reach clients as the node
  being unavailable, not as a client auth failure. Neither moves the
  transcode: a replica with a stale key registry cannot sign for any node.
  /api/v2 delivery maps a relay 502 to dependency_unavailable.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The core now signs a source grant for every job it sends a transcode node:
a stateless capability to use one revision of one catalog file, or theme
file, through one node. Nodes do not use grants yet and still approve
paths against the catalog themselves.

- A grant names the node, the file or theme id, the fspath-encoded catalog
  path, the size and the modification time, and lasts an hour. Its key is
  derived from auth.jwt_secret under its own label. Revisions compare the
  modification time at microseconds, the catalog's precision.
- Native and Jellyfin-compatible starts, dead-node moves, download
  preparation, trickplay, chapter thumbnails and subtitle-sync samples
  carry source_grant. A move sends the replacement node a fresh grant.
  When no grant can be minted the work fails over or runs locally as a
  failed dispatch does.
- POST /api/internal/nodes/self/sources/open exchanges a grant for the
  approved path and a renewed grant. It refuses another node's grant
  (403), a source that left the catalog or the disk (410) and a changed
  size or modification time (412).
- Resolve checks that the catalog still has the recipe's file or theme and
  adds a grant for the calling node.
- nodesource.Opener is the node side: it opens a grant against the node's
  own mount, refuses a mount whose revision differs, and renews the grant
  while the source is open.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…crets

A transcode node now starts with two settings, SILO_CORE_URL and
SILO_NODE_KEY, and holds no database, Redis, data cipher, event bus or
shared secret. There is one transcode node type and no legacy mode: nodes
from before this change cannot work with an updated core, or the reverse.
Proxies are unchanged.

- MODE=transcode branches before the bootstrap. DATABASE_URL, REDIS_URL,
  SECRET_KEY, NODE_URL and NODE_NAME are ignored with one warning. A
  plain-HTTP core URL off the host logs a warning, because the node takes
  its FFmpeg path, directories and input paths from the core's answers.
- The node reads its configuration from the core, polls it every 30
  seconds, and rereads it when the core pushes a reload. The core pushes
  after a drain request or resume and after a change to a node's
  overrides. An unchanged poll keeps the configuration pointer.
- Sessions and stream telemetry stay in memory and go to the core in a
  report every second. Logs, FFmpeg output included, ship to the core.
  Drain changes are reported to the core instead of the event bus.
- The node verifies no stream token and reads no deny marker or recipe.
  A lost HLS session and every progressive remux request ask the core's
  resolve route, after the node's own stop fences. A force reload asks the
  core to revoke the node's recipes first.
- Every job opens its input with the source grant it carries, at the
  approved path on the node's own mount. A mount whose file differs from
  the core's answers 409. The catalog path authorizers are gone.
- Health carries the node control version and key_rejected. The core
  treats a transcode node without the version, or with a rejected key, as
  unhealthy, so a node on an older build is not placed.
- The omnibus init and the shipped Compose file no longer ask a transcode
  node for database or Redis settings.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
- config now shares the per-node background budget, and resolve and
  sources/open get a budget of their own (200 a second, burst 600), so a
  node key cannot loop catalog reads without bound. A node treats 429 as
  transient on every route.
- Log entries a node ships are normalized before they are stored: an
  address that does not parse is cleared and node-supplied text is capped.
  A bad row no longer makes the core retry the batch row by row, and the
  dropped-entries warning is logged at most once a minute per node.
- Issuing a key publishes node_pool_changed even when the pool reload
  fails, and a node's 401 asks the credential registry to reload, so a
  replica holding a replaced key heals in seconds.
- A dead-node move writes the new node's stored recipe as soon as the move
  commits, then retires the old node. Nodes no longer delete recipes, so
  the wait left a window where the new node could not rebuild.
- A chapter thumbnail job a node cannot serve reports the reason the core
  falls back to local extraction for.
- A rejected key is described with both causes: a replaced key or a clock
  more than 30 seconds off.
- A progressive remux request checks the node's own state before it asks
  the core.
- make dev-transcode starts a node with SILO_CORE_URL and SILO_NODE_KEY.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
docs/architecture/transcode-nodes.md is the authority for the design: node
keys, signing in both directions, the node control routes, playback
authority on the core, source grants, failure behavior and security
properties. docs/update-to-1.0.md gains the operator steps for the
coordinated node upgrade. Other documents link to the new one and no
longer say that a transcode node reads the database, Redis or the shared
secret.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…e rejects

- Creating, updating or deleting a node now reloads this server's
  credential registry before the response and publishes
  node_pool_changed, and reconciliation invalidates the registry when the
  node list changes. A deleted node kept signing and being signed for
  until the registry's 60-second reload.
- A transcode node shutting down on SIGTERM no longer waits for its
  sessions while the main server rejects its key: no relay can reach
  them and nothing will stop them. After a key rotation without a drain,
  the restart waited out the 10-minute drain timeout.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A transcode node can now run without a library mount. Source access is a
per-node setting: local (the default) reads the node's own mount as
before, and core reads the bytes over HTTP from the API servers.

- stream_nodes.source_access is node configuration: v2 node rows carry
  it, create and update accept it for transcode nodes, the capabilities
  advertise it, and the node gets it in its configuration document and a
  reload push when it changes. Dispatch does not branch on it: the core
  mints the same source grant either way.
- GET and HEAD /api/internal/nodes/sources serve the granted file to its
  node, with the grant in a signed header. The core checks the grant, not
  the catalog, opens the path, compares size and modification time on the
  descriptor and serves from it, so a file replaced after the check is
  never served. Metrics count active streams, bytes and ends by outcome.
- A grant now carries when it was issued and cannot be renewed or read
  with past 24 hours.
- On the node a loopback relay gives FFmpeg and Go readers the source,
  with one URL per source revision so path-keyed caches keep working. It
  signs every upstream request, resumes after a cut or stalled body, and
  fails the read after 30 seconds without progress.
- Go-side reads use a paged reader that fetches concurrently and merges
  fetches of the same page. internal/fspath answers stats for a relayed
  input and opens a reader for either a path or a relayed input.
- Every FFmpeg and ffprobe launch through fspath.CommandContext gets
  protocol and format whitelists on a relayed input. The admitted
  containers come from internal/mediacontainer, which the scanner now
  reads its extension lists from too.
- Text subtitle burn-in stages the track over the relay. When it cannot
  be staged, the whole-file libass fallback is refused for a relayed
  input and the node answers 409, so the start goes elsewhere.
- Trickplay sampling reads a relayed input through a concat list with
  per-entry whitelists, and a node whose FFmpeg cannot read one refuses
  the run so the work moves.
- Relay URLs are replaced with the source's entity tag in the node's
  logs, FFmpeg log lines and error bodies.
- Subtitle rendition sources compare modification time at microseconds,
  like the other cross-host revision checks.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The node form has a Source access choice for transcode nodes, on a server
that supports it: read from the node's own library mount, or from this
server. The help text says a node reading from the server needs no mount
and that every byte it reads passes through the API servers.

The translation pin names a local catalog commit. Re-sync to a published
release before this merges.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
- FFmpeg and ffprobe read a relayed input without an HTTP proxy: the
  argument guard and the relayed concat list set the proxy off, and a
  launch with a relayed input starts without the proxy variables. A node
  host with http_proxy set sent every loopback read to that proxy.
- The source bytes route allows 512 concurrent streams per node on each
  API server and answers 429 beyond that, so a node key cannot exhaust the
  server's file descriptors. A node backs off and retries.
- Source streams end when an API server begins shutting down, and the
  node's relay resumes against another server or after the restart. One
  open stream held a graceful shutdown for about 30 seconds.
- silo_node_source_bytes_sent_total advances while a stream runs, not
  only when it ends.
- Every answer of the bytes route is no-store, including 416 and 412.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…te-transcode-nodes

- .silo-translations, web/src/locales/*, .silo-translations-files: took
  main's, then regenerated with sync-translations --local from the
  rebased silo-translations branch (pin local-de1af480da75).
- go.mod/go.sum: kept miniredis/gopher-lua beside main's bumped
  go-keyring and xxh3; go mod tidy.
- scripts/ci/db-contracts.txt: kept both sides' entries.
- contracts/api/v2/openapi.json: regenerated; the node protocol's
  playback_RecipeCard schema gains main's adaptation_reasons.
- internal/transcodenode: main's new spawnReconstruct test passes a
  nodecontrol.Resolution, as this branch's spawnReconstruct takes.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…-nodes-core-source-access

Brings in origin/main through PR 1's merge.

- internal/fspath/os.go: kept this branch's argument guard and proxy
  bypass in CommandContext beside main's FFConcatFileURL, which now
  refuses a relayed input with ErrRelayed: a list on stdin is outside
  the argv guard.
- internal/mediasample/concat.go, request.go: concatPath names a
  relayed input as its bare URL and otherwise defers to
  fspath.FFConcatFileURL; Validate and the Samples list use it, so a
  relayed sample run keeps its per-entry restrictions.
- internal/playback/remux.go: main's macOS Firefox HEVC IDR primer
  writes its source into an unguarded ffconcat list, so a relayed input
  skips the primer (checked before any read) and serves the plain
  seeked copy. keyframes.HEVCKeyframeIsIDR opens through
  fspath.OpenReader, as Load does.
- docs/architecture/transcode-nodes.md: says so under Relayed concat.
- Locale files regenerated from the rebased silo-translations branch
  (local-de1af480da75); contracts regenerated, unchanged.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Transcode nodes can now read approved media revisions through API servers when configured for core source access. The change adds source-byte routes, node-side relaying, media-processing support, and admin configuration and reporting for the new mode.

Changes: Core source access

Layer / File(s) Summary
Source-access configuration
internal/nodepool/*, migrations/sql/*, internal/apiv2/*, internal/api/handlers/*, internal/nodeconfig/remote.go, internal/nodecontrol/*, web/src/api/*, web/src/pages/AdminNodes*, contracts/api/v2/openapi.json, docs/admin-api.md
Adds local and core source-access settings, persists them for transcode nodes, exposes them through admin APIs and the UI, and sends the selected mode to nodes. Changes apply when a source is opened.
Granted source-byte endpoint
internal/nodecontrol/*, internal/api/router.go, contracts/api/v2/*, docs/architecture/worker-http-protocol.md, docs/transcode-node-api.md
Adds authenticated GET and HEAD source routes. The endpoint validates grants and file revisions, serves ranged bytes, limits concurrent streams per node, and stops active streams during shutdown. Grants have a 24-hour maximum age.
Node relay and reader
internal/nodesource/*, internal/fspath/*, internal/mediacontainer/*, cmd/silo/transcode_node.go
Adds a loopback HTTP relay and random-access readers for core-backed sources. The relay fetches and validates source ranges, shares live revision entries, restricts FFmpeg and ffprobe access, and redacts relay URLs in logs.
Media-processing integration
internal/embeddedsub/*, internal/mediasample/*, internal/playback/*, internal/scanner/*, internal/tonemap/*, internal/transcodenode/*, internal/matroska/*, docs/architecture/*, docs/update-to-1.0.md
Updates media readers and sampling to support relayed inputs. Relayed text-subtitle burn-in that cannot be staged returns HTTP 409. Tests cover sampling, playback, relay recovery, and related behavior.

Estimated code review effort: 5 (Critical) | ~120 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant FFmpeg
  participant LoopbackRelay
  participant NodeClient
  participant APIServer
  participant SourceFile
  FFmpeg->>LoopbackRelay: Request media through relay URL
  LoopbackRelay->>NodeClient: Request source byte range
  NodeClient->>APIServer: Send signed GET with grant and If-Match
  APIServer->>SourceFile: Validate grant and open checked descriptor
  SourceFile-->>APIServer: Return source bytes
  APIServer-->>NodeClient: Stream ranged response
  NodeClient-->>LoopbackRelay: Return validated bytes
  LoopbackRelay-->>FFmpeg: Stream media bytes
Loading

Suggested reviewers: rhainland, blurbery, rangodj

Merge Risk: Minimal · up to 5d2e7

Transcode nodes can now read media through the API servers instead of a shared library mount; the default local mode is unchanged. The earlier concern that a dropped relay connection could look like the end of a file, and leave a subtitle index incomplete, is addressed in the current reader. No outstanding defects remain, so the change looks ready to merge. Operators should still plan for the extra API-server bandwidth that core mode uses.

Security architecture risk: Minimal · up to 5d2e7

The remote-read design uses node credentials and file-specific grants, checks source revisions, and bounds concurrent reads. The inspected changes did not establish an introduced security or failure-containment defect.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • observed — A compromised node key together with a grant issued to that node can read the named file revision through the API servers. The key alone cannot supply a valid grant for an arbitrary path. Each grant lasts one hour after issuance or renewal, with renewal capped at 24 hours from original issuance; a read accepted before expiry may continue afterward. Catalog withdrawal blocks renewal, not every outstanding byte request.

Trust Boundaries and Controls

  • observed — Disabled-node authentication and renewal of existing grants predate this PR. Disabling is documented as stopping new placement while existing streams continue, rather than revoking the node credential. The inspected change therefore does not establish a new disablement bypass.
  • observed — Relay URLs are host-local bearer capabilities, including when visible in process arguments; the documented deployment assumes no untrusted local users or processes. Request signatures do not provide confidentiality or authenticate responses. The documented network boundary requires trusted links or HTTPS for node-to-API traffic.

Resilience and Maintainability Implications

  • observed — Source-stream admission and release are mutex-protected, and release is deferred across handler exits. Application shutdown rejects new reads and aborts active responses. The relay resumes interrupted reads from the current offset, checks response identity and bounds, and limits retries without progress; lasting authorization or revision refusals end the shared source.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat(nodes): let transcode nodes read sources through the API servers" matches the main change: a new per-node source_access setting that lets transcode nodes read source bytes over HTTP fr…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description matches the changeset. It explains the new per-node Source access setting (local or core) for transcode nodes, the signed source-bytes route, the loopback relay for FFmpeg and ffprobe,…
Full details: Title check

Explanation

The title "feat(nodes): let transcode nodes read sources through the API servers" matches the main change: a new per-node source_access setting that lets transcode nodes read source bytes over HTTP from the API servers instead of mounting the library. The title is specific and concise, and the changeset supports it.

Full details: Description check

Explanation

The description matches the changeset. It explains the new per-node Source access setting (local or core) for transcode nodes, the signed source-bytes route, the loopback relay for FFmpeg and ffprobe, the FFmpeg guard, subtitle burn-in refusals, grant versioning with a 24-hour cap, and log redaction. The raw summary confirms these same areas across the API, node, nodesource, fspath, playback, web, and migration files. The description also covers validation, risks, and the database migration, which are reflected in the changed files.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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: 2ccbfb30-9d6b-4e4d-9b76-e381bd66126a
Commits

Reviewing files that changed from the base of the PR and between 5a7bcd1 and 5d2e78b.

Files selected for processing: 6

  • contracts/api/v2/openapi.json
  • internal/api/router.go
  • internal/nodesource/reader.go
  • internal/nodesource/relay_test.go
  • scripts/ci/db-contracts.txt
  • web/src/api/types.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@silo-triage silo-triage Bot added the size/XXXL 3000+ added + deleted lines (all files); change volume, not priority. label Nov 15, 2026
@silo-triage silo-triage Bot added enhancement New feature or request priority: P2 Limited scope, workaround exists, or polish stacked Base is another open PR; merge in stack order named in the body labels Nov 15, 2026
@Quick104
Quick104 marked this pull request as ready for review November 15, 2026 16:23
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T22:54:46.371460Z 5d08067 New commits
🔒 Security Review ✅ Completed 2026-11-15T22:57:52.138122Z 5d08067 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bacb254c35

ℹ️ 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".

Comment thread internal/nodesource/relay_test.go Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

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: 2b03fe80-3e96-4c87-86ae-427f0a0cf311
Commits

Reviewing files that changed from the base of the PR and between d6d5687 and bacb254.

Files selected for processing: 80

  • cmd/silo/transcode_node.go
  • contracts/api/v2/openapi.json
  • contracts/api/v2/route-inventory.json
  • docs/admin-api.md
  • docs/architecture/media-sampling.md
  • docs/architecture/transcode-nodes.md
  • docs/architecture/worker-http-protocol.md
  • docs/transcode-node-api.md
  • docs/update-to-1.0.md
  • internal/api/handlers/admin_node_configuration.go
  • internal/api/handlers/admin_node_configuration_test.go
  • internal/api/handlers/nodes.go
  • internal/api/router.go
  • internal/apiv2/admin_node_configuration.go
  • internal/apiv2/admin_node_drain.go
  • internal/apiv2/admin_nodes_read.go
  • internal/embeddedsub/file.go
  • internal/fspath/launch_guard_test.go
  • internal/fspath/os.go
  • internal/fspath/relayed.go
  • internal/mediacontainer/mediacontainer.go
  • internal/mediacontainer/mediacontainer_test.go
  • internal/mediasample/args.go
  • internal/mediasample/caps.go
  • internal/mediasample/caps_test.go
  • internal/mediasample/concat.go
  • internal/mediasample/keyframes.go
  • internal/mediasample/relayed_proxy_test.go
  • internal/mediasample/relayed_test.go
  • internal/mediasample/request.go
  • internal/nodeconfig/remote.go
  • internal/nodecontrol/client.go
  • internal/nodecontrol/fixture_test.go
  • internal/nodecontrol/protocol.go
  • internal/nodecontrol/protocol_registry.go
  • internal/nodecontrol/server.go
  • internal/nodecontrol/server_test.go
  • internal/nodecontrol/source_bytes.go
  • internal/nodecontrol/source_bytes_test.go
  • internal/nodecontrol/source_stream_test.go
  • internal/nodecontrol/sources.go
  • internal/nodepool/admin_configuration.go
  • internal/nodepool/repository.go
  • internal/nodepool/source_access_db_test.go
  • internal/nodesource/args.go
  • internal/nodesource/fetch.go
  • internal/nodesource/grant.go
  • internal/nodesource/grant_test.go
  • internal/nodesource/nodesourcetest/core.go
  • internal/nodesource/protocol.go
  • internal/nodesource/reader.go
  • internal/nodesource/redact.go
  • internal/nodesource/registry.go
  • internal/nodesource/relay.go
  • internal/nodesource/relay_test.go
  • internal/nodesource/source.go
  • internal/playback/ffmpeg_log_sink.go
  • internal/playback/keyframes/cache.go
  • internal/playback/keyframes/hevc.go
  • internal/playback/relayed_source_test.go
  • internal/playback/remux.go
  • internal/playback/subtitle_rendition_tracks.go
  • internal/playback/subtitle_rendition_tracks_test.go
  • internal/playback/transcode.go
  • internal/scanner/audio_extensions.go
  • internal/scanner/video_extensions.go
  • internal/tonemap/revision.go
  • internal/transcodenode/media_sample.go
  • internal/transcodenode/server.go
  • internal/transcodenode/source_input.go
  • internal/transcodenode/start_protocol.go
  • internal/transcodenode/thin_node_core_linux_test.go
  • internal/transcodenode/thin_node_test.go
  • internal/transcodenode/trickplay.go
  • migrations/sql/20261115070854_add_stream_node_source_access.sql
  • scripts/ci/db-contracts.txt
  • web/src/api/types.ts
  • web/src/api/v2/schema.ts
  • web/src/pages/AdminNodes.test.tsx
  • web/src/pages/AdminNodes.tsx
Files not reviewed due to moderation or processing errors: 16

  • contracts/api/v2/route-inventory.json
  • internal/api/router.go
  • internal/nodecontrol/client.go
  • internal/nodecontrol/protocol_registry.go
  • internal/nodecontrol/source_bytes.go
  • internal/nodecontrol/source_bytes_test.go
  • internal/nodecontrol/source_stream_test.go
  • internal/nodecontrol/sources.go
  • internal/fspath/os.go
  • internal/fspath/relayed.go
  • internal/mediacontainer/mediacontainer.go
  • internal/mediacontainer/mediacontainer_test.go
  • internal/nodesource/args.go
  • internal/nodesource/fetch.go
  • internal/nodesource/nodesourcetest/core.go
  • internal/nodesource/protocol.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

Comment thread docs/admin-api.md Resolved
Comment thread docs/admin-api.md Resolved
Comment thread internal/mediasample/caps.go Resolved
Comment thread internal/nodesource/grant.go Resolved
Comment thread internal/nodesource/source.go Resolved
Base automatically changed from feat/self-hosted-remote-transcode-nodes to main November 15, 2026 22:37
@silo-kody

silo-kody Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

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 settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5d2e78b8a7

ℹ️ 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".

Comment thread internal/playback/keyframes/cache.go Resolved
Comment thread internal/nodecontrol/source_bytes.go Resolved
Comment thread internal/nodesource/grant.go Resolved
Comment thread internal/nodesource/relay.go Resolved
Comment thread internal/nodesource/source.go Resolved
Comment thread internal/playback/keyframes/cache.go Resolved
Comment on lines +371 to +374
fileURL, err := fspath.FFConcatFileURL(filePath)
if err != nil {
return nil
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kody code-review Bug medium

Relayed HEVC remuxes lose the IDR primer needed by Firefox

Seeks starting on a CRA can produce blank video in macOS Firefox because the fspath.FFConcatFileURL error path skips the IDR primer for relayed inputs. Preserve a safely restricted primer path or fall back to a compatible transcode when needed.

Prompt for LLM
File internal/playback/remux.go, lines 371-374:

Relayed HEVC remuxes lose the IDR primer needed by Firefox

Relayed HEVC remuxes now always skip the IDR primer, so seeks starting on a CRA can produce a stream that macOS Firefox displays as blank, even though the same source works with local access. Preserve a safely restricted primer path for relayed inputs or fall back to a compatible transcode when the primer is needed.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Known limit, listed under Risks in the description and in the design record. A relayed input is refused in a concat list because the list would name it outside the protocol and format restrictions every relayed FFmpeg input gets. A node with a library mount, or the API server, still applies the primer.

🤖 Claude Code (claude-fable-5-2)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying. The missing primer is a documented limitation of relayed inputs, and the restriction is intentional. Mounted nodes and the API server retain the existing behavior.

The user-facing risk remains: an affected macOS Firefox seek may display blank video when handled by a node using API-server source access. Since that tradeoff is already documented, I’d withdraw the suggestion as a new finding rather than present it as an overlooked regression.

- The keyframe index loader takes the start's context, so a cancelled
  start no longer waits on a stalled relayed read.
- A grant minted before the issue time existed still verifies and renews.
  The first transcode node change shipped that version, and a job holding
  one would have lost its source at the next renewal after an update.
- A refusal of a grant that another job has since replaced no longer ends
  every job on the source; the newer grant is tried.
- A relay response whose write fails while the request lives is aborted,
  not finished as if it were whole.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@silo-kody

silo-kody Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

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 settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104
Quick104 merged commit 3e256e3 into main Nov 15, 2026
45 checks passed
@Quick104
Quick104 deleted the feat/thin-nodes-core-source-access branch November 15, 2026 22:54
// source's start can't be probed.
func planFromKeyframeIndex(ctx context.Context, opts TranscodeOpts) (*copySegmentPlan, error) {
idx, err := loadKeyframeIndex(opts.InputPath)
idx, err := loadKeyframeIndex(ctx, opts.InputPath)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kody code-review Bug high

Canceled index reads can persist an incompatible reconstructed playlist

A canceled index read is treated as a fallback, so resolveCopyPlan can record an unplanned playlist for a reconstructed session that previously served a planned one. Propagate context cancellation instead of treating it as a missing index.

Prompt for LLM
File internal/playback/copy_keyframe_plan.go, line 85:

Canceled index reads can persist an incompatible reconstructed playlist

When the startup context is canceled during the newly cancellable index read, this error is converted into a successful fallback, so `resolveCopyPlan` can record an unplanned playlist for a reconstructed session that previously served a planned playlist. Propagate context cancellation instead of treating it as a missing index so reconstructed sessions do not persist an incompatible playlist decision.

Suggested code:

idx, err := loadKeyframeIndex(ctx, opts.InputPath)
if err != nil {
	if ctx.Err() != nil {
		return nil, ctx.Err()
	}
	if !errors.Is(err, keyframes.ErrNoIndex) {
		log.Printf("playback: read keyframe index for %s: %v; using FFmpeg's playlist", opts.SessionID, err)
	}
	return nil, nil
}

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request priority: P2 Limited scope, workaround exists, or polish size/XXXL 3000+ added + deleted lines (all files); change volume, not priority. stacked Base is another open PR; merge in stack order named in the body

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant