Delete bone_machine.py
Browse files- bone_machine.py +0 -539
bone_machine.py
DELETED
|
@@ -1,539 +0,0 @@
|
|
| 1 |
-
import random
|
| 2 |
-
from dataclasses import dataclass
|
| 3 |
-
from typing import Tuple, Optional, List, Dict, Any
|
| 4 |
-
|
| 5 |
-
from bone_body import BioSystem, MitochondrialState, Biometrics, MitochondrialForge, EndocrineSystem, MetabolicGovernor
|
| 6 |
-
from bone_brain import DreamEngine, ShimmerState
|
| 7 |
-
from bone_config import BoneConfig
|
| 8 |
-
from bone_core import LoreManifest
|
| 9 |
-
from bone_lexicon import LexiconService
|
| 10 |
-
from bone_physics import TheGatekeeper, QuantumObserver, SurfaceTension, ZoneInertia
|
| 11 |
-
from bone_protocols import LimboLayer
|
| 12 |
-
from bone_spores import MycelialNetwork, ImmuneMycelium, BioLichen, BioParasite
|
| 13 |
-
from bone_types import MindSystem, PhysSystem, PhysicsPacket, Prisma
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
class TheCrucible:
|
| 17 |
-
def __init__(self):
|
| 18 |
-
self.max_voltage_cap = getattr(BoneConfig.MACHINE, "CRUCIBLE_VOLTAGE_CAP", 20.0)
|
| 19 |
-
self.active_state = "COLD"
|
| 20 |
-
self.dampener_charges = 3
|
| 21 |
-
self.dampener_tolerance = getattr(
|
| 22 |
-
BoneConfig.MACHINE, "DAMPENER_TOLERANCE", 15.0
|
| 23 |
-
)
|
| 24 |
-
self.instability_index = 0.0
|
| 25 |
-
self.logs = self._load_logs()
|
| 26 |
-
|
| 27 |
-
@staticmethod
|
| 28 |
-
def _load_logs():
|
| 29 |
-
base = {
|
| 30 |
-
"DAMPER_EMPTY": "⚠️ DAMPER EMPTY",
|
| 31 |
-
"DAMPER_HIT": "🛡️ DAMPENER: -{reduction:.1f}v ({reason})",
|
| 32 |
-
"HOLDING": "Holding Charge",
|
| 33 |
-
"REGULATOR": "⚖️ REGULATOR: {direction} (Drag {current:.1f} -> {new:.1f})",
|
| 34 |
-
"SURGE": "⚡ SURGE: Absorbed {voltage}v.",
|
| 35 |
-
"RITUAL": "🔥 RITUAL: Capacity +{gain:.1f}v",
|
| 36 |
-
"MELTDOWN": "💥 MELTDOWN: Hull Breach (-{damage:.1f} HP)"
|
| 37 |
-
}
|
| 38 |
-
manifest = LoreManifest.get_instance().get("narrative_data") or {}
|
| 39 |
-
return manifest.get("CRUCIBLE_LOGS", base)
|
| 40 |
-
|
| 41 |
-
def dampener_status(self):
|
| 42 |
-
return f"🛡️ Charges: {self.dampener_charges}"
|
| 43 |
-
|
| 44 |
-
def dampen(
|
| 45 |
-
self, voltage_spike: float, stability_index: float
|
| 46 |
-
) -> Tuple[bool, str, float]:
|
| 47 |
-
if self.dampener_charges <= 0:
|
| 48 |
-
return False, "⚠️ DAMPER EMPTY", 0.0
|
| 49 |
-
should_dampen = False
|
| 50 |
-
reduction_factor = 0.0
|
| 51 |
-
reason = ""
|
| 52 |
-
if voltage_spike > self.dampener_tolerance:
|
| 53 |
-
should_dampen = True
|
| 54 |
-
reduction_factor = 0.7
|
| 55 |
-
reason = "Circuit Breaker"
|
| 56 |
-
elif voltage_spike > 8.0 and stability_index < 0.3:
|
| 57 |
-
should_dampen = True
|
| 58 |
-
reduction_factor = 0.4
|
| 59 |
-
reason = "Instability"
|
| 60 |
-
if should_dampen:
|
| 61 |
-
self.dampener_charges -= 1
|
| 62 |
-
reduction = voltage_spike * reduction_factor
|
| 63 |
-
msg = self.logs.get("DAMPER_HIT", "🛡️ Hit").format(reduction=reduction, reason=reason)
|
| 64 |
-
return True, msg, reduction
|
| 65 |
-
return False, self.logs.get("HOLDING", "Holding"), 0.0
|
| 66 |
-
|
| 67 |
-
def audit_fire(self, physics: Dict) -> Tuple[str, float, Optional[str]]:
|
| 68 |
-
voltage = physics.get("voltage", 0.0)
|
| 69 |
-
structure = physics.get("kappa", 0.0)
|
| 70 |
-
ideal_voltage = structure * 20.0
|
| 71 |
-
delta = voltage - ideal_voltage
|
| 72 |
-
self.instability_index = (self.instability_index * 0.7) + (delta * 0.3)
|
| 73 |
-
if abs(self.instability_index) < 0.1:
|
| 74 |
-
self.instability_index = 0.0
|
| 75 |
-
current_drag = physics.get("narrative_drag", 0.0)
|
| 76 |
-
adjustment = self.instability_index * 0.5
|
| 77 |
-
if current_drag < 1.0 and adjustment < 0:
|
| 78 |
-
adjustment *= 0.1
|
| 79 |
-
new_drag = max(0.0, min(10.0, current_drag + adjustment))
|
| 80 |
-
physics["narrative_drag"] = round(new_drag, 2)
|
| 81 |
-
msg = None
|
| 82 |
-
if abs(adjustment) > 0.1:
|
| 83 |
-
direction = "TIGHTENING" if adjustment > 0 else "RELAXING"
|
| 84 |
-
msg = self.logs.get("REGULATOR", "⚖️ REG").format(direction=direction, current=current_drag, new=new_drag)
|
| 85 |
-
if physics.get("system_surge_event", False):
|
| 86 |
-
self.active_state = "SURGE"
|
| 87 |
-
return "SURGE", 0.0, self.logs.get("SURGE", "⚡ SURGE").format(voltage=voltage)
|
| 88 |
-
if voltage > 18.0:
|
| 89 |
-
if structure > 0.5:
|
| 90 |
-
gain = voltage * 0.1
|
| 91 |
-
self.max_voltage_cap += gain
|
| 92 |
-
self.active_state = "RITUAL"
|
| 93 |
-
return "RITUAL", gain, self.logs.get("RITUAL", "🔥 RITUAL").format(gain=gain)
|
| 94 |
-
else:
|
| 95 |
-
damage = voltage * 0.5
|
| 96 |
-
self.active_state = "MELTDOWN"
|
| 97 |
-
return (
|
| 98 |
-
"MELTDOWN",
|
| 99 |
-
damage,
|
| 100 |
-
self.logs.get("MELTDOWN", "💥 MELTDOWN").format(damage=damage)
|
| 101 |
-
)
|
| 102 |
-
self.active_state = "REGULATED"
|
| 103 |
-
return "REGULATED", adjustment, msg
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
class TheForge:
|
| 107 |
-
def __init__(self):
|
| 108 |
-
gordon_data = LoreManifest.get_instance().get("gordon") or {}
|
| 109 |
-
raw_recipes = gordon_data.get("RECIPES", [])
|
| 110 |
-
self.recipe_map = {}
|
| 111 |
-
for r in raw_recipes:
|
| 112 |
-
ing = r.get("ingredient")
|
| 113 |
-
if ing:
|
| 114 |
-
if ing not in self.recipe_map:
|
| 115 |
-
self.recipe_map[ing] = []
|
| 116 |
-
self.recipe_map[ing].append(r)
|
| 117 |
-
|
| 118 |
-
@staticmethod
|
| 119 |
-
def hammer_alloy(physics: Dict) -> Tuple[bool, Optional[str], Optional[str]]:
|
| 120 |
-
counts = physics.get("counts", {})
|
| 121 |
-
clean_words = physics.get("clean_words", [])
|
| 122 |
-
if not clean_words:
|
| 123 |
-
return False, None, None
|
| 124 |
-
heavy = counts.get("heavy", 0)
|
| 125 |
-
kinetic = counts.get("kinetic", 0)
|
| 126 |
-
avg_density = ((heavy * 2.0) + (kinetic * 0.5)) / len(clean_words)
|
| 127 |
-
if random.random() >= (physics.get("voltage", 0) / 20.0) * avg_density:
|
| 128 |
-
return False, None, None
|
| 129 |
-
if heavy > 3:
|
| 130 |
-
return True, f"🔨 FORGED: Lead Boots (Mass {avg_density:.1f})", "LEAD_BOOTS"
|
| 131 |
-
if kinetic > 3:
|
| 132 |
-
return True, "🔨 FORGED: Safety Scissors (Kinetic)", "SAFETY_SCISSORS"
|
| 133 |
-
return True, "🔨 FORGED: Anchor Stone", "ANCHOR_STONE"
|
| 134 |
-
|
| 135 |
-
def attempt_crafting(
|
| 136 |
-
self, physics: Dict, inventory_list: List[str]
|
| 137 |
-
) -> Tuple[bool, Optional[str], Optional[str], Optional[str]]:
|
| 138 |
-
if not inventory_list:
|
| 139 |
-
return False, None, None, None
|
| 140 |
-
clean_words = physics.get("clean_words", [])
|
| 141 |
-
if not clean_words:
|
| 142 |
-
return False, None, None, None
|
| 143 |
-
clean_set = set(clean_words)
|
| 144 |
-
voltage = float(physics.get("voltage", 0))
|
| 145 |
-
for item in inventory_list:
|
| 146 |
-
if item in self.recipe_map:
|
| 147 |
-
for recipe in self.recipe_map[item]:
|
| 148 |
-
cat_words = LexiconService.get(recipe["catalyst_category"])
|
| 149 |
-
if not cat_words or clean_set.isdisjoint(cat_words):
|
| 150 |
-
continue
|
| 151 |
-
hits = len(clean_set.intersection(cat_words))
|
| 152 |
-
entanglement = self._calculate_entanglement(hits, voltage)
|
| 153 |
-
if random.random() < entanglement:
|
| 154 |
-
return (
|
| 155 |
-
True,
|
| 156 |
-
f"⚗️ ALCHEMY: {recipe['result']} (via {item})",
|
| 157 |
-
item,
|
| 158 |
-
recipe["result"],
|
| 159 |
-
)
|
| 160 |
-
else:
|
| 161 |
-
return (
|
| 162 |
-
False,
|
| 163 |
-
f"⚠️ ALCHEMY FAIL: Decoherence ({int(entanglement * 100)}%)",
|
| 164 |
-
None,
|
| 165 |
-
None,
|
| 166 |
-
)
|
| 167 |
-
return False, None, None, None
|
| 168 |
-
|
| 169 |
-
@staticmethod
|
| 170 |
-
def _calculate_entanglement(hit_count: int, voltage: float) -> float:
|
| 171 |
-
return min(1.0, 0.2 + (hit_count * 0.1) + (voltage / 133.0))
|
| 172 |
-
|
| 173 |
-
@staticmethod
|
| 174 |
-
def transmute(physics: Dict) -> Optional[str]:
|
| 175 |
-
counts = physics.get("counts", {})
|
| 176 |
-
voltage = float(physics.get("voltage", 0))
|
| 177 |
-
gamma = float(physics.get("gamma", 0.0))
|
| 178 |
-
if gamma < 0.15 and counts.get("abstract", 0) > 1:
|
| 179 |
-
return f"⚠️ EMULSION FAIL: Add Binder (Heavy)."
|
| 180 |
-
if voltage > 15.0:
|
| 181 |
-
return f"🌡️ OVERHEAT: {voltage:.1f}v. Add Coolant (Aerobic)."
|
| 182 |
-
return None
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
class TheTheremin:
|
| 186 |
-
def __init__(self):
|
| 187 |
-
self.decoherence_buildup = 0.0
|
| 188 |
-
self.classical_turns = 0
|
| 189 |
-
self.AMBER_THRESHOLD = 20.0
|
| 190 |
-
self.SHATTER_POINT = 100.0
|
| 191 |
-
self.is_stuck = False
|
| 192 |
-
self.logs = self._load_logs()
|
| 193 |
-
|
| 194 |
-
@staticmethod
|
| 195 |
-
def _load_logs():
|
| 196 |
-
base = {
|
| 197 |
-
"MELT": "🔥 MELT: -{val:.1f} Resin",
|
| 198 |
-
"CALCIFY": "🗿 CALCIFICATION: Turn {turns} (+{val:.1f} Resin)",
|
| 199 |
-
"SHATTER": "🔨 SHATTER: -{val:.1f} Resin",
|
| 200 |
-
"RESIN": "🎻 RESIN: +{val:.1f}",
|
| 201 |
-
"TURBULENCE": "🌊 TURBULENCE: -{val:.1f} Resin",
|
| 202 |
-
"COLLAPSE": "💣 COLLAPSE: AIRSTRIKE INITIATED (Drag +20, Voltage 0)"
|
| 203 |
-
}
|
| 204 |
-
manifest = LoreManifest.get_instance().get("narrative_data") or {}
|
| 205 |
-
return manifest.get("THEREMIN_LOGS", base)
|
| 206 |
-
|
| 207 |
-
def listen(
|
| 208 |
-
self, physics: Dict, governor_mode="COURTYARD"
|
| 209 |
-
) -> Tuple[bool, float, Optional[str], Optional[str]]:
|
| 210 |
-
counts = physics.get("counts", {})
|
| 211 |
-
voltage = float(physics.get("voltage", 0.0))
|
| 212 |
-
turb = float(physics.get("turbulence", 0.0))
|
| 213 |
-
rep = float(physics.get("repetition", 0.0))
|
| 214 |
-
complexity = float(physics.get("truth_ratio", 0.0))
|
| 215 |
-
ancient_mass = (
|
| 216 |
-
counts.get("heavy", 0) + counts.get("thermal", 0) + counts.get("cryo", 0)
|
| 217 |
-
)
|
| 218 |
-
modern_mass = counts.get("abstract", 0)
|
| 219 |
-
raw_mix = min(ancient_mass, modern_mass)
|
| 220 |
-
resin_flow = raw_mix * 2.0
|
| 221 |
-
if governor_mode == "LABORATORY":
|
| 222 |
-
resin_flow *= 0.5
|
| 223 |
-
if voltage > 5.0:
|
| 224 |
-
resin_flow = max(0.0, resin_flow - (voltage * 0.6))
|
| 225 |
-
thermal_hits = counts.get("thermal", 0)
|
| 226 |
-
theremin_msg = ""
|
| 227 |
-
melt_thresh = getattr(BoneConfig.MACHINE, "THEREMIN_MELT_THRESHOLD", 5.0)
|
| 228 |
-
critical_event = None
|
| 229 |
-
if thermal_hits > 0 and self.decoherence_buildup > melt_thresh:
|
| 230 |
-
dissolved = thermal_hits * 15.0
|
| 231 |
-
self.decoherence_buildup = max(0.0, self.decoherence_buildup - dissolved)
|
| 232 |
-
self.classical_turns = 0
|
| 233 |
-
theremin_msg = self.logs.get("MELT", "🔥 MELT").format(val=dissolved)
|
| 234 |
-
if rep > 0.5:
|
| 235 |
-
self.classical_turns += 1
|
| 236 |
-
slag = self.classical_turns * 2.0
|
| 237 |
-
self.decoherence_buildup += slag
|
| 238 |
-
theremin_msg = self.logs.get("CALCIFY", "🗿 CALCIFY").format(turns=self.classical_turns, val=slag)
|
| 239 |
-
elif complexity > 0.4 and self.classical_turns > 0:
|
| 240 |
-
self.classical_turns = 0
|
| 241 |
-
relief = 15.0
|
| 242 |
-
self.decoherence_buildup = max(0.0, self.decoherence_buildup - relief)
|
| 243 |
-
theremin_msg = self.logs.get("SHATTER", "🔨 SHATTER").format(val=relief)
|
| 244 |
-
elif resin_flow > 0.5:
|
| 245 |
-
self.decoherence_buildup += resin_flow
|
| 246 |
-
theremin_msg = self.logs.get("RESIN", "🎻 RESIN").format(val=resin_flow)
|
| 247 |
-
if turb > 0.6 and self.decoherence_buildup > 0:
|
| 248 |
-
shatter_amt = turb * 10.0
|
| 249 |
-
self.decoherence_buildup = max(0.0, self.decoherence_buildup - shatter_amt)
|
| 250 |
-
theremin_msg = self.logs.get("TURBULENCE", "🌊 TURBULENCE").format(val=shatter_amt)
|
| 251 |
-
self.classical_turns = 0
|
| 252 |
-
if turb < 0.2:
|
| 253 |
-
physics["narrative_drag"] = max(
|
| 254 |
-
0.0, float(physics.get("narrative_drag", 0)) - 1.0
|
| 255 |
-
)
|
| 256 |
-
if self.decoherence_buildup > self.SHATTER_POINT:
|
| 257 |
-
self.decoherence_buildup = 0.0
|
| 258 |
-
self.classical_turns = 0
|
| 259 |
-
if isinstance(physics, dict):
|
| 260 |
-
physics["narrative_drag"] = max(
|
| 261 |
-
physics.get("narrative_drag", 0.0) + 20.0, 20.0
|
| 262 |
-
)
|
| 263 |
-
physics["voltage"] = 0.0
|
| 264 |
-
return (
|
| 265 |
-
False,
|
| 266 |
-
resin_flow,
|
| 267 |
-
self.logs.get("COLLAPSE", "💣 COLLAPSE"),
|
| 268 |
-
"AIRSTRIKE",
|
| 269 |
-
)
|
| 270 |
-
if self.classical_turns > 3:
|
| 271 |
-
critical_event = "CORROSION"
|
| 272 |
-
theremin_msg = f"{theremin_msg or ''} | ⚠️ CORROSION"
|
| 273 |
-
if self.decoherence_buildup > self.AMBER_THRESHOLD:
|
| 274 |
-
self.is_stuck = True
|
| 275 |
-
theremin_msg = f"{theremin_msg or ''} | 🍯 STUCK"
|
| 276 |
-
elif self.is_stuck and self.decoherence_buildup < 5.0:
|
| 277 |
-
self.is_stuck = False
|
| 278 |
-
theremin_msg = f"{theremin_msg or ''} | 🦋 FREE"
|
| 279 |
-
return self.is_stuck, resin_flow, theremin_msg, critical_event
|
| 280 |
-
|
| 281 |
-
def get_readout(self):
|
| 282 |
-
status = "STUCK" if self.is_stuck else "FLOW"
|
| 283 |
-
return f"🎻 THEREMIN Resin {self.decoherence_buildup:.1f} Status {status}"
|
| 284 |
-
|
| 285 |
-
@dataclass
|
| 286 |
-
class SystemEmbryo:
|
| 287 |
-
mind: MindSystem
|
| 288 |
-
limbo: LimboLayer
|
| 289 |
-
bio: BioSystem
|
| 290 |
-
physics: PhysSystem
|
| 291 |
-
shimmer: Any
|
| 292 |
-
is_gestating: bool = True
|
| 293 |
-
soul_legacy: Optional[Dict] = None
|
| 294 |
-
continuity: Optional[Dict] = None
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
SAFE_BIO_DEFAULTS: Dict[str, Any] = {
|
| 298 |
-
"is_alive": True,
|
| 299 |
-
"atp": 10.0,
|
| 300 |
-
"respiration": "NECROSIS",
|
| 301 |
-
"enzyme": "NONE",
|
| 302 |
-
"chem": {
|
| 303 |
-
"DOP": 0.0, "COR": 0.0, "OXY": 0.0,
|
| 304 |
-
"SER": 0.0, "ADR": 0.0, "MEL": 0.0
|
| 305 |
-
},
|
| 306 |
-
}
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
class PanicRoom:
|
| 310 |
-
@staticmethod
|
| 311 |
-
def get_safe_physics():
|
| 312 |
-
safe_packet = PhysicsPacket.void_state()
|
| 313 |
-
safe_packet.voltage = 0.0
|
| 314 |
-
safe_packet.narrative_drag = 0.0
|
| 315 |
-
safe_packet.exhaustion = 0.0
|
| 316 |
-
safe_packet.beta_index = 0.0
|
| 317 |
-
safe_packet.psi = 0.0
|
| 318 |
-
safe_packet.chi = 0.0
|
| 319 |
-
safe_packet.entropy = 0.0
|
| 320 |
-
safe_packet.valence = 0.0
|
| 321 |
-
safe_packet.kappa = 0.0
|
| 322 |
-
safe_packet.psi = 0.0
|
| 323 |
-
safe_packet.chi = 0.0
|
| 324 |
-
safe_packet.entropy = 0.0
|
| 325 |
-
safe_packet.valence = 0.0
|
| 326 |
-
safe_packet.kappa = 0.0
|
| 327 |
-
safe_packet.vector = {
|
| 328 |
-
k: 0.0
|
| 329 |
-
for k in ["STR", "VEL", "PSI", "ENT", "PHI", "BET", "DEL", "LAMBDA", "CHI"]
|
| 330 |
-
}
|
| 331 |
-
safe_packet.clean_words = ["white", "room", "safe", "mode"]
|
| 332 |
-
safe_packet.raw_text = "[PANIC PROTOCOL]: SAFE_MODE. You will wake up in a white room. Do not be alarmed."
|
| 333 |
-
safe_packet.flow_state = "SAFE_MODE"
|
| 334 |
-
safe_packet.zone = "PANIC_ROOM"
|
| 335 |
-
safe_packet.manifold = "WHITE_ROOM"
|
| 336 |
-
return safe_packet
|
| 337 |
-
|
| 338 |
-
@staticmethod
|
| 339 |
-
def get_safe_bio(previous_state=None):
|
| 340 |
-
base = {"is_alive": True, "atp": 10.0, "respiration": "NECROSIS", "enzyme": "NONE", "chem": {
|
| 341 |
-
"DOP": 0.0,
|
| 342 |
-
"COR": 0.0,
|
| 343 |
-
"OXY": 0.0,
|
| 344 |
-
"SER": 0.0,
|
| 345 |
-
"ADR": 0.0,
|
| 346 |
-
"MEL": 0.0,
|
| 347 |
-
}, "logs": [
|
| 348 |
-
f"{Prisma.RED}BIO FAIL: Panic Room Protocol Active. Sensory input severed.{Prisma.RST}"
|
| 349 |
-
]}
|
| 350 |
-
state = previous_state or {}
|
| 351 |
-
if isinstance(state, dict):
|
| 352 |
-
if old_chem := state.get("chemistry", {}):
|
| 353 |
-
base["chem"]["COR"] = 0.0
|
| 354 |
-
base["chem"]["ADR"] = 0.0
|
| 355 |
-
base["chem"]["SER"] = max(0.2, old_chem.get("SER", 0.0))
|
| 356 |
-
return base
|
| 357 |
-
|
| 358 |
-
@staticmethod
|
| 359 |
-
def get_safe_mind():
|
| 360 |
-
return {
|
| 361 |
-
"lens": "GORDON",
|
| 362 |
-
"role": "Panic Room Overseer",
|
| 363 |
-
"thought": "SAFE_MODE. You will wake up in a white room. Do not be alarmed.",
|
| 364 |
-
}
|
| 365 |
-
|
| 366 |
-
@staticmethod
|
| 367 |
-
def get_safe_soul():
|
| 368 |
-
return {
|
| 369 |
-
"name": "Traveler",
|
| 370 |
-
"archetype": "The Survivor",
|
| 371 |
-
"virtues": {"resilience": 1.0},
|
| 372 |
-
"vices": {"amnesia": 1.0},
|
| 373 |
-
"narrative_arc": "RECOVERY",
|
| 374 |
-
"xp": 0,
|
| 375 |
-
}
|
| 376 |
-
|
| 377 |
-
@staticmethod
|
| 378 |
-
def get_safe_limbo():
|
| 379 |
-
return {
|
| 380 |
-
"mood": "NEUTRAL",
|
| 381 |
-
"volatility": 0.0,
|
| 382 |
-
"mask": "DEFAULT",
|
| 383 |
-
"glitch_factor": 0.0,
|
| 384 |
-
}
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
class ViralTracer:
|
| 388 |
-
def __init__(self, memory_ref):
|
| 389 |
-
self.memory = memory_ref
|
| 390 |
-
self.active_loops = []
|
| 391 |
-
|
| 392 |
-
@staticmethod
|
| 393 |
-
def inject(start_node: str) -> Optional[List[str]]:
|
| 394 |
-
if random.random() < 0.05:
|
| 395 |
-
return [start_node, "echo", "void", start_node]
|
| 396 |
-
return None
|
| 397 |
-
|
| 398 |
-
@staticmethod
|
| 399 |
-
def psilocybin_rewire(loop_path: List[str]) -> str:
|
| 400 |
-
return f"Rewired logic loop: {'->'.join(loop_path)}"
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
class ThePacemaker:
|
| 404 |
-
def __init__(self):
|
| 405 |
-
self.boredom_level = 0.0
|
| 406 |
-
self.heart_rate = 60
|
| 407 |
-
self.BOREDOM_THRESHOLD = getattr(BoneConfig, "BOREDOM_THRESHOLD", 10.0)
|
| 408 |
-
|
| 409 |
-
def beat(self, stress: float):
|
| 410 |
-
self.heart_rate = 60 + (stress * 20)
|
| 411 |
-
|
| 412 |
-
def update(self, repetition_score: float, voltage: float):
|
| 413 |
-
if repetition_score > 0.5 or voltage < 5.0:
|
| 414 |
-
self.boredom_level += 1.0
|
| 415 |
-
else:
|
| 416 |
-
self.boredom_level = max(0.0, self.boredom_level - 2.0)
|
| 417 |
-
|
| 418 |
-
def is_bored(self) -> bool:
|
| 419 |
-
return self.boredom_level > self.BOREDOM_THRESHOLD
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
class BoneArchitect:
|
| 423 |
-
@staticmethod
|
| 424 |
-
def _construct_mind(events, lex) -> Tuple[MindSystem, LimboLayer]:
|
| 425 |
-
from bone_village import MirrorGraph
|
| 426 |
-
|
| 427 |
-
_mem = MycelialNetwork(events)
|
| 428 |
-
limbo = LimboLayer()
|
| 429 |
-
_mem.cleanup_old_sessions(limbo)
|
| 430 |
-
lore = LoreManifest.get_instance()
|
| 431 |
-
mind = MindSystem(
|
| 432 |
-
mem=_mem,
|
| 433 |
-
lex=lex,
|
| 434 |
-
dreamer=DreamEngine(events, lore),
|
| 435 |
-
mirror=MirrorGraph(events),
|
| 436 |
-
tracer=ViralTracer(_mem),
|
| 437 |
-
)
|
| 438 |
-
return mind, limbo
|
| 439 |
-
|
| 440 |
-
@staticmethod
|
| 441 |
-
def _construct_bio(events, mind, lex) -> BioSystem:
|
| 442 |
-
genesis_val = getattr(BoneConfig.METABOLISM, "GENESIS_VOLTAGE", 100.0)
|
| 443 |
-
mito_state = MitochondrialState(atp_pool=genesis_val)
|
| 444 |
-
start_health = getattr(BoneConfig, "MAX_HEALTH", 100.0)
|
| 445 |
-
start_stamina = getattr(BoneConfig, "MAX_STAMINA", 100.0)
|
| 446 |
-
bio_metrics = Biometrics(health=start_health, stamina=start_stamina)
|
| 447 |
-
return BioSystem(
|
| 448 |
-
mito=MitochondrialForge(mito_state, events),
|
| 449 |
-
endo=EndocrineSystem(),
|
| 450 |
-
immune=ImmuneMycelium(),
|
| 451 |
-
lichen=BioLichen(),
|
| 452 |
-
governor=MetabolicGovernor(),
|
| 453 |
-
shimmer=ShimmerState(),
|
| 454 |
-
parasite=BioParasite(mind.mem, lex),
|
| 455 |
-
events=events,
|
| 456 |
-
biometrics=bio_metrics,
|
| 457 |
-
)
|
| 458 |
-
|
| 459 |
-
@staticmethod
|
| 460 |
-
def _construct_physics(events, bio, mind, lex) -> PhysSystem:
|
| 461 |
-
from bone_village import TheCartographer
|
| 462 |
-
|
| 463 |
-
gate = TheGatekeeper(lex, mind.mem)
|
| 464 |
-
return PhysSystem(
|
| 465 |
-
observer=QuantumObserver(events),
|
| 466 |
-
forge=TheForge(),
|
| 467 |
-
crucible=TheCrucible(),
|
| 468 |
-
theremin=TheTheremin(),
|
| 469 |
-
pulse=ThePacemaker(),
|
| 470 |
-
nav=TheCartographer(bio.shimmer),
|
| 471 |
-
gate=gate,
|
| 472 |
-
tension=SurfaceTension(),
|
| 473 |
-
dynamics=ZoneInertia(), # [FULLER] Gravity restored!
|
| 474 |
-
)
|
| 475 |
-
|
| 476 |
-
@staticmethod
|
| 477 |
-
def incubate(events, lex) -> SystemEmbryo:
|
| 478 |
-
if hasattr(events, "set_dormancy"):
|
| 479 |
-
events.set_dormancy(True)
|
| 480 |
-
events.log(
|
| 481 |
-
f"{Prisma.GRY}[ARCHITECT]: Laying foundations (Dormancy Active)...{Prisma.RST}",
|
| 482 |
-
"SYS",
|
| 483 |
-
)
|
| 484 |
-
mind, limbo = BoneArchitect._construct_mind(events, lex)
|
| 485 |
-
bio = BoneArchitect._construct_bio(events, mind, lex)
|
| 486 |
-
physics = BoneArchitect._construct_physics(events, bio, mind, lex)
|
| 487 |
-
return SystemEmbryo(
|
| 488 |
-
mind=mind, limbo=limbo, bio=bio, physics=physics, shimmer=bio.shimmer
|
| 489 |
-
)
|
| 490 |
-
|
| 491 |
-
@staticmethod
|
| 492 |
-
def awaken(embryo: SystemEmbryo) -> SystemEmbryo:
|
| 493 |
-
events = embryo.bio.mito.events
|
| 494 |
-
load_result = None
|
| 495 |
-
try:
|
| 496 |
-
if hasattr(embryo.mind.mem, "autoload_last_spore"):
|
| 497 |
-
load_result = embryo.mind.mem.autoload_last_spore()
|
| 498 |
-
except Exception as e:
|
| 499 |
-
events.log(
|
| 500 |
-
f"{Prisma.RED}[ARCHITECT]: Spore resurrection failed: {e}{Prisma.RST}",
|
| 501 |
-
"CRIT",
|
| 502 |
-
)
|
| 503 |
-
load_result = None
|
| 504 |
-
embryo.soul_legacy = {}
|
| 505 |
-
embryo.continuity = None
|
| 506 |
-
recovered_atlas = {}
|
| 507 |
-
if isinstance(load_result, (list, tuple)) and load_result:
|
| 508 |
-
padded_result = list(load_result) + [None] * (5 - len(load_result))
|
| 509 |
-
mito_legacy, immune_legacy, soul_legacy, continuity, atlas = padded_result[:5]
|
| 510 |
-
if mito_legacy and hasattr(embryo.bio.mito, "apply_inheritance"):
|
| 511 |
-
embryo.bio.mito.apply_inheritance(mito_legacy)
|
| 512 |
-
if immune_legacy and isinstance(immune_legacy, (list, set)) and hasattr(embryo.bio.immune, "load_antibodies"):
|
| 513 |
-
embryo.bio.immune.load_antibodies(immune_legacy)
|
| 514 |
-
if isinstance(soul_legacy, dict):
|
| 515 |
-
embryo.soul_legacy = soul_legacy
|
| 516 |
-
if isinstance(continuity, dict):
|
| 517 |
-
embryo.continuity = continuity
|
| 518 |
-
if isinstance(atlas, dict):
|
| 519 |
-
recovered_atlas = atlas
|
| 520 |
-
if recovered_atlas and hasattr(embryo.physics, "nav"):
|
| 521 |
-
if hasattr(embryo.physics.nav, "import_atlas"):
|
| 522 |
-
try:
|
| 523 |
-
embryo.physics.nav.import_atlas(recovered_atlas)
|
| 524 |
-
events.log(
|
| 525 |
-
f"{Prisma.MAG}[ARCHITECT]: World Map restored from Spore.{Prisma.RST}",
|
| 526 |
-
"SYS",
|
| 527 |
-
)
|
| 528 |
-
except Exception as e:
|
| 529 |
-
events.log(
|
| 530 |
-
f"{Prisma.OCHRE}[ARCHITECT]: Atlas corrupt, discarding map: {e}{Prisma.RST}",
|
| 531 |
-
"WARN",
|
| 532 |
-
)
|
| 533 |
-
if embryo.bio.mito.state.atp_pool <= 0.0:
|
| 534 |
-
genesis_val = getattr(BoneConfig.METABOLISM, "GENESIS_VOLTAGE", 100.0)
|
| 535 |
-
events.log(
|
| 536 |
-
f"⚡ COLD BOOT: Injecting Genesis Spark ({genesis_val} ATP).", "SYS"
|
| 537 |
-
)
|
| 538 |
-
embryo.bio.mito.adjust_atp(genesis_val, reason="GENESIS")
|
| 539 |
-
return embryo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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