Skip to content

Complete stable playback and proxy safeguards - #184

Merged
cbulock merged 1 commit into
mainfrom
codex/remaining-hardening
Sep 6, 2026
Merged

Complete stable playback and proxy safeguards#184
cbulock merged 1 commit into
mainfrom
codex/remaining-hardening

Conversation

@cbulock

@cbulock cbulock commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • propagate stable source-channel IDs through source sync, playback, MCP, and admin preview while retaining legacy URLs
  • add forged and trusted reverse-proxy request coverage for the explicit trust policy
  • harden transcoding worker shutdown, bounded configuration, direct executable fixtures, and startup failure handling

Fixes #167
Fixes #170
Fixes #177

Validation

  • targeted ESLint passes
  • focused integration coverage passes for source identity, MCP, output profiles, and proxy trust
  • the transcode fixture suite is blocked locally by sandbox child-process spawn EPERM; it uses direct executables and no cmd.exe
  • git diff --check passes

Copilot AI lite review requested due to automatic review settings September 6, 2026 19:35

Copilot AI 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.

🟡 Changes recommended

The transcode integration fixture currently sets FFMPEG_PATH to the Node executable (which cannot accept ffmpeg flags), and the SIGKILL escalation guard in stopWorker prevents forced termination from ever triggering.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR aims to make playback resilient to channel renames by propagating a stable sourceChannelId through source sync, output/playback surfaces (including MCP and admin preview), and it strengthens reverse-proxy trust handling plus transcoding worker safeguards.

Changes:

  • Propagate persistent sourceChannelId from source_channels into in-memory snapshots and consumers (MCP, output profiles, admin preview).
  • Add integration coverage for stable source-channel playback and explicit reverse-proxy trust behavior.
  • Harden transcoding process lifecycle (timeouts, backpressure handling, shutdown escalation) and update test fixtures.
File summaries
File Description
test/integration/transcode.test.js Updates transcoding integration fixtures to avoid shell wrappers and exercise error/success cases.
test/integration/parseM3U-sqlite.test.js Asserts channel snapshots persist the durable sourceChannelId.
test/integration/output-profile-routes.test.js Adds an end-to-end assertion that stable /stream/channel/:id URLs remain playable after renames.
test/integration/mcp.test.js Extends MCP list_channels payload expectations to include sourceChannelId.
test/integration/improvements.test.js Adds reverse-proxy trust tests to ensure forged forwarded headers are ignored unless explicitly trusted.
server/transcode.js Adds bounded config parsing, stronger spawn failure handling, backpressure support, and worker shutdown escalation.
server/mcp.js Exposes sourceChannelId in list_channels output for stable agent playback URLs.
scripts/parseM3U.js Copies persisted sourceChannelId from source sync into the mapped channel snapshot.
libs/source-sync-service.js Returns a lookup of persisted source-channel IDs and stamps sourceChannelId onto discovered channels.
admin/src/App.vue Switches preview routes to prefer /.../channel/:sourceChannelId when available, falling back to legacy routes.
Review details
  • Files reviewed: 10/10 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +38 to +42
function setFfmpegStub(stub, originalNodeOptions) {
process.env.FFMPEG_PATH = process.execPath;
process.env.FFMPEG_STUB_CONFIG = JSON.stringify(stub.options);
process.env.NODE_OPTIONS = `${originalNodeOptions || ''} --require ${JSON.stringify(stub.preloadPath)}`.trim();
}
Comment thread server/transcode.js
Comment on lines +145 to +149
// SIGTERM is advisory on Windows. Escalate so a stalled upstream cannot
// retain an expensive encoder worker indefinitely.
forceKillTimer = setTimeout(() => {
if (ffmpegProcess.exitCode === null && !ffmpegProcess.killed) ffmpegProcess.kill('SIGKILL');
}, KILL_GRACE_MS);
@cbulock
cbulock merged commit ee3416d into main Sep 6, 2026
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants