@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
@@ -78,13 +78,23 @@ flowchart TB
78
78
  ScoreEntry["ScoredGenomeEntry\nranking helper"] --> Network
79
79
  ```
80
80
 
81
- ### FlappyTrainerNetwork
81
+ ### FlappyGenerationEvaluationPlan
82
82
 
83
- Network shape expected by the Flappy trainer.
83
+ Generation-level rollout plans for staged evaluation.
84
84
 
85
- The trainer only needs the evaluation-facing subset of a full network plus an
86
- optional score field used by staged ranking helpers. That narrow shape keeps
87
- the trainer decoupled from most of the broader network implementation.
85
+ Each generation resolves one plan that answers three questions: how strong is
86
+ the current mutation schedule, which shared seeds belong to each stage, and
87
+ what rollout budget each stage is allowed to spend. This is the contract that
88
+ makes quick screening, full passes, and reevaluation feel like one coherent
89
+ policy instead of three unrelated helper calls.
90
+
91
+ ### FlappyGenerationReport
92
+
93
+ Compact generation report used for training logs.
94
+
95
+ The report is shaped for longitudinal monitoring rather than raw storage. It
96
+ collects the distribution and best-run details needed to judge whether a
97
+ generation improved robustly instead of producing one lucky outlier.
88
98
 
89
99
  ### FlappyTrainerNeatController
90
100
 
@@ -95,13 +105,13 @@ documents only the methods and mutable options it actually depends on, which
95
105
  makes the orchestration code read more like policy and less like framework
96
106
  plumbing.
97
107
 
98
- ### FlappyGenerationReport
108
+ ### FlappyTrainerNetwork
99
109
 
100
- Compact generation report used for training logs.
110
+ Network shape expected by the Flappy trainer.
101
111
 
102
- The report is shaped for longitudinal monitoring rather than raw storage. It
103
- collects the distribution and best-run details needed to judge whether a
104
- generation improved robustly instead of producing one lucky outlier.
112
+ The trainer only needs the evaluation-facing subset of a full network plus an
113
+ optional score field used by staged ranking helpers. That narrow shape keeps
114
+ the trainer decoupled from most of the broader network implementation.
105
115
 
106
116
  ### FlappyTrainerRuntimeState
107
117
 
@@ -119,16 +129,6 @@ These values define the static training shape before runtime state and staged
119
129
  evaluation are attached. Once created, the rest of the trainer can treat this
120
130
  as a stable configuration shelf rather than scattered ad hoc constants.
121
131
 
122
- ### FlappyGenerationEvaluationPlan
123
-
124
- Generation-level rollout plans for staged evaluation.
125
-
126
- Each generation resolves one plan that answers three questions: how strong is
127
- the current mutation schedule, which shared seeds belong to each stage, and
128
- what rollout budget each stage is allowed to spend. This is the contract that
129
- makes quick screening, full passes, and reevaluation feel like one coherent
130
- policy instead of three unrelated helper calls.
131
-
132
132
  ### ScoredGenomeEntry
133
133
 
134
134
  Score carrier used for deterministic ordering helpers.
@@ -139,6 +139,39 @@ leak across multiple helpers.
139
139
 
140
140
  ## trainer/trainer.ts
141
141
 
142
+ ### handleTrainerMainError
143
+
144
+ ```ts
145
+ handleTrainerMainError(
146
+ error: unknown,
147
+ ): void
148
+ ```
149
+
150
+ Handles fatal `main` rejection path.
151
+
152
+ The trainer keeps this boundary small so unexpected failures are formatted in
153
+ one consistent place before reaching the CLI. That keeps shutdown behavior
154
+ and terminal messaging consistent whether the failure came from setup,
155
+ evaluation, or the loop itself.
156
+
157
+ Parameters:
158
+ - `error` - - Unknown rejection reason from trainer execution.
159
+
160
+ Returns: Nothing.
161
+
162
+ ### isDirectTrainerExecution
163
+
164
+ ```ts
165
+ isDirectTrainerExecution(): boolean
166
+ ```
167
+
168
+ Resolves whether this module is the direct Node entrypoint.
169
+
170
+ This lets the file behave as both a reusable module and a runnable script
171
+ without duplicating the startup boundary in a second wrapper file.
172
+
173
+ Returns: `true` when Node launched this file directly.
174
+
142
175
  ### runTrainer
143
176
 
144
177
  ```ts
@@ -176,39 +209,6 @@ Example:
176
209
  await runTrainer();
177
210
  ```
178
211
 
179
- ### handleTrainerMainError
180
-
181
- ```ts
182
- handleTrainerMainError(
183
- error: unknown,
184
- ): void
185
- ```
186
-
187
- Handles fatal `main` rejection path.
188
-
189
- The trainer keeps this boundary small so unexpected failures are formatted in
190
- one consistent place before reaching the CLI. That keeps shutdown behavior
191
- and terminal messaging consistent whether the failure came from setup,
192
- evaluation, or the loop itself.
193
-
194
- Parameters:
195
- - `error` - - Unknown rejection reason from trainer execution.
196
-
197
- Returns: Nothing.
198
-
199
- ### isDirectTrainerExecution
200
-
201
- ```ts
202
- isDirectTrainerExecution(): boolean
203
- ```
204
-
205
- Resolves whether this module is the direct Node entrypoint.
206
-
207
- This lets the file behave as both a reusable module and a runnable script
208
- without duplicating the startup boundary in a second wrapper file.
209
-
210
- Returns: `true` when Node launched this file directly.
211
-
212
212
  ## trainer/trainer.errors.ts
213
213
 
214
214
  Small CLI-facing error-rendering boundary for the trainer.
@@ -218,6 +218,10 @@ shutdown paths from inventing slightly different terminal messages. That is a
218
218
  small detail, but it makes long-running scripts and quick debugging sessions
219
219
  easier to scan.
220
220
 
221
+ ### FLAPPY_TRAINER_UNEXPECTED_ERROR_PREFIX
222
+
223
+ Prefix used when rendering unexpected trainer failures to stderr.
224
+
221
225
  ### formatTrainerErrorMessage
222
226
 
223
227
  ```ts
