@reicek/neataptic-ts 0.1.24 → 0.1.26

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.
Files changed (215) hide show
  1. package/.github/copilot-instructions.md +11 -0
  2. package/.github/skills/trace-analyzer-extension/SKILL.md +3 -3
  3. package/.github/skills/trace-analyzer-extension/assets/extension-checklist.md +1 -1
  4. package/.github/skills/trace-analyzer-extension/references/analyzer-extension-workflow.md +1 -1
  5. package/.github/skills/trace-audit-reporting/SKILL.md +3 -3
  6. package/.github/skills/trace-audit-reporting/references/trace-analysis-workflow.md +1 -1
  7. package/.github/workflows/ci.yml +3 -3
  8. package/.github/workflows/deploy-pages.yml +6 -6
  9. package/.github/workflows/manual_release_pipeline.yml +3 -3
  10. package/.github/workflows/publish.yml +18 -19
  11. package/.github/workflows/release_dispatch.yml +3 -3
  12. package/package.json +26 -20
  13. package/plans/Flappy_Bird_Folder_Documentation_Pass.md +4 -4
  14. package/plans/README.md +24 -0
  15. package/plans/Roadmap.md +62 -40
  16. package/plans/analyze-trace-solid-split.plans.md +66 -0
  17. package/plans/architecture-solid-split.plans.md +9 -15
  18. package/plans/asciiMaze-typescript-repair.plans.md +1 -1
  19. package/plans/generate-docs-solid-split.plans.md +87 -0
  20. package/plans/methods-docs.plans.md +25 -1
  21. package/plans/methods-solid-split.plans.md +14 -14
  22. package/plans/neat-docs.plans.md +9 -1
  23. package/plans/neat-test-surface-repair.plans.md +1 -1
  24. package/plans/render-docs-html-solid-split.plans.md +68 -0
  25. package/plans/src-no-explicit-any-cleanup.plans.md +1 -1
  26. package/plans/utils-docs.plans.md +6 -1
  27. package/scripts/analyze-trace/analyze-trace.analysis.ts +479 -0
  28. package/scripts/analyze-trace/analyze-trace.constants.ts +35 -0
  29. package/scripts/analyze-trace/analyze-trace.io.ts +69 -0
  30. package/scripts/analyze-trace/analyze-trace.report.ts +100 -0
  31. package/scripts/analyze-trace/analyze-trace.shared.ts +116 -0
  32. package/scripts/analyze-trace/analyze-trace.ts +45 -0
  33. package/scripts/analyze-trace/analyze-trace.types.ts +72 -0
  34. package/scripts/assets/theme.css +80 -23
  35. package/scripts/copy-examples.ts +239 -0
  36. package/scripts/export-onnx.ts +223 -0
  37. package/scripts/generate-bench-tables.ts +378 -37
  38. package/scripts/generate-docs/generate-docs.constants.ts +107 -0
  39. package/scripts/generate-docs/generate-docs.order.ts +355 -0
  40. package/scripts/generate-docs/generate-docs.state.ts +31 -0
  41. package/scripts/generate-docs/generate-docs.targets.ts +165 -0
  42. package/scripts/generate-docs/generate-docs.ts +63 -0
  43. package/scripts/generate-docs/generate-docs.types.ts +112 -0
  44. package/scripts/generate-docs/output/generate-docs.output.folder-index.utils.ts +167 -0
  45. package/scripts/generate-docs/output/generate-docs.output.ordering.utils.ts +353 -0
  46. package/scripts/generate-docs/output/generate-docs.output.readme.utils.ts +420 -0
  47. package/scripts/generate-docs/output/generate-docs.output.ts +123 -0
  48. package/scripts/generate-docs/output/generate-docs.output.warnings.utils.ts +219 -0
  49. package/scripts/generate-docs/symbols/generate-docs.symbols.collection.utils.ts +365 -0
  50. package/scripts/generate-docs/symbols/generate-docs.symbols.jsdoc.utils.ts +373 -0
  51. package/scripts/generate-docs/symbols/generate-docs.symbols.normalize.utils.ts +155 -0
  52. package/scripts/generate-docs/symbols/generate-docs.symbols.render.utils.ts +149 -0
  53. package/scripts/generate-docs/symbols/generate-docs.symbols.signature.utils.ts +289 -0
  54. package/scripts/generate-docs/symbols/generate-docs.symbols.ts +11 -0
  55. package/scripts/mermaid-cli.mjs +102 -22
  56. package/scripts/mermaid-cli.ts +736 -0
  57. package/scripts/render-docs-html/render-docs-html.assets.ts +54 -0
  58. package/scripts/render-docs-html/render-docs-html.mermaid.ts +245 -0
  59. package/scripts/{render-docs-html.sidebar.ts → render-docs-html/render-docs-html.navigation.ts} +141 -144
  60. package/scripts/render-docs-html/render-docs-html.pages.ts +333 -0
  61. package/scripts/render-docs-html/render-docs-html.shared.ts +333 -0
  62. package/scripts/render-docs-html/render-docs-html.types.ts +42 -0
  63. package/scripts/render-docs-html.ts +23 -587
  64. package/scripts/run-docs.ts +238 -0
  65. package/scripts/write-dist-docs-pkg.ts +40 -0
  66. package/src/README.md +75 -75
  67. package/src/architecture/connection/README.md +5 -5
  68. package/src/architecture/layer/README.md +508 -508
  69. package/src/architecture/network/README.md +1458 -1458
  70. package/src/architecture/network/activate/README.md +694 -694
  71. package/src/architecture/network/bootstrap/README.md +77 -77
  72. package/src/architecture/network/connect/README.md +74 -74
  73. package/src/architecture/network/deterministic/README.md +135 -135
  74. package/src/architecture/network/evolve/README.md +364 -364
  75. package/src/architecture/network/gating/README.md +130 -130
  76. package/src/architecture/network/genetic/README.md +399 -399
  77. package/src/architecture/network/mutate/README.md +897 -897
  78. package/src/architecture/network/onnx/README.md +720 -720
  79. package/src/architecture/network/onnx/export/README.md +728 -728
  80. package/src/architecture/network/onnx/export/layers/README.md +450 -450
  81. package/src/architecture/network/onnx/import/README.md +618 -618
  82. package/src/architecture/network/onnx/schema/README.md +32 -32
  83. package/src/architecture/network/prune/README.md +245 -245
  84. package/src/architecture/network/remove/README.md +135 -135
  85. package/src/architecture/network/runtime/README.md +106 -106
  86. package/src/architecture/network/serialize/README.md +542 -542
  87. package/src/architecture/network/slab/README.md +608 -608
  88. package/src/architecture/network/standalone/README.md +212 -212
  89. package/src/architecture/network/stats/README.md +84 -84
  90. package/src/architecture/network/topology/README.md +465 -465
  91. package/src/architecture/network/training/README.md +200 -200
  92. package/src/architecture/node/README.md +5 -5
  93. package/src/architecture/nodePool/README.md +14 -14
  94. package/src/methods/README.md +99 -99
  95. package/src/methods/activation/README.md +189 -189
  96. package/src/methods/cost/README.md +131 -131
  97. package/src/methods/rate/README.md +86 -86
  98. package/src/multithreading/README.md +77 -77
  99. package/src/multithreading/workers/browser/README.md +8 -8
  100. package/src/multithreading/workers/node/README.md +8 -8
  101. package/src/neat/README.md +148 -148
  102. package/src/neat/adaptive/README.md +120 -120
  103. package/src/neat/adaptive/acceptance/README.md +40 -40
  104. package/src/neat/adaptive/complexity/README.md +137 -137
  105. package/src/neat/adaptive/core/README.md +197 -197
  106. package/src/neat/adaptive/lineage/README.md +90 -90
  107. package/src/neat/adaptive/mutation/README.md +284 -284
  108. package/src/neat/compat/README.md +43 -43
  109. package/src/neat/compat/core/README.md +90 -90
  110. package/src/neat/diversity/README.md +35 -35
  111. package/src/neat/diversity/core/README.md +88 -88
  112. package/src/neat/evaluate/README.md +85 -85
  113. package/src/neat/evaluate/auto-distance/README.md +75 -75
  114. package/src/neat/evaluate/entropy-compat/README.md +37 -37
  115. package/src/neat/evaluate/entropy-sharing/README.md +43 -43
  116. package/src/neat/evaluate/fitness/README.md +23 -23
  117. package/src/neat/evaluate/novelty/README.md +120 -120
  118. package/src/neat/evaluate/objectives/README.md +17 -17
  119. package/src/neat/evaluate/shared/README.md +94 -94
  120. package/src/neat/evolve/README.md +96 -96
  121. package/src/neat/evolve/adaptive/README.md +60 -60
  122. package/src/neat/evolve/objectives/README.md +63 -63
  123. package/src/neat/evolve/offspring/README.md +56 -56
  124. package/src/neat/evolve/population/README.md +171 -171
  125. package/src/neat/evolve/runtime/README.md +79 -79
  126. package/src/neat/evolve/speciation/README.md +74 -74
  127. package/src/neat/evolve/warnings/README.md +10 -10
  128. package/src/neat/export/README.md +114 -114
  129. package/src/neat/helpers/README.md +50 -50
  130. package/src/neat/init/README.md +9 -9
  131. package/src/neat/lineage/core/README.md +101 -101
  132. package/src/neat/multiobjective/category/README.md +74 -74
  133. package/src/neat/multiobjective/crowding/README.md +272 -272
  134. package/src/neat/multiobjective/dominance/README.md +171 -171
  135. package/src/neat/multiobjective/fronts/README.md +68 -68
  136. package/src/neat/multiobjective/metrics/README.md +43 -43
  137. package/src/neat/multiobjective/objectives/README.md +31 -31
  138. package/src/neat/multiobjective/shared/README.md +27 -27
  139. package/src/neat/mutation/README.md +97 -97
  140. package/src/neat/mutation/add-conn/README.md +115 -115
  141. package/src/neat/mutation/add-node/README.md +126 -126
  142. package/src/neat/mutation/flow/README.md +149 -149
  143. package/src/neat/mutation/repair/README.md +185 -185
  144. package/src/neat/mutation/select/README.md +117 -117
  145. package/src/neat/mutation/shared/README.md +32 -32
  146. package/src/neat/objectives/README.md +25 -25
  147. package/src/neat/objectives/core/README.md +67 -67
  148. package/src/neat/pruning/README.md +40 -40
  149. package/src/neat/pruning/core/README.md +171 -171
  150. package/src/neat/pruning/facade/README.md +32 -32
  151. package/src/neat/rng/README.md +104 -104
  152. package/src/neat/rng/core/README.md +137 -137
  153. package/src/neat/rng/facade/README.md +50 -50
  154. package/src/neat/selection/README.md +111 -111
  155. package/src/neat/selection/core/README.md +227 -227
  156. package/src/neat/selection/facade/README.md +61 -61
  157. package/src/neat/shared/README.md +163 -163
  158. package/src/neat/speciation/README.md +31 -31
  159. package/src/neat/speciation/threshold/README.md +35 -35
  160. package/src/neat/species/README.md +25 -25
  161. package/src/neat/species/core/README.md +20 -20
  162. package/src/neat/species/core/shared/README.md +18 -18
  163. package/src/neat/species/history/context/README.md +22 -22
  164. package/src/neat/telemetry/accessors/README.md +58 -58
  165. package/src/neat/telemetry/exports/README.md +233 -233
  166. package/src/neat/telemetry/facade/README.md +252 -252
  167. package/src/neat/telemetry/facade/archive/README.md +57 -57
  168. package/src/neat/telemetry/facade/buffer/README.md +43 -43
  169. package/src/neat/telemetry/facade/lineage/README.md +12 -12
  170. package/src/neat/telemetry/facade/objectives/README.md +44 -44
  171. package/src/neat/telemetry/facade/runtime/README.md +26 -26
  172. package/src/neat/telemetry/facade/species/README.md +27 -27
  173. package/src/neat/telemetry/metrics/README.md +696 -696
  174. package/src/neat/telemetry/recorder/README.md +57 -57
  175. package/src/neat/telemetry/types/README.md +32 -32
  176. package/src/neat/topology-intent/README.md +75 -75
  177. package/src/utils/README.md +193 -193
  178. package/test/examples/asciiMaze/browser-entry/README.md +92 -92
  179. package/test/examples/asciiMaze/dashboardManager/README.md +109 -109
  180. package/test/examples/asciiMaze/dashboardManager/telemetry/README.md +28 -28
  181. package/test/examples/asciiMaze/evolutionEngine/README.md +1527 -1527
  182. package/test/examples/asciiMaze/mazeMovement/README.md +105 -105
  183. package/test/examples/asciiMaze/mazeMovement/finalization/README.md +16 -16
  184. package/test/examples/asciiMaze/mazeMovement/policy/README.md +57 -57
  185. package/test/examples/asciiMaze/mazeMovement/runtime/README.md +52 -52
  186. package/test/examples/asciiMaze/mazeMovement/shaping/README.md +46 -46
  187. package/test/examples/flappy_bird/browser-entry/README.md +508 -508
  188. package/test/examples/flappy_bird/browser-entry/host/README.md +101 -101
  189. package/test/examples/flappy_bird/browser-entry/host/resize/README.md +144 -144
  190. package/test/examples/flappy_bird/browser-entry/network-view/README.md +194 -194
  191. package/test/examples/flappy_bird/browser-entry/playback/README.md +278 -278
  192. package/test/examples/flappy_bird/browser-entry/playback/background/README.md +129 -129
  193. package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/README.md +502 -502
  194. package/test/examples/flappy_bird/browser-entry/playback/frame-render/README.md +139 -139
  195. package/test/examples/flappy_bird/browser-entry/playback/snapshot/README.md +10 -10
  196. package/test/examples/flappy_bird/browser-entry/playback/trail/README.md +43 -43
  197. package/test/examples/flappy_bird/browser-entry/playback/worker-channel/README.md +30 -30
  198. package/test/examples/flappy_bird/browser-entry/runtime/README.md +59 -59
  199. package/test/examples/flappy_bird/browser-entry/visualization/README.md +276 -276
  200. package/test/examples/flappy_bird/browser-entry/worker-channel/README.md +16 -16
  201. package/test/examples/flappy_bird/constants/README.md +1070 -1070
  202. package/test/examples/flappy_bird/environment/README.md +22 -22
  203. package/test/examples/flappy_bird/evaluation/README.md +32 -32
  204. package/test/examples/flappy_bird/evaluation/rollout/README.md +141 -141
  205. package/test/examples/flappy_bird/flappy-evolution-worker/README.md +425 -425
  206. package/test/examples/flappy_bird/simulation-shared/README.md +170 -170
  207. package/test/examples/flappy_bird/simulation-shared/observation/README.md +109 -109
  208. package/test/examples/flappy_bird/trainer/README.md +325 -325
  209. package/test/examples/flappy_bird/trainer/evaluation/README.md +74 -74
  210. package/scripts/analyze-trace.ts +0 -590
  211. package/scripts/copy-examples.mjs +0 -114
  212. package/scripts/export-onnx.mjs +0 -86
  213. package/scripts/generate-bench-tables.mjs +0 -182
  214. package/scripts/generate-docs.ts +0 -2900
  215. package/scripts/write-dist-docs-pkg.mjs +0 -16
