Spaces:
Sleeping
Sleeping
Update codex/formulas.py
Browse files- codex/formulas.py +1 -31
codex/formulas.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
# codex/formulas.py
|
| 2 |
# Author: Liam Grinstead
|
| 3 |
# RFT-native scoring wrapped in Formula class, restoring GVU_FORMULAS for compatibility
|
| 4 |
|
|
@@ -9,13 +8,6 @@ class Formula:
|
|
| 9 |
self.expression = expression
|
| 10 |
|
| 11 |
def evaluate(self, agent: dict) -> float:
|
| 12 |
-
"""
|
| 13 |
-
RFT scoring:
|
| 14 |
-
- collapse_overlay: {'tau_eff': float, 'beta_band': float, 'operator_weights': {pair: weight}}
|
| 15 |
-
- tier: 'Tier_X'
|
| 16 |
-
- emotional_resonance: bool
|
| 17 |
-
- symbolic_operators: list[str]
|
| 18 |
-
"""
|
| 19 |
overlay = agent.get("collapse_overlay", {})
|
| 20 |
tau_eff = overlay.get("tau_eff", 1.0)
|
| 21 |
beta = overlay.get("beta_band", 0.5)
|
|
@@ -24,40 +16,18 @@ class Formula:
|
|
| 24 |
tier_level = int(tier.split("_")[1]) if "_" in tier else 1
|
| 25 |
resonance = 1.2 if agent.get("emotional_resonance") else 1.0
|
| 26 |
|
| 27 |
-
# Operator coupling magnitude with diminishing returns
|
| 28 |
coupling_sum = sum(weights.values())
|
| 29 |
coupling = coupling_sum / (1.0 + 0.25 * max(1, len(weights)))
|
| 30 |
|
| 31 |
-
# Tier drift dynamics
|
| 32 |
drift_penalty = 0.18 * tier_level
|
| 33 |
drift_resilience = 1.0 + 0.05 * (tier_level - 1)
|
| 34 |
|
| 35 |
-
# Collapse energy and coherence
|
| 36 |
collapse_energy = tau_eff * (0.6 + 0.4 * beta) * (1.0 + 0.35 * coupling)
|
| 37 |
coherence = exp(- (0.22 * tau_eff + 0.08 * tier_level)) * (0.9 + 0.1 * beta)
|
| 38 |
|
| 39 |
-
# GVU seal factor
|
| 40 |
gvu = (collapse_energy * resonance * drift_resilience) * (0.7 + 0.6 * coherence) - drift_penalty
|
| 41 |
-
|
| 42 |
score = max(0.0, gvu)
|
| 43 |
return round(score, 4)
|
| 44 |
|
| 45 |
-
|
| 46 |
-
# Restore GVU_FORMULAS so legacy imports work (e.g., falsifiability_bench.py)
|
| 47 |
GVU_FORMULAS = {
|
| 48 |
-
|
| 49 |
-
"Formula_20": Formula("−τ_eff / (τ_c + 19/20) ⋅ P_standard ⋅ τ_eff ⋅ ℯ ⋅ |grad_R_O − grad_T_P| / GVU")
|
| 50 |
-
}
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
# Optional helpers retained for downstream modules that expect invariant access
|
| 54 |
-
def rft_invariants(agent: dict) -> dict:
|
| 55 |
-
overlay = agent.get("collapse_overlay", {})
|
| 56 |
-
tier = agent.get("tier", "Tier_1")
|
| 57 |
-
tier_level = int(tier.split("_")[1]) if "_" in tier else 1
|
| 58 |
-
return {
|
| 59 |
-
"tau_eff": overlay.get("tau_eff", 1.0),
|
| 60 |
-
"beta_band": overlay.get("beta_band", 0.5),
|
| 61 |
-
"operator_count": len(agent.get("symbolic_operators", [])),
|
| 62 |
-
"tier_level": tier_level,
|
| 63 |
-
}
|
|
|
|
|
|
|
| 1 |
# Author: Liam Grinstead
|
| 2 |
# RFT-native scoring wrapped in Formula class, restoring GVU_FORMULAS for compatibility
|
| 3 |
|
|
|
|
| 8 |
self.expression = expression
|
| 9 |
|
| 10 |
def evaluate(self, agent: dict) -> float:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
overlay = agent.get("collapse_overlay", {})
|
| 12 |
tau_eff = overlay.get("tau_eff", 1.0)
|
| 13 |
beta = overlay.get("beta_band", 0.5)
|
|
|
|
| 16 |
tier_level = int(tier.split("_")[1]) if "_" in tier else 1
|
| 17 |
resonance = 1.2 if agent.get("emotional_resonance") else 1.0
|
| 18 |
|
|
|
|
| 19 |
coupling_sum = sum(weights.values())
|
| 20 |
coupling = coupling_sum / (1.0 + 0.25 * max(1, len(weights)))
|
| 21 |
|
|
|
|
| 22 |
drift_penalty = 0.18 * tier_level
|
| 23 |
drift_resilience = 1.0 + 0.05 * (tier_level - 1)
|
| 24 |
|
|
|
|
| 25 |
collapse_energy = tau_eff * (0.6 + 0.4 * beta) * (1.0 + 0.35 * coupling)
|
| 26 |
coherence = exp(- (0.22 * tau_eff + 0.08 * tier_level)) * (0.9 + 0.1 * beta)
|
| 27 |
|
|
|
|
| 28 |
gvu = (collapse_energy * resonance * drift_resilience) * (0.7 + 0.6 * coherence) - drift_penalty
|
|
|
|
| 29 |
score = max(0.0, gvu)
|
| 30 |
return round(score, 4)
|
| 31 |
|
|
|
|
|
|
|
| 32 |
GVU_FORMULAS = {
|
| 33 |
+
"Formula_20": Formula("−τ_eff / (τ_c + 19/20) ⋅ P_standard ⋅ τ_eff ⋅ ℯ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|