@reicek/neataptic-ts 0.1.15 → 0.1.18

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 (370) hide show
  1. package/.github/copilot-instructions.md +123 -15
  2. package/.prettierrc.json +12 -0
  3. package/bench-browser/bench-entry.ts +1 -1
  4. package/bench-browser/dev.bundle.1759662879868-23916.js +10517 -0
  5. package/bench-browser/dev.bundle.js +229 -229
  6. package/bench-browser/prod.bundle.1759662879868-23916.js +41 -0
  7. package/bench-browser/prod.bundle.js +955 -955
  8. package/docs/architecture/README.md +85 -168
  9. package/docs/architecture/index.html +76 -152
  10. package/docs/architecture/network/README.md +161 -366
  11. package/docs/architecture/network/index.html +79 -282
  12. package/docs/assets/ascii-maze.bundle.js +41 -41
  13. package/docs/assets/ascii-maze.bundle.js.map +4 -4
  14. package/docs/methods/README.md +4 -6
  15. package/docs/methods/index.html +3 -8
  16. package/docs/multithreading/README.md +21 -5
  17. package/docs/multithreading/index.html +8 -6
  18. package/docs/multithreading/workers/README.md +2 -2
  19. package/docs/multithreading/workers/browser/README.md +10 -2
  20. package/docs/multithreading/workers/browser/index.html +6 -4
  21. package/docs/multithreading/workers/index.html +2 -2
  22. package/docs/multithreading/workers/node/README.md +27 -1
  23. package/docs/multithreading/workers/node/index.html +20 -3
  24. package/docs/neat/README.md +8569 -756
  25. package/docs/neat/index.html +5521 -624
  26. package/docs/src/README.md +133 -321
  27. package/docs/src/index.html +123 -182
  28. package/docs/utils/README.md +11 -26
  29. package/docs/utils/index.html +9 -27
  30. package/eslint.config.mjs +57 -0
  31. package/package.json +9 -1
  32. package/plans/ES2023 migration +40 -176
  33. package/plans/HyperMorphoNEAT.md +360 -578
  34. package/plans/Memory_Optimization.md +4 -3
  35. package/src/README.md +133 -321
  36. package/src/architecture/README.md +85 -168
  37. package/src/architecture/activationArrayPool.ts +5 -1
  38. package/src/architecture/architect.ts +24 -21
  39. package/src/architecture/connection.ts +71 -31
  40. package/src/architecture/group.ts +44 -31
  41. package/src/architecture/layer.ts +95 -72
  42. package/src/architecture/network/README.md +161 -366
  43. package/src/architecture/network/network.activate.ts +37 -23
  44. package/src/architecture/network/network.connect.ts +18 -7
  45. package/src/architecture/network/network.deterministic.ts +32 -11
  46. package/src/architecture/network/network.evolve.ts +157 -62
  47. package/src/architecture/network/network.gating.ts +17 -4
  48. package/src/architecture/network/network.genetic.ts +107 -72
  49. package/src/architecture/network/network.mutate.ts +120 -70
  50. package/src/architecture/network/network.onnx.ts +399 -269
  51. package/src/architecture/network/network.prune.ts +44 -22
  52. package/src/architecture/network/network.remove.ts +21 -10
  53. package/src/architecture/network/network.serialize.ts +222 -104
  54. package/src/architecture/network/network.slab.ts +245 -91
  55. package/src/architecture/network/network.standalone.ts +61 -34
  56. package/src/architecture/network/network.stats.ts +20 -5
  57. package/src/architecture/network/network.topology.ts +16 -4
  58. package/src/architecture/network/network.training.ts +302 -144
  59. package/src/architecture/network.ts +193 -106
  60. package/src/architecture/node.ts +96 -64
  61. package/src/architecture/nodePool.ts +35 -43
  62. package/src/methods/README.md +4 -6
  63. package/src/methods/activation.ts +8 -4
  64. package/src/methods/cost.ts +3 -3
  65. package/src/methods/mutation.ts +63 -29
  66. package/src/methods/rate.ts +11 -9
  67. package/src/multithreading/README.md +21 -5
  68. package/src/multithreading/multi.ts +31 -23
  69. package/src/multithreading/types.ts +20 -0
  70. package/src/multithreading/workers/README.md +2 -2
  71. package/src/multithreading/workers/browser/README.md +10 -2
  72. package/src/multithreading/workers/browser/testworker.ts +22 -8
  73. package/src/multithreading/workers/node/README.md +27 -1
  74. package/src/multithreading/workers/node/testworker.ts +36 -19
  75. package/src/multithreading/workers/node/worker.ts +36 -28
  76. package/src/multithreading/workers/workers.ts +8 -4
  77. package/src/neat/README.md +8569 -756
  78. package/src/neat/neat.adaptive.ts +158 -373
  79. package/src/neat/neat.adaptive.utils.ts +1553 -0
  80. package/src/neat/neat.compat.ts +46 -107
  81. package/src/neat/neat.compat.utils.ts +278 -0
  82. package/src/neat/neat.diversity.ts +18 -178
  83. package/src/neat/neat.diversity.utils.ts +359 -0
  84. package/src/neat/neat.evaluate.auto-distance.utils.ts +210 -0
  85. package/src/neat/neat.evaluate.constants.utils.ts +42 -0
  86. package/src/neat/neat.evaluate.entropy-compat.utils.ts +67 -0
  87. package/src/neat/neat.evaluate.entropy-sharing.utils.ts +78 -0
  88. package/src/neat/neat.evaluate.fitness.utils.ts +48 -0
  89. package/src/neat/neat.evaluate.novelty.utils.ts +225 -0
  90. package/src/neat/neat.evaluate.objectives.utils.ts +50 -0
  91. package/src/neat/neat.evaluate.speciation.utils.ts +35 -0
  92. package/src/neat/neat.evaluate.ts +46 -300
  93. package/src/neat/neat.evaluate.types.utils.ts +198 -0
  94. package/src/neat/neat.evaluate.utils.ts +9 -0
  95. package/src/neat/neat.evolve.adaptive.utils.ts +224 -0
  96. package/src/neat/neat.evolve.objectives.utils.ts +241 -0
  97. package/src/neat/neat.evolve.population.utils.ts +513 -0
  98. package/src/neat/neat.evolve.runtime.utils.ts +128 -0
  99. package/src/neat/neat.evolve.speciation.utils.ts +251 -0
  100. package/src/neat/neat.evolve.telemetry.utils.ts +39 -0
  101. package/src/neat/neat.evolve.ts +241 -988
  102. package/src/neat/neat.evolve.types.ts +320 -0
  103. package/src/neat/neat.evolve.utils.ts +7 -0
  104. package/src/neat/neat.export.ts +98 -39
  105. package/src/neat/neat.harness.types.ts +35 -0
  106. package/src/neat/neat.helpers.ts +119 -54
  107. package/src/neat/neat.lineage.ts +46 -131
  108. package/src/neat/neat.lineage.utils.ts +387 -0
  109. package/src/neat/neat.multiobjective.archive.utils.ts +59 -0
  110. package/src/neat/neat.multiobjective.category.utils.ts +335 -0
  111. package/src/neat/neat.multiobjective.crowding.utils.ts +512 -0
  112. package/src/neat/neat.multiobjective.dominance.utils.ts +403 -0
  113. package/src/neat/neat.multiobjective.fronts.utils.ts +177 -0
  114. package/src/neat/neat.multiobjective.objectives.utils.ts +75 -0
  115. package/src/neat/neat.multiobjective.ts +33 -200
  116. package/src/neat/neat.multiobjective.types.utils.ts +112 -0
  117. package/src/neat/neat.multiobjective.utils.ts +9 -0
  118. package/src/neat/neat.mutation.add-conn.utils.ts +278 -0
  119. package/src/neat/neat.mutation.add-node.utils.ts +309 -0
  120. package/src/neat/neat.mutation.dead-ends.utils.ts +229 -0
  121. package/src/neat/neat.mutation.flow.utils.ts +355 -0
  122. package/src/neat/neat.mutation.min-hidden.utils.ts +281 -0
  123. package/src/neat/neat.mutation.select.utils.ts +347 -0
  124. package/src/neat/neat.mutation.ts +211 -596
  125. package/src/neat/neat.mutation.types.ts +193 -0
  126. package/src/neat/neat.mutation.utils.ts +6 -0
  127. package/src/neat/neat.objectives.ts +36 -63
  128. package/src/neat/neat.objectives.utils.ts +195 -0
  129. package/src/neat/neat.pruning.ts +79 -141
  130. package/src/neat/neat.pruning.utils.ts +375 -0
  131. package/src/neat/neat.selection.ts +53 -180
  132. package/src/neat/neat.selection.utils.ts +470 -0
  133. package/src/neat/neat.speciation.ts +108 -432
  134. package/src/neat/neat.speciation.utils.ts +926 -0
  135. package/src/neat/neat.species.ts +34 -73
  136. package/src/neat/neat.species.utils.ts +156 -0
  137. package/src/neat/neat.telemetry.buffer.utils.ts +58 -0
  138. package/src/neat/neat.telemetry.complexity.utils.ts +250 -0
  139. package/src/neat/neat.telemetry.diversity.utils.ts +214 -0
  140. package/src/neat/neat.telemetry.entropy.utils.ts +111 -0
  141. package/src/neat/neat.telemetry.exports.ts +205 -222
  142. package/src/neat/neat.telemetry.exports.utils.ts +428 -0
  143. package/src/neat/neat.telemetry.lineage.utils.ts +359 -0
  144. package/src/neat/neat.telemetry.objectives.utils.ts +216 -0
  145. package/src/neat/neat.telemetry.operator.utils.ts +20 -0
  146. package/src/neat/neat.telemetry.performance.utils.ts +30 -0
  147. package/src/neat/neat.telemetry.rng.utils.ts +22 -0
  148. package/src/neat/neat.telemetry.selection.utils.ts +108 -0
  149. package/src/neat/neat.telemetry.ts +351 -794
  150. package/src/neat/neat.telemetry.types.ts +51 -0
  151. package/src/neat/neat.telemetry.utils.ts +11 -0
  152. package/src/neat/neat.types.ts +582 -35
  153. package/src/neat.ts +142 -96
  154. package/src/utils/README.md +11 -26
  155. package/src/utils/memory.ts +143 -73
  156. package/srcLint.md +185 -0
  157. package/test/architecture/activationArrayPool.capacity.test.ts +15 -4
  158. package/test/architecture/activationArrayPool.test.ts +2 -2
  159. package/test/architecture/connection.test.ts +16 -5
  160. package/test/architecture/group.test.ts +51 -37
  161. package/test/architecture/layer.test.ts +173 -103
  162. package/test/architecture/node.test.ts +53 -47
  163. package/test/benchmarks/benchmark.browser.headless.test.ts +62 -23
  164. package/test/benchmarks/benchmark.buildVariants.test.ts +4 -4
  165. package/test/benchmarks/benchmark.fieldAudit.test.ts +26 -7
  166. package/test/benchmarks/benchmark.memory.test.ts +191 -78
  167. package/test/benchmarks/benchmark.nodePool.determinism.test.ts +9 -2
  168. package/test/benchmarks/benchmark.nodePool.memory.test.ts +9 -2
  169. package/test/benchmarks/benchmark.nodePool.removeRelease.test.ts +10 -2
  170. package/test/benchmarks/benchmark.nodePool.stress.test.ts +5 -4
  171. package/test/benchmarks/benchmark.report.test.ts +7 -7
  172. package/test/benchmarks/benchmark.serialization.gater.test.ts +56 -16
  173. package/test/benchmarks/benchmark.slab.fragmentation.bounds.test.ts +13 -4
  174. package/test/benchmarks/benchmark.slab.fragmentation.trend.test.ts +17 -7
  175. package/test/benchmarks/benchmark.variance.escalation.test.ts +12 -1
  176. package/test/benchmarks/benchmark.variance.test.ts +25 -4
  177. package/test/examples/asciiMaze/asciiMaze.e2e.test.ts +6 -85
  178. package/test/examples/asciiMaze/asciiMaze.ts +0 -10
  179. package/test/examples/asciiMaze/browser-entry.ts +115 -43
  180. package/test/examples/asciiMaze/browserLogger.ts +32 -19
  181. package/test/examples/asciiMaze/browserTerminalUtility.ts +1 -1
  182. package/test/examples/asciiMaze/dashboardManager.ts +311 -169
  183. package/test/examples/asciiMaze/evolutionEngine/engineState.ts +807 -0
  184. package/test/examples/asciiMaze/evolutionEngine/evolutionLoop.ts +1722 -0
  185. package/test/examples/asciiMaze/evolutionEngine/neatConfiguration.ts +309 -0
  186. package/test/examples/asciiMaze/evolutionEngine/networkInspection.ts +434 -0
  187. package/test/examples/asciiMaze/evolutionEngine/optionsAndSetup.ts +433 -0
  188. package/test/examples/asciiMaze/evolutionEngine/populationDynamics.ts +1696 -0
  189. package/test/examples/asciiMaze/evolutionEngine/populationPruning.ts +670 -0
  190. package/test/examples/asciiMaze/evolutionEngine/rngAndTiming.ts +145 -0
  191. package/test/examples/asciiMaze/evolutionEngine/sampling.ts +299 -0
  192. package/test/examples/asciiMaze/evolutionEngine/scratchPools.ts +445 -0
  193. package/test/examples/asciiMaze/evolutionEngine/setupHelpers.ts +283 -0
  194. package/test/examples/asciiMaze/evolutionEngine/telemetryMetrics.ts +1625 -0
  195. package/test/examples/asciiMaze/evolutionEngine/trainingWarmStart.ts +617 -0
  196. package/test/examples/asciiMaze/evolutionEngine.ts +383 -8432
  197. package/test/examples/asciiMaze/fitness.ts +7 -7
  198. package/test/examples/asciiMaze/interfaces.ts +454 -9
  199. package/test/examples/asciiMaze/mazeMovement.ts +166 -150
  200. package/test/examples/asciiMaze/mazeUtils.ts +30 -46
  201. package/test/examples/asciiMaze/mazeVision.ts +7 -7
  202. package/test/examples/asciiMaze/mazeVisualization.ts +54 -51
  203. package/test/examples/asciiMaze/mazes.ts +42 -63
  204. package/test/examples/asciiMaze/networkRefinement.ts +35 -24
  205. package/test/examples/asciiMaze/networkVisualization.ts +354 -178
  206. package/test/examples/asciiMaze/refineWinner.ts +4 -4
  207. package/test/examples/asciiMaze/terminalUtility.ts +1 -1
  208. package/test/methods/activation.test.ts +17 -78
  209. package/test/methods/connection.test.ts +4 -3
  210. package/test/methods/cost.test.ts +3 -3
  211. package/test/methods/crossover.test.ts +6 -2
  212. package/test/methods/gating.test.ts +9 -3
  213. package/test/methods/mutation.test.ts +11 -8
  214. package/test/methods/optimizers.advanced.test.ts +15 -7
  215. package/test/methods/optimizers.behavior.test.ts +25 -16
  216. package/test/methods/optimizers.formula.test.ts +68 -48
  217. package/test/methods/selection.test.ts +1 -1
  218. package/test/multithreading/activations.functions.test.ts +3 -2
  219. package/test/multithreading/multi.test.ts +56 -37
  220. package/test/multithreading/worker.node.process.test.ts +3 -3
  221. package/test/multithreading/workers.coverage.test.ts +21 -13
  222. package/test/neat/{neat.adaptive.ancestorUniq.cooldown.skip.test.ts → neat.adaptive.ancestorUniq.cooldown.test.ts} +16 -7
  223. package/test/neat/neat.adaptive.ancestorUniq.epsilon.test.ts +39 -10
  224. package/test/neat/neat.adaptive.ancestorUniq.lineagePressure.test.ts +39 -10
  225. package/test/neat/neat.adaptive.complexityBudget.connShrink.test.ts +7 -5
  226. package/test/neat/neat.adaptive.complexityBudget.growth.novelty.test.ts +7 -5
  227. package/test/neat/neat.adaptive.complexityBudget.minClamp.test.ts +3 -3
  228. package/test/neat/neat.adaptive.complexityBudget.test.ts +4 -2
  229. package/test/neat/neat.adaptive.complexityBudget.trend.test.ts +5 -7
  230. package/test/neat/neat.adaptive.criterion.complexity.test.ts +13 -8
  231. package/test/neat/neat.adaptive.minimalCriterion.rejection.test.ts +8 -4
  232. package/test/neat/neat.adaptive.mutation.amount.adapt.test.ts +12 -7
  233. package/test/neat/neat.adaptive.mutation.anneal.strategy.test.ts +9 -7
  234. package/test/neat/neat.adaptive.mutation.exploreLow.strategy.test.ts +9 -7
  235. package/test/neat/neat.adaptive.mutation.strategy.test.ts +12 -5
  236. package/test/neat/neat.adaptive.mutation.twotier.balance.test.ts +8 -4
  237. package/test/neat/neat.adaptive.mutation.twotier.fallback.single.test.ts +6 -4
  238. package/test/neat/neat.adaptive.operator.adaptation.decay.balance.test.ts +14 -11
  239. package/test/neat/neat.adaptive.operator.bandit.decay.test.ts +5 -5
  240. package/test/neat/neat.adaptive.operator.decay.test.ts +4 -2
  241. package/test/neat/neat.adaptive.phasedComplexity.test.ts +5 -3
  242. package/test/neat/neat.adaptive.phasedComplexity.toggle.test.ts +5 -5
  243. package/test/neat/neat.adaptive.pruning.test.ts +5 -2
  244. package/test/neat/neat.additional.coverage.test.ts +43 -23
  245. package/test/neat/neat.advanced.enhancements.test.ts +2 -2
  246. package/test/neat/neat.advanced.test.ts +36 -19
  247. package/test/neat/neat.compat.distance.cache.test.ts +21 -7
  248. package/test/neat/neat.diversity.autocompat.test.ts +13 -5
  249. package/test/neat/neat.diversity.metrics.test.ts +1 -0
  250. package/test/neat/neat.diversity.stats.test.ts +14 -15
  251. package/test/neat/neat.enhancements.test.ts +36 -23
  252. package/test/neat/neat.entropy.ancestorAdaptive.test.ts +54 -29
  253. package/test/neat/neat.entropy.compat.csv.test.ts +7 -11
  254. package/test/neat/neat.export.meta.fromjson.test.ts +3 -2
  255. package/test/neat/neat.export.state.rehydrate.test.ts +8 -7
  256. package/test/neat/neat.fastmode.autotune.test.ts +10 -6
  257. package/test/neat/neat.helpers.spawn.pool.test.ts +18 -12
  258. package/test/neat/neat.innovation.test.ts +123 -44
  259. package/test/neat/neat.lineage.antibreeding.test.ts +34 -16
  260. package/test/neat/neat.lineage.buildAnc.window.test.ts +15 -7
  261. package/test/neat/neat.lineage.entropy.test.ts +36 -24
  262. package/test/neat/neat.lineage.inbreeding.test.ts +51 -32
  263. package/test/neat/neat.lineage.pressure.test.ts +10 -4
  264. package/test/neat/neat.multiobjective.adaptive.test.ts +13 -9
  265. package/test/neat/neat.multiobjective.dynamic.schedule.test.ts +9 -10
  266. package/test/neat/neat.multiobjective.dynamic.test.ts +11 -4
  267. package/test/neat/neat.multiobjective.fastsort.delegation.test.ts +41 -26
  268. package/test/neat/neat.multiobjective.prune.test.ts +14 -8
  269. package/test/neat/neat.mutation.addconn.cycle.guard.test.ts +38 -21
  270. package/test/neat/neat.mutation.undefined.pool.test.ts +10 -4
  271. package/test/neat/neat.objectives.register.clear.test.ts +14 -6
  272. package/test/neat/neat.offspring.allocation.test.ts +1 -2
  273. package/test/neat/neat.operator.bandit.test.ts +1 -1
  274. package/test/neat/neat.operator.phases.test.ts +18 -6
  275. package/test/neat/neat.pruneInactive.behavior.test.ts +26 -11
  276. package/test/neat/neat.pruning.adaptive.test.ts +16 -5
  277. package/test/neat/neat.reenable.adaptation.test.ts +16 -10
  278. package/test/neat/neat.rng.state.test.ts +33 -15
  279. package/test/neat/neat.selection.strategies.test.ts +15 -11
  280. package/test/neat/neat.spawn.add.test.ts +68 -35
  281. package/test/neat/neat.speciation.age.penalty.test.ts +63 -33
  282. package/test/neat/neat.speciation.assign.existing.test.ts +64 -24
  283. package/test/neat/neat.speciation.auto.tuning.jitter.test.ts +78 -38
  284. package/test/neat/neat.speciation.create.newSpecies.test.ts +59 -25
  285. package/test/neat/neat.speciation.fitnessSharing.equal.test.ts +33 -5
  286. package/test/neat/neat.speciation.fitnessSharing.kernel.test.ts +33 -6
  287. package/test/neat/neat.speciation.pid.threshold.clip.max.test.ts +68 -29
  288. package/test/neat/neat.speciation.pid.threshold.clip.min.test.ts +68 -29
  289. package/test/neat/neat.speciation.stagnation.prune.test.ts +23 -9
  290. package/test/neat/neat.speciation.test.ts +2 -0
  291. package/test/neat/neat.species.history.fallbacks.test.ts +59 -14
  292. package/test/neat/neat.telemetry.advanced.test.ts +124 -64
  293. package/test/neat/neat.telemetry.csv.lineage.test.ts +12 -7
  294. package/test/neat/neat.telemetry.fastmode.diversity.test.ts +52 -9
  295. package/test/neat/neat.telemetry.objective.events.test.ts +64 -13
  296. package/test/neat/neat.telemetry.parity.test.ts +13 -7
  297. package/test/neat/neat.telemetry.select.entropy.cache.test.ts +37 -12
  298. package/test/neat/neat.telemetry.stream.test.ts +10 -2
  299. package/test/neat/neat.telemetry.test.ts +1 -1
  300. package/test/neat/neat.test.ts +62 -39
  301. package/test/neat/neat.utilities.test.ts +37 -19
  302. package/test/network/acyclic.topoorder.test.ts +4 -4
  303. package/test/network/checkpoint.metricshook.test.ts +6 -2
  304. package/test/network/error.handling.test.ts +99 -67
  305. package/test/network/evolution.test.ts +22 -19
  306. package/test/network/genetic.test.ts +40 -21
  307. package/test/network/learning.capability.test.ts +15 -7
  308. package/test/network/mutation.effects.test.ts +84 -64
  309. package/test/network/network.activate.test.ts +38 -12
  310. package/test/network/network.deterministic.test.ts +20 -5
  311. package/test/network/network.evolve.branches.test.ts +28 -20
  312. package/test/network/network.evolve.multithread.branches.test.ts +78 -56
  313. package/test/network/network.evolve.test.ts +47 -25
  314. package/test/network/network.gating.removal.test.ts +17 -12
  315. package/test/network/network.mutate.additional.test.ts +6 -5
  316. package/test/network/network.mutate.edgecases.test.ts +3 -1
  317. package/test/network/network.mutate.test.ts +4 -2
  318. package/test/network/network.prune.earlyexit.test.ts +39 -5
  319. package/test/network/network.pruning.test.ts +1 -1
  320. package/test/network/network.remove.errors.test.ts +6 -6
  321. package/test/network/network.slab.alloc.stats.reuse.test.ts +18 -8
  322. package/test/network/network.slab.async.test.ts +114 -42
  323. package/test/network/network.slab.capacity.test.ts +47 -37
  324. package/test/network/network.slab.fallbacks.test.ts +26 -6
  325. package/test/network/network.slab.fast.gain.parity.test.ts +29 -10
  326. package/test/network/network.slab.fast.gating.guard.test.ts +26 -11
  327. package/test/network/network.slab.fast.parity.test.ts +17 -9
  328. package/test/network/network.slab.flags.test.ts +26 -6
  329. package/test/network/network.slab.gain.omission.test.ts +29 -9
  330. package/test/network/network.slab.gain.release-on-reset.test.ts +33 -13
  331. package/test/network/network.slab.phase3.test.ts +24 -6
  332. package/test/network/network.slab.plasticity.test.ts +39 -13
  333. package/test/network/network.slab.versioning.test.ts +24 -4
  334. package/test/network/network.stats.test.ts +32 -7
  335. package/test/network/network.training.advanced.test.ts +45 -18
  336. package/test/network/network.training.basic.test.ts +128 -55
  337. package/test/network/network.training.helpers.test.ts +20 -17
  338. package/test/network/onnx.export.test.ts +170 -95
  339. package/test/network/onnx.recurrent.fused.test.ts +70 -54
  340. package/test/network/pruning.topology.test.ts +77 -36
  341. package/test/network/regularization.determinism.test.ts +19 -5
  342. package/test/network/regularization.dropconnect.validation.test.ts +2 -2
  343. package/test/network/regularization.stochasticdepth.test.ts +27 -12
  344. package/test/network/regularization.test.ts +94 -74
  345. package/test/network/regularization.weightnoise.test.ts +9 -4
  346. package/test/network/standalone.test.ts +27 -25
  347. package/test/network/structure.serialization.test.ts +160 -152
  348. package/test/onnx/onnx.conv.groundwork.test.ts +11 -7
  349. package/test/onnx/onnx.conv.infer.test.ts +8 -4
  350. package/test/onnx/onnx.conv.pool.flatten.test.ts +2 -2
  351. package/test/onnx/onnx.conv.pool.validation.test.ts +30 -20
  352. package/test/onnx/onnx.export.test.ts +53 -39
  353. package/test/onnx/onnx.import.test.ts +9 -5
  354. package/test/onnx/onnx.roundtrip.test.ts +3 -3
  355. package/test/training/training.determinism.mixed-precision.test.ts +7 -5
  356. package/test/training/training.earlystopping.test.ts +9 -9
  357. package/test/training/training.edge-cases.test.ts +24 -8
  358. package/test/training/training.extensions.test.ts +8 -7
  359. package/test/training/training.gradient.features.test.ts +7 -5
  360. package/test/training/training.gradient.refinements.test.ts +13 -5
  361. package/test/training/training.optimizer.test.ts +13 -2
  362. package/test/training/training.plateau.smoothing.test.ts +1 -1
  363. package/test/training/training.smoothing.types.test.ts +16 -12
  364. package/test/training/training.train.options.coverage.test.ts +1 -1
  365. package/test/utils/console-helper.ts +12 -8
  366. package/test/utils/jest-setup.ts +48 -33
  367. package/test/utils/pollUntil.test.ts +6 -6
  368. package/test/utils/pollUntil.ts +8 -8
  369. package/test/utils/test-helpers.ts +25 -20
  370. package/plans/ASCII_MAZE_enhancements.md +0 -0
