@reicek/neataptic-ts 0.1.25 → 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 (210) 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/package.json +19 -13
  8. package/plans/Flappy_Bird_Folder_Documentation_Pass.md +4 -4
  9. package/plans/README.md +24 -0
  10. package/plans/Roadmap.md +62 -40
  11. package/plans/analyze-trace-solid-split.plans.md +66 -0
  12. package/plans/architecture-solid-split.plans.md +9 -15
  13. package/plans/asciiMaze-typescript-repair.plans.md +1 -1
  14. package/plans/generate-docs-solid-split.plans.md +87 -0
  15. package/plans/methods-docs.plans.md +25 -1
  16. package/plans/methods-solid-split.plans.md +14 -14
  17. package/plans/neat-docs.plans.md +9 -1
  18. package/plans/neat-test-surface-repair.plans.md +1 -1
  19. package/plans/render-docs-html-solid-split.plans.md +68 -0
  20. package/plans/src-no-explicit-any-cleanup.plans.md +1 -1
  21. package/plans/utils-docs.plans.md +6 -1
  22. package/scripts/analyze-trace/analyze-trace.analysis.ts +479 -0
  23. package/scripts/analyze-trace/analyze-trace.constants.ts +35 -0
  24. package/scripts/analyze-trace/analyze-trace.io.ts +69 -0
  25. package/scripts/analyze-trace/analyze-trace.report.ts +100 -0
  26. package/scripts/analyze-trace/analyze-trace.shared.ts +116 -0
  27. package/scripts/analyze-trace/analyze-trace.ts +45 -0
  28. package/scripts/analyze-trace/analyze-trace.types.ts +72 -0
  29. package/scripts/assets/theme.css +80 -23
  30. package/scripts/copy-examples.ts +239 -0
  31. package/scripts/export-onnx.ts +223 -0
  32. package/scripts/generate-bench-tables.ts +378 -37
  33. package/scripts/generate-docs/generate-docs.constants.ts +107 -0
  34. package/scripts/generate-docs/generate-docs.order.ts +355 -0
  35. package/scripts/generate-docs/generate-docs.state.ts +31 -0
  36. package/scripts/generate-docs/generate-docs.targets.ts +165 -0
  37. package/scripts/generate-docs/generate-docs.ts +63 -0
  38. package/scripts/generate-docs/generate-docs.types.ts +112 -0
  39. package/scripts/generate-docs/output/generate-docs.output.folder-index.utils.ts +167 -0
  40. package/scripts/generate-docs/output/generate-docs.output.ordering.utils.ts +353 -0
  41. package/scripts/generate-docs/output/generate-docs.output.readme.utils.ts +420 -0
  42. package/scripts/generate-docs/output/generate-docs.output.ts +123 -0
  43. package/scripts/generate-docs/output/generate-docs.output.warnings.utils.ts +219 -0
  44. package/scripts/generate-docs/symbols/generate-docs.symbols.collection.utils.ts +365 -0
  45. package/scripts/generate-docs/symbols/generate-docs.symbols.jsdoc.utils.ts +373 -0
  46. package/scripts/generate-docs/symbols/generate-docs.symbols.normalize.utils.ts +155 -0
  47. package/scripts/generate-docs/symbols/generate-docs.symbols.render.utils.ts +149 -0
  48. package/scripts/generate-docs/symbols/generate-docs.symbols.signature.utils.ts +289 -0
  49. package/scripts/generate-docs/symbols/generate-docs.symbols.ts +11 -0
  50. package/scripts/mermaid-cli.mjs +102 -22
  51. package/scripts/mermaid-cli.ts +736 -0
  52. package/scripts/render-docs-html/render-docs-html.assets.ts +54 -0
  53. package/scripts/render-docs-html/render-docs-html.mermaid.ts +245 -0
  54. package/scripts/{render-docs-html.sidebar.ts → render-docs-html/render-docs-html.navigation.ts} +141 -144
  55. package/scripts/render-docs-html/render-docs-html.pages.ts +333 -0
  56. package/scripts/render-docs-html/render-docs-html.shared.ts +333 -0
  57. package/scripts/render-docs-html/render-docs-html.types.ts +42 -0
  58. package/scripts/render-docs-html.ts +23 -587
  59. package/scripts/run-docs.ts +238 -0
  60. package/scripts/write-dist-docs-pkg.ts +40 -0
  61. package/src/README.md +75 -75
  62. package/src/architecture/connection/README.md +5 -5
  63. package/src/architecture/layer/README.md +508 -508
  64. package/src/architecture/network/README.md +1458 -1458
  65. package/src/architecture/network/activate/README.md +694 -694
  66. package/src/architecture/network/bootstrap/README.md +77 -77
  67. package/src/architecture/network/connect/README.md +74 -74
  68. package/src/architecture/network/deterministic/README.md +135 -135
  69. package/src/architecture/network/evolve/README.md +364 -364
  70. package/src/architecture/network/gating/README.md +130 -130
  71. package/src/architecture/network/genetic/README.md +399 -399
  72. package/src/architecture/network/mutate/README.md +897 -897
  73. package/src/architecture/network/onnx/README.md +720 -720
  74. package/src/architecture/network/onnx/export/README.md +728 -728
  75. package/src/architecture/network/onnx/export/layers/README.md +450 -450
  76. package/src/architecture/network/onnx/import/README.md +618 -618
  77. package/src/architecture/network/onnx/schema/README.md +32 -32
  78. package/src/architecture/network/prune/README.md +245 -245
  79. package/src/architecture/network/remove/README.md +135 -135
  80. package/src/architecture/network/runtime/README.md +106 -106
  81. package/src/architecture/network/serialize/README.md +542 -542
  82. package/src/architecture/network/slab/README.md +608 -608
  83. package/src/architecture/network/standalone/README.md +212 -212
  84. package/src/architecture/network/stats/README.md +84 -84
  85. package/src/architecture/network/topology/README.md +465 -465
  86. package/src/architecture/network/training/README.md +200 -200
  87. package/src/architecture/node/README.md +5 -5
  88. package/src/architecture/nodePool/README.md +14 -14
  89. package/src/methods/README.md +99 -99
  90. package/src/methods/activation/README.md +189 -189
  91. package/src/methods/cost/README.md +131 -131
  92. package/src/methods/rate/README.md +86 -86
  93. package/src/multithreading/README.md +77 -77
  94. package/src/multithreading/workers/browser/README.md +8 -8
  95. package/src/multithreading/workers/node/README.md +8 -8
  96. package/src/neat/README.md +148 -148
  97. package/src/neat/adaptive/README.md +120 -120
  98. package/src/neat/adaptive/acceptance/README.md +40 -40
  99. package/src/neat/adaptive/complexity/README.md +137 -137
  100. package/src/neat/adaptive/core/README.md +197 -197
  101. package/src/neat/adaptive/lineage/README.md +90 -90
  102. package/src/neat/adaptive/mutation/README.md +284 -284
  103. package/src/neat/compat/README.md +43 -43
  104. package/src/neat/compat/core/README.md +90 -90
  105. package/src/neat/diversity/README.md +35 -35
  106. package/src/neat/diversity/core/README.md +88 -88
  107. package/src/neat/evaluate/README.md +85 -85
  108. package/src/neat/evaluate/auto-distance/README.md +75 -75
  109. package/src/neat/evaluate/entropy-compat/README.md +37 -37
  110. package/src/neat/evaluate/entropy-sharing/README.md +43 -43
  111. package/src/neat/evaluate/fitness/README.md +23 -23
  112. package/src/neat/evaluate/novelty/README.md +120 -120
  113. package/src/neat/evaluate/objectives/README.md +17 -17
  114. package/src/neat/evaluate/shared/README.md +94 -94
  115. package/src/neat/evolve/README.md +96 -96
  116. package/src/neat/evolve/adaptive/README.md +60 -60
  117. package/src/neat/evolve/objectives/README.md +63 -63
  118. package/src/neat/evolve/offspring/README.md +56 -56
  119. package/src/neat/evolve/population/README.md +171 -171
  120. package/src/neat/evolve/runtime/README.md +79 -79
  121. package/src/neat/evolve/speciation/README.md +74 -74
  122. package/src/neat/evolve/warnings/README.md +10 -10
  123. package/src/neat/export/README.md +114 -114
  124. package/src/neat/helpers/README.md +50 -50
  125. package/src/neat/init/README.md +9 -9
  126. package/src/neat/lineage/core/README.md +101 -101
  127. package/src/neat/multiobjective/category/README.md +74 -74
  128. package/src/neat/multiobjective/crowding/README.md +272 -272
  129. package/src/neat/multiobjective/dominance/README.md +171 -171
  130. package/src/neat/multiobjective/fronts/README.md +68 -68
  131. package/src/neat/multiobjective/metrics/README.md +43 -43
  132. package/src/neat/multiobjective/objectives/README.md +31 -31
  133. package/src/neat/multiobjective/shared/README.md +27 -27
  134. package/src/neat/mutation/README.md +97 -97
  135. package/src/neat/mutation/add-conn/README.md +115 -115
  136. package/src/neat/mutation/add-node/README.md +126 -126
  137. package/src/neat/mutation/flow/README.md +149 -149
  138. package/src/neat/mutation/repair/README.md +185 -185
  139. package/src/neat/mutation/select/README.md +117 -117
  140. package/src/neat/mutation/shared/README.md +32 -32
  141. package/src/neat/objectives/README.md +25 -25
  142. package/src/neat/objectives/core/README.md +67 -67
  143. package/src/neat/pruning/README.md +40 -40
  144. package/src/neat/pruning/core/README.md +171 -171
  145. package/src/neat/pruning/facade/README.md +32 -32
  146. package/src/neat/rng/README.md +104 -104
  147. package/src/neat/rng/core/README.md +137 -137
  148. package/src/neat/rng/facade/README.md +50 -50
  149. package/src/neat/selection/README.md +111 -111
  150. package/src/neat/selection/core/README.md +227 -227
  151. package/src/neat/selection/facade/README.md +61 -61
  152. package/src/neat/shared/README.md +163 -163
  153. package/src/neat/speciation/README.md +31 -31
  154. package/src/neat/speciation/threshold/README.md +35 -35
  155. package/src/neat/species/README.md +25 -25
  156. package/src/neat/species/core/README.md +20 -20
  157. package/src/neat/species/core/shared/README.md +18 -18
  158. package/src/neat/species/history/context/README.md +22 -22
  159. package/src/neat/telemetry/accessors/README.md +58 -58
  160. package/src/neat/telemetry/exports/README.md +233 -233
  161. package/src/neat/telemetry/facade/README.md +252 -252
  162. package/src/neat/telemetry/facade/archive/README.md +57 -57
  163. package/src/neat/telemetry/facade/buffer/README.md +43 -43
  164. package/src/neat/telemetry/facade/lineage/README.md +12 -12
  165. package/src/neat/telemetry/facade/objectives/README.md +44 -44
  166. package/src/neat/telemetry/facade/runtime/README.md +26 -26
  167. package/src/neat/telemetry/facade/species/README.md +27 -27
  168. package/src/neat/telemetry/metrics/README.md +696 -696
  169. package/src/neat/telemetry/recorder/README.md +57 -57
  170. package/src/neat/telemetry/types/README.md +32 -32
  171. package/src/neat/topology-intent/README.md +75 -75
  172. package/src/utils/README.md +193 -193
  173. package/test/examples/asciiMaze/browser-entry/README.md +92 -92
  174. package/test/examples/asciiMaze/dashboardManager/README.md +109 -109
  175. package/test/examples/asciiMaze/dashboardManager/telemetry/README.md +28 -28
  176. package/test/examples/asciiMaze/evolutionEngine/README.md +1527 -1527
  177. package/test/examples/asciiMaze/mazeMovement/README.md +105 -105
  178. package/test/examples/asciiMaze/mazeMovement/finalization/README.md +16 -16
  179. package/test/examples/asciiMaze/mazeMovement/policy/README.md +57 -57
  180. package/test/examples/asciiMaze/mazeMovement/runtime/README.md +52 -52
  181. package/test/examples/asciiMaze/mazeMovement/shaping/README.md +46 -46
  182. package/test/examples/flappy_bird/browser-entry/README.md +508 -508
  183. package/test/examples/flappy_bird/browser-entry/host/README.md +101 -101
  184. package/test/examples/flappy_bird/browser-entry/host/resize/README.md +144 -144
  185. package/test/examples/flappy_bird/browser-entry/network-view/README.md +194 -194
  186. package/test/examples/flappy_bird/browser-entry/playback/README.md +278 -278
  187. package/test/examples/flappy_bird/browser-entry/playback/background/README.md +129 -129
  188. package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/README.md +502 -502
  189. package/test/examples/flappy_bird/browser-entry/playback/frame-render/README.md +139 -139
  190. package/test/examples/flappy_bird/browser-entry/playback/snapshot/README.md +10 -10
  191. package/test/examples/flappy_bird/browser-entry/playback/trail/README.md +43 -43
  192. package/test/examples/flappy_bird/browser-entry/playback/worker-channel/README.md +30 -30
  193. package/test/examples/flappy_bird/browser-entry/runtime/README.md +59 -59
  194. package/test/examples/flappy_bird/browser-entry/visualization/README.md +276 -276
  195. package/test/examples/flappy_bird/browser-entry/worker-channel/README.md +16 -16
  196. package/test/examples/flappy_bird/constants/README.md +1070 -1070
  197. package/test/examples/flappy_bird/environment/README.md +22 -22
  198. package/test/examples/flappy_bird/evaluation/README.md +32 -32
  199. package/test/examples/flappy_bird/evaluation/rollout/README.md +141 -141
  200. package/test/examples/flappy_bird/flappy-evolution-worker/README.md +425 -425
  201. package/test/examples/flappy_bird/simulation-shared/README.md +170 -170
  202. package/test/examples/flappy_bird/simulation-shared/observation/README.md +109 -109
  203. package/test/examples/flappy_bird/trainer/README.md +325 -325
  204. package/test/examples/flappy_bird/trainer/evaluation/README.md +74 -74
  205. package/scripts/analyze-trace.ts +0 -590
  206. package/scripts/copy-examples.mjs +0 -114
  207. package/scripts/export-onnx.mjs +0 -86
  208. package/scripts/generate-bench-tables.mjs +0 -182
  209. package/scripts/generate-docs.ts +0 -2900
  210. package/scripts/write-dist-docs-pkg.mjs +0 -16