@@ -237,10 +241,6 @@ Parameters:
237
241
 
238
242
  Returns: Formatted error string for CLI logging.
239
243
 
240
- ### FLAPPY_TRAINER_UNEXPECTED_ERROR_PREFIX
241
-
242
- Prefix used when rendering unexpected trainer failures to stderr.
243
-
244
244
  ## trainer/trainer.constants.ts
245
245
 
246
246
  Named knobs for trainer cadence, fairness, fallback behavior, and terminal
@@ -322,13 +322,6 @@ Reporting and terminal output:
322
322
  | `FLAPPY_TRAINER_LOG_PARTS_DELIMITER` | Keeps compact generation logs consistently tokenized. |
323
323
  | `FLAPPY_TRAINER_STOPPED_MESSAGE` | Gives graceful shutdown a stable terminal message. |
324
324
 
325
- ### FLAPPY_TRAINER_DEFAULT_POPULATION_SIZE
326
-
327
- Default population size used by the Flappy trainer NEAT run.
328
-
329
- The demo keeps this large enough for staged selection to matter while still
330
- remaining practical for local experimentation.
331
-
332
325
  ### FLAPPY_TRAINER_DEFAULT_ELITISM_COUNT
333
326
 
334
327
  Number of elite genomes preserved unchanged each generation.
@@ -336,6 +329,13 @@ Number of elite genomes preserved unchanged each generation.
336
329
  Preserving a small elite keeps the trainer from discarding clearly strong
337
330
  genomes while the rest of the population continues exploring.
338
331
 
332
+ ### FLAPPY_TRAINER_DEFAULT_POPULATION_SIZE
333
+
334
+ Default population size used by the Flappy trainer NEAT run.
335
+
336
+ The demo keeps this large enough for staged selection to matter while still
337
+ remaining practical for local experimentation.
338
+
339
339
  ### FLAPPY_TRAINER_DEFAULT_RNG_SEED
340
340
 
341
341
  Deterministic trainer RNG seed used for reproducible training runs.
@@ -343,215 +343,215 @@ Deterministic trainer RNG seed used for reproducible training runs.
343
343
  Reusing the shared Flappy example seed makes trainer behavior easier to
344
344
  compare across doc examples, tests, and manual tuning sessions.
345
345
 
346
- ### FLAPPY_TRAINER_STOPPED_MESSAGE
346
+ ### FLAPPY_TRAINER_DUMMY_FLAP_OUTPUT
347
347
 
348
- Log message emitted when trainer loop exits cleanly.
348
+ Dummy output channel value for the "flap" action score.
349
349
 
350
- A dedicated constant keeps the shutdown path stable for humans and for any
351
- scripts that watch trainer output.
350
+ Keeping the flap score lower than the no-flap score produces a predictable
351
+ never-flap dummy network for defensive report code paths.
352
352
 
353
- ### FLAPPY_TRAINER_REEVALUATION_MIN_CANDIDATE_COUNT
353
+ ### FLAPPY_TRAINER_DUMMY_NETWORK_ID
354
354
 
355
- Minimum candidate count for reevaluation stage, regardless of elitism.
355
+ ID used by dummy fallback network for defensive reporting paths.
356
356
 
357
- This prevents small elite settings from starving the anti-luck pass of enough
358
- genomes to produce a meaningful final comparison.
357
+ The report helpers occasionally need a safe stand-in network so logging can
358
+ stay total even when no real population data is available.
359
359
 
360
- ### FLAPPY_TRAINER_SCORE_MEDIAN_PERCENTILE
360
+ ### FLAPPY_TRAINER_DUMMY_NO_FLAP_OUTPUT
361
361
 
362
- Percentile used when reporting median population score.
362
+ Dummy output channel value for the "no flap" action score.
363
363
 
364
- Keeping the percentile explicit makes the report math self-documenting even
365
- for readers who skim the log formatter before the statistics helpers.
364
+ The dummy network intentionally prefers the passive action so fallback report
365
+ generation remains deterministic and simple.
366
366
 
367
- ### FLAPPY_TRAINER_SCORE_P90_PERCENTILE
367
+ ### FLAPPY_TRAINER_FRAME_PRIMARY_BASE_SCORE
368
368
 
369
- Percentile used when reporting high-end population score (P90).
369
+ Base offset awarded to genomes that satisfy the mean-pipe progress filter.
370
370
 
371
- The trainer uses `p90` as a quick "is the upper tail getting healthier?"
372
- signal without over-focusing on only the single best genome.
371
+ The large offset makes it obvious that surviving the gate is more important
372
+ than tiny differences in the secondary frame-oriented terms.
373
373
 
374
- ### FLAPPY_TRAINER_MUTATION_ANNEAL_GENERATIONS
374
+ ### FLAPPY_TRAINER_FRAME_PRIMARY_PIPE_WEIGHT
375
375
 
376
- Generation count used to fully anneal mutation schedule from start to end values.
376
+ Pipe-progress contribution weight for frame-primary scoring.
377
377
 
378
- Within this window the trainer gradually cools from more exploratory updates
379
- toward smaller, steadier changes.
378
+ This keeps pipe progress visible even inside the gated scoring branch so the
379
+ ranking still prefers genuinely advancing policies.
380
380
 
381
- ### FLAPPY_TRAINER_MUTATION_RATE_START
381
+ ### FLAPPY_TRAINER_FRAME_PRIMARY_SURVIVAL_WEIGHT
382
382
 
383
- Initial mutation rate at generation `0` before annealing.
383
+ Survival contribution weight for frame-primary scoring.
384
384
 
385
- The starting rate is intentionally aggressive so the early population can
386
- discover useful topologies quickly.
385
+ Once a genome passes the pipe-progress gate, extra survival time still matters
386
+ because it often signals more stable control.
387
387
 
