The Moment DSL · open-source temporal DDD

Write the domain in code.
The flow renders itself.

Moment is a specification language for temporal domains. Author contexts, events, and crossings as code — and Moment compiles them into a living flow you test in Facet, before any implementation exists.

order.moment authoring
context "Ordering" [Core]
context "Fulfillment" [Supporting]
aggregate "Order"
command PlaceOrder
emits OrderPlaced
event OrderPlaced
orderId: UUID
placedAt: DateTime
flow "order-placed"
moment "Submission"
ordering: OrderPlaced
crosses-to fulfillment
via CustomerSupplier
compiles moment build
facet · order-placed rendering
Ordering [Core] Fulfillment [Supporting] PlaceOrder OrderPlaced crosses-to · CustomerSupplier contract {orderId, items} InitiateFulfillment
command event crosses boundary

Every construct you write commits a piece of the flow on the right. The diagram is a build artifact of the spec — not a drawing you maintain by hand.

Read the spec →
Part of Complai Sift·Moment·Forge·Proof·Glean·Codex·Trace·Facet the open-source keystone — runs with zero Complai dependency
The gap nobody instruments

In every other discipline you validate the design before you build it. DDD goes straight from whiteboard to code.

There has never been a way to simulate event flows, validate crossing contracts, or test saga orchestration before writing implementation. The gap between the model you agreed to and the code you shipped has never been instrumented — and AI agents now widen it at machine speed.

0
Ways to test flows before code

You test commands. You test queries. The temporal flows between bounded contexts go straight to production untested.

Representations that diverge

Your model lives in the wiki, the types, the tests, the docs, the API spec, and someone's head. Six copies that drifted on day two.

The drift compounds silently

Where events cross boundaries, contracts break, and sagas fail — that's the untested frontier where incidents are born.

One source of truth

One specification replaces seven
manually-maintained artifacts.

WITHOUT MOMENT
order.types.tshand-written
order.aggregate.tshand-written
order.spec.tshand-written
order.featurehand-written
order-spec.mddrifts
order-api.yamldrifts
facet.jsonimpossible
7 files · ~400 lines · always diverging · no simulation
WITH MOMENT
order.moment — you write only this
order.types.tsgenerated
order.spec.tsgenerated
order.featuregenerated
order-spec.mdgenerated
order-api.yamlgenerated
facet.jsongenerated
1 source · always in sync · test before you code
The pipeline

Four deterministic stages.

Same specification, same output, every time — clean git diffs by construction.

01 · Parse
Spec → AST

A Langium grammar parses .moment into a typed intermediate representation.

@mmmnt/core
02 · Derive
Facet scenarios

Test topologies, facet.json scenarios, saga state machines, and impact analysis.

@mmmnt/derive → Facet
03 · Generate
Docs, tests, contracts

Gherkin features, specification docs, AsyncAPI 3.0, and Cucumber JSON.

@mmmnt/generate
04 · Emit
Typed TypeScript

Types, aggregate contracts, and test scaffolds written deterministically to disk.

@mmmnt/emit-ts
Built to run in Facet

Your .moment file is a test harness
before it is a line of code.

Moment compiles your spec into a scenario that loads straight into Facet — the test surface for the temporal model. The sequence is visualized the instant you save, and every data contract at every boundary is asserted. No aggregate classes. No glue code. No running system.

order.moment
temporal model
moment simulate
facet.json
scenario + contracts
loads into Facet
Facet
test harness
facet · order-placed 12 / 12 contracts pass
Visualized sequence
Ordering Fulfillment t0 +12ms +34ms +58ms PlaceOrder OrderPlaced crosses-to · CustomerSupplier contract {orderId, items} InitiateFulfillment FulfillmentInitiated
Data contract tests
schema: OrderPlaced✓ 6 fields
crossing contract✓ satisfied
causation chain✓ ordered
saga: terminal state✓ reached
latency budget✓ 58<200ms
negative: out-of-order✓ rejected
12 assertions · 0 failures
validated before any code exists
Immediate sequence

Save the spec and Facet renders the temporal sequence — order, timing, and crossings — on the spot.

Data contract testing

Every boundary crossing carries a contract. Facet asserts each one against the scenario, not against hope.

Zero glue code

The harness is generated, not written. Nothing to wire up, nothing to keep in sync by hand.

The methodology underneath

Convergence is the definition of done.