@@ -42,78 +42,60 @@ flowchart TD
42
42
 
43
43
  ## neat/mutation/select/mutation.select.ts
44
44
 
45
- ### resolveFFWPolicyForSelect
45
+ ### applyOperatorAdaptationForSelect
46
46
 
47
47
  ```ts
48
- resolveFFWPolicyForSelect(
48
+ applyOperatorAdaptationForSelect(
49
+ pool: MutationMethod[],
49
50
  internal: NeatControllerForMutation,
50
- methods: { mutation: unknown; },
51
- rawReturnForTest: boolean,
52
- ): MutationMethod | MutationMethod[] | null
51
+ ): MutationMethod[]
53
52
  ```
54
53
 
55
- Resolve legacy FFW policy behavior, including test-specific returns.
54
+ Apply operator adaptation weighting to the pool when enabled.
56
55
 
57
- Older feed-forward configuration paths can encode mutation policy in shapes
58
- that do not look like the newer flat operator pool. This helper isolates that
59
- compatibility layer so the rest of selection can operate on a predictable
60
- surface.
56
+ Operator adaptation uses recent structural success as a lightweight teaching
57
+ signal. Operators that have enough attempts and a sufficiently high success
58
+ ratio are duplicated into the candidate pool, increasing their sampling
59
+ probability without changing the operator interface itself.
61
60
 
