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 |
sequence
Section titled “sequence”kind: sequenceid: write.save-notedisplay_id: SEQ-SAVEcapability: writetitle: Save a notesummary: 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) |
How it starts
Section titled “How it starts”| 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.
edges: - to: write.write-note.saved trigger: write.save sequence: write.save-note outcome: savedkind: sequenceid: library.purge-archiveddisplay_id: SEQ-PURGEcapability: librarytitle: Delete old archived notessummary: Each night the API deletes notes archived longer than the retention period.trigger: library.nightlyparticipants: - { id: API, is: [system.api], label: API } - { id: DB, is: [system.db], label: Database }outcomes: []items: - msg: from: API to: DB text: Delete notes archived before the retention period constants: [constant.archive-retention] ops: - { op: delete, entity: data.notes, index: I2, where: archived longer than the retention period, }| 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 kinds
Section titled “Rule kinds”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.
kind: ruleid: write.lengthdisplay_id: RULE-NOTE-LENGTHcapability: writerule_kind: decisiontitle: A note stays within the length limitsummary: Decides whether a note is short enough to save.when: The note is longer than the limitthen: Saving is refused and the editor shows the limitotherwise: The note is savedconstants: [constant.max-note-length]kind: ruleid: notifications.audiencedisplay_id: RULE-NOTIFY-AUDIENCEcapability: notificationsrule_kind: decisiontitle: Reminders reach writers; failures reach adminssummary: Archive reminders reach the writer who owns the note; failed purges reach the workspace's admins only.table: columns: [Kind, Audience, Recipients] rows: - [An archive reminder, Writers, The writer who owns the note] - [A failed purge of archived notes, Admins, Every admin of the workspace]kind: ruleid: rule.own-notesdisplay_id: RULE-OWN-NOTESrule_kind: invarianttitle: A writer reaches only their own notessummary: Every read and change of a note is limited to the writer who saved it.holds: Every note is read, listed, archived, and deleted only for the writer it belongs toscope: [data.notes]kind: ruleid: library.retentiondisplay_id: RULE-PURGE-ARCHIVEDcapability: libraryrule_kind: policytitle: Archived notes are deleted after the retention periodsummary: A note archived longer than the retention period is deleted for good.whenever: A note has been archived for longer than the retention periodthen: The note is deleted and cannot be restoredsequence: library.purge-archivedconstants: [constant.archive-retention]kind: ruleid: write.save-fastdisplay_id: RULE-SAVE-FASTcapability: writerule_kind: qualitytitle: Saving feels instantsummary: A writer sees a save confirmed within a second.applies_to: [write.save-note]measure: Time from pressing Save to the confirmation, over a week of savestarget: Under one second for 95 in 100 savesDecision rules
Section titled “Decision rules”| 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.
constant
Section titled “constant”Always shared. Prose names the value in words (“the length limit”) and links
the constant from constants.
kind: constantid: constant.max-note-lengthdisplay_id: CONST-MAX-NOTE-LENGTHname: MAX_NOTE_LENGTH # required: the name code knowsvalue: '10000'unit: charactersdescription: 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).