388
- ### FLAPPY_TRAINER_MUTATION_RATE_END
388
+ ### FLAPPY_TRAINER_FRAME_STABILITY_STDDEV_WEIGHT
389
389
 
390
- Final mutation rate reached after annealing window completes.
390
+ Penalty multiplier applied to fitness standard deviation in frame-primary scoring.
391
391
 
392
- Lower late-stage mutation pressure helps good policies stabilize instead of
393
- being reshuffled as aggressively as the opening generations.
392
+ Higher instability lowers the provisional score so a lucky but erratic genome
393
+ is less likely to outrank a steadier competitor.
394
394
 
395
- ### FLAPPY_TRAINER_MUTATION_AMOUNT_START
395
+ ### FLAPPY_TRAINER_FULL_PASS_ELITISM_MULTIPLIER
396
396
 
397
- Initial mutation amount at generation `0` before annealing.
397
+ Multiplier over elitism used to size full-pass candidate pool.
398
398
 
399
- This controls how many mutation operations can be applied while the trainer
400
- is still in its exploratory phase.
399
+ This ties the full-pass budget to a familiar population concept so the deeper
400
+ stage scales alongside the preserved elite.
401
401
 
402
- ### FLAPPY_TRAINER_MUTATION_AMOUNT_END
402
+ ### FLAPPY_TRAINER_FULL_PASS_POPULATION_FRACTION
403
403
 
404
- Final mutation amount reached after annealing window completes.
404
+ Population fraction used to size full-pass candidate pool.
405
405
 
406
- Cooling the mutation amount along with the rate reduces late-generation noise
407
- without fully freezing structural search.
406
+ The full stage uses the larger of this fraction and the elitism-based floor so
407
+ promising mid-pack genomes are not excluded too aggressively.
408
408
 
409
- ### FLAPPY_TRAINER_NEAT_INITIAL_MUTATION_RATE
409
+ ### FLAPPY_TRAINER_FULL_ROLLOUT_EARLY_TERMINATION_CONSECUTIVE_FRAMES
410
410
 
411
- Initial NEAT mutation rate before generation schedule annealing is applied.
411
+ Consecutive unrecoverable frames needed to stop full rollout early.
412
412
 
413
- This seeds the controller with a sensible baseline before the per-generation
414
- planner starts taking over.
413
+ This longer streak makes the full stage less trigger-happy than the quick
414
+ screen while still avoiding wasted rollout budget.
415
415
 
416
- ### FLAPPY_TRAINER_NEAT_INITIAL_MUTATION_AMOUNT
416
+ ### FLAPPY_TRAINER_FULL_ROLLOUT_EARLY_TERMINATION_GRACE_FRAMES
417
417
 
418
- Initial NEAT mutation amount before generation schedule annealing is applied.
418
+ Early-termination grace frames used during full rollout stage.
419
419
 
420
- Matching the controller bootstrap to the trainer policy avoids a confusing
421
- mismatch between generation `0` and later loop behavior.
420
+ The deeper stage allows more time before judging a trajectory unrecoverable
421
+ because the trainer is now evaluating stronger candidates more carefully.
422
422
 
423
- ### FLAPPY_TRAINER_QUICK_ROLLOUT_MAX_FRAMES
423
+ ### FLAPPY_TRAINER_FULL_ROLLOUT_PIPE_PROGRESS_TARGET
424
424
 
425
- Frame cap used during quick screening rollout stage.
425
+ Pipe-progress target used to normalize full and reevaluation rollout fitness.
426
426
 
427
- The quick stage is supposed to eliminate obviously weak genomes cheaply, so
428
- its horizon is intentionally shorter than the full evaluation horizon.
427
+ The deeper stages share a tougher target because they are used for robust
428
+ ranking rather than first-pass elimination.
429
429
 
430
- ### FLAPPY_TRAINER_QUICK_ROLLOUT_EARLY_TERMINATION_GRACE_FRAMES
430
+ ### FLAPPY_TRAINER_LOG_PARTS_DELIMITER
431
431
 
432
- Early-termination grace frames used during quick screening rollout stage.
432
+ Delimiter used when composing compact generation log lines.
433
433
 
434
- This short grace period gives a policy a brief chance to stabilize before the
435
- unrecoverable-flight heuristic is allowed to stop the rollout.
434
+ A single-space delimiter keeps the log dense, stable, and easy to parse by eye
435
+ during long-running terminal sessions.
436
436
 
437
- ### FLAPPY_TRAINER_QUICK_ROLLOUT_EARLY_TERMINATION_CONSECUTIVE_FRAMES
437
+ ### FLAPPY_TRAINER_MUTATION_AMOUNT_END
438
438
 
439
- Consecutive unrecoverable frames needed to stop quick screening rollout early.
439
+ Final mutation amount reached after annealing window completes.
440
440
 
441
- Requiring a streak prevents one noisy frame from ending the screen too early
442
- while still saving time on clearly doomed trajectories.
441
+ Cooling the mutation amount along with the rate reduces late-generation noise
442
+ without fully freezing structural search.
443
443
 
444
- ### FLAPPY_TRAINER_QUICK_ROLLOUT_PIPE_PROGRESS_TARGET
444
+ ### FLAPPY_TRAINER_MUTATION_AMOUNT_START
445
445
 
446
- Pipe-progress target used to normalize quick screening rollout fitness.
446
+ Initial mutation amount at generation `0` before annealing.
447
447
 
448
- The lower quick-stage target reflects the fact that this pass is a screen, not
449
- the trainer's final statement of policy quality.
448
+ This controls how many mutation operations can be applied while the trainer
449
+ is still in its exploratory phase.
450
450
 
451
- ### FLAPPY_TRAINER_FULL_ROLLOUT_EARLY_TERMINATION_GRACE_FRAMES
451
+ ### FLAPPY_TRAINER_MUTATION_ANNEAL_GENERATIONS
452
452
 
