Skip to content

feat(nodes): run transcode nodes without database, Redis or shared secrets - #2525

Closed
Quick104 wants to merge 2 commits into
mainfrom
feat/thin-transcode-nodes
Closed

Quick104 wants to merge 2 commits into
mainfrom
feat/thin-transcode-nodes

Conversation

@Quick104

@Quick104 Quick104 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: #1176
Validation tasks: none (no passed case is affected; #1177 C1–C3 and #1178 C1–C3 have not run, and their node registration steps now include issuing a key)

A remote transcode node today is the full silo binary with the main server's Postgres connection, Redis, SECRET_KEY and the shared auth.jwt_secret, which also signs login and stream tokens. It must also mount the media library at the exact paths the catalog uses. Anyone who controls a GPU box therefore holds credentials to the whole deployment, and a node without shared storage cannot work at all.

This change makes the one existing transcode node type thin. A node starts with two settings, SILO_CORE_URL and SILO_NODE_KEY, and holds no database, Redis or shared secret. It reads source media either through its own mount (the default, as today) or over HTTP from the core, chosen per node. Client routes, responses and playback behavior are unchanged.

Approach

  • Node keys. Each transcode node has its own key, issued once from the admin page and stored encrypted on its stream_nodes row. Requests to a transcode node are signed with that node's key; the shared secret is now used only for proxies. Signing names the kind of node it targets, so a transcode node never receives a shared-secret signature. The node signs its own calls to the core with the same key under a separate label, so a request captured in one direction never verifies in the other.
  • Core-served control plane. The node pulls its configuration from the core, sends a fenced session and telemetry report every second, ships its logs (FFmpeg output included) to the core's operational log, and tells the core when its drain state changes. These run on node-signed routes under /api/internal/nodes/, outside user auth and request logging.
  • The core decides playback authority. A node no longer verifies stream tokens or reads stop markers. When it needs a recipe (to rebuild a lost HLS session or serve a progressive remux), it asks the core's resolve route, which runs the checks the node used to run, binds the recipe to the asking node and returns the playback identity. Relays check stop markers before signing; the Jellyfin-compatible relays gained that check. Recipe deletion happens where the core stops a session.
  • Source access. Every job carries a short-lived grant the core signs for one file revision and one node. In local mode the node exchanges it for the approved catalog path. In core mode it reads the bytes from the core through a loopback relay that FFmpeg and Go readers use, with resume after interruptions. FFmpeg inputs from the relay get protocol and format whitelists. Tone-map validation, the Matroska keyframe index, the DV probe, concat sampling and keyframe plan records work on relayed sources. Text-subtitle burn-in on a core-mode node is refused so the work moves to a local-mode node or the server; staging subtitles for it is the stacked follow-up PR.
  • Moving a transcode off a dead node (added on main while this was in progress) now sends the replacement node a fresh grant and the playback identity, writes the recipe bound to the new node so it can rebuild the session after a restart, rechecks stop markers before it serves from the new executor, and ends the move when the file has left the catalog.
  • Admin. v2 node rows add source_access (transcode nodes only) and key_issued, and POST /api/v2/admin/nodes/{id}/key issues or rotates a key, with capability flags for both. The web nodes page shows key status, issues and rotates keys (the key is shown once), and sets source access.

The design is documented in docs/architecture/transcode-nodes.md; docs/update-to-1.0.md has the operator steps. This replaces the approach in #2408, which added a second, standalone worker type next to the existing node.

Surfaces: server and web admin. No Apple, Android or Jellyfin client change. The user manual needs an update: Silo-Server/siloserver.org#213.

Validation

  • Go: build, gofmt, make lint-changed (0 issues), and race tests for every touched package, run against Postgres 18 and Redis. Known failures that also fail on main: TestAdminSubtitleListPageDB, TestCatalogTransferPersistsJobsAndSignedLink, TestManagedCreateAbsenceRacePostgres.
  • Real FFmpeg (6.1 locally, jellyfin-ffmpeg 7 in the sandbox): core-mode output matches local-mode output by frame hashes for decode, seek, remux, download prepare, chapter frames, sampling and HLS copy.
  • Contracts: route inventory, migration ledger, offline routes, OpenAPI, contract diff (additive only), fixtures, web types and local-path checks pass.
  • Web: node page tests, typecheck, lint and prettier pass.
  • End to end in an isolated sandbox with one API, one proxy, a library-mounted node and a node with no mount and no route to Postgres or Redis: playback, seek, pause, HDR and DV, remux, downloads, trickplay, chapter thumbnails, subtitle sync, Jellyfin-compatible playback, API and node restarts, drain, force reload, disable and key rotation. After rebasing on current main, the same sandbox ran a smoke pass plus dead-node moves in both directions (including onto the node without a mount), a rebuild on the new node after a move, a stop during a move, the text burn-in refusal, and key rotation. Defects these runs found are fixed and were re-run.
  • Independent review: each implementation stage was reviewed by two models before commit, then the whole branch twice and the rebase onto main once; findings were fixed with regression tests.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/pr-2525/

Risks

  • Coordinated upgrade. Transcode nodes from before this change cannot work with an updated core, or the reverse. Operators stop transcode nodes, update the core and proxies, issue each node a key, then start nodes with the new settings (docs/update-to-1.0.md). Proxies keep their current settings.
  • Migration. Adds stream_nodes.node_key_ciphertext and stream_nodes.source_access and includes source_access in the configuration revision trigger.
  • Requirements for core source access. The API servers and local-mode nodes must see each file with the same size and modification time to the second. Nodes need a network path to the API, and a reverse proxy in front of it must pass /api/internal/nodes/* without buffering. In core mode every byte a node reads passes through the API.
  • Security. A stolen node key lets the holder take work for that node and read files granted to that node until the grant expires (at most one hour); it cannot sign for other nodes or read files no grant names. Loopback relay URLs are short-lived capabilities on the node host, which is assumed to run no untrusted local users.
  • Behavior changes on shared paths. A rebuilt copy session whose keyframe index cannot be read now fails retryably instead of serving a different playlist. A node's 401 reaches clients as 502 (v1) or 503 dependency_unavailable (v2). When a recipe exists in the core's store, a node rebuild uses it in preference to the stream token, and a store read error answers 503.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code (T3 Code)
  • Tool(s): Claude Code subagents; OpenAI Codex via T3 delegated tasks; GitHub CLI; Playwright
  • Model(s): claude-opus-5-5 (orchestration, implementation, review); gpt-6.1-sol (review)
  • Involvement: Fully AI-generated; human verification pending
  • Adversarial review: Each of six implementation stages was reviewed by claude-opus-5-5 and gpt-6.1-sol, which checked security, multi-replica behavior, failure handling and contracts against the source and reproduced findings with tests. They found cross-node signing gaps, session-key collisions, a missing Jellyfin stop-marker check, a grant issued without a catalog check, relay stall handling and subtitle-staging timing; each was fixed with a regression test. A sandbox end-to-end run then found a capability-read signing regression and two error-mapping gaps, and two final whole-branch reviews found a rotated-key placement problem; all are fixed. A review of the rebase onto main found that main's new dead-node move left moved sessions unrebuildable, skipped a stop-marker recheck and could rebuild a deleted file locally; all three are fixed and covered by tests and a sandbox re-run.

🤖 Generated with Claude Code

Note

Run transcode nodes without database, Redis, or shared secrets via per-node keys and source grants

  • Adds a standalone transcode-node bootstrap (transcode_node.go) started from SILO_CORE_URL and SILO_NODE_KEY; nodes pull their configuration, report sessions, and ship logs to the core over the new node-control endpoints (server.go).
  • Replaces the shared JWT secret with per-node signing keys: nodeauth.SignTranscode/SignToCore/VerifyFromNode use separate MAC domains, keys are encrypted at rest in the new node_key_ciphertext column, and a KeyRegistry serves credentials for signing and core-side verification.
  • Replaces local input-path authorization with core-issued source grants: nodes open media through the core source relay (relay.go) with restricted FFmpeg arguments, page-cached ranged readers, and loopback-URL redaction in logs.
  • Lost-session reconstruction, remux routing, and stop/recipe authority move from node-local stores to core resolution; admin endpoints add key issuance, drain pushes, and source-access configuration with UI support in AdminNodes.
  • Behavioral Change: node routes now require a node-key signature (legacy shared-secret bearers get 401); keyless transcode nodes are excluded from placement; text subtitle burn-in from relayed sources is refused (HTTP 422); stop paths delete core-side node recipes before the node DELETE; v1 create/update paths discard SourceAccess.

Macroscope summarized 97501ff. (Automatic summaries will resume when PR exits draft mode or review begins).

…crets

A transcode node now needs only the core's URL and its own key. It holds no
database or Redis connection and no cluster-wide secret.

- Per-node keys: the core issues each transcode node its own key (rotated
  from web admin or POST /api/v2/admin/nodes/{id}/key), and signs every call
  with the key of the node it targets. Proxies keep the shared secret. A node
  whose key the core rejects reports that through health and takes no work.
- Core-served node state: nodes fetch their configuration from the core and
  send it their reports, stream telemetry and operational logs, instead of
  reading and writing the database and Redis.
- Resolve and relay deny: a restarted node rebuilds a session from the
  recipe the core's resolve endpoint returns, and the core refuses relays and
  resolves for stopped or denied transports.
- Source grants: every job the core sends a node carries a short-lived grant
  for its source file. With local source access the node opens its own mount
  and checks the approved revision; with core source access it reads the file
  through the core over a loopback relay held to the admitted protocols and
  demuxers.
- Relayed media consumers: transcodes, downloads, trickplay, chapter
  thumbnails, media sampling, subtitle sync and theme audio all run on
  relayed sources. Text-subtitle burn-in from a relayed source is refused,
  so that work goes to a node with the library or to the API server. A
  transcode moved off an unreachable node gets a fresh grant and a recipe
  bound to its new node, and the move rechecks stop markers.
- Web admin shows each node's source access and key state and issues keys.
- Docs describe thin nodes, the node control protocol and source access.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@silo-kody

silo-kody Bot commented Oct 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 ❌

@silo-triage silo-triage Bot added enhancement New feature or request go Pull requests that update go code impact: security Auth, privacy, or permission boundary javascript Pull requests that update javascript code priority: P2 Limited scope, workaround exists, or polish triaged High-confidence review completed; does not mean fixed, validated, or accepted for release. labels Oct 15, 2026
@zenjabba

Copy link
Copy Markdown
Contributor

We checked this against what we need from transcode nodes. We run dedicated, mountless GPU nodes for customers who administer their own Silo cluster, sometimes across a public network. The thin-node model covers most of it: no Postgres, Redis or shared secret on the node, source_access: core for nodes without a mount, and stateless control routes across API replicas.

Five things are still missing for our use. Each item below says what is missing and gives a concrete way to close it. Paths refer to this branch at 97501ff.

1. Operator-owned encoding ceiling (blocking for us)

Need. The node's operator sets a hard limit on concurrent encoding work. The limit covers playback, prepared downloads, trickplay, chapter thumbnails, media samples and subtitle sync together. The customer's admin can lower it with max_jobs but cannot raise it.

What this branch has. The node environment is SILO_CORE_URL, SILO_NODE_KEY, PORT and SILO_NODE_DRAIN_TIMEOUT. NodeConfig carries no cap. max_jobs stays an admin-editable column that only placement reads. The node has no ceiling on encoding work: gpuGate only keeps re-probes and work apart, and sync_node_capacity limits only subtitle-sync sampling. Whoever holds the admin login decides the node's capacity.

How to meet it. Port the ceiling half of #2371. That code already exists and is tested:

  1. Read SILO_TRANSCODE_MAX_JOBS in loadTranscodeNodeEnv (cmd/silo/transcode_node.go). In feat(nodes): enforce provider capacity and enroll customer configuration #2371 it is read in internal/config/bootstrap.go, which MODE=transcode now skips. Unset or 0 means unlimited. Keep it out of NodeConfig so the core can never raise it.
  2. Call encodinglimit.Configure(n) at node startup. Start every node FFmpeg process through encodinglimit.StartWith / Run / CombinedOutput (internal/encodinglimit/limit.go). Each slot is held until the process is reaped. At capacity, the node answers 503 with Retry-After: 1 (writeEncodingCapacityError), and the dispatchers treat that like any failed start and try the next candidate.
  3. Add encoding_capacity {max_jobs, active_jobs, available_jobs} to the node's /api/v1/health. It lands in LastStats through marshalLastStats as it is. On the core, clampEncodingCap (internal/nodepool/encoding_capacity.go) lowers a higher or unlimited max_jobs to the reported ceiling and keeps a lower one. feat(nodes): enforce provider capacity and enroll customer configuration #2371's AdminNodes presentation shows the reported ceiling next to the editable value.
  4. Two lessons from feat(nodes): enforce provider capacity and enroll customer configuration #2371 to keep:
    • Check current-session affinity before the cap. A session already on a node at its ceiling, or on a draining node, stays there (transcodeEligible must check currentURL before underCap).
    • A copy-recovery or seek restart must release the old process's slot before it starts the new one, and must restore the previous recipe if the replacement can't start (fixed in feat(nodes): enforce provider capacity and enroll customer configuration #2371 at da2360a0a).
  5. Tests to carry over: internal/encodinglimit/limit_test.go, internal/nodepool/encoding_capacity_test.go, internal/transcodenode/encoding_capacity_test.go and internal/transcodenode/recovery_rollback_test.go.

Acceptance criteria.

  • With SILO_TRANSCODE_MAX_JOBS=2, an admin max_jobs of unlimited or 5 gives 2, and an admin value of 1 gives 1.
  • A third concurrent job of any kind gets 503 from the node, and placement moves it elsewhere.
  • A seek inside a session that is already running at the ceiling still succeeds.

The enrollment half of #2371 existed so operators would not have to hand each node the customer's database, Redis and SECRET_KEY. Per-node keys remove that, so it isn't needed here. We'll provision nodes with POST /api/v2/admin/nodes/{id}/key.

2. Performance evidence for core source access

Need. A mountless node must match a library-mounted node on startup, seek, producer throughput and concurrent capacity.

What this branch has. It shows correctness (frame hashes match between core and local mode) but has no timing numbers. Two design points could cost speed on remote nodes:

  • The first copy-video start reads the file twice through the core. FFmpeg reads it once, and keyframes.LoadSource streams the whole file again in the background for the Matroska check (described under "Local and core access" in transcode-nodes.md). For a remote node, every first play of a copy session moves the file over the WAN twice. Fix: the core has the file locally, so it can verify the index there. Serve it on a node-signed route keyed by the grant ETag, for example GET /api/internal/nodes/sources/keyframes with X-Silo-Source-Grant. Keep the node's per-revision cache, and keep the current background check as the fallback when the route returns 503.
  • Nothing measures what the core serves. HandleSource has no per-replica limit (by design) and no metrics, and in core mode every source byte goes through the API. Fix: add metrics for active source streams and bytes served per node, so operators can size API bandwidth before they move nodes to core mode.

How to meet it. #2408 already documents a paired method and its results in transcode-source-transport-evidence.md, at an earlier commit of that PR. It compares local mount, HTTP and HTTPS on an Intel Flex 140, measuring startup and seek readiness, producer throughput against a local file, and burst concurrency. #2408 measured, against a local mount:

  • startup: +5.8 ms (HTTP) and +12.3 ms (HTTPS)
  • seek: +10.0 ms and +15.6 ms
  • producer throughput: 98.7% and 96.7% of the local file

We'd like core mode to land in the same range. We can run that harness against this branch and post the numbers here.

3. Text subtitle burn-in on core-mode nodes

Every node we run is core mode. Until #2526 lands, every text burn-in moves to the customer's API server CPU, or fails where the routing policy doesn't allow local execution. Please merge #2526 together with this PR, or straight after it in the same release.

4. TLS on the node listener

Need. Remote nodes over a public network, with plain HTTP still available on a trusted LAN.

What this branch has. The node listens on plain HTTP: startStandaloneServer builds an http.Server with no TLS. The core and proxies send signed commands and relay segments over that link in cleartext. The HMAC stops forgery, but output bytes can be read on the way, and a captured request can be replayed for 30 seconds. The doc says "Links that cross untrusted networks still need TLS" but gives no way to set it up.

How to meet it.

  1. Add optional SILO_NODE_TLS_CERT_FILE and SILO_NODE_TLS_KEY_FILE to loadTranscodeNodeEnv. When both are set, serve TLS, and load the certificate through tls.Config.GetCertificate, re-reading it when the file changes, so ACME renewals need no restart. The admin then registers the node URL as https://.
  2. On the core and proxies, verify node certificates against the system roots, plus an optional SILO_NODE_CA_FILE for private CAs.
  3. For node → core with a private CA, document SSL_CERT_FILE, which Go already honors.
  4. Add these to the environment table in transcode-nodes.md and to update-to-1.0.md.

If you'd rather not add TLS to the binary, the alternative is a documented TLS-terminating sidecar example (Caddy or nginx) in update-to-1.0.md. The built-in option is less for operators to get wrong.

5. Reverse-proxy example in the upgrade guide

update-to-1.0.md says /api/internal/nodes/* must not buffer and needs long timeouts. A copyable snippet would prevent most of the support questions. For nginx:

location /api/internal/nodes/ {
    proxy_pass http://silo_api;
    proxy_http_version 1.1;
    proxy_set_header Connection "";
    proxy_buffering off;
    proxy_request_buffering off;
    proxy_read_timeout 3600s;
    proxy_send_timeout 3600s;
    client_max_body_size 2m;   # reports and log batches go up to 1 MiB; nginx's default limit is 1m
}

Comment on lines +59 to +61
if err := h.revokeNodeRecipes(ctx, node); err != nil {
return nil, err
}

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

HLS reconstruction bypasses stored-recipe revocation in internal/api/handlers/admin_node_reload.go because nodecontrol.resolveHLS treats a revoked recipe as a store miss and accepts the card derived from an already-issued complete stream token, allowing the next manifest request to restart the transport immediately after force reload. Enforce the node's revocation generation or a transport tombstone before accepting the complete-token fallback.

Prompt for LLM

File internal/api/handlers/admin_node_reload.go:

Line 59 to 61:

HLS reconstruction bypasses stored-recipe revocation in internal/api/handlers/admin_node_reload.go because nodecontrol.resolveHLS treats a revoked recipe as a store miss and accepts the card derived from an already-issued complete stream token, allowing the next manifest request to restart the transport immediately after force reload. Enforce the node's revocation generation or a transport tombstone before accepting the complete-token fallback.

Talk to Kody by mentioning @kody

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

​

​

@zenjabba

Copy link
Copy Markdown
Contributor

We ran the benchmark from item 2 against this branch (97501ff) on an Intel Flex 140. On a LAN, core source access matches a local library mount: startup is within 2 ms, seek within 14 ms, and encoding throughput is 99% of local over HTTP and 95% over HTTPS. There is also a correction to item 2 of my earlier comment, below.

Setup

  • Build. The image is built from this branch's Dockerfile (image sha256:82135956…, silo binary sha256:b88be5ee…). All runs use the same binary.
  • Core. The API container, Postgres 18 and Redis 8.2 run on one host. nginx 1.27.5 sits in front of them, with the /api/internal/nodes/ block from item 5: buffering off, 3600 s timeouts, client_max_body_size 2m.
  • Node. The node runs on a separate host on the same LAN, set up as MODE=transcode with only SILO_CORE_URL and SILO_NODE_KEY. It runs in its own mount and PID namespaces, sees one Flex render node and the library directory, and is limited to 2 CPU cores. The FFmpeg stack is FFmpeg 8.1.3, oneVPL 2.17 and iHD 26.3.5, the same one used for feat(transcode): add standalone HTTP/HTTPS workers #2408's numbers.
  • Recipe. Silo's own QSV path: VAAPI decode → hwmap=derive_device=qsv → h264_qsv, 1080p → 720p.
  • Fixture. 300 s of 1080p30 H.264 High at 8 Mbps with AAC stereo in MKV, 303 MB. It is synthetic, with noise added so the encoder has real work.
  • Arms. One node process, with source_access switched by PUT /api/v2/admin/nodes/{id} before every action. Each action is preceded by a change into its mode and a 3 s settle, so both arms see the same reload.
  • Pairs. 30 pairs per cohort, with arm order randomized per pair.
  • Cohorts. The two cohorts differ only in SILO_CORE_URL: http:// or https://, both through nginx.
  • Measures.
    • Startup: POST /api/v1/playback/start → playlist → third complete segment.
    • Seek: replan to 150 s → third complete segment.
    • Throughput: least-squares fps over content seconds 20–220 of a full transcode, from segment file times on the node.
  • Checks on every measured action.
    • The three segments decode to 180 frames of 1280x720 H.264 plus AAC.
    • Local and core output is byte-identical in all 120 paired actions.
    • The node's FFmpeg read the catalog path (local) or the loopback relay (core), held only the Flex render node, and ran the recipe above.
    • None of the 159 core-mode FFmpeg processes opened the library file; all 159 local-mode ones did.

Results

Local mount Core source Paired median core − local (95% CI)
HTTP startup (n=30) 434.5 ms 435.3 ms +0.3 ms [−0.4, +1.2]
HTTP seek (n=30) 850.5 ms 853.5 ms +7.4 ms [−1.3, +14.0]
HTTPS startup (n=30) 434.1 ms 436.5 ms +1.8 ms [−0.1, +3.6]
HTTPS seek (n=30) 847.4 ms 859.3 ms +14.0 ms [+7.9, +17.3]
HTTP encode throughput (3 runs each) 728.9 fps 724.4 fps 99.4% of local
HTTPS encode throughput (3 runs each) 731.2 fps 695.4 fps 95.1% of local
HTTP 4-stream burst, slowest stream, median of 3 1464 ms 1460 ms —
HTTPS 4-stream burst, slowest stream, median of 3 1493 ms 1489 ms —

Over HTTPS, core-mode throughput was 695 fps in all three runs, so the 5% is consistent, not noise. #2408's raw-FFmpeg measurement showed the same pattern (96.7% over HTTPS, 98.7% over HTTP). The node has 2 cores shared by FFmpeg and the TLS relay; we did not isolate the cause.

Readiness moves in 100 ms steps in both modes. TranscodeSession.waitForManifest, WaitForSegment and WaitForOpenSegment (internal/playback/transcode.go) check the filesystem every 100 ms. So core mode's extra few milliseconds show up as how often an action lands one step later:

  • HTTPS startup: 5 of 30 core actions landed one step later; no local action did.
  • Seek: local reached the earlier step in 8/30 (HTTP) and 6/30 (HTTPS) actions; core did in 1/30 and 0/30.

This predates the PR and affects local nodes too. Waking those waits when the segment is written, instead of on a 100 ms timer, could take up to one step off each wait for every node.

Correction to item 2: the copy-video double read

I said the first copy-video start in core mode reads the file twice. That only happens with playback.copy_keyframe_playlist enabled, and it defaults to false. With it on, measured over HTTP:

Copy-video start Readiness Source bytes through the core
Core, first start of this file (cold) 641 ms 661 MB (2.18× the file, 416 requests)
Core, second start (index cached) 150 ms 303 MB (1.00×, 1 request)
Local, first start 161 ms none
Local, second start 152 ms none

So the fix suggested in item 2 (the core verifies the Matroska index and returns it on a grant-keyed route) still applies, but only to installs that turn the setting on. Without it, there is nothing to fix for copy-video.

What's left from item 2

  • Speed. Core source access meets the speed requirement for the default configuration on a LAN.
  • Source metrics. HandleSource still has no metrics. The HTTP cohort alone moved 3.3 GB of source through the core to one node in under 12 minutes, and nothing in Silo shows that traffic.
  • Not measured:
    • WAN latency or bandwidth limits.
    • A local node backed by NFS.
    • Several nodes reading through one API replica at once.
    • HEVC, HDR and 4K sources.
    • The node's CPU cost of TLS.

@silo-triage silo-triage Bot added the size/XXXL 3000+ added + deleted lines (all files); change volume, not priority. label Oct 15, 2026
@zenjabba

Copy link
Copy Markdown
Contributor

@Quick104 the 100 ms readiness steps in the benchmark above come from FFmpeg output polling in internal/playback/transcode.go, which this branch's nodes also run. #2541 checks every 10 ms instead (fixes #2540).

Same Flex 140 setup, this branch at 97501ff with and without that change, 30 startups and 30 seeks per source mode, medians in ms (local mount / through core):

Before After
POST /playback/start answers 417 / 417 334 / 338
Startup, first segment 427 / 426 343 / 347
Seek, third segment 847 / 850 727 / 763

The diff applies cleanly on top of 97501ff if you want it before it reaches main.

…des (#2526)

* feat(nodes): stage relayed text subtitles for burn-in on core-mode nodes

A node that reads its source through the core can now burn in a text
subtitle instead of refusing it. The libass subtitles filter opens its file
itself, outside FFmpeg's input restrictions, so it must not open the relay
URL. The node instead extracts the selected track to an ASS script, with
the source's attached fonts, into a node-level staging cache keyed by
source revision, track and codec. Every start, restart and rebuild on that
source and track reuses it.

- Staging runs detached from the request on a reopened source handle, with
  bounded admission (two at a time, a queue of eight), byte reservations
  against a 1 GiB cache, leases, idle cancellation and a timeout that grows
  with the file. A full queue or cache answers 503.
- A start whose staging is not complete returns a preparing session, and
  FFmpeg launches once staging completes. Segment and init requests wait
  meanwhile as for a slow FFmpeg start.
- A staging failure does not advance the hardware fallback, and a rebuild
  does not retry it in software.
- This also restores the session closing state and shutdown under each
  session's lifecycle lock, which the separate shutdown-race fix brings to
  main; the pending launch depends on it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(nodes): build burn-in subtitle bundles on the core

A core-mode node no longer demuxes the whole source through the relay to
burn in a text subtitle. The core builds a subtitle bundle (the track as
an ASS script extracted with -copyts, plus every font attachment) from
its own copy, caches it in the subtitle cache, and serves it at
GET /api/internal/nodes/sources/subtitle under the source grant. Each
session fetches the bundle into its own output directory and launches
FFmpeg once it is unpacked.

This replaces the node-level staging cache with its slots, queue,
leases, eviction, adoption and fsync. Closing a session cancels its
fetch, and a passing core failure answers 503 for starts and rebuilds.
A readiness-gated start waits for the bundle within its request before
FFmpeg's manifest wait. A same-ID replacement retires the live session
only once its bundle is staged. Restarts share the start's spawn and
publish path, and attachment dumping streams through one helper shared
with the client font bundle.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(nodes): bind subtitle bundles to the grant and fail staging before acceptance

The core now builds and serves a subtitle bundle only for the granted
source revision, and answers 412 when the file changed. A build that
fails for the core's own reasons (its disk, a process that cannot start)
answers 503, not 422, so nodes retry it. A bundle download cut short is
retried as a passing failure.

Jellyfin-compatible text burn-in starts now require readiness, as native
starts already do, so a staging failure fails the start, where the
fallback to another node or the API server runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Oct 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 ❌

Comment on lines +242 to +244
c.mu.Lock()
c.bundleFailures[fill.key] = subtitleBundleFailure{err: err, at: time.Now()}
c.mu.Unlock()

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 Security high

Unbounded negative-cache growth in internal/playback/subtitle_bundle.go occurs because bundleFailures deletes expired failed-build entries only when the identical key is requested again, allowing a registered node with a valid source grant to grow the core's heap by continually requesting different nonexistent track ordinals. Sweep expired entries independently of lookups and cap the negative cache.

Prompt for LLM

File internal/playback/subtitle_bundle.go:

Line 242 to 244:

Unbounded negative-cache growth in `internal/playback/subtitle_bundle.go` occurs because `bundleFailures` deletes expired failed-build entries only when the identical key is requested again, allowing a registered node with a valid source grant to grow the core's heap by continually requesting different nonexistent track ordinals. Sweep expired entries independently of lookups and cap the negative cache.

Talk to Kody by mentioning @kody

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

​

​

Comment on lines +290 to +292
if err != nil {
return sourceFault(fmt.Errorf("extract track: %w", err))
}

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

Error misclassification in internal/playback/subtitle_bundle.go routes core scratch-file output-write errors such as ENOSPC from boundedRun through sourceFault, producing a cached 422 and nonretryable ErrSubtitleStaging instead of a transient 503. Distinguish local output I/O errors from FFmpeg/source failures before wrapping ErrSubtitleBundleFailed.

Prompt for LLM

File internal/playback/subtitle_bundle.go:

Line 290 to 292:

Error misclassification in `internal/playback/subtitle_bundle.go` routes core scratch-file output-write errors such as ENOSPC from `boundedRun` through `sourceFault`, producing a cached 422 and nonretryable `ErrSubtitleStaging` instead of a transient 503. Distinguish local output I/O errors from FFmpeg/source failures before wrapping `ErrSubtitleBundleFailed`.

Talk to Kody by mentioning @kody

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

​

​

Comment on lines +250 to +253
if err := fill.Commit(); err != nil {
slog.Warn("subtitle bundle commit failed", "component", "playback",
"input", src.Path, "track", src.Track, "error", err)
return

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 Performance medium

Negative-cache bypass in internal/playback/subtitle_bundle.go lets OpenSubtitleBundle immediately start another whole-source build after Commit fails, discards the fill, and releases its key. Record commit failures before allowing another build for that key so persistent cache write, sync, or publish failures receive the documented one-minute backoff instead of triggering repeated demuxes that consume shared warm slots.

Prompt for LLM

File internal/playback/subtitle_bundle.go:

Line 250 to 253:

Negative-cache bypass in `internal/playback/subtitle_bundle.go` lets `OpenSubtitleBundle` immediately start another whole-source build after `Commit` fails, discards the fill, and releases its key. Record commit failures before allowing another build for that key so persistent cache write, sync, or publish failures receive the documented one-minute backoff instead of triggering repeated demuxes that consume shared warm slots.

Talk to Kody by mentioning @kody

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

​

​

@@ -2803,6 +3015,16 @@ func (s *TranscodeSession) SegmentRecoveryDecision(segNum int, now time.Time) Se
decision.WaitTimeout = activeSegmentWait
decision.RestartOnTimeout = false
decision.Reason = segmentReasonRestarting
case progress.Preparing:

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 Kody Rules high

Recovery-path suppression in internal/playback/transcode.go occurs after a seek restart when subtitle staging is pending and a missing requested segment falls below StartSegmentNumber: the unconditional progress.Preparing case overrides the segNum < progress.StartSegmentNumber recovery case, selecting a 12-second wait with RestartOnTimeout disabled even though the pending generation cannot produce that segment. Restrict the preparing wait to segNum >= progress.StartSegmentNumber so earlier requests follow the restart path instead of timing out with a 404.

Kody rule violation: Use source anchors and produced-head state in planned segment recovery

Prompt for LLM

File internal/playback/transcode.go:

Line 3018:

Recovery-path suppression in `internal/playback/transcode.go` occurs after a seek restart when subtitle staging is pending and a missing requested segment falls below `StartSegmentNumber`: the unconditional `progress.Preparing` case overrides the `segNum < progress.StartSegmentNumber` recovery case, selecting a 12-second wait with `RestartOnTimeout` disabled even though the pending generation cannot produce that segment. Restrict the preparing wait to `segNum >= progress.StartSegmentNumber` so earlier requests follow the restart path instead of timing out with a 404.

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 go Pull requests that update go code impact: security Auth, privacy, or permission boundary javascript Pull requests that update javascript code priority: P2 Limited scope, workaround exists, or polish size/XXXL 3000+ added + deleted lines (all files); change volume, not priority. triaged High-confidence review completed; does not mean fixed, validated, or accepted for release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants