Skip to content

feat: implement alert simulation sandbox#600

Merged
Mosas2000 merged 1 commit into
StellaBridge:mainfrom
dannyy2000:feature/alert-simulation-sandbox
Jun 17, 2026
Merged

feat: implement alert simulation sandbox#600
Mosas2000 merged 1 commit into
StellaBridge:mainfrom
dannyy2000:feature/alert-simulation-sandbox

Conversation

@dannyy2000

Copy link
Copy Markdown
Contributor

What was done

Added a complete alert simulation sandbox that lets operators safely test routing rules against synthetic data before enabling them in production. No real alerts are dispatched during simulation.

Backend — POST /api/v1/admin/alert-routing/simulate

  • New dry-run endpoint added to the existing alert routing admin route
  • Loads all active routing rules (optionally scoped by ownerAddress)
  • Evaluates each rule against the simulated alert using the same matching logic as the live router (severity, assetCode, sourceType)
  • Returns per-rule results with human-readable match reasons, effective channels, fallback channels, and suppression window info
  • Inactive rules are listed separately (skipped from evaluation) and can be disclosed in the UI
  • No DB writes, no channel dispatches — pure evaluation

Frontend — AlertSimulationSandbox page at /alert-sandbox

Left panel — configuration:

  • Admin API token input (persisted in localStorage)
  • Six scenario presets for common failure modes: Critical Bridge Failure, Token Exploit, TVL Anomaly, Reserve Backing Drift, Gas Price Spike, Scheduled Maintenance
  • Full parameter form: severity selector, asset code, source type, triggered value, threshold, metric, owner address, run label

Right panel — Results tab:

  • Summary cards: FIRES / SILENT status, rules matched, rules checked
  • Simulated input echo bar
  • Effective channels panel with suppression window warning
  • Per-rule breakdown with green check / grey X indicators and condition-level explanations
  • Disclosure toggle for skipped inactive rules

Right panel — History tab:

  • Up to 20 simulation runs stored in localStorage via useAlertSimulation hook
  • Each entry shows severity, label, asset/source, result, timestamp
  • Click any entry to restore its results in the Results tab
  • "Clear all" button

Navigation

  • "Alert Sandbox" added to the Operations group in navigation.ts
  • Route registered in App.tsx

Test plan

  • Visit /alert-sandbox — page renders with preset buttons and input form
  • Enter admin API token and click "Critical Bridge Failure" preset — fields populate
  • Click "Run Simulation" — results panel shows FIRES/SILENT, per-rule cards
  • Verify match reasons explain each condition clearly
  • Select different severity/asset/source combinations and confirm rule matching changes
  • Check suppression window note appears when matched rule has suppressionWindowSeconds > 0
  • Switch to History tab — past runs listed, click one to restore results
  • Click "Clear all" — history cleared
  • Confirm no actual alert is dispatched (check backend logs / audit history)
  • Responsive: page adapts correctly on mobile breakpoints

Closes #590

Closes StellaBridge#590

Adds a safe sandbox where operators can test alert routing rules
against synthetic data before enabling them in production.

Backend:
- POST /api/v1/admin/alert-routing/simulate dry-runs the routing
  evaluation logic for all active rules without dispatching anything.
  Returns per-rule match results with human-readable reasons and a
  summary (wouldDispatch, effectiveChannels, suppressionWindow).

Frontend:
- AlertSimulationSandbox page at /alert-sandbox with a two-panel layout.
- Left panel: admin token input, six scenario presets (critical bridge
  failure, token exploit, TVL anomaly, reserve drift, gas spike,
  maintenance), and a full parameter form (severity, assetCode,
  sourceType, metric, triggered value, threshold, owner, run label).
- Right panel: Results tab showing summary cards, effective channels,
  per-rule breakdown with match/no-match indicators and condition
  explanations, inactive-rule disclosure; History tab listing past runs
  stored in localStorage (up to 20), clickable to restore.
- useAlertSimulation hook manages API calls, error state, and
  localStorage persistence of simulation history.
- Nav entry added to the Operations group in MobileNav navigation.ts
  and route registered in App.tsx.
@Mosas2000

Copy link
Copy Markdown
Contributor

Nice flow, checked it all!

@Mosas2000 Mosas2000 merged commit 813ae84 into StellaBridge:main Jun 17, 2026
13 of 20 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

Development

Successfully merging this pull request may close these issues.

Implement Alert Simulation Sandbox

2 participants