453
- Early-termination grace frames used during full rollout stage.
453
+ Generation count used to fully anneal mutation schedule from start to end values.
454
454
 
455
- The deeper stage allows more time before judging a trajectory unrecoverable
456
- because the trainer is now evaluating stronger candidates more carefully.
455
+ Within this window the trainer gradually cools from more exploratory updates
456
+ toward smaller, steadier changes.
457
457
 
458
- ### FLAPPY_TRAINER_FULL_ROLLOUT_EARLY_TERMINATION_CONSECUTIVE_FRAMES
458
+ ### FLAPPY_TRAINER_MUTATION_RATE_END
459
459
 
460
- Consecutive unrecoverable frames needed to stop full rollout early.
460
+ Final mutation rate reached after annealing window completes.
461
461
 
462
- This longer streak makes the full stage less trigger-happy than the quick
463
- screen while still avoiding wasted rollout budget.
462
+ Lower late-stage mutation pressure helps good policies stabilize instead of
463
+ being reshuffled as aggressively as the opening generations.
464
464
 
465
- ### FLAPPY_TRAINER_FULL_ROLLOUT_PIPE_PROGRESS_TARGET
465
+ ### FLAPPY_TRAINER_MUTATION_RATE_START
466
466
 
467
- Pipe-progress target used to normalize full and reevaluation rollout fitness.
467
+ Initial mutation rate at generation `0` before annealing.
468
468
 
469
- The deeper stages share a tougher target because they are used for robust
470
- ranking rather than first-pass elimination.
469
+ The starting rate is intentionally aggressive so the early population can
470
+ discover useful topologies quickly.
471
471
 
472
- ### FLAPPY_TRAINER_FRAME_STABILITY_STDDEV_WEIGHT
472
+ ### FLAPPY_TRAINER_NEAT_INITIAL_MUTATION_AMOUNT
473
473
 
474
- Penalty multiplier applied to fitness standard deviation in frame-primary scoring.
474
+ Initial NEAT mutation amount before generation schedule annealing is applied.
475
475
 
476
- Higher instability lowers the provisional score so a lucky but erratic genome
477
- is less likely to outrank a steadier competitor.
476
+ Matching the controller bootstrap to the trainer policy avoids a confusing
477
+ mismatch between generation `0` and later loop behavior.
478
478
 
479
- ### FLAPPY_TRAINER_PIPE_FILTER_TOLERANCE
479
+ ### FLAPPY_TRAINER_NEAT_INITIAL_MUTATION_RATE
480
480
 
481
- Allowed mean-pipes delta from the current best before frame-primary scoring applies.
481
+ Initial NEAT mutation rate before generation schedule annealing is applied.
482
482
 
483
- This acts like a gating tolerance: only genomes close enough in pipe progress
484
- get the more generous frame-primary score treatment.
483
+ This seeds the controller with a sensible baseline before the per-generation
484
+ planner starts taking over.
485
485
 
486
- ### FLAPPY_TRAINER_FRAME_PRIMARY_BASE_SCORE
486
+ ### FLAPPY_TRAINER_PIPE_FALLBACK_PIPE_WEIGHT
487
487
 
488
- Base offset awarded to genomes that satisfy the mean-pipe progress filter.
488
+ Pipe-progress contribution weight for fallback scoring path.
489
489
 
490
- The large offset makes it obvious that surviving the gate is more important
491
- than tiny differences in the secondary frame-oriented terms.
490
+ The fallback path leans heavily on pipe progress because it is the clearest
491
+ robust signal available before the primary gate is satisfied.
492
492
 
493
- ### FLAPPY_TRAINER_FRAME_PRIMARY_SURVIVAL_WEIGHT
493
+ ### FLAPPY_TRAINER_PIPE_FILTER_TOLERANCE
494
494
 
495
- Survival contribution weight for frame-primary scoring.
495
+ Allowed mean-pipes delta from the current best before frame-primary scoring applies.
496
496
 
497
- Once a genome passes the pipe-progress gate, extra survival time still matters
498
- because it often signals more stable control.
497
+ This acts like a gating tolerance: only genomes close enough in pipe progress
498
+ get the more generous frame-primary score treatment.
499
499
 
500
- ### FLAPPY_TRAINER_FRAME_PRIMARY_PIPE_WEIGHT
500
+ ### FLAPPY_TRAINER_QUICK_ROLLOUT_EARLY_TERMINATION_CONSECUTIVE_FRAMES
501
501
 
502
- Pipe-progress contribution weight for frame-primary scoring.
502
+ Consecutive unrecoverable frames needed to stop quick screening rollout early.
503
503
 
504
- This keeps pipe progress visible even inside the gated scoring branch so the
505
- ranking still prefers genuinely advancing policies.
504
+ Requiring a streak prevents one noisy frame from ending the screen too early
505
+ while still saving time on clearly doomed trajectories.
506
506
 
507
- ### FLAPPY_TRAINER_PIPE_FALLBACK_PIPE_WEIGHT
507
+ ### FLAPPY_TRAINER_QUICK_ROLLOUT_EARLY_TERMINATION_GRACE_FRAMES
508
508
 
509
- Pipe-progress contribution weight for fallback scoring path.
509
+ Early-termination grace frames used during quick screening rollout stage.
510
510
 
511
- The fallback path leans heavily on pipe progress because it is the clearest
512
- robust signal available before the primary gate is satisfied.
511
+ This short grace period gives a policy a brief chance to stabilize before the
512
+ unrecoverable-flight heuristic is allowed to stop the rollout.
513
513
 
514
- ### FLAPPY_TRAINER_FULL_PASS_ELITISM_MULTIPLIER
514
+ ### FLAPPY_TRAINER_QUICK_ROLLOUT_MAX_FRAMES
515
515
 
516
- Multiplier over elitism used to size full-pass candidate pool.
516
+ Frame cap used during quick screening rollout stage.
517
517
 