62
- The `rawReturnForTest` flag exists because some tests assert the preserved
63
- legacy pool shape rather than one sampled method. Production mutation flow,
64
- by contrast, normally wants one concrete operator.
61
+ The helper intentionally does not compute a fancy score. It just reshapes the
62
+ pool, which keeps the later selection steps simple and preserves compatibility
63
+ with random sampling and bandit-based final choice.
65
64
 
66
65
  Parameters:
66
+ - `pool` - - base pool
67
67
  - `internal` - - neat controller context
68
- - `methods` - - methods module
69
- - `rawReturnForTest` - - whether to return raw FFW array for tests
70
68
 
71
- Returns: mutation method or null when not handled
69
+ Returns: augmented pool
72
70
 
73
- ### normalizeMutationPoolForSelect
71
+ ### applyOperatorBanditForSelect
74
72
 
75
73
  ```ts
76
- normalizeMutationPoolForSelect(
74
+ applyOperatorBanditForSelect(
75
+ pool: MutationMethod[],
76
+ fallbackMethod: MutationMethod,
77
77
  internal: NeatControllerForMutation,
78
- methods: { mutation: unknown; },
79
- rawReturnForTest: boolean,
80
- ): MutationMethod[]
78
+ ): MutationMethod
81
79
  ```
82
80
 
