🌐 US-Proxy
id="body-softwares" class="foundation-grid action-show controller-softwares engine-home">

Inspiration

Every video streaming engineer knows the NDA Reproduction Deadlock.

When an enterprise town hall, pre-release film screener, or medical broadcast stalls mid-stream in hls.js, the customer's security team strictly forbids uploading raw .m4s segments, internal CDN URLs, or proprietary metadata boxes (udta / meta) to a public GitHub issue. Meanwhile, open-source player maintainers cannot debug a screenshot of a spinner—without a stream that reproduces the exact Media Source Extensions (MSE) state transition, issues get closed as "Cannot Reproduce."

Existing "sanitizers" fail this problem in two ways: re-encoding with ffmpeg destroys the exact tfdt / trun / EXTINF timestamp discrepancy that caused the stall, while zeroing out mdat bytes produces invalid H.264/AAC payloads that crash hardware decoders before the timeline bug ever triggers.

For Kiroween's Frankenstein category, we asked: What if we could sever the broken timeline nervous system from a quarantined confidential stream and stitch it onto a clean, decodable public body—entirely inside the browser with zero outbound network requests?


What it does

Ghost Stream is a browser-local Obsidian Forensic Workbench plus a Recipient-Only Kiro MCP Server that turns unshareable HLS/fMP4 playback failures into deterministic, verifiable public reproductions:

  1. Quarantine Chamber (Zero Egress): Drop a local HLS/fMP4 folder or run the built-in CONFIDENTIAL Q4 BOARD sample (90 kHz crimson broadcast). Every playlist, init.mp4, and .m4s segment stays in an in-memory Virtual_FS with a custom hls.js loader (0 cross-origin requests).
  2. Frankenstein Timeline Graft (@ghost-stream/core): Parses ISO-BMFF boxes (mvhd, mdhd, trex, tfhd, 64-bit BigInt tfdt, trun, mdat) and HLS playlists, strips 100% of customer mdat bytes, udta/meta boxes, filenames, and URLs, and extracts a versioned Public Timeline Recipe. Using exact rational common-origin + baseShift arithmetic, it grafts that timing skeleton onto deterministic public synthetic Donor Streams (donor-video-2s at 1 kHz or dual-track donor-av-beat with 90 kHz H.264 flash + 48 kHz AAC click track) without re-encoding a single media byte.
  3. Five Live Browser MSE Fault Experiments (F1–F5) & Dual hls.js Runtimes (1.7.4 vs 1.6.13):
    • F1 (tfdt Clock Jump without #EXT-X-DISCONTINUITY): Reproduces an identical [2.00, 3.25) MSE buffered hole on both the 90 kHz confidential stream and the 1 kHz public ghost donor. Toggling the Single-Variable Patch (+1 #EXT-X-DISCONTINUITY) collapses the hole into continuous [0, 8] playback.
    • F2 (Phantom #EXT-X-GAP): Contrasts a playable segment falsely skipped due to #EXT-X-GAP against a genuinely missing segment counter-example.
    • F3 (Dual-Track A/V Offset & Progressive Drift): Grafts fixed offsets and per-segment drift onto synchronized visual flashes + WebAudio click beats.
    • F4 (EXTINF vs Container Duration Divergence): Compares playlist seek targets against real post-append buffered bounds across cold-seek and warm-seek.
    • F5 (Negative Control & hls.js Version Boundary): Demonstrates why static heuristics lie—a huge +30.0 s jump is silently absorbed by initPTS normalization (0 holes), while a +2.00 s boundary exposes behavioral differences between pinned hls.js 1.6.13 and 1.7.4.
  4. Three Strict Evidence Layers (structural / player / observable): Static container mismatches never claim a bug is "reproduced." A fault transitions from structurally present, not observed to REPRODUCED only when real hls.js TimeRanges (player) and requestVideoFrameCallback mediaTime / audio onset (observable) confirm it in the live browser.
  5. Disclosure-Gated Recipient Blind Replay & Verifiable Provenance:
    • Before anything is exported, the sender must explicitly acknowledge the Public Timing Disclosure (segment count, durations, tfdt deltas, and optional mdat size ratios).
    • Shareable URL Hash (#ghost=v1...) opens in a 4-State Recipient Blind Replay Mode: the maintainer replays and measures the ghost stream blind first, before unlocking the sender's recorded expectation—preventing confirmation bias.
    • Media Provenance Report verifies byte-for-byte that every output mdat SHA-256 matches the public donor manifest (manifest.json) and every container box was regenerated from an allowlist.
    • One-click Offline Repro Pack (.zip) (complete with a self-contained classic-script launcher.html that works directly over file://) and hls.js GitHub Issue Markdown.
  6. Recipient-Only Kiro MCP Server (@ghost-stream/mcp-server): Maintainers working inside Kiro IDE can call inspect_public_recipe, graft_from_recipe, and verify_sanitization over stdio to audit incoming ghost packs without touching sender code.

How we built it with Kiro

Ghost Stream was engineered end-to-end inside Kiro IDE using Specs, Steering, Hooks, Property-Based Testing, and MCP:

  • Spec-Driven Engineering (.kiro/specs/ghost-stream/): We authored 31 EARS requirements in requirements.md, formalized the dual-timeline ISO-BMFF rewriter, rational timescale math, type-level privacy boundary, and Surgical Darkroom visual architecture in 17 sections of design.md, and decomposed implementation into 23 traceable engineering tasks in tasks.md—including an iterative spec-driven UI overhaul (Requirement 31, Tasks 22–23) that added the Surgical Suture Bridge, 4-Vertebrae X-Ray Spine, and Live In-Browser Kiro MCP Lab.
  • Architectural & Design Guardrails via Steering (.kiro/steering/): Four persistent steering documents kept every Kiro task aligned:
    • product.md forbade over-claiming cryptographic zero-knowledge against timing side-channels (enforcing the honest Media Provenance Report + Public Timing Disclosure model) and enforced the 3-layer evidence hierarchy.
    • tech.md locked out ffmpeg.wasm, external network fetches, paid APIs, and 32-bit Number truncation on 64-bit tfdt ticks (BigInt end-to-end).
    • architecture-invariants.md enforced compile-time generator isolation: graftGhostStream(recipe: TimelineRecipe, donor: DonorPack) cannot receive OriginalStreamBundle or comparator observations—verified by static import boundary tests.
    • ui-design.md governed the Surgical Darkroom palette (#08090C obsidian, #F43F5E arterial fracture, #2DD4BF bio-teal donor, #34D399 emerald suture), zero external web-font requests, WCAG AA contrast, and single-viewport stage hierarchy.
  • Automated Quality Gates via Kiro Hooks (.kiro/hooks/):
    • post-core-save-pbt.kiro.hook triggered core unit + fast-check property suites whenever packages/core/src/**/*.ts changed.
    • pre-stop-compliance-gate.kiro.hook enforced our 5-command verification gate (pnpm test, pnpm test:pbt, pnpm build, pnpm verify:donors, pnpm verify:kiroween) so compliance never drifted.
  • Recipient MCP Server Registered in Kiro (.kiro/settings/mcp.json): We built @ghost-stream/mcp-server exposing 3 read-only tools (inspect_public_recipe, verify_sanitization, graft_from_recipe) with strict allowlist entry checks (refusing unlisted ZIP entries without echoing customer filenames), 64 KiB output caps, and 136 automated unit + real child-process stdio framing tests.

Challenges we ran into

Building against real ISO-BMFF bytes and real hls.js MSE pipelines uncovered four subtle engineering traps—each caught before release:

  1. fast-check P1 Caught a Mathematical Over-Claim in Our Own Spec: Our initial Requirement 24.5 claimed that quantizing timestamps from timescale A (90,000 Hz) to donor timescale B (1,000 Hz) and back stays within 1 tick of A. Property test P1 immediately falsified this with a counterexample: 1 ms equals 90 ticks at 90 kHz, so nearest-integer rounding across 90000 -> 1000 -> 90000 has a tight worst-case error of 44 ticks (<= (A + B) / (2B) ticks of A, which is <= 1 tick of min(A, B) in seconds, and <= 1 tick of A iff B >= A). We proved the exact bound, updated requirements.md and design.md, and locked it down with 100+ randomized runs.
  2. Why +30s Jumps Vanish in hls.js While +1.25s Breaks MSE: Early intuition suggested a dramatic +30s tfdt jump would make the most obvious demo stall. Testing against real hls.js passthrough-remuxer revealed the opposite: hls.js treats huge jumps as rollover/unaligned origins and normalizes them via initPTS, whereas a +1.25s jump on 2-second segments slips below normalization in 1.7.4 (>=) vs 1.6.13 (>), leaving a real [2.00, 3.25) MSE hole. That discovery inspired F5 (our negative control + runtime version boundary experiment) alongside F1.
  3. The hls.js rangeStart: 0, rangeEnd: 0 Virtual Loader Trap: During live browser verification, hls.js populated context.rangeStart = 0 and context.rangeEnd = 0 on every fragment load even when no HTTP Range header was requested—slicing our virtual segments down to 1 byte! Fixing the virtual byte-range check to rangeEnd > 0 restored full fMP4 segment delivery.
  4. Preventing Silent Zero-Test False Positives & Jekyll Underscore Drops: In CI setup, vitest run --dir tests/pbt matched 0 files and exited 0 silently. We replaced it with positional vitest run tests/pbt/ (no --passWithNoTests) and built scripts/check-pbt-suite.mjs (19 self-tests) to AST-check that P1–P6 exist, run >= 100 iterations, and contain zero .skip/.only. And when deploying Vite's _ghost-bytes_* asset chunks to GitHub Pages, adding .nojekyll prevented Jekyll from silently dropping underscore-prefixed virtual donor bundles.

Accomplishments that we're proud of

  • 1,248 automated tests passing across 4 workspace packages (527 in core including 35 fast-check property tests across P1–P6 at numRuns >= 100, 136 in mcp-server, 580 in web, and 5 determinism script tests).
  • Bit-identical donor determinism (pnpm verify:donors): Rebuilding all synthetic H.264/AAC fMP4 donors twice from scratch produces identical SHA-256 hashes across all 19 generated files (~131 KB total, zero ffmpeg.wasm bloat).
  • True zero-setup live forensic workbench: One click on Play Live Fault Comparison runs two synchronized hls.js MSE pipelines entirely in memory (0 cross-origin requests), proving identical [2.00, 3.25) buffer holes across 90 kHz confidential and 1 kHz ghost streams—and proving the single-variable #EXT-X-DISCONTINUITY fix live.
  • Intellectual honesty built into the UX: Separation of structural, player, and observable evidence, 4-state blind replay to prevent maintainer bias, and explicit Media Provenance vs timing-disclosure boundaries.

What we learned

Stitching incompatible subsystems (Frankenstein style)—an ISO-BMFF binary box surgeon, rational multi-timescale arithmetic, dual hls.js versions in one bundle, requestVideoFrameCallback browser telemetry, file:// classic-script ZIP replay, and a Kiro stdio MCP server—succeeds when interfaces act as physical firewalls. Making it a TypeScript type error for the generator to see customer bytes turned privacy from a "best-effort promise" into a structural invariant that fast-check and static tests continuously verify.


What's next for Ghost Stream

  • MPEG-DASH SegmentTimeline ($Time$ / $Number$) Grafting: Extending TimelineRecipe to multi-period MPD manifests and sidx subsegment indexes.
  • Low-Latency HLS (LL-HLS) & CMAF Chunked Transfer: Reproducing partial-segment (EXT-X-PART) moof + mdat cadence stalls without sharing live broadcast content.
  • Browser DevTools Recorder Panel Extension: Capturing broken live fMP4 timelines directly from an active player tab into a local Quarantine Recipe in one click.

Built With

Share this project:

Updates

Submission history