518
- This ties the full-pass budget to a familiar population concept so the deeper
519
- stage scales alongside the preserved elite.
518
+ The quick stage is supposed to eliminate obviously weak genomes cheaply, so
519
+ its horizon is intentionally shorter than the full evaluation horizon.
520
520
 
521
- ### FLAPPY_TRAINER_FULL_PASS_POPULATION_FRACTION
521
+ ### FLAPPY_TRAINER_QUICK_ROLLOUT_PIPE_PROGRESS_TARGET
522
522
 
523
- Population fraction used to size full-pass candidate pool.
523
+ Pipe-progress target used to normalize quick screening rollout fitness.
524
524
 
525
- The full stage uses the larger of this fraction and the elitism-based floor so
526
- promising mid-pack genomes are not excluded too aggressively.
525
+ The lower quick-stage target reflects the fact that this pass is a screen, not
526
+ the trainer's final statement of policy quality.
527
527
 
528
- ### FLAPPY_TRAINER_DUMMY_NETWORK_ID
528
+ ### FLAPPY_TRAINER_REEVALUATION_MIN_CANDIDATE_COUNT
529
529
 
530
- ID used by dummy fallback network for defensive reporting paths.
530
+ Minimum candidate count for reevaluation stage, regardless of elitism.
531
531
 
532
- The report helpers occasionally need a safe stand-in network so logging can
533
- stay total even when no real population data is available.
532
+ This prevents small elite settings from starving the anti-luck pass of enough
533
+ genomes to produce a meaningful final comparison.
534
534
 
535
- ### FLAPPY_TRAINER_DUMMY_NO_FLAP_OUTPUT
535
+ ### FLAPPY_TRAINER_SCORE_MEDIAN_PERCENTILE
536
536
 
537
- Dummy output channel value for the "no flap" action score.
537
+ Percentile used when reporting median population score.
538
538
 
539
- The dummy network intentionally prefers the passive action so fallback report
540
- generation remains deterministic and simple.
539
+ Keeping the percentile explicit makes the report math self-documenting even
540
+ for readers who skim the log formatter before the statistics helpers.
541
541
 
542
- ### FLAPPY_TRAINER_DUMMY_FLAP_OUTPUT
542
+ ### FLAPPY_TRAINER_SCORE_P90_PERCENTILE
543
543
 
544
- Dummy output channel value for the "flap" action score.
544
+ Percentile used when reporting high-end population score (P90).
545
545
 
546
- Keeping the flap score lower than the no-flap score produces a predictable
547
- never-flap dummy network for defensive report code paths.
546
+ The trainer uses `p90` as a quick "is the upper tail getting healthier?"
547
+ signal without over-focusing on only the single best genome.
548
548
 
549
- ### FLAPPY_TRAINER_LOG_PARTS_DELIMITER
549
+ ### FLAPPY_TRAINER_STOPPED_MESSAGE
550
550
 
551
- Delimiter used when composing compact generation log lines.
551
+ Log message emitted when trainer loop exits cleanly.
552
552
 
553
- A single-space delimiter keeps the log dense, stable, and easy to parse by eye
554
- during long-running terminal sessions.
553
+ A dedicated constant keeps the shutdown path stable for humans and for any
554
+ scripts that watch trainer output.
555
555
 
556
556
  ## trainer/trainer.loop.service.ts
557
557
 
@@ -572,29 +572,26 @@ flowchart LR
572
572
  Log --> Resolve
573
573
  ```
574
574
 
575
- ### runTrainerEvolutionLoop
575
+ ### applyMutationSchedule
576
576
 
577
577
  ```ts
578
- runTrainerEvolutionLoop(
578
+ applyMutationSchedule(
579
579
  neatController: FlappyTrainerNeatController,
580
- trainerRuntimeState: FlappyTrainerRuntimeState,
581
- logGenerationSummary: LogGenerationSummaryCallback,
582
- ): Promise<void>
580
+ mutationSchedule: FlappyMutationSchedule,
581
+ ): void
583
582
  ```
584
583
 
585
- Runs the outer evolution loop until runtime stop is requested.
584
+ Applies mutation schedule values to the NEAT controller options.
586
585
 
587
- Educational note:
588
- This is the trainer's main heartbeat: resolve the current mutation schedule,
589
- evolve one generation, run a representative fallback rollout for logging, and
590
- emit a compact summary.
586
+ The schedule is resolved outside this helper so the loop can read as a clean
587
+ "resolve -> apply -> evolve -> report" flow. That separation also makes it
588
+ easier to inspect the active schedule in logs or tests.
591
589
 
592
590
  Parameters:
593
591
  - `neatController` - - Trainer NEAT controller.
594
- - `trainerRuntimeState` - - Mutable trainer runtime state.
595
- - `logGenerationSummary` - - Callback that emits compact generation logs.
592
+ - `mutationSchedule` - - Mutation schedule for current generation.
596
593
 
597
- Returns: Promise resolved when the trainer has been stopped.
594
+ Returns: Nothing.
598
595
 
599
596
  ### LogGenerationSummaryCallback
600
597
 
@@ -614,26 +611,29 @@ The loop owns evolution cadence, while the callback owns presentation.
614
611
  Keeping those concerns separate makes it easy to reuse the loop with richer
615
612
  reporting later.
616
613
 
617
- ### applyMutationSchedule
614
+ ### runTrainerEvolutionLoop
618
615
 
619
616
  ```ts