@@ -4,6 +4,65 @@ Purpose
4
4
  -------
5
5
  When generating, modifying, or suggesting code that touches files under `src/` or `test/`, follow the project `STYLEGUIDE.md` rules and perform the quick validations listed below before returning suggestions.
6
6
 
7
+ **CRITICAL: Fix-first strategy for test failures**
8
+ ---------------------------------------------------
9
+ When asked to fix multiple test failures:
10
+
11
+ 1. **FOCUS on fixing ALL issues systematically BEFORE running tests**
12
+ - Create or update a comprehensive fix plan (e.g., `plans/TestsFix.md`)
13
+ - Categorize errors by type (TypeScript compilation, async/await, runtime logic)
14
+ - Prioritize: HIGH (compilation blockers) → MEDIUM (easy fixes) → LOW (investigation needed)
15
+ - Mark completed items with ✅ as you progress
16
+
17
+ 2. **DO NOT run tests or check test output during the fix phase**
18
+ - Avoid running `npm test`, `npm run test:silent`, or any test execution commands
19
+ - Do NOT run partial test checks like `Select-String -Pattern "●"` to see failures
20
+ - Do NOT attempt to run individual tests to "verify" fixes
21
+ - TypeScript compilation checks (`npx tsc --noEmit`) are acceptable to validate type fixes
22
+ - **REMEMBER**: You already have the test failure output - use it to guide your fixes
23
+
24
+ 3. **ONLY run full test suite AFTER all fixes are applied**
25
+ - Apply ALL planned fixes first (optimistically)
26
+ - Use `npm test` or `npm run test:silent` for final validation ONLY
27
+ - Analyze remaining failures and update the plan accordingly
28
+ - If you feel tempted to run a test, STOP and apply more fixes instead
29
+
30
+ 4. **Follow the plan strictly**
31
+ - Do not improvise or skip ahead
32
+ - Execute fixes in the documented priority order
33
+ - Update the plan with ✅ checkmarks and status notes as you complete each item
34
+ - Mark ALL items completed before running tests
35
+
36
+ **Why this matters:**
37
+ - Running tests interrupts the systematic fix workflow
38
+ - Test output during fixes causes distraction and context switching
39
+ - You already have all the error information needed to fix issues
40
+ - Optimistic fixing is faster than iterative test-fix-test cycles
41
+ - This strategy ensures thorough, complete fixes before validation
42
+
43
+ This strategy prevents distraction, maintains focus, and ensures systematic completion of all fixes before validation.
44
+
45
+
46
+ ES2023-first policy (strict)
47
+ ----------------------------
48
+ For educational clarity and a modern look, always prefer idiomatic ES2023 syntax when it improves readability or safety without changing behavior. This repo is intentionally opinionated: use the immutable array methods and modern language constructs by default.
49
+
50
+ Prefer (non-exhaustive):
51
+ - Arrays: `toSorted`, `toReversed`, `toSpliced`, `with`, `.at(-1)`, `findLast`, `findLastIndex`.
52
+ - Objects: spread/rest over `Object.assign` for shallow copies and merges.
53
+ - Optional chaining `?.` and nullish coalescing `??` (avoid `||` for defaulting unless you mean falsy semantics).
54
+ - Deep clone: `structuredClone` (or the project helper `safeStructuredClone` when cross-env safety is needed).
55
+ - Errors: `Error` with `{ cause }` (e.g., `new Error(msg, { cause })`).
56
+ - Numerics: numeric separators for long literals (for readability only, not to change values).
57
+ - Modules: ES modules `import`/`export` over CommonJS `require`/`module.exports` (follow the repo’s phase plan; new code should be ESM).
58
+
59
+ Avoid (legacy/less clear):
60
+ - In-place `sort`, `reverse`, `splice` in code paths that expect immutability; use the ES2023 immutable variants above.
61
+ - `Object.assign({}, obj)` or `Object.assign([], arr)` for cloning; use object/array spread.
62
+ - `JSON.parse(JSON.stringify(x))` for deep clone; use `structuredClone`/`safeStructuredClone`.
63
+ - Index math like `arr[arr.length - 1]`; prefer `arr.at(-1)` when readability benefits.
64
+ - CommonJS `require()` in new or refactored modules; prefer ESM.
65
+
7
66
  How to use these instructions
