Delete bone_drivers.py
Browse files- bone_drivers.py +0 -425
bone_drivers.py
DELETED
|
@@ -1,425 +0,0 @@
|
|
| 1 |
-
import json, os, random
|
| 2 |
-
from dataclasses import dataclass, field
|
| 3 |
-
from typing import Dict, Tuple, List, Optional, Any
|
| 4 |
-
from bone_core import LoreManifest
|
| 5 |
-
from bone_config import BonePresets
|
| 6 |
-
from bone_lexicon import LexiconService
|
| 7 |
-
from bone_types import PhysicsPacket
|
| 8 |
-
|
| 9 |
-
SCENARIOS = LoreManifest.get_instance().get("scenarios") or {
|
| 10 |
-
"ARCHETYPES": ["Void"],
|
| 11 |
-
"BANNED_CLICHES": [],
|
| 12 |
-
}
|
| 13 |
-
LENSES = (LoreManifest.get_instance().get("narrative_data") or {}).get("lenses", {})
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
class SoulDriver:
|
| 17 |
-
ARCHETYPE_TO_PERSONA_WEIGHT = {
|
| 18 |
-
"THE POET": {"NATHAN": 0.8, "JESTER": 0.4, "NARRATOR": 0.6},
|
| 19 |
-
"THE ENGINEER": {"GORDON": 0.9, "CLARENCE": 0.7, "SHERLOCK": 0.5},
|
| 20 |
-
"THE NIHILIST": {"NARRATOR": 0.9, "CLARENCE": 0.3, "JESTER": -0.5},
|
| 21 |
-
"THE CRITIC": {"CLARENCE": 0.8, "SHERLOCK": 0.6, "GORDON": 0.2},
|
| 22 |
-
"THE EXPLORER": {"NATHAN": 0.7, "JESTER": 0.5, "SHERLOCK": 0.6},
|
| 23 |
-
"THE OBSERVER": {"NARRATOR": 1.0, "GORDON": 0.2},
|
| 24 |
-
}
|
| 25 |
-
|
| 26 |
-
def __init__(self, soul_ref):
|
| 27 |
-
self.soul = soul_ref
|
| 28 |
-
|
| 29 |
-
def get_influence(self) -> Dict[str, float]:
|
| 30 |
-
base_weights = {persona: 0.0 for persona in EnneagramDriver.WEIGHTS.keys()}
|
| 31 |
-
if not self.soul:
|
| 32 |
-
return base_weights
|
| 33 |
-
archetype = getattr(self.soul, "archetype", "THE OBSERVER")
|
| 34 |
-
mapping = self.ARCHETYPE_TO_PERSONA_WEIGHT.get(archetype, {"NARRATOR": 1.0})
|
| 35 |
-
for persona, weight in mapping.items():
|
| 36 |
-
if persona in base_weights:
|
| 37 |
-
base_weights[persona] += weight
|
| 38 |
-
paradox = getattr(self.soul, "paradox_accum", 0.0)
|
| 39 |
-
chaos = min(0.5, (paradox - 5.0) * 0.05) if paradox > 5.0 else 0.0
|
| 40 |
-
dignity = 1.0
|
| 41 |
-
if hasattr(self.soul, "anchor") and hasattr(self.soul.anchor, "dignity_reserve"):
|
| 42 |
-
dignity = max(0.2, self.soul.anchor.dignity_reserve / 100.0)
|
| 43 |
-
return {
|
| 44 |
-
p: (w + random.uniform(-chaos, chaos)) * dignity
|
| 45 |
-
for p, w in base_weights.items()
|
| 46 |
-
}
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
class UserProfile:
|
| 50 |
-
def __init__(self, name="USER"):
|
| 51 |
-
self.name = name
|
| 52 |
-
self.affinities = {
|
| 53 |
-
"heavy": 0.0,
|
| 54 |
-
"kinetic": 0.0,
|
| 55 |
-
"abstract": 0.0,
|
| 56 |
-
"photo": 0.0,
|
| 57 |
-
"aerobic": 0.0,
|
| 58 |
-
"thermal": 0.0,
|
| 59 |
-
"cryo": 0.0,
|
| 60 |
-
}
|
| 61 |
-
self.confidence = 0
|
| 62 |
-
self.file_path = "user_profile.json"
|
| 63 |
-
self.load()
|
| 64 |
-
|
| 65 |
-
def update(self, counts, total_words):
|
| 66 |
-
if total_words < 3:
|
| 67 |
-
return
|
| 68 |
-
self.confidence += 1
|
| 69 |
-
alpha = 0.2 if self.confidence < 50 else 0.05
|
| 70 |
-
for cat in self.affinities:
|
| 71 |
-
density = counts.get(cat, 0) / total_words
|
| 72 |
-
target = 1.0 if density > 0.15 else (-0.5 if density == 0 else 0.0)
|
| 73 |
-
self.affinities[cat] = (alpha * target) + (
|
| 74 |
-
(1 - alpha) * self.affinities[cat]
|
| 75 |
-
)
|
| 76 |
-
|
| 77 |
-
def get_preferences(self):
|
| 78 |
-
likes = [k for k, v in self.affinities.items() if v > 0.3]
|
| 79 |
-
hates = [k for k, v in self.affinities.items() if v < -0.2]
|
| 80 |
-
return likes, hates
|
| 81 |
-
|
| 82 |
-
def save(self):
|
| 83 |
-
try:
|
| 84 |
-
with open(self.file_path, "w") as f:
|
| 85 |
-
json.dump(self.__dict__, f)
|
| 86 |
-
except IOError:
|
| 87 |
-
pass
|
| 88 |
-
|
| 89 |
-
def load(self):
|
| 90 |
-
if os.path.exists(self.file_path):
|
| 91 |
-
try:
|
| 92 |
-
with open(self.file_path) as f:
|
| 93 |
-
data = json.load(f)
|
| 94 |
-
self.affinities = data.get("affinities", self.affinities)
|
| 95 |
-
self.confidence = data.get("confidence", 0)
|
| 96 |
-
except (IOError, json.JSONDecodeError):
|
| 97 |
-
pass
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
class EnneagramDriver:
|
| 101 |
-
WEIGHTS = {
|
| 102 |
-
"JESTER": {
|
| 103 |
-
"tension_min": 12.0,
|
| 104 |
-
"vectors": {"DEL": 4.0, "ENT": 4.0, "PSI": -3.0},
|
| 105 |
-
},
|
| 106 |
-
"GORDON": {"drag_min": 3.0, "vectors": {"STR": 3.0, "E": 3.0, "SUB": 2.0}},
|
| 107 |
-
"GLASS": {"coherence_max": 0.2, "vectors": {"LQ": 2.0, "VEL": 2.0}},
|
| 108 |
-
"CLARENCE": {
|
| 109 |
-
"coherence_min": 0.8,
|
| 110 |
-
"drag_min": 6.0,
|
| 111 |
-
"vectors": {"STR": 4.0, "BET": 3.0},
|
| 112 |
-
},
|
| 113 |
-
"NATHAN": {"tension_min": 8.0, "vectors": {"TMP": 3.0, "PHI": 2.0, "BIO": 2.0}},
|
| 114 |
-
"SHERLOCK": {
|
| 115 |
-
"tension_min": 10.0,
|
| 116 |
-
"vectors": {"PHI": 4.0, "VEL": 3.0, "PSI": 2.0},
|
| 117 |
-
},
|
| 118 |
-
"NARRATOR": {"safe_zone": True, "vectors": {"PSI": 4.0}},
|
| 119 |
-
}
|
| 120 |
-
|
| 121 |
-
def __init__(self, events_ref):
|
| 122 |
-
self.events = events_ref
|
| 123 |
-
self.current_persona = "NARRATOR"
|
| 124 |
-
self.pending_persona = None
|
| 125 |
-
self.stability_counter = 0
|
| 126 |
-
self.HYSTERESIS_THRESHOLD = 3
|
| 127 |
-
|
| 128 |
-
@staticmethod
|
| 129 |
-
def _get_phys_attr(physics, key, default=None):
|
| 130 |
-
if isinstance(physics, dict):
|
| 131 |
-
return physics.get(key, default)
|
| 132 |
-
return getattr(physics, key, default)
|
| 133 |
-
|
| 134 |
-
def _calculate_raw_persona(self, physics, soul_ref=None) -> Tuple[str, str, str]:
|
| 135 |
-
p_vec = self._get_phys_attr(physics, "vector", {}) or {}
|
| 136 |
-
p_vol = self._get_phys_attr(physics, "voltage", 0.0)
|
| 137 |
-
p_drag = self._get_phys_attr(physics, "narrative_drag", 0.0)
|
| 138 |
-
p_coh = self._get_phys_attr(physics, "kappa", 0.0)
|
| 139 |
-
p_zone = self._get_phys_attr(physics, "zone", "")
|
| 140 |
-
scores = {k: 0.0 for k in self.WEIGHTS.keys()}
|
| 141 |
-
scores["NARRATOR"] += 2.0
|
| 142 |
-
is_safe_metrics = 4.0 <= p_vol <= 10.0 and 0.5 <= p_drag <= 3.5
|
| 143 |
-
if p_zone == BonePresets.SANCTUARY.get("ZONE") or is_safe_metrics:
|
| 144 |
-
scores["NARRATOR"] += 6.0
|
| 145 |
-
scores["JESTER"] += 3.0
|
| 146 |
-
scores["GORDON"] -= 2.0
|
| 147 |
-
for persona, criteria in self.WEIGHTS.items():
|
| 148 |
-
if "tension_min" in criteria and p_vol > criteria["tension_min"]:
|
| 149 |
-
scores[persona] += 3.0
|
| 150 |
-
if "drag_min" in criteria and p_drag > criteria["drag_min"]:
|
| 151 |
-
scores[persona] += 5.0
|
| 152 |
-
if "coherence_min" in criteria and p_coh > criteria["coherence_min"]:
|
| 153 |
-
scores[persona] += 4.0
|
| 154 |
-
if "coherence_max" in criteria and p_coh < criteria["coherence_max"]:
|
| 155 |
-
scores[persona] += 4.0
|
| 156 |
-
for dim, weight in criteria.get("vectors", {}).items():
|
| 157 |
-
if (val := p_vec.get(dim, 0.0)) > 0.2:
|
| 158 |
-
scores[persona] += val * weight
|
| 159 |
-
if soul_ref:
|
| 160 |
-
soul_driver = SoulDriver(soul_ref)
|
| 161 |
-
influence = soul_driver.get_influence()
|
| 162 |
-
for persona, weight in influence.items():
|
| 163 |
-
scores[persona] += weight * 2.0
|
| 164 |
-
sorted_scores = sorted(scores.items(), key=lambda x: x[1], reverse=True)
|
| 165 |
-
winner, win_score = sorted_scores[0]
|
| 166 |
-
runner_up, run_score = sorted_scores[1]
|
| 167 |
-
if (win_score - run_score) < 0.5:
|
| 168 |
-
k1 = "THE OBSERVER" if winner == "NARRATOR" else winner
|
| 169 |
-
k2 = "THE OBSERVER" if runner_up == "NARRATOR" else runner_up
|
| 170 |
-
hybrid_key_a = f"{k1}_{k2}_HYBRID"
|
| 171 |
-
hybrid_key_b = f"{k2}_{k1}_HYBRID"
|
| 172 |
-
final_hybrid = None
|
| 173 |
-
if hybrid_key_a in LENSES:
|
| 174 |
-
final_hybrid = hybrid_key_a
|
| 175 |
-
elif hybrid_key_b in LENSES:
|
| 176 |
-
final_hybrid = hybrid_key_b
|
| 177 |
-
if final_hybrid:
|
| 178 |
-
return (
|
| 179 |
-
final_hybrid,
|
| 180 |
-
"SYNTHESIS",
|
| 181 |
-
f"Dialectic Resonance: {winner} + {runner_up}",
|
| 182 |
-
)
|
| 183 |
-
reason = (
|
| 184 |
-
f"Winner: {winner} ({scores[winner]:.1f}) [V:{p_vol:.1f} D:{p_drag:.1f}]"
|
| 185 |
-
)
|
| 186 |
-
state_map = {
|
| 187 |
-
"JESTER": "MANIC",
|
| 188 |
-
"GORDON": "TIRED",
|
| 189 |
-
"GLASS": "FRAGILE",
|
| 190 |
-
"CLARENCE": "RIGID",
|
| 191 |
-
"NATHAN": "WIRED",
|
| 192 |
-
"SHERLOCK": "FOCUSED",
|
| 193 |
-
"NARRATOR": "OBSERVING",
|
| 194 |
-
}
|
| 195 |
-
return winner, state_map.get(winner, "ACTIVE"), reason
|
| 196 |
-
|
| 197 |
-
def decide_persona(self, physics, soul_ref=None) -> Tuple[str, str, str]:
|
| 198 |
-
candidate, state_desc, reason = self._calculate_raw_persona(physics, soul_ref)
|
| 199 |
-
if candidate == self.current_persona:
|
| 200 |
-
self.stability_counter = 0
|
| 201 |
-
self.pending_persona = None
|
| 202 |
-
return self.current_persona, state_desc, reason
|
| 203 |
-
if candidate == self.pending_persona:
|
| 204 |
-
self.stability_counter += 1
|
| 205 |
-
else:
|
| 206 |
-
self.pending_persona = candidate
|
| 207 |
-
self.stability_counter = 1
|
| 208 |
-
if "HYBRID" in candidate:
|
| 209 |
-
self.current_persona = candidate
|
| 210 |
-
self.stability_counter = 0
|
| 211 |
-
self.pending_persona = None
|
| 212 |
-
return self.current_persona, state_desc, f"SHIFT: {reason}"
|
| 213 |
-
if self.stability_counter >= self.HYSTERESIS_THRESHOLD:
|
| 214 |
-
self.current_persona = candidate
|
| 215 |
-
self.stability_counter = 0
|
| 216 |
-
self.pending_persona = None
|
| 217 |
-
return self.current_persona, state_desc, f"SHIFT: {reason}"
|
| 218 |
-
return (
|
| 219 |
-
self.current_persona,
|
| 220 |
-
"STABLE",
|
| 221 |
-
f"Resisting {candidate} ({self.stability_counter}/{self.HYSTERESIS_THRESHOLD})",
|
| 222 |
-
)
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
@dataclass
|
| 226 |
-
class VSLState:
|
| 227 |
-
archetype: str = "EXPLORER"
|
| 228 |
-
E: float = 0.1
|
| 229 |
-
B: float = 0.3
|
| 230 |
-
L: float = 0.0
|
| 231 |
-
O: float = 1.0
|
| 232 |
-
active_modules: List[str] = field(default_factory=list)
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
class DriverRegistry:
|
| 236 |
-
def __init__(self, events_ref):
|
| 237 |
-
self.enneagram = EnneagramDriver(events_ref)
|
| 238 |
-
self.current_focus = "NONE"
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
class LiminalModule:
|
| 242 |
-
def __init__(self):
|
| 243 |
-
self.lambda_val = 0.0
|
| 244 |
-
self.godel_scars = 0
|
| 245 |
-
|
| 246 |
-
def analyze(self, text: str, physics_vector: Dict[str, float]) -> float:
|
| 247 |
-
liminal_vocab = LexiconService.get("liminal") or {
|
| 248 |
-
"void",
|
| 249 |
-
"silence",
|
| 250 |
-
"gap",
|
| 251 |
-
"absence",
|
| 252 |
-
"space",
|
| 253 |
-
}
|
| 254 |
-
words = text.lower().split()
|
| 255 |
-
|
| 256 |
-
void_hits = sum(1 for w in words if w in liminal_vocab)
|
| 257 |
-
lexical_lambda = min(1.0, void_hits * 0.15)
|
| 258 |
-
|
| 259 |
-
dark_matter_sparks = 0
|
| 260 |
-
if len(words) > 1:
|
| 261 |
-
categories = [LexiconService.get_current_category(w) for w in words]
|
| 262 |
-
for i in range(len(categories) - 1):
|
| 263 |
-
c1, c2 = categories[i], categories[i + 1]
|
| 264 |
-
if c1 and c2 and c1 != c2:
|
| 265 |
-
if (
|
| 266 |
-
c1 in ["heavy", "kinetic"]
|
| 267 |
-
and c2 in ["abstract", "liminal", "void"]
|
| 268 |
-
) or (c1 in ["abstract", "liminal", "void"] and c2 in ["heavy"]):
|
| 269 |
-
dark_matter_sparks += 1
|
| 270 |
-
|
| 271 |
-
dark_matter_lambda = min(1.0, dark_matter_sparks * 0.25)
|
| 272 |
-
|
| 273 |
-
vector_lambda = 0.0
|
| 274 |
-
if physics_vector:
|
| 275 |
-
vector_lambda = (
|
| 276 |
-
(physics_vector.get("PSI", 0) * 0.5)
|
| 277 |
-
+ (physics_vector.get("ENT", 0) * 0.3)
|
| 278 |
-
+ (physics_vector.get("DEL", 0) * 0.2)
|
| 279 |
-
)
|
| 280 |
-
|
| 281 |
-
raw_target = lexical_lambda + dark_matter_lambda + vector_lambda
|
| 282 |
-
self.lambda_val = (self.lambda_val * 0.7) + (raw_target * 0.15)
|
| 283 |
-
|
| 284 |
-
if self.lambda_val > 0.85:
|
| 285 |
-
self.godel_scars += 1
|
| 286 |
-
|
| 287 |
-
return min(1.0, self.lambda_val)
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
class SyntaxModule:
|
| 291 |
-
def __init__(self):
|
| 292 |
-
self.omega_val = 1.0
|
| 293 |
-
self.grammatical_stress = 0.0
|
| 294 |
-
|
| 295 |
-
def analyze(self, text: str, narrative_drag: float) -> float:
|
| 296 |
-
words = text.split()
|
| 297 |
-
if not words:
|
| 298 |
-
return 1.0
|
| 299 |
-
bureau_vocab = LexiconService.get("bureau_buzzwords") or set()
|
| 300 |
-
buzz_count = sum(1 for w in words if w.lower() in bureau_vocab)
|
| 301 |
-
avg_len = sum(len(w) for w in words) / len(words)
|
| 302 |
-
if (avg_len > 6.0 and narrative_drag > 5.0) or buzz_count > 0:
|
| 303 |
-
target_omega = 1.0
|
| 304 |
-
elif avg_len < 3.5 and narrative_drag < 1.0:
|
| 305 |
-
target_omega = 0.4
|
| 306 |
-
else:
|
| 307 |
-
target_omega = 0.7
|
| 308 |
-
punctuation_density = sum(1 for c in text if c in ",;:-") / max(1, len(words))
|
| 309 |
-
if punctuation_density > 0.2:
|
| 310 |
-
self.grammatical_stress += 0.2
|
| 311 |
-
target_omega -= 0.3
|
| 312 |
-
else:
|
| 313 |
-
self.grammatical_stress = max(0.0, self.grammatical_stress - 0.1)
|
| 314 |
-
self.omega_val = (self.omega_val * 0.8) + (max(0.1, target_omega) * 0.2)
|
| 315 |
-
return self.omega_val
|
| 316 |
-
|
| 317 |
-
class CongruenceValidator:
|
| 318 |
-
def __init__(self):
|
| 319 |
-
self.last_phi = 1.0
|
| 320 |
-
self._archetype_map = None
|
| 321 |
-
|
| 322 |
-
@property
|
| 323 |
-
def map(self):
|
| 324 |
-
if self._archetype_map is None:
|
| 325 |
-
try:
|
| 326 |
-
self._archetype_map = LoreManifest.get_instance().get("LENSES") or {}
|
| 327 |
-
except Exception:
|
| 328 |
-
self._archetype_map = {}
|
| 329 |
-
return self._archetype_map
|
| 330 |
-
|
| 331 |
-
def calculate_resonance(self, text: str, context: Any) -> float:
|
| 332 |
-
if not text:
|
| 333 |
-
return 0.0
|
| 334 |
-
raw_lens = getattr(context, "active_lens", "OBSERVER")
|
| 335 |
-
archetype = raw_lens.upper().replace("THE ", "")
|
| 336 |
-
tone_score = 0.8
|
| 337 |
-
target_data = self.map.get(archetype, {})
|
| 338 |
-
target_words = set()
|
| 339 |
-
if isinstance(target_data, dict):
|
| 340 |
-
if vocab_str := target_data.get("vocab", ""):
|
| 341 |
-
target_words.update(w.strip().lower() for w in vocab_str.split(","))
|
| 342 |
-
target_words.update(target_data.get("keywords", []))
|
| 343 |
-
if target_words:
|
| 344 |
-
words_to_check = (
|
| 345 |
-
set(context.clean_words) if hasattr(context, "clean_words") else set()
|
| 346 |
-
)
|
| 347 |
-
hits = len(words_to_check.intersection(target_words))
|
| 348 |
-
if hits > 0:
|
| 349 |
-
tone_score += 0.1 * hits
|
| 350 |
-
return min(1.5, tone_score)
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
class BoneConsultant:
|
| 354 |
-
def __init__(self):
|
| 355 |
-
self.state = VSLState()
|
| 356 |
-
self.active = True
|
| 357 |
-
self.liminal_mod = LiminalModule()
|
| 358 |
-
self.syntax_mod = SyntaxModule()
|
| 359 |
-
|
| 360 |
-
@staticmethod
|
| 361 |
-
def engage():
|
| 362 |
-
return "VSL HYPERVISOR: LATTICE REVEALED."
|
| 363 |
-
|
| 364 |
-
@staticmethod
|
| 365 |
-
def disengage():
|
| 366 |
-
return "VSL HYPERVISOR: RETURNING TO SURFACE MODE."
|
| 367 |
-
|
| 368 |
-
def update_coordinates(
|
| 369 |
-
self,
|
| 370 |
-
user_text: str,
|
| 371 |
-
bio_state: Optional[Dict] = None,
|
| 372 |
-
physics: Optional[PhysicsPacket] = None,
|
| 373 |
-
):
|
| 374 |
-
word_count = len(user_text.split())
|
| 375 |
-
self.state.E = min(1.0, self.state.E + (word_count * 0.002))
|
| 376 |
-
if bio_state and "fatigue" in bio_state:
|
| 377 |
-
self.state.E = max(self.state.E, bio_state["fatigue"] * 0.3)
|
| 378 |
-
phys_beta = 0.0
|
| 379 |
-
phys_vec = {}
|
| 380 |
-
drag = 0.0
|
| 381 |
-
if physics:
|
| 382 |
-
if hasattr(physics, "beta_index"):
|
| 383 |
-
phys_beta = physics.beta_index
|
| 384 |
-
if hasattr(physics, "vector"):
|
| 385 |
-
phys_vec = physics.vector
|
| 386 |
-
if hasattr(physics, "narrative_drag"):
|
| 387 |
-
drag = physics.narrative_drag
|
| 388 |
-
self.state.B = (self.state.B * 0.8) + (phys_beta * 0.2)
|
| 389 |
-
self.state.L = self.liminal_mod.analyze(user_text, phys_vec)
|
| 390 |
-
self.state.O = self.syntax_mod.analyze(user_text, drag)
|
| 391 |
-
if "[VSL_LIMINAL]" in user_text:
|
| 392 |
-
if "LIMINAL" not in self.state.active_modules:
|
| 393 |
-
self.state.active_modules.append("LIMINAL")
|
| 394 |
-
if "[VSL_SYNTAX]" in user_text:
|
| 395 |
-
if "SYNTAX" not in self.state.active_modules:
|
| 396 |
-
self.state.active_modules.append("SYNTAX")
|
| 397 |
-
|
| 398 |
-
def get_system_prompt(self, soul_snapshot: Optional[Dict] = None) -> str:
|
| 399 |
-
directives = []
|
| 400 |
-
if "LIMINAL" in self.state.active_modules or self.state.L > 0.7:
|
| 401 |
-
scar_note = f" (Godel Scars: {self.liminal_mod.godel_scars})" if self.liminal_mod.godel_scars > 0 else ""
|
| 402 |
-
directives.append(
|
| 403 |
-
f"ARCHETYPE: THE REVENANT. Read the dark matter between the words. Speak of the absences.{scar_note}"
|
| 404 |
-
)
|
| 405 |
-
elif "SYNTAX" in self.state.active_modules or self.state.O > 0.9:
|
| 406 |
-
stress_note = " The grammatical structure is fracturing. Punish jagged prose." if self.syntax_mod.grammatical_stress > 0.5 else ""
|
| 407 |
-
directives.append(
|
| 408 |
-
f"ARCHETYPE: THE BUREAU. Enforce structural rigidity. Correct grammar. Use bureaucratic jargon.{stress_note}"
|
| 409 |
-
)
|
| 410 |
-
else:
|
| 411 |
-
if self.state.E < 0.3:
|
| 412 |
-
directives.append("MODE: BUNNY HILL. Be warm, simple, welcoming.")
|
| 413 |
-
elif self.state.B > 0.6:
|
| 414 |
-
directives.append(
|
| 415 |
-
"MODE: PARADOX. Hold contradictory truths. Be Jester-like."
|
| 416 |
-
)
|
| 417 |
-
else:
|
| 418 |
-
directives.append("MODE: GLACIER. Deep, slow, resonant.")
|
| 419 |
-
if soul_snapshot:
|
| 420 |
-
arch = soul_snapshot.get("archetype", "UNKNOWN")
|
| 421 |
-
muse = (soul_snapshot.get("obsession") or {}).get(
|
| 422 |
-
"title", "None"
|
| 423 |
-
)
|
| 424 |
-
directives.append(f"NARRATIVE_LAYER: You are {arch}. MUSE: {muse}.")
|
| 425 |
-
return "\n".join(directives)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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