Edge Simulator (Scenario Lab)
The scenario lab (/scenarios) is the portal-side edge simulator: a
load + attack generator that stands in for a fleet of real edge boxes,
driving the same real ingest surfaces a box would hit — so a scenario
run produces real cases, real HITL gates, and real audit-chain trails,
not mock data. It lives in the unified portal (apps/portal, the Phase C
product console — module M6); it is not a service in the compose stack
and does not run unless the portal is running. The production edge
simulator ships later with the Phase E developer console (aiso-2zc);
this engine is the reference-stack stand-in for it (ownership note in
apps/portal/src/lib/simulator/engine.ts).
┌──────────── what a real box does ────────────┐
noise telemetry (eps) │ edge event stream → ECS normalize → ES │
──────────────────────▶ POST 127.0.0.1:8120/ (Vector edr_webhook) │
│ → soc-box-ecs-{tenant}-* (no triage) │
│ │
attack alerts (cadence)│ detection fires → AlertMetadataPush │
──────────────────────▶ POST 127.0.0.1:8117/api/alerts/ingest │
│ → dedupe → sync triage graph → case + │
│ OPA gate + §3.4 audit trail │
└──────────────────────────────────────────────┘
Implementation: apps/portal/src/lib/simulator/{config,engine}.ts; routes
/api/scenario/{run,stop,status}; UI src/components/ScenarioPanel.tsx.
Targets are env-configured: SOC_API_BASE (default http://127.0.0.1:8117),
SOC_VECTOR_URL (default http://127.0.0.1:8120), SOC_TENANT
(default tnt_acme_01).
The six knobs
Validated by a zod schema (ScenarioConfigSchema); a shareable URL can
never start a runaway scenario — unknown/out-of-range values fall back to
defaults per field (parseScenarioInput clamps and reports which fields
it refused).
| Knob | Range | Default | Models |
|---|---|---|---|
eps |
10–5000 int | 50 | Total telemetry events/s delivered to the edge (noise + attack) |
attack_cadence |
0–30 | 2 | Attack alerts/minute routed through the full triage path (case-creating) |
noise_ratio |
0–1 | 0.1 | Fraction of non-attack events generated as messy telemetry (jitter fields, sometimes-broken types — the VRL defaults kick in) |
fleet_size |
1–20 int | 2 | Simulated edge boxes edge-sim-0001…N; every event is stamped with one |
tunnel_latency_ms |
0–2000 int | 20 | Artificial edge→cloud egress delay per attack batch (models tunnel latency; the measured send→ACK minus the injected delay is the "observed" latency the /system page graphs) |
verdict_mix_pct |
0–100 int | 50 | Share of attack alerts taking the high-blast (HITL) lane — see the honesty note below |
The four presets
Deliberate drill profiles (PRESETS in config.ts):
| Preset | Config (eps / cadence / noise / fleet / latency / mix) | Purpose |
|---|---|---|
| Quiet Tuesday | 25 / 1 / 0.05 / 2 / 10 ms / 50 % | Baseline business-as-usual |
| Ransomware drill | 120 / 4 / 0.1 / 4 / 40 ms / 100 % | HIGHBLAST-shaped attacks flood the HITL approval queue for the on-call lead |
| APT29 emulation | 60 / 1 / 0.2 / 8 / 120 ms / 75 % | Sustained, patient intrusion: low cadence, mixed verdicts, wide fleet, real-ish latency |
| Noisy neighbor stress | 5000 / 2 / 0.9 / 20 / 800 ms / 40 % | Full EPS ceiling, 90 % messy telemetry — exists to push Vector backpressure and ES queue into visible range on /system |
How a run works
The engine is a process singleton with a 1 s tick loop:
- Noise: each tick delivers
epsevents through a bounded in-flight pool (64) with a 950 ms delivery window. Events the pool cannot deliver in time are counted as dropped — this deliberately models the edge spool cap, with the reference's honest twist: the reference box has no spool replay, so a saturated pipeline loses telemetry rather than buffering it (noise_droppedin the status). - Attacks: paced by
attack_cadence/minute with fractional carry. Each alert carries the configuredtunnel_latency_msegress delay, is POSTed to/api/alerts/ingestwith the dev-mode caller headers (X-Tenant-Id+X-Actor-Subject: edge-agent), and the synchronous response nests the run view undertriage— the engine readstriage.stateto classify the outcome lane and records the alert→case-view latency. A stringtriagemeans the run was deferred (orchestrator unreachable; the alert is still durably landed) and is counted asattacks_failedwith the deferral aslast_error. - Status (
GET /api/scenario/status, any authenticated role): running flag, active config, counters (noise_sent/noise_dropped/attacks_sent/attacks_hitl/attacks_autonomous/attacks_failed), a 240-sample rolling latency series, and the last 8 produced case ids with states. - Start/stop (
POST /api/scenario/runwith{config},POST /api/scenario/stop): requirecases:update(scenarios create cases in the tenant); unauthorized starts return 404, never 403 (the portal's route-class convention — existence is not disclosed). - Config is URL state: the panel encodes knob values as query params
(
configToParams), so a drill setup is a shareable link. - Reset:
/api/resetstops the engine and re-baselines all counters (all state is in-memory; a portal restart re-baselines implicitly).
Honest verdict-lane mapping
The reference stub LLM has exactly two deterministic lanes (the stub cannot produce false-positive/benign verdicts — those land with the production LLM backends, spec §3.1):
| Lane | Trigger in the simulator | Stub verdict | Lands as |
|---|---|---|---|
| High-blast (HITL) | verdict_mix_pct share of attacks, shaped with event.original: "HIGHBLAST" + rule_id prefixed HIGHBLAST-… |
true_positive 0.93, host_isolate + ioc_enrichment_push |
awaiting_approval → attacks_hitl |
| Default (autonomous) | remaining attacks (suspicious-logon shape) | true_positive 0.88, token_revoke |
remediated/contained → attacks_autonomous |
The scenario lab does not pretend otherwise — the page's explain popovers state the two-lane limit explicitly.
What a run gets you (and where to look)
- Real cases in the tenant queue (
/api/cases, portal M1) — therecent_casesstatus readout lists the last 8 with live states. - Real HITL approvals for the HITL-lane alerts — decide them through
the portal (control-plane approval ledger,
docs/developer/api/reference.md). - Real audit-chain growth —
GET :8130/v1/audit/{tenant}/chain(verification.countclimbs with each run; the orchestrator's/healthzshows the per-tenant chain verdict). - Latency/backpressure evidence on the portal's
/systempage — the injected-delay baseline is annotated on the graph, drops and anomaly flags included.
Caveats
- Not in
deploy/compose— there is no simulator service todocker compose up. The engine runs inside the portal Node process; dev-mode hot reloads restart it (acceptable for a reference demo, per the engine's ownership note). - Drops are loss, not buffering (see above) — the "noisy neighbor" preset is designed to make that visible, not to hide it.
- The simulator's edge leg writes into the real tenant ES index
(
soc-box-ecs-{tenant}-*): stress runs pollute the evidence the triage graph queries. Reset demo state via the runbook (docs/developer/operations.md§4) when you are done.