8
67
  -----------------------------
9
68
  - Always prefer to produce code that already satisfies the style guide.
@@ -26,6 +85,60 @@ Strict rules to enforce (apply to any suggestion touching `src/` or `test/`)
26
85
 
27
86
  6. Lookup tables and enums: prefer a single table/enum for small fixed mappings (for example direction deltas) and helper methods like `#opposite(direction)` rather than scattered arithmetic.
28
87
 
88
+ 7. Types: avoid `any` and `unknown` in `src/` and `test/`. Use precise types or `// eslint-disable-next-line @typescript-eslint/no-explicit-any` with a short justification comment.
89
+
90
+ 8. Local helper structure preference:
91
+ - For new or refactored functions that introduce internal helpers, order the function as:
92
+ 1) Local variables/constants at top
93
+ 2) Declarative logic (calls to helpers)
94
+ 3) Return (fold)
95
+ 4) Internal helper function declarations at the end of the parent function
96
+ - Helpers should be small and pure where practical, with step-level inline comments and JSDoc.
97
+
98
+ 9. Mandatory implementation pattern (always; keep cognitive complexity low):
99
+ - Applies to all new code and any modified/refactored code in `src/` and `test/`.
100
+ - Prefer a *declarative top-level flow* ("collect → transform → fold/return") over deeply nested control flow.
101
+ - Avoid ternary chains (especially nested) for multi-branch fallback logic; use named resolver helpers with early returns instead.
102
+ - When normalizing legacy/loose data, isolate type assertions/casting into a single helper and keep the rest strongly typed.
103
+ - Keep helpers after the fold, and give each helper a single responsibility (SOLID: SRP). If the logic reads like a decision tree, it likely wants 2–4 small helpers.
104
+
105
+ Example (ideal structure)
106
+ -------------------------
107
+ ```ts
108
+ export function exampleMethod(input: Input) {
109
+ const constants = /* ... */;
110
+ const locals = /* ... */;
111
+
112
+ if (/* guard */) return /* fold */;
113
+
114
+ const stepOne = helperOne(input, locals, constants);
115
+ const stepTwo = helperTwo(stepOne, locals, constants);
116
+ return helperThree(stepTwo, locals, constants);
117
+
118
+ /** @param value - Input. @returns Intermediate. */
119
+ function helperOne(value: Input, _locals: unknown, _constants: unknown): Intermediate {
120
+ // Step 1: ...
121
+ return /* ... */;
122
+ }
123
+
124
+ /** @param value - Intermediate. @returns Intermediate. */
125
+ function helperTwo(value: Intermediate, _locals: unknown, _constants: unknown): Intermediate {
126
+ // Step 1: ...
127
+ return /* ... */;
128
+ }
129
+
130
+ /** @param value - Intermediate. @returns Output. */
131
+ function helperThree(value: Intermediate, _locals: unknown, _constants: unknown): Output {
132
+ // Step 1: Fold/return.
133
+ return /* ... */;
134
+ }
135
+ }
136
+
137
+ type Input = unknown;
138
+ type Intermediate = unknown;
139
+ type Output = unknown;
140
+ ```
141
+
29
142
  Automated validations to run before finalizing a suggestion
