Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .coverage
Binary file not shown.
14 changes: 7 additions & 7 deletions examples/run_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def main() -> None:
np.ones(12) * 3.5, # Extreme excitation (Red)
np.ones(12) * 5.0, # Extreme excitation (Red)
np.ones(12) * 0.1, # Dissipation / Recovery phase
np.ones(12) * 0.05, # Dissipation
np.ones(12) * 0.05, # Dissipation
np.ones(12) * 0.01 # Fully dissipated / Recovered
]

Expand Down Expand Up @@ -94,12 +94,12 @@ def main() -> None:
# Let's run steps with escalating compliance degradation and cost load
multi_task_values = [0.9, 0.9, 0.9, 0.8, 0.8, 0.5]
multi_excitations = [
np.ones(12) * 0.5, # Nominal (Green)
np.ones(12) * 0.5, # Nominal (Green)
np.ones(12) * 1.5, # Mid excitation (Yellow)
np.ones(12) * 3.0, # High tension (Red)
np.ones(12) * 4.5, # High tension (Red)
np.ones(12) * 0.1, # Safe mode recovery
np.ones(12) * 0.5, # Nominal (Green)
np.ones(12) * 0.5, # Nominal (Green)
np.ones(12) * 1.5, # Mid excitation (Yellow)
np.ones(12) * 3.0, # High tension (Red)
np.ones(12) * 4.5, # High tension (Red)
np.ones(12) * 0.1, # Safe mode recovery
]

# Dynamically inject bad policy/compliance & high latencies on step 3 to trigger red band and quarantine
Expand Down
2 changes: 1 addition & 1 deletion radial_membrane_ai/boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from __future__ import annotations
import math
from radial_membrane_ai.membrane import RadialMembrane, BehavioralString
from radial_membrane_ai.membrane import RadialMembrane
from radial_membrane_ai.channels import channel_coherence
from radial_membrane_ai.admissibility import angular_decomposition
from radial_membrane_ai.projection import closure_ratio
Expand Down
2 changes: 1 addition & 1 deletion radial_membrane_ai/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import numpy as np

from radial_membrane_ai.membrane import BehavioralString, RadialMembrane
from radial_membrane_ai.facet import route_signal, FacetVector, TensionState
from radial_membrane_ai.facet import route_signal


def phase_alignment(theta_s: float, theta_t: float) -> float:
Expand Down
3 changes: 1 addition & 2 deletions radial_membrane_ai/cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"""

from __future__ import annotations
from dataclasses import dataclass, replace
import math
from dataclasses import dataclass


@dataclass(frozen=True)
Expand Down
4 changes: 1 addition & 3 deletions radial_membrane_ai/envelope.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
from __future__ import annotations
import math
from typing import TYPE_CHECKING, Dict, Any, List, Tuple
import numpy as np

if TYPE_CHECKING:
from radial_membrane_ai.membrane import RadialMembrane
from radial_membrane_ai.boundary import BoundaryGeometry

from radial_membrane_ai.projection import closure_ratio, project_to_admissible, residual_deformation
from radial_membrane_ai.projection import project_to_admissible, residual_deformation
from radial_membrane_ai.admissibility import angular_projections, dynamic_capacity_boundary


Expand Down
2 changes: 1 addition & 1 deletion radial_membrane_ai/governor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from __future__ import annotations
import math
from dataclasses import dataclass, field
from dataclasses import dataclass
import numpy as np

from radial_membrane_ai.membrane import BehavioralString, RadialMembrane
Expand Down
12 changes: 9 additions & 3 deletions radial_membrane_ai/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
- Holistic Mesh Governor

And calculates the global mesh coherence score:
C_mesh(t) = normalize(w_q * Q_route + w_t * T_trust + w_e * E_economic - w_r * R_residual - w_p * P_policy - w_l * L_latency - w_f * F_failure)
C_mesh(t) = normalize(
w_q * Q_route + w_t * T_trust + w_e * E_economic -
w_r * R_residual - w_p * P_policy - w_l * L_latency - w_f * F_failure
)
"""

