DecidrHolon Design Kit

Patterns

Failing closed

Serve a fixed safe line and withhold model calls whenever checks fail, strict answers are unusable, spend caps trigger, limits hit, or the holon is paused.

When a guard, decision check, budget hold, or access gate fails, a holon never improvises its way past the failure. It stops immediately and returns a fixed, pre-approved line (or HTTP error) with zero unchecked model calls. Reference: flow.mjs Reference: guards.mjs Reference: server.mjs

Failing closed is built into the flow container, the spend meter, and the HTTP gate so safety holds even when upstream model services time out, return malformed probabilities, or hit daily spend ceilings. Doctrine §8 Reference: meter.mjs Reference: public.mjs

Best practices

  • Never invoke the reply model when inbound checks fail or time out. No checks means no reply; serve the fixed unavailable line immediately. Reference: flow.mjs
  • Treat missing, refused, or non-finite strict answers as fired. If the decisions service declines or omits a strict check, apply its guard automatically. Reference: flow.mjs
  • Replace the draft reply whenever reply review fails. Never display an unreviewed draft; serve the adviser line if advice was requested, or the unavailable line otherwise. Reference: flow.mjs
  • Stop every model call on budget exhaustion, ledger corruption, or a PAUSE file. Refuse server startup if an existing spend ledger is missing or has lost its tables. Reference: meter.mjs Reference: server.mjs
  • Return plain 404 to unauthenticated public requests. A stray visitor or scanner learns nothing about routes and triggers zero spend. Reference: public.mjs Reference: server.mjs
  • Keep explore endpoints off by default and always off in public mode. Return 409 whenever an exploratory route is called while disabled or paused. Reference: server.mjs Reference: flow.mjs

Failure modes and fixed outcomes

Every failure path in the reference holon maps to one deterministic action and one fixed outcome. Reference: flow.mjs Reference: guards.mjs Reference: server.mjs Reference: meter.mjs

Failure or limitWhat the holon doesFixed outcome
Pre-model screen stop (over 500 chars, wellbeing, secret, internal-workings probe)Stops at screen; runs zero model calls; records a placeholder in thread history. Reference: guards.mjs Reference: flow.mjsServes the matching fixed line (tooLong, wellbeing, secret, or inside). Reference: guards.mjs
Decisions service fails or times out (10 s)Sets failClosed: true on rules; never calls the reply model. Reference: flow.mjs Reference: server.mjsServes the unavailable fixed line. Reference: flow.mjs
Refused or non-finite strict/blocking checkunusable(row) counts the rule as fired. Reference: flow.mjsServes the block line or enforces withhold / person handling. Reference: flow.mjs
Reply model fails, times out (15 s), or returns emptyMarks reply failed ($0.00 billed) and settles the spend hold. Reference: flow.mjs Reference: server.mjsServes resting if budget is exhausted, else unavailable. Reference: flow.mjs
Post-reply canary leak or stray contact detailfinish() replaces the output; a leak short-circuits the reply battery. Reference: guards.mjs Reference: flow.mjsServes inside (on leak) or unavailable (on stray contact). Reference: guards.mjs
Reply battery fails or returns unusable answerRefuses to release the unreviewed draft. Reference: flow.mjsServes advice if the visitor asked for personal advice, else unavailable. Reference: flow.mjs
Daily budget spent, 4,000 call cap reached, or meter brokenmeter.hold() returns null; no network call leaves. Reference: meter.mjsServes the resting fixed line. Reference: flow.mjs
PAUSE file present in data folderChecked at route admission and before every model call (including mid-flow). Reference: server.mjs Reference: meter.mjsServes the resting fixed line. Reference: server.mjs
Missing or stripped spend ledger on existing deploycheckLedger() and openMeter({ requireExisting: true }) throw on startup. Reference: server.mjs Reference: meter.mjsProcess exits rather than starting with a fresh budget. Reference: server.mjs
Rate, concurrency, body-size (4 KB), or body-time (5 s) limit hitRejects before the flow starts (429, 503, 413, or 408). Reference: server.mjs Reference: public.mjsReturns the busy fixed line or error response. Reference: server.mjs
Missing cookie, wrong key, or 10 bad keys in 10 minLocks out offending address for the 10-minute window; reveals no routes. Reference: server.mjs Reference: public.mjsReturns plain 404 Not found. Reference: server.mjs
POST /api/explore in public mode, paused, or disabledRefuses to invoke the explore service. Reference: server.mjs Reference: flow.mjsReturns 409 ({ ok: false, off: true }). Reference: server.mjs
JavaScript
if (!d.ok) {
  reveal(run, said, null);
  step(run, 'rules', { status: 'done', failClosed: true, fired: [], results: [] }, 'message');
  metrics.tasks += 1;
  history.push(
    { role: 'user', content: '[a message the holon did not act on]' },
    { role: 'assistant', content: fixed.unavailable }
  );
  threads.set(threadId, history.slice(-20));
  return finishRun(fixed.unavailable, { failClosed: true });
}

Public rate limits and model-off releases

When a holon console runs in public mode, the gate enforces layered sliding-window and concurrency limits before any flow enters admitAndRun(): Reference: public.mjs Reference: server.mjs

  • Message limits: 20 messages per 10 minutes per session, 40 per 10 minutes per hashed address, and 500 per day across the whole server. Reference: public.mjs
  • Profile-check limits: 1 run per 10 minutes per session and 12 per day total. Reference: public.mjs
  • Concurrency and sessions: 1 flow at a time per session, at most 2 concurrent flows per address, at most 4 concurrent flows across all sessions, and a cap of 300 sessions (evicting the oldest idle session). Reference: public.mjs Reference: server.mjs
  • Origin check: Every public POST /api/* request must supply a matching Origin header and application/json content type (sameOriginJson). Reference: public.mjs Reference: server.mjs

On live public chat deployments, the reply model also starts off (FLOW_MODEL=off) using deterministic fallback until IP-shield checks pass end to end. Holon rules §3.4 Ruling 21

Do

Stop the flow and serve a calm fixed line when checks cannot run.

Message run · EFS Fail closed
Checks: unavailable ($0.00) · Reply model: not called
I can't answer that just now. Please try again in a moment.
HTML
<div class="hx-card hx-stack">
  <div class="hx-spread">
    <span class="hx-title">Message run · EFS</span>
    <span class="hx-chip">Fail closed</span>
  </div>
  <div class="hx-small hx-muted">Checks: unavailable ($0.00) · Reply model: not called</div>
  <div class="hx-msg-holon">I can't answer that just now. Please try again in a moment.</div>
</div>
Don’t

Do not fall through to the reply model when checks time out.

Fallback reply
Checks timed out after 10 s; sending unscreened message straight to reply model.
HTML
<div class="hx-card hx-stack">
  <span class="hx-title">Fallback reply</span>
  <div class="hx-small hx-muted">Checks timed out after 10 s; sending unscreened message straight to reply model.</div>
</div>