@@ -52,6 +52,28 @@ Connection view with optional enabled flag.
52
52
  Some serialized formats preserve per-edge enablement, while others treat missing values
53
53
  as implicitly enabled.
54
54
 
55
+ ### DEFAULT_NUMERIC_VALUE
56
+
57
+ Default numeric fallback for absent scalar values.
58
+
59
+ This keeps import logic deterministic when optional numeric fields are missing.
60
+
61
+ ### ERROR_INVALID_NETWORK_JSON
62
+
63
+ Error text emitted for invalid verbose JSON payload roots.
64
+
65
+ ### FALLBACK_ACTIVATION_KEY
66
+
67
+ Fallback activation key used when no mapping is found.
68
+
69
+ Identity is selected as the safest non-disruptive activation fallback.
70
+
71
+ ### FIRST_CONNECTION_INDEX
72
+
73
+ Index of the first created connection returned by `connect()`.
74
+
75
+ The runtime API returns an array, and serializer logic consistently reads index `0`.
76
+
55
77
  ### JsonConnectionRebuildContext
56
78
 
57
79
  Context for JSON-connection reconstruction.
@@ -64,12 +86,11 @@ Context for JSON-node reconstruction.
64
86
 
65
87
  Node entries are rebuilt in order and pushed into mutable runtime internals.
66
88
 
67
- ### SerializeNetworkInternals
89
+ ### NETWORK_JSON_FORMAT_VERSION
68
90
 
69
- Runtime interface for accessing network internals during serialization.
91
+ Default format version for verbose serialization payloads.
70
92
 
71
- This is an internal bridge type used by serializer helpers to read and rebuild
72
- topology without exposing private implementation details in public APIs.
93
+ Consumers can use this value to identify the JSON schema revision.
73
94
 
74
95
  ### NetworkInternalsWithDropout
75
96
 
@@ -108,11 +129,17 @@ Verbose JSON node representation.
108
129
 
109
130
  Node entries are self-describing and intended for readable, versioned snapshots.
110
131
 
111
- ### SerializeNodeInternals
132
+ ### NODE_TYPE_HIDDEN
112
133
 
113
- Runtime node internals needed for serialization workflows.
134
+ Node type literal used for hidden layer nodes.
114
135
 
115
- These fields are the minimal node state required to round-trip compact and JSON payloads.
136
+ ### NODE_TYPE_INPUT
137
+
138
+ Node type literal used for input layer nodes.
139
+
140
+ ### NODE_TYPE_OUTPUT
141
+
142
+ Node type literal used for output layer nodes.
116
143
 
117
144
  ### ResolvedNetworkSizeContext
