Deterministic flows with probabilistic slots
Wrap every model call inside a fixed, event-emitting flow so code controls context, rules, variant pricing, and failure paths.
A holon does not rely on a model being reliable on its own. Instead, you build a deterministic container around every probabilistic slot so code controls ordered context, locks, exit checks, variant pricing, and event storage. Doctrine §8 Reference: flow.mjs
Breaking one interaction into small, repeating steps sacrifices monolithic elegance on purpose. Small steps keep each model call tractable, let you swap a deterministic rule for a model later, and emit replayable events that become the system's history. Doctrine §5
Best practices
- Keep the flow structure fixed in code and confine models to narrow slots. Deterministic steps handle routing, screening, rule evaluation, pricing, and event storage at zero model cost. Doctrine §8 Ruling 4 Reference: flow.mjs
- Run code guards before the first model call. Reject empty, oversized, wellbeing, secret, or internal-workings messages in code so no tokens are spent and no private strings leave the server. Reference: guards.mjs Reference: flow.mjs Wireframe review C5
- Pass only the minimal ordered context each slot requires. Supply the exact facts, conversation window, or declared attributes for that step rather than an organisation's full record. Doctrine §5 Ruling 18
- Select each step's product variant in code from the run's path. Never ask a model to pick a price or billing variant; charge
$0.00whenever a step fails. Ruling 52 Reference: task-types.mjs Reference: flow.mjs - Emit an immutable event for every completed, stopped, or failed step. Recording every step makes the run auditable and replayable from the append-only event store. Doctrine §8 Reference: flow.mjs Reference: decision-store.mjs
The seven-stage message flow
The reference holon processes every visitor message through seven ordered stages. Code runs four stages at $0.00, and model calls run inside three bounded slots. Reference: flow.mjs Reference: task-types.json
- Receive (
receive): Accepts the visitor's text, counts its words, and starts a tracked run. Reference: flow.mjs - Screen (
screen): Normalises text, removes phone numbers, emails, and ID numbers, and stops early on length, wellbeing, secrets, or internal-workings probes. Reference: guards.mjs Reference: flow.mjs - Checks (
checks): Sends one request to the decisions service containing the full message battery against the screened text. Reference: flow.mjs Reference: battery.mjs - Rules (
rules): Evaluates person-defined formal rules over the check probabilities, applying blocking, withholding, escalation, or reply notes. Reference: flow.mjs - Reply (
reply): Runs one grounded turn of the reply model (or emits a fixed line if blocked), constrained by organisation facts and active rule notes. Reference: flow.mjs - Review (
review): Runs post-reply code guards first, then sends the draft reply to the decisions service reply battery before a person sees it. Reference: flow.mjs Reference: guards.mjs - Stored (
stored): Emits the closing event and records the run summary; a withheld message's raw text is never stored. Reference: flow.mjs Reference: decision-store.mjs
| Stage | Executor | Draft product, variant, and price | On failure or early stop |
|---|---|---|---|
receive | Code | Receive a message · Code only · $0.00 / message | Empty text returns an error before a run starts. Reference: flow.mjs Reference: task-types.json |
screen | Code | Screen a message · Code only · $0.00 / message | Stops early and serves a fixed line with no model call. Reference: guards.mjs Reference: flow.mjs |
checks | Model (decisions service) | Classify a message · Standard · $0.01 / message | Fails closed to a fixed line; no reply model runs. Reference: flow.mjs Reference: task-types.json |
rules | Code | Apply the rules · Code only · $0.00 / message | Blocking rule serves a fixed line; unusable strict check counts as fired. Reference: flow.mjs Reference: task-types.json |
reply | Model (reply model) or fixed | Prepare a reply · Reviewed · $0.05 / reply (Live $0.06, Fixed $0.00) | Failed step bills $0.00 and serves the resting or unavailable fixed line. Reference: flow.mjs Reference: task-types.json |
review | Code + model (decisions service) | Check a reply · Standard · $0.01 / reply (Code only $0.00) | Leak, failed check, or unavailable review replaces the reply with a fixed line. Reference: flow.mjs Reference: guards.mjs |
stored | Code | Store the record · Code only · $0.00 / run | Records step events while keeping withheld visitor text out of the store. Reference: flow.mjs Reference: decision-store.mjs |
A normal reviewed message bills $0.07 ($0.01 classify, $0.05 reviewed reply, $0.01 reply check), while a stopped or failed step bills $0.00. Note that the step-level catalogue validates every (flow, step, variant) tuple at startup so a broken price file halts boot immediately. Reference: task-types.mjs House note: three-service holon
function step(run, name, data, flow, variant = 'code_only', rawMicro = 0) {
const tt = taskTypes.price(flow, name, variant);
const s = {
name, ...data, task_type: tt.task_type, variant: tt.variant,
price_cents: data.status === 'failed' ? 0 : tt.price_cents,
raw_cost_micro: Math.max(0, Math.round(Number(rawMicro) || 0)),
};
const i = run.steps.findIndex(x => x.name === name);
if (i >= 0) run.steps[i] = s; else run.steps.push(s);
emit({ type: 'run.step', runId: run.id, step: s });
if (s.status === 'done' || s.status === 'failed' || s.status === 'stopped') {
store?.addEvent({ runId: run.id, holon: holonName, flow, step: name, payload: s });
}
}Task runs follow the same container
BusinessOS task runs apply the exact same deterministic wrapper across three ordered action-type slots. Wireframe spec B Wireframe review C3
- Intake (
read,watch,listen, orobserve): Code pulls only the declared Tail-Light context for the task, screens private details, and emits the intake event at$0.00. Wireframe spec B Wireframe review C3 - Consider (
consider): Runs a decision battery and, where logical reasoning is required, a reviewed reasoning slot bounded by that context. Wireframe spec B Wireframe review C3 - Commit (
select,enter,upload, orcount): Validates controlled option membership and exit rules, then appends one immutable cell and event. Any step requiring human confirmation or approval stops deterministically athold_for_review($0.00). Wireframe spec B Wireframe review C3 Reference: task-types.json
Show each discrete stage with its variant price and factual outcome.
<div class="hx-card hx-stack">
<div class="hx-spread">
<div class="hx-row">
<img class="hx-glyph" src="assets/glyphs/organisation.svg" alt="Organisation holon">
<span class="hx-title">Message run · EFS</span>
</div>
<span class="hx-small hx-muted">Total $0.07</span>
</div>
<div class="hx-spread hx-small">
<span class="hx-row"><span class="hx-dot"></span>Classify a message · Standard</span>
<span class="hx-price">$0.01 / message</span>
</div>
<div class="hx-spread hx-small">
<span class="hx-row"><span class="hx-dot"></span>Prepare a reply · Reviewed</span>
<span class="hx-price">$0.05 / reply</span>
</div>
<div class="hx-spread hx-small">
<span class="hx-row"><span class="hx-dot"></span>Check a reply · Standard</span>
<span class="hx-price">$0.01 / reply</span>
</div>
</div>Do not collapse intake, classification, reply, and review into one unpriced model call.
<div class="hx-card hx-stack">
<div class="hx-spread">
<span class="hx-title">Single model turn</span>
<span class="hx-small hx-muted">$0.07</span>
</div>
<div class="hx-small hx-muted">One prompt checked the message, composed the answer, and saved the record.</div>
</div>