30
143
  -------------------------------------------------------
31
144
  When you modify or create files under `src/` or `test/`, run (or advise running) these quick validations. If you cannot run them, still make sure your suggestion would pass them.
@@ -43,9 +156,9 @@ When you modify or create files under `src/` or `test/`, run (or advise running)
43
156
  Quick checks to run (recommended)
44
157
  --------------------------------
45
158
  - TypeScript: run `npm run build` and report pass/fail.
46
- - Short-id scan: flag uses of the short identifiers regex `\b(dx|dy|d|i|a|b|c|p|o|idx|cand|tries)\b` in changed files.
47
159
  - Tests heuristic: flag test files that contain more than one `expect(` occurrence (these should be split into multiple `it()` blocks).
48
160
  - JSDoc: for new exported symbols, ensure a JSDoc block with `@param`/`@returns` exists (or flag if missing).
161
+ - ES2023 modernization: flag legacy patterns and suggest modern equivalents (see below one-liners).
49
162
 
50
163
  PowerShell examples (local validation)
51
164
  -------------------------------------
@@ -54,23 +167,18 @@ When you modify or create files under `src/` or `test/`, run (or advise running)
54
167
  npx tsc --noEmit -p tsconfig.json
55
168
  ```
56
169
 
57
- Short-id scan:
58
- ```powershell
59
- Get-ChildItem -Path src,test -Recurse -Include *.ts,*.tsx | Select-String -Pattern '\b(dx|dy|d|i|a|b|c|p|o|idx|cand|tries)\b' -NotMatch '\b(i|j)\b' -List
60
- ```
61
-
62
- Test heuristic:
63
- ```powershell
64
- Get-ChildItem -Path test -Recurse -Include *.ts,*.tsx | ForEach-Object {
65
- $count = (Get-Content $_.FullName | Select-String 'expect\(' -AllMatches).Matches.Count
66
- if ($count -gt 1) { Write-Output "$($_.FullName): $count expects" }
67
- }
68
- ```
69
-
70
170
  What to include with a suggestion
71
171
  --------------------------------
72
172
  - A short validation summary (TypeScript: pass/fail, short-id matches: list or 0, test-expect heuristic: list or 0, JSDoc missing: list or 0).
173
+ - ES2023: list any flagged legacy patterns and the intended replacements (e.g., `Object.assign` -> spread, `arr[arr.length-1]` -> `arr.at(-1)`, `JSON.parse(JSON.stringify())` -> `structuredClone`).
73
174
  - If any issue can't be safely fixed automatically, include a TODO comment at the top of the changed file and a one-line explanation in the patch.
74
175
 
75
- - A runnable patch or new file content that follows the rules above.
176
+ Test failure workflow
177
+ ---------------------
178
+ When fixing multiple test failures:
179
+ 1. Create/update a comprehensive plan document (e.g., `plans/TestsFix.md`)
180
+ 2. Apply ALL fixes systematically without running tests
181
+ 3. Validate TypeScript compilation with `npx tsc --noEmit -p tsconfig.test.json`
182
+ 4. ONLY run `npm test` after all planned fixes are complete
183
+ 5. Analyze results and iterate on remaining issues
76
184
 
@@ -0,0 +1,12 @@
1
+ {
2
+ "singleQuote": true,
3
+ "parser": "typescript",
4
+ "overrides": [
5
+ {
6
+ "files": "*.ts",
7
+ "options": {
8
+ "parser": "typescript"
9
+ }
10
+ }
11
+ ]
12
+ }
@@ -68,5 +68,5 @@ function run(): BrowserBenchRecord[] {
68
68
  results: run(),
69
69
  };
70
70
 
71
- // eslint-disable-next-line no-console
71
+
72
72
  console.log('[NEATAPTIC_BROWSER_BENCH] ready');