83
- Normalize the configured mutation pool to a flat operator list.
84
-
85
- This helper is the bridge from loose policy configuration to a concrete
86
- candidate shelf. It flattens nested legacy arrays and preserves the special
87
- FFW path when tests explicitly need the historical representation.
88
-
89
- Parameters:
90
- - `internal` - - neat controller context
91
- - `methods` - - methods module
92
- - `rawReturnForTest` - - whether to return raw FFW for tests
93
-
94
- Returns: normalized mutation pool
95
-
96
- ### isLegacyFFWPoolForSelect
97
-
98
- ```ts
99
- isLegacyFFWPoolForSelect(
100
- configuredPool: MutationMethod[],
101
- methods: { mutation: unknown; },
102
- ): boolean
103
- ```
81
+ Apply operator bandit selection if enabled.
104
82
 
105
- Check whether a pool matches the legacy FFW operator ordering.
83
+ The operator bandit is the strongest opinionated selector in this chapter.
84
+ Instead of drawing randomly from the shaped pool, it ranks candidate
85
+ operators with a UCB-style score that balances observed success and
86
+ exploration.
106
87
 
107
- The selection boundary uses this check as a compatibility detector, not as a
108
- generic equality helper. Matching the canonical FFW ordering tells the caller
109
- that the configured pool is really a feed-forward preset that may deserve
110
- special handling.
88
+ Early in a run, under-sampled operators receive effectively unbounded
89
+ exploration pressure. Later, the choice shifts toward operators with better
90
+ observed structural payoff. That makes this helper the bridge between simple
91
+ mutation policy configuration and online operator learning.
111
92
 
112
93
  Parameters:
113
- - `configuredPool` - - configured operator pool
114
- - `methods` - - methods module
94
+ - `pool` - - operator pool
95
+ - `fallbackMethod` - - method used when bandit is disabled
96
+ - `internal` - - neat controller context
115
97
 
116
- Returns: true when the pool matches FFW
98
+ Returns: selected method
117
99
 
118
100
  ### applyPhasedComplexityForSelect
119
101
 
@@ -138,52 +120,76 @@ Parameters:
138
120
 
139
121
  Returns: pool with phased complexity adjustments
140
122
 
141
- ### applyOperatorAdaptationForSelect
123
+ ### isBlockedByRecurrentPolicyForSelect
142
124
 
143
125
  ```ts
144
- applyOperatorAdaptationForSelect(
145
- pool: MutationMethod[],
126
+ isBlockedByRecurrentPolicyForSelect(
127
+ mutationMethod: MutationMethod,
146
128
  internal: NeatControllerForMutation,
147
- ): MutationMethod[]
129
+ methods: { mutation: unknown; },
130
+ ): boolean
148
131
  ```
149
132
 
150
- Apply operator adaptation weighting to the pool when enabled.
151
-
152
- Operator adaptation uses recent structural success as a lightweight teaching
153
- signal. Operators that have enough attempts and a sufficiently high success
154
- ratio are duplicated into the candidate pool, increasing their sampling
155
- probability without changing the operator interface itself.
133
+ Check whether a mutation is blocked by recurrent connection policy.
156
134
 
157
- The helper intentionally does not compute a fancy score. It just reshapes the
158
- pool, which keeps the later selection steps simple and preserves compatibility
159
- with random sampling and bandit-based final choice.
135
+ Structural capacity limits are not the only hard guard. Some runs prohibit
136
+ recurrent structure entirely, and this helper keeps that policy localized so
137
+ the rest of the selection code can stay focused on scoring and weighting.
160
138
 
161
139
  Parameters:
162
- - `pool` - - base pool
140
+ - `mutationMethod` - - mutation operator to check
163
141
  - `internal` - - neat controller context
142
+ - `methods` - - methods module
164
143
 
165
- Returns: augmented pool
144
+ Returns: true when the mutation should be blocked
166
145
 
167
- ### sampleFromPoolForSelect
146
+ ### isBlockedByStructuralLimitsForSelect
168
147
 
169
148
  ```ts
170
- sampleFromPoolForSelect(
171
- pool: MutationMethod[],
149
+ isBlockedByStructuralLimitsForSelect(
150
+ mutationMethod: MutationMethod,
151
+ genome: GenomeWithMetadata,
172
152
  internal: NeatControllerForMutation,
173
- ): MutationMethod | null
153
+ methods: { mutation: unknown; },
154
+ ): boolean
174
155
  ```
175
156
 
176
- Sample a random method from the pool.
157
+ Check whether a mutation is blocked by structural limits.
177
158
 
178
- This is the uncomplicated fallback selector. It is useful both for direct
179
- legacy sampling paths and for each configuration that wants weighted random
180
- choice without the stronger opinion of the operator bandit.
159
+ This helper is one of the hard guard rails after softer policy shaping has
160
+ already happened. Even if an operator is favored by phase bias or adaptation,
161
+ it must still respect controller-wide caps such as maximum nodes,
162
+ connections, or gates.
181
163
 
182
164
  Parameters:
183
- - `pool` - - operator pool
165
+ - `mutationMethod` - - mutation operator to check
166
+ - `genome` - - genome to inspect
184
167
  - `internal` - - neat controller context
168
+ - `methods` - - methods module
185
169
 
186
- Returns: sampled method or null
170
+ Returns: true when the mutation should be blocked
171
+
172
+ ### isLegacyFFWPoolForSelect
173
+
174
+ ```ts
175
+ isLegacyFFWPoolForSelect(
176
+ configuredPool: MutationMethod[],
177
+ methods: { mutation: unknown; },
178
+ ): boolean
179
+ ```
180
+
181
+ Check whether a pool matches the legacy FFW operator ordering.
182
+
183
+ The selection boundary uses this check as a compatibility detector, not as a
184
+ generic equality helper. Matching the canonical FFW ordering tells the caller
185
+ that the configured pool is really a feed-forward preset that may deserve
186
+ special handling.
187
+
188
+ Parameters:
189
+ - `configuredPool` - - configured operator pool
190
+ - `methods` - - methods module
191
+
192
+ Returns: true when the pool matches FFW
187
193
 
188
194
  ### isOperatorNamePrefixedForSelect
189
195
 
@@ -206,80 +212,74 @@ Parameters:
206
212
 
207
213
  Returns: true when the operator name matches the prefix
208
214
 
209
- ### isBlockedByStructuralLimitsForSelect
215
+ ### normalizeMutationPoolForSelect
210
216
 
211
217
  ```ts
212
- isBlockedByStructuralLimitsForSelect(
213
- mutationMethod: MutationMethod,
214
- genome: GenomeWithMetadata,
218
+ normalizeMutationPoolForSelect(
215
219
  internal: NeatControllerForMutation,
216
220
  methods: { mutation: unknown; },
217
- ): boolean
221
+ rawReturnForTest: boolean,
222
+ ): MutationMethod[]
218
223
  ```
219
224
 
220
- Check whether a mutation is blocked by structural limits.
225
+ Normalize the configured mutation pool to a flat operator list.
221
226
 
222
- This helper is one of the hard guard rails after softer policy shaping has
223
- already happened. Even if an operator is favored by phase bias or adaptation,
224
- it must still respect controller-wide caps such as maximum nodes,
225
- connections, or gates.
227
+ This helper is the bridge from loose policy configuration to a concrete
228
+ candidate shelf. It flattens nested legacy arrays and preserves the special
229
+ FFW path when tests explicitly need the historical representation.
226
230
 
227
231
  Parameters:
228
- - `mutationMethod` - - mutation operator to check
229
- - `genome` - - genome to inspect
230
232
  - `internal` - - neat controller context
231
233
  - `methods` - - methods module
234
+ - `rawReturnForTest` - - whether to return raw FFW for tests
232
235
 
233
- Returns: true when the mutation should be blocked
236
+ Returns: normalized mutation pool
234
237
 
235
- ### applyOperatorBanditForSelect
238
+ ### resolveFFWPolicyForSelect
236
239
 
237
240
  ```ts
238
- applyOperatorBanditForSelect(
239
- pool: MutationMethod[],
240
- fallbackMethod: MutationMethod,
241
+ resolveFFWPolicyForSelect(
241
242
  internal: NeatControllerForMutation,
242
- ): MutationMethod
243
+ methods: { mutation: unknown; },
244
+ rawReturnForTest: boolean,
245
+ ): MutationMethod | MutationMethod[] | null
243
246
  ```
244
247
 
245
- Apply operator bandit selection if enabled.
248
+ Resolve legacy FFW policy behavior, including test-specific returns.
246
249
 
247
- The operator bandit is the strongest opinionated selector in this chapter.
248
- Instead of drawing randomly from the shaped pool, it ranks candidate
249
- operators with a UCB-style score that balances observed success and
250
- exploration.
250
+ Older feed-forward configuration paths can encode mutation policy in shapes
251
+ that do not look like the newer flat operator pool. This helper isolates that
252
+ compatibility layer so the rest of selection can operate on a predictable
253
+ surface.
251
254
 
