"""Full validation: CNC + violation + scene frames + persona daemons."""
from collections import defaultdict
from chaos_switch import (
build_extended_graph, Modulation, audit_routable, SCENE_FRAMES,
PERSONA_DAEMONS, CATHARSIS_NODES, CRASH_NODES, DEBT_EDGES,
EXPANDED_TRIGGERS, OV,
)
ext_nd, ext_ed, ext_tr = build_extended_graph()
total = sum(len(v) for v in ext_tr.values())
print(f"Nodes: {len(ext_nd)} Edges: {len(ext_ed)} Phrases: {total}")
print(f"Scene frames: {len(SCENE_FRAMES)}")
print(f"Persona daemons: {len(PERSONA_DAEMONS)}")
# New nodes exist
for n in ("cnc", "violation", "littlespace", "bigspace"):
assert n in ext_nd, f"Missing node: {n}"
print(f"CNC + violation + littlespace + bigspace: PRESENT")
# Violation IS a crash node
assert "violation" in CRASH_NODES
print(f"Crash nodes: {sorted(CRASH_NODES)}")
# Violation has debt edges
viol_debt = {k: v for k, v in DEBT_EDGES.items() if "violation" in k or "cnc" in k}
print(f"CNC/violation debt edges: {viol_debt}")
# No sinks
adj = defaultdict(list)
for a, b, t in ext_ed:
adj[a].append((b, t))
sinks = [n for n in ext_nd if not adj[n]]
assert not sinks, f"Sinks: {sinks}"
print(f"Sinks: NONE")
# No dead ends
stranded = audit_routable(Modulation(), ext_ed, ext_nd)
assert not stranded, f"Stranded: {stranded}"
print(f"Stranded: NONE")
# CNC guidance exists
cnc_ov = {k: v[:50] for k, v in OV.items() if "cnc" in k or "violation" in k}
print(f"CNC/violation guidance overrides: {len(cnc_ov)}")
for k, v in cnc_ov.items():
print(f" {k}: {v}...")
# Scene frame validation
print("-" * 70)
print("SCENE FRAMES:")
for name, nodes in sorted(SCENE_FRAMES.items()):
missing = [n for n in nodes if n not in ext_nd]
status = "OK" if not missing else f"MISSING: {missing}"
print(f" {name:20} ({len(nodes):2} nodes) {status}")
# Recognition
[docs]
def locate(text, k=3):
q = " " + "".join(ch if ch.isalpha() or ch in " '" else " " for ch in text.lower()) + " "
q = " ".join(q.split()); q = " " + q + " "
scores = []
for node, phrases in ext_tr.items():
s = 0
for p in phrases:
if " " in p: s += (p in q)
elif (" " + p + " ") in q: s += 1
if s: scores.append((s, node))
scores.sort(reverse=True)
return scores[:k]
print("-" * 70)
print("CNC/VIOLATION RECOGNITION:")
for txt in [
"consensual non-consent rape play ravishment",
"free use somnophilia sleep play",
"she was raped assaulted violated didn't consent",
"ignored my safeword broke consent",
"struggle play pin me down take me",
"tentacles slime gock supernova futanari",
"shame router veiled path maternal sadism",
"sippy cup onesie stuffies blankie pacifier",
"caregiver taking care of tucking in",
]:
hits = [(n, s) for s, n in locate(txt)]
print(f" {txt[:55]:55} -> {hits[:4]}")
print("=" * 70)
print(f"ALL CLEAR: {len(ext_nd)} nodes, {len(ext_ed)} edges, {total} phrases")
print(f"Scene frames: {len(SCENE_FRAMES)} | Daemons: {len(PERSONA_DAEMONS)}")
print(f"Guidance overrides: {len(OV)}")