tnfr 3.0.3__py3-none-any.whl → 8.5.0__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.

Potentially problematic release.


This version of tnfr might be problematic. Click here for more details.

Files changed (360) hide show
  1. tnfr/__init__.py +375 -56
  2. tnfr/__init__.pyi +33 -0
  3. tnfr/_compat.py +10 -0
  4. tnfr/_generated_version.py +34 -0
  5. tnfr/_version.py +49 -0
  6. tnfr/_version.pyi +7 -0
  7. tnfr/alias.py +723 -0
  8. tnfr/alias.pyi +108 -0
  9. tnfr/backends/__init__.py +354 -0
  10. tnfr/backends/jax_backend.py +173 -0
  11. tnfr/backends/numpy_backend.py +238 -0
  12. tnfr/backends/optimized_numpy.py +420 -0
  13. tnfr/backends/torch_backend.py +408 -0
  14. tnfr/cache.py +171 -0
  15. tnfr/cache.pyi +13 -0
  16. tnfr/cli/__init__.py +110 -0
  17. tnfr/cli/__init__.pyi +26 -0
  18. tnfr/cli/arguments.py +489 -0
  19. tnfr/cli/arguments.pyi +29 -0
  20. tnfr/cli/execution.py +914 -0
  21. tnfr/cli/execution.pyi +70 -0
  22. tnfr/cli/interactive_validator.py +614 -0
  23. tnfr/cli/utils.py +51 -0
  24. tnfr/cli/utils.pyi +7 -0
  25. tnfr/cli/validate.py +236 -0
  26. tnfr/compat/__init__.py +85 -0
  27. tnfr/compat/dataclass.py +136 -0
  28. tnfr/compat/jsonschema_stub.py +61 -0
  29. tnfr/compat/matplotlib_stub.py +73 -0
  30. tnfr/compat/numpy_stub.py +155 -0
  31. tnfr/config/__init__.py +224 -0
  32. tnfr/config/__init__.pyi +10 -0
  33. tnfr/config/constants.py +104 -0
  34. tnfr/config/constants.pyi +12 -0
  35. tnfr/config/defaults.py +54 -0
  36. tnfr/config/defaults_core.py +212 -0
  37. tnfr/config/defaults_init.py +33 -0
  38. tnfr/config/defaults_metric.py +104 -0
  39. tnfr/config/feature_flags.py +81 -0
  40. tnfr/config/feature_flags.pyi +16 -0
  41. tnfr/config/glyph_constants.py +31 -0
  42. tnfr/config/init.py +77 -0
  43. tnfr/config/init.pyi +8 -0
  44. tnfr/config/operator_names.py +254 -0
  45. tnfr/config/operator_names.pyi +36 -0
  46. tnfr/config/physics_derivation.py +354 -0
  47. tnfr/config/presets.py +83 -0
  48. tnfr/config/presets.pyi +7 -0
  49. tnfr/config/security.py +927 -0
  50. tnfr/config/thresholds.py +114 -0
  51. tnfr/config/tnfr_config.py +498 -0
  52. tnfr/constants/__init__.py +92 -0
  53. tnfr/constants/__init__.pyi +92 -0
  54. tnfr/constants/aliases.py +33 -0
  55. tnfr/constants/aliases.pyi +27 -0
  56. tnfr/constants/init.py +33 -0
  57. tnfr/constants/init.pyi +12 -0
  58. tnfr/constants/metric.py +104 -0
  59. tnfr/constants/metric.pyi +19 -0
  60. tnfr/core/__init__.py +33 -0
  61. tnfr/core/container.py +226 -0
  62. tnfr/core/default_implementations.py +329 -0
  63. tnfr/core/interfaces.py +279 -0
  64. tnfr/dynamics/__init__.py +238 -0
  65. tnfr/dynamics/__init__.pyi +83 -0
  66. tnfr/dynamics/adaptation.py +267 -0
  67. tnfr/dynamics/adaptation.pyi +7 -0
  68. tnfr/dynamics/adaptive_sequences.py +189 -0
  69. tnfr/dynamics/adaptive_sequences.pyi +14 -0
  70. tnfr/dynamics/aliases.py +23 -0
  71. tnfr/dynamics/aliases.pyi +19 -0
  72. tnfr/dynamics/bifurcation.py +232 -0
  73. tnfr/dynamics/canonical.py +229 -0
  74. tnfr/dynamics/canonical.pyi +48 -0
  75. tnfr/dynamics/coordination.py +385 -0
  76. tnfr/dynamics/coordination.pyi +25 -0
  77. tnfr/dynamics/dnfr.py +3034 -0
  78. tnfr/dynamics/dnfr.pyi +26 -0
  79. tnfr/dynamics/dynamic_limits.py +225 -0
  80. tnfr/dynamics/feedback.py +252 -0
  81. tnfr/dynamics/feedback.pyi +24 -0
  82. tnfr/dynamics/fused_dnfr.py +454 -0
  83. tnfr/dynamics/homeostasis.py +157 -0
  84. tnfr/dynamics/homeostasis.pyi +14 -0
  85. tnfr/dynamics/integrators.py +661 -0
  86. tnfr/dynamics/integrators.pyi +36 -0
  87. tnfr/dynamics/learning.py +310 -0
  88. tnfr/dynamics/learning.pyi +33 -0
  89. tnfr/dynamics/metabolism.py +254 -0
  90. tnfr/dynamics/nbody.py +796 -0
  91. tnfr/dynamics/nbody_tnfr.py +783 -0
  92. tnfr/dynamics/propagation.py +326 -0
  93. tnfr/dynamics/runtime.py +908 -0
  94. tnfr/dynamics/runtime.pyi +77 -0
  95. tnfr/dynamics/sampling.py +36 -0
  96. tnfr/dynamics/sampling.pyi +7 -0
  97. tnfr/dynamics/selectors.py +711 -0
  98. tnfr/dynamics/selectors.pyi +85 -0
  99. tnfr/dynamics/structural_clip.py +207 -0
  100. tnfr/errors/__init__.py +37 -0
  101. tnfr/errors/contextual.py +492 -0
  102. tnfr/execution.py +223 -0
  103. tnfr/execution.pyi +45 -0
  104. tnfr/extensions/__init__.py +205 -0
  105. tnfr/extensions/__init__.pyi +18 -0
  106. tnfr/extensions/base.py +173 -0
  107. tnfr/extensions/base.pyi +35 -0
  108. tnfr/extensions/business/__init__.py +71 -0
  109. tnfr/extensions/business/__init__.pyi +11 -0
  110. tnfr/extensions/business/cookbook.py +88 -0
  111. tnfr/extensions/business/cookbook.pyi +8 -0
  112. tnfr/extensions/business/health_analyzers.py +202 -0
  113. tnfr/extensions/business/health_analyzers.pyi +9 -0
  114. tnfr/extensions/business/patterns.py +183 -0
  115. tnfr/extensions/business/patterns.pyi +8 -0
  116. tnfr/extensions/medical/__init__.py +73 -0
  117. tnfr/extensions/medical/__init__.pyi +11 -0
  118. tnfr/extensions/medical/cookbook.py +88 -0
  119. tnfr/extensions/medical/cookbook.pyi +8 -0
  120. tnfr/extensions/medical/health_analyzers.py +181 -0
  121. tnfr/extensions/medical/health_analyzers.pyi +9 -0
  122. tnfr/extensions/medical/patterns.py +163 -0
  123. tnfr/extensions/medical/patterns.pyi +8 -0
  124. tnfr/flatten.py +262 -0
  125. tnfr/flatten.pyi +21 -0
  126. tnfr/gamma.py +354 -0
  127. tnfr/gamma.pyi +36 -0
  128. tnfr/glyph_history.py +377 -0
  129. tnfr/glyph_history.pyi +35 -0
  130. tnfr/glyph_runtime.py +19 -0
  131. tnfr/glyph_runtime.pyi +8 -0
  132. tnfr/immutable.py +218 -0
  133. tnfr/immutable.pyi +36 -0
  134. tnfr/initialization.py +203 -0
  135. tnfr/initialization.pyi +65 -0
  136. tnfr/io.py +10 -0
  137. tnfr/io.pyi +13 -0
  138. tnfr/locking.py +37 -0
  139. tnfr/locking.pyi +7 -0
  140. tnfr/mathematics/__init__.py +79 -0
  141. tnfr/mathematics/backend.py +453 -0
  142. tnfr/mathematics/backend.pyi +99 -0
  143. tnfr/mathematics/dynamics.py +408 -0
  144. tnfr/mathematics/dynamics.pyi +90 -0
  145. tnfr/mathematics/epi.py +391 -0
  146. tnfr/mathematics/epi.pyi +65 -0
  147. tnfr/mathematics/generators.py +242 -0
  148. tnfr/mathematics/generators.pyi +29 -0
  149. tnfr/mathematics/metrics.py +119 -0
  150. tnfr/mathematics/metrics.pyi +16 -0
  151. tnfr/mathematics/operators.py +239 -0
  152. tnfr/mathematics/operators.pyi +59 -0
  153. tnfr/mathematics/operators_factory.py +124 -0
  154. tnfr/mathematics/operators_factory.pyi +11 -0
  155. tnfr/mathematics/projection.py +87 -0
  156. tnfr/mathematics/projection.pyi +33 -0
  157. tnfr/mathematics/runtime.py +182 -0
  158. tnfr/mathematics/runtime.pyi +64 -0
  159. tnfr/mathematics/spaces.py +256 -0
  160. tnfr/mathematics/spaces.pyi +83 -0
  161. tnfr/mathematics/transforms.py +305 -0
  162. tnfr/mathematics/transforms.pyi +62 -0
  163. tnfr/metrics/__init__.py +79 -0
  164. tnfr/metrics/__init__.pyi +20 -0
  165. tnfr/metrics/buffer_cache.py +163 -0
  166. tnfr/metrics/buffer_cache.pyi +24 -0
  167. tnfr/metrics/cache_utils.py +214 -0
  168. tnfr/metrics/coherence.py +2009 -0
  169. tnfr/metrics/coherence.pyi +129 -0
  170. tnfr/metrics/common.py +158 -0
  171. tnfr/metrics/common.pyi +35 -0
  172. tnfr/metrics/core.py +316 -0
  173. tnfr/metrics/core.pyi +13 -0
  174. tnfr/metrics/diagnosis.py +833 -0
  175. tnfr/metrics/diagnosis.pyi +86 -0
  176. tnfr/metrics/emergence.py +245 -0
  177. tnfr/metrics/export.py +179 -0
  178. tnfr/metrics/export.pyi +7 -0
  179. tnfr/metrics/glyph_timing.py +379 -0
  180. tnfr/metrics/glyph_timing.pyi +81 -0
  181. tnfr/metrics/learning_metrics.py +280 -0
  182. tnfr/metrics/learning_metrics.pyi +21 -0
  183. tnfr/metrics/phase_coherence.py +351 -0
  184. tnfr/metrics/phase_compatibility.py +349 -0
  185. tnfr/metrics/reporting.py +183 -0
  186. tnfr/metrics/reporting.pyi +25 -0
  187. tnfr/metrics/sense_index.py +1203 -0
  188. tnfr/metrics/sense_index.pyi +9 -0
  189. tnfr/metrics/trig.py +373 -0
  190. tnfr/metrics/trig.pyi +13 -0
  191. tnfr/metrics/trig_cache.py +233 -0
  192. tnfr/metrics/trig_cache.pyi +10 -0
  193. tnfr/multiscale/__init__.py +32 -0
  194. tnfr/multiscale/hierarchical.py +517 -0
  195. tnfr/node.py +763 -0
  196. tnfr/node.pyi +139 -0
  197. tnfr/observers.py +255 -130
  198. tnfr/observers.pyi +31 -0
  199. tnfr/ontosim.py +144 -137
  200. tnfr/ontosim.pyi +28 -0
  201. tnfr/operators/__init__.py +1672 -0
  202. tnfr/operators/__init__.pyi +31 -0
  203. tnfr/operators/algebra.py +277 -0
  204. tnfr/operators/canonical_patterns.py +420 -0
  205. tnfr/operators/cascade.py +267 -0
  206. tnfr/operators/cycle_detection.py +358 -0
  207. tnfr/operators/definitions.py +4108 -0
  208. tnfr/operators/definitions.pyi +78 -0
  209. tnfr/operators/grammar.py +1164 -0
  210. tnfr/operators/grammar.pyi +140 -0
  211. tnfr/operators/hamiltonian.py +710 -0
  212. tnfr/operators/health_analyzer.py +809 -0
  213. tnfr/operators/jitter.py +272 -0
  214. tnfr/operators/jitter.pyi +11 -0
  215. tnfr/operators/lifecycle.py +314 -0
  216. tnfr/operators/metabolism.py +618 -0
  217. tnfr/operators/metrics.py +2138 -0
  218. tnfr/operators/network_analysis/__init__.py +27 -0
  219. tnfr/operators/network_analysis/source_detection.py +186 -0
  220. tnfr/operators/nodal_equation.py +395 -0
  221. tnfr/operators/pattern_detection.py +660 -0
  222. tnfr/operators/patterns.py +669 -0
  223. tnfr/operators/postconditions/__init__.py +38 -0
  224. tnfr/operators/postconditions/mutation.py +236 -0
  225. tnfr/operators/preconditions/__init__.py +1226 -0
  226. tnfr/operators/preconditions/coherence.py +305 -0
  227. tnfr/operators/preconditions/dissonance.py +236 -0
  228. tnfr/operators/preconditions/emission.py +128 -0
  229. tnfr/operators/preconditions/mutation.py +580 -0
  230. tnfr/operators/preconditions/reception.py +125 -0
  231. tnfr/operators/preconditions/resonance.py +364 -0
  232. tnfr/operators/registry.py +74 -0
  233. tnfr/operators/registry.pyi +9 -0
  234. tnfr/operators/remesh.py +1809 -0
  235. tnfr/operators/remesh.pyi +26 -0
  236. tnfr/operators/structural_units.py +268 -0
  237. tnfr/operators/unified_grammar.py +105 -0
  238. tnfr/parallel/__init__.py +54 -0
  239. tnfr/parallel/auto_scaler.py +234 -0
  240. tnfr/parallel/distributed.py +384 -0
  241. tnfr/parallel/engine.py +238 -0
  242. tnfr/parallel/gpu_engine.py +420 -0
  243. tnfr/parallel/monitoring.py +248 -0
  244. tnfr/parallel/partitioner.py +459 -0
  245. tnfr/py.typed +0 -0
  246. tnfr/recipes/__init__.py +22 -0
  247. tnfr/recipes/cookbook.py +743 -0
  248. tnfr/rng.py +178 -0
  249. tnfr/rng.pyi +26 -0
  250. tnfr/schemas/__init__.py +8 -0
  251. tnfr/schemas/grammar.json +94 -0
  252. tnfr/sdk/__init__.py +107 -0
  253. tnfr/sdk/__init__.pyi +19 -0
  254. tnfr/sdk/adaptive_system.py +173 -0
  255. tnfr/sdk/adaptive_system.pyi +21 -0
  256. tnfr/sdk/builders.py +370 -0
  257. tnfr/sdk/builders.pyi +51 -0
  258. tnfr/sdk/fluent.py +1121 -0
  259. tnfr/sdk/fluent.pyi +74 -0
  260. tnfr/sdk/templates.py +342 -0
  261. tnfr/sdk/templates.pyi +41 -0
  262. tnfr/sdk/utils.py +341 -0
  263. tnfr/secure_config.py +46 -0
  264. tnfr/security/__init__.py +70 -0
  265. tnfr/security/database.py +514 -0
  266. tnfr/security/subprocess.py +503 -0
  267. tnfr/security/validation.py +290 -0
  268. tnfr/selector.py +247 -0
  269. tnfr/selector.pyi +19 -0
  270. tnfr/sense.py +378 -0
  271. tnfr/sense.pyi +23 -0
  272. tnfr/services/__init__.py +17 -0
  273. tnfr/services/orchestrator.py +325 -0
  274. tnfr/sparse/__init__.py +39 -0
  275. tnfr/sparse/representations.py +492 -0
  276. tnfr/structural.py +705 -0
  277. tnfr/structural.pyi +83 -0
  278. tnfr/telemetry/__init__.py +35 -0
  279. tnfr/telemetry/cache_metrics.py +226 -0
  280. tnfr/telemetry/cache_metrics.pyi +64 -0
  281. tnfr/telemetry/nu_f.py +422 -0
  282. tnfr/telemetry/nu_f.pyi +108 -0
  283. tnfr/telemetry/verbosity.py +36 -0
  284. tnfr/telemetry/verbosity.pyi +15 -0
  285. tnfr/tokens.py +58 -0
  286. tnfr/tokens.pyi +36 -0
  287. tnfr/tools/__init__.py +20 -0
  288. tnfr/tools/domain_templates.py +478 -0
  289. tnfr/tools/sequence_generator.py +846 -0
  290. tnfr/topology/__init__.py +13 -0
  291. tnfr/topology/asymmetry.py +151 -0
  292. tnfr/trace.py +543 -0
  293. tnfr/trace.pyi +42 -0
  294. tnfr/tutorials/__init__.py +38 -0
  295. tnfr/tutorials/autonomous_evolution.py +285 -0
  296. tnfr/tutorials/interactive.py +1576 -0
  297. tnfr/tutorials/structural_metabolism.py +238 -0
  298. tnfr/types.py +775 -0
  299. tnfr/types.pyi +357 -0
  300. tnfr/units.py +68 -0
  301. tnfr/units.pyi +13 -0
  302. tnfr/utils/__init__.py +282 -0
  303. tnfr/utils/__init__.pyi +215 -0
  304. tnfr/utils/cache.py +4223 -0
  305. tnfr/utils/cache.pyi +470 -0
  306. tnfr/utils/callbacks.py +375 -0
  307. tnfr/utils/callbacks.pyi +49 -0
  308. tnfr/utils/chunks.py +108 -0
  309. tnfr/utils/chunks.pyi +22 -0
  310. tnfr/utils/data.py +428 -0
  311. tnfr/utils/data.pyi +74 -0
  312. tnfr/utils/graph.py +85 -0
  313. tnfr/utils/graph.pyi +10 -0
  314. tnfr/utils/init.py +821 -0
  315. tnfr/utils/init.pyi +80 -0
  316. tnfr/utils/io.py +559 -0
  317. tnfr/utils/io.pyi +66 -0
  318. tnfr/utils/numeric.py +114 -0
  319. tnfr/utils/numeric.pyi +21 -0
  320. tnfr/validation/__init__.py +257 -0
  321. tnfr/validation/__init__.pyi +85 -0
  322. tnfr/validation/compatibility.py +460 -0
  323. tnfr/validation/compatibility.pyi +6 -0
  324. tnfr/validation/config.py +73 -0
  325. tnfr/validation/graph.py +139 -0
  326. tnfr/validation/graph.pyi +18 -0
  327. tnfr/validation/input_validation.py +755 -0
  328. tnfr/validation/invariants.py +712 -0
  329. tnfr/validation/rules.py +253 -0
  330. tnfr/validation/rules.pyi +44 -0
  331. tnfr/validation/runtime.py +279 -0
  332. tnfr/validation/runtime.pyi +28 -0
  333. tnfr/validation/sequence_validator.py +162 -0
  334. tnfr/validation/soft_filters.py +170 -0
  335. tnfr/validation/soft_filters.pyi +32 -0
  336. tnfr/validation/spectral.py +164 -0
  337. tnfr/validation/spectral.pyi +42 -0
  338. tnfr/validation/validator.py +1266 -0
  339. tnfr/validation/window.py +39 -0
  340. tnfr/validation/window.pyi +1 -0
  341. tnfr/visualization/__init__.py +98 -0
  342. tnfr/visualization/cascade_viz.py +256 -0
  343. tnfr/visualization/hierarchy.py +284 -0
  344. tnfr/visualization/sequence_plotter.py +784 -0
  345. tnfr/viz/__init__.py +60 -0
  346. tnfr/viz/matplotlib.py +278 -0
  347. tnfr/viz/matplotlib.pyi +35 -0
  348. tnfr-8.5.0.dist-info/METADATA +573 -0
  349. tnfr-8.5.0.dist-info/RECORD +353 -0
  350. tnfr-8.5.0.dist-info/entry_points.txt +3 -0
  351. tnfr-3.0.3.dist-info/licenses/LICENSE.txt → tnfr-8.5.0.dist-info/licenses/LICENSE.md +1 -1
  352. tnfr/constants.py +0 -183
  353. tnfr/dynamics.py +0 -543
  354. tnfr/helpers.py +0 -198
  355. tnfr/main.py +0 -37
  356. tnfr/operators.py +0 -296
  357. tnfr-3.0.3.dist-info/METADATA +0 -35
  358. tnfr-3.0.3.dist-info/RECORD +0 -13
  359. {tnfr-3.0.3.dist-info → tnfr-8.5.0.dist-info}/WHEEL +0 -0
  360. {tnfr-3.0.3.dist-info → tnfr-8.5.0.dist-info}/top_level.txt +0 -0
