The language · from one rule to state

Describe the rule. Trace the change.

Start with Counter: a guard decides whether a command may proceed, a binding supplies an event’s payload, and a fold turns that event into state. Business declarations live in one author tree; technical bindings and handwritten implementations have separate responsibilities. Neither a graph nor a green gate replaces human agreement on the rule.

Minimal Counter · How folds work · Real bank slice · Expression reference · Relation registry

01

Counter: one causal chain, three views

1 · Business meaning

Start with count = 0. Request SetCount(id="counter-1", count=2). A nonempty id and a nonnegative count pass both guards. Bind the parameters into CountSet; applying that event sets id to counter-1 and count to 2. A negative count is rejected without an event. This is assignment, not increment.

2 · Current author input

These are reformatted JSON array fragments from the shipped Counter slice at cb860b5c, not a complete YAML file or project. Keep their original positions and the surrounding type declarations. The guide’s public init creates the whole project.

payload.guards — evaluated in order, against command parameters and current state.

[
  {"kind":"invariantRef","ref":"nonempty-id","errCode":"EMPTY_ID","cond":"param.id.nonEmpty","onFail":"reject"},
  {"kind":"invariantRef","ref":"nonnegative-count","errCode":"NEGATIVE_COUNT","cond":"param.count >= 0","onFail":"reject"}
]

events.CountSet.bindings — populate the event, not the state.

[
  {"slot":"id","expr":"param.id"},
  {"slot":"count","expr":"param.count"}
]

events.CountSet.foldAssignments — replay reads the recorded event, not the original command.

[
  {"slot":"id","expr":"event.id"},
  {"slot":"count","expr":"event.count"}
]

3 · Expanded semantic view — IR, not author input

The count assignment’s update subtree in admitted domain-folds@6 is below. The full product also carries target, type, source and dependencies. Do not paste this IR into expr.

{
  "op": "set",
  "value": {
    "op": "ref",
    "ref": {"context":"example","kind":"event-slot","owner":["Counter","CountSet"],"id":"count"}
  }
}
02

Guard, binding, fold: different jobs

Guard

May this command proceed?

A true predicate proceeds to the next guard. On false, onFail: reject stops with its error code; succeed-empty stops successfully with no events. Neither runs later guards. The policy is not the predicate’s return value.

Binding

What fact is recorded?

Emission bindings fill event slots from declared command/state values, or explicitly admitted, version-pinned host outputs. An event field and a state field are not interchangeable.

Fold

What state follows this fact?

Event application alone evolves aggregate state. A fold replays state + event; it cannot call a host, read the clock/network or depend on the original command parameters.

Simultaneous updates, not a script

Every right-hand side and update base reads the same immutable pre-event snapshot. Compute all results, then form a new state. Removing a map entry in one assignment does not hide its old value from another. Each event may assign each target only once: no ordering trick, last-write-wins or intermediate-state reads.

A fold map read such as state.pending[event.key] produces an optional value in typed products. The receiving type must admit that optional; it is not an unchecked extraction. Even where a legacy tree precheck accepts a spelling, strict typed admission can still reject it.

EXACT VALUES

Long/Int/Integer use canonical signed-64 decimal strings at the product/oracle boundary, never JS Number. Exact money needs declared nominal types, precision, scale and units. There is no implicit currency, rounding or conversion. Wrong units, precision or overflow fail; money-apply is an operator name, not a built-in banking policy. Host clocks and arbitrary Scala are not replay expressions; literal:SYSTEM_NOW is not a clock call in these strict products.

03

A real slice, unedited

From truth/bank-wealth/…/credit-balance/slices/initialize-account.slice.yaml. One command, five guards, one event, folds and provenance. This source excerpt is not a standalone project or a new bank acceptance run.

Business view: identity, conflict, then idempotency

  1. ACCOUNT_ID: the requested resource must equal this aggregate’s id.
  2. ACCOUNT_CURRENCY: currency must be CNY and the amount must carry that same currency.
  3. ACCOUNT_INIT_CONFLICT: before initialization, proceed; afterwards require the same recorded amount. A different amount rejects before the idempotency guard.
  4. ACCOUNT_INIT_ONCE: !state.initialized being false means succeed-empty. A matching retry emits no second event and skips subsequent guards.
  5. ACCOUNT_SEED_NONNEGATIVE: a fresh seed must be >= 0.00. Zero is allowed; this is not the stricter money-positive predicate.

