DecidrHolon Design Kit

Patterns

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

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

  1. Receive (receive): Accepts the visitor's text, counts its words, and starts a tracked run. Reference: flow.mjs
  2. 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
  3. Checks (checks): Sends one request to the decisions service containing the full message battery against the screened text. Reference: flow.mjs Reference: battery.mjs
  4. Rules (rules): Evaluates person-defined formal rules over the check probabilities, applying blocking, withholding, escalation, or reply notes. Reference: flow.mjs
  5. 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
  6. 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
  7. 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
StageExecutorDraft product, variant, and priceOn failure or early stop
receiveCodeReceive a message · Code only · $0.00 / messageEmpty text returns an error before a run starts. Reference: flow.mjs Reference: task-types.json
screenCodeScreen a message · Code only · $0.00 / messageStops early and serves a fixed line with no model call. Reference: guards.mjs Reference: flow.mjs
checksModel (decisions service)Classify a message · Standard · $0.01 / messageFails closed to a fixed line; no reply model runs. Reference: flow.mjs Reference: task-types.json
rulesCodeApply the rules · Code only · $0.00 / messageBlocking rule serves a fixed line; unusable strict check counts as fired. Reference: flow.mjs Reference: task-types.json
replyModel (reply model) or fixedPrepare 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
reviewCode + 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
storedCodeStore the record · Code only · $0.00 / runRecords 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

JavaScript
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

  1. Intake (read, watch, listen, or observe): 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
  2. 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
  3. Commit (select, enter, upload, or count): Validates controlled option membership and exit rules, then appends one immutable cell and event. Any step requiring human confirmation or approval stops deterministically at hold_for_review ($0.00). Wireframe spec B Wireframe review C3 Reference: task-types.json
Do

Show each discrete stage with its variant price and factual outcome.

Organisation holon Message run · EFS
Total $0.07
Classify a message · Standard $0.01 / message
Prepare a reply · Reviewed $0.05 / reply
Check a reply · Standard $0.01 / reply
HTML
<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>
Don’t

Do not collapse intake, classification, reply, and review into one unpriced model call.

Single model turn $0.07
One prompt checked the message, composed the answer, and saved the record.
HTML
<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>