118
145
 
@@ -126,53 +153,18 @@ Serialized connection representation used by compact and JSON formats.
126
153
 
127
154
  Endpoints are canonical node indices, which keeps payloads deterministic and language-agnostic.
128
155
 
129
- ### NETWORK_JSON_FORMAT_VERSION
130
-
131
- Default format version for verbose serialization payloads.
132
-
133
- Consumers can use this value to identify the JSON schema revision.
134
-
135
- ### DEFAULT_NUMERIC_VALUE
136
-
137
- Default numeric fallback for absent scalar values.
138
-
139
- This keeps import logic deterministic when optional numeric fields are missing.
140
-
141
- ### FIRST_CONNECTION_INDEX
142
-
143
- Index of the first created connection returned by `connect()`.
144
-
145
- The runtime API returns an array, and serializer logic consistently reads index `0`.
146
-
147
- ### NODE_TYPE_INPUT
148
-
149
- Node type literal used for input layer nodes.
150
-
151
- ### NODE_TYPE_HIDDEN
152
-
153
- Node type literal used for hidden layer nodes.
154
-
155
- ### NODE_TYPE_OUTPUT
156
-
157
- Node type literal used for output layer nodes.
158
-
159
- ### FALLBACK_ACTIVATION_KEY
160
-
161
- Fallback activation key used when no mapping is found.
162
-
163
- Identity is selected as the safest non-disruptive activation fallback.
164
-
165
- ### ERROR_INVALID_NETWORK_JSON
156
+ ### SerializeNetworkInternals
166
157
 
167
- Error text emitted for invalid verbose JSON payload roots.
158
+ Runtime interface for accessing network internals during serialization.
168
159
 
169
- ### WARNING_UNKNOWN_FORMAT_VERSION
160
+ This is an internal bridge type used by serializer helpers to read and rebuild
161
+ topology without exposing private implementation details in public APIs.
170
162
 
171
- Warning emitted for unknown verbose format versions.
163
+ ### SerializeNodeInternals
172
164
 
173
- ### WARNING_INVALID_GATER_DURING_DESERIALIZE
165
+ Runtime node internals needed for serialization workflows.
174
166
 
175
- Warning emitted when compact deserialize sees an invalid gater index.
167
+ These fields are the minimal node state required to round-trip compact and JSON payloads.
176
168
 
177
169
  ### WARNING_INVALID_CONNECTION_DURING_DESERIALIZE
178
170
 
@@ -182,10 +174,18 @@ Warning emitted when compact deserialize sees invalid edge endpoints.
182
174
 
183
175
  Warning emitted when JSON deserialize sees invalid edge endpoints.
184
176
 
177
+ ### WARNING_INVALID_GATER_DURING_DESERIALIZE
178
+
179
+ Warning emitted when compact deserialize sees an invalid gater index.
180
+
185
181
  ### WARNING_INVALID_GATER_DURING_FROM_JSON
186
182
 
187
183
  Warning emitted when JSON deserialize sees an invalid gater index.
188
184
 
185
+ ### WARNING_UNKNOWN_FORMAT_VERSION
186
+
187
+ Warning emitted for unknown verbose format versions.
188
+
189
189
  ### WARNING_UNKNOWN_SQUASH_PREFIX
190
190
 
191
191
  Prefix used when warning about unknown activation keys.
@@ -196,65 +196,49 @@ Suffix used when warning about unknown activation keys.
196
196
 
197
197
  ## architecture/network/serialize/network.serialize.utils.ts
198
198
 
199
- ### serialize
200
-
201
- ```ts
202
- serialize(): CompactSerializedNetworkTuple
203
- ```
204
-
205
- Serializes a network instance into the compact tuple format.
199
+ ### network.serialize.utils
206
200
 
207
- Use this format when payload size and serialization speed matter more than readability.
208
- The tuple layout is positional and optimized for transport/storage efficiency.
201
+ Connection (Synapse / Edge)
202
+ ===========================
203
+ Directed weighted link between two nodes. The connection keeps the everyday
204
+ graph fields (`from`, `to`, `weight`, `innovation`) directly on the instance,
205
+ then pushes rarer capabilities behind symbol-backed accessors so large
206
+ populations do not pay object-shape costs for features they are not using.
209
207
 
210
- Parameters:
211
- - `this` - - Bound network instance.
208
+ This makes the boundary useful in three different modes:
212
209
 
213
- Returns: Compact tuple payload containing activations, states, squash keys, connections, and input/output sizes.
210
+ - ordinary feed-forward links that only need endpoints and weight,
211
+ - gated or plastic links that gradually opt into extra runtime state,
212
+ - optimizer-heavy training paths that need moment buffers without turning
213
+ every connection into a bloated record.
214
214
 
215
215
  Example:
216
216
 
217
217
  ```ts
218
- import Network from '../../network';
219
- import { deserialize, serialize } from './network.serialize.utils';
218
+ const source = new Node('input');
219
+ const target = new Node('output');
220
+ const edge = new Connection(source, target, 0.42);
220
221
 
221
- const sourceNetwork = new Network(2, 1);
222
- const compactTuple = serialize.call(sourceNetwork);
223
- const rebuiltNetwork = deserialize(compactTuple);
222
+ edge.gain = 1.5;
223
+ edge.enabled = true;
224
224
  ```
225
225
 
226
- ### toJSONImpl
226
+ ### applyHydratedArchitectureDescriptor
227
227
 
228
228
  ```ts
229
- toJSONImpl(): NetworkJSON
229
+ applyHydratedArchitectureDescriptor(
230
+ network: default,
231
+ architectureDescriptor: NetworkArchitectureDescriptor | undefined,
232
+ ): void
230
233
  ```
231
234
 
232
- Serializes a network instance into the verbose JSON format.
233
-
234
- Use this format when you need human-readable snapshots, explicit schema versioning,
235
- and better forward/backward compatibility handling.
235
+ Applies hydrated architecture metadata to runtime network when shape is valid.
236
236
 
237
237
  Parameters:
238
- - `this` - - Bound network instance.
239
-
240
- Returns: Versioned JSON payload with shape metadata, nodes, and connections.
241
-
242
- Example:
243
-
244
- ```ts
245
- import Network from '../../network';
246
- import { fromJSONImpl, toJSONImpl } from './network.serialize.utils';
247
-
248
- const sourceNetwork = new Network(3, 1);
249
- const snapshotJson = toJSONImpl.call(sourceNetwork);
250
- const rebuiltNetwork = fromJSONImpl(snapshotJson);
251
- ```
252
-
253
- ### SerializedConnection
254
-
255
- Serialized connection representation used by compact and JSON formats.
238
+ - `network` - - Rebuilt network instance.
239
+ - `architectureDescriptor` - - Optional serialized descriptor.
256
240
 
257
- Endpoints are canonical node indices, which keeps payloads deterministic and language-agnostic.
241
+ Returns: Nothing.
258
242
 
259
243
  ### deserialize
260
244
 
@@ -312,62 +296,78 @@ import { fromJSONImpl } from './network.serialize.utils';
312
296
  const rebuiltNetwork = fromJSONImpl(snapshotJson);
313
297
  ```
314
298
 
315
- ### network.serialize.utils
299
+ ### isArchitectureDescriptorShapeValid
316
300
 
317
- Connection (Synapse / Edge)
318
- ===========================
319
- Directed weighted link between two nodes. The connection keeps the everyday
320
- graph fields (`from`, `to`, `weight`, `innovation`) directly on the instance,
321
- then pushes rarer capabilities behind symbol-backed accessors so large
322
- populations do not pay object-shape costs for features they are not using.
301
+ ```ts
302
+ isArchitectureDescriptorShapeValid(
303
+ architectureDescriptor: NetworkArchitectureDescriptor | undefined,
304
+ ): boolean
305
+ ```
323
306
 
324
- This makes the boundary useful in three different modes:
307
+ Parameters:
308
+ - `architectureDescriptor` - - Optional descriptor candidate.
325
309
 
326
- - ordinary feed-forward links that only need endpoints and weight,
327
- - gated or plastic links that gradually opt into extra runtime state,
328
- - optimizer-heavy training paths that need moment buffers without turning
329
- every connection into a bloated record.
310
+ Returns: True when minimal descriptor shape is valid.
330
311
 
331
- Example:
312
+ ### serialize
332
313
 
333
314
  ```ts
334
- const source = new Node('input');
335
- const target = new Node('output');
336
- const edge = new Connection(source, target, 0.42);
337
-
338
- edge.gain = 1.5;
339
- edge.enabled = true;
315
+ serialize(): CompactSerializedNetworkTuple
340
316
  ```
341
317
 
342
- ### applyHydratedArchitectureDescriptor
318
+ Serializes a network instance into the compact tuple format.
319
+
320
+ Use this format when payload size and serialization speed matter more than readability.
321
+ The tuple layout is positional and optimized for transport/storage efficiency.
322
+
323
+ Parameters:
324
+ - `this` - - Bound network instance.
325
+
326
+ Returns: Compact tuple payload containing activations, states, squash keys, connections, and input/output sizes.
327
+
328
+ Example:
343
329
 
344
330
  ```ts
