SSM-AI – Appendix D — Reference Pseudocode, Checklist & Manifest Keys (D4–D6)

Concise glue code, pass/fail checks, and a manifest snippet you can paste today.

D4) Reference pseudocode (concise, glueable)

def rsi_from_e(e_items, c=1.0, eps_w=1e-12, eps_a=1e-6,
               w_policy="uniform", gamma=1.0):
    U_in = V_out = W_in = 0.0
    for (e_in, e_out, m_or_w) in e_items:
        w = (abs(m_or_w)**gamma) if (w_policy=="abs_m_gamma") else 1.0
        a_in  = tanh(-c*e_in);  a_out = tanh(+c*e_out)
        U_in += w * atanh(max(-1+eps_a, min(1-eps_a, a_in  )))
        V_out+= w * atanh(max(-1+eps_a, min(1-eps_a, a_out )))
        W_in += w
    return 0.0 if W_in <= 0 else tanh((V_out - U_in) / max(W_in, eps_w))

def fuse_init(eps_w=1e-12):
    return {"U": 0.0, "W": 0.0, "eps_w": eps_w}

def fuse_add(state, a, w=1.0, eps_a=1e-6):
    a_c = max(-1+eps_a, min(1-eps_a, a))
    state["U"] += w * atanh(a_c)
    state["W"] += w

def fuse_merge(state, other):
    state["U"] += other["U"]; state["W"] += other["W"]

def fuse_value(state):
    return tanh(state["U"] / max(state["W"], state["eps_w"]))

def gate_apply(RSI, g, mode="mul"):
    return (g*RSI) if mode == "mul" else tanh(g*atanh(RSI))

def path_init(eps_a=1e-6, eps_w=1e-12):
    return {"U": 0.0, "W": 0.0, "stack": [], "eps_a": eps_a, "eps_w": eps_w}

def path_push(path, RSI_used, w=1.0, beta=0.0, b=0.0):
    a_c = max(-1+path["eps_a"], min(1-path["eps_a"], RSI_used))
    u_step = atanh(a_c) + beta*b
    path["U"] += w * u_step
    path["W"] += w
    path["stack"].append((w*u_step, w))

def path_pop(path):
    if not path["stack"]: return
    dU, dW = path["stack"].pop()
    path["U"] -= dU; path["W"] -= dW

def path_value(path):
    return tanh(path["U"] / max(path["W"], path["eps_w"]))
# Classical numbers stay pristine everywhere: phi((m,a)) = m

D5) Acceptance checklist (must pass)

# Parity
phi((m,a)) = m across all SDK flows

# Clamp discipline
|clamp_align(a)| < 1; never call atanh(±1)

# Order/shard invariance
fuse_value identical under permutations; fuse_merge is associative/commutative on (U,W)

# Bounds
All RSI, RSI_env, RSI_path in (-1,+1); bands map per thresholds

# Gate purity
gate_apply changes alignment only (RSI_env); m is never mutated

# Determinism
Golden vectors reproduce within dtype tolerance; same manifest ⇒ same outputs

# Numeric policy
Prefer float64 internally; dtype-aware eps_a, eps_w; guard means with max(W, eps_w)

# Division policy (lane M2)
Lane mul/div via tanh(atanh(a1) ± atanh(a2)); magnitude math remains classical

D6) Manifest keys (SDK expectations)

{
  "eps_a": 1e-6,
  "eps_w": 1e-12,
  "weights": {"policy": "uniform", "gamma": 1.0},        # or {"policy":"abs_m_gamma","gamma":1.0}
  "combine_policy": "M2",
  "division_policy": "strict",
  "lens": {"Unit": 1.0, "c": 1.0},
  "gate": {"mode": "mul", "rho": 0.20, "g_min": 0.00},
  "bands": {"A++":0.90, "A+":0.60, "A0":-0.60, "A-":-0.90, "A--":-1.00}
}

One-line takeaway. Glue these three blocks into any stack to lock semantics to clamp → atanh → add in u → divide → tanh with (U,W) fusion — bounded, shard-proof, deterministic — while classical values remain untouched via phi((m,a)) = m.


Navigation
Previous: SSM-AI – Appendix D — Starter SDK & Golden Vectors (D1–D3)
Next: SSM-AI – Appendix E — Vendor Bake-off Protocol (fair, bounded, reproducible)


Directory of Pages
SSM-AI — Table of Contents