Temporal contracts for TypeScript

Write the rule once.
Run it wherever events happen.

Falsify generated inputs, verify recorded traces, and monitor live streams with the same serializable law.

Runtime deps
0
Definition
JSON-safe
Status
Research preview
law / noTurnDuringTakeover executable
never turn.emitted between takeover.started and takeover.ended
counterexample found 5 events → 2 relevant events

The proof is executable

Put a real trace on trial.

This lab imports Eventlaw's verifier directly. Switch scenarios, inspect the events, then run the same core code used by the library.

no-turn-during-takeover.ts
Input

Recorded trace

5 events
    Output

    Verification report

    Ready

    Select a scenario and run its law.

    A five-event trace contains one forbidden turn. Eventlaw reduces it to the two events that explain the violation.

    One definition, three modes

    The law travels. Its meaning does not.

    1. 01

      Generated

      Search input spaces and shrink a failure to a readable trace.

    2. 02

      Recorded

      Replay JSONL or adapted telemetry against the exact same AST.

    3. 03

      Live

      Push events through an incremental monitor with explicit memory bounds.

    Portable by construction

    A law is data, not a callback.

    Definitions compile to a JSON-safe AST. Save one beside a trace, send it across a worker boundary, or evaluate it in a different process without serializing functions.

    • Explicit correlation and deadlines
    • Pass, fail, and pending trace semantics
    • Human-readable minimal counterexamples
    law.ast.jsonJSON-safe
    {
      "kind": "neverBetween",
      "forbidden": { "type": "turn.emitted" },
      "start": { "type": "takeover.started" },
      "end": { "type": "takeover.ended" },
      "partitionBy": "conversationId"
    }

    Bring your traces

    The core does not own your event bus.

    Research preview

    Useful enough to test. Early enough to shape.

    Eventlaw is not published to npm yet. The core, adapters, tests, examples, and design notes are open for experiments and design partners. The law language will evolve from real event-system failures, not from invented syntax.

    Bring a temporal rule we should be able to express

    Start with one production rule

    What should never happen in your event stream?

    Explore on GitHub Propose a law