252
- Early in a run, under-sampled operators receive effectively unbounded
253
- exploration pressure. Later, the choice shifts toward operators with better
254
- observed structural payoff. That makes this helper the bridge between simple
255
- mutation policy configuration and online operator learning.
255
+ The `rawReturnForTest` flag exists because some tests assert the preserved
256
+ legacy pool shape rather than one sampled method. Production mutation flow,
257
+ by contrast, normally wants one concrete operator.
256
258
 
257
259
  Parameters:
258
- - `pool` - - operator pool
259
- - `fallbackMethod` - - method used when bandit is disabled
260
260
  - `internal` - - neat controller context
261
+ - `methods` - - methods module
262
+ - `rawReturnForTest` - - whether to return raw FFW array for tests
261
263
 
262
- Returns: selected method
264
+ Returns: mutation method or null when not handled
263
265
 
264
- ### isBlockedByRecurrentPolicyForSelect
266
+ ### sampleFromPoolForSelect
265
267
 
266
268
  ```ts
267
- isBlockedByRecurrentPolicyForSelect(
268
- mutationMethod: MutationMethod,
269
+ sampleFromPoolForSelect(
270
+ pool: MutationMethod[],
269
271
  internal: NeatControllerForMutation,
270
- methods: { mutation: unknown; },
271
- ): boolean
272
+ ): MutationMethod | null
272
273
  ```
273
274
 
274
- Check whether a mutation is blocked by recurrent connection policy.
275
+ Sample a random method from the pool.
275
276
 
276
- Structural capacity limits are not the only hard guard. Some runs prohibit
277
- recurrent structure entirely, and this helper keeps that policy localized so
278
- the rest of the selection code can stay focused on scoring and weighting.
277
+ This is the uncomplicated fallback selector. It is useful both for direct
278
+ legacy sampling paths and for each configuration that wants weighted random
279
+ choice without the stronger opinion of the operator bandit.
279
280
 
280
281
  Parameters:
281
- - `mutationMethod` - - mutation operator to check
282
+ - `pool` - - operator pool
282
283
  - `internal` - - neat controller context
283
- - `methods` - - methods module
284
284
 
285
- Returns: true when the mutation should be blocked
285
+ Returns: sampled method or null
@@ -37,6 +37,15 @@ flowchart TD
37
37
 
38
38
  ## neat/mutation/shared/mutation.types.ts
39
39
 
40
+ ### ConnectionWithMetadata
41
+
42
+ Runtime interface for a connection within a genome.
43
+
44
+ This is the minimum edge metadata required by the structural mutation paths.
45
+ The add-node and add-conn chapters use it to preserve weights, inspect edge
46
+ activation, and attach innovation ids that later support alignment-based
47
+ crossover and speciation.
48
+
40
49
  ### GenomeWithMetadata
41
50
 
42
51
  Runtime interface for a genome with mutation-related metadata.
@@ -51,24 +60,6 @@ state such as `_mutRate` and `_mutAmount` travels with the genome itself,
51
60
  while global innovation tables and policy controls stay on the controller
52
61
  host contract.
53
62
 
54
- ### NodeWithMetadata
55
-
56
- Runtime interface for a node within a genome.
57
-
58
- Mutation helpers only need a narrow node view: topology category, optional
59
- gene identity, adjacency lists, and one projection check. That narrowness is
60
- what lets the structural chapters reason about connection growth and cycle
61
- checks without depending on the whole node implementation.
62
-
63
- ### ConnectionWithMetadata
64
-
65
- Runtime interface for a connection within a genome.
66
-
67
- This is the minimum edge metadata required by the structural mutation paths.
68
- The add-node and add-conn chapters use it to preserve weights, inspect edge
69
- activation, and attach innovation ids that later support alignment-based
70
- crossover and speciation.
71
-
72
63
  ### MutationMethod
73
64
 
74
65
  Runtime interface for a mutation method descriptor.
@@ -78,14 +69,17 @@ as enum literals alone. That gives selection helpers room to reason about
78
69
  operator families, sample-count hints, and output-mutation behavior without
79
70
  having to know the concrete implementation of each operator.
80
71
 
81
- ### OperatorStats
72
+ ### NeatControllerForMutation
82
73
 
83
- Runtime interface for operator statistics tracking.
74
+ Runtime interface for the NEAT controller used in mutation operations.
84
75
 
85
- These counters support the adaptive side of mutation policy. They do not try
86
- to capture full fitness impact; instead they record a cheap local proxy for
87
- whether an attempted operator actually produced structure often enough to be
88
- favored later by adaptation or bandit logic.
76
+ This host contract is the bridge between local genome edits and global NEAT
77
+ state. It exposes configuration, RNG access, innovation stores, operator
78
+ statistics, and the narrow controller callbacks that the mutation helpers need.
79
+
80
+ The important boundary is that mutation chapters can mutate controller-owned
81
+ bookkeeping through this interface, but they do not need the entire `Neat`
82
+ class surface to do their work.
89
83
 
90
84
  ### NodeSplitRecord
91
85
 
@@ -96,14 +90,20 @@ A node-split record is the durable memory that tells the add-node path,
96
90
  paired edge innovations is how separate genomes can independently perform the
97
91
  same split and still remain historically alignable.
98
92
 
99
- ### NeatControllerForMutation
93
+ ### NodeWithMetadata
100
94
 
