Nexus prompt

Prompt

Build NEXUS as a single self-contained HTML file (inline JS/CSS, no external libraries or network calls): a visual, in-browser simulation of a durable multi-tenant workflow engine. Engine (real working logic, no stubs): - Simulated transactional store: an append-only event log, with task/workflow state rebuilt as projections from it. Each "transaction" applies all its events or none. - Seeded RNG and a simulated clock (no real timers driving logic), so every run is reproducible. - DAG workflows with dependencies, cycle detection, and failure propagation (descendants of a failed task are skipped). - Workers claim tasks atomically with expiring leases and fencing tokens; a stale worker's result is rejected. - Retries with exponential backoff + jitter, up to a retry limit. - Scheduler with priorities, FIFO within priority, global + per-tenant concurrency limits, and fairness so one tenant can't starve others. - Cancellation that races correctly with completion (exactly one wins). Visualization: - Animated DAG: nodes colored by state (pending, running, succeeded, failed, retrying, skipped, cancelled). - Worker panel showing current task, lease expiry, and fencing token. - Live event log feed and per-tenant throughput bars. - Buttons: Run demo, Crash a worker, Cancel workflow, Flood from Tenant A, Step clock, Reset seed. Chaos mode: - A seed input field and a "Chaos" button. - Pressing it runs 500 random operations generated from that seed: worker crashes (including mid-transaction), lease expiries, cancellations, retries, tenant floods, duplicate event deliveries, late results from stale workers, and clock jumps, interleaved randomly across multiple workflows. - Afterward, check every listed invariant against the live state, then discard all projections, rebuild them from the event log alone, and diff against the live state. - Display the result: PASS, or the first violated invariant / first mismatch with the operation number that caused it. The same seed must always produce the same result. - Chaos operations must go through the same engine code paths as normal operation, with no special cases. Built-in test suite that runs on page load and renders a PASS/FAIL table with the seed used: 1. Two workers race to claim one task → exactly one wins. 2. Worker finishes after its lease expires and the task is reclaimed → its result is rejected. 3. Crash mid-transaction → no partial state; rebuilding projections from the log gives identical state. 4. Indirect cycle (A→B→C→A) → workflow rejected. 5. Task fails until retries are exhausted → marked failed, descendants skipped. 6. Cancel races completion → final state is consistent and only one event recorded. 7. Same event delivered twice → applied once. 8. Tenant A floods high-priority tasks → Tenant B still makes progress. 9. 10,000-node chain validates without stack overflow (iterative, not recursive). Each test must check invariants on the actual engine, not hardcoded results. At the top of the page, list the system's invariants and state its delivery guarantee honestly (at-least-once with deduplication, not exactly-once).

A system prompt was added to support web rendering

Drag to resize

Response not available

Drag to resize

Response not available

Drag to resize
Drag to resize
Drag to resize