Guardrails, two-channel ranking code, and acceptance checks.
K7) Guardrails & Policies
- Parity. Classical retrieval stays intact:
phi((m,a)) = m. - Clamp. Enforce
|a| < 1witheps_a = 1e-6before anyatanh. - Visibility. Log
m_retrieval, RSI or a_search, band, g_t. - Search-safe defaults. Missing features ⇒ treat as
0, setRSI := 0(neutral), rely onm_retrieval. - Click/open policy (by band). A++/A+ open; A0 preview; A-/A– require extra confirmation.
- Shard/stream parity. Always merge via
(U,W)only; never averageaorRSIdirectly. - Determinism. Same manifest ⇒ identical ranking and bands.
K8) Pseudocode (two-channel lens + ranker)
def lens_search(feat, cfg):
p = cfg["alpha"]*feat.get("quality", 0.0) \
+ cfg["beta"] *feat.get("freshness", 0.0) \
+ cfg["gamma"]*feat.get("authority", 0.0)
n = cfg["delta"]*feat.get("risk_penalty", 0.0) \
+ cfg["eta"] *feat.get("coherence_penalty", 0.0)
a_out = tanh(cfg["c"] * p / max(cfg["Unit_out"], 1e-12))
a_in = tanh(-cfg["c"] * n / max(cfg["Unit_in"], 1e-12))
return a_in, a_out
def rank_results(items, cfg, g_t=1.0, eps_w=1e-12, eps_a=1e-6):
ranked = []
for it in items:
a_in, a_out = lens_search(it["feat"], cfg)
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 = atanh(a_in); V_out = atanh(a_out); W = 1.0
RSI = tanh((V_out - U_in) / max(W, eps_w))
RSI_e = g_t * RSI
ranked.append({"doc_id": it["doc_id"], "m": it["m"], "RSI": RSI, "RSI_env": RSI_e})
return sorted(ranked, key=lambda r: (r["RSI_env"], r["m"]), reverse=True)
Notes
- Primary ranker:
RSI_env(orRSIifg_t=1). - Tie-break:
m_retrievalto preserve legacy behavior. - Bands: Use A++/A+/A0/A-/A– for UI/policy, not for averaging.
K9) Acceptance Checklist (must pass)
- Order/shard invariance. Shuffle and per-shard merges reproduce identical lists (via
(U,W)). - Boundedness.
a_search,RSI,RSI_envstrictly in(-1, +1); bands per manifest thresholds. - Parity.
m_retrievalexactly matches the baseline system. - Drift sanity. Hour/day roll-ups from
(U,W)yield the samea_poolacross pipelines. - Determinism. Identical manifest ⇒ identical ranking, bands, and stamps.
Navigation
Previous: SSM-AI – Appendix K — SSM-Search (K4–K6)
Next: SSM-AI – Appendix L — Governance Quick Reference (L1–L3)
Directory of Pages
SSM-AI — Table of Contents