101
- Runtime interface for the NEAT controller used in mutation operations.
95
+ Runtime interface for a node within a genome.
102
96
 
103
- This host contract is the bridge between local genome edits and global NEAT
104
- state. It exposes configuration, RNG access, innovation stores, operator
105
- statistics, and the narrow controller callbacks that the mutation helpers need.
97
+ Mutation helpers only need a narrow node view: topology category, optional
98
+ gene identity, adjacency lists, and one projection check. That narrowness is
99
+ what lets the structural chapters reason about connection growth and cycle
100
+ checks without depending on the whole node implementation.
106
101
 
107
- The important boundary is that mutation chapters can mutate controller-owned
108
- bookkeeping through this interface, but they do not need the entire `Neat`
109
- class surface to do their work.
102
+ ### OperatorStats
103
+
104
+ Runtime interface for operator statistics tracking.
105
+
106
+ These counters support the adaptive side of mutation policy. They do not try
107
+ to capture full fitness impact; instead they record a cheap local proxy for
108
+ whether an attempted operator actually produced structure often enough to be
109
+ favored later by adaptation or bandit logic.
@@ -81,6 +81,31 @@ const objectives = neat._getObjectives();
81
81
  console.log(objectives.map((objective) => objective.key));
82
82
  ```
83
83
 
84
+ ### clearObjectives
85
+
86
+ ```ts
87
+ clearObjectives(): void
88
+ ```
89
+
90
+ Clear all registered multi-objectives.
91
+
92
+ Use this when a run should fall back to its default objective behavior or
93
+ when a test needs a clean objective slate before registering a new set. This
94
+ clears the user-defined objective layer and invalidates the cached resolved
95
+ list so the next read rebuilds it from the remaining controller defaults.
96
+
97
+ Parameters:
98
+ - `this` - - NEAT host exposing multi-objective options and the cached objective list.
99
+
100
+ Returns: Nothing. Registered user objectives and the cached objective list are cleared.
101
+
102
+ Example:
103
+
104
+ ```ts
105
+ neat.clearObjectives();
106
+ const objectives = neat._getObjectives();
107
+ ```
108
+
84
109
  ### registerObjective
85
110
 
86
111
  ```ts
@@ -115,28 +140,3 @@ Example:
115
140
  ```ts
116
141
  neat.registerObjective('energy', 'min', (genome) => genome.cost ?? 0);
117
142
  ```
118
-
119
- ### clearObjectives
120
-
121
- ```ts
122
- clearObjectives(): void
123
- ```
124
-
125
- Clear all registered multi-objectives.
126
-
127
- Use this when a run should fall back to its default objective behavior or
128
- when a test needs a clean objective slate before registering a new set. This
129
- clears the user-defined objective layer and invalidates the cached resolved
130
- list so the next read rebuilds it from the remaining controller defaults.
131
-
132
- Parameters:
133
- - `this` - - NEAT host exposing multi-objective options and the cached objective list.
134
-
135
- Returns: Nothing. Registered user objectives and the cached objective list are cleared.
136
-
137
- Example:
138
-
139
- ```ts
140
- neat.clearObjectives();
141
- const objectives = neat._getObjectives();
142
- ```
@@ -84,6 +84,25 @@ must exist by default, middle helpers gather and validate user intent, and
84
84
  later helpers hydrate missing containers or replace one objective without
85
85
  mutating an older list in place.
86
86
 
87
+ ### buildDefaultFitnessObjective
88
+
89
+ ```ts
90
+ buildDefaultFitnessObjective(): ObjectiveDescriptor
91
+ ```
92
+
93
+ Build the default fitness objective descriptor.
94
+
95
+ The default fitness objective is the anchor that keeps ordinary NEAT runs
96
+ meaningful even when no richer objective policy has been configured yet.
97
+ Core resolution builds it on demand so callers do not need a special
98
+ bootstrap path elsewhere.
99
+
100
+ Keeping this builder separate from the collection logic also makes the core
101
+ flow easier to teach: one helper decides *whether* the default should exist,
102
+ this helper decides *what* that default descriptor looks like.
103
+
104
+ Returns: Default fitness objective descriptor.
105
+
87
106
  ### collectDefaultObjectives
88
107
 
89
108
  ```ts
@@ -130,46 +149,49 @@ Parameters:
130
149
 
131
150
  Returns: Valid user objective descriptors.
132
151
 
133
- ### buildDefaultFitnessObjective
152
+ ### ensureMultiObjectiveOptions
134
153
 
135
154
  ```ts