tnfr/types.py ADDED
@@ -0,0 +1,775 @@
1
+ """Type definitions and protocols shared across the engine."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import (
6
+ Callable,
7
+ Hashable,
8
+ Iterable,
9
+ Mapping,
10
+ MutableMapping,
11
+ MutableSequence,
12
+ Sequence,
13
+ )
14
+ from enum import Enum
15
+ from types import SimpleNamespace
16
+ from typing import (
17
+ TYPE_CHECKING,
18
+ Any,
19
+ ContextManager,
20
+ Iterable,
21
+ Protocol,
22
+ TypedDict,
23
+ runtime_checkable,
24
+ )
25
+
26
+ from numbers import Real
27
+
28
+ from ._compat import TypeAlias
29
+
30
+ if TYPE_CHECKING:
31
+ from .mathematics import BEPIElement
32
+
33
+ try: # pragma: no cover - optional dependency for typing only
34
+ import numpy as np
35
+ except Exception: # pragma: no cover - graceful fallback when NumPy is missing
36
+ np = SimpleNamespace(ndarray=Any, float64=float) # type: ignore[assignment]
37
+
38
+ if TYPE_CHECKING: # pragma: no cover - import-time typing hook
39
+ try:
40
+ import numpy.typing as npt
41
+ except Exception: # pragma: no cover - fallback when NumPy typing is missing
42
+ npt = SimpleNamespace(NDArray=Any) # type: ignore[assignment]
43
+ else: # pragma: no cover - runtime fallback without numpy.typing
44
+ npt = SimpleNamespace(NDArray=Any) # type: ignore[assignment]
45
+
46
+ __all__ = (
47
+ "TNFRGraph",
48
+ "Graph",
49
+ "ValidatorFunc",
50
+ "NodeId",
51
+ "Node",
52
+ "GammaSpec",
53
+ "EPIValue",
54
+ "BEPIProtocol",
55
+ "ensure_bepi",
56
+ "serialize_bepi",
57
+ "serialize_bepi_json",
58
+ "deserialize_bepi_json",
59
+ "ZERO_BEPI_STORAGE",
60
+ "DeltaNFR",
61
+ "SecondDerivativeEPI",
62
+ "Phase",
63
+ "StructuralFrequency",
64
+ "SenseIndex",
65
+ "CouplingWeight",
66
+ "CoherenceMetric",
67
+ "DeltaNFRHook",
68
+ "GraphLike",
69
+ "IntegratorProtocol",
70
+ "Glyph",
71
+ "GlyphCode",
72
+ "GlyphLoadDistribution",
73
+ "GlyphSelector",
74
+ "SelectorPreselectionMetrics",
75
+ "SelectorPreselectionChoices",
76
+ "SelectorPreselectionPayload",
77
+ "SelectorMetrics",
78
+ "SelectorNorms",
79
+ "SelectorThresholds",
80
+ "SelectorWeights",
81
+ "TraceCallback",
82
+ "CallbackError",
83
+ "TraceFieldFn",
84
+ "TraceFieldMap",
85
+ "TraceFieldRegistry",
86
+ "TraceMetadata",
87
+ "TraceSnapshot",
88
+ "RemeshMeta",
89
+ "HistoryState",
90
+ "DiagnosisNodeData",
91
+ "DiagnosisSharedState",
92
+ "DiagnosisPayload",
93
+ "DiagnosisResult",
94
+ "DiagnosisPayloadChunk",
95
+ "DiagnosisResultList",
96
+ "DnfrCacheVectors",
97
+ "DnfrVectorMap",
98
+ "NeighborStats",
99
+ "TimingContext",
100
+ "PresetTokens",
101
+ "ProgramTokens",
102
+ "ArgSpec",
103
+ "TNFRConfigValue",
104
+ "SigmaVector",
105
+ "SigmaTrace",
106
+ "FloatArray",
107
+ "FloatMatrix",
108
+ "NodeInitAttrMap",
109
+ "NodeAttrMap",
110
+ "GlyphogramRow",
111
+ "GlyphTimingTotals",
112
+ "GlyphTimingByNode",
113
+ "GlyphCounts",
114
+ "GlyphMetricsHistoryValue",
115
+ "GlyphMetricsHistory",
116
+ "MetricsListHistory",
117
+ "ParallelWijPayload",
118
+ )
119
+
120
+ if TYPE_CHECKING: # pragma: no cover - import-time typing hook
121
+ import networkx as nx
122
+
123
+ from .glyph_history import HistoryDict as _HistoryDict
124
+ from .tokens import Token as _Token
125
+
126
+ TNFRGraph: TypeAlias = nx.Graph
127
+ else: # pragma: no cover - runtime fallback without networkx
128
+ TNFRGraph: TypeAlias = Any
129
+ _HistoryDict = Any # type: ignore[assignment]
130
+ _Token = Any # type: ignore[assignment]
131
+ #: Graph container storing TNFR nodes, edges and their coherence telemetry.
132
+
133
+ if TYPE_CHECKING:
134
+ FloatArray: TypeAlias = npt.NDArray[np.float64]
135
+ FloatMatrix: TypeAlias = npt.NDArray[np.float64]
136
+ else: # pragma: no cover - runtime fallback without NumPy
137
+ FloatArray: TypeAlias = Any
138
+ FloatMatrix: TypeAlias = Any
139
+
140
+ Graph: TypeAlias = TNFRGraph
141
+ #: Backwards-compatible alias for :data:`TNFRGraph`.
142
+
143
+ ValidatorFunc: TypeAlias = Callable[[TNFRGraph], None]
144
+ """Callable signature enforced by graph validation hooks."""
145
+
146
+ NodeId: TypeAlias = Hashable
147
+ #: Hashable identifier for a coherent TNFR node.
148
+
149
+ Node: TypeAlias = NodeId
150
+ #: Backwards-compatible alias for :data:`NodeId`.
151
+
152
+ NodeInitAttrMap: TypeAlias = MutableMapping[str, float]
153
+ #: Mutable mapping storing scalar node attributes during initialization.
154
+
155
+ NodeAttrMap: TypeAlias = Mapping[str, Any]
156
+ #: Read-only mapping exposing resolved node attributes during execution.
157
+
158
+ GammaSpec: TypeAlias = Mapping[str, Any]
159
+ #: Mapping describing Γ evaluation parameters for a node or graph.
160
+
161
+
162
+ @runtime_checkable
163
+ class BEPIProtocol(Protocol):
164
+ """Structural contract describing BEPI-compatible values."""
165
+
166
+ f_continuous: Any
167
+ a_discrete: Any
168
+ x_grid: Any
169
+
170
+ def direct_sum(self, other: Any) -> Any: ...
171
+
172
+ def tensor(self, vector: Sequence[complex] | np.ndarray) -> np.ndarray: ...
173
+
174
+ def adjoint(self) -> Any: ...
175
+
176
+ def compose(
177
+ self,
178
+ transform: Callable[[np.ndarray], np.ndarray],
179
+ *,
180
+ spectral_transform: Callable[[np.ndarray], np.ndarray] | None = None,
181
+ ) -> Any: ...
182
+
183
+
184
+ EPIValue: TypeAlias = BEPIProtocol
185
+ #: BEPI Primary Information Structure carried by a node.
186
+
187
+ ZERO_BEPI_STORAGE: dict[str, tuple[complex, ...] | tuple[float, ...]] = {
188
+ "continuous": (0j, 0j),
189
+ "discrete": (0j, 0j),
190
+ "grid": (0.0, 1.0),
191
+ }
192
+ """Canonical zero element used as fallback when EPI data is missing."""
193
+
194
+
195
+ def _is_scalar(value: Any) -> bool:
196
+ scalar_types: tuple[type[Any], ...]
197
+ np_scalar = getattr(np, "generic", None)
198
+ if np_scalar is None:
199
+ scalar_types = (int, float, complex, Real)
200
+ else:
201
+ scalar_types = (int, float, complex, Real, np_scalar)
202
+ return isinstance(value, scalar_types)
203
+
204
+
205
+ def ensure_bepi(value: Any) -> "BEPIElement":
206
+ """Normalise arbitrary inputs into a :class:`~tnfr.mathematics.BEPIElement`."""
207
+
208
+ from .mathematics import BEPIElement as _BEPIElement
209
+
210
+ if isinstance(value, _BEPIElement):
211
+ return value
212
+ if _is_scalar(value):
213
+ scalar = complex(value)
214
+ return _BEPIElement((scalar, scalar), (scalar, scalar), (0.0, 1.0))
215
+ if isinstance(value, Mapping):
216
+ try:
217
+ continuous = value["continuous"]
218
+ discrete = value["discrete"]
219
+ grid = value["grid"]
220
+ except KeyError as exc: # pragma: no cover - defensive
221
+ missing = exc.args[0]
222
+ raise ValueError(
223
+ f"Missing '{missing}' key for BEPI serialization."
224
+ ) from exc
225
+ return _BEPIElement(continuous, discrete, grid)
226
+ if isinstance(value, Sequence) and not isinstance(value, (str, bytes, bytearray)):
227
+ if len(value) != 3:
228
+ raise ValueError("Sequential BEPI representations must contain 3 elements.")
229
+ continuous, discrete, grid = value
230
+ return _BEPIElement(continuous, discrete, grid)
231
+ raise TypeError(f"Unsupported BEPI value type: {type(value)!r}")
232
+
233
+
234
+ def serialize_bepi(value: Any) -> dict[str, tuple[complex, ...] | tuple[float, ...]]:
235
+ """Serialise a BEPI element into canonical ``continuous/discrete/grid`` tuples."""
236
+
237
+ element = ensure_bepi(value)
238
+ continuous = tuple(complex(v) for v in element.f_continuous.tolist())
239
+ discrete = tuple(complex(v) for v in element.a_discrete.tolist())
240
+ grid = tuple(float(v) for v in element.x_grid.tolist())
241
+ return {"continuous": continuous, "discrete": discrete, "grid": grid}
242
+
243
+
244
+ def serialize_bepi_json(value: Any) -> dict[str, list[dict[str, float]] | list[float]]:
245
+ """Serialize a BEPI element into JSON-compatible format.
246
+
247
+ Complex numbers are represented as dicts with 'real' and 'imag' keys.
248
+ This enables full JSON/YAML serialization while preserving structural coherence.
249
+
250
+ Parameters
251
+ ----------
252
+ value : Any
253
+ A BEPIElement instance or value convertible to one.
254
+
255
+ Returns
256
+ -------
257
+ dict
258
+ Dictionary with 'continuous', 'discrete', and 'grid' keys, where
259
+ complex values are represented as ``{"real": float, "imag": float}``
260
+ and grid values remain as floats.
261
+
262
+ Examples
263
+ --------
264
+ >>> from tnfr.mathematics import BEPIElement
265
+ >>> bepi = BEPIElement((1+2j, 3+0j), (4+5j,), (0.0, 1.0))
266
+ >>> serialize_bepi_json(bepi) # doctest: +SKIP
267
+ {
268
+ 'continuous': [{'real': 1.0, 'imag': 2.0}, {'real': 3.0, 'imag': 0.0}],
269
+ 'discrete': [{'real': 4.0, 'imag': 5.0}],
270
+ 'grid': [0.0, 1.0]
271
+ }
272
+ """
273
+ element = ensure_bepi(value)
274
+
275
+ def _complex_to_dict(c: complex) -> dict[str, float]:
276
+ return {"real": float(c.real), "imag": float(c.imag)}
277
+
278
+ continuous = [_complex_to_dict(v) for v in element.f_continuous.tolist()]
279
+ discrete = [_complex_to_dict(v) for v in element.a_discrete.tolist()]
280
+ grid = [float(v) for v in element.x_grid.tolist()]
281
+
282
+ return {"continuous": continuous, "discrete": discrete, "grid": grid}
283
+
284
+
285
+ def deserialize_bepi_json(
286
+ data: dict[str, list[dict[str, float]] | list[float]],
287
+ ) -> "BEPIElement":
288
+ """Deserialize a BEPI element from JSON-compatible format.
289
+
290
+ Reconstructs complex numbers from dicts with 'real' and 'imag' keys.
291
+
292
+ Parameters
293
+ ----------
294
+ data : dict
295
+ Dictionary with 'continuous', 'discrete', and 'grid' keys in JSON format.
296
+ The 'continuous' and 'discrete' values should be lists of dicts with
297
+ 'real' and 'imag' keys, while 'grid' should be a list of floats.
298
+
299
+ Returns
300
+ -------
301
+ BEPIElement
302
+ Reconstructed BEPI element with validated structural integrity.
303
+
304
+ Examples
305
+ --------
306
+ >>> data = {
307
+ ... 'continuous': [{'real': 1.0, 'imag': 2.0}, {'real': 3.0, 'imag': 0.0}],
308
+ ... 'discrete': [{'real': 4.0, 'imag': 5.0}],
309
+ ... 'grid': [0.0, 1.0]
310
+ ... }
311
+ >>> bepi = deserialize_bepi_json(data) # doctest: +SKIP
312
+ """
313
+ from .mathematics import BEPIElement as _BEPIElement
314
+
315
+ def _dict_to_complex(d: dict[str, float] | float | complex) -> complex:
316
+ if isinstance(d, dict):
317
+ return complex(d["real"], d["imag"])
318
+ return complex(d)
319
+
320
+ continuous = [_dict_to_complex(v) for v in data["continuous"]]
321
+ discrete = [_dict_to_complex(v) for v in data["discrete"]]
322
+ grid = data["grid"]
323
+
324
+ return _BEPIElement(continuous, discrete, grid)
325
+
326
+
327
+ DeltaNFR: TypeAlias = float
328
+ #: Scalar internal reorganisation driver ΔNFR applied to a node.
329
+
330
+ SecondDerivativeEPI: TypeAlias = float
331
+ #: Second derivative ∂²EPI/∂t² tracking bifurcation pressure.
332
+
333
+ Phase: TypeAlias = float
334
+ #: Phase (φ) describing a node's synchrony relative to its neighbors.
335
+
336
+ StructuralFrequency: TypeAlias = float
337
+ #: Structural frequency νf expressed in Hz_str.
338
+
339
+ SenseIndex: TypeAlias = float
340
+ #: Sense index Si capturing a node's reorganising capacity.
341
+
342
+ CouplingWeight: TypeAlias = float
343
+ #: Weight attached to edges describing coupling coherence strength.
344
+
345
+ CoherenceMetric: TypeAlias = float
346
+ #: Aggregated measure of coherence such as C(t) or Si.
347
+
348
+ TimingContext: TypeAlias = ContextManager[None]
349
+ #: Context manager used to measure execution time for cache operations.
350
+
351
+ ProgramTokens: TypeAlias = Sequence[_Token]
352
+ #: Sequence of execution tokens composing a TNFR program.
353
+
354
+ PresetTokens: TypeAlias = Sequence[_Token]
355
+ #: Sequence of execution tokens composing a preset program.
356
+
357
+ ArgSpec: TypeAlias = tuple[str, Mapping[str, Any]]
358
+ #: CLI argument specification pairing an option flag with keyword arguments.
359
+
360
+ TNFRConfigScalar: TypeAlias = bool | int | float | str | None
361
+ """Primitive value allowed within TNFR configuration stores."""
362
+
363
+ TNFRConfigSequence: TypeAlias = Sequence[TNFRConfigScalar]
364
+ """Homogeneous sequence of scalar TNFR configuration values."""
365
+
366
+ TNFRConfigValue: TypeAlias = (
367
+ TNFRConfigScalar | TNFRConfigSequence | MutableMapping[str, "TNFRConfigValue"]
368
+ )
369
+ """Permissible configuration entry for TNFR coherence defaults.
370
+
371
+ The alias captures the recursive structure used by TNFR defaults: scalars
372
+ express structural thresholds, booleans toggle operators, and nested mappings
373
+ or sequences describe coherent parameter bundles such as γ grammars,
374
+ selector advice or trace capture lists.
375
+
376
+ Configuration dictionaries support the full :class:`~collections.abc.MutableMapping`
377
+ protocol, enabling dict-like operations such as ``.get()``, ``__setitem__``,
378
+ and ``.update()`` for runtime configuration adjustments.
379
+ """
380
+
381
+
382
+ class _SigmaVectorRequired(TypedDict):
383
+ """Mandatory components for a σ-vector in the sense plane."""
384
+
385
+ x: float
386
+ y: float
387
+ mag: float
388
+ angle: float
389
+ n: int
390
+
391
+
392
+ class _SigmaVectorOptional(TypedDict, total=False):
393
+ """Optional metadata captured when tracking σ-vectors."""
394
+
395
+ glyph: str
396
+ w: float
397
+ t: float
398
+
399
+
400
+ class SigmaVector(_SigmaVectorRequired, _SigmaVectorOptional):
401
+ """Typed dictionary describing σ-vector telemetry."""
402
+
403
+
404
+ class SigmaTrace(TypedDict):
405
+ """Time-aligned σ(t) trace exported alongside glyphograms."""
406
+
407
+ t: list[float]
408
+ sigma_x: list[float]
409
+ sigma_y: list[float]
410
+ mag: list[float]
411
+ angle: list[float]
412
+
413
+
414
+ class SelectorThresholds(TypedDict):
415
+ """Normalised thresholds applied by the glyph selector."""
416
+
417
+ si_hi: float
418
+ si_lo: float
419
+ dnfr_hi: float
420
+ dnfr_lo: float
421
+ accel_hi: float
422
+ accel_lo: float
423
+
424
+
425
+ class SelectorWeights(TypedDict):
426
+ """Normalised weights controlling selector scoring."""
427
+
428
+ w_si: float
429
+ w_dnfr: float
430
+ w_accel: float
431
+
432
+
433
+ SelectorMetrics: TypeAlias = tuple[float, float, float]
434
+ """Tuple grouping normalised Si, |ΔNFR| and acceleration values."""
435
+
436
+ SelectorNorms: TypeAlias = Mapping[str, float]
437
+ """Mapping storing maxima used to normalise selector metrics."""
438
+
439
+
440
+ @runtime_checkable
441
+ class _DeltaNFRHookProtocol(Protocol):
442
+ """Callable signature expected for ΔNFR update hooks.
443
+
444
+ Hooks receive the graph instance and may expose optional keyword
445
+ arguments such as ``n_jobs`` or cache controls. Additional positional
446
+ arguments are reserved for future extensions and ignored by the core
447
+ engine, keeping compatibility with user-provided hooks that only need the
448
+ graph reference.
449
+
450
+ Notes
451
+ -----
452
+ Marked with @runtime_checkable to enable isinstance() checks for validating
453
+ hook implementations conform to the expected callable signature.
454
+ """
455
+
456
+ def __call__(
457
+ self,
458
+ graph: TNFRGraph,
459
+ /,
460
+ *args: Any,
461
+ **kwargs: Any,
462
+ ) -> None: ...
463
+
464
+
465
+ DeltaNFRHook: TypeAlias = _DeltaNFRHookProtocol
466
+ #: Callable hook invoked to compute ΔNFR for a :data:`TNFRGraph`.
467
+
468
+
469
+ @runtime_checkable
470
+ class _NodeViewLike(Protocol):
471
+ """Subset of :class:`networkx.NodeView` behaviour relied on by TNFR.
472
+
473
+ Notes
474
+ -----
475
+ Marked with @runtime_checkable to enable isinstance() checks for validating
476
+ node view implementations conform to the expected interface.
477
+ """
478
+
479
+ def __iter__(self) -> Iterable[Any]: ...
480
+
481
+ def __call__(self, data: bool = ...) -> Iterable[Any]: ...
482
+
483
+ def __getitem__(self, node: Any) -> Mapping[str, Any]: ...
484
+
485
+
486
+ @runtime_checkable
487
+ class _EdgeViewLike(Protocol):
488
+ """Subset of :class:`networkx.EdgeView` behaviour relied on by TNFR.
489
+
490
+ Notes
491
+ -----
492
+ Marked with @runtime_checkable to enable isinstance() checks for validating
493
+ edge view implementations conform to the expected interface.
494
+ """
495
+
496
+ def __iter__(self) -> Iterable[Any]: ...
497
+
498
+ def __call__(self, data: bool = ...) -> Iterable[Any]: ...
499
+
500
+
501
+ @runtime_checkable
502
+ class GraphLike(Protocol):
503
+ """Protocol describing graph objects consumed by TNFR subsystems.
504
+
505
+ Graph-like containers must expose cached-property style ``nodes`` and
506
+ ``edges`` views compatible with :mod:`networkx`, a ``neighbors`` iterator,
507
+ ``number_of_nodes`` introspection and a metadata mapping via ``.graph``.
508
+ Metrics, cache utilities and CLI diagnostics assume this interface when
509
+ traversing structural coherence data.
510
+
511
+ Notes
512
+ -----
513
+ Marked with @runtime_checkable to enable isinstance() checks for validating
514
+ graph implementations conform to the expected TNFR graph interface.
515
+ """
516
+
517
+ graph: MutableMapping[str, Any]
518
+ nodes: _NodeViewLike
519
+ edges: _EdgeViewLike
520
+
521
+ def number_of_nodes(self) -> int:
522
+ """Return the total number of coherent nodes in the graph."""
523
+
524
+ ...
525
+
526
+ def neighbors(self, n: Any) -> Iterable[Any]:
527
+ """Yield adjacent nodes coupled to ``n`` within the structure."""
528
+
529
+ ...
530
+
531
+ def __getitem__(self, node: Any) -> MutableMapping[Any, Any]:
532
+ """Expose adjacency metadata for ``node`` using ``G[node]`` semantics."""
533
+
534
+ ...
535
+
536
+ def __iter__(self) -> Iterable[Any]:
537
+ """Iterate over nodes to allow direct structural traversals."""
538
+
539
+ ...
540
+
541
+
542
+ @runtime_checkable
543
+ class IntegratorProtocol(Protocol):
544
+ """Interface describing configurable nodal equation integrators.
545
+
546
+ Notes
547
+ -----
548
+ Marked with @runtime_checkable to enable isinstance() checks for validating
549
+ integrator implementations conform to the expected interface.
550
+ """
551
+
552
+ def integrate(
553
+ self,
554
+ graph: TNFRGraph,
555
+ *,
556
+ dt: float | None,
557
+ t: float | None,
558
+ method: str | None,
559
+ n_jobs: int | None,
560
+ ) -> None:
561
+ """Advance the nodal equation for ``graph`` using integrator configuration."""
562
+
563
+ ...
564
+
565
+
566
+ class Glyph(str, Enum):
567
+ """Canonical TNFR structural symbols (glyphs).
568
+
569
+ Glyphs are the structural symbols (AL, EN, IL, etc.) that represent the
570
+ application of structural operators. Each structural operator (Emission,
571
+ Reception, Coherence, etc.) is associated with a specific glyph symbol.
572
+
573
+ For public-facing documentation and APIs, refer to these by their structural
574
+ operator names rather than the internal glyph codes.
575
+ """
576
+
577
+ AL = "AL"
578
+ EN = "EN"
579
+ IL = "IL"
580
+ OZ = "OZ"
581
+ UM = "UM"
582
+ RA = "RA"
583
+ SHA = "SHA"
584
+ VAL = "VAL"
585
+ NUL = "NUL"
586
+ THOL = "THOL"
587
+ ZHIR = "ZHIR"
588
+ NAV = "NAV"
589
+ REMESH = "REMESH"
590
+
591
+
592
+ GlyphCode: TypeAlias = Glyph | str
593
+ """Structural operator symbol (glyph) identifier accepted by selector pipelines and grammars."""
594
+
595
+ GlyphLoadDistribution: TypeAlias = dict[Glyph | str, float]
596
+ """Normalised load proportions keyed by structural operator symbol (glyph) or aggregate labels."""
597
+
598
+
599
+ @runtime_checkable
600
+ class _SelectorLifecycle(Protocol):
601
+ """Protocol describing the selector lifecycle supported by the runtime.
602
+
603
+ Notes
604
+ -----
605
+ Marked with @runtime_checkable to enable isinstance() checks for validating
606
+ selector implementations conform to the expected lifecycle interface.
607
+ """
608
+
609
+ def __call__(self, graph: TNFRGraph, node: NodeId) -> GlyphCode: ...
610
+
611
+ def prepare(self, graph: TNFRGraph, nodes: Sequence[NodeId]) -> None: ...
612
+
613
+ def select(self, graph: TNFRGraph, node: NodeId) -> GlyphCode: ...
614
+
615
+
616
+ GlyphSelector: TypeAlias = Callable[[TNFRGraph, NodeId], GlyphCode] | _SelectorLifecycle
617
+ """Selector callable or object returning the structural operator symbol (glyph) to apply for a node."""
618
+
619
+ SelectorPreselectionMetrics: TypeAlias = Mapping[Any, SelectorMetrics]
620
+ """Mapping of nodes to their normalised selector metrics."""
621
+
622
+ SelectorPreselectionChoices: TypeAlias = Mapping[Any, Glyph | str]
623
+ """Mapping of nodes to their preferred structural operator symbol (glyph) prior to grammar filters."""
624
+
625
+ SelectorPreselectionPayload: TypeAlias = tuple[
626
+ SelectorPreselectionMetrics,
627
+ SelectorPreselectionChoices,
628
+ ]
629
+ #: Tuple grouping selector metrics and base decisions for preselection steps.
630
+
631
+ TraceFieldFn: TypeAlias = Callable[[TNFRGraph], "TraceMetadata"]
632
+ #: Callable producing :class:`tnfr.trace.TraceMetadata` from a :data:`TNFRGraph`.
633
+
634
+ TraceFieldMap: TypeAlias = Mapping[str, "TraceFieldFn"]
635
+ #: Mapping of trace field names to their producers for a given phase.
636
+
637
+ TraceFieldRegistry: TypeAlias = dict[str, dict[str, "TraceFieldFn"]]
638
+ #: Registry grouping trace field producers by capture phase.
639
+
640
+
641
+ class TraceMetadata(TypedDict, total=False):
642
+ """Metadata captured by trace field producers across phases."""
643
+
644
+ gamma: Mapping[str, Any]
645
+ grammar: Mapping[str, Any]
646
+ selector: str | None
647
+ dnfr_weights: Mapping[str, Any]
648
+ si_weights: Mapping[str, Any]
649
+ si_sensitivity: Mapping[str, Any]
650
+ callbacks: Mapping[str, list[str] | None]
651
+ thol_open_nodes: int
652
+ kuramoto: Mapping[str, float]
653
+ sigma: Mapping[str, float]
654
+ glyphs: Mapping[str, int]
655
+
656
+
657
+ class TraceSnapshot(TraceMetadata, total=False):
658
+ """Trace metadata snapshot recorded in TNFR history."""
659
+
660
+ t: float
661
+ phase: str
662
+
663
+
664
+ HistoryState: TypeAlias = _HistoryDict | dict[str, Any]
665
+ #: History container used to accumulate glyph metrics and logs for the graph.
666
+
667
+
668
+ class CallbackError(TypedDict):
669
+ """Metadata captured for a failed callback invocation."""
670
+
671
+ event: str
672
+ step: int | None
673
+ error: str
674
+ traceback: str
675
+ fn: str
676
+ name: str | None
677
+
678
+
679
+ TraceCallback: TypeAlias = Callable[[TNFRGraph, dict[str, Any]], None]
680
+ #: Callback signature used by :func:`tnfr.trace.register_trace`.
681
+
682
+ DiagnosisNodeData: TypeAlias = Mapping[str, Any]
683
+ #: Raw nodal measurement payload used prior to computing diagnostics.
684
+
685
+ DiagnosisSharedState: TypeAlias = Mapping[str, Any]
686
+ #: Shared read-only state propagated to diagnosis workers.
687
+
688
+ DiagnosisPayload: TypeAlias = dict[str, Any]
689
+ #: Structured diagnostics exported for a single node.
690
+
691
+ DiagnosisResult: TypeAlias = tuple[NodeId, DiagnosisPayload]
692
+ #: Node identifier paired with its :data:`DiagnosisPayload`.
693
+
694
+ DiagnosisPayloadChunk: TypeAlias = list[DiagnosisNodeData]
695
+ #: Chunk of nodal payloads processed together by diagnosis workers.
696
+
697
+ DiagnosisResultList: TypeAlias = list[DiagnosisResult]
698
+ #: Collection of diagnosis results matching worker output shape.
699
+
700
+ DnfrCacheVectors: TypeAlias = tuple[
701
+ np.ndarray | None,
702
+ np.ndarray | None,
703
+ np.ndarray | None,
704
+ np.ndarray | None,
705
+ np.ndarray | None,
706
+ ]
707
+ """Tuple grouping cached NumPy vectors for θ, EPI, νf and trigonometric projections."""
708
+
709
+ DnfrVectorMap: TypeAlias = dict[str, np.ndarray | None]
710
+ """Mapping of TNFR state aliases to their NumPy buffers synchronized from lists."""
711
+
712
+ NeighborStats: TypeAlias = tuple[
713
+ Sequence[float],
714
+ Sequence[float],
715
+ Sequence[float],
716
+ Sequence[float],
717
+ Sequence[float] | None,
718
+ Sequence[float] | None,
719
+ Sequence[float] | None,
720
+ ]
721
+ """Bundle of neighbour accumulators for cosine, sine, EPI, νf and topology totals."""
722
+
723
+ GlyphogramRow: TypeAlias = MutableMapping[str, float]
724
+ """Row exported by glyph timing summaries."""
725
+
726
+ GlyphTimingTotals: TypeAlias = MutableMapping[str, float]
727
+ """Aggregate glyph timing totals keyed by glyph code."""
728
+
729
+ GlyphTimingByNode: TypeAlias = MutableMapping[
730
+ Any, MutableMapping[str, MutableSequence[float]]
731
+ ]
732
+ """Glyph timing segments stored per node during audits."""
733
+
734
+ GlyphCounts: TypeAlias = Mapping[str, int]
735
+ """Glyph occurrence counters keyed by glyph code."""
736
+
737
+ GlyphMetricsHistoryValue: TypeAlias = MutableMapping[Any, Any] | MutableSequence[Any]
738
+ """Flexible container used by glyph history accumulators."""
739
+
740
+ GlyphMetricsHistory: TypeAlias = MutableMapping[str, GlyphMetricsHistoryValue]
741
+ """History map storing glyph metrics by identifier."""
742
+
743
+ MetricsListHistory: TypeAlias = MutableMapping[str, list[Any]]
744
+ """Mapping associating glyph metric identifiers with time series."""
745
+
746
+
747
+ class RemeshMeta(TypedDict, total=False):
748
+ """Event metadata persisted after applying REMESH coherence operators."""
749
+
750
+ alpha: float
751
+ alpha_source: str
752
+ tau_global: int
753
+ tau_local: int
754
+ step: int | None
755
+ topo_hash: str | None
756
+ epi_mean_before: float
757
+ epi_mean_after: float
758
+ epi_checksum_before: str
759
+ epi_checksum_after: str
760
+ stable_frac_last: float
761
+ phase_sync_last: float
762
+ glyph_disr_last: float
763
+
764
+
765
+ class ParallelWijPayload(TypedDict):
766
+ """Container for broadcasting Wij coherence components to worker pools."""
767
+
768
+ epi_vals: Sequence[float]
769
+ vf_vals: Sequence[float]
770
+ si_vals: Sequence[float]
771
+ cos_vals: Sequence[float]
772
+ sin_vals: Sequence[float]
773
+ weights: tuple[float, float, float, float]
774
+ epi_range: float
775
+ vf_range: float