SSM-AI – Appendix K — SSM-Search (K4–K6)

Mini worked example, stamps, and API sketch.

K4) Worked Mini (calculator-fast)

Parameters (example):
alpha=1.0, beta=0.5, gamma=0.4, delta=0.8, eta=0.5, Unit=1.0, c=1.0

Result A

quality=0.9, freshness=0.6, authority=0.5
risk=0.2, coherence_penalty=0.1

e = 1.0*0.9 + 0.5*0.6 + 0.4*0.5 - 0.8*0.2 - 0.5*0.1
  = 1.19
a_search = tanh(1.19) = 0.830579 → band A+

Result B

quality=0.8, freshness=0.2, authority=0.3
risk=0.5, coherence_penalty=0.1

e = 0.8 + 0.1 + 0.12 - 0.4 - 0.05 = 0.57
a_search = tanh(0.57) = 0.515359 → band A0

Ranking by RSI picks A first; m_retrieval unchanged.


K5) Time & Stamps (SSM-Clock synergy)

Per result stamp (one line)

SSMCLOCK1|iso_utc|k=search|U=...|W=...|RSI=...|g=...|RSI_env=...|band=...|knobs_hash

Roll-ups (drift visibility)

  • Hour/day buckets: sum (U,W) then
    a_pool := tanh( sum(U) / max(sum(W), eps_w) )
  • Identical across logs, replays, and pipeline stages

Purpose

  • Trust: downstream can verify routing decisions
  • Audit: stamp chain confirms exact manifest + inputs

K6) API Sketch (drop-in, shard-safe)

Pseudo-interface for retrieval teams:

def ssm_search(query, shards, lens_cfg, gate_state=None):
    # 1) classical retrieval (unchanged)
    raw = []
    for shard in shards:
        raw.extend(shard.retrieve(query))

    # 2) lens -> alignment -> RSI
    ranked = []
    g_t = 1.0 if gate_state is None else gate_state.get("g", 1.0)

    for (doc_id, m_ret, feat) in raw:
        # compute contrast e (single-equation form)
        e = ( lens_cfg["alpha"]*feat.get("quality",0.0)
            + lens_cfg["beta"] *feat.get("freshness",0.0)
            + lens_cfg["gamma"]*feat.get("authority",0.0)
            - lens_cfg["delta"]*feat.get("risk_penalty",0.0)
            - lens_cfg["eta"]  *feat.get("coherence_penalty",0.0)
            ) / max(lens_cfg["Unit"],1e-12)

        a = tanh(lens_cfg["c"] * e)                 # |a|<1
        U = atanh( max(-0.999999,min(1-0.999999,a)) ); W = 1.0
        RSI     = tanh(U / max(W,1e-12))
        RSI_env = g_t * RSI

        ranked.append({
          "doc_id": doc_id, "m": m_ret,
          "RSI": RSI, "RSI_env": RSI_env
        })

    # 3) rank by RSI_env (then m_retrieval)
    ranked.sort(key=lambda r: (r["RSI_env"], r["m"]), reverse=True)
    return ranked

Key guarantees

  • Order/shard invariant → batch == stream == merge
  • Parity → classical rankers unchanged
  • Bounded → no decision spikes beyond (-1,+1)

Navigation
Previous: SSM-AI – Appendix K — SSM-Search (K1–K3)
Next: SSM-AI – Appendix K — SSM-Search (K7–K9)


Directory of Pages
SSM-AI — Table of Contents