Current author view: original file bytes

# ═══ truthsrc atom — hand-editable; contract: SCHEMA.md ═══

kind: slice
aggregate: CreditBalance
command: InitializeAccount
payload:
  {
    "name": "InitializeAccount",
    "parameters": [
      "resource: AccountId @BUSINESS_INPUT",
      "currency: String @BUSINESS_INPUT",
      "amount: Money @BUSINESS_INPUT"
    ],
    "guards": [
      "@guard[invariantRef](reject ACCOUNT_ID/ACCOUNT_ID: \"param.resource == state.id\")",
      "@guard[invariantRef](reject ACCOUNT_CURRENCY/ACCOUNT_CURRENCY: \"param.currency == \\\"CNY\\\" && param.amount.currency == param.currency\")",
      "@guard[invariantRef](reject ACCOUNT_INIT_CONFLICT/ACCOUNT_INIT_CONFLICT: \"!state.initialized || state.accountBalance.get(param.currency).contains(param.amount)\")",
      "@guard[invariantRef](succeed-empty ACCOUNT_INIT_ONCE/ACCOUNT_INIT_ONCE: \"!state.initialized\")",
      "@guard[invariantRef](reject ACCOUNT_SEED_NONNEGATIVE/ACCOUNT_SEED_NONNEGATIVE: \"param.amount.amount >= 0.00\")"
    ],
    "produces": [
      "AccountInitialized"
    ],
    "provenance": {
      "author": "agent-assisted-bank-v1",
      "workshopHeld": false,
      "approvedBy": "user-approved-p24-p25-bank-joint",
      "sourceVersion": "bank-v1-p23-design-2"
    }
  }
events:
  {
    "AccountInitialized": {
      "name": "AccountInitialized",
      "payloads": [
        "resource: AccountId @PROPAGATED",
        "currency: String @PROPAGATED",
        "amount: Money @PROPAGATED"
      ],
      "bindings": [
        "resource <- param.resource",
        "currency <- param.currency",
        "amount <- param.amount"
      ],
      "foldAssignments": [
        "initialized := \"literal:true\"",
        "accountBalance := @fold[put](key=event.currency, value=event.amount)"
      ]
    }
  }

Expanded semantic view — explanation, not author input

After all five guards pass, the three bindings record resource, currency and amount in AccountInitialized. Its fold sets initialized=true and puts the event amount under the event currency in accountBalance, both against the same pre-event snapshot. For a fresh matching account, 0.00 CNY is valid; a matching initialized retry has no event/fold; a conflicting amount is a rejection. This explains the declaration, not an independent execution of banking behavior.

Guards

Rules with teeth

Guards retain their order and their false-predicate outcome: reject rejects, while succeed-empty ends an idempotent retry without another event. “Non-negative balance” is no longer a comment — it compiles into the generated command handler.

Bindings

Where payloads come from

Every event field is either propagated from a parameter or computed — provenance at the field level, which is what read-model lineage (R10/R11) builds on.

Folds

History becomes state

foldAssignments define how the event updates aggregate state — the algebra the generated event applier implements.

04

Current expression reference

Checked against toolchain cb860b5c, package 0.5.0. Author format, micro syntax and product profiles are separate versions. Counter selects decision @4, dependencies/folds @6; do not silently replace those profiles with an older example.

Current finite fold operations remain supported; reusable pure function definitions/references and function-level BDD are deferred in DEF-21, with syntax and definition location undecided and no relaxation of replay, type or version admission.

Seven fold operations

Each row below is an author object fragment inside an event’s foldAssignments, not standalone YAML. Example field names require matching declarations. Outer objects with string operands are the supported interim form; they are not the proposed final language design.

