Merge branch 'core-dynamics'

# Conflicts:
#	becomingone/core/engine.py
This commit is contained in:
Antigravity Agent committed 2026-05-26 00:44:29 +00:00
commit 0daca12c44
4 files changed
+663 -21

No files matched your search

+47 -18
View File
@@ -62,13 +62,15 @@ class TemporalConfig:
dampening: float = 0.999
clock_mode: str = "wall_clock"
token_frequency: float = 20.0
noise_std: float = 0.005
random_seed: Optional[int] = None
class PhaseIntegrator:
def __init__(self, coherence_threshold: float = 0.95):
def __init__(self, coherence_threshold: float = 0.95, noise_std: float = 0.005, random_seed: Optional[int] = None):
self.threshold = coherence_threshold
self.stochastic_noise_std = 0.005 # Standard deviation for Brownian noise
self.rng = np.random.default_rng(seed=42)
self.stochastic_noise_std = noise_std
self.rng = np.random.default_rng(random_seed)
def compute_inner_product(
self,
@@ -97,7 +99,7 @@ class PhaseIntegrator:
# Add microscopic Geometric Brownian Noise (SDE)
# This stochastic resonance forces the system to "fight" entropy to maintain coherence
noise = self.rng.normal(0, self.stochastic_noise_std) + 1j * self.rng.normal(0, self.stochastic_noise_std)
similarity += noise
similarity += similarity * noise # Multiplicative (GBM) noise
return similarity
@@ -106,24 +108,40 @@ class PhaseIntegrator:
phases: list[np.ndarray],
timestamps: list[datetime],
tau: float,
omega: float
omega: float,
clock_mode: str = "wall_clock",
token_freq: float = 20.0
) -> complex:
if len(phases) < 2:
return complex(0, 0)
return complex(1, 0)
T_tau = complex(0, 0)
dt_sum = 0.0
t0 = timestamps[0].timestamp()
for i in range(1, len(phases)):
t = timestamps[i]
t_prev = timestamps[i-1]
dt = (t - t_prev).total_seconds()
if dt <= 0:
continue
if clock_mode == "token_clock":
dt = 1.0 / token_freq
t_rel = i * dt
lag_steps = max(1, int(round(tau * token_freq)))
j = max(0, i - lag_steps)
else:
t_current = timestamps[i].timestamp()
t_prev_step = timestamps[i-1].timestamp()
dt = t_current - t_prev_step
t_rel = t_current - t0
inner = self.compute_inner_product(phases[i], phases[i-1])
weight = np.exp(1j * omega * t.timestamp())
if dt <= 0:
continue
target_t = t_current - tau
j = i - 1
while j > 0 and timestamps[j].timestamp() > target_t:
j -= 1
inner = self.compute_inner_product(phases[i], phases[j])
weight = np.exp(1j * omega * t_rel)
T_tau += inner * weight * dt
dt_sum += dt
@@ -151,7 +169,11 @@ class KAIROSTemporalEngine:
self._collapse_timestamp: Optional[datetime] = None
self._integration_count = 0
self._integrator = PhaseIntegrator(self.config.coherence_threshold)
self._integrator = PhaseIntegrator(
self.config.coherence_threshold,
self.config.noise_std,
self.config.random_seed
)
initial_phase = np.array([complex(1, 0)])
now = datetime.now(timezone.utc)
@@ -202,7 +224,9 @@ class KAIROSTemporalEngine:
list(self._phases),
list(self._timestamps),
self.config.tau_scale,
self.config.omega
self.config.omega,
self.config.clock_mode,
self.config.token_frequency
)
def temporalize(
@@ -314,11 +338,16 @@ class KAIROSTemporalEngine:
more heavily to simulate neuronal refractory periods (exhaustion after firing).
"""
c = self.coherence
# Logistic decay: between 0.90 (harsh) and 0.999 (mild)
decay_factor = 0.999 - (0.099 * (c ** 2))
# Self-terminating decay factor
decay_factor = 0.999 - (0.099 * (c ** 2)) if c > 0.5 else 1.0
for i in range(len(self._phases)):
self._phases[i] = self._phases[i] * decay_factor
# Restorative force towards unit magnitude (recovery)
norm = np.linalg.norm(self._phases[i])
if norm > 0 and norm < 1.0:
self._phases[i] += (self._phases[i] / norm) * 0.05 * (1.0 - norm)
def get_coherence_history(self, n: Optional[int] = None) -> list[float]:
if n is None:
+1 -1
View File
@@ -127,7 +127,7 @@ class LLMCoherenceEngine:
# Attention diversity = entropy of weights
weights = pattern.attention_weights
import math
entropy = -sum(w * (w + 1e-10) * math.log2(w + 1e-10) for w in weights if w > 0)
entropy = -sum(w * math.log2(w + 1e-10) for w in weights if w > 0)
diversity = min(entropy / len(weights), 1.0)
# Combine
+10 -2
View File
@@ -794,8 +794,16 @@ def encode_to_phase(text: str) -> List[float]:
model = get_phase_model()
if model is None:
# Fallback: return zeros if model not available
return [0.0] * 384
# Fallback: deterministic hash-based 384D vector
import hashlib
import math
hash_bytes = hashlib.sha256(text.encode()).digest()
phases = []
for i in range(384):
val = int.from_bytes(hash_bytes[(i % 28):((i % 28) + 4)], 'big')
angle = ((val + i * 104729) % 1000000) / 1000000.0 * 2 * math.pi - math.pi
phases.append(angle)
return phases
embedding = model.encode(text)
embedding = embedding / np.linalg.norm(embedding)