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:
- Quarantine Chamber (Zero Egress): Drop a local HLS/fMP4 folder or run the built-in
CONFIDENTIAL Q4 BOARDsample (90 kHzcrimson broadcast). Every playlist,init.mp4, and.m4ssegment stays in an in-memoryVirtual_FSwith a customhls.jsloader (0 cross-origin requests). - Frankenstein Timeline Graft (
@ghost-stream/core): Parses ISO-BMFF boxes (mvhd,mdhd,trex,tfhd, 64-bitBigInttfdt,trun,mdat) and HLS playlists, strips 100% of customermdatbytes,udta/metaboxes, filenames, and URLs, and extracts a versioned Public Timeline Recipe. Using exact rational common-origin +baseShiftarithmetic, it grafts that timing skeleton onto deterministic public synthetic Donor Streams (donor-video-2sat1 kHzor dual-trackdonor-av-beatwith90 kHzH.264 flash +48 kHzAAC click track) without re-encoding a single media byte. - Five Live Browser MSE Fault Experiments (F1–F5) & Dual
hls.jsRuntimes (1.7.4vs1.6.13):- F1 (
tfdtClock Jump without#EXT-X-DISCONTINUITY): Reproduces an identical[2.00, 3.25)MSE buffered hole on both the90 kHzconfidential stream and the1 kHzpublic 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-GAPagainst 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 (
EXTINFvs Container Duration Divergence): Compares playlist seek targets against real post-append buffered bounds across cold-seek and warm-seek. - F5 (Negative Control &
hls.jsVersion Boundary): Demonstrates why static heuristics lie—a huge+30.0 sjump is silently absorbed byinitPTSnormalization (0holes), while a+2.00 sboundary exposes behavioral differences between pinnedhls.js 1.6.13and1.7.4.
- F1 (
- Three Strict Evidence Layers (
structural/player/observable): Static container mismatches never claim a bug is "reproduced." A fault transitions fromstructurally present, not observedtoREPRODUCEDonly when realhls.jsTimeRanges(player) andrequestVideoFrameCallbackmediaTime/ audio onset (observable) confirm it in the live browser. - Disclosure-Gated Recipient Blind Replay & Verifiable Provenance:
- Before anything is exported, the sender must explicitly acknowledge the Public Timing Disclosure (segment count, durations,
tfdtdeltas, and optionalmdatsize 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
mdatSHA-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-scriptlauncher.htmlthat works directly overfile://) andhls.jsGitHub Issue Markdown.
- Before anything is exported, the sender must explicitly acknowledge the Public Timing Disclosure (segment count, durations,
- Recipient-Only Kiro MCP Server (
@ghost-stream/mcp-server): Maintainers working inside Kiro IDE can callinspect_public_recipe,graft_from_recipe, andverify_sanitizationover 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 inrequirements.md, formalized the dual-timeline ISO-BMFF rewriter, rational timescale math, type-level privacy boundary, and Surgical Darkroom visual architecture in 17 sections ofdesign.md, and decomposed implementation into 23 traceable engineering tasks intasks.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.mdforbade 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.mdlocked outffmpeg.wasm, external network fetches, paid APIs, and 32-bitNumbertruncation on 64-bittfdtticks (BigIntend-to-end).architecture-invariants.mdenforced compile-time generator isolation:graftGhostStream(recipe: TimelineRecipe, donor: DonorPack)cannot receiveOriginalStreamBundleor comparator observations—verified by static import boundary tests.ui-design.mdgoverned the Surgical Darkroom palette (#08090Cobsidian,#F43F5Earterial fracture,#2DD4BFbio-teal donor,#34D399emerald 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.hooktriggered core unit +fast-checkproperty suites wheneverpackages/core/src/**/*.tschanged.pre-stop-compliance-gate.kiro.hookenforced 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-serverexposing 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:
fast-checkP1 Caught a Mathematical Over-Claim in Our Own Spec: Our initial Requirement 24.5 claimed that quantizing timestamps from timescaleA(90,000 Hz) to donor timescaleB(1,000 Hz) and back stays within1tick ofA. Property test P1 immediately falsified this with a counterexample:1 msequals90ticks at90 kHz, so nearest-integer rounding across90000 -> 1000 -> 90000has a tight worst-case error of44ticks (<= (A + B) / (2B)ticks ofA, which is<= 1tick ofmin(A, B)in seconds, and<= 1tick ofAiffB >= A). We proved the exact bound, updatedrequirements.mdanddesign.md, and locked it down with 100+ randomized runs.- Why
+30sJumps Vanish inhls.jsWhile+1.25sBreaks MSE: Early intuition suggested a dramatic+30stfdtjump would make the most obvious demo stall. Testing against realhls.jspassthrough-remuxerrevealed the opposite:hls.jstreats huge jumps as rollover/unaligned origins and normalizes them viainitPTS, whereas a+1.25sjump on 2-second segments slips below normalization in1.7.4(>=) vs1.6.13(>), leaving a real[2.00, 3.25)MSE hole. That discovery inspired F5 (our negative control + runtime version boundary experiment) alongside F1. - The
hls.jsrangeStart: 0, rangeEnd: 0Virtual Loader Trap: During live browser verification,hls.jspopulatedcontext.rangeStart = 0andcontext.rangeEnd = 0on every fragment load even when no HTTPRangeheader was requested—slicing our virtual segments down to 1 byte! Fixing the virtual byte-range check torangeEnd > 0restored full fMP4 segment delivery. - Preventing Silent Zero-Test False Positives & Jekyll Underscore Drops:
In CI setup,
vitest run --dir tests/pbtmatched 0 files and exited0silently. We replaced it with positionalvitest run tests/pbt/(no--passWithNoTests) and builtscripts/check-pbt-suite.mjs(19 self-tests) to AST-check that P1–P6 exist, run>= 100iterations, and contain zero.skip/.only. And when deploying Vite's_ghost-bytes_*asset chunks to GitHub Pages, adding.nojekyllprevented Jekyll from silently dropping underscore-prefixed virtual donor bundles.
Accomplishments that we're proud of
- 1,248 automated tests passing across 4 workspace packages (
527incoreincluding35fast-checkproperty tests across P1–P6 atnumRuns >= 100,136inmcp-server,580inweb, and5determinism 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, zeroffmpeg.wasmbloat). - True zero-setup live forensic workbench: One click on
Play Live Fault Comparisonruns two synchronizedhls.jsMSE pipelines entirely in memory (0 cross-origin requests), proving identical[2.00, 3.25)buffer holes across90 kHzconfidential and1 kHzghost streams—and proving the single-variable#EXT-X-DISCONTINUITYfix live. - Intellectual honesty built into the UX: Separation of
structural,player, andobservableevidence, 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: ExtendingTimelineRecipeto multi-period MPD manifests andsidxsubsegment indexes. - Low-Latency HLS (LL-HLS) & CMAF Chunked Transfer: Reproducing partial-segment (
EXT-X-PART)moof + mdatcadence 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
- fast-check
- ffmpeg
- fmp4
- github
- hls.js
- iso-bmff
- kiro
- mcp
- python
- react
- tailwindcss
- typescript
- vite
- vitest
- web-audio-api