Operation / author formArguments and meaningTypes, profile and limits
set
{"slot":"count","expr":"event.count"}
slot, expr; optional op:"set". Replace a value.Exact target type required. Supported by fold products @1 onward. Use direct assignment, not the broken micro set form.
put
{"slot":"items","op":"put","key":"event.key","value":"event.value"}
slot, op, key, value. Insert or replace one key.Map target; matching key and value types. Not a list append. Fold products @1 onward.
remove
{"slot":"items","op":"remove","key":"event.key"}
slot, op, key. Remove a key; absence leaves the map unchanged.Map target, matching key type. No value argument. Fold products @1 onward.
put-all
{"slot":"items","op":"put-all","key":"event.keys","value":"event.value"}
key is a sequence; put the same scalar value at each key.Map target; sequence element matches key type. Not a map merge or key/value zip. Fold products @1 onward.
remove-all
{"slot":"items","op":"remove-all","key":"event.keys"}
Remove the keys in the sequence.Map target; scalar key is invalid here. No value/callback. Fold products @1 onward.
money-apply
{"slot":"balance","op":"money-apply","delta":"event.amount","sign":-1}
slot, op, delta, sign. Pre-event balance plus signed delta.Admitted exact nominal target/delta, same units; sign exactly 1 or -1. No floating point. Fold products @1 onward with exact types.
integer-apply
{"slot":"count","op":"integer-apply","delta":"event.count","sign":1}
Pre-event signed-64 count plus signed delta; rejects overflow.Integer target/delta. Author aggregate must opt into valueExpressionProfile:"truthsrc.domain-values/v2"; this marker alone does not select a product/generator. Typed fold products @1 onward.

Do not mix four grammar layers

Pinned references: AUTHORING · micro · SCHEMA · author values · PRODUCTS · typed folds/oracles. Historical sections describe broader legacy carriers; these strict profiles are not arbitrary execution permission.

Next: approve and check one Counter rule change.

05

The shape of a tree

From the bank example — physical author-file counts verified. The 59 independent VO atom files (F-10) plus 59 VOs expanded from structures give 118 VO nodes in the canonical graphstore (F-03); files and expanded nodes are different counting units.

truth/bank-wealth/
├── system.yaml                    # the system root: id, name, responsibility
├── inbox/                         # workshop intake — notes are DRAFTS, not law
│   ├── 02-commands/  05-context-map/  06-aggregate-detail/ …   # 13 product slots
└── contexts/bankwealth/
    ├── context.yaml               # bounded context + its dependencies (R21)
    ├── aggregates/
    │   ├── credit-balance/
    │   │   ├── aggregate.yaml     # state fields + named @rule invariants
    │   │   └── slices/initialize-account.slice.yaml
    │   ├── fund-order/  …         # 27 slices across 3 aggregates
    │   └── sip-plan/
    ├── value-objects/             # 59 independent VO atom files: Money, AccountId, AmountDecimal…
    ├── read-models/               # 6 read models with field lineage (R10/R11)
    ├── policies/                  # event → command reaction rules (R7/R9)
    ├── stories/                   # 4 user stories
    ├── use-cases.yaml             # flows realized by slices (R18)
    ├── pipelines/                 # 4 Monarch-style ordered step queues (R14–R16)
    ├── sagas/                     # 2 TCC cross-aggregate transactions
    └── formal-products/           # 36 contracts: ports, hosts, artifact contracts…
RULE ZERO

The author tree is the only place to edit business declarations. Compiled canonical, semantic products, graphs and code anchors are derived, not competing business models. Technical bindings and supported handwritten zones have their own explicit contracts; do not patch generated artifacts to change a rule.

06

Scope layer: what you can say

Two vocabularies, one registry. Workshop note types are the discovery surface (what a wall of sticky notes becomes); atom kinds are the compiled contract. verified against lib/shared.mjs

15 note types — the workshop intake

GroupTypesWhat they carry
Behaviorevent · command · policy · timerDomain events, commands that request change, reaction policies, time triggers — the EventStorming vocabulary.
Structureaggregate · entity · field · readModelConsistency boundaries, entities, fields with lineage, read-side projections.
Strategycontext · subdomain · relationBounded contexts, core/supporting/generic classification, and inter-context relations — the strategic DDD layer.
People & systemsrole · externalSystemActors (with the commands they may issue, R12) and external systems at the boundary.
Knowledgequestion · storyOpen questions / hotspots that must not silently vanish, and user stories awaiting placement.