620
- applyMutationSchedule(
617
+ runTrainerEvolutionLoop(
621
618
  neatController: FlappyTrainerNeatController,
622
- mutationSchedule: FlappyMutationSchedule,
623
- ): void
619
+ trainerRuntimeState: FlappyTrainerRuntimeState,
620
+ logGenerationSummary: LogGenerationSummaryCallback,
621
+ ): Promise<void>
624
622
  ```
625
623
 
626
- Applies mutation schedule values to the NEAT controller options.
624
+ Runs the outer evolution loop until runtime stop is requested.
627
625
 
628
- The schedule is resolved outside this helper so the loop can read as a clean
629
- "resolve -> apply -> evolve -> report" flow. That separation also makes it
630
- easier to inspect the active schedule in logs or tests.
626
+ Educational note:
627
+ This is the trainer's main heartbeat: resolve the current mutation schedule,
628
+ evolve one generation, run a representative fallback rollout for logging, and
629
+ emit a compact summary.
631
630
 
632
631
  Parameters:
633
632
  - `neatController` - - Trainer NEAT controller.
634
- - `mutationSchedule` - - Mutation schedule for current generation.
633
+ - `trainerRuntimeState` - - Mutable trainer runtime state.
634
+ - `logGenerationSummary` - - Callback that emits compact generation logs.
635
635
 
636
- Returns: Nothing.
636
+ Returns: Promise resolved when the trainer has been stopped.
637
637
 
638
638
  ## trainer/trainer.setup.service.ts
639
639
 
@@ -644,20 +644,32 @@ controller construction can be read, tested, and tuned without also reading
644
644
  the outer loop. This boundary answers a simple question: what does the demo
645
645
  need before the first generation can run?
646
646
 
647
- ### createTrainerSetup
647
+ ### createNeatController
648
648
 
649
649
  ```ts
650
- createTrainerSetup(): FlappyTrainerSetup
650
+ createNeatController(
651
+ trainerSetup: FlappyTrainerSetup,
652
+ ): FlappyTrainerNeatController
651
653
  ```
652
654
 
653
- Creates immutable setup values for the trainer.
655
+ Builds the NEAT controller with baseline options.
654
656
 
655
657
  Educational note:
656
- The setup object freezes the core training shape up front: input width,
657
- output width, population size, and elitism count. Centralizing those values
658
- makes the rest of the trainer read as policy rather than configuration noise.
658
+ The trainer enables population-level fitness mode because the quality of a
659
+ Flappy policy depends on fair comparison across shared seed batches, not on a
660
+ one-network-at-a-time scoring callback.
659
661
 
660
- Returns: Default trainer setup values used for NEAT configuration.
662
+ Parameters:
663
+ - `trainerSetup` - - Immutable trainer setup values.
664
+
665
+ Returns: Typed NEAT controller used by the trainer loop.
666
+
667
+ Example:
668
+
669
+ ```ts
670
+ const trainerSetup = createTrainerSetup();
671
+ const neatController = createNeatController(trainerSetup);
672
+ ```
661
673
 
662
674
  ### createTrainerRuntimeState
663
675
 
@@ -672,32 +684,20 @@ latest report so the outer loop can remain easy to reason about.
672
684
 
673
685
  Returns: Fresh runtime state used by loop orchestration.
674
686
 
675
- ### createNeatController
687
+ ### createTrainerSetup
676
688
 
677
689
  ```ts
678
- createNeatController(
679
- trainerSetup: FlappyTrainerSetup,
680
- ): FlappyTrainerNeatController
690
+ createTrainerSetup(): FlappyTrainerSetup
681
691
  ```
682
692
 
683
- Builds the NEAT controller with baseline options.
693
+ Creates immutable setup values for the trainer.
684
694
 
685
695
  Educational note:
686
- The trainer enables population-level fitness mode because the quality of a
687
- Flappy policy depends on fair comparison across shared seed batches, not on a
688
- one-network-at-a-time scoring callback.
689
-
690
- Parameters:
691
- - `trainerSetup` - - Immutable trainer setup values.
692
-
693
- Returns: Typed NEAT controller used by the trainer loop.
694
-
695
- Example:
696
+ The setup object freezes the core training shape up front: input width,
697
+ output width, population size, and elitism count. Centralizing those values
698
+ makes the rest of the trainer read as policy rather than configuration noise.
696
699
 
697
- ```ts
698
- const trainerSetup = createTrainerSetup();
699
- const neatController = createNeatController(trainerSetup);
700
- ```
700
+ Returns: Default trainer setup values used for NEAT configuration.
701
701
 
702
702
  ### resolveNoopFitness
703
703
 
@@ -868,38 +868,38 @@ The trainer should stop between generations, not by tearing the process down
868
868
  in the middle of evaluation. This file converts OS-level stop signals into one
869
869
  shared runtime intent flag that the main loop can observe safely.
870
870
 
871
- ### registerTrainerStopSignals
871
+ ### handleTrainerStopSignal
872
872
 
873
873
  ```ts