136
- buildDefaultFitnessObjective(): ObjectiveDescriptor
155
+ ensureMultiObjectiveOptions(
156
+ neatInstance: NeatLikeWithObjectives,
157
+ ): { enabled?: boolean | undefined; objectives?: ObjectiveDescriptor[] | undefined; }
137
158
  ```
138
159
 
139
- Build the default fitness objective descriptor.
160
+ Ensure the multi-objective options container exists.
140
161
 
141
- The default fitness objective is the anchor that keeps ordinary NEAT runs
142
- meaningful even when no richer objective policy has been configured yet.
143
- Core resolution builds it on demand so callers do not need a special
144
- bootstrap path elsewhere.
162
+ Objective registration and resolution are allowed to hydrate this container
163
+ lazily so controller construction does not need to eagerly materialize every
164
+ optional configuration branch.
145
165
 
146
- Keeping this builder separate from the collection logic also makes the core
147
- flow easier to teach: one helper decides *whether* the default should exist,
148
- this helper decides *what* that default descriptor looks like.
166
+ This is one of the small helpers that keeps the core chapter mutation-safe:
167
+ later logic can assume the container exists without scattering defensive
168
+ object creation throughout the file.
149
169
 
150
- Returns: Default fitness objective descriptor.
170
+ Parameters:
171
+ - `neatInstance` - - NEAT host receiving the multi-objective container.
151
172
 
152
- ### isMultiObjectiveEnabled
173
+ Returns: Initialized multi-objective options.
174
+
175
+ ### ensureObjectivesList
153
176
 
154
177
  ```ts
155
- isMultiObjectiveEnabled(
156
- neatInstance: NeatLikeWithObjectives,
157
- ): boolean
178
+ ensureObjectivesList(
179
+ multiObjectiveOptions: { enabled?: boolean | undefined; objectives?: ObjectiveDescriptor[] | undefined; },
180
+ ): ObjectiveDescriptor[]
158
181
  ```
159
182
 
160
- Check whether multi-objective mode is enabled with a candidate list.
183
+ Ensure the objectives list exists on the multi-objective container.
161
184
 
162
- This guard is intentionally strict: enabling multi-objective mode without an
163
- objective array is treated as incomplete configuration, so downstream helpers
164
- can avoid reasoning about half-hydrated state.
185
+ This helper complements container hydration by guaranteeing a writable list
186
+ surface for later non-destructive replacement logic.
165
187
 
166
- That strictness keeps later helpers simpler because they can assume that a
167
- `true` result means both the mode and the candidate container are present.
188
+ It exists so registration code can talk about replacing objectives by key
189
+ instead of repeatedly guarding against `undefined` lists.
168
190
 
169
191
  Parameters:
170
- - `neatInstance` - - NEAT host exposing objective settings.
192
+ - `multiObjectiveOptions` - - Multi-objective container to hydrate.
171
193
 
172
- Returns: `true` when multi-objective mode is enabled and an objective list exists.
194
+ Returns: Objectives list ready for non-destructive operations.
173
195
 
174
196
  ### getObjectiveCandidates
175
197
 
@@ -191,6 +213,28 @@ Parameters:
191
213
 
192
214
  Returns: Objective candidates from configuration.
193
215
 
216
+ ### isMultiObjectiveEnabled
217
+
218
+ ```ts
219
+ isMultiObjectiveEnabled(
220
+ neatInstance: NeatLikeWithObjectives,
221
+ ): boolean
222
+ ```
223
+
224
+ Check whether multi-objective mode is enabled with a candidate list.
225
+
226
+ This guard is intentionally strict: enabling multi-objective mode without an
227
+ objective array is treated as incomplete configuration, so downstream helpers
228
+ can avoid reasoning about half-hydrated state.
229
+
230
+ That strictness keeps later helpers simpler because they can assume that a
231
+ `true` result means both the mode and the candidate container are present.
232
+
233
+ Parameters:
234
+ - `neatInstance` - - NEAT host exposing objective settings.
235
+
236
+ Returns: `true` when multi-objective mode is enabled and an objective list exists.
237
+
194
238
  ### isValidObjective
195
239
 
196
240
  ```ts
@@ -214,50 +258,6 @@ Parameters:
214
258
 
215
259
  Returns: `true` when the descriptor can be used safely.
216
260
 
217
- ### ensureMultiObjectiveOptions
218
-
219
- ```ts
220
- ensureMultiObjectiveOptions(
221
- neatInstance: NeatLikeWithObjectives,
222
- ): { enabled?: boolean | undefined; objectives?: ObjectiveDescriptor[] | undefined; }
223
- ```
224
-
225
- Ensure the multi-objective options container exists.
226
-
227
- Objective registration and resolution are allowed to hydrate this container
228
- lazily so controller construction does not need to eagerly materialize every
229
- optional configuration branch.
230
-
231
- This is one of the small helpers that keeps the core chapter mutation-safe:
232
- later logic can assume the container exists without scattering defensive
233
- object creation throughout the file.
234
-
235
- Parameters:
236
- - `neatInstance` - - NEAT host receiving the multi-objective container.
237
-
238
- Returns: Initialized multi-objective options.
239
-
240
- ### ensureObjectivesList
241
-
242
- ```ts
243
- ensureObjectivesList(
244
- multiObjectiveOptions: { enabled?: boolean | undefined; objectives?: ObjectiveDescriptor[] | undefined; },
245
- ): ObjectiveDescriptor[]
246
- ```
247
-
248
- Ensure the objectives list exists on the multi-objective container.
249
-
250
- This helper complements container hydration by guaranteeing a writable list
251
- surface for later non-destructive replacement logic.
252
-
253
- It exists so registration code can talk about replacing objectives by key
254
- instead of repeatedly guarding against `undefined` lists.
255
-
256
- Parameters:
257
- - `multiObjectiveOptions` - - Multi-objective container to hydrate.
258
-
259
- Returns: Objectives list ready for non-destructive operations.
260
-
261
261
  ### replaceObjectiveByKey
262
262
 
263
263
  ```ts