“Publishing ten seconds earlier created eleven downstream corrections and left a stale snapshot in the archive. Here is the exact revision bill.”
SWITCHYARD is a deterministic streaming replay engine and downstream correction-budget planner. Rather than treating stream processing as an abstract animated watermark or raw throughput benchmark, SWITCHYARD explores the operational tension between Publication Latency and Downstream Revision Burden.
It models dual-clock temporal windowing, partition candidate watermarks with simulated idle detection, and computes the exact operational bill incurred across consumers with diverse SLA contracts (revisable vs. immutable, fan-out, and latency).
| Workspace | Purpose | Signature Deliverable |
|---|---|---|
| Stream & Time Plot | Dual-clock 2D event replay | SVG scatter plot with 45° causality line ( |
| Correction Ledger | Downstream revision accounting | Computes the operational work units and stale snapshots created across consumers when late arrivals revise window totals. |
| Window Inspector | In-flight window state machine | Drill-down into window intervals OPEN, EMITTED, REVISABLE, FINALIZED), and late rejects. |
| Checkpoint Lab | State snapshot & recovery verification | Captures complete engine state; proves 100% restored equivalence vs. uninterrupted replay; features a teaching mode demonstrating deduplication state loss. |
| Trade-off Benchmark | Empirical Pareto frontier | 60-trial benchmark across 20 seeds comparing aggressive early publication, moderate windowing, and generous lateness regimes. |
| Export & Audit | Reproducible bundles & incident briefs | Downloadable JSON run bundles with SHA-256 event checksums, executable in CI, and printable incident reports. |
2D visual mapping of event time (
Computes the exact revision bill (11 work units and 1 stale snapshot) across revisable wallboards, immutable archives, and fan-out summaries:

Detailed inspection of window intervals, accumulated in-flight totals, initial emissions, revisions, and the too-late rejection ledger:

Validates state snapshotting, restoration equivalence, and features an interactive teaching mode demonstrating duplicate leaks when dedup state is dropped:

Evaluates the trade-off frontier across 60 trials and provides interactive sliders to test custom windowing parameters in real time:

Tested across desktop (1440px), tablet (1024px), and mobile (390px) viewports with accessible touch navigation:
| Tablet Layout (1024px) | Mobile Layout (390px) |
|---|---|
![]() |
![]() |
In our verified test fixture:
-
Tumbling Window Width:
$300\text{ s}$ ($[0, 300\text{ s})$) -
Out-of-Order Bound:
$0\text{ s}$ -
Allowed Lateness:
$120\text{ s}$ (finalization bound at$420\text{ s}$ )
-
$e_1$ ($t_E=10\text{ s}, t_A=10\text{ s}, \text{val}=2$ ): In-flight sum$= 2$ . Window status:OPEN. -
$e_2$ ($t_E=310\text{ s}, t_A=310\text{ s}, \text{val}=1$ ): Global watermark reaches$310\text{ s} \ge 300\text{ s}$ .- Window
$[0, 300\text{ s})$ emits initial value$V_0 = 2$ . -
wallboard(delay 0s): publishes 2 at$t_A = 310\text{ s}$ . -
archive(delay 0s): publishes 2 at$t_A = 310\text{ s}$ . -
summary(delay 10s): schedules publication for$t_A = 320\text{ s}$ .
- Window
-
$e_3$ ($t_E=20\text{ s}, t_A=320\text{ s}, \text{val}=3$ ):- Arrives while
$WM = 310\text{ s} < 420\text{ s}$ (within allowed lateness). - Window sum updates to
$2 + 3 = 5$ . -
REVISE_UNTIL_FINALIZEDtriggersREVISIONemission of value$5$ . -
Downstream Bill:
-
wallboard($F=1$ , revisable): issues correction$\to 1\text{ work unit}$ . -
archive($F=1$ , immutable): rejects update$\to 1\text{ stale snapshot}, 0\text{ work units}$ . -
summary($F=10$ , revisable): published at$t_A=320\text{ s}$ , issues fan-out correction$\to 10\text{ work units}$ . -
Reconciled Work Units:
$1 + 0 + 10 = \mathbf{11\text{ units}}$ . -
Reconciled Stale Snapshots:
$\mathbf{1}$ .
-
- Arrives while
If a publication delay of
Measured across 60 experimental trials (20 seeds × 3 policy regimes, 500 events per stream) via scripts/run_benchmark.mjs:
| Policy Configuration | Mean Correction Work Units | Mean Stale Snapshots | Mean Late Rejections | Mean Window Error vs Oracle | Mean Run Latency |
|---|---|---|---|---|---|
| Aggressive Early Publication (Zero Lateness) | 0.0 units | 0.0 | 13.8 rows | 6.95 count | 1.54 ms |
| Moderate Windowing (15s Bound, 60s Lateness) | 45.5 units | 5.5 | 5.2 rows | 2.93 count | 1.11 ms |
| Generous Lateness (30s Bound, 180s Lateness) | 82.0 units | 8.4 | 0.1 rows | 0.07 count | 1.19 ms |
- Total Benchmark Runtime: 0.100 seconds for all 60 trials.
- Engine Throughput: ~300,000 events/second in client-side in-memory JavaScript.
Full methodology and per-trial output: docs/BENCHMARK.md.
SWITCHYARD builds upon foundational stream processing literature and does not claim to have invented event-time windowing or watermark mechanics:
| Pioneer System | Foundation Relevant to SWITCHYARD | SWITCHYARD Focus |
|---|---|---|
| Apache Beam / Dataflow Model | Unified event-time windowing, watermarks, triggers, and allowed lateness. | Translates abstract triggers into an inspectable downstream correction ledger. |
| Apache Flink | Stateful stream processing, asynchronous checkpointing, and unaligned state recovery. | Provides a client-side checkpoint recovery lab with interactive deduplication loss demonstration. |
| Spark Structured Streaming | Watermark-based state eviction and append vs. update modes. | Visualizes the Pareto frontier between publication latency and revision overhead. |
Full attribution: docs/PRIOR_ART.md.
- Node.js
$\ge 18$ (tested on Node v20/v24)
# Navigate to project directory
cd d:\Ran\switchyard
# Install dependencies
npm installnpm testExecutes all 5 stream contract tests in ~130ms.
npm run devLaunches Vite dev server at http://localhost:5174/.
npm run buildCompiles optimized static assets in dist/ (JavaScript: 64.7 kB gzipped, CSS: 540 bytes).
npm run benchmarkExecutes 60 trials across 20 seeds in ~100ms and updates docs/BENCHMARK.md.
docs/ENGINE_CONTRACT.md: Dual-clock grammar, watermark rules, window lifecycle states, consumer SLA definitions.docs/PRIOR_ART.md: Attribution of related streaming literature and open-source systems.docs/BENCHMARK.md: 60-trial empirical benchmark report across 20 seeds.docs/VALIDATION.md: Automated verification run log and mathematical proofs.docs/PERFORMANCE.md: Runtime latency, memory bounds, and bundle budget profile.docs/DEMO_SCRIPT.md: 60-second executive walkthrough script.docs/INTERVIEW_WALKTHROUGH.md: Senior/Staff system design interview preparation guide.docs/LINKEDIN_POST.md: Ready-to-publish engineering launch draft.BUILD_STATUS.md: Complete milestone progress tracker (100% complete).


