facets docs
DocumentLIVE

Authoring models that run

Status: LIVE. The author's path from a description to a running, gated, gallery-visible model — and the five facts that bite everyone once. Written after the first real SL-authoring session (Watershed and Supply Chain, 2026-07-27, #258/#259/#261); every trap below was hit that night, and every mitigation named here now exists.

For using the app, start at quickstart.md. For the language itself, language/spec.md is normative. This doc is the working loop between them.

The ten processes, in plain words

Every component is one of Mobus's ten atomic work processes, and the rail names them by two-letter chips. Each has one plain word, and the app shows the pair wherever a primitive is named (hover a rail chip; the inspector's work-process row). The same table lives in the engine's teaching cards (crates/facets-compose/src/docs.rs) and the web gloss (web/src/canvas/types.ts).

Mobus word Plain word Everyday instance
Buffering a stock a reservoir, a savings account, a population
Combining a merge tributaries joining, incomes pooling
Splitting a divider splitting a bill, a river delta
Impeding a resistance a bottleneck, bureaucracy, a resistor
Propelling a pump a courier, an economy moving goods
Copying a broadcast sharing a file, announcing a vote
Sensing a gauge a thermometer, a vote count
Modulating a valve; fed only messages, a gate on messages (#587) a thermostat throttling heat, a quorum gate, a censor's office
Amplifying an amplifier a megaphone, a transistor
Inverting a comparator a thermostat's dial

An agent (facets#269) is not an eleventh process: a decision-maker, drawn as Mobus's management oval, that watches a stock (Buffering) over a flow in and commands a valve (Modulating), an amplifier (Amplifying) or a stock's release over a flow out — the heavy dashed command line. Its rule is one of four (ADR 0008 D4, spec §4.7): proportional, a dial; threshold, a switch, with an optional dead band; table, a graded response, one output per bin of the reading; trace, a dial over the mean of its last few readings — the only one with a memory, which the engine keeps as run state and clears each run. An agent acts in one of two forms: manages <process> signals the process over the command line each tick; manages param "<name>" (ADR 0008 D1) writes a declared param of the same file at the end of each tick, which the next tick runs under, so the inputs rail shows that knob as set by the agent. The param is a flow amount with a range or the shares of a two-way split, declared before the agent, and the rule's commands must fit its range. An agent reads one of two things: watches <stock> reads the stock's level; watches flow <a> -> <b> ["label"] (spec v1.14) reads what that physical flow delivered on the last completed tick, the feedforward form, which measures an input before it reaches a level. The flow is declared above the agent, and the canvas draws the reading as a dotted line from the flow to the agent. The bench shelf carries one witness per rule against its control, the quota fishery in both forms, and the feedforward room (assets/bench/README.md).

What actually makes a model run

Excavated in the #318 library consolidation by putting every bundled model through facets run and sorting the answers. Eighteen examples, eight of which ran; the ten that did not stopped at one of exactly three gates, in this order. Nothing else stops a model, and one thing widely assumed to stop one does not.

Gate 1 — the lens, before anything about the contents is read. @lens selects the representational mode (Lens::mode()): Klir → Core, Bunge → Structural, Mobus → Operational. Only Operational carries flow semantics, so only a Mobus-pinned model can reach run at all. Six of the ten stopped here, and all six were every non-Mobus model in the library — three Klir, three Bunge, no exceptions either way. This is not a defect in those files. It is a statement about which tradition they are written in, and the fix is a modelling decision, not a repair. (The one door around it is run_markov, which reads a Klir canvas as a DTMC. Different call, different meaning: it conserves probability, not substance.)

Gate 2 — the operational projection. Under Mobus, validate_operational must yield a spec: every component needs a primitive, every boundary-crossing flow needs an interface, and endpoints must be typed in the declared direction. The steel-plant walk stopped here on one line — its purchase-order flows run into source Iron-Source, and a source originates flow.

Gate 3 — no algebraic cycle (#259). Circuit::eval_order topologically sorts same-step dependencies, and a pushed wire adds a dependency edge unless the receiver reads state instead of input: an observation tap, a gradient wire, a Source's emission, or a non-Message inflow into a Buffering receiver. So a loop is well-posed exactly when it passes through a stock read as a level. Three stopped here.

The last clause of gate 3 is the sharp part, and it is easy to get wrong:

The substance on the loop's return leg decides it, not the presence of a stock. A Buffering component fed informational around the loop is still an algebraic cycle. Only a physical inflow (matter or energy) lets the receiver read start-of-step storage instead of this step's input.

Verified with a separating pair — identical topology, identical stock, one word different: flow Valve -> Store : matter "return" runs; flow Valve -> Store : informational "return" is refused, naming Store → Valve.

And what is NOT a gate: quantities. archive/respiring-cell.sl declares no time unit, no amount, no stock, and no parameter of any kind, and it runs — because its flow graph is acyclic, so gate 3 has nothing to fail on. Parameterization decides whether a run is meaningful; it has never decided whether one happens (#216, already withdrawn once).

Which leaves two shapes, and among the eight that ran there were only these two:

  • acyclic — the component flow graph is a DAG. Nothing further is needed.
  • cyclic with a Buffering on every cycle, taking its loop inflow as matter or energy.

The clearest way to see gate 3 is the pair the archive keeps deliberately: archive/thermostat.sl is the textbook control loop and it is refused, because Furnace → Sensor → Thermostat → Furnace is a loop of pure relays. The repair is not a parameter — it is a missing thing. The room is the regulated variable and it is not in the model, so the loop has nowhere to remember. assets/archive/demos/homeostat.json is the same system with the room present as a Buffering component between the valve and the thermostat, and it runs and converges. If a loop refuses, the first question is not "which stock do I add" but "what is the regulated variable, and did I forget to draw it?"

The short path (a structural model)

Write a .sl file. The grammar is small and the parser's error messages state the exact clause syntax whenever you miss — lean on them; they are the documentation. Crib from ../assets/examples/ (predator-prey.sl shows environment mediation; archive/respiring-cell.sl is the smallest thing in the repo that runs, and archive/watershed.sl is the one that separates the conservation ledger into all four channels at once). Drop the file in assets/examples/ and it self-sorts into the gallery by its system "…" : Kingdom/Genus line. That's it — it opens as a diagram under all three lenses.

The full path (a model that RUNS in the gallery)

A runnable gallery entry is three artifacts, and the model one is never hand-written:

  1. The .sl file in assets/examples/ — the SOURCE. Declare a time unit, put amount <n> unit <u> on the source-originating flows, primitive on components, interface where flows cross the boundary.
  2. The minted model in assets/models/demos/<name>.json — the machine projection of your .sl. Mint and re-mint with BLESS_SL_DEMOS=1 cargo test -p facets-canvas --test sl_demos after adding your name to the DEMOS list in ../crates/facets-canvas/tests/sl_demos.rs. That gate then holds, forever: the .sl parses → projects → runs conserved and Δt-invariant, and the stored model equals the current projection (edit the .sl without re-minting and CI fails, so the diagram and the run can never drift apart).
  3. The bundle in assets/demos/<name>.json — title, blurb, genus, horizon t, a forcing CSV, and a mapping. The same gate runs your actual bundle through force_and_run, exactly the call the Run button makes, so a bundle mistake fails in CI rather than at click time.

The web gallery picks all of this up by glob; no registration code.

Name the knobs and the readouts (param, metric — spec §4.5–4.6)

Without params, the run tab's Inputs card speaks the kernel's taxonomy ("drivers · absolute rates", "relative weights"). A param line names an adjustable quantity in your model's own vocabulary, and the panel renders it first — a bounded slider for a single amount, % shares for a fanout (the first line from assets/examples/llm-market.sl, the second from its open-weight child, assets/walkthroughs/llm-market/open-weight-serving.sl):

param "Routed workload" : flow "Routed demand" -> Router "routed workload" range 0..12000
param shares "Open-weight models, routed" : from "Open-weight pool"

The boundary to keep straight: a param is presentation over a declared amount, never dynamics. It stores no value (the flow's amount IS the value), it never projects (the engine cannot see it), and the % display of a shares group is derived — the model keeps raw weights, and a share edit edits exactly one of them. Declaring params is enrichment: undeclared magnitudes keep the taxonomy fallback, so nothing requires them. The gallery's "reset to declared" restores what your .sl declares — your declared amounts are the defaults, which is one more reason to calibrate them honestly and cite sources in comments.

A metric line is the same move on the way OUT (#203): where a param names an input knob, a metric names a readout you want every run to answer, in your words — and the run deck renders declared metrics first, above the kernel-fidelity furniture (both lines from the llm-market children in assets/walkthroughs/llm-market/, where the per-model roster lives):

metric "DeepSeek share of routed open" : share of flow "Open-weight pool" -> DeepSeek "routed serving share"
metric "Opus tokens served" : sum into Opus

share of flow reads one flow as a fraction of everything leaving its source (composition — refuse yourself the temptation to declare it on a single-outflow source; the parser will anyway, because that share is identically 1). sum into reads everything arriving at a thing (throughput), as a per-tick series and a run-end total. Declare several of one verb and the deck sorts them by endpoint — your leaderboard. A metric is a derived reading of what the run executed, never a number of its own: it computes from the recorder's per-flow series and can state nothing the trace does not carry. When your model wants a question these two verbs cannot ask, that is a new verb for the language, not a formula — see ADR 0006 for the growth rule.

The five facts that bite

  1. A flow must land where its substance is read. Each primitive consumes specific substances (Mobus Figs 3.18–3.19): a Combining ignores messages, a Copying ignores matter. A flow into a deaf receiver is delivered every step and ignored — the model validates, runs, conserves, and regulates nothing. check_flows_are_consumed (#261) now warns with a fix-shaped hint; take the warning seriously, it found a shipped demo's dead control loop.
  2. A sensor reads a stock over an : informational flow from it. That flow is the observation tap: each step the sensor reads the stock's level and takes nothing. A : matter flow from a stock into a sensor is a real outflow instead. The stock's release splits into it and the sensor dissipates its share, so reading drains what it measures, and sensor_drains_stock warns. (This fact said the opposite until the 2026-11-03 toy-model walk; the engine changed in 4cb56b1, 2026-08-14, and every shipped sensor model reads informationally.) A stock and the step: a stock releases only what it held at the start of a step, so what arrives during a step waits one step. A stock drained harder than it is filled therefore rests at about one step's inflow, not at zero, and that resting level shrinks with Δt (a treasury paid 9 a step and drawn 25 a step rests at 9 at Δt 1, 4 at Δt 0.5, near 0 at Δt 0.1; toy-model walk, 2026-11-03). It is the explicit step, not a parameter: compare drained levels at the same Δt, or refine Δt to read the continuous limit. An encounter is a rate law, not a sensor holding a valve open (#573, #577; walk row 48). When a flow depends on two stocks at once (infection on susceptibles and infected, predation on prey and predators), write the work process with mass action <k>: component Infection primitive Combining mass action 0.5, a : matter flow from the stock it uses up and an : informational flow from the stock it only reads. It draws k · S · I a time unit from the opening levels, and never clips. A sensor opening a valve is still right for real control, a thermostat or a float valve; it is the wrong idiom for an encounter, because the gate clamps at 1. assets/bench/sir-epidemic.sl is the worked case. An agent sets the encounter's rate through the command form (#584): param "contact rate" : mass action of Infection range 0.05..0.5 and agent Public … manages param "contact rate"; the range starts above zero, and a threshold or table commands it (a proportional rule's span starts at 0). sir-epidemic-agent.sl is that case. A memory is a stock declared informational (#576): component Memory primitive Buffering stock ideas time constant 5 informational. An informational flow into it is an inflow, not a gate; it forgets at level / τ, so it rests at inflow × τ (a leaky integrator); reading it copies its level without draining it; and it is off the matter and energy books. An informational flow into any other stock is still its gate. A gate on messages is a Modulating fed only messages (#587): the command into it (an agent's or a comparator's) sets the share that passes, every other message into it is what it gates, and what it stops ceases, since messages copy. assets/bench/censorship.sl is the worked case: a regime holding what the public remembers at its line.
  3. amount is an absolute rate only on source-originating flows. On flows out of processes it is a relative weight for the fanout split; the actual outflow of a stock is its release/time-constant behavior. Don't decorate downstream flows with amounts and expect them to act. And when a signal's availability is simply never the constraint — released weights feeding an Amplifying model, an always-on control line — say ample instead of inventing a huge number (spec §4.4): informational flows only, no unit, the gate reads held open and the diagram shows the word.
  4. Stocks start at zero unless the line says initial. SL's stock <unit> declares a unit, not a value; stock <unit> initial <n> sets the basepoint (#112 slice 1, 2026-08-15; the update below). Without it, author systems that fill from empty, or force them.
  5. Feedback loops need memory on the loop. Wires transmit; stocks remember (#259). A loop is well-posed when it passes through a stock's level read; a loop of pure relays has no deterministic step and the run refuses with the loop named. Time is honest everywhere else too: rates are per time unit, and a run's totals don't depend on Δt (dt_invariance.rs holds this).

Reading a run: instants and steps

A run of N steps has N + 1 instants, numbered 0 to N. Tick 0 is the start, before anything has moved: every stock at its initial (or zero), nothing yet received by a sink, and no flow shown on the canvas. A stock is a state, so it has a value at every instant. A flow is what moves between two instants, so it has one value per step, and the scrubber shows it at the instant its step ended. That is why a run of 12 reads "start / 12" at one end and "tick 12 / 12" at the other. Data lines up the same way: a stock column's first row is the observed start (it also sets the stock's starting level), and a flow column is one row per step. The formal reason is the spec's §8.2, "H starts at the point": a run is the unfolding x₀, T(x₀), T²(x₀), … of the model's step from its starting state.

The three pre-SL demos, and why they cannot be ported

allocation, homeostat and reservoir (now in assets/archive/demos/, retired from the gallery in the August 2026 curation) predate System Language. They are bundled JSON with no .sl source, and the #318 pass asked whether to port them. The answer for two of them is that the language cannot say what they say, and that is worth knowing before anyone tries again:

demo carries portable?
reservoir initial_state.storage = 100 and cognitive_params.release_rate = 1.5 on its Buffering component. The only model in the repo that starts with a stock already full — everywhere else stocks start at zero. no
homeostat release_rate on the Room. A closed regulatory loop that actually runs and converges — see the thermostat pair above. no
allocation nothing but structure: one Splitting component fanning a forced total across three weighted sinks, all four columns driven from CSV. yes, but its fact already lives in llm-market.sl, richer, with param shares

Update, 2026-08-15 — the two productions exist. #112 slice 1 landed after the transition-functor derivation ruled both facts orthogonal to the functor (an initial stock is a choice of basepoint — a pointed coalgebra; a release rate is a parameter of the transition map). SL now says both: stock <unit> initial <n> and, on a Buffering component, release <n> — the emit refusal narrowed to the keys that remain untyped (capacity, setpoint, time_constant, …), each narrowing with its separating instance (sl_stock_dynamics.rs). The first user of both clauses is examples/translation-apparatus.sl's tRNA pool: stock tRNA initial 100 release 20, a self-contained dynamical model with no JSON bypass.

What this means for the three archived demos: porting is now possible and remains open work — they stay in the archive, held by their gates, until someone ports them deliberately and re-blesses. Their history is the record of why the productions exist.

Where the semantics live

Authority order when a question gets deep: the circuit.rs module header (update rule, conservation ledger), language/spec.md §8 (what SL declares vs what engines interpret), and the gates themselves — sl_demos.rs, dt_invariance.rs, and scripts/mutation_check.py, which proves the gates can fail.