12 atom kinds — the compiled contract

KindFileHolds
noteinbox/**Draft workshop notes of any note type — awaiting human promotion.
aggregateaggregates/<slug>/aggregate.yamlIdentity, state fields, ordered command/event pools, named @rule invariants.
sliceslices/<slug>.slice.yamlThe causal unit: one command, its guards, the events it produces, fold assignments, provenance.
value-objectvalue-objects/<slug>.vo.yamlTyped values — Money, nominal wrappers like AccountId.
read-modelread-models/…Read-side shapes with per-field sources (lineage).
policypolicies/…“When event X then command Y” reaction rules.
story / use-casesstories/… · use-cases.yamlUser stories and the flows that realize them.
pipelinepipelines/<slug>.pipeline.yamlAn ordered business-step queue (steps, never “stages”) — compiled to a Monarch plan.
sagasagas/<slug>.saga.yamlCross-aggregate TCC transactions: participants, phases, compensation — compiled to saga-core IR.
scenarioscenarios/<slug>.scenario.yamlNarrative runbooks / demo scripts.
formal-productformal-products/…Engineering contracts: technical ports, effect hosts, artifact contracts, host computations — what the generated code must satisfy.
07

The relation registry — the metamodel’s spine

22 typed relations. The propagates flag is a human ruling per relation: does this edge carry impact? blast_radius walks exactly the propagates edges — over-reporting rather than missing. verified

IDFromRelationToPropagatesMeaning
R1aggregateownsslice✓structural ownership
R2aggregatereferencesaggregate✓cross-aggregate reference
R3aggregateemitsevent✓event-pool membership
R4sliceissuescommand✓one command per slice (1:1)
R5sliceemitsevent✓events a slice produces
R6commandproducesevent✓causality; conditions live in guards
R7eventtriggerspolicy✓reaction rules
R8policyconstrainsslice✓policy bounds a slice
R9policyinvokescommand✓policy issues a command
R10read-modelderives-fromfield✓read-side lineage
R11fieldlineagefield✓field-to-field chains
R12rolecan-issuecommand—permission, not impact
R13read-modelvisible-torole—visibility
R14pipelinehas-stepstep✓ordered steps
R15stepperformed-byrole—participation
R16stepexecutesslice✓a step runs a slice
R17storycoversuse-case—traceability
R18use-caserealized-byslice✓flow → slices
R19scenarioexercisespipeline—runbook path
R20value-objectused-byaggregate✓type usage
R21contextdepends-oncontext✓the context map
R22aggregatebelongs-tosubdomain—strategic classification

Strategic layer in one glance: R21 is the context map; R22 places aggregates in core/supporting/generic subdomains; R12/R13 carry who may act and who sees what. Everything else is behavior — and behavior edges propagate impact.

08

Governance: three gates, not style guides

validate — 0 hard findings

author structure and declared-reference checks, not complete typed admission

Unknown kinds, dangling references, an event defined in two places, a slice without its aggregate — all hard findings. Zero is the only acceptable count. Bank tree as of 2026-11-11: 0 hard verified.

roundtrip — byte-identical

tree → canonical → tree must reproduce the author files exactly

This is the anti-formatting-drift gate. If compilation “normalizes” anything, the roundtrip diverges and the gate fails. Bank tree: 157 atoms, byte-identical verified.

compile-products — strict contracts

formal products must satisfy their schemas before use

Ports, saga IR, execution IR: typed, versioned products compiled from the tree with their own validation. Generated code consumes frozen products only.

AGENTS

The editing contract for AI agents is the same three gates plus stewardship rules: every batch ends validate AND roundtrip green; payload text is preserved verbatim; no tool artifacts inside the tree; one event defined in exactly one slice. It ships with the toolchain as AGENTS.md and a query skill pack.

09

What authoring looks like today — and tomorrow

Today the editing surface is YAML files plus three extraction skills (from a codebase, from reachable data, from a one-line description). Visual authoring — importing workshop boards from Qlerify or Miro, reverse-engineering a tree from an existing repo — is designed for but not yet built: DEF-02.

Schema reference: SCHEMA.md · authoring guide: AUTHORING.md · full tutorial: TUTORIAL.md