Beam pick example, structured logging, and privacy-first defaults.
J7) Example: beam pick (12 lines)
Single chooser call recovers a ranked candidate while preserving magnitudes.
from math import atanh, tanh
def rsi_candidate(items, c=1.0, eps_w=1e-12, eps_a=1e-6):
U_in = V_out = W = 0.0
for (e_in, e_out, w) in items:
a_in = tanh(-c * e_in); a_out = tanh(+c * e_out)
a_in = max(-1+eps_a, min(1-eps_a, a_in))
a_out = max(-1+eps_a, min(1-eps_a, a_out))
U_in += w * atanh(a_in); V_out += w * atanh(a_out); W += w
return tanh((V_out - U_in) / max(W, eps_w)) if W > 0 else 0.0
def pick_beam(beam, g_t=1.0):
scored = [(cid, g_t * rsi_candidate(items)) for (cid, items) in beam]
return max(scored, key=lambda kv: kv[1])[0]
What this shows
- Two-channel (support vs penalty) in one call
- Order-invariant scoring (shard/stream safe)
- Magnitudes untouched →
phi((m,a)) = m
J8) Logging schema (CSV/JSONL, replay-ready)
Minimal columns for drift dashboards and deterministic replay:
iso_utc, svc, knobs_hash, m, a, U, W, RSI, g_t, RSI_env, band, stamp
Replay identity:
a_out == tanh( sum(U) / max(sum(W), eps_w) )
phi((m,a)) = m
Note
- No free text → avoids leakage
- Stamps chain with
knobs_hashfor audit
J9) Security & privacy defaults
Practical posture for safe field deployment:
- PII-avoidance. Lenses consume declared, dimensionless aggregates only.
- Masking. Structured tags, no raw text in logs.
- Scopes. Alignment-only utilities; never mutate classical magnitudes.
- Bounded. All signals |a|<1, |RSI|<1, |RSI_env|<1.
- Fail-open for m. If any guard trips → routing by classical
m, with a stamped cause.
Why it matters
The SDK cannot leak content even if misconfigured upstream; alignment remains visible, bounded, deterministic — but magnitudes remain sacrosanct.
Navigation
Previous: SSM-AI – Appendix J — SDK Packaging & Golden Tests (J4–J6)
Next: SSM-AI – Appendix J — SDK Packaging & Golden Tests (J10 & One-line takeaway)
Directory of Pages
SSM-AI — Table of Contents