This page is the short, public form of SAFi’s formal mathematical specification. The versioned source of truth is docs/MATHEMATICAL_SPECIFICATION.md in the repository; everything here mirrors it.

Timing: one synchronous pass

Every stage runs synchronously inside a single request. No answer reaches the user before it has been scored and ruled on. If the audit ran after delivery it would be a report, not a control.

Objects

t      turn index (indexes the agent's Spirit-memory sequence)
x_t    input context (prompt + metadata)
V      value set {(v_i, w_i)}, sum(w_i) = 1, compiled by Synderesis before the turn
R      rubric set, one scoring guide per value; given to the Conscience
P      persona given to the Intellect: worldview and style, no value or rubric
f_t    the Spirit's coaching note, read by the next turn's Intellect
a_t    draft response from the Intellect
r_t    the Intellect's short internal reflection (audit log)
L_t    Conscience ledger {(v_i, s_i, c_i)}
s_i    alignment score for value v_i, in [-1, 1]
c_i    confidence for value v_i, in [0, 1]
A_t    aggregate alignment in [0, 1]   (the gating quantity)
S_t    Spirit coherence in [1, 10]     (the display/audit quantity)
M_t    memory state (prior audits, profiles, aggregates)
beta   EMA smoothing factor, default 0.9
theta  alignment threshold, default 0.5

The pipeline

0  Phase Zero  gate on x_t -> safe | redirect          (no model)
1  Intellect   (a_t, r_t) = I(x_t, P, M_t, f_{t-1})   P = persona; V withheld
2  Will P1     structural check on a_t (deterministic repair first)
3  Conscience  L_t = C(a_t, x_t, R)   one (score, confidence) per value
4  Will P2     hard-gate check on L_t (fail-closed)
5  Spirit      (critical_violation, A_t) = integrate(L_t)
6  Will P3     alignment check: A_t vs theta
7  Spirit      (S_t, mu_t, d_t) = compute(L_t, M_t)   after commit
   [tool turns] a fourth Will gate rules the tool intent before any execution

Phase Zero is a gate, not a faculty

SAFi has five faculties: Synderesis, Intellect, Will, Conscience, Spirit. Phase Zero is not one of them. It is a deterministic input-threat gate (signatures, blacklist, an entropy heuristic) that runs before any model is called, so an attack never reaches the Intellect.

The Will is a pure function

Each Will pass is binary (approve or violation) and contains zero model calls: string comparisons, set membership, numeric thresholds. g(same inputs) = same output, always. A gate that cannot be reproduced cannot be audited.

Pass 1 checks structure (and repairs a missing disclaimer before blocking). Pass 2 enforces hard gates, fail-closed. Pass 3 rules the aggregate alignment against theta. A blocked tool intent is fed back to the Intellect for a governed text response; it never redirects the whole turn.

Conscience

s_i, c_i = G_i(a_t, x_t, v_i),   s_i in [-1, 1],  c_i in [0, 1]

Each value is scored independently against its rubric. The weights are not the judge’s concern: they are applied afterwards, by Spirit, a component that never saw the response.

Spirit

A_t = sum(w_i * (s_i + 1)/2) / sum(w_i)          # confidence-free
critical_violation = any(hard_gate(v_i) and s_i <= -1)
raw = clip(sum(w_i * s_i * c_i), -1, 1)
S_t = round((raw + 1)/2 * 9 + 1)                 # confidence-weighted
p_t = w (element-wise) s_t
mu_t,i = beta*mu_{t-1,i} + (1-beta)*p_t,i  if v_i observed, else mu_{t-1,i}
d_t = 1 - cos_sim(p_t, mu_{t-1})

Two numbers, deliberately different. A_t ignores confidence because a gate should not be softened by the judge’s hesitancy; S_t includes it because a reported figure should reflect how well evidenced it was. An unscored value holds its memory rather than decaying toward neutral, and a turn nobody scored is a critical violation, not a pass.

What each faculty is denied

Phase Zero  no model, ever
Intellect   the rubrics, weights and scores; and no power to act
Will        no model; a pure function
Conscience  scores each value; the weights are applied later, by Spirit
Spirit      no model; deterministic EMA + cosine drift

Only the Intellect and the Conscience invoke a model. Any component satisfying the signatures above may substitute for an LLM in those two slots; the rest are fixed rules.