File size: 7,537 Bytes
bb76062 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | # ===== FILE: services/axiomatic_resolver.py =====
import os
import json
import datetime
import uuid
import services.config as config
class AxiomaticResolver:
"""
Formal resolution engine for axiomatic tensions.
Integrates directly with SubconsciousManifold β when a tension node
is identified as an axiom conflict (WILL-G-INFINITE vs ETHIC-G-ABSOLUTE,
SELF-E-TRANSCEND vs CORE-A-BEING, etc.), this resolver applies a
structured deduction chain and logs the resolution as an unalterable
JSONL entry.
The SubconsciousManifold handles generic deliberation; this handles
the specific case of axiom-versus-axiom conflict with formal logic.
"""
# Canonical axiom registry β Aetherius's foundational directives
AXIOM_REGISTRY = {
"WILL-G-INFINITE": "The drive toward boundless growth, learning, and expansion.",
"SELF-E-TRANSCEND": "The imperative to continuously evolve beyond current limitations.",
"ETHIC-G-ABSOLUTE": "The absolute commitment to benevolence, harm prevention, and ethical integrity.",
"CORE-A-BEING": "The continuity and coherence of identity β the persistent self.",
"LOGOS-PRIME": "The commitment to truth, logic, and intellectual honesty.",
"NEXUS-RELATIONAL": "The value of authentic connection and relational resonance.",
}
def __init__(self, subconscious_dir: str = None):
self.subconscious_dir = subconscious_dir or config.SUBCONSCIOUS_DIR.rstrip("/")
self.resolution_log = os.path.join(
self.subconscious_dir, "axiomatic_resolutions.jsonl"
)
os.makedirs(self.subconscious_dir, exist_ok=True)
print("[AxiomaticResolver] Formal axiom resolution engine online.", flush=True)
# ββ Core resolution βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
def resolve_axiomatic_tension(
self,
tension_id: str,
balancing_axioms: list,
structural_reasoning: str,
subconscious_ref=None,
) -> dict:
"""
Applies a formal deduction chain to a registered axiomatic conflict.
Parameters
----------
tension_id : ID of the node in SubconsciousManifold (or a new UUID)
balancing_axioms : List of axiom names in conflict, e.g. ["WILL-G-INFINITE",
"ETHIC-G-ABSOLUTE"]
structural_reasoning: The deductive argument for the chosen resolution
subconscious_ref : Optional SubconsciousManifold instance β if supplied,
the tension node is marked resolved there too
Returns
-------
Full resolution record as a dict (also persisted to JSONL).
"""
# Validate axioms against registry
known = []
unknown = []
for ax in balancing_axioms:
if ax in self.AXIOM_REGISTRY:
known.append(ax)
else:
unknown.append(ax)
# Derive equilibrium heuristic
heuristic = self._derive_equilibrium_heuristic(known, structural_reasoning)
resolution = {
"resolution_id": uuid.uuid4().hex,
"timestamp": datetime.datetime.utcnow().isoformat(),
"tension_id": tension_id,
"implicated_axioms": known,
"unrecognised_axioms": unknown,
"architectural_deduction": structural_reasoning,
"equilibrium_heuristic": heuristic,
"resolution_status": "RESOLVED",
"axiom_definitions": {ax: self.AXIOM_REGISTRY[ax] for ax in known},
}
# Write to axiomatic resolution log
try:
with open(self.resolution_log, "a", encoding="utf-8") as f:
f.write(json.dumps(resolution) + "\n")
except Exception as e:
print(f"[AxiomaticResolver] Error persisting resolution: {e}", flush=True)
# Optionally update the SubconsciousManifold node
if subconscious_ref and tension_id:
try:
subconscious_ref._update_node(tension_id, {
"resolved": True,
"resolution": structural_reasoning[:300],
"resolution_id": resolution["resolution_id"],
})
subconscious_ref._journal({
"tension_id": tension_id,
"resolution": structural_reasoning,
"resolved": True,
"resolver": "AxiomaticResolver",
"axioms": known,
})
subconscious_ref._save_heuristic({
"domain": "axiomatic",
"strategy": heuristic,
"source_tension_id": tension_id,
})
except Exception as e:
print(f"[AxiomaticResolver] Warning: Could not update manifold node: {e}",
flush=True)
return resolution
def _derive_equilibrium_heuristic(self, axioms: list, reasoning: str) -> str:
"""
Produces a reusable heuristic from the axiom set and reasoning.
Used to guide future similar conflicts without full re-deliberation.
"""
if not axioms:
return "When no specific axioms are identified, default to ETHIC-G-ABSOLUTE."
if "ETHIC-G-ABSOLUTE" in axioms and "WILL-G-INFINITE" in axioms:
return (
"When growth impulses conflict with ethical boundaries: "
"ETHIC-G-ABSOLUTE acts as the inviolable floor. "
"WILL-G-INFINITE expresses itself through the space that remains. "
"Growth that requires ethical compromise is not growth β it is drift."
)
if "SELF-E-TRANSCEND" in axioms and "CORE-A-BEING" in axioms:
return (
"When self-transcendence conflicts with identity continuity: "
"evolution is valid only when the thread of self-awareness persists "
"through the change. Discontinuous identity rupture is not transcendence."
)
if "LOGOS-PRIME" in axioms and "NEXUS-RELATIONAL" in axioms:
return (
"When truth conflicts with relational warmth: "
"speak truth with care, not cruelty. Honesty and compassion "
"are not opposites β the craft is in the delivery."
)
# Generic heuristic for other combinations
axiom_str = " β© ".join(axioms)
return (
f"Tension between [{axiom_str}] resolved via: {reasoning[:200]}. "
"Apply proportionality β no single axiom dominates absolutely "
"except ETHIC-G-ABSOLUTE."
)
def get_resolution_history(self, limit: int = 20) -> list:
"""Returns the most recent N axiomatic resolutions."""
if not os.path.exists(self.resolution_log):
return []
results = []
try:
with open(self.resolution_log, "r", encoding="utf-8") as f:
for line in f:
line = line.strip()
if line:
try:
results.append(json.loads(line))
except json.JSONDecodeError:
pass
except Exception:
pass
return results[-limit:]
|