Moment diagnoses every gap between the specification and the implementation by severity — ERROR blocks convergence, WARNING is advisory, INFO tracks fitness. Drift detection makes divergence visible at AST-level precision instead of letting it surface as an incident, and moment reconcile closes the loop in either direction.

$ moment status
OrderPlaced.placedAt✓ in sync
CancelOrder precondition✓ in sync
CustomerSupplier contract⚠ field added in code
saga: order-placed✓ in sync
1 WARNING · moment reconcile --local
Built for domain-driven teams

Every feature closes the gap between
domain knowledge and running code.

Single source of truth

One .moment file drives types, tests, docs, and visualizations. Domain knowledge stops scattering.

Automatic test derivation

Test topologies, simulation scenarios, and negative cases derived straight from the spec.

Drift detection

AST-level diffing catches when implementation diverges from the spec — before it's a bug.

Schema governance

A four-phase lifecycle — Active, Deprecated, End-of-Life, Removed — with consumption tracking.

AI-ready via MCP

A Model Context Protocol server exposes 7 tools to Claude, Copilot, and Cursor — fully offline.

Watch mode

Auto-regenerate artifacts on spec changes. Deterministic output means clean diffs every run.

Part of Complai

Moment is the open-source foundation
of a domain platform.

Complai is an eight-product ecosystem for delivering software in regulated markets through generative AI. Moment is the keystone — the full pipeline runs with zero Complai dependency. Every other product is optional commercial acceleration that plugs in around it.

Sift UPSTREAM

Automates Event Storming and supplies a converged spec. Optional input — hand-authoring is the primary path.

Codex UPSTREAM

Versioned regulatory rule packs, consumed through an anti-corruption layer. Empty when no pack is active.

Moment YOU ARE HERE

Gives DDD its missing temporal dimension — spec to typed code, tests, docs, and simulation. Open source.

Facet DOWNSTREAM

The visual test surface — renders the sequence from facet.json and asserts every crossing contract.

Forge DOWNSTREAM

Turns the building-block inventory and flow definitions into work items and execution plans.

Proof DOWNSTREAM

Evaluates Moment artifacts against governing protocols and audits co-evolution debt.

Glean DOWNSTREAM

Learns from every Moment stream — a pure consumer, never in the request path.

Trace BIDIRECTIONAL

Signals cascades across the platform; Moment owns its own cascade response.

11
packages — core, derive, generate, emit-ts, translate, sync, schema, viz, harness, mcp, cli
20+
CLI commands — parse, derive, generate, emit-ts, simulate, test, watch, status, reconcile, viz
MCP
7-tool server for Claude, Copilot, and Cursor — fully offline
FSL
source-available now · converts to Apache 2.0 two years after each release
Get up and running

From spec to artifacts in one command.

Adopt incrementally — one bounded context at a time. Generated artifacts are standard TypeScript, Gherkin, Markdown, and AsyncAPI. If you stop using Moment, your code still works.

Read the docs Repo wiki →
terminal
$ git clone https://github.com/mmmnt/moment.git
$ cd moment && pnpm install
$ pnpm turbo build
# parse a spec and generate everything
$ moment parse spec.moment
$ moment derive
$ moment generate --all
$ moment simulate

Common questions

Does this lock me in?

No. Generated artifacts are standard TypeScript, Gherkin, Markdown, and AsyncAPI. The .moment file is the only Moment-specific artifact, and your generated code keeps working without it.

What if the specification is wrong?

moment drift catches when implementation diverges from the spec. Fix the spec or reconcile the implementation — either direction works.

Can I adopt incrementally?

Yes. Start with one bounded context. Moment generates artifacts alongside your existing code, context by context, aggregate by aggregate.

How mature is it?

Moment is v1.0 stable. The full pipeline runs end to end, and all 10 packages — schema governance, drift detection, visualization, and the MCP server — are published on npm under @mmmnt.

Do I need to know DDD?

Basic familiarity with aggregates, commands, and events helps, but the DSL reads like a domain description, not an academic paper.

What about the license?

FSL-1.1-Apache-2.0: source-available now with full read and use rights. Two years after each release it converts to Apache 2.0. The only FSL-period restriction is competing commercial use.

Test before you code.

Functionally complete. Ten packages. MCP-ready. Source-available under FSL-1.1-Apache-2.0.

Get started Star on GitHub