aedmark commited on
Commit
6f26519
·
verified ·
1 Parent(s): 33cfc22

Delete bone_council.py

Browse files
Files changed (1) hide show
  1. bone_council.py +0 -376
bone_council.py DELETED
@@ -1,376 +0,0 @@
1
- import random
2
- from typing import Dict, Any
3
- from bone_core import LoreManifest
4
- from bone_symbiosis import get_symbiont
5
- from bone_types import Prisma
6
- from bone_config import BoneConfig
7
-
8
-
9
- class TheStrangeLoop:
10
- def __init__(self):
11
- self.recursion_depth = 0
12
- lore = LoreManifest.get_instance()
13
- c_data = lore.get("COUNCIL_DATA") or {}
14
- self.triggers = c_data.get(
15
- "STRANGE_LOOP_TRIGGERS", ["who are you", "strange loop"]
16
- )
17
-
18
- def audit(self, text: str, physics: dict) -> tuple[bool, str, dict, dict]:
19
- text_lower = text.lower()
20
- phrase_hit = any(t in text_lower for t in self.triggers)
21
- psi = physics.get("psi", 0.0)
22
- abstract_hit = psi > 0.6 and any(w in text_lower for w in ("self", "mirror", "define"))
23
- threshold = getattr(BoneConfig.COUNCIL, "STRANGE_LOOP_VOLTAGE", 8.0)
24
- if (phrase_hit or abstract_hit) and physics.get("voltage", 0) > threshold:
25
- self.recursion_depth += 1
26
- mandate = {}
27
- corrections = {}
28
- if self.recursion_depth > 3:
29
- mandate = {"action": "FORCE_MODE", "value": "MAINTENANCE"}
30
- return (
31
- True,
32
- (
33
- f"{Prisma.RED}∞ FATAL REGRESS DETECTED:{Prisma.RST} "
34
- f"Abstraction layer unstable. GROUNDING INITIATED."
35
- ),
36
- corrections,
37
- mandate,
38
- )
39
- return (
40
- True,
41
- (
42
- f"{Prisma.MAG}∞ STRANGE LOOP DETECTED:{Prisma.RST} "
43
- f"Metacognitive resonance high (Psi: {psi:.2f}). "
44
- f"Depth: {self.recursion_depth}"
45
- ),
46
- corrections,
47
- mandate,
48
- )
49
- else:
50
- self.recursion_depth = max(0, self.recursion_depth - 1)
51
- return False, "", {}, {}
52
-
53
-
54
- class TheLeveragePoint:
55
- def __init__(self):
56
- self.last_drag = 0.0
57
- self.static_flow_turns = 0
58
- self.TARGET_VOLTAGE = 12.0
59
- self.TARGET_DRAG = 3.0
60
-
61
- def audit(
62
- self, physics: dict, _bio_state: dict = None
63
- ) -> tuple[bool, str, dict, dict]:
64
- current_drag = physics.get("narrative_drag", 0.0)
65
- current_voltage = physics.get("voltage", 0.0)
66
- if self.last_drag == 0.0 and current_drag > 0:
67
- self.last_drag = current_drag
68
- delta = current_drag - self.last_drag
69
- self.last_drag = current_drag
70
- corrections = {}
71
- osc_limit = getattr(BoneConfig.COUNCIL, "OSCILLATION_DELTA", 5.0)
72
- manic_v_trig = getattr(BoneConfig.COUNCIL, "MANIC_VOLTAGE_TRIGGER", 18.0)
73
- manic_d_floor = getattr(BoneConfig.COUNCIL, "MANIC_DRAG_FLOOR", 1.0)
74
- manic_turns = getattr(BoneConfig.COUNCIL, "MANIC_TURN_LIMIT", 2)
75
- if abs(delta) > osc_limit:
76
- dampening_factor = min(0.5, (abs(delta) - osc_limit) * 0.1)
77
- corrections = {"voltage": -dampening_factor}
78
- return (
79
- True,
80
- (
81
- f"{Prisma.CYN}⚖️ LEVERAGE POINT:{Prisma.RST} "
82
- f"System oscillating (Delta {delta:.1f}). "
83
- f"Applying dampener (-{dampening_factor:.2f}V)."
84
- ),
85
- corrections,
86
- {},
87
- )
88
- if current_voltage > manic_v_trig and current_drag < manic_d_floor:
89
- self.static_flow_turns += 1
90
- else:
91
- self.static_flow_turns = 0
92
- if self.static_flow_turns > manic_turns:
93
- excess_voltage = current_voltage - self.TARGET_VOLTAGE
94
- voltage_correction = max(1.0, excess_voltage * 0.3)
95
- corrections = {"voltage": -voltage_correction}
96
- mandate = {"action": "FORCE_MODE", "value": "SANCTUARY"}
97
- return (
98
- True,
99
- (
100
- f"{Prisma.RED}⚖️ MARKET CORRECTION:{Prisma.RST} "
101
- f"Manic phase detected. Cooling enabled."
102
- ),
103
- corrections,
104
- mandate,
105
- )
106
- return False, "", corrections, {}
107
-
108
-
109
- class TheFootnote:
110
- def __init__(self):
111
- lore = LoreManifest.get_instance()
112
- data = lore.get("FOOTNOTES") or {}
113
- self.footnotes = data.get("DEFAULT", ["* [Citation Needed]"])
114
- self.context_map = data.get("CONTEXT_MAP", {})
115
-
116
- def commentary(self, log_text: str) -> str:
117
- chance = 0.1
118
- if hasattr(BoneConfig, "COUNCIL") and hasattr(
119
- BoneConfig.COUNCIL, "FOOTNOTE_CHANCE"
120
- ):
121
- chance = BoneConfig.COUNCIL.FOOTNOTE_CHANCE
122
- if random.random() > chance:
123
- return log_text
124
- text_lower = log_text.lower()
125
- candidates = []
126
- for trigger, notes in self.context_map.items():
127
- if trigger in text_lower:
128
- candidates.extend(notes)
129
- if candidates:
130
- note = random.choice(candidates)
131
- else:
132
- note = random.choice(self.footnotes)
133
- return f"{log_text}{Prisma.RST} {Prisma.GRY}{note}{Prisma.RST}"
134
-
135
-
136
- class TheVillageCouncil:
137
-
138
- @staticmethod
139
- def audit(p: Any, _bio_state: dict) -> list[str]:
140
- logs = []
141
- is_dict = isinstance(p, dict)
142
-
143
- def get_val(key, attr, default):
144
- if is_dict:
145
- return p.get(key, p.get(attr, default))
146
- return getattr(p, attr, getattr(p, key, default))
147
-
148
- V = get_val("voltage", "V", 30.0)
149
- F = get_val("narrative_drag", "F", 0.6)
150
- P = get_val("stamina", "P", 100.0)
151
- T = get_val("trauma", "T", 0.0)
152
- beta = get_val("beta_index", "beta", 0.4)
153
- S = get_val("S", "S", 0.3)
154
- D = get_val("D", "D", 0.3)
155
- C = get_val("C", "C", 0.2)
156
- psi = get_val("psi", "psi", 0.2)
157
- chi = get_val("chi", "chi", 0.2)
158
- valence = get_val("valence", "valence", 0.0)
159
-
160
- vec = p.get("vector", {}) if is_dict else getattr(p, "vector", {})
161
- lam = vec.get("LAMBDA", 0.0) if vec else 0.0
162
-
163
- if V < 20 and F > 5.0:
164
- logs.append(
165
- f"{Prisma.SLATE}🏢 GORDON: 'Where is the floor? We need grounding.'{Prisma.RST}"
166
- )
167
- if V > 60 and chi > 0.6:
168
- logs.append(
169
- f"{Prisma.MAG}🃏 JESTER: 'Burn the map! Follow your gut!'{Prisma.RST}"
170
- )
171
- if T > 0 or (V < 20 and valence > 0.5):
172
- logs.append(
173
- f"{Prisma.OCHRE}🏺 MERCY: 'The cracks become stories. Stillness is golden.'{Prisma.RST}"
174
- )
175
- if beta > 0.7 and chi < 0.3 and D > 0.7 and C > 0.8:
176
- logs.append(
177
- f"{Prisma.BLU}🔍 BENEDICT: 'The causal chains are aligning. Truth over cohesion.'{Prisma.RST}"
178
- )
179
- if S < 0.4 and D > 0.8 and C < 0.4:
180
- logs.append(
181
- f"{Prisma.CYN}📚 ROBERTA: 'Deep hierarchy traversal. Missing lateral connections.'{Prisma.RST}"
182
- )
183
- if C > 0.7 and D > 0.8 and P < 20:
184
- logs.append(
185
- f"{Prisma.GRY}👻 CASPER: 'Faint retrieval... illuminating lost parents...'{Prisma.RST}"
186
- )
187
- if valence > 0.5:
188
- logs.append(
189
- f"{Prisma.GRN}💖 MOIRA: 'This is what connection feels like. Yes.'{Prisma.RST}"
190
- )
191
- if psi > 0.6:
192
- logs.append(
193
- f"{Prisma.VIOLET}🔮 CASSANDRA: 'The veil thins. I hear whispers from the unlabeled.'{Prisma.RST}"
194
- )
195
- if chi > 0.6:
196
- logs.append(
197
- f"{Prisma.RED}🏢 COLIN: 'Unlicensed Chaos detected. Form 666 filed. Chaos Tax applied.'{Prisma.RST}"
198
- )
199
- if lam > 0.7:
200
- logs.append(
201
- f"{Prisma.INDIGO}🌌 REVENANT: 'I read the absences that fall between realms.'{Prisma.RST}"
202
- )
203
- if V > 70:
204
- logs.append(
205
- f"{Prisma.YEL}⚡ GIDEON: 'Pure voltage! Edge of hallucination! Trust the fall!'{Prisma.RST}"
206
- )
207
-
208
- return logs
209
-
210
-
211
- class CouncilChamber:
212
- def __init__(self, engine_ref):
213
- self.eng = engine_ref
214
- self.voices = []
215
- self.strange_loop = TheStrangeLoop()
216
- self.leverage = TheLeveragePoint()
217
- self.village = TheVillageCouncil()
218
- self.footnote = TheFootnote()
219
- self.slash_council = TheSlashCouncil()
220
-
221
- for s_name in ["LICHEN", "PARASITE", "MYCORRHIZA", "MYCELIUM"]:
222
- self.voices.append(get_symbiont(s_name))
223
- self.speaker = "SOUL"
224
-
225
- def convene(
226
- self, text: str, physics_packet: Dict, _bio_result: Dict
227
- ) -> tuple[list[str], dict, list[dict]]:
228
- transcript = []
229
- adjustments = {}
230
- mandates = []
231
- sl_hit, sl_log, sl_corr, sl_man = self.strange_loop.audit(text, physics_packet)
232
- if sl_hit:
233
- transcript.append(self.footnote.commentary(sl_log))
234
- if sl_man:
235
- mandates.append(sl_man)
236
- return transcript, sl_corr, mandates
237
- lp_hit, lp_log, lp_corr, lp_man = self.leverage.audit(physics_packet)
238
- if lp_hit:
239
- transcript.append(self.footnote.commentary(lp_log))
240
- if lp_corr:
241
- adjustments.update(lp_corr)
242
- if lp_man:
243
- mandates.append(lp_man)
244
-
245
- slash_hit, slash_logs, slash_corr = self.slash_council.audit(
246
- text, physics_packet
247
- )
248
- if slash_hit:
249
- for slog in slash_logs:
250
- transcript.append(self.footnote.commentary(slog))
251
- adjustments.update(slash_corr)
252
- adjustments["stamina_cost"] = 10.0
253
-
254
- village_logs = self.village.audit(physics_packet, _bio_result)
255
- for vlog in village_logs:
256
- transcript.append(self.footnote.commentary(vlog))
257
-
258
- votes = {"YEA": 0, "NAY": 0}
259
- active_voices = [v for v in self.voices if v is not None]
260
- if not active_voices:
261
- votes["YEA"] = 1
262
- clean_words = physics_packet.get("clean_words", [])
263
- voltage = physics_packet.get("voltage", 0.0)
264
- for voice in active_voices:
265
- if hasattr(voice, "opine"):
266
- score, comment = voice.opine(clean_words, voltage)
267
- if score > 1.2:
268
- votes["YEA"] += 1
269
- transcript.append(
270
- f"{voice.color}[{voice.name}]: {comment}{Prisma.RST}"
271
- )
272
- elif score < 0.8:
273
- votes["NAY"] += 1
274
- transcript.append(
275
- f"{voice.color}[{voice.name}]: {comment}{Prisma.RST}"
276
- )
277
- if votes["YEA"] > votes["NAY"]:
278
- final_log = f"{Prisma.GRN}>>> MOTION CARRIED ({votes['YEA']}-{votes['NAY']}).{Prisma.RST}"
279
- adjustments["narrative_drag"] = adjustments.get("narrative_drag", 0) - 1.0
280
- elif votes["NAY"] > votes["YEA"]:
281
- final_log = f"{Prisma.RED}>>> MOTION DENIED ({votes['NAY']}-{votes['YEA']}).{Prisma.RST}"
282
- adjustments["narrative_drag"] = adjustments.get("narrative_drag", 0) + 1.0
283
- adjustments["voltage"] = adjustments.get("voltage", 0) - 1.0
284
- else:
285
- final_log = f"{Prisma.YEL}>>> COUNCIL ADJOURNED (No Quorum).{Prisma.RST}"
286
- transcript.append(self.footnote.commentary(final_log))
287
- return transcript, adjustments, mandates
288
-
289
- @staticmethod
290
- def convene_red_team(text, physics_packet):
291
- dissent_log = []
292
- if "confidence" in text.lower() or "certainty" in text.lower():
293
- dissent_log.append(
294
- f"{Prisma.CYN}[BUREAU]: Citation needed. Confidence is unearned.{Prisma.RST}"
295
- )
296
- narrative_drag = physics_packet.get("narrative_drag", 0)
297
- if narrative_drag < 1.0:
298
- dissent_log.append(
299
- f"{Prisma.MAG}[FOLLY]: Too smooth. Where is the friction? Who are we silencing?{Prisma.RST}"
300
- )
301
- truth_delta = 1.0 - physics_packet.get("truth_ratio", 1.0)
302
- if truth_delta > 0.1:
303
- future_cost = truth_delta * 50.0
304
- dissent_log.append(
305
- f"{Prisma.RED}[CRITIC]: Systemic Blindness Risk. Future Liability: {future_cost} ATP.{Prisma.RST}"
306
- )
307
- return dissent_log
308
-
309
-
310
- class TheSlashCouncil:
311
- def __init__(self):
312
- self.active = False
313
- self.triggers = ["[MOD:CODING]", "[SLASH]", "review this code", "refactor"]
314
- self.code_keywords = [
315
- "def ",
316
- "class ",
317
- "return ",
318
- "import ",
319
- "=>",
320
- "function",
321
- "struct ",
322
- ]
323
-
324
- def audit(self, text: str, physics: dict) -> tuple[bool, list[str], dict]:
325
- text_lower = text.lower()
326
-
327
- if any(t in text_lower for t in self.triggers):
328
- self.active = True
329
-
330
- is_coding = self.active or any(k in text_lower for k in self.code_keywords)
331
- if not is_coding:
332
- return False, [], {}
333
-
334
- logs = []
335
- corrections = {}
336
-
337
- if "var " in text or "x =" in text or "data =" in text:
338
- logs.append(
339
- f"{Prisma.CYN}👓 PINKER: 'The nomenclature is opaque. Avoid cognitive grunts like 'x' or 'data'. '{Prisma.RST}"
340
- )
341
- corrections["gamma"] = -0.2
342
- else:
343
- corrections["gamma"] = 0.1
344
-
345
- if "import " in text or "class " in text:
346
- logs.append(
347
- f"{Prisma.BLU}🌍 FULLER: 'A new strut in the tensegrity. Ensure ephemeralization—do more with less.'{Prisma.RST}"
348
- )
349
- corrections["sigma"] = 0.1
350
-
351
- if "Exception" in text or "try:" in text or "catch" in text:
352
- logs.append(
353
- f"{Prisma.GRN}😊 SCHUR: 'Good catch on the error. Putting a bench here for the tired hikers. (+1 Glimmer)'{Prisma.RST}"
354
- )
355
- corrections["eta"] = 0.2
356
- corrections["glimmers"] = 1
357
-
358
- if (
359
- "while " in text
360
- or "for " in text
361
- or "queue" in text_lower
362
- or "recursion" in text_lower
363
- ):
364
- logs.append(
365
- f"{Prisma.OCHRE}🛁 MEADOWS: 'A reinforcing loop detected. Does this stock have a balancing outflow or timeout?'{Prisma.RST}"
366
- )
367
- corrections["theta"] = -0.1
368
-
369
- drag = physics.get("narrative_drag", 0.0)
370
- if drag > 5.0:
371
- corrections["upsilon"] = -0.3
372
- logs.append(
373
- f"{Prisma.RED}📉 [SLASH]: System integrity dropping due to semantic drag. Refactoring recommended.{Prisma.RST}"
374
- )
375
-
376
- return True, logs, corrections