Skip to content

Sequences and rules

Kind What it holds
sequence What happens between two steps: who calls whom, in order, and how it ends
rule A decision, an invariant, a policy, or a quality target
constant A named value rules, columns, and messages depend on
write.save-note
kind: sequence
id: write.save-note
display_id: SEQ-SAVE
capability: write
title: Save a note
summary: The API checks the note's length, stores it, and tells the editor whether it was saved.
participants: # the lanes
- { id: Web, is: [system.web], label: Web app }
- { id: API, is: [system.api], label: API }
- { id: DB, is: [system.db], label: Database }
outcomes: # the ways it ends; edges map each to a step
- { id: saved, label: Saved }
- { id: refused, label: Too long }
items:
- msg:
from: Web
to: API
text: Save the note # what it does, in words
interface: interface.save-note
http: { method: POST, path: /api/notes }
inputs:
- { name: text, source: The editor, source_kind: surface }
- msg:
from: API
to: API
text: Check the note's length
rules: [write.length]
- alt:
branches:
- when: The note is over the limit
outcome: refused
items:
- msg:
from: API
to: Web
text: Refused with the limit
reply: true
results:
- {
status: 400,
code: note_too_long,
copy: 'Notes can be up to {limit} characters.',
}
- when: The note is within the limit
outcome: saved
items:
- msg:
from: API
to: DB
text: Store the note
ops:
- {
op: insert,
entity: data.notes,
set: [writer_id, text, created_at],
}
- msg:
{
from: API,
to: Web,
text: Saved,
reply: true,
results: [{ status: 201 }],
}
Field Req. Meaning
capability yes Owning capability (home.capability)
title yes Plain-words name
owner no Actor or system id responsible for running this sequence
participants yes Actor, system, or interface ids, or { id, is?, label? } lanes
items yes Messages and blocks, in order
outcomes yes [{ id, label }]; [] for a sequence no edge runs
trigger no Only when no edge runs it: a schedule, event, or call trigger
parts, part_of no Parts, over 16 messages (size.sequence)
Started by How
an edge The edge names it in sequence; the sequence has no trigger
another sequence A message invokes it, or a continue: { to } hands off
itself Its own trigger, never an action (field.invalid)

None of these is a sequence.unreached warning. When the last item is an alt and there are several outcomes, every branch names one.

in step write.write-note.type
edges:
- to: write.write-note.saved
trigger: write.save
sequence: write.save-note
outcome: saved
Item Shape
msg A message (below)
note { over, text, ops?, rules?, tags? }
alt { branches: [{ when, outcome?, items }] }
opt { when, items }
loop { while, max?, items }
par { branches: [{ label?, items }] }
break { when, items }
transaction { label?, items }
continue { to, text? }

msg fields: from, to, text (required); reply, interface (the operation called), call, http, auth, owner, invokes, inputs, guards, ops, rules, constants, results, timeout, retry, idempotency, note, tags. source_kind on an input is surface, parameter, return, stored, payload, session, constant, config, or derived.

ops fields: op (read, insert, update, upsert, delete, lock, audit, enqueue, write, append), entity or path (ops.target), by, index (ops.index), where, join, set, conflict, order, limit, mode, returns, triggers, shared_with, note. An index names the intended access path, not the planner’s choice.

A rule used in one capability names it; a rule several use names none and is shared (home.shared otherwise).

rule_kind Logic Applied by
decision when/then/otherwise?, decision, table, or judge rules on a step, edge, message, note, or rule, or its own applies_to
invariant holds, scope? or applies_to? its scope or applies_to
policy whenever, then, otherwise?, sequence? its sequence, its own applies_to, or rules on a step, edge, message, note, or rule
quality applies_to, measure, target, scope? its applies_to

No logic for its kind is rule.empty; a decision or policy nothing applies is rule.orphan.

write.length
kind: rule
id: write.length
display_id: RULE-NOTE-LENGTH
capability: write
rule_kind: decision
title: A note stays within the length limit
summary: Decides whether a note is short enough to save.
when: The note is longer than the limit
then: Saving is refused and the editor shows the limit
otherwise: The note is saved
constants: [constant.max-note-length]
Field Meaning
decision A flowchart: { nodes: [{ id, node_kind, text, ops?, refs? }], edges: [{ from, to, label?, undirected? }] } (rule.decision)
table { columns, rows }, one cell per column (table.shape)
judge A model’s judgment: { evidence, output, gate?, prompt? }
default, precedence What applies when nothing else does; which condition wins
inputs, params, calculations, sets Inputs, tunable values, formulas, and named lists

node_kind is input, decision, calc, judge, action, outcome, data, or note. Node text names things in words; refs carries the links (text.ref-id).

Every rule may also set applies_to (steps, flows, sequences, interfaces, or entities it governs), rules (rules it applies), constants, constraints ([{ text, hard? }]), and sources (pointers to authoritative external documents kept outside Emergent Instruments: [{ name, location?, section?, owner?, version?, kind? }], available on every record kind). A concrete target is a quality rule, never a DCL. A given/when/then test belongs with the code.

Always shared. Prose names the value in words (“the length limit”) and links the constant from constants.

constant.max-note-length
kind: constant
id: constant.max-note-length
display_id: CONST-MAX-NOTE-LENGTH
name: MAX_NOTE_LENGTH # required: the name code knows
value: '10000'
unit: characters
description: The most characters one note may hold.

Also: source (path#key, when code owns the value) and table ({ columns, rows }, e.g. tiers with prices).