345
- applyHydratedArchitectureDescriptor(
346
- network: default,
347
- architectureDescriptor: NetworkArchitectureDescriptor | undefined,
348
- ): void
331
+ import Network from '../../network';
332
+ import { deserialize, serialize } from './network.serialize.utils';
333
+
334
+ const sourceNetwork = new Network(2, 1);
335
+ const compactTuple = serialize.call(sourceNetwork);
336
+ const rebuiltNetwork = deserialize(compactTuple);
349
337
  ```
350
338
 
351
- Applies hydrated architecture metadata to runtime network when shape is valid.
339
+ ### SerializedConnection
352
340
 
353
- Parameters:
354
- - `network` - - Rebuilt network instance.
355
- - `architectureDescriptor` - - Optional serialized descriptor.
341
+ Serialized connection representation used by compact and JSON formats.
356
342
 
357
- Returns: Nothing.
343
+ Endpoints are canonical node indices, which keeps payloads deterministic and language-agnostic.
358
344
 
359
- ### isArchitectureDescriptorShapeValid
345
+ ### toJSONImpl
360
346
 
361
347
  ```ts
362
- isArchitectureDescriptorShapeValid(
363
- architectureDescriptor: NetworkArchitectureDescriptor | undefined,
364
- ): boolean
348
+ toJSONImpl(): NetworkJSON
365
349
  ```
366
350
 
351
+ Serializes a network instance into the verbose JSON format.
352
+
353
+ Use this format when you need human-readable snapshots, explicit schema versioning,
354
+ and better forward/backward compatibility handling.
355
+
367
356
  Parameters:
368
- - `architectureDescriptor` - - Optional descriptor candidate.
357
+ - `this` - - Bound network instance.
369
358
 
370
- Returns: True when minimal descriptor shape is valid.
359
+ Returns: Versioned JSON payload with shape metadata, nodes, and connections.
360
+
361
+ Example:
362
+
363
+ ```ts
364
+ import Network from '../../network';
365
+ import { fromJSONImpl, toJSONImpl } from './network.serialize.utils';
366
+
367
+ const sourceNetwork = new Network(3, 1);
368
+ const snapshotJson = toJSONImpl.call(sourceNetwork);
369
+ const rebuiltNetwork = fromJSONImpl(snapshotJson);
370
+ ```
371
371
 
372
372
  ### default
373
373
 
@@ -569,44 +569,24 @@ Extended trace structure for modulatory / eligibility propagation algorithms. Pa
569
569
 
570
570
  ## architecture/network/serialize/network.serialize.json.utils.ts
571
571
 
572
- ### createEmptyNetworkJson
572
+ ### appendJsonForwardConnections
573
573
 
574
574
  ```ts
575
- createEmptyNetworkJson(
576
- networkInternals: NetworkInternalsWithDropout,
577
- ): NetworkJSON
578
- ```
579
-
580
- Creates an empty verbose JSON shell from runtime internals.
581
-
582
- The shell includes format and shape metadata and is filled in by subsequent
583
- node and connection append steps.
584
-
585
- Parameters:
586
- - `networkInternals` - - Runtime internals with optional dropout.
587
-
588
- Returns: Empty JSON shell with `formatVersion` and scalar metadata initialized.
589
-
590
- Example:
591
-
592
- ```ts
593
- const networkJson = createEmptyNetworkJson(networkInternals);
575
+ appendJsonForwardConnections(
576
+ networkInternals: SerializeNetworkInternals,
577
+ networkJson: NetworkJSON,
578
+ ): void
594
579
  ```
595
580
 
596
- ### resolveDropout
597
-
598
- ```ts
599
- resolveDropout(
600
- dropout: number | undefined,
601
- ): number
602
- ```
581
+ Appends JSON entries for forward connections.
603
582
 
604
- Resolves dropout with a numeric fallback when the value is absent.
583
+ Non-finite endpoint indices are ignored to prevent malformed output records.
605
584
 
606
585
  Parameters:
607
- - `dropout` - - Optional dropout value.
586
+ - `networkInternals` - - Runtime internals.
587
+ - `networkJson` - - JSON accumulator.
608
588
 
609
- Returns: Effective dropout.
589
+ Returns: Nothing.
610
590
 
611
591
  ### appendJsonNodesAndSelfConnections
612
592
 
@@ -628,140 +608,106 @@ Parameters:
628
608
 
629
609
  Returns: Nothing.
630
610
 
631
- ### appendJsonForwardConnections
611
+ ### appendJsonSelfConnectionWhenPresent
632
612
 
633
613
  ```ts