874
- registerTrainerStopSignals(
874
+ handleTrainerStopSignal(
875
875
  trainerRuntimeState: FlappyTrainerRuntimeState,
876
876
  ): void
877
877
  ```
878
878
 
879
- Registers graceful stop signal handlers.
879
+ Handles one stop signal update.
880
880
 
881
- Educational note:
882
- Long-running evolutionary runs should stop cleanly when the user presses
883
- `Ctrl+C`. This service flips runtime intent instead of abruptly tearing down
884
- the process mid-generation.
881
+ The handler does the minimum possible work because signal paths should stay
882
+ predictable and side-effect light.
885
883
 
886
884
  Parameters:
887
885
  - `trainerRuntimeState` - - Mutable trainer runtime state.
888
886
 
889
887
  Returns: Nothing.
890
888
 
891
- ### handleTrainerStopSignal
889
+ ### registerTrainerStopSignals
892
890
 
893
891
  ```ts
894
- handleTrainerStopSignal(
892
+ registerTrainerStopSignals(
895
893
  trainerRuntimeState: FlappyTrainerRuntimeState,
896
894
  ): void
897
895
  ```
898
896
 
899
- Handles one stop signal update.
897
+ Registers graceful stop signal handlers.
900
898
 
901
- The handler does the minimum possible work because signal paths should stay
902
- predictable and side-effect light.
899
+ Educational note:
900
+ Long-running evolutionary runs should stop cleanly when the user presses
901
+ `Ctrl+C`. This service flips runtime intent instead of abruptly tearing down
902
+ the process mid-generation.
903
903
 
904
904
  Parameters:
905
905
  - `trainerRuntimeState` - - Mutable trainer runtime state.
@@ -1164,43 +1164,43 @@ These utilities keep score extraction and descending-order selection in one
1164
1164
  place so the staged evaluation services do not each reinvent the same sorting
1165
1165
  logic with slightly different fallback rules.
1166
1166
 
1167
- ### selectTopGenomesByScore
1167
+ ### resolveBestGenomeByScore
1168
1168
 
1169
1169
  ```ts
1170
- selectTopGenomesByScore(
1170
+ resolveBestGenomeByScore(
1171
1171
  population: readonly FlappyTrainerNetwork[],
1172
- provisionalScoresByGenome: ReadonlyMap<FlappyTrainerNetwork, number>,
1173
- targetCount: number,
1174
- ): FlappyTrainerNetwork[]
1172
+ ): FlappyTrainerNetwork | undefined
1175
1173
  ```
1176
1174
 
1177
- Returns top genomes ordered by current provisional score.
1175
+ Resolves the best genome by current score.
1176
+
1177
+ This helper is intentionally tiny, but it gives the rest of the trainer a
1178
+ single vocabulary term for "the current best genome under whatever score shelf
1179
+ is currently populated."
1178
1180
 
1179
1181
  Parameters:
1180
1182
  - `population` - - Current trainer population.
1181
- - `provisionalScoresByGenome` - - Optional map of staged provisional scores.
1182
- - `targetCount` - - Maximum number of genomes to return.
1183
1183
 
1184
- Returns: Highest-scoring genomes in descending score order.
1184
+ Returns: Highest-scoring genome or `undefined` when population is empty.
1185
1185
 
1186
- ### resolveBestGenomeByScore
1186
+ ### selectTopGenomesByScore
1187
1187
 
1188
1188
  ```ts
1189
- resolveBestGenomeByScore(
1189
+ selectTopGenomesByScore(
1190
1190
  population: readonly FlappyTrainerNetwork[],
1191
- ): FlappyTrainerNetwork | undefined
1191
+ provisionalScoresByGenome: ReadonlyMap<FlappyTrainerNetwork, number>,
1192
+ targetCount: number,
1193
+ ): FlappyTrainerNetwork[]
1192
1194
  ```
1193
1195
 
1194
- Resolves the best genome by current score.
1195
-
1196
- This helper is intentionally tiny, but it gives the rest of the trainer a
1197
- single vocabulary term for "the current best genome under whatever score shelf
1198
- is currently populated."
1196
+ Returns top genomes ordered by current provisional score.
1199
1197
 
1200
1198
  Parameters:
1201
1199
  - `population` - - Current trainer population.
1200
+ - `provisionalScoresByGenome` - - Optional map of staged provisional scores.
1201
+ - `targetCount` - - Maximum number of genomes to return.
1202
1202
 
1203
- Returns: Highest-scoring genome or `undefined` when population is empty.
1203
+ Returns: Highest-scoring genomes in descending score order.
1204
1204
 
1205
1205
  ## trainer/trainer.evaluation-plan.utils.ts
1206
1206
 
@@ -1232,50 +1232,46 @@ flowchart TB
1232
1232
  ReevalOptions --> Plan
1233
1233
  ```
1234
1234
 
1235
- ### resolveGenerationEvaluationPlan
1235
+ ### buildSharedSeedBatch
1236
1236
 
1237
1237
  ```ts
1238
- resolveGenerationEvaluationPlan(
1238
+ buildSharedSeedBatch(
1239
1239
  generationIndex: number,
1240
- ): FlappyGenerationEvaluationPlan
1240
+ stageSalt: number,
1241
+ seedCount: number,
1242
+ ): number[]
1241
1243
  ```
1242
1244
 
1243
- Resolves all per-generation evaluation controls.
1245
+ Build deterministic shared seeds for one generation stage.
1244
1246
 
1245
- Think of this as the trainer's "generation contract": the rest of the system
1246
- can ask for one object and receive a fully prepared set of seeds, rollout
1247
- options, and annealed mutation values.
1247
+ Shared seeds are what make same-generation comparisons fair: genomes face the
1248
+ same sampled worlds instead of winning because they happened to get a kinder
1249
+ random rollout.
1248
1250
 
1249
1251
  Parameters:
1250
1252
  - `generationIndex` - - Zero-based generation index.
1253
+ - `stageSalt` - - Constant stage-specific salt.
1254
+ - `seedCount` - - Number of seeds to produce.
1251
1255
 
1252
- Returns: Full staged evaluation plan for the generation.
1256
+ Returns: Deterministic shared seed list.
1253
1257
 
1254
- ### resolveMutationSchedule
1258
+ ### createFullRolloutOptions
1255
1259
 
1256
1260
  ```ts
1257
- resolveMutationSchedule(
1258
- generationIndex: number,
1259
- ): FlappyMutationSchedule
1261
+ createFullRolloutOptions(
1262
+ difficultyScale: number,
1263
+ ): FlappyRolloutOptions
1260
1264
  ```
1261
1265
 
1262
- Resolve a smooth mutation annealing schedule.
1266
+ Builds full-stage rollout options.
1263
1267
 
1264
- Early generations mutate more aggressively so the population can search the
1265
- space broadly. Later generations cool down so the trainer can refine useful
1266
- structures rather than constantly replacing them.
1268
+ This stage gives stronger candidates a longer, stricter test so the trainer
1269
+ can refine the leaderboard before committing to expensive reevaluation.
1267
1270
 
1268
1271
  Parameters:
1269
- - `generationIndex` - - Zero-based generation index.
1270
-
1271
- Returns: Mutation rate and mutation amount for this generation.
1272
-
1273
- ### FlappyMutationSchedule
1274
-
1275
- Mutation schedule used by generation planning and outer loop logging.
1272
+ - `difficultyScale` - - Difficulty scale for this generation.
1276
1273
 
1277
- These two numbers are treated as a single policy decision because the trainer
1278
- cools both the frequency and the size of mutations together.
1274
+ Returns: Full stage rollout options.
1279
1275
 
1280
1276
  ### createQuickRolloutOptions
1281
1277
 
@@ -1296,41 +1292,50 @@ Parameters:
1296
1292
 
1297
1293
  Returns: Quick stage rollout options.
1298
1294
 
1299
- ### createFullRolloutOptions
1295
+ ### createReevaluationRolloutOptions
1300
1296
 
1301
1297
  ```ts
1302
- createFullRolloutOptions(
1298
+ createReevaluationRolloutOptions(
1303
1299
  difficultyScale: number,
1304
1300
  ): FlappyRolloutOptions
1305
1301
  ```
1306
1302
 
1307
- Builds full-stage rollout options.
1303
+ Builds high-confidence reevaluation rollout options.
1308
1304
 
1309
- This stage gives stronger candidates a longer, stricter test so the trainer
1310
- can refine the leaderboard before committing to expensive reevaluation.
1305
+ Reevaluation deliberately disables early termination so the strongest
1306
+ candidates are judged on a more faithful, less shortcut-heavy comparison.
1311
1307
 
1312
1308
  Parameters:
1313
1309
  - `difficultyScale` - - Difficulty scale for this generation.
1314
1310
 
1315
- Returns: Full stage rollout options.
1311
+ Returns: Reevaluation stage rollout options.
1316
1312
 
1317
- ### createReevaluationRolloutOptions
1313
+ ### FlappyMutationSchedule
1314
+
1315
+ Mutation schedule used by generation planning and outer loop logging.
1316
+
1317
+ These two numbers are treated as a single policy decision because the trainer
1318
+ cools both the frequency and the size of mutations together.
1319
+
1320
+ ### mixSeed
1318
1321
 
1319
1322
  ```ts
1320
- createReevaluationRolloutOptions(
1321
- difficultyScale: number,
1322
- ): FlappyRolloutOptions
1323
+ mixSeed(
1324
+ generationIndex: number,
1325
+ stageSalt: number,
1326
+ ): number
1323
1327
  ```
1324
1328
 
1325
- Builds high-confidence reevaluation rollout options.
1329
+ Mixes generation and stage salts into a deterministic uint32 RNG seed.
1326
1330
 
1327
- Reevaluation deliberately disables early termination so the strongest
1328
- candidates are judged on a more faithful, less shortcut-heavy comparison.
1331
+ The small mixing pipeline spreads nearby generation numbers apart so adjacent
1332
+ stages and generations do not accidentally reuse overly correlated seed sets.
1329
1333
 
1330
1334
  Parameters:
1331
- - `difficultyScale` - - Difficulty scale for this generation.
1335
+ - `generationIndex` - - Current generation index.
1336
+ - `stageSalt` - - Stage-specific salt.
1332
1337
 
1333
- Returns: Reevaluation stage rollout options.
1338
+ Returns: Mixed uint32 seed.
1334
1339
 
1335
1340
  ### resolveCurriculumDifficultyScale
1336
1341
 
@@ -1350,45 +1355,40 @@ Parameters:
1350
1355
 
1351
1356
  Returns: Difficulty scale in [0, 1].
1352
1357
 
1353
- ### buildSharedSeedBatch
1358
+ ### resolveGenerationEvaluationPlan
1354
1359
 
1355
1360
  ```ts
1356
- buildSharedSeedBatch(
1361
+ resolveGenerationEvaluationPlan(
1357
1362
  generationIndex: number,
1358
- stageSalt: number,
1359
- seedCount: number,
1360
- ): number[]
1363
+ ): FlappyGenerationEvaluationPlan
1361
1364
  ```
1362
1365
 
1363
- Build deterministic shared seeds for one generation stage.
1366
+ Resolves all per-generation evaluation controls.
1364
1367
 
1365
- Shared seeds are what make same-generation comparisons fair: genomes face the
1366
- same sampled worlds instead of winning because they happened to get a kinder
1367
- random rollout.
1368
+ Think of this as the trainer's "generation contract": the rest of the system
1369
+ can ask for one object and receive a fully prepared set of seeds, rollout
1370
+ options, and annealed mutation values.
1368
1371
 
1369
1372
  Parameters:
1370
1373
  - `generationIndex` - - Zero-based generation index.
1371
- - `stageSalt` - - Constant stage-specific salt.
1372
- - `seedCount` - - Number of seeds to produce.
1373
1374
 
1374
- Returns: Deterministic shared seed list.
1375
+ Returns: Full staged evaluation plan for the generation.
1375
1376
 
1376
- ### mixSeed
1377
+ ### resolveMutationSchedule
1377
1378
 
1378
1379
  ```ts
1379
- mixSeed(
1380
+ resolveMutationSchedule(
1380
1381
  generationIndex: number,
1381
- stageSalt: number,
1382
- ): number
1382
+ ): FlappyMutationSchedule
1383
1383
  ```
1384
1384
 
1385
- Mixes generation and stage salts into a deterministic uint32 RNG seed.
1385
+ Resolve a smooth mutation annealing schedule.
1386
1386
 
1387
- The small mixing pipeline spreads nearby generation numbers apart so adjacent
1388
- stages and generations do not accidentally reuse overly correlated seed sets.
1387
+ Early generations mutate more aggressively so the population can search the
1388
+ space broadly. Later generations cool down so the trainer can refine useful
1389
+ structures rather than constantly replacing them.
1389
1390
 
1390
1391
  Parameters:
1391
- - `generationIndex` - - Current generation index.
1392
- - `stageSalt` - - Stage-specific salt.
1392
+ - `generationIndex` - - Zero-based generation index.
1393
1393
 
1394
- Returns: Mixed uint32 seed.
1394
+ Returns: Mutation rate and mutation amount for this generation.