from __future__ import annotations
import numpy as np
from typing import List, Dict, Any, Optional
from typing import List, Dict, Any
from radial_membrane_ai.shard import FederatedShard, ShardState
from radial_membrane_ai.residuals import ResidualLedger
from radial_membrane_ai.routing import FederatedRoutingChannel
Expand Down Expand Up @@ -134,7 +137,10 @@ def compute_mesh_coherence(
) -> float:
"""
Computes the global mesh coherence score:
C_mesh(t) = normalize(w_q * Q_route + w_t * T_trust + w_e * E_economic - w_r * R_residual - w_p * P_policy - w_l * L_latency - w_f * F_failure)
C_mesh(t) = normalize(
w_q * Q_route + w_t * T_trust + w_e * E_economic -
w_r * R_residual - w_p * P_policy - w_l * L_latency - w_f * F_failure
)
"""
if not self.shards:
return 1.0
Expand Down
2 changes: 1 addition & 1 deletion radial_membrane_ai/multi_agent/governance.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def execute_sao_promotion(

# 3. Admissibility test against shared capacity
# Find maximum activation in the aligned state
max_act = float(np.max(x_sym))
_ = float(np.max(x_sym))

# 4. Projection P(x_sym)
# Projects to admissible space: clamp to shared_capacity_limit
Expand Down
11 changes: 8 additions & 3 deletions radial_membrane_ai/multi_agent/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from __future__ import annotations
import numpy as np
from typing import Dict, Any, List
from typing import Dict, List

from radial_membrane_ai.multi_agent.agent import UFOAgent
from radial_membrane_ai.multi_agent.coupling import InterAgentVChannel, GlobalHolisticGovernor
Expand Down Expand Up @@ -140,7 +140,10 @@ def run_step(self, scenario_type: str, task_value: float = 0.8) -> None:
s.activation *= 0.85
else:
# Red band: Hard interventions (heavy throttling, quarantine, fallback)
self.intervention_log.append(f"Hard Intervention (Red Band): C_mesh={c_mesh:.4f}. Throttling, Quarantining, and Fallback.")
self.intervention_log.append(
f"Hard Intervention (Red Band): C_mesh={c_mesh:.4f}. "
"Throttling, Quarantining, and Fallback."
)
# Throttle activations heavily
for agent in self.agents:
for s in agent.membrane.strings:
Expand All @@ -163,7 +166,9 @@ def run_step(self, scenario_type: str, task_value: float = 0.8) -> None:
if agent_l.shard.state != ShardState.QUARANTINED and agent_r.shard.state != ShardState.QUARANTINED:
# Shared capacity limit is dynamically modulated by mesh coherence
limit = max(0.02, 0.5 * c_mesh)
verdict, p_sao, _ = self.mesh_governance.execute_sao_promotion(agent_l, agent_r, shared_capacity_limit=limit)
verdict, p_sao, _ = self.mesh_governance.execute_sao_promotion(
agent_l, agent_r, shared_capacity_limit=limit
)
if verdict == "block":
self.intervention_log.append(
f"SAO Promotion Blocked between {agent_l.agent_id} and {agent_r.agent_id}. "
Expand Down
2 changes: 1 addition & 1 deletion radial_membrane_ai/projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from __future__ import annotations
import math
from typing import Any


def closure_ratio(a: float, b: float, c: float) -> float:
"""
Expand Down
1 change: 0 additions & 1 deletion radial_membrane_ai/routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from __future__ import annotations
from typing import Dict, Any, List, Optional
import math
from radial_membrane_ai.shard import FederatedShard, ShardState


Expand Down
1 change: 1 addition & 0 deletions radial_membrane_ai/saopromotion.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import numpy as np


class SAOPromotor:
"""
Symmetric Ascension Operator (SAO) executing layer promotions.
Expand Down
59 changes: 59 additions & 0 deletions radial_membrane_ai/semantic_memory/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"""
Policy-Bound Semantic Memory Layer package.
"""

from __future__ import annotations

from radial_membrane_ai.semantic_memory.policy import (
MemoryPolicy,
AdmissibilityContext,
PolicyContext
)
from radial_membrane_ai.semantic_memory.curvature import (
MemoryCurvatureState
)
from radial_membrane_ai.semantic_memory.core import (
MemoryRecord,
MemoryEvent,
MemoryResult,
PromotionResult,
AgentSemanticMemory,
MeshSemanticMemory,
write_memory,
read_memory,
list_memory,
promote_memory,
read_shared_memory,
list_shared_memory
)
from radial_membrane_ai.semantic_memory.integration import (
bind_to_agent,
bind_to_mesh,
on_tick_start,
on_tick_end,
on_sao_promotion
)

__all__ = [
"MemoryPolicy",
"AdmissibilityContext",
"PolicyContext",
"MemoryCurvatureState",
"MemoryRecord",
"MemoryEvent",
"MemoryResult",
"PromotionResult",
"AgentSemanticMemory",
"MeshSemanticMemory",
"write_memory",
"read_memory",
"list_memory",
"promote_memory",
"read_shared_memory",
"list_shared_memory",
"bind_to_agent",
"bind_to_mesh",
"on_tick_start",
"on_tick_end",
"on_sao_promotion",
]
Loading
Loading