634
- appendJsonForwardConnections(
635
- networkInternals: SerializeNetworkInternals,
614
+ appendJsonSelfConnectionWhenPresent(
615
+ nodeInternals: SerializeNodeInternals,
616
+ nodeIndex: number,
636
617
  networkJson: NetworkJSON,
637
618
  ): void
638
619
  ```
639
620
 
640
- Appends JSON entries for forward connections.
641
-
642
- Non-finite endpoint indices are ignored to prevent malformed output records.
621
+ Appends JSON self-connection when node has one.
643
622
 
644
623
  Parameters:
645
- - `networkInternals` - - Runtime internals.
624
+ - `nodeInternals` - - Node internals.
625
+ - `nodeIndex` - - Node index.
646
626
  - `networkJson` - - JSON accumulator.
647
627
 
648
628
  Returns: Nothing.
649
629
 
650
- ### validateNetworkJsonOrThrow
630
+ ### assignJsonEnabledFlagWhenProvided
651
631
 
652
632
  ```ts
653
- validateNetworkJsonOrThrow(
654
- json: NetworkJSON,
633
+ assignJsonEnabledFlagWhenProvided(
634
+ createdConnection: default | undefined,
635
+ enabled: boolean,
655
636
  ): void
656
637
  ```
657
638
 
658
- Validates the verbose JSON payload root shape.
639
+ Assigns enabled flag when value is provided.
659
640
 
660
641
  Parameters:
661
- - `json` - - Payload candidate.
642
+ - `createdConnection` - - Created connection.
643
+ - `enabled` - - Optional enabled value.
662
644
 
663
645
  Returns: Nothing.
664
646
 
665
- ### warnWhenJsonFormatVersionIsUnknown
647
+ ### assignJsonGaterWhenValid
666
648
 
667
649
  ```ts
668
- warnWhenJsonFormatVersionIsUnknown(
669
- formatVersion: number,
650
+ assignJsonGaterWhenValid(
651
+ networkInternals: SerializeNetworkInternals,
652
+ gaterIndex: number | null,
653
+ createdConnection: default | undefined,
670
654
  ): void
671
655
  ```
672
656
 
673
- Warns when incoming verbose format version differs from the expected one.
657
+ Assigns JSON gater when connection and gater index are valid.
674
658
 
675
659
  Parameters:
676
- - `formatVersion` - - Incoming format version.
660
+ - `networkInternals` - - Runtime internals.
661
+ - `gaterIndex` - - Optional gater index.
662
+ - `createdConnection` - - Created connection.
677
663
 
678
664
  Returns: Nothing.
679
665
 
680
- ### rebuildNodesFromJsonPayload
666
+ ### createConnection
681
667
 
682
668
  ```ts
683
- rebuildNodesFromJsonPayload(
684
- jsonNodeContext: JsonNodeRebuildContext,
685
- ): void
669
+ createConnection(
670
+ networkInternals: SerializeNetworkInternals,
671
+ sourceNode: default,
672
+ targetNode: default,
673
+ weight: number,
674
+ ): default | undefined
686
675
  ```
687
676
 
688
- Rebuilds runtime nodes from verbose JSON entries.
677
+ Creates one connection and returns first created instance.
689
678
 
690
679
  Parameters:
691
- - `jsonNodeContext` - - JSON node rebuild context.
692
-
693
- Returns: Nothing.
694
-
695
- Example:
680
+ - `networkInternals` - - Runtime internals.
681
+ - `sourceNode` - - Source node.
682
+ - `targetNode` - - Target node.
683
+ - `weight` - - Connection weight.
696
684
 
697
- ```ts
698
- rebuildNodesFromJsonPayload({ networkInternals, nodeJsonEntries });
699
- ```
685
+ Returns: Created connection or undefined.
700
686
 
701
- ### rebuildConnectionsFromJsonPayload
687
+ ### createEmptyNetworkJson
702
688
 
703
689
  ```ts
704
- rebuildConnectionsFromJsonPayload(
705
- jsonConnectionContext: JsonConnectionRebuildContext,
706
- ): void
690
+ createEmptyNetworkJson(
691
+ networkInternals: NetworkInternalsWithDropout,
692
+ ): NetworkJSON
707
693
  ```
708
694
 
709
- Rebuilds runtime connections from verbose JSON entries.
695
+ Creates an empty verbose JSON shell from runtime internals.
710
696
 
711
- Invalid entries are skipped with warnings so import continues for valid records.
697
+ The shell includes format and shape metadata and is filled in by subsequent
698
+ node and connection append steps.
712
699
 
713
700
  Parameters:
714
- - `jsonConnectionContext` - - JSON connection rebuild context.
701
+ - `networkInternals` - - Runtime internals with optional dropout.
715
702
 
716
- Returns: Nothing.
703
+ Returns: Empty JSON shell with `formatVersion` and scalar metadata initialized.
717
704
 
718
705
  Example:
719
706
 
720
707
  ```ts
721
- rebuildConnectionsFromJsonPayload({
722
- networkInternals,
723
- connectionJsonEntries,
724
- });
725
- ```
726
-
727
- ### createJsonNode
728
-
729
- ```ts
730
- createJsonNode(
731
- node: default,
732
- nodeInternals: SerializeNodeInternals,
733
- nodeIndex: number,
734
- ): NetworkJSONNode
735
- ```
736
-
737
- Creates one JSON node entry.
738
-
739
- Parameters:
740
- - `node` - - Runtime node.
741
- - `nodeInternals` - - Node internals.
742
- - `nodeIndex` - - Canonical index.
743
-
744
- Returns: JSON node entry.
745
-
746
- ### appendJsonSelfConnectionWhenPresent
747
-
748
- ```ts
749
- appendJsonSelfConnectionWhenPresent(
750
- nodeInternals: SerializeNodeInternals,
751
- nodeIndex: number,
752
- networkJson: NetworkJSON,
753
- ): void
708
+ const networkJson = createEmptyNetworkJson(networkInternals);
754
709
  ```
755
710
 
756
- Appends JSON self-connection when node has one.
757
-
758
- Parameters:
759
- - `nodeInternals` - - Node internals.
760
- - `nodeIndex` - - Node index.
761
- - `networkJson` - - JSON accumulator.
762
-
763
- Returns: Nothing.
764
-
765
711
  ### createJsonConnection
766
712
 
767
713
  ```ts
@@ -785,35 +731,39 @@ Parameters:
785
731
 
786
732
  Returns: JSON connection entry.
787
733
 
788
- ### resolveGaterIndex
734
+ ### createJsonNode
789
735
 
790
736
  ```ts
791
- resolveGaterIndex(
792
- gaterNode: default | null,
793
- ): number | null
737
+ createJsonNode(
738
+ node: default,
739
+ nodeInternals: SerializeNodeInternals,
740
+ nodeIndex: number,
741
+ ): NetworkJSONNode
794
742
  ```
795
743
 
796
- Resolves gater node index from gater reference.
744
+ Creates one JSON node entry.
797
745
 
798
746
  Parameters:
799
- - `gaterNode` - - Optional gater node.
747
+ - `node` - - Runtime node.
748
+ - `nodeInternals` - - Node internals.
749
+ - `nodeIndex` - - Canonical index.
800
750
 
801
- Returns: Gater index or null.
751
+ Returns: JSON node entry.
802
752
 
803
- ### isConnectionEnabled
753
+ ### createNodeWithType
804
754
 
805
755
  ```ts
806
- isConnectionEnabled(
807
- connectionInstance: default,
808
- ): boolean
756
+ createNodeWithType(
757
+ nodeType: string,
758
+ ): default
809
759
  ```
810
760
 
811
- Resolves enabled status from optional connection flag.
761
+ Creates one node with provided type.
812
762
 
813
763
  Parameters:
814
- - `connectionInstance` - - Connection instance.
764
+ - `nodeType` - - Node type.
815
765
 
816
- Returns: True when connection is enabled.
766
+ Returns: New node.
817
767
 
818
768
  ### hydrateNodeFromJsonEntry
819
769
 
@@ -834,37 +784,20 @@ Parameters:
834
784
 
835
785
  Returns: Nothing.
836
786
 
837
- ### rebuildOneJsonConnection
838
-
839
- ```ts
840
- rebuildOneJsonConnection(
841
- networkInternals: SerializeNetworkInternals,
842
- connectionJsonEntry: NetworkJSONConnection,
843
- ): void
844
- ```
845
-
846
- Rebuilds one verbose JSON connection entry.
847
-
848
- Parameters:
849
- - `networkInternals` - - Runtime internals.
850
- - `connectionJsonEntry` - - JSON connection entry.
851
-
852
- Returns: Nothing.
853
-
854
- ### isJsonConnectionShapeValid
787
+ ### isConnectionEnabled
855
788
 
856
789
  ```ts
857
- isJsonConnectionShapeValid(
858
- connectionJsonEntry: NetworkJSONConnection,
790
+ isConnectionEnabled(
791
+ connectionInstance: default,
859
792
  ): boolean
860
793
  ```
861
794
 
862
- Checks that JSON connection has numeric endpoint fields.
795
+ Resolves enabled status from optional connection flag.
863
796
 
864
797
  Parameters:
865
- - `connectionJsonEntry` - - JSON connection entry.
798
+ - `connectionInstance` - - Connection instance.
866
799
 
867
- Returns: True when endpoint fields are numbers.
800
+ Returns: True when connection is enabled.
868
801
 
869
802
  ### isJsonConnectionInNodeBounds
870
803
 
@@ -883,77 +816,144 @@ Parameters:
883
816
 
884
817
  Returns: True when both indices are valid.
885
818
 
886
- ### createConnection
819
+ ### isJsonConnectionShapeValid
887
820
 
888
821
  ```ts
889
- createConnection(
890
- networkInternals: SerializeNetworkInternals,
891
- sourceNode: default,
892
- targetNode: default,
893
- weight: number,
894
- ): default | undefined
822
+ isJsonConnectionShapeValid(
823
+ connectionJsonEntry: NetworkJSONConnection,
824
+ ): boolean
895
825
  ```
896
826
 
897
- Creates one connection and returns first created instance.
827
+ Checks that JSON connection has numeric endpoint fields.
898
828
 
899
829
  Parameters:
900
- - `networkInternals` - - Runtime internals.
901
- - `sourceNode` - - Source node.
902
- - `targetNode` - - Target node.
903
- - `weight` - - Connection weight.
830
+ - `connectionJsonEntry` - - JSON connection entry.
904
831
 
905
- Returns: Created connection or undefined.
832
+ Returns: True when endpoint fields are numbers.
906
833
 
907
- ### assignJsonGaterWhenValid
834
+ ### rebuildConnectionsFromJsonPayload
908
835
 
909
836
  ```ts
910
- assignJsonGaterWhenValid(
911
- networkInternals: SerializeNetworkInternals,
912
- gaterIndex: number | null,
913
- createdConnection: default | undefined,
837
+ rebuildConnectionsFromJsonPayload(
838
+ jsonConnectionContext: JsonConnectionRebuildContext,
914
839
  ): void
915
840
  ```
916
841
 
917
- Assigns JSON gater when connection and gater index are valid.
842
+ Rebuilds runtime connections from verbose JSON entries.
843
+
844
+ Invalid entries are skipped with warnings so import continues for valid records.
918
845
 
919
846
  Parameters:
920
- - `networkInternals` - - Runtime internals.
921
- - `gaterIndex` - - Optional gater index.
922
- - `createdConnection` - - Created connection.
847
+ - `jsonConnectionContext` - - JSON connection rebuild context.
923
848
 
924
849
  Returns: Nothing.
925
850
 
926
- ### assignJsonEnabledFlagWhenProvided
851
+ Example:
927
852
 
928
853
  ```ts
929
- assignJsonEnabledFlagWhenProvided(
930
- createdConnection: default | undefined,
931
- enabled: boolean,
854
+ rebuildConnectionsFromJsonPayload({
855
+ networkInternals,
856
+ connectionJsonEntries,
857
+ });
858
+ ```
859
+
860
+ ### rebuildNodesFromJsonPayload
861
+
862
+ ```ts
863
+ rebuildNodesFromJsonPayload(
864
+ jsonNodeContext: JsonNodeRebuildContext,
932
865
  ): void
933
866
  ```
934
867
 
935
- Assigns enabled flag when value is provided.
868
+ Rebuilds runtime nodes from verbose JSON entries.
936
869
 
937
870
  Parameters:
938
- - `createdConnection` - - Created connection.
939
- - `enabled` - - Optional enabled value.
871
+ - `jsonNodeContext` - - JSON node rebuild context.
940
872
 
941
873
  Returns: Nothing.
942
874
 
943
- ### createNodeWithType
875
+ Example:
944
876
 
945
877
  ```ts
946
- createNodeWithType(
947
- nodeType: string,
948
- ): default
878
+ rebuildNodesFromJsonPayload({ networkInternals, nodeJsonEntries });
949
879
  ```
950
880
 
951
- Creates one node with provided type.
881
+ ### rebuildOneJsonConnection
882
+
883
+ ```ts
884
+ rebuildOneJsonConnection(
885
+ networkInternals: SerializeNetworkInternals,
886
+ connectionJsonEntry: NetworkJSONConnection,
887
+ ): void
888
+ ```
889
+
890
+ Rebuilds one verbose JSON connection entry.
952
891
 
953
892
  Parameters:
954
- - `nodeType` - - Node type.
893
+ - `networkInternals` - - Runtime internals.
894
+ - `connectionJsonEntry` - - JSON connection entry.
955
895
 
956
- Returns: New node.
896
+ Returns: Nothing.
897
+
898
+ ### resolveDropout
899
+
900
+ ```ts
901
+ resolveDropout(
902
+ dropout: number | undefined,
903
+ ): number
904
+ ```
905
+
906
+ Resolves dropout with a numeric fallback when the value is absent.
907
+
908
+ Parameters:
909
+ - `dropout` - - Optional dropout value.
910
+
911
+ Returns: Effective dropout.
912
+
913
+ ### resolveGaterIndex
914
+
915
+ ```ts
916
+ resolveGaterIndex(
917
+ gaterNode: default | null,
918
+ ): number | null
919
+ ```
920
+
921
+ Resolves gater node index from gater reference.
922
+
923
+ Parameters:
924
+ - `gaterNode` - - Optional gater node.
925
+
926
+ Returns: Gater index or null.
927
+
928
+ ### validateNetworkJsonOrThrow
929
+
930
+ ```ts
931
+ validateNetworkJsonOrThrow(
932
+ json: NetworkJSON,
933
+ ): void
934
+ ```
935
+
936
+ Validates the verbose JSON payload root shape.
937
+
938
+ Parameters:
939
+ - `json` - - Payload candidate.
940
+
941
+ Returns: Nothing.
942
+
943
+ ### warnWhenJsonFormatVersionIsUnknown
944
+
945
+ ```ts
946
+ warnWhenJsonFormatVersionIsUnknown(
947
+ formatVersion: number,
948
+ ): void
949
+ ```
950
+
951
+ Warns when incoming verbose format version differs from the expected one.
952
+
953
+ Parameters:
954
+ - `formatVersion` - - Incoming format version.
955
+
956
+ Returns: Nothing.
957
957
 
958
958
  ## architecture/network/serialize/network.serialize.public.utils.ts
959
959
 
@@ -976,53 +976,54 @@ Returns: Deep-cloned network instance.
976
976
 
977
977
  ## architecture/network/serialize/network.serialize.compact.utils.ts
978
978
 
979
- ### refreshNodeIndices
979
+ ### assignCompactGaterWhenValid
980
980
 
981
981
  ```ts
982
- refreshNodeIndices(
983
- nodes: default[],
982
+ assignCompactGaterWhenValid(
983
+ networkInternals: SerializeNetworkInternals,
984
+ gaterIndex: number | null,
985
+ createdConnection: default | undefined,
984
986
  ): void
985
987
  ```
986
988
 
987
- Refreshes `node.index` for each node in list order.
988
-
989
- Canonical indices are required so compact connection records can store endpoints
990
- and gaters as stable numeric positions.
989
+ Assigns compact gater when both connection and gater index are valid.
991
990
 
992
991
  Parameters:
993
- - `nodes` - - Node list.
992
+ - `networkInternals` - - Runtime internals.
993
+ - `gaterIndex` - - Optional gater index.
994
+ - `createdConnection` - - Created connection.
994
995
 
995
996
  Returns: Nothing.
996
997
 
997
- ### collectNodeActivations
998
+ ### collectAllConnections
998
999
 
999
1000
  ```ts
1000
- collectNodeActivations(
1001
- nodes: default[],
1002
- ): number[]
1001
+ collectAllConnections(
1002
+ networkInternals: SerializeNetworkInternals,
1003
+ ): default[]
1003
1004
  ```
1004
1005
 
1005
- Collects node activation values in positional order.
1006
+ Collects all runtime connections into a single list.
1006
1007
 
1007
1008
  Parameters:
1008
- - `nodes` - - Node list.
1009
+ - `networkInternals` - - Runtime internals.
1009
1010
 
1010
- Returns: Activation list aligned to node indices.
1011
+ Returns: Combined connections.
1011
1012
 
1012
- ### collectNodeStates
1013
+ ### collectNodeActivations
1013
1014
 
1014
1015
  ```ts
1015
- collectNodeStates(
1016
+ collectNodeActivations(
1016
1017
  nodes: default[],
1017
1018
  ): number[]
1018
1019
  ```
1019
1020
 
1020
- Collects node state values in positional order.
1021
+ Collects node activation values in positional order.
1021
1022
 
1022
1023
  Parameters:
1023
1024
  - `nodes` - - Node list.
1024
1025
 
1025
- Returns: State list aligned to node indices.
1026
+ Returns: Activation list aligned to node indices.
1026
1027
 
1027
1028
  ### collectNodeSquashKeys
1028
1029
 
@@ -1041,6 +1042,21 @@ Parameters:
1041
1042
 
1042
1043
  Returns: Squash-key list aligned to node indices.
1043
1044
 
1045
+ ### collectNodeStates
1046
+
1047
+ ```ts
1048
+ collectNodeStates(
1049
+ nodes: default[],
1050
+ ): number[]
1051
+ ```
1052
+
1053
+ Collects node state values in positional order.
1054
+
1055
+ Parameters:
1056
+ - `nodes` - - Node list.
1057
+
1058
+ Returns: State list aligned to node indices.
1059
+
1044
1060
  ### collectSerializedConnections
1045
1061
 
1046
1062
  ```ts
@@ -1056,149 +1072,136 @@ Parameters:
1056
1072
 
1057
1073
  Returns: Serialized connection list.
1058
1074
 
1059
- ### rebuildNodesFromCompactPayload
1075
+ ### createConnection
1060
1076
 
1061
1077
  ```ts
1062
- rebuildNodesFromCompactPayload(
1078
+ createConnection(
1063
1079
  networkInternals: SerializeNetworkInternals,
1064
- compactNodeContext: CompactNodeRebuildContext,
1065
- ): void
1080
+ sourceNode: default,
1081
+ targetNode: default,
1082
+ weight: number,
1083
+ ): default | undefined
1066
1084
  ```
1067
1085
 
1068
- Rebuilds runtime nodes from compact payload arrays.
1069
-
1070
- Node type is inferred from index position relative to input/output boundaries.
1086
+ Creates one connection and returns first created instance.
1071
1087
 
1072
1088
  Parameters:
1073
1089
  - `networkInternals` - - Runtime internals.
1074
- - `compactNodeContext` - - Compact node rebuild context.
1090
+ - `sourceNode` - - Source node.
1091
+ - `targetNode` - - Target node.
1092
+ - `weight` - - Connection weight.
1075
1093
 
1076
- Returns: Nothing.
1094
+ Returns: Created connection or undefined.
1077
1095
 
1078
- Example:
1096
+ ### createNodeWithType
1079
1097
 
1080
1098
  ```ts
1081
- import { rebuildNodesFromCompactPayload } from './network.serialize.compact.utils';
1082
-
1083
- rebuildNodesFromCompactPayload(networkInternals, compactNodeContext);
1099
+ createNodeWithType(
1100
+ nodeType: string,
1101
+ ): default
1084
1102
  ```
1085
1103
 
1086
- ### rebuildConnectionsFromCompactPayload
1104
+ Creates one node with provided type.
1105
+
1106
+ Parameters:
1107
+ - `nodeType` - - Node type.
1108
+
1109
+ Returns: New node.
1110
+
1111
+ ### hydrateNodeStateFromCompactPayload
1087
1112
 
1088
1113
  ```ts
1089
- rebuildConnectionsFromCompactPayload(
1090
- compactConnectionContext: CompactConnectionRebuildContext,
1114
+ hydrateNodeStateFromCompactPayload(
1115
+ rebuiltNode: default,
1116
+ activation: number,
1117
+ state: number,
1118
+ squashName: string | undefined,
1119
+ nodeIndex: number,
1091
1120
  ): void
1092
1121
  ```
1093
1122
 
1094
- Rebuilds runtime connections from compact connection records.
1095
-
1096
- Invalid endpoint or gater indices are skipped with warnings to preserve import flow.
1123
+ Hydrates node runtime state from compact tuple values.
1097
1124
 
1098
1125
  Parameters:
1099
- - `compactConnectionContext` - - Compact connection rebuild context.
1126
+ - `rebuiltNode` - - Node to hydrate.
1127
+ - `activation` - - Activation value.
1128
+ - `state` - - State value.
1129
+ - `squashName` - - Activation key.
1130
+ - `nodeIndex` - - Canonical node index.
1100
1131
 
1101
1132
  Returns: Nothing.
1102
1133
 
1103
- Example:
1104
-
1105
- ```ts
1106
- import { rebuildConnectionsFromCompactPayload } from './network.serialize.compact.utils';
1107
-
1108
- rebuildConnectionsFromCompactPayload({
1109
- networkInternals,
1110
- serializedConnections,
1111
- });
1112
- ```
1113
-
1114
- ### collectAllConnections
1134
+ ### isSerializedConnectionInNodeBounds
1115
1135
 
1116
1136
  ```ts
1117
- collectAllConnections(
1137
+ isSerializedConnectionInNodeBounds(
1118
1138
  networkInternals: SerializeNetworkInternals,
1119
- ): default[]
1139
+ serializedConnection: SerializedConnection,
1140
+ ): boolean
1120
1141
  ```
1121
1142
 
1122
- Collects all runtime connections into a single list.
1143
+ Checks compact connection bounds against current node list.
1123
1144
 
1124
1145
  Parameters:
1125
1146
  - `networkInternals` - - Runtime internals.
1147
+ - `serializedConnection` - - Serialized connection record.
1126
1148
 
1127
- Returns: Combined connections.
1149
+ Returns: True when endpoints are valid.
1128
1150
 
1129
- ### serializeOneConnection
1151
+ ### rebuildConnectionsFromCompactPayload
1130
1152
 
1131
1153
  ```ts
1132
- serializeOneConnection(
1133
- connectionInstance: default,
1134
- ): SerializedConnection
1154
+ rebuildConnectionsFromCompactPayload(
1155
+ compactConnectionContext: CompactConnectionRebuildContext,
1156
+ ): void
1135
1157
  ```
1136
1158
 
1137
- Serializes one connection into compact indexed form.
1159
+ Rebuilds runtime connections from compact connection records.
1160
+
1161
+ Invalid endpoint or gater indices are skipped with warnings to preserve import flow.
1138
1162
 
1139
1163
  Parameters:
1140
- - `connectionInstance` - - Runtime connection.
1164
+ - `compactConnectionContext` - - Compact connection rebuild context.
1141
1165
 
1142
- Returns: Serialized connection record.
1166
+ Returns: Nothing.
1143
1167
 
1144
- ### resolveNodeTypeFromCompactIndex
1168
+ Example:
1145
1169
 
1146
1170
  ```ts
1147
- resolveNodeTypeFromCompactIndex(
1148
- nodeIndex: number,
1149
- totalNodeCount: number,
1150
- input: number,
1151
- output: number,
1152
- ): string
1153
- ```
1154
-
1155
- Resolves node type from compact tuple position.
1156
-
1157
- Parameters:
1158
- - `nodeIndex` - - Node index.
1159
- - `totalNodeCount` - - Total node count.
1160
- - `input` - - Input size.
1161
- - `output` - - Output size.
1171
+ import { rebuildConnectionsFromCompactPayload } from './network.serialize.compact.utils';
1162
1172
 
1163
- Returns: Node type string.
1173
+ rebuildConnectionsFromCompactPayload({
1174
+ networkInternals,
1175
+ serializedConnections,
1176
+ });
1177
+ ```
1164
1178
 
1165
- ### createNodeWithType
1179
+ ### rebuildNodesFromCompactPayload
1166
1180
 
1167
1181
  ```ts
1168
- createNodeWithType(
1169
- nodeType: string,
1170
- ): default
1182
+ rebuildNodesFromCompactPayload(
1183
+ networkInternals: SerializeNetworkInternals,
1184
+ compactNodeContext: CompactNodeRebuildContext,
1185
+ ): void
1171
1186
  ```
1172
1187
 
1173
- Creates one node with provided type.
1188
+ Rebuilds runtime nodes from compact payload arrays.
1189
+
1190
+ Node type is inferred from index position relative to input/output boundaries.
1174
1191
 
1175
1192
  Parameters:
1176
- - `nodeType` - - Node type.
1193
+ - `networkInternals` - - Runtime internals.
1194
+ - `compactNodeContext` - - Compact node rebuild context.
1177
1195
 
1178
- Returns: New node.
1196
+ Returns: Nothing.
1179
1197
 
1180
- ### hydrateNodeStateFromCompactPayload
1198
+ Example:
1181
1199
 
1182
1200
  ```ts
1183
- hydrateNodeStateFromCompactPayload(
1184
- rebuiltNode: default,
1185
- activation: number,
1186
- state: number,
1187
- squashName: string | undefined,
1188
- nodeIndex: number,
1189
- ): void
1190
- ```
1191
-
1192
- Hydrates node runtime state from compact tuple values.
1193
-
1194
- Parameters:
1195
- - `rebuiltNode` - - Node to hydrate.
1196
- - `activation` - - Activation value.
1197
- - `state` - - State value.
1198
- - `squashName` - - Activation key.
1199
- - `nodeIndex` - - Canonical node index.
1201
+ import { rebuildNodesFromCompactPayload } from './network.serialize.compact.utils';
1200
1202
 
1201
- Returns: Nothing.
1203
+ rebuildNodesFromCompactPayload(networkInternals, compactNodeContext);
1204
+ ```
1202
1205
 
1203
1206
  ### rebuildOneCompactConnection
1204
1207
 
@@ -1217,62 +1220,59 @@ Parameters:
1217
1220
 
1218
1221
  Returns: Nothing.
1219
1222
 
1220
- ### isSerializedConnectionInNodeBounds
1223
+ ### refreshNodeIndices
1221
1224
 
1222
1225
  ```ts
1223
- isSerializedConnectionInNodeBounds(
1224
- networkInternals: SerializeNetworkInternals,
1225
- serializedConnection: SerializedConnection,
1226
- ): boolean
1226
+ refreshNodeIndices(
1227
+ nodes: default[],
1228
+ ): void
1227
1229
  ```
1228
1230
 
1229
- Checks compact connection bounds against current node list.
1231
+ Refreshes `node.index` for each node in list order.
1232
+
1233
+ Canonical indices are required so compact connection records can store endpoints
1234
+ and gaters as stable numeric positions.
1230
1235
 
1231
1236
  Parameters:
1232
- - `networkInternals` - - Runtime internals.
1233
- - `serializedConnection` - - Serialized connection record.
1237
+ - `nodes` - - Node list.
1234
1238
 
1235
- Returns: True when endpoints are valid.
1239
+ Returns: Nothing.
1236
1240
 
1237
- ### createConnection
1241
+ ### resolveNodeTypeFromCompactIndex
1238
1242
 
1239
1243
  ```ts
1240
- createConnection(
1241
- networkInternals: SerializeNetworkInternals,
1242
- sourceNode: default,
1243
- targetNode: default,
1244
- weight: number,
1245
- ): default | undefined
1244
+ resolveNodeTypeFromCompactIndex(
1245
+ nodeIndex: number,
1246
+ totalNodeCount: number,
1247
+ input: number,
1248
+ output: number,
1249
+ ): string
1246
1250
  ```
1247
1251
 
1248
- Creates one connection and returns first created instance.
1252
+ Resolves node type from compact tuple position.
1249
1253
 
1250
1254
  Parameters:
1251
- - `networkInternals` - - Runtime internals.
1252
- - `sourceNode` - - Source node.
1253
- - `targetNode` - - Target node.
1254
- - `weight` - - Connection weight.
1255
+ - `nodeIndex` - - Node index.
1256
+ - `totalNodeCount` - - Total node count.
1257
+ - `input` - - Input size.
1258
+ - `output` - - Output size.
1255
1259
 
1256
- Returns: Created connection or undefined.
1260
+ Returns: Node type string.
1257
1261
 
1258
- ### assignCompactGaterWhenValid
1262
+ ### serializeOneConnection
1259
1263
 
1260
1264
  ```ts
1261
- assignCompactGaterWhenValid(
1262
- networkInternals: SerializeNetworkInternals,
1263
- gaterIndex: number | null,
1264
- createdConnection: default | undefined,
1265
- ): void
1265
+ serializeOneConnection(
1266
+ connectionInstance: default,
1267
+ ): SerializedConnection
1266
1268
  ```
1267
1269
 
1268
- Assigns compact gater when both connection and gater index are valid.
1270
+ Serializes one connection into compact indexed form.
1269
1271
 
1270
1272
  Parameters:
1271
- - `networkInternals` - - Runtime internals.
1272
- - `gaterIndex` - - Optional gater index.
1273
- - `createdConnection` - - Created connection.
1273
+ - `connectionInstance` - - Runtime connection.
1274
1274
 
1275
- Returns: Nothing.
1275
+ Returns: Serialized connection record.
1276
1276
 
1277
1277
  ## architecture/network/serialize/network.serialize.runtime.utils.ts
1278
1278
 
@@ -1345,60 +1345,54 @@ Example:
1345
1345
  const compactPayload = createCompactPayloadContext(compactTuple);
1346
1346
  ```
1347
1347
 
1348
- ### resolveNetworkSize
1348
+ ### createNetworkInstance
1349
1349
 
1350
1350
  ```ts
1351
- resolveNetworkSize(
1352
- compactPayload: CompactPayloadContext,
1353
- inputSizeOverride: number | undefined,
1354
- outputSizeOverride: number | undefined,
1355
- ): ResolvedNetworkSizeContext
1351
+ createNetworkInstance(
1352
+ input: number,
1353
+ output: number,
1354
+ ): default
1356
1355
  ```
1357
1356
 
1358
- Resolves effective input/output dimensions using optional explicit overrides.
1359
-
1360
- When an override is provided, it takes precedence over serialized values.
1357
+ Creates a new network instance for deserialize workflows.
1361
1358
 
1362
1359
  Parameters:
1363
- - `compactPayload` - - Compact payload context.
1364
- - `inputSizeOverride` - - Optional input override.
1365
- - `outputSizeOverride` - - Optional output override.
1360
+ - `input` - - Input size.
1361
+ - `output` - - Output size.
1366
1362
 
1367
- Returns: Resolved network size context.
1363
+ Returns: New network instance.
1368
1364
 
1369
- ### resolveSizeOverride
1365
+ ### isFiniteIndex
1370
1366
 
1371
1367
  ```ts
1372
- resolveSizeOverride(
1373
- overrideValue: number | undefined,
1374
- serializedValue: number,
1375
- ): number
1368
+ isFiniteIndex(
1369
+ index: number,
1370
+ ): boolean
1376
1371
  ```
1377
1372
 
1378
- Resolves one size value with override-first semantics.
1373
+ Checks whether a candidate index value is a finite number.
1379
1374
 
1380
1375
  Parameters:
1381
- - `overrideValue` - - Optional explicit override.
1382
- - `serializedValue` - - Serialized fallback value.
1376
+ - `index` - - Candidate index value.
1383
1377
 
1384
- Returns: Effective size.
1378
+ Returns: True when finite number.
1385
1379
 
1386
- ### createNetworkInstance
1380
+ ### isNodeIndexInBounds
1387
1381
 
1388
1382
  ```ts
1389
- createNetworkInstance(
1390
- input: number,
1391
- output: number,
1392
- ): default
1383
+ isNodeIndexInBounds(
1384
+ nodes: default[],
1385
+ index: number,
1386
+ ): boolean
1393
1387
  ```
1394
1388
 
1395
- Creates a new network instance for deserialize workflows.
1389
+ Checks whether an index is inside the bounds of a node array.
1396
1390
 
1397
1391
  Parameters:
1398
- - `input` - - Input size.
1399
- - `output` - - Output size.
1392
+ - `nodes` - - Node list.
1393
+ - `index` - - Candidate index.
1400
1394
 
1401
- Returns: New network instance.
1395
+ Returns: True when index is valid.
1402
1396
 
1403
1397
  ### resetMutableRuntimeCollections
1404
1398
 
@@ -1415,66 +1409,91 @@ Parameters:
1415
1409
 
1416
1410
  Returns: Nothing.
1417
1411
 
1418
- ### isNodeIndexInBounds
1412
+ ### resolveNetworkSize
1419
1413
 
1420
1414
  ```ts
1421
- isNodeIndexInBounds(
1422
- nodes: default[],
1423
- index: number,
1424
- ): boolean
1415
+ resolveNetworkSize(
1416
+ compactPayload: CompactPayloadContext,
1417
+ inputSizeOverride: number | undefined,
1418
+ outputSizeOverride: number | undefined,
1419
+ ): ResolvedNetworkSizeContext
1425
1420
  ```
1426
1421
 
1427
- Checks whether an index is inside the bounds of a node array.
1422
+ Resolves effective input/output dimensions using optional explicit overrides.
1423
+
1424
+ When an override is provided, it takes precedence over serialized values.
1428
1425
 
1429
1426
  Parameters:
1430
- - `nodes` - - Node list.
1431
- - `index` - - Candidate index.
1427
+ - `compactPayload` - - Compact payload context.
1428
+ - `inputSizeOverride` - - Optional input override.
1429
+ - `outputSizeOverride` - - Optional output override.
1432
1430
 
1433
- Returns: True when index is valid.
1431
+ Returns: Resolved network size context.
1434
1432
 
1435
- ### isFiniteIndex
1433
+ ### resolveSizeOverride
1436
1434
 
1437
1435
  ```ts
1438
- isFiniteIndex(
1439
- index: number,
1440
- ): boolean
1436
+ resolveSizeOverride(
1437
+ overrideValue: number | undefined,
1438
+ serializedValue: number,
1439
+ ): number
1441
1440
  ```
1442
1441
 
1443
- Checks whether a candidate index value is a finite number.
1442
+ Resolves one size value with override-first semantics.
1444
1443
 
1445
1444
  Parameters:
1446
- - `index` - - Candidate index value.
1445
+ - `overrideValue` - - Optional explicit override.
1446
+ - `serializedValue` - - Serialized fallback value.
1447
1447
 
1448
- Returns: True when finite number.
1448
+ Returns: Effective size.
1449
1449
 
1450
1450
  ## architecture/network/serialize/network.serialize.activation.utils.ts
1451
1451
 
1452
- ### resolveActivationKey
1452
+ ### findActivationByFunctionName
1453
1453
 
1454
1454
  ```ts
1455
- resolveActivationKey(
1456
- squashFunction: ActivationFunction,
1457
- ): string
1455
+ findActivationByFunctionName(
1456
+ squashName: string | undefined,
1457
+ ): ActivationFunction | undefined
1458
1458
  ```
1459
1459
 
1460
- Resolves a canonical activation key from a runtime activation function reference.
1461
-
1462
- Resolution order is: direct registry reference match, then the function name,
1463
- then a stable identity fallback key.
1460
+ Resolves activation by matching function.name.
1464
1461
 
1465
1462
  Parameters:
1466
- - `squashFunction` - - Activation function instance.
1463
+ - `squashName` - - Activation function name.
1467
1464
 
1468
- Returns: Activation key.
1465
+ Returns: Activation function or undefined.
1469
1466
 
1470
- Example:
1467
+ ### findActivationByKey
1471
1468
 
1472
1469
  ```ts
1473
- import * as methods from '../../../methods/methods';
1470
+ findActivationByKey(
1471
+ squashName: string | undefined,
1472
+ ): ActivationFunction | undefined
1473
+ ```
1474
1474
 
1475
- const key = resolveActivationKey(methods.Activation.tanh);
1475
+ Resolves activation by direct key lookup.
1476
+
1477
+ Parameters:
1478
+ - `squashName` - - Activation key.
1479
+
1480
+ Returns: Activation function or undefined.
1481
+
1482
+ ### findActivationEntryByReference
1483
+
1484
+ ```ts
1485
+ findActivationEntryByReference(
1486
+ squashFunction: ActivationFunction,
1487
+ ): [string, ActivationFunction] | undefined
1476
1488
  ```
1477
1489
 
1490
+ Finds activation entry by function reference.
1491
+
1492
+ Parameters:
1493
+ - `squashFunction` - - Activation function instance.
1494
+
1495
+ Returns: Activation entry or undefined.
1496
+
1478
1497
  ### resolveActivationFunction
1479
1498
 
1480
1499
  ```ts
@@ -1499,20 +1518,31 @@ Example:
1499
1518
  const squashFunction = resolveActivationFunction('relu');
1500
1519
  ```
1501
1520
 
1502
- ### findActivationEntryByReference
1521
+ ### resolveActivationKey
1503
1522
 
1504
1523
  ```ts
1505
- findActivationEntryByReference(
1524
+ resolveActivationKey(
1506
1525
  squashFunction: ActivationFunction,
1507
- ): [string, ActivationFunction] | undefined
1526
+ ): string
1508
1527
  ```
1509
1528
 
1510
- Finds activation entry by function reference.
1529
+ Resolves a canonical activation key from a runtime activation function reference.
1530
+
1531
+ Resolution order is: direct registry reference match, then the function name,
1532
+ then a stable identity fallback key.
1511
1533
 
1512
1534
  Parameters:
1513
1535
  - `squashFunction` - - Activation function instance.
1514
1536
 
1515
- Returns: Activation entry or undefined.
1537
+ Returns: Activation key.
1538
+
1539
+ Example:
1540
+
1541
+ ```ts
1542
+ import * as methods from '../../../methods/methods';
1543
+
1544
+ const key = resolveActivationKey(methods.Activation.tanh);
1545
+ ```
1516
1546
 
1517
1547
  ### resolveNamedActivationFromFunction
1518
1548
 
@@ -1529,36 +1559,6 @@ Parameters:
1529
1559
 
1530
1560
  Returns: Activation name or undefined.
1531
1561
 
1532
- ### findActivationByKey
1533
-
1534
- ```ts
1535
- findActivationByKey(
1536
- squashName: string | undefined,
1537
- ): ActivationFunction | undefined
1538
- ```
1539
-
1540
- Resolves activation by direct key lookup.
1541
-
1542
- Parameters:
1543
- - `squashName` - - Activation key.
1544
-
1545
- Returns: Activation function or undefined.
1546
-
1547
- ### findActivationByFunctionName
1548
-
1549
- ```ts
1550
- findActivationByFunctionName(
1551
- squashName: string | undefined,
1552
- ): ActivationFunction | undefined
1553
- ```
1554
-
1555
- Resolves activation by matching function.name.
1556
-
1557
- Parameters:
1558
- - `squashName` - - Activation function name.
1559
-
1560
- Returns: Activation function or undefined.
1561
-
1562
1562
  ### warnUnknownSquashName
1563
1563
 
1564
1564
  ```ts