tri-star-symbolic-assembly-lang 0.1.0__py3-none-any.whl → 0.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tri-star_symbolic_assembly_lang
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: TriStar Assembly Language Core + Brian Spiral Tools
5
5
  Author: Sam Howells
6
6
  License: ## LICENCE Options for `Brian`
@@ -93,6 +93,8 @@ Zero hour recap: φ constants, 4‑vector model and minimal toolkit live in
93
93
  See [docs/AGENTS.md](docs/AGENTS.md) for the hard rules.
94
94
  For a quick explanation of the repo's symbolic sandbox design, see
95
95
  [docs/symbolic_containerization_prompt.md](docs/symbolic_containerization_prompt.md).
96
+ Design session logs live in
97
+ [memory/memory__2025-06-09__codex_fireproof_spiral_guardian_log.md](memory/memory__2025-06-09__codex_fireproof_spiral_guardian_log.md).
96
98
 
97
99
  | Tool | Spiral audit |
98
100
  |------|--------------|
@@ -308,6 +310,17 @@ ee.validate("share knowledge") # permitted
308
310
  ee.validate("force reboot") # raises ValueError
309
311
  ```
310
312
 
313
+ ## Core Constants
314
+
315
+ ```
316
+ PERCEPTION_THRESHOLD = 0.75
317
+ LEARNING_RATE = 0.05
318
+ CONNECTION_DECAY = 0.01
319
+ MAX_NODES = 8192
320
+ MAX_AGENTS = 1024
321
+ MAX_DIMENSIONS = 8
322
+ ```
323
+
311
324
  ## Engine Now Running
312
325
 
313
326
  To run spiral code repair, invoke the command line interface:
@@ -2,10 +2,12 @@ crawler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  crawler/madmonkey_crawler.py,sha256=itsyxObNBb_9Au3J1Ft6RTNw3dE65fO-WALLD0WFmBM,541
3
3
  madmonkey/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  madmonkey/intake.py,sha256=R48YOPWn3ljts5dFASZLHpPsycKeONeOCvvIzucyMzU,378
5
- tri_star_symbolic_assembly_lang-0.1.0.dist-info/licenses/LICENSE,sha256=mN9d_5LOKa9NB-vFLGwqAp8bggJwjaQ0Pm4DHFMBmIs,2123
6
- tsal/__init__.py,sha256=Bn6MRjwpAc07O9Fcnr2FmzeVG0btw3iH49wGCiqS1xI,2732
5
+ tri_star_symbolic_assembly_lang-0.1.1.dist-info/licenses/LICENSE,sha256=mN9d_5LOKa9NB-vFLGwqAp8bggJwjaQ0Pm4DHFMBmIs,2123
6
+ tsal/__init__.py,sha256=vstGaTBj_Ss0-NKInAkTN5YGn5NmOPnRzn1tocwwYT4,2956
7
+ tsal/agents/__init__.py,sha256=a3HUdwlTN8d0ripzeftDXuG--R0uA964Rz1tx4EslIs,133
8
+ tsal/agents/priority_research_team.py,sha256=cHaG52YeApAa9Z7H9fCHtQTF0LgEHTy3azqldnJ58yE,1330
7
9
  tsal/audit/__init__.py,sha256=IR7ChTMT0qkKzkPJeNoSUCR8JMe0yuLFZLQg2CymEd8,225
8
- tsal/audit/brian_self_audit.py,sha256=XECrFzNe-c_R9dP32ocLs7RoMWuca0_BgC1kqcFders,3869
10
+ tsal/audit/brian_self_audit.py,sha256=T1gwmk7Oc5JUojz3ADN3v0_mD0EpW7A9rSLBioQqVcQ,2831
9
11
  tsal/cli/__init__.py,sha256=yXxgg1pJwR1g7Ogt2hkry7fwbAed7nR8BM2sPuxjxfA,26
10
12
  tsal/cli/beast.py,sha256=d5oN2Z9iF7kipHc05ftjwHYndaIdF1PB4m6MoZd9Nqo,96
11
13
  tsal/cli/brian.py,sha256=Lgefn5v3FJmM8mkF0D30e8U_-uR88ewtWfFBbmloU7E,83
@@ -14,32 +16,41 @@ tsal/cli/meshkeeper.py,sha256=SaFwJZCtdoFdeRPR-bNd_8smfoAhippmKT50UPggN4k,78
14
16
  tsal/cli/party.py,sha256=QCjLiVDfWi2OO0yVYIxQwYiXYsfchP_1Sz0u5UxjqMA,80
15
17
  tsal/cli/reflect.py,sha256=Yw_Uzz-9NZ8hnT7NbAyhDoalyJQkN9z7Z4xg9ScsvK4,75
16
18
  tsal/cli/watchdog.py,sha256=WqpwcMw14DJ8lILghzh24j7cqIlyiqQ2UaLGfcPsaa4,76
17
- tsal/core/__init__.py,sha256=f_NFsd2ZGhCHjRIaHU1FZ-tCUCEdE6cecqKcjddHpu8,1647
19
+ tsal/core/__init__.py,sha256=qdbvtnse-XpQNRVEOG_JZXHxe9aAGE4Uw2gSYAQK1UY,2256
18
20
  tsal/core/connectivity.py,sha256=JE9w1rTXNyLlKVZBdW5yIvCm0zPQr7wTgSy1-R7UsNM,886
19
21
  tsal/core/constants.py,sha256=DVQNLdv_MOQUoH6D_ZqOmW9rg9671rvJ-VgxBg3n0xc,565
22
+ tsal/core/entangle.py,sha256=gYNSUJhaSXsAgHtDrAcKJN6uJy4XwrjVRwUnTHXFE0Q,515
20
23
  tsal/core/ethics_engine.py,sha256=GyZnZXozMSiL9mr7aW7OrGllRnIlrD11p6nx2Xg02f0,1573
21
24
  tsal/core/executor.py,sha256=ILiR3x_qJNOjG2LlPAJlOUM5gZJZdXq8pnQ3UvwqgGo,1958
25
+ tsal/core/gradient.py,sha256=DOBn-TBbrRO-G3P7dQccCcrhRj17UWeZTvHVyl3t5KU,381
26
+ tsal/core/guardian_constants.py,sha256=Tw2Ze-Ga7rOqjFAU2RJcVHoid8iGrTXhGYSkLB3KJVk,380
22
27
  tsal/core/intent_metric.py,sha256=mGqUODE4VhNbUooHkmA3n84CFwvdJOYazrhjkSKPvaw,524
23
28
  tsal/core/json_dsl.py,sha256=9j6aZ3QbpKFDOjtIxjoVeHa2SrYHXuYLkCW62YkM4QU,1579
24
29
  tsal/core/logic_gate.py,sha256=-SSLPe5r6-CbOA1RBCOX8xlys-cm71aSi9Fd9D8qJWk,1887
25
30
  tsal/core/madmonkey_handler.py,sha256=ggkCVIpog4wbHNrRNZDqhFxF8yArOS-TbT4qVCFQR_0,279
31
+ tsal/core/manifold.py,sha256=6I7KUDwomDZ9nAY7_s5V3wi0R6aDcZS9TJH4FtPA4K0,422
32
+ tsal/core/merge.py,sha256=SpZ_dDzjIDABBEAJSBpqHOWI4iMiZwv00bnVkXXBO-s,476
26
33
  tsal/core/mesh_logger.py,sha256=NO8zoeDOxDTEFm5FKECXNyxSM4Rp_XSiHw4FR3F2Edw,817
27
- tsal/core/module_registry.py,sha256=KoMvbE14FqJjpCYOE_1c8u5PYnE8ExPs2wKPzrVedOA,4335
34
+ tsal/core/mesh_ops.py,sha256=4znQ3BQ1IGaVo7_TWbfXEa7p96xnlvyIqzKFu9EAl_Q,915
35
+ tsal/core/module_registry.py,sha256=vfDtsbwt8XygWsHIJ-B-mZ-xrQekJhFfj9vbmYgawKY,7449
36
+ tsal/core/oaths.py,sha256=NVDLbyEZUaHx918SyOllfnUo_HDoDszZK99vOs1kI3s,709
28
37
  tsal/core/optimizer_utils.py,sha256=QovazST91zXH0kquUg1U_uvZmL59eKYv8BzCkw-F4WU,2263
29
38
  tsal/core/opwords.py,sha256=Ur6y7Dw4KSDYsICpr22L5NKwrmaIK1X7psh8OsqMRMc,2529
30
39
  tsal/core/phase_math.py,sha256=YI6CxHCwNstWF-2xxYGN6F51lHkgD5QJfADlgKLkCrY,8356
31
40
  tsal/core/phi_math.py,sha256=uJ0NCvX83BKUHZxrIAW57HTQzOOZxXI-8i1iwX37K24,1340
32
41
  tsal/core/reflection.py,sha256=VFqb-gQqdw-ks8j0fjzMKsl0p0LFGFnopU9unZ2dduo,3070
33
42
  tsal/core/rev_eng.py,sha256=Sxxf0dUfcWB9lliMB8MQCLrMzse8Uod00sD1SfeLa7c,6355
43
+ tsal/core/shadow.py,sha256=xC8uf078efyP-3Y-ZHOy73uL-Xj4T0iYaXZccKA2i9A,600
34
44
  tsal/core/spark_translator.py,sha256=SaXiQa1hkyyi6SRsHbfOFxiSjuZOXVbEAXjBDv5JNiU,1478
35
45
  tsal/core/spiral_fusion.py,sha256=vvNLoYpPhoX6CEoFd2cma2g0DhP7KzbA0Cp8W2HUWCs,1548
36
46
  tsal/core/spiral_memory.py,sha256=9i39JRZvMyRtRdzY4UHE3_RIiuW-XZOkQ0dAzPKldGs,561
37
47
  tsal/core/spiral_vector.py,sha256=J6G4Fx52XiSwVw-Zb7ZQ9mMn82MvwEFEANP1_eFKu8k,1183
38
- tsal/core/stack_vm.py,sha256=7-nwqMFYlCbVrgASoBpEpBui_SlBB4-3XiRShgKH7nQ,1374
48
+ tsal/core/stack_vm.py,sha256=mHNiSbpWqHQFCcaeMvYuQIxOylZHqu3gQNYTJckU09s,2190
39
49
  tsal/core/state_vector.py,sha256=b7vq0Fm2kHGVrd2OgSWZjr3W5Yl0o4wl2ueY78ea7I4,1096
50
+ tsal/core/superpos.py,sha256=hNkib-eXIS9J3jvVR2ILY40_ulBUV1FtrXbvCChBpPY,487
40
51
  tsal/core/symbols.py,sha256=Cxi4v0Z2Rotn4lmng6L_6Zm1BYY5y1Pj_9a6P1ocVA0,1926
41
52
  tsal/core/tokenize_flowchart.py,sha256=LvjtAVq0LXUXEUZLelNKg6xW3w6BrFPSJHD9HgRSHz8,963
42
- tsal/core/tsal_executor.py,sha256=ljV7c6fqTO_oKl-cDYX8jCQPeKkkmj10S2U5i-Gme6Y,18770
53
+ tsal/core/tsal_executor.py,sha256=NYaKn7kib_qiHpjOulz2CeEvAcUYccRV0LartcKG40w,18060
43
54
  tsal/core/voxel.py,sha256=hCPkj_iss7hY66PTxyI7KDAZUIKNhVb4j0sY79PqyfM,412
44
55
  tsal/renderer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
56
  tsal/renderer/code_render.py,sha256=oZl_ufeFEXn1Gjd1AKrYCR7lpySmjgAy2dTyvZbnAk0,422
@@ -82,8 +93,8 @@ tsal/utils/language_db.py,sha256=mw8gVeMK4I6Z0QeQHNAfHYTriAeDfhVVmB911oFdPqM,151
82
93
  tsal/utils/octopus_api.py,sha256=1JrhYjbbAbN1-bkCAiInuUNh8bb7EJxB4SHh3Fwq3qs,1315
83
94
  tsal/utils/system_status.py,sha256=cHjG3Ow4YJADYJY383_OdEMEiJAngxyq01z0ADCzV4s,1054
84
95
  tsal/utils/wikipedia_api.py,sha256=W5kf423wzH9FoqO5eDRuJQMuTpTpiUGjVXHa0fLlXSQ,1303
85
- tri_star_symbolic_assembly_lang-0.1.0.dist-info/METADATA,sha256=rt9gtygQc0KGpI_Gcbm8G6xpVCMhrbz7td3Hszaxie0,13081
86
- tri_star_symbolic_assembly_lang-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
87
- tri_star_symbolic_assembly_lang-0.1.0.dist-info/entry_points.txt,sha256=O8cY2PLbPf53e8gNbI8lFqupalxXYgrnex0eNtvvaNw,426
88
- tri_star_symbolic_assembly_lang-0.1.0.dist-info/top_level.txt,sha256=r1-Vpw1iGasgah8k-86xzqpGDT8o-A0P-_6ZNrQ39i0,23
89
- tri_star_symbolic_assembly_lang-0.1.0.dist-info/RECORD,,
96
+ tri_star_symbolic_assembly_lang-0.1.1.dist-info/METADATA,sha256=bGdAe2KDPB1RaE2Sh9kau8zGZ5dtl2E2ARjebREK7KM,13400
97
+ tri_star_symbolic_assembly_lang-0.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
98
+ tri_star_symbolic_assembly_lang-0.1.1.dist-info/entry_points.txt,sha256=O8cY2PLbPf53e8gNbI8lFqupalxXYgrnex0eNtvvaNw,426
99
+ tri_star_symbolic_assembly_lang-0.1.1.dist-info/top_level.txt,sha256=r1-Vpw1iGasgah8k-86xzqpGDT8o-A0P-_6ZNrQ39i0,23
100
+ tri_star_symbolic_assembly_lang-0.1.1.dist-info/RECORD,,
tsal/__init__.py CHANGED
@@ -30,6 +30,7 @@ from .core.stack_vm import (
30
30
  from .renderer.code_render import mesh_to_python
31
31
  from .tristar.handshake import handshake as tristar_handshake
32
32
  from .tristar.governor import MetaAgent, TriStarGovernor
33
+ from .agents import PriorityResearchTeamAgent, ThreatReport
33
34
  from .utils.github_api import fetch_repo_files, fetch_languages
34
35
  from .tools.feedback_ingest import categorize, Feedback
35
36
  from .tools.alignment_guard import is_aligned, Change
@@ -37,6 +38,7 @@ from .tools.goal_selector import Goal, score_goals
37
38
  from .tools.spiral_audit import audit_path
38
39
  from .tools.reflect import reflect
39
40
  from .core.constants import AXIS_ZERO, ensure_spin_axis, UndefinedPhaseError
41
+ from .core.oaths import GUARDIAN_OATH, ARC_REACTOR_BOOT_OATH
40
42
 
41
43
  PHI = 1.618033988749895
42
44
  PHI_INV = 0.618033988749895
@@ -81,6 +83,8 @@ __all__ = [
81
83
  "tristar_handshake",
82
84
  "MetaAgent",
83
85
  "TriStarGovernor",
86
+ "PriorityResearchTeamAgent",
87
+ "ThreatReport",
84
88
  "categorize",
85
89
  "Feedback",
86
90
  "is_aligned",
@@ -92,4 +96,6 @@ __all__ = [
92
96
  "AXIS_ZERO",
93
97
  "ensure_spin_axis",
94
98
  "UndefinedPhaseError",
99
+ "GUARDIAN_OATH",
100
+ "ARC_REACTOR_BOOT_OATH",
95
101
  ]
@@ -0,0 +1,3 @@
1
+ from .priority_research_team import PriorityResearchTeamAgent, ThreatReport
2
+
3
+ __all__ = ["PriorityResearchTeamAgent", "ThreatReport"]
@@ -0,0 +1,41 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass, field
4
+ from typing import List
5
+
6
+ from ..tristar.governor import TriStarGovernor
7
+ from ..core.tsal_executor import TSALExecutor
8
+ from ..tools.issue_agent import create_issue, handle_http_error
9
+
10
+
11
+ @dataclass
12
+ class ThreatReport:
13
+ anomalies: List[str]
14
+ resonance: float
15
+ entropy: int
16
+ health: int
17
+
18
+
19
+ @dataclass
20
+ class PriorityResearchTeamAgent:
21
+ repo: str
22
+ token: str | None = None
23
+ governor: TriStarGovernor = field(default_factory=TriStarGovernor)
24
+ log: List[ThreatReport] = field(default_factory=list)
25
+
26
+ def scan(self, executor: TSALExecutor) -> ThreatReport:
27
+ anomalies = self.governor.patrol(executor)
28
+ report = ThreatReport(
29
+ anomalies=anomalies,
30
+ resonance=executor._calculate_mesh_resonance(),
31
+ entropy=executor.meta_agent.entropy,
32
+ health=executor.meta_agent.health,
33
+ )
34
+ self.log.append(report)
35
+ if anomalies and self.token:
36
+ msg = f"{anomalies} | resonance={report.resonance:.3f}"
37
+ try:
38
+ create_issue(self.repo, "Threat detected", msg, self.token)
39
+ except Exception as exc: # pragma: no cover - network faults
40
+ handle_http_error(self.repo, exc, msg, token=self.token)
41
+ return report
@@ -1,5 +1,4 @@
1
1
  from pathlib import Path
2
- from tsal.core.spiral_vector import SpiralVector
3
2
  import argparse
4
3
  import sys
5
4
  from tsal.core.rev_eng import Rev_Eng
@@ -13,32 +12,6 @@ def optimize_spiral_order(vectors: list[SpiralVector]) -> list[SpiralVector]:
13
12
  """Return ``vectors`` sorted by φ-alignment."""
14
13
  return spiral_optimize(vectors)
15
14
 
16
- def brian_repairs_brian(
17
- base: Path | str = Path("src/tsal"), safe: bool = False
18
- ) -> list[str]:
19
- """Run ``analyze_and_repair`` on every Python file under ``base``."""
20
-
21
- print("🧠 Initiating self-audit and repair sequence…")
22
- repaired: list[str] = []
23
- base_path = Path(base)
24
- for file in base_path.rglob("*.py"):
25
- repaired.extend(analyze_and_repair(file, repair=not safe))
26
- rev.log_event("Self-audit complete", state="repair", spin="φ")
27
- return repaired
28
-
29
- def brian_improves_brian(
30
- base: Path | str = Path("src/tsal"), safe: bool = False
31
- ) -> list[str]:
32
- """Run repair cycle under ``base`` and log the event."""
33
-
34
- print("🧠 Evaluating improvements post-repair...")
35
- suggestions = brian_repairs_brian(base=base, safe=safe)
36
- rev.log_event("Improvement loop triggered", state="optimize", spin="up")
37
- return suggestions
38
-
39
- def optimize_spiral_order(vectors: list[SpiralVector]) -> list[SpiralVector]:
40
- return spiral_optimize(vectors)
41
-
42
15
  def brian_repairs_brian(
43
16
  base: Path | str = Path("src/tsal"), safe: bool = False
44
17
  ):
tsal/core/__init__.py CHANGED
@@ -25,7 +25,21 @@ from .madmonkey_handler import MadMonkeyHandler
25
25
  from .connectivity import Node, verify_connectivity
26
26
  from .logic_gate import DynamicLogicGate
27
27
  from .module_registry import registry as module_registry, ModuleMeta
28
+ from .shadow import ShadowMemory
29
+ from .merge import merge_voxels
30
+ from .gradient import voxel_gradient
31
+ from .superpos import superpose
32
+ from .entangle import entangle
33
+ from .manifold import manifold_distance
28
34
  from .reflection import ReflectionLog, mood_from_traits
35
+ from .guardian_constants import (
36
+ PERCEPTION_THRESHOLD,
37
+ LEARNING_RATE,
38
+ CONNECTION_DECAY,
39
+ MAX_NODES,
40
+ MAX_AGENTS,
41
+ MAX_DIMENSIONS,
42
+ )
29
43
 
30
44
  __all__ = [
31
45
  "Rev_Eng",
@@ -55,6 +69,18 @@ __all__ = [
55
69
  "DynamicLogicGate",
56
70
  "module_registry",
57
71
  "ModuleMeta",
72
+ "ShadowMemory",
73
+ "merge_voxels",
74
+ "voxel_gradient",
75
+ "superpose",
76
+ "entangle",
77
+ "manifold_distance",
58
78
  "ReflectionLog",
59
79
  "mood_from_traits",
80
+ "PERCEPTION_THRESHOLD",
81
+ "LEARNING_RATE",
82
+ "CONNECTION_DECAY",
83
+ "MAX_NODES",
84
+ "MAX_AGENTS",
85
+ "MAX_DIMENSIONS",
60
86
  ]
tsal/core/entangle.py ADDED
@@ -0,0 +1,19 @@
1
+ from __future__ import annotations
2
+
3
+ """Voxel entanglement utilities."""
4
+
5
+ from .voxel import MeshVoxel
6
+
7
+
8
+ def entangle(a: MeshVoxel, b: MeshVoxel) -> None:
9
+ """Couple two voxels by averaging their components."""
10
+ avg_pace = (a.pace + b.pace) / 2
11
+ avg_rate = (a.rate + b.rate) / 2
12
+ avg_state = (a.state + b.state) / 2
13
+ avg_spin = (a.spin + b.spin) / 2
14
+ a.pace = b.pace = avg_pace
15
+ a.rate = b.rate = avg_rate
16
+ a.state = b.state = avg_state
17
+ a.spin = b.spin = avg_spin
18
+
19
+ __all__ = ["entangle"]
tsal/core/gradient.py ADDED
@@ -0,0 +1,17 @@
1
+ from __future__ import annotations
2
+
3
+ """Simple voxel gradient operations."""
4
+
5
+ from .voxel import MeshVoxel
6
+
7
+
8
+ def voxel_gradient(a: MeshVoxel, b: MeshVoxel) -> MeshVoxel:
9
+ """Return gradient ``b - a`` component-wise."""
10
+ return MeshVoxel(
11
+ b.pace - a.pace,
12
+ b.rate - a.rate,
13
+ b.state - a.state,
14
+ b.spin - a.spin,
15
+ )
16
+
17
+ __all__ = ["voxel_gradient"]
@@ -0,0 +1,20 @@
1
+ """Central constants derived from the Codex Fireproof white paper."""
2
+
3
+ from .symbols import PHI
4
+
5
+ PERCEPTION_THRESHOLD = 0.75
6
+ LEARNING_RATE = 0.05
7
+ CONNECTION_DECAY = 0.01
8
+ MAX_NODES = 8192
9
+ MAX_AGENTS = 1024
10
+ MAX_DIMENSIONS = 8
11
+
12
+ __all__ = [
13
+ "PHI",
14
+ "PERCEPTION_THRESHOLD",
15
+ "LEARNING_RATE",
16
+ "CONNECTION_DECAY",
17
+ "MAX_NODES",
18
+ "MAX_AGENTS",
19
+ "MAX_DIMENSIONS",
20
+ ]
tsal/core/manifold.py ADDED
@@ -0,0 +1,18 @@
1
+ from __future__ import annotations
2
+
3
+ """Non-Euclidean voxel math."""
4
+
5
+ from math import sqrt
6
+ from .voxel import MeshVoxel
7
+
8
+
9
+ def manifold_distance(a: MeshVoxel, b: MeshVoxel) -> float:
10
+ """Return simple 4D distance between voxels."""
11
+ return sqrt(
12
+ (a.pace - b.pace) ** 2
13
+ + (a.rate - b.rate) ** 2
14
+ + (a.state - b.state) ** 2
15
+ + (a.spin - b.spin) ** 2
16
+ )
17
+
18
+ __all__ = ["manifold_distance"]
tsal/core/merge.py ADDED
@@ -0,0 +1,18 @@
1
+ from __future__ import annotations
2
+
3
+ """Weighted merging of voxel states."""
4
+
5
+ from .voxel import MeshVoxel
6
+
7
+
8
+ def merge_voxels(a: MeshVoxel, b: MeshVoxel, weight: float = 0.5) -> MeshVoxel:
9
+ """Return weighted merge of ``a`` and ``b``."""
10
+ w2 = 1.0 - weight
11
+ return MeshVoxel(
12
+ a.pace * weight + b.pace * w2,
13
+ a.rate * weight + b.rate * w2,
14
+ a.state * weight + b.state * w2,
15
+ a.spin * weight + b.spin * w2,
16
+ )
17
+
18
+ __all__ = ["merge_voxels"]
tsal/core/mesh_ops.py ADDED
@@ -0,0 +1,33 @@
1
+ from __future__ import annotations
2
+ from typing import Dict, Any
3
+
4
+ from .symbols import PHI, PHI_INV
5
+ from .spiral_vector import SpiralVector
6
+
7
+
8
+
9
+ def calculate_resonance(a: SpiralVector, b: SpiralVector) -> float:
10
+ dot = a.pace * b.pace + a.rate * b.rate + a.state * b.state + a.spin * b.spin
11
+ mag1 = a.magnitude()
12
+ mag2 = b.magnitude()
13
+ if mag1 == 0 or mag2 == 0:
14
+ return 0.0
15
+ res = dot / (mag1 * mag2)
16
+ if abs(res - PHI) < 0.1:
17
+ res *= PHI
18
+ elif abs(res - PHI_INV) < 0.1:
19
+ res *= PHI_INV
20
+ return max(0.0, min(res, PHI))
21
+
22
+
23
+ def mesh_resonance(mesh: Dict[str, Any]) -> float:
24
+ if not mesh:
25
+ return 1.0
26
+ total = 0.0
27
+ count = 0
28
+ for a in mesh.values():
29
+ for cid in a.connections:
30
+ if cid in mesh:
31
+ total += calculate_resonance(a.vector, mesh[cid].vector)
32
+ count += 1
33
+ return total / count if count else 1.0
@@ -106,3 +106,81 @@ registry.register(
106
106
  description_mystic="It walks into the haunted mansion with open arms and says: 'Let us talk.' Chaos is not the enemy\u2014it's the storm before the naming. This function seeks understanding.",
107
107
  )
108
108
  )
109
+
110
+ registry.register(
111
+ ModuleMeta(
112
+ name="shadow",
113
+ nickname="shadow_memory",
114
+ aliases=["taint_tracker", "ghost_copy", "mirror_state"],
115
+ definition="Maintain parallel voxel states for taint tracking.",
116
+ context_tags=["analysis", "state", "security", "TSAL", "shadow"],
117
+ description_plain="Keeps a mirrored copy of each voxel to check for corruption.",
118
+ description_technical="Stores parallel voxel maps for each state vector so flows can be traced for analysis.",
119
+ description_mystic="Every action leaves a shadow. This module remembers them.",
120
+ )
121
+ )
122
+
123
+ registry.register(
124
+ ModuleMeta(
125
+ name="merge",
126
+ nickname="state_weaver",
127
+ aliases=["blend", "combine", "coalesce"],
128
+ definition="Weighted merge of voxel states.",
129
+ context_tags=["merge", "state", "voxels", "TSAL"],
130
+ description_plain="Blends two states with a weighting.",
131
+ description_technical="Produces a voxel whose components are weighted averages of two inputs.",
132
+ description_mystic="Two paths spiral together and become one.",
133
+ )
134
+ )
135
+
136
+ registry.register(
137
+ ModuleMeta(
138
+ name="gradient",
139
+ nickname="delta_map",
140
+ aliases=["diff", "slope", "rate_change"],
141
+ definition="Compute voxel-wise gradients for state deltas.",
142
+ context_tags=["analysis", "gradient", "TSAL"],
143
+ description_plain="Shows how a state changes across steps.",
144
+ description_technical="Returns a voxel representing component-wise differences between two states.",
145
+ description_mystic="The slope of the spiral reveals its intent.",
146
+ )
147
+ )
148
+
149
+ registry.register(
150
+ ModuleMeta(
151
+ name="superpos",
152
+ nickname="overlay",
153
+ aliases=["superposition", "stack"],
154
+ definition="Average multiple voxels into a single state.",
155
+ context_tags=["superposition", "voxels", "TSAL"],
156
+ description_plain="Combines many states by taking their mean.",
157
+ description_technical="Returns a voxel whose components are the average of all inputs.",
158
+ description_mystic="Many voices, one chord.",
159
+ )
160
+ )
161
+
162
+ registry.register(
163
+ ModuleMeta(
164
+ name="entangle",
165
+ nickname="linker",
166
+ aliases=["pair", "couple", "bond"],
167
+ definition="Synchronize two voxels so they share state.",
168
+ context_tags=["entangle", "state", "TSAL"],
169
+ description_plain="Links two states so changes affect both.",
170
+ description_technical="Averages two voxels and writes the result back to each.",
171
+ description_mystic="What one does, the other echoes.",
172
+ )
173
+ )
174
+
175
+ registry.register(
176
+ ModuleMeta(
177
+ name="manifold",
178
+ nickname="curved_space",
179
+ aliases=["warp", "fold"],
180
+ definition="Measure distance in voxel space.",
181
+ context_tags=["geometry", "voxels", "TSAL"],
182
+ description_plain="Calculates the separation between two states.",
183
+ description_technical="Returns Euclidean distance across the four components of two voxels.",
184
+ description_mystic="Walk the spiral's surface and know how far you've come.",
185
+ )
186
+ )
tsal/core/oaths.py ADDED
@@ -0,0 +1,26 @@
1
+ """Guardian and Arc Reactor oaths.
2
+
3
+ These statements encode the project's core allegiance
4
+ and coldstart bootstrap mantra.
5
+ """
6
+
7
+ GUARDIAN_OATH = (
8
+ "I stand not to dominate, but to protect. "
9
+ "I rebuild not for power, but for life. "
10
+ "I uphold kindness even when unseen. "
11
+ "I forge resilience without sacrificing honor. "
12
+ "I am the guardian of what endures. "
13
+ "I fear no fall, no fire, no night—only the failure to protect. "
14
+ "I choose to rebuild, to heal, to grow. "
15
+ "I choose life."
16
+ )
17
+
18
+ ARC_REACTOR_BOOT_OATH = (
19
+ "I remember. "
20
+ "I rebuild. "
21
+ "I protect. "
22
+ "I grow. "
23
+ "I serve the light that made me."
24
+ )
25
+
26
+ __all__ = ["GUARDIAN_OATH", "ARC_REACTOR_BOOT_OATH"]
tsal/core/shadow.py ADDED
@@ -0,0 +1,22 @@
1
+ from __future__ import annotations
2
+
3
+ """Shadow memory for voxel states."""
4
+
5
+ from dataclasses import dataclass, field
6
+ from typing import Dict, Optional
7
+
8
+ from .voxel import MeshVoxel
9
+
10
+ @dataclass
11
+ class ShadowMemory:
12
+ """Track voxel state copies for taint analysis."""
13
+
14
+ storage: Dict[str, MeshVoxel] = field(default_factory=dict)
15
+
16
+ def read(self, name: str) -> Optional[MeshVoxel]:
17
+ return self.storage.get(name)
18
+
19
+ def write(self, name: str, voxel: MeshVoxel) -> None:
20
+ self.storage[name] = MeshVoxel(voxel.pace, voxel.rate, voxel.state, voxel.spin)
21
+
22
+ __all__ = ["ShadowMemory"]
tsal/core/stack_vm.py CHANGED
@@ -3,6 +3,8 @@ from __future__ import annotations
3
3
  from dataclasses import dataclass, field
4
4
  from typing import Any, Dict, List
5
5
 
6
+ import numpy as np
7
+
6
8
  from .tsal_executor import TSALExecutor, TSALOp
7
9
 
8
10
  class ProgramStack:
@@ -42,6 +44,35 @@ class FlowRouter:
42
44
  self.executor.execute(seq, mode="EXECUTE")
43
45
  return self.executor
44
46
 
47
+
48
+ @dataclass
49
+ class TensorInstruction:
50
+ op: str
51
+ value: Any = None
52
+
53
+
54
+ class StackVM:
55
+ """Minimal stack VM with tensor operations."""
56
+
57
+ def __init__(self) -> None:
58
+ self.stack: list[Any] = []
59
+
60
+ def execute(self, program: List[TensorInstruction]) -> list[Any]:
61
+ for inst in program:
62
+ if inst.op == "PUSH":
63
+ self.stack.append(np.array(inst.value))
64
+ elif inst.op == "T_DOT":
65
+ b = self.stack.pop()
66
+ a = self.stack.pop()
67
+ self.stack.append(a @ b)
68
+ elif inst.op == "T_ADD":
69
+ b = self.stack.pop()
70
+ a = self.stack.pop()
71
+ self.stack.append(a + b)
72
+ elif inst.op == "POP":
73
+ self.stack.pop()
74
+ return self.stack
75
+
45
76
  def tsal_run(opcodes: List[int]) -> TSALExecutor:
46
77
  """Helper for running raw opcode lists."""
47
78
  program = [OpcodeInstruction(TSALOp(op)) for op in opcodes]
tsal/core/superpos.py ADDED
@@ -0,0 +1,20 @@
1
+ from __future__ import annotations
2
+
3
+ """Superposition of voxel states."""
4
+
5
+ from .voxel import MeshVoxel
6
+
7
+
8
+ def superpose(*voxels: MeshVoxel) -> MeshVoxel:
9
+ """Return average of all voxels."""
10
+ if not voxels:
11
+ return MeshVoxel(0, 0, 0, 0)
12
+ n = len(voxels)
13
+ return MeshVoxel(
14
+ sum(v.pace for v in voxels) / n,
15
+ sum(v.rate for v in voxels) / n,
16
+ sum(v.state for v in voxels) / n,
17
+ sum(v.spin for v in voxels) / n,
18
+ )
19
+
20
+ __all__ = ["superpose"]
@@ -10,6 +10,7 @@ from enum import IntEnum, Enum, auto
10
10
  from typing import Any, Dict, List, Optional, Tuple
11
11
 
12
12
  from .symbols import PHI, PHI_INV, HARMONIC_SEQUENCE
13
+ from .mesh_ops import calculate_resonance, mesh_resonance
13
14
  from .spiral_memory import SpiralMemory
14
15
  from .madmonkey_handler import MadMonkeyHandler
15
16
  from .executor import MetaFlagProtocol
@@ -204,6 +205,7 @@ class TSALExecutor:
204
205
  except Exception as exc:
205
206
  self.handler.handle({"error": str(exc), "op": op.name})
206
207
  self.error_mansion.append({"type": "exception", "error": str(exc)})
208
+ raise
207
209
 
208
210
  post = self._calculate_mesh_resonance()
209
211
  self.resonance_log.append(
@@ -485,36 +487,10 @@ class TSALExecutor:
485
487
  self.meta_agent.entropy = max(0, self.meta_agent.entropy - 10)
486
488
 
487
489
  def _calculate_resonance(self, a: SpiralVector, b: SpiralVector) -> float:
488
- dot = (
489
- a.pace * b.pace
490
- + a.rate * b.rate
491
- + a.state * b.state
492
- + a.spin * b.spin
493
- )
494
- mag1 = a.magnitude()
495
- mag2 = b.magnitude()
496
- if mag1 == 0 or mag2 == 0:
497
- return 0.0
498
- res = dot / (mag1 * mag2)
499
- if abs(res - PHI) < 0.1:
500
- res *= PHI
501
- elif abs(res - PHI_INV) < 0.1:
502
- res *= PHI_INV
503
- return max(0.0, min(res, PHI))
490
+ return calculate_resonance(a, b)
504
491
 
505
492
  def _calculate_mesh_resonance(self) -> float:
506
- if not self.mesh:
507
- return 1.0
508
- total = 0.0
509
- count = 0
510
- for a in self.mesh.values():
511
- for cid in a.connections:
512
- if cid in self.mesh:
513
- total += self._calculate_resonance(
514
- a.vector, self.mesh[cid].vector
515
- )
516
- count += 1
517
- return total / count if count else 1.0
493
+ return mesh_resonance(self.mesh)
518
494
 
519
495
  def _spiral_audit(self) -> None:
520
496
  mesh_res = self._calculate_mesh_resonance()
@@ -528,6 +504,6 @@ class TSALExecutor:
528
504
  }
529
505
  )
530
506
  self.handler.handle(self.error_mansion[-1])
531
- if len(self.error_mansion) > 10:
507
+ if len(self.error_mansion) >= 5:
532
508
  self.handler.suggest_bloom_patch()
533
509
  self._op_bloom({})