From 2ad9dce8f5718122b974c3780288082847964de3 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 21 Apr 2026 06:13:10 +0000 Subject: [PATCH 1/3] =?UTF-8?q?Rename=20guardian=20=E2=86=92=20theta:=20co?= =?UTF-8?q?re/guardian.py=20=E2=86=92=20core/theta.py,=20GuardianTensor=20?= =?UTF-8?q?=E2=86=92=20ThetaTensor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - core/theta.py: renamed from guardian.py; class GuardianTensor → ThetaTensor; removed ring_alias field from state() - core/pcna.py: import ThetaTensor from .theta; self.guardian → self.theta; state() rings dict drops duplicate "guardian" key, renames variable guardian_state → theta_state - core/merge.py: all .guardian. → .theta.; output keys dominant_guardian_coherence → dominant_theta_coherence, a/b_guardian_coherence_after → a/b_theta_coherence_after - core/zeta.py: _theta_gate_factor() uses .theta attribute https://claude.ai/code/session_018vyPzNQrgsLKq34wyyNY7W --- core/merge.py | 66 +++++++++++++++++----------------- core/pcna.py | 27 +++++++------- core/{guardian.py => theta.py} | 11 +++--- core/zeta.py | 4 +-- 4 files changed, 52 insertions(+), 56 deletions(-) rename core/{guardian.py => theta.py} (95%) diff --git a/core/merge.py b/core/merge.py index 18c88c5..3f7ff97 100644 --- a/core/merge.py +++ b/core/merge.py @@ -34,35 +34,35 @@ def absorb(dominant: PCNAEngine, donor: PCNAEngine) -> dict: _blend_core(dominant.psi, donor.psi, alpha) _blend_core(dominant.omega, donor.omega, alpha) - dominant.guardian.tensor = _fed_avg( - dominant.guardian.tensor, donor.guardian.tensor, alpha=1.0 - alpha + dominant.theta.tensor = _fed_avg( + dominant.theta.tensor, donor.theta.tensor, alpha=1.0 - alpha ) dominant.memory_l.tensor = _fed_avg( dominant.memory_l.tensor, donor.memory_l.tensor, alpha=0.8 ) - for i in range(min(len(dominant.guardian.circle_count), len(donor.guardian.circle_count))): - dominant.guardian.circle_count[i] = max( - dominant.guardian.circle_count[i], - donor.guardian.circle_count[i], + for i in range(min(len(dominant.theta.circle_count), len(donor.theta.circle_count))): + dominant.theta.circle_count[i] = max( + dominant.theta.circle_count[i], + donor.theta.circle_count[i], ) - dominant.guardian._recompute_coherence() + dominant.theta._recompute_coherence() dominant.memory_l._recompute_hub_avg() phi_c = round(dominant.phi.ring_coherence, 4) - guard_c = round(float(dominant.guardian.node_coherence.mean()), 4) + guard_c = round(float(dominant.theta.node_coherence.mean()), 4) return { "mode": "absorb", - "dominant_id": dominant.guardian.instance_id, - "donor_id": donor.guardian.instance_id, + "dominant_id": dominant.theta.instance_id, + "donor_id": donor.theta.instance_id, "donor_status": "retired", "dominant_phi_coherence": phi_c, - "dominant_guardian_coherence": guard_c, + "dominant_theta_coherence": guard_c, "dominant_psi_coherence": round(dominant.psi.ring_coherence, 4), "dominant_omega_coherence": round(dominant.omega.ring_coherence, 4), - "circle_counts_after": [int(v) for v in dominant.guardian.circle_count], + "circle_counts_after": [int(v) for v in dominant.theta.circle_count], "timestamp": time.time(), } @@ -79,19 +79,19 @@ def fork(parent: PCNAEngine) -> tuple[PCNAEngine, dict]: ) c_core._recompute_coherence() - child.guardian.tensor = np.clip( - parent.guardian.tensor + noise.normal(0, 0.01, parent.guardian.tensor.shape), 0.0, 1.0 + child.theta.tensor = np.clip( + parent.theta.tensor + noise.normal(0, 0.01, parent.theta.tensor.shape), 0.0, 1.0 ) child.memory_l.tensor = parent.memory_l.tensor.copy() - child.guardian.circle_count = parent.guardian.circle_count.copy() - child.guardian.blueprint_shards = parent.guardian.blueprint_shards[:] - child.guardian._recompute_coherence() + child.theta.circle_count = parent.theta.circle_count.copy() + child.theta.blueprint_shards = parent.theta.blueprint_shards[:] + child.theta._recompute_coherence() child.memory_l._recompute_hub_avg() result = { "mode": "fork", - "parent_id": parent.guardian.instance_id, - "child_id": child.guardian.instance_id, + "parent_id": parent.theta.instance_id, + "child_id": child.theta.instance_id, "parent_status": "continues", "child_status": "spawned", "child_phi_coherence": round(child.phi.ring_coherence, 4), @@ -113,35 +113,35 @@ def converge(a: PCNAEngine, b: PCNAEngine, alpha: float = 0.5) -> dict: core_a._recompute_coherence() core_b._recompute_coherence() - new_ga = _fed_avg(a.guardian.tensor, b.guardian.tensor, alpha) - new_gb = _fed_avg(b.guardian.tensor, a.guardian.tensor, alpha) + new_ga = _fed_avg(a.theta.tensor, b.theta.tensor, alpha) + new_gb = _fed_avg(b.theta.tensor, a.theta.tensor, alpha) new_mla = _fed_avg(a.memory_l.tensor, b.memory_l.tensor, alpha=0.6) new_mlb = _fed_avg(b.memory_l.tensor, a.memory_l.tensor, alpha=0.6) - a.guardian.tensor = new_ga - b.guardian.tensor = new_gb + a.theta.tensor = new_ga + b.theta.tensor = new_gb a.memory_l.tensor = new_mla b.memory_l.tensor = new_mlb - for i in range(min(len(a.guardian.circle_count), len(b.guardian.circle_count))): - avg = (int(a.guardian.circle_count[i]) + int(b.guardian.circle_count[i])) // 2 - a.guardian.circle_count[i] = avg - b.guardian.circle_count[i] = avg + for i in range(min(len(a.theta.circle_count), len(b.theta.circle_count))): + avg = (int(a.theta.circle_count[i]) + int(b.theta.circle_count[i])) // 2 + a.theta.circle_count[i] = avg + b.theta.circle_count[i] = avg - a.guardian._recompute_coherence() - b.guardian._recompute_coherence() + a.theta._recompute_coherence() + b.theta._recompute_coherence() a.memory_l._recompute_hub_avg() b.memory_l._recompute_hub_avg() return { "mode": "converge", - "instance_a": a.guardian.instance_id, - "instance_b": b.guardian.instance_id, + "instance_a": a.theta.instance_id, + "instance_b": b.theta.instance_id, "alpha": alpha, "a_phi_coherence_after": round(a.phi.ring_coherence, 4), "b_phi_coherence_after": round(b.phi.ring_coherence, 4), - "a_guardian_coherence_after": round(float(a.guardian.node_coherence.mean()), 4), - "b_guardian_coherence_after": round(float(b.guardian.node_coherence.mean()), 4), + "a_theta_coherence_after": round(float(a.theta.node_coherence.mean()), 4), + "b_theta_coherence_after": round(float(b.theta.node_coherence.mean()), 4), "a_psi_coherence_after": round(a.psi.ring_coherence, 4), "b_psi_coherence_after": round(b.psi.ring_coherence, 4), "a_omega_coherence_after": round(a.omega.ring_coherence, 4), diff --git a/core/pcna.py b/core/pcna.py index 2e219ae..1f4df34 100644 --- a/core/pcna.py +++ b/core/pcna.py @@ -34,7 +34,7 @@ from .ptca_core import PTCACore from .memory_core import MemoryCore -from .guardian import GuardianTensor +from .theta import ThetaTensor def _tensor_to_b64(arr: np.ndarray) -> str: @@ -71,12 +71,12 @@ def __init__(self, phases: int = 7): self.omega = PTCACore(name="omega", symbol="Ω", role="autonomy", n=53, seed=47, phases=phases) self.memory_l = MemoryCore(n=19, seed=19, role="long_term", phases=phases) self.memory_s = MemoryCore(n=17, seed=17, role="short_term", phases=phases) - self.guardian = GuardianTensor(phases=phases) + self.theta = ThetaTensor(phases=phases) self.infer_count = 0 self.reward_count = 0 self.last_coherence = 0.0 self.last_winner = "phi" - self.blueprint_hash = self.guardian.blueprint_hash + self.blueprint_hash = self.theta.blueprint_hash self.created_at = time.time() self.checkpoint_at: float | None = None self.checkpoint_ring_means: dict[str, float] = {} @@ -162,7 +162,7 @@ def _inject(self, signal: np.ndarray): self.phi._recompute_coherence() self.memory_s.write(signal) - theta_nc = self.guardian.node_coherence + theta_nc = self.theta.node_coherence theta_signal = np.full(53, float(theta_nc.mean()), dtype=np.float64) theta_signal[:len(theta_nc)] = theta_nc self.phi.inject(theta_signal) @@ -195,7 +195,7 @@ def _propagate(self): self.phi.propagate(steps=10) self.psi.propagate(steps=8) self.omega.propagate(steps=6) - self.guardian.propagate(steps=5) + self.theta.propagate(steps=5) def _ptca_seed_audit(self) -> dict: cores = {"phi": self.phi, "psi": self.psi, "omega": self.omega} @@ -210,7 +210,7 @@ def _ptca_seed_audit(self) -> dict: return result def _pcta_circle_audit(self) -> dict: - g_audit = self.guardian.pcta_circle_audit() + g_audit = self.theta.pcta_circle_audit() open_nodes = [n for n in g_audit if n["gate"]] closed_nodes = [n for n in g_audit if not n["gate"]] return { @@ -218,7 +218,7 @@ def _pcta_circle_audit(self) -> dict: "gates_open": len(open_nodes), "gates_closed": len(closed_nodes), "avg_circles": round(sum(n["circles"] for n in g_audit) / len(g_audit), 2), - "guardian_coherence": round(float(self.guardian.node_coherence.mean()), 4), + "guardian_coherence": round(float(self.theta.node_coherence.mean()), 4), "memory_l_hub_avg": self.memory_l.state()["avg_hub"], } @@ -272,7 +272,7 @@ def infer(self, text: str) -> dict: "coherence_score": coherence["weighted_coherence"], "winner": coherence["winner"], "confidence": coherence["confidence"], - "guardian_circles": int(self.guardian.circle_count.mean()), + "guardian_circles": int(self.theta.circle_count.mean()), "memory_l_state": self.memory_l.state(), "memory_s_state": self.memory_s.state(), } @@ -281,7 +281,7 @@ def reward(self, winner: str, outcome: float) -> dict: self.phi.nudge(outcome, lr=0.025) self.psi.nudge(outcome, lr=0.020) self.omega.nudge(outcome, lr=0.015) - self.guardian.apply_reward(outcome) + self.theta.apply_reward(outcome) flushed = self.memory_s.flush_to(self.memory_l, outcome) try: @@ -303,8 +303,8 @@ def reward(self, winner: str, outcome: float) -> dict: "phi_coherence_after": round(self.phi.ring_coherence, 4), "psi_coherence_after": round(self.psi.ring_coherence, 4), "omega_coherence_after": round(self.omega.ring_coherence, 4), - "theta_coherence_after": round(float(self.guardian.node_coherence.mean()), 4), - "guardian_circles_after": [int(v) for v in self.guardian.circle_count], + "theta_coherence_after": round(float(self.theta.node_coherence.mean()), 4), + "guardian_circles_after": [int(v) for v in self.theta.circle_count], "memory_l_flush_count": self.memory_l.flush_count, "memory_s_flush_count": self.memory_s.flush_count, } @@ -322,7 +322,7 @@ def state(self) -> dict: except Exception: sigma_state = {} - guardian_state = self.guardian.state() + theta_state = self.theta.state() return { "engine": "pcna", @@ -336,8 +336,7 @@ def state(self) -> dict: "phi": self.phi.state(), "psi": self.psi.state(), "omega": self.omega.state(), - "theta": guardian_state, - "guardian": guardian_state, + "theta": theta_state, "sigma": sigma_state, "memory_l": self.memory_l.state(), "memory_s": self.memory_s.state(), diff --git a/core/guardian.py b/core/theta.py similarity index 95% rename from core/guardian.py rename to core/theta.py index 69a4da7..592f432 100644 --- a/core/guardian.py +++ b/core/theta.py @@ -1,11 +1,10 @@ -# 130:12 """ -Θ (Theta) Guardian Tensor — N=29 prime-node microkernel ring. +Θ (Theta) — N=29 prime-node microkernel ring. - Ragged circle counts per seed: circleCount[i] in [1..12] - Hash-based instance/key identifiers derived with hashlib - SHA-256 blueprint hash sharded across all 29 nodes - Gate control: coherence threshold per node - - Phi injection mirror: node_coherence broadcast → Φ (Task #72) + - Phi injection mirror: node_coherence broadcast → Φ Architecturally unique — not parameterized like PTCACore. Self-declares identity in state() as symbol="Θ", name="theta". @@ -26,8 +25,8 @@ BLUEPRINT_CHUNK_SIZE = 4 -class GuardianTensor: - """Guardian microkernel ring — N=29 nodes, ragged circle counts.""" +class ThetaTensor: + """Theta microkernel ring — N=29 nodes, ragged circle counts.""" def __init__(self, instance_id: str | None = None, phases: int = 7): self.phases = phases @@ -126,7 +125,6 @@ def state(self) -> dict: "symbol": "Θ", "role": "microkernel", "ring": "theta", - "ring_alias": "guardian", "n": N, "instance_id": self.instance_id, "ring_coherence": round(float(self.node_coherence.mean()), 4), @@ -163,4 +161,3 @@ def _shard_blueprint(bp_hash: str, n: int) -> list[str]: shard = bp_hash[start:start + BLUEPRINT_CHUNK_SIZE] shards.append(shard.ljust(BLUEPRINT_CHUNK_SIZE, "0")) return shards -# 130:12 diff --git a/core/zeta.py b/core/zeta.py index e35a805..49c7590 100644 --- a/core/zeta.py +++ b/core/zeta.py @@ -197,9 +197,9 @@ def _theta_gate_factor(self) -> float: try: - guardian = _get_default_pcna().guardian + theta = _get_default_pcna().theta - open_frac = float(guardian.gate_open.mean()) + open_frac = float(theta.gate_open.mean()) return round(0.8 + open_frac * 0.4, 4) From 6d767196f2e54de619142e129894cdcda515d3ae Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 21 Apr 2026 21:53:58 +0000 Subject: [PATCH 2/3] =?UTF-8?q?Complete=20guardian=E2=86=92theta=20rename?= =?UTF-8?q?=20in=20pcna.py=20output=20keys=20and=20RING=5FWEIGHTS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address Codex P2 and Copilot review comments: all remaining guardian_* identifiers in PCNAEngine now use theta_* so ring_weights, rings dict, and all method return payloads are internally consistent. - RING_WEIGHTS: "guardian" → "theta" - _pcta_circle_audit(): guardian_nodes → theta_nodes, guardian_coherence → theta_coherence - _coherence_score(): ring_scores key "guardian" → "theta"; indexes circle_audit["theta_coherence"] - infer(): guardian_steps → theta_steps, guardian_circles → theta_circles - reward(): guardian_circles_after → theta_circles_after https://claude.ai/code/session_018vyPzNQrgsLKq34wyyNY7W --- core/pcna.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/core/pcna.py b/core/pcna.py index 1f4df34..0da1281 100644 --- a/core/pcna.py +++ b/core/pcna.py @@ -51,7 +51,7 @@ def _b64_to_tensor(s: str) -> np.ndarray: "phi": 0.30, "psi": 0.15, "omega": 0.15, - "guardian": 0.20, + "theta": 0.20, "memory_l": 0.12, "memory_s": 0.08, } @@ -214,11 +214,11 @@ def _pcta_circle_audit(self) -> dict: open_nodes = [n for n in g_audit if n["gate"]] closed_nodes = [n for n in g_audit if not n["gate"]] return { - "guardian_nodes": len(g_audit), + "theta_nodes": len(g_audit), "gates_open": len(open_nodes), "gates_closed": len(closed_nodes), "avg_circles": round(sum(n["circles"] for n in g_audit) / len(g_audit), 2), - "guardian_coherence": round(float(self.theta.node_coherence.mean()), 4), + "theta_coherence": round(float(self.theta.node_coherence.mean()), 4), "memory_l_hub_avg": self.memory_l.state()["avg_hub"], } @@ -227,7 +227,7 @@ def _coherence_score(self, seed_audit: dict, circle_audit: dict) -> dict: "phi": seed_audit["phi_coherence"], "psi": seed_audit["psi_coherence"], "omega": seed_audit["omega_coherence"], - "guardian": circle_audit["guardian_coherence"], + "theta": circle_audit["theta_coherence"], "memory_l": self.memory_l.state()["avg_hub"], "memory_s": self.memory_s.state()["avg_hub"], } @@ -265,14 +265,14 @@ def infer(self, text: str) -> dict: "signal_mean": round(float(signal.mean()), 4), "step1_project": {"signal_len": len(signal), "signal_mean": round(float(signal.mean()), 4)}, "step2_inject": {"phi_n": 53, "psi_n": 53, "omega_n": 53, "memory_s_n": 17}, - "step3_propagate": {"phi_steps": 10, "psi_steps": 8, "omega_steps": 6, "guardian_steps": 5}, + "step3_propagate": {"phi_steps": 10, "psi_steps": 8, "omega_steps": 6, "theta_steps": 5}, "step4_ptca_seed": seed_audit, "step5_pcta_circle": circle_audit, "step6_coherence": coherence, "coherence_score": coherence["weighted_coherence"], "winner": coherence["winner"], "confidence": coherence["confidence"], - "guardian_circles": int(self.theta.circle_count.mean()), + "theta_circles": int(self.theta.circle_count.mean()), "memory_l_state": self.memory_l.state(), "memory_s_state": self.memory_s.state(), } @@ -304,7 +304,7 @@ def reward(self, winner: str, outcome: float) -> dict: "psi_coherence_after": round(self.psi.ring_coherence, 4), "omega_coherence_after": round(self.omega.ring_coherence, 4), "theta_coherence_after": round(float(self.theta.node_coherence.mean()), 4), - "guardian_circles_after": [int(v) for v in self.theta.circle_count], + "theta_circles_after": [int(v) for v in self.theta.circle_count], "memory_l_flush_count": self.memory_l.flush_count, "memory_s_flush_count": self.memory_s.flush_count, } From 5cc35c962ae405e7db9f60629b11184c86b2127f Mon Sep 17 00:00:00 2001 From: Erin Spencer Date: Tue, 21 Apr 2026 15:24:09 -0700 Subject: [PATCH 3/3] Update core/pcna.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- core/pcna.py | 1 + 1 file changed, 1 insertion(+) diff --git a/core/pcna.py b/core/pcna.py index 0da1281..ba12dcf 100644 --- a/core/pcna.py +++ b/core/pcna.py @@ -305,6 +305,7 @@ def reward(self, winner: str, outcome: float) -> dict: "omega_coherence_after": round(self.omega.ring_coherence, 4), "theta_coherence_after": round(float(self.theta.node_coherence.mean()), 4), "theta_circles_after": [int(v) for v in self.theta.circle_count], + "theta_circles_after": [int(v) for v in self.theta.circle_count], "memory_l_flush_count": self.memory_l.flush_count, "memory_s_flush_count": self.memory_s.flush_count, }