RFTSystems commited on
Commit
8f7b2ac
·
verified ·
1 Parent(s): f9a51ca

Update codex/formulas.py

Browse files
Files changed (1) hide show
  1. codex/formulas.py +52 -20
codex/formulas.py CHANGED
@@ -1,28 +1,60 @@
 
1
  # Author: Liam Grinstead
2
- # Dynamic GVU-modulated fitness evaluation
3
 
4
- class Formula:
5
- def __init__(self, expression):
6
- self.expression = expression
7
 
8
- def evaluate(self, agent):
9
- # Extract collapse torque score
10
- torque_score = agent.get("collapse_overlay", {}).get("score", 10)
 
 
 
 
 
 
 
 
 
 
11
 
12
- # Parse tier level from "Tier_X"
13
- tier = agent.get("tier", "Tier_1")
14
- tier_level = int(tier.split("_")[1]) if "_" in tier else 1
 
 
 
 
15
 
16
- # Emotional resonance multiplier
17
- resonance_bonus = 1.5 if agent.get("emotional_resonance") else 1.0
 
18
 
19
- # Count symbolic operators
20
- operator_count = len(agent.get("symbolic_operators", []))
 
21
 
22
- # Final fitness score
23
- score = (torque_score * resonance_bonus) + (tier_level * 0.75) + (operator_count * 0.1)
24
- return round(score, 4)
25
 
26
- GVU_FORMULAS = {
27
- "Formula_20": Formula("−τ_eff / (τ_c + 19/20) P_standard τ_eff ⋅ ℯ ⋅ |grad_R_O − grad_T_P| / GVU")
28
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # formulas_rft.py
2
  # Author: Liam Grinstead
3
+ # RFT-native scoring: collapse energy, operator coupling, tier drift, GVU sealing
4
 
5
+ from math import exp
 
 
6
 
7
+ def rft_score(agent: dict) -> float:
8
+ # Required agent structure
9
+ # agent = {
10
+ # "id": "Agent_1032",
11
+ # "tier": "Tier_6",
12
+ # "collapse_overlay": {
13
+ # "tau_eff": 1.8, # effective collapse torque
14
+ # "beta_band": 0.65, # collapse band coefficient
15
+ # "operator_weights": {("R","O"):0.9,("T","P"):0.7} # symbolic couplings
16
+ # },
17
+ # "symbolic_operators": ["R","O","T","P"],
18
+ # "emotional_resonance": True
19
+ # }
20
 
21
+ overlay = agent.get("collapse_overlay", {})
22
+ tau_eff = overlay.get("tau_eff", 1.0)
23
+ beta = overlay.get("beta_band", 0.5)
24
+ weights = overlay.get("operator_weights", {})
25
+ tier = agent.get("tier", "Tier_1")
26
+ tier_level = int(tier.split("_")[1]) if "_" in tier else 1
27
+ resonance = 1.2 if agent.get("emotional_resonance") else 1.0
28
 
29
+ # Operator coupling magnitude: sum of weights with diminishing returns
30
+ coupling_sum = sum(weights.values())
31
+ coupling = coupling_sum / (1.0 + 0.25 * len(weights))
32
 
33
+ # Tier drift penalty: higher tiers resist collapse but pay drift tax
34
+ drift_penalty = 0.18 * tier_level
35
+ drift_resilience = 1.0 + 0.05 * (tier_level - 1)
36
 
37
+ # Collapse energy: tau_eff modulated by collapse band and coupling
38
+ collapse_energy = tau_eff * (0.6 + 0.4 * beta) * (1.0 + 0.35 * coupling)
 
39
 
40
+ # Coherence: exponential stabilizer tempered by drift
41
+ # Higher tau_eff increases energy but coherence saturates via exp(-penalty)
42
+ coherence = exp(- (0.22 * tau_eff + 0.08 * tier_level)) * (0.9 + 0.1 * beta)
43
+
44
+ # GVU seal factor: balances energy vs. coherence and drift
45
+ gvu = (collapse_energy * resonance * drift_resilience) * (0.7 + 0.6 * coherence) - drift_penalty
46
+
47
+ # Final score clamps to positive domain and rounds
48
+ score = max(0.0, gvu)
49
+ return round(score, 4)
50
+
51
+ def rft_invariants(agent: dict) -> dict:
52
+ # Canonical invariants for artifact export and registry
53
+ overlay = agent.get("collapse_overlay", {})
54
+ tier_level = int(agent.get("tier","Tier_1").split("_")[1]) if "_" in agent.get("tier","Tier_1") else 1
55
+ return {
56
+ "tau_eff": overlay.get("tau_eff", 1.0),
57
+ "beta_band": overlay.get("beta_band", 0.5),
58
+ "operator_count": len(agent.get("symbolic_operators", [])),
59
+ "tier_level": tier_level
60
+ }