@reicek/neataptic-ts 0.1.26 → 0.1.27

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 (123) hide show
  1. package/.github/agents/boundary-mapper.agent.md +13 -8
  2. package/.github/agents/docs-scout.agent.md +14 -9
  3. package/.github/agents/plan-scout.agent.md +11 -6
  4. package/.github/agents/solid-split.agent.md +33 -17
  5. package/.github/copilot-instructions.md +100 -88
  6. package/.github/skills/educational-docs/SKILL.md +90 -40
  7. package/.github/skills/educational-docs/assets/mermaid-diagram-playbook.md +141 -141
  8. package/.github/skills/educational-docs/assets/visual-style-guide.md +1 -1
  9. package/.github/skills/plan-alignment/SKILL.md +1 -1
  10. package/.github/skills/solid-split/SKILL.md +54 -35
  11. package/.github/skills/solid-split/assets/docs-checklist.md +1 -1
  12. package/.github/skills/solid-split/assets/split-plan-template.md +41 -12
  13. package/.github/skills/solid-split/assets/split-workflow-checklist.md +4 -1
  14. package/.github/skills/test-fix-workflow/SKILL.md +12 -7
  15. package/.github/skills/trace-analyzer-extension/SKILL.md +1 -1
  16. package/.github/skills/trace-analyzer-extension/assets/extension-checklist.md +1 -1
  17. package/.github/skills/trace-analyzer-extension/references/analyzer-extension-workflow.md +1 -1
  18. package/.github/skills/trace-audit-reporting/SKILL.md +1 -1
  19. package/.github/skills/trace-audit-reporting/assets/performance-report-template.md +1 -1
  20. package/.github/skills/trace-audit-reporting/references/trace-analysis-workflow.md +1 -1
  21. package/.github/skills/tracker-handoff/SKILL.md +53 -5
  22. package/package.json +1 -1
  23. package/plans/Flappy_Bird_Folder_Documentation_Pass.logs.md +42 -0
  24. package/plans/Flappy_Bird_Folder_Documentation_Pass.md +22 -104
  25. package/plans/README.md +6 -2
  26. package/plans/Roadmap.md +35 -31
  27. package/plans/analyze-trace-solid-split.logs.md +35 -0
  28. package/plans/analyze-trace-solid-split.plans.md +21 -52
  29. package/plans/architecture-solid-split.logs.md +44 -0
  30. package/plans/architecture-solid-split.plans.md +20 -653
  31. package/plans/asciiMaze-typescript-repair.logs.md +35 -0
  32. package/plans/asciiMaze-typescript-repair.plans.md +30 -36
  33. package/plans/generate-docs-solid-split.logs.md +36 -0
  34. package/plans/generate-docs-solid-split.plans.md +21 -73
  35. package/plans/methods-docs.logs.md +37 -0
  36. package/plans/methods-docs.plans.md +22 -183
  37. package/plans/methods-solid-split.logs.md +41 -0
  38. package/plans/methods-solid-split.plans.md +23 -65
  39. package/plans/neat-docs.logs.md +38 -0
  40. package/plans/neat-docs.plans.md +21 -63
  41. package/plans/neat-test-surface-repair.logs.md +38 -0
  42. package/plans/neat-test-surface-repair.plans.md +24 -24
  43. package/plans/readme-first-section-pass.logs.md +63 -0
  44. package/plans/readme-first-section-pass.plans.md +42 -0
  45. package/plans/render-docs-html-solid-split.logs.md +36 -0
  46. package/plans/render-docs-html-solid-split.plans.md +20 -54
  47. package/plans/src-no-explicit-any-cleanup.logs.md +39 -0
  48. package/plans/src-no-explicit-any-cleanup.plans.md +23 -161
  49. package/plans/utils-docs.logs.md +37 -0
  50. package/plans/utils-docs.plans.md +20 -35
  51. package/src/README.md +88 -22
  52. package/src/architecture/README.md +94 -17
  53. package/src/architecture/activationArrayPool/README.md +53 -0
  54. package/src/architecture/activationArrayPool/activationArrayPool.ts +53 -0
  55. package/src/architecture/layer/README.md +94 -5
  56. package/src/architecture/layer/layer.ts +94 -5
  57. package/src/architecture/network/README.md +85 -14
  58. package/src/architecture/network/activate/README.md +301 -213
  59. package/src/architecture/network/activate/docs.order.json +9 -0
  60. package/src/architecture/network/activate/network.activate.utils.ts +90 -0
  61. package/src/architecture/network/connect/README.md +80 -3
  62. package/src/architecture/network/connect/docs.order.json +9 -0
  63. package/src/architecture/network/connect/network.connect.utils.ts +79 -0
  64. package/src/architecture/network/deterministic/README.md +96 -12
  65. package/src/architecture/network/deterministic/docs.order.json +10 -0
  66. package/src/architecture/network/deterministic/network.deterministic.utils.ts +90 -0
  67. package/src/architecture/network/evolve/README.md +286 -228
  68. package/src/architecture/network/evolve/docs.order.json +11 -0
  69. package/src/architecture/network/evolve/network.evolve.utils.ts +59 -0
  70. package/src/architecture/network/gating/README.md +58 -16
  71. package/src/architecture/network/gating/docs.order.json +9 -0
  72. package/src/architecture/network/gating/network.gating.utils.ts +43 -0
  73. package/src/architecture/network/genetic/README.md +75 -36
  74. package/src/architecture/network/genetic/docs.order.json +10 -0
  75. package/src/architecture/network/genetic/network.genetic.utils.ts +53 -17
  76. package/src/architecture/network/network.ts +91 -46
  77. package/src/architecture/network/standalone/README.md +309 -285
  78. package/src/architecture/network/standalone/docs.order.json +13 -0
  79. package/src/architecture/network/standalone/network.standalone.utils.ts +51 -28
  80. package/src/architecture/network.ts +94 -17
  81. package/src/architecture/nodePool/README.md +53 -0
  82. package/src/architecture/nodePool/nodePool.ts +53 -0
  83. package/src/methods/README.md +80 -34
  84. package/src/methods/methods.ts +80 -34
  85. package/src/methods/mutation/README.md +39 -93
  86. package/src/methods/mutation/mutation.ts +58 -0
  87. package/src/multithreading/README.md +114 -14
  88. package/src/multithreading/docs.order.json +5 -0
  89. package/src/multithreading/multi.ts +103 -7
  90. package/src/multithreading/types.ts +6 -1
  91. package/src/multithreading/workers/README.md +72 -2
  92. package/src/multithreading/workers/browser/README.md +39 -0
  93. package/src/multithreading/workers/browser/testworker.ts +40 -0
  94. package/src/multithreading/workers/node/README.md +50 -11
  95. package/src/multithreading/workers/node/docs.order.json +4 -0
  96. package/src/multithreading/workers/node/testworker.ts +43 -3
  97. package/src/multithreading/workers/workers.ts +36 -1
  98. package/src/neat/README.md +230 -152
  99. package/src/neat/adaptive/core/README.md +99 -42
  100. package/src/neat/adaptive/core/adaptive.core.ts +71 -14
  101. package/src/neat/adaptive/core/docs.order.json +8 -0
  102. package/src/neat/docs.order.json +9 -0
  103. package/src/neat/lineage/README.md +118 -16
  104. package/src/neat/lineage/lineage.ts +115 -13
  105. package/src/neat/neat.defaults.constants.ts +91 -13
  106. package/src/neat.ts +86 -20
  107. package/src/utils/README.md +71 -21
  108. package/src/utils/memory.ts +69 -19
  109. package/test/examples/asciiMaze/browser-entry/README.md +81 -8
  110. package/test/examples/asciiMaze/browser-entry/browser-entry.ts +81 -8
  111. package/test/examples/asciiMaze/dashboardManager/README.md +68 -4
  112. package/test/examples/asciiMaze/dashboardManager/dashboardManager.ts +68 -4
  113. package/test/examples/asciiMaze/evolutionEngine/README.md +1259 -1174
  114. package/test/examples/asciiMaze/evolutionEngine/docs.order.json +10 -0
  115. package/test/examples/asciiMaze/evolutionEngine/evolutionEngine.types.ts +87 -0
  116. package/test/examples/asciiMaze/mazeMovement/README.md +81 -4
  117. package/test/examples/asciiMaze/mazeMovement/mazeMovement.ts +81 -4
  118. package/test/examples/flappy_bird/browser-entry/README.md +64 -21
  119. package/test/examples/flappy_bird/browser-entry/browser-entry.ts +64 -21
  120. package/test/examples/flappy_bird/flappy-evolution-worker/README.md +98 -10
  121. package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.ts +98 -10
  122. package/test/examples/flappy_bird/simulation-shared/README.md +88 -4
  123. package/test/examples/flappy_bird/simulation-shared/simulation-shared.types.ts +88 -4
@@ -4,172 +4,34 @@
4
4
 
5
5
  ## Scope
6
6
 
7
- - Eliminate remaining `@typescript-eslint/no-explicit-any` debt in `src/`.
8
- - Keep the cleanup aligned with the current folderized architecture instead of pre-split file lists.
9
- - Treat unrelated ESLint failures as out of scope unless a touched file requires a local fix to validate safely.
7
+ - Remove `@typescript-eslint/no-explicit-any` debt across `src/` and close the
8
+ remaining explicit-form `any` variants introduced by earlier refactors.
9
+ - Keep the cleanup behavior-preserving and validation-driven.
10
10
 
11
- ## Current state
11
+ ## Final state
12
12
 
13
- - The old root-level handoff note drifted after the architecture and NEAT refactors and is no longer a reliable file-by-file checklist.
14
- - A current raw source scan now finds 0 `any` tokens across `src/**/*.ts`.
15
- - The explicit-form follow-up scan for patterns such as `as any`, `Promise<any>`, `Array<any>`, `Map<any, ...>`, `: any`, and `{any[]}` also returns 0 matches across `src/**/*.ts`.
16
- - `src/architecture/nodePool.ts`, previously marked as the next target in the legacy note, now lints clean and is no longer the correct starting point.
17
- - A broad `npx eslint src` run now passes after the follow-up lint-hygiene cleanup removed stale unused imports and empty-interface wrappers that were outside the original explicit-any lane.
13
+ - The tracked `src/` explicit-`any` debt was eliminated and the baseline closed
14
+ at zero for the targeted forms in this lane.
15
+ - Root NEAT, evolve, adaptive, multiobjective, multithreading, and related
16
+ hotspots were brought into stronger typed form without reopening unrelated
17
+ behavior changes.
18
+ - No active backlog remains; this file is now a reopen point if explicit-`any`
19
+ debt returns.
18
20
 
19
- ## Coverage backlog
21
+ ## Audit summary
20
22
 
21
- ### [DONE] Legacy pre-split cleanup pass
23
+ - Validation used targeted ESLint runs and `npx tsc --noEmit -p tsconfig.json`
24
+ after durable batches.
25
+ - The lane closed on a green `npx eslint src` final pass.
22
26
 
23
- - The earlier cleanup covered `src/methods/`, `src/multithreading/`, and part of the pre-folderized architecture surface.
24
- - That historical pass is kept only as a coarse extent note because the old path-by-path checklist no longer matches the current tree.
27
+ ## Reopen conditions
25
28
 
26
- ### [DONE] Root `src/neat.ts` explicit-any removal pass
29
+ - Future refactors reintroduce explicit `any` or equivalent typed debt in
30
+ `src/`.
31
+ - Stronger typing regresses in the previously cleaned hotspot files.
32
+ - Lint or type baselines reopen because of source-surface drift.
27
33
 
28
- - Removed the file-wide `@typescript-eslint/no-explicit-any` escape hatch from `src/neat.ts`.
29
- - Replaced root-surface `any` usage with shared contracts for options, export/import payloads, RNG state, objective accessors, compatibility inputs, and helper `this` delegation.
30
- - `npx eslint src/neat.ts --rule "@typescript-eslint/no-explicit-any:error"` now passes.
31
- - `npx tsc --noEmit -p tsconfig.json` passes after the root facade cleanup.
34
+ ## Audit log
32
35
 
33
- ### [DONE] Root `src/neat.ts` polish follow-through
34
-
35
- - The root strict-typing pass briefly exposed a small boundary-polish detour in the NEAT entry surface.
36
- - That follow-through extracted the root compatibility alias shelf into `src/neat/neat.types.ts`, extracted the constructor-default shelf into `src/neat/neat.defaults.constants.ts`, exported constructor bootstrap contracts from `src/neat/init/neat.init.ts`, and centralized `buildEmptyDiversityStats()` in `src/neat/diversity/diversity.ts`.
37
- - The result kept `src/neat.ts` orchestration-first without creating a second active roadmap lane.
38
- - Documentation effects from that detour remain tracked in `plans/neat-docs.plans.md`; this tracker keeps only the compact structural note so the strict-typing lane stays self-contained.
39
-
40
- ### [DONE] `src/neat/evolve/objectives/evolve.objectives.utils.ts` cleanup pass
41
-
42
- - Removed the file-wide `@typescript-eslint/no-explicit-any` escape hatch from `src/neat/evolve/objectives/evolve.objectives.utils.ts`.
43
- - Replaced `any`-based objective, population, entropy-accessor, and cache-reset handling with the existing evolve contracts in `src/neat/evolve/evolve.types.ts`.
44
- - Kept the runtime behavior narrow by centralizing the entropy accessor as a typed local helper instead of widening the shared controller contract.
45
- - `npx eslint src/neat/evolve/objectives/evolve.objectives.utils.ts --rule "@typescript-eslint/no-explicit-any:error"` now passes.
46
- - `npx tsc --noEmit -p tsconfig.json` passes after the evolve-objectives cleanup.
47
-
48
- ### [DONE] `src/neat/evolve/population/evolve.population.utils.ts` cleanup pass
49
-
50
- - Removed the file-wide `@typescript-eslint/no-explicit-any` escape hatch from `src/neat/evolve/population/evolve.population.utils.ts`.
51
- - Replaced `any`-based species allocation, per-member score folding, remainder budgeting, and lineage bookkeeping with the existing evolve contracts in `src/neat/evolve/evolve.types.ts`.
52
- - Kept the runtime behavior intact by preserving the existing lineage-id fallback semantics (`?? 0`) where parent ids remain optional on the shared genome contract.
53
- - `npx eslint src/neat/evolve/population/evolve.population.utils.ts --rule "@typescript-eslint/no-explicit-any:error"` now passes.
54
- - `npx tsc --noEmit -p tsconfig.json` passes after the evolve-population cleanup.
55
-
56
- ### [DONE] `src/neat/evolve/adaptive/evolve.adaptive.utils.ts` cleanup pass
57
-
58
- - Removed the file-wide `@typescript-eslint/no-explicit-any` escape hatch from `src/neat/evolve/adaptive/evolve.adaptive.utils.ts`.
59
- - Replaced `any`-based option access, cache invalidation iteration, and re-enable counter resets with the existing evolve contracts in `src/neat/evolve/evolve.types.ts`.
60
- - Added the narrow per-genome re-enable counters to `GenomeWithMetadata` so the adaptive bridge can reuse the shared evolve runtime metadata instead of reintroducing local casts.
61
- - Normalized missing compatibility coefficients before auto-tuning updates so the helper no longer relies on `any` to hide optional-option gaps.
62
- - `npx eslint src/neat/evolve/adaptive/evolve.adaptive.utils.ts --rule "@typescript-eslint/no-explicit-any:error"` now passes.
63
- - `npx tsc --noEmit -p tsconfig.json` passes after the evolve-adaptive cleanup.
64
-
65
- ### [DONE] `src/neat/multiobjective/category/multiobjective.category.ts` cleanup pass
66
-
67
- - Removed the file-wide `@typescript-eslint/no-explicit-any` escape hatch from `src/neat/multiobjective/category/multiobjective.category.ts`.
68
- - Replaced `any`-based Pareto snapshot shaping, objective-vector extraction, and objective-removal filtering with the existing evolve genome and objective descriptor contracts.
69
- - Dropped the unnecessary `undefined as any` cache reset in favor of the native optional objective-list contract.
70
- - `npx eslint src/neat/multiobjective/category/multiobjective.category.ts --rule "@typescript-eslint/no-explicit-any:error"` now passes.
71
- - `npx tsc --noEmit -p tsconfig.json` passes after the multi-objective category cleanup.
72
-
73
- ### [DONE] `src/neat/evolve/speciation/evolve.speciation.utils.ts` cleanup pass
74
-
75
- - Removed the file-wide `@typescript-eslint/no-explicit-any` escape hatch from `src/neat/evolve/speciation/evolve.speciation.utils.ts`.
76
- - Replaced `any`-based node filtering and species-history snapshot shaping with narrow local node typing plus the shared evolve species contracts.
77
- - Aligned the minimal snapshot rows with `SpeciesHistoryRecord` by writing `bestScore` and `avgSharedFitness` instead of leaking ad hoc fields through `any`.
78
- - `npx eslint src/neat/evolve/speciation/evolve.speciation.utils.ts --rule "@typescript-eslint/no-explicit-any:error"` now passes.
79
- - `npx tsc --noEmit -p tsconfig.json` passes after the evolve-speciation cleanup.
80
-
81
- ### [DONE] `src/neat/evolve/runtime/evolve.runtime.utils.ts` cleanup pass
82
-
83
- - Removed the file-wide `@typescript-eslint/no-explicit-any` escape hatch from `src/neat/evolve/runtime/evolve.runtime.utils.ts`.
84
- - Replaced `any`-based timer access with one typed high-resolution timer resolver shared by both start-time and elapsed-time helpers.
85
- - Replaced the score-reset callback cast with direct `GenomeWithMetadata` inference across the live population.
86
- - `npx eslint src/neat/evolve/runtime/evolve.runtime.utils.ts --rule "@typescript-eslint/no-explicit-any:error"` now passes.
87
- - `npx tsc --noEmit -p tsconfig.json` passes after the evolve-runtime cleanup.
88
-
89
- ### [DONE] `src/neat/adaptive/adaptive.ts` contract-doc cleanup pass
90
-
91
- - Replaced the repeated JSDoc `@this {{ ... any ... }}` object literals in `src/neat/adaptive/adaptive.ts` with the existing `NeatLikeWithAdaptiveType` host contract.
92
- - Kept the change documentation-only: behavior and implementation types were already routed through the adaptive core contracts.
93
- - `npx eslint src/neat/adaptive/adaptive.ts --rule "@typescript-eslint/no-explicit-any:error"` now passes.
94
- - `npx tsc --noEmit -p tsconfig.json` passes after the adaptive-root cleanup.
95
-
96
- ### [DONE] `src/multithreading/multi.ts` worker-doc cleanup pass
97
-
98
- - Replaced stale `Promise<any>` JSDoc return annotations on the worker helpers with `Promise<TestWorkerConstructor>` to match the existing TypeScript signatures.
99
- - `npx eslint src/multithreading/multi.ts --rule "@typescript-eslint/no-explicit-any:error"` now passes.
100
- - `npx tsc --noEmit -p tsconfig.json` passes after the multithreading cleanup.
101
-
102
- ### [DONE] Root `src/neat.ts`, `src/neat/evolve/evolve.ts`, and network-chapter doc cleanup pass
103
-
104
- - Removed stale any-focused commentary from `src/neat/evolve/evolve.ts` now that the helper split carries the narrow runtime contracts.
105
- - Reworded the `_structuralEntropy` compatibility note in `src/neat.ts` so it no longer references loose `(controller as any)` test examples.
106
- - Updated network chapter examples and JSDoc in `src/architecture/network/network.ts` and `src/architecture/network/slab/network.slab.utils.ts` to use the typed public slab accessors instead of loose-cast examples.
107
- - `npx tsc --noEmit -p tsconfig.json` passes after the root/network documentation cleanup.
108
-
109
- ### [DONE] `src/architecture/network/stats/network.stats.utils.ts` doc cleanup pass
110
-
111
- - Removed the stale note describing the `_lastStats` bridge as "typed as any" and replaced it with wording that points at the existing `NetworkStatsProps` bridge.
112
- - `npx eslint src/architecture/network/stats/network.stats.utils.ts --rule "@typescript-eslint/no-explicit-any:error"` now passes.
113
- - `npx tsc --noEmit -p tsconfig.json` passes after the network-stats cleanup.
114
-
115
- ### [DONE] Repo-wide prose-only cleanup pass
116
-
117
- - Rewrote the remaining ordinary-English `any` phrases across the architecture, NEAT, mutation, telemetry, selection, objectives, and multithreading chapters so the raw `\bany\b` source scan is now clean.
118
- - Kept this pass documentation-only: comments, examples, and JSDoc were tightened without changing runtime behavior or widening contracts.
119
- - `grep_search` for raw `\bany\b` across `src/**/*.ts` now returns 0 matches.
120
- - `grep_search` for explicit forms such as `as any`, `Promise<any>`, `Array<any>`, `Map<any>`, `: any`, and `{any[]}` across `src/**/*.ts` now returns 0 matches.
121
- - `npx tsc --noEmit -p tsconfig.json` passes after the final prose-only sweep.
122
-
123
- ### [DONE] Broad `src` lint-hygiene follow-up
124
-
125
- - Removed stale unused imports from `src/architecture/network/network.ts`, `src/architecture/network/onnx/export/network.onnx.export.types.ts`, and `src/architecture/network/onnx/network.onnx.utils.types.ts`.
126
- - Replaced the empty facade interfaces in `src/neat/pruning/facade/pruning.facade.ts` and `src/neat/rng/facade/rng.facade.ts` with equivalent type aliases to satisfy `@typescript-eslint/no-empty-object-type`.
127
- - `npx eslint src` now passes after the follow-up cleanup.
128
- - `npx tsc --noEmit -p tsconfig.json` still passes after the lint-hygiene follow-up.
129
-
130
- ### [DONE] Current hotspots in the refactored tree
131
-
132
- - No remaining hotspots in `src/**/*.ts` for raw `any` tokens.
133
- - No remaining hotspots in `src/**/*.ts` for explicit-form `any` usage.
134
- - No remaining broad ESLint errors in `src/` after the unused-import and empty-interface follow-up.
135
-
136
- ### [PLANNED] Validation discipline
137
-
138
- - Validate touched files with targeted ESLint runs instead of treating the whole `src/` tree as a single pass/fail gate.
139
- - Run `npx tsc --noEmit -p tsconfig.json` after each durable batch.
140
- - Avoid broad test runs for this workstream unless a specific edit changes behavior rather than types.
141
-
142
- ## Immediate next steps
143
-
144
- 1. Treat this lane as complete unless future refactors reintroduce explicit-any debt into `src/`.
145
- 2. If later work reopens the lane, resume from current repo state and start with a fresh raw scan instead of replaying this completed tracker.
146
-
147
- ## Deferred questions
148
-
149
- - Decide later whether some remaining `any` usage is genuinely architectural and should be documented with narrowly scoped eslint suppression instead of erased mechanically.
150
- - If the broader ES2023 modernization pass introduces lint enforcement changes, keep this tracker aligned with the final lint gate instead of duplicating policy here.
151
-
152
- ## Handoff query
153
-
154
- ```text
155
- Continue from the current repo state only. Do not rely on prior chat history.
156
- Current repo state:
157
- - The root `src/neat.ts` pass is complete.
158
- - The root surface-polish follow-through from that pass has been compressed into this tracker; there is no separate active plan for it.
159
- - `src/neat/evolve/objectives/evolve.objectives.utils.ts` is now clean for `@typescript-eslint/no-explicit-any`.
160
- - `src/neat/evolve/population/evolve.population.utils.ts` is now clean for `@typescript-eslint/no-explicit-any`.
161
- - `src/neat/evolve/adaptive/evolve.adaptive.utils.ts` is now clean for `@typescript-eslint/no-explicit-any`.
162
- - `src/neat/multiobjective/category/multiobjective.category.ts` is now clean for `@typescript-eslint/no-explicit-any`.
163
- - `src/neat/evolve/speciation/evolve.speciation.utils.ts` is now clean for `@typescript-eslint/no-explicit-any`.
164
- - `src/neat/evolve/runtime/evolve.runtime.utils.ts` is now clean for `@typescript-eslint/no-explicit-any`.
165
- - `src/neat/adaptive/adaptive.ts` is now clean for explicit-form `any` usage.
166
- - `src/multithreading/multi.ts` is now clean for explicit-form `any` usage.
167
- - `src/architecture/network/stats/network.stats.utils.ts` is now clean for explicit-form `any` usage.
168
- - The raw `any` baseline is down to 0.
169
- - The explicit-form scan for `as any`, `Promise<any>`, `Array<any>`, `Map<any>`, `: any`, and `{any[]}` is also at 0.
170
- - `npx eslint src` passes.
171
-
172
- Next target:
173
- - No active target in this lane. Reopen only if future edits reintroduce explicit-any debt or new broad lint drift into `src/`.
174
- - If reopened, begin with a fresh raw scan, `npx eslint src`, and `npx tsc --noEmit -p tsconfig.json` before selecting a new target.
175
- ```
36
+ - Durable completion notes now live in
37
+ [src-no-explicit-any-cleanup.logs.md](src-no-explicit-any-cleanup.logs.md).
@@ -0,0 +1,37 @@
1
+ # Utils Docs Plan Log
2
+
3
+ **Status:** [DONE]
4
+
5
+ ## Audit scope
6
+
7
+ - Objective: improve the generated utility chapter openings, especially around
8
+ memory heuristics and snapshot-layer mechanics, while keeping the lane
9
+ behavior-neutral.
10
+
11
+ ## Durable milestones
12
+
13
+ ### [DONE] Utility opening upgrades
14
+
15
+ - Strengthened the `src/utils/memory.ts` and `src/utils/memory.utils.ts`
16
+ openings so they explain heuristic rationale and aggregation behavior more
17
+ clearly.
18
+
19
+ ### [DONE] Diagram support in utility chapters
20
+
21
+ - Added Mermaid-backed visuals where they improved the explanation of snapshot
22
+ layers and memory behavior.
23
+
24
+ ### [DONE] Docs generation unblock
25
+
26
+ - Fixed a pre-existing Mermaid rendering failure outside the utility modules so
27
+ global docs generation could complete reliably again.
28
+
29
+ ## Controls and evidence
30
+
31
+ - Validation used `npm run docs` and `npx tsc --noEmit -p tsconfig.json`.
32
+ - The pass did not require runtime behavior changes.
33
+
34
+ ## Reopen triggers
35
+
36
+ - Utility chapter openings drift or new utility surfaces are added.
37
+ - Mermaid or generator behavior causes docs regression in this lane.
@@ -4,46 +4,31 @@
4
4
 
5
5
  ## Scope
6
6
 
7
- This plan tracks educational-docs passes for the small shared utility surfaces
8
- under [src/utils/README.md](../src/utils/README.md).
7
+ - Educational-docs pass for the shared utility chapters under `src/utils/`.
8
+ - Raise the generated utility openings without changing runtime behavior.
9
9
 
10
- Primary reader:
10
+ ## Final state
11
11
 
12
- - readers who want to understand support utilities as teaching tools rather
13
- than as unframed implementation leftovers.
12
+ - The utility chapter openings now explain memory heuristics and snapshot
13
+ layering more clearly instead of reading as implementation shelves.
14
+ - Mermaid-supported diagrams are part of the generated utility documentation
15
+ path where they materially improve comprehension.
16
+ - No active backlog remains; this plan is now a reopen point for future utility
17
+ documentation drift.
14
18
 
15
- Primary surfaces:
19
+ ## Audit summary
16
20
 
17
- - [src/utils/memory.ts](../src/utils/memory.ts)
18
- - [src/utils/memory.utils.ts](../src/utils/memory.utils.ts)
19
- - [src/utils/README.md](../src/utils/README.md)
21
+ - Documentation updates were validated with `npm run docs` and
22
+ `npx tsc --noEmit -p tsconfig.json`.
23
+ - A pre-existing Mermaid rendering issue in another docs surface was also fixed
24
+ during this lane to keep global docs generation healthy.
20
25
 
21
- ## Session Log
26
+ ## Reopen conditions
22
27
 
23
- ### Latest completed chapter work
28
+ - New utility modules are added under `src/utils/`.
29
+ - Utility README openings drift below the current documentation bar.
30
+ - Mermaid or generated-doc ownership regressions reappear.
24
31
 
25
- - Strengthened the root [src/utils/memory.ts](../src/utils/memory.ts) opening so
26
- the generated [src/utils/README.md](../src/utils/README.md) now explains why
27
- heuristic memory instrumentation exists, which questions it answers, and how
28
- to read the snapshot in layers.
29
- - Added a real module introduction to
30
- [src/utils/memory.utils.ts](../src/utils/memory.utils.ts) so the helper file
31
- reads as aggregation and snapshot mechanics rather than a flat export shelf.
32
- - Added Mermaid teaching diagrams to both module openings.
33
- - Regenerated docs and re-ran `npx tsc --noEmit -p tsconfig.json` successfully.
34
- - Fixed an existing Mermaid rendering failure in
35
- [src/neat/init/neat.init.ts](../src/neat/init/neat.init.ts) that had been
36
- blocking global docs generation.
32
+ ## Audit log
37
33
 
38
- Remaining gaps:
39
-
40
- - The `src/utils` folder is now small and reasonably aligned; future work here
41
- is more likely to be refinement than rescue.
42
- - If additional utility modules are added later, keep this plan focused on
43
- chapter quality instead of growing a long historical log.
44
-
45
- Next step:
46
-
47
- - Move to the next small cross-cutting folder that still reads more like a
48
- helper shelf than a chapter, using [src/utils/README.md](../src/utils/README.md)
49
- as the quality bar for support modules.
34
+ - Durable completion notes now live in [utils-docs.logs.md](utils-docs.logs.md).
package/src/README.md CHANGED
@@ -2,34 +2,100 @@
2
2
 
3
3
  Root orchestration surface for NeuroEvolution of Augmenting Topologies (NEAT) in NeatapticTS.
4
4
 
5
- Within the broader `src` surface, this file is the public chapter map for the
6
- library's evolutionary controller.
7
- The heavy algorithmic work lives in focused `src/neat/**` modules, but this
8
- root surface keeps the user-facing workflow readable: configure a population,
9
- evaluate genomes, evolve the next generation, inspect telemetry, and persist
10
- the state when a run becomes worth keeping.
11
-
12
- What this file covers:
13
- - the high-level lifecycle of a NEAT run,
14
- - the default knobs that shape population growth and speciation,
15
- - reproducibility helpers such as seeded RNG snapshots and state export,
16
- - educational inspection hooks for telemetry, species history, diversity, and Pareto fronts.
17
-
18
- What you can learn here:
19
- - how the top-level controller stays orchestration-first even after the internal SOLID split,
20
- - which public methods belong to setup, evolution, diagnostics, and persistence,
21
- - which subsystem README to open next when you want the underlying mechanics.
5
+ This root chapter is the public control desk for the library. The
6
+ architecture surfaces explain what a network graph is. The `src/neat/**`
7
+ chapters explain how evaluation, reproduction, speciation, telemetry, and
8
+ persistence work in detail. This file sits between those two layers and
9
+ answers the first practical reader question: how do I run one evolutionary
10
+ experiment without learning every subsystem in the same breath?
11
+
12
+ That boundary matters because a useful NEAT run is more than "mutate a
13
+ network." A controller has to keep a population alive, protect enough
14
+ diversity to avoid early collapse, score genomes fairly, record what
15
+ happened, and give the caller a deterministic way to pause or resume the
16
+ search. The root surface is where those responsibilities become one readable
17
+ workflow instead of a pile of helper calls.
18
+
19
+ One helpful mental model is to read the controller as four shelves. The setup
20
+ shelf decides population size, defaults, and reproducibility. The search
21
+ shelf drives `evaluate()`, `evolve()`, and the public mutation hooks. The
22
+ observability shelf exposes telemetry, lineage, diversity, species, and
23
+ Pareto views. The persistence shelf turns a live run into replayable state
24
+ through `toJSON()`, `exportState()`, and RNG snapshots.
25
+
26
+ The chapter also exists to keep the public class orchestration-first after
27
+ the internal split. `src/neat/**` now owns the heavier policy chapters:
28
+ `evaluate/` scores genomes, `evolve/` creates the next generation,
29
+ `speciation/` manages compatibility pressure, `telemetry/` records what the
30
+ run did, and `export/` plus `rng/` keep experiments reproducible. If you can
31
+ read the root workflow first, the subchapters become "why does this step
32
+ work?" reads instead of "where do I even start?" reads.
33
+
34
+ The guiding historical idea comes from Stanley and Miikkulainen's NEAT
35
+ paper: evolve both weights and topology while protecting innovation long
36
+ enough for new structures to prove useful. See Stanley and Miikkulainen,
37
+ [Evolving Neural Networks through Augmenting Topologies](https://nn.cs.utexas.edu/?stanley:ec02),
38
+ for the compact background behind the controller vocabulary that appears all
39
+ through this surface.
40
+
41
+ Read this root when you want to answer one of three questions quickly: how to
42
+ start a run, how to move it forward generation by generation, or how to
43
+ inspect and persist it without diving into every implementation chapter. Read
44
+ the narrower `src/neat/**` READMEs when the next question becomes about one
45
+ specific policy family rather than the whole experiment loop.
22
46
 
23
47
  ```mermaid
24
48
  flowchart LR
25
- Configure["Configure run<br/>sizes + fitness + options"] --> Seed["Seed or restore<br/>constructor / createPool / import"]
26
- Seed --> Score["Score population<br/>evaluate()"]
27
- Score --> Breed["Breed next generation<br/>evolve() / mutate()"]
28
- Breed --> Observe["Observe search pressure<br/>telemetry / species / diversity / Pareto"]
29
- Observe --> Persist["Persist or replay<br/>exportState() / toJSON() / RNG state"]
49
+ classDef base fill:#08131f,stroke:#1ea7ff,color:#dff6ff,stroke-width:1px;
50
+ classDef accent fill:#0f2233,stroke:#ffd166,color:#fff4cc,stroke-width:1.5px;
51
+
52
+ Configure["Configure run<br/>sizes + fitness + options"]:::accent --> Seed["Seed or restore<br/>constructor / createPool / import"]:::base
53
+ Seed --> Score["Score population<br/>evaluate()"]:::base
54
+ Score --> Breed["Breed next generation<br/>evolve() / mutate()"]:::accent
55
+ Breed --> Observe["Observe pressure<br/>telemetry / species / diversity / Pareto"]:::base
56
+ Observe --> Persist["Persist or replay<br/>exportState() / toJSON() / RNG state"]:::base
30
57
  Breed --> Score
31
58
  ```
32
59
 
60
+ ```mermaid
61
+ flowchart TD
62
+ classDef base fill:#08131f,stroke:#1ea7ff,color:#dff6ff,stroke-width:1px;
63
+ classDef accent fill:#0f2233,stroke:#ffd166,color:#fff4cc,stroke-width:1.5px;
64
+
65
+ Root["src root controller"]:::accent --> Setup["Defaults and initialization<br/>constructor / createPool / import"]:::base
66
+ Root --> Search["Search loop<br/>evaluate / evolve / mutate"]:::base
67
+ Root --> Observe["Diagnostics<br/>telemetry / species / lineage / Pareto"]:::base
68
+ Root --> Replay["Persistence<br/>toJSON / exportState / RNG"]:::base
69
+ Search --> Chapters["Detailed policy chapters<br/>src/neat/**"]:::base
70
+ ```
71
+
72
+ Example: start a small deterministic run and inspect the best score after one
73
+ generation.
74
+
75
+ ```ts
76
+ const neat = new Neat(2, 1, fitness, {
77
+ popsize: 50,
78
+ seed: 7,
79
+ fastMode: true,
80
+ });
81
+
82
+ await neat.evaluate();
83
+ const bestGenome = await neat.evolve();
84
+
85
+ console.log(bestGenome.score);
86
+ ```
87
+
88
+ Example: capture telemetry and a replayable snapshot after the current run
89
+ step.
90
+
91
+ ```ts
92
+ const latestTelemetry = neat.getTelemetry().at(-1);
93
+ const exportedState = neat.exportState();
94
+
95
+ console.log(latestTelemetry?.generation);
96
+ console.log(exportedState.neat.generation);
97
+ ```
98
+
33
99
  Recommended reading after this root chapter:
34
100
  - `./neat/evaluate/README.md` for scoring flow and objective handling
35
101
  - `./neat/evolve/README.md` for reproduction orchestration
@@ -2,20 +2,97 @@
2
2
 
3
3
  Architecture root chapter map and compatibility surface.
4
4
 
5
- This folder gathers the core runtime building blocks that most NeatapticTS
6
- networks are composed from: `Network` orchestration, `Node` and
7
- `Connection` graph primitives, `Group` and `Layer` composition helpers,
8
- `Architect` presets, and the shared allocation pools that keep hot paths
9
- leaner during training and inference.
10
-
11
- How to read this chapter:
12
- - Start here for the high-level map of the architecture package.
13
- - Continue into `network/` for the main orchestration surface and its
14
- runtime, training, mutation, serialization, and ONNX subchapters.
15
- - Continue into `node/`, `connection/`, `group/`, and `layer/` for the graph
16
- building blocks.
17
- - Continue into `architect/` for preset builders and into `nodePool/` and
18
- `activationArrayPool/` for allocation-oriented helpers.
19
- - Treat the flat `src/architecture/*.ts` files as compatibility facades that
20
- keep public imports stable while the implementation lives in narrower,
21
- teachable chapters.
5
+ This root answers the first structural question behind the whole library:
6
+ what are the durable building blocks a NeatapticTS network is made from
7
+ before NEAT, training, workers, or ONNX translation start adding policy
8
+ around it? The answer is a small graph vocabulary. Nodes and connections hold
9
+ local signal semantics. Groups and layers organize repeated structure.
10
+ `Network` orchestrates the whole graph. `Architect` offers common presets.
11
+ The pool chapters keep allocation-heavy hot paths from turning runtime work
12
+ into needless object churn.
13
+
14
+ Read this folder as a map between two kinds of knowledge. One kind is graph
15
+ anatomy: what a node, connection, group, or layer means. The other kind is
16
+ graph orchestration: how those parts become a runnable, mutable, trainable,
17
+ serializable network. The architecture root exists so a reader can see both
18
+ at once before diving into the heavier subchapters.
19
+
20
+ That boundary matters because the rest of the repo reuses architecture in
21
+ several different ways. The NEAT controller mutates and evaluates graphs.
22
+ The methods chapter defines reusable activation and structural vocabulary.
23
+ Browser examples step and visualize networks. ONNX import and export
24
+ translate networks across ecosystems. If the architecture layer is unclear,
25
+ everything above it feels like policy without a substrate. This root chapter
26
+ makes the substrate legible first.
27
+
28
+ One helpful mental model is to split the folder into four shelves: graph
29
+ primitives (`node`, `connection`), composition helpers (`group`, `layer`,
30
+ `architect`), orchestration (`network`), and runtime-efficiency helpers
31
+ (`nodePool`, `activationArrayPool`). The flat `src/architecture/*.ts` files
32
+ are compatibility facades that keep imports stable while the real ownership
33
+ and longer explanations live in the chaptered subfolders.
34
+
35
+ ```mermaid
36
+ flowchart TD
37
+ classDef base fill:#08131f,stroke:#1ea7ff,color:#dff6ff,stroke-width:1px;
38
+ classDef accent fill:#0f2233,stroke:#ffd166,color:#fff4cc,stroke-width:1.5px;
39
+
40
+ Architecture[architecture root]:::accent --> Primitives[Node and Connection<br/>graph primitives]:::base
41
+ Architecture --> Composition[Group Layer Architect<br/>composition helpers]:::base
42
+ Architecture --> Orchestration[Network<br/>runtime orchestration]:::base
43
+ Architecture --> Pools[NodePool and ActivationArrayPool<br/>allocation helpers]:::base
44
+ ```
45
+
46
+ The second useful lens is ownership versus compatibility. This root folder
47
+ intentionally still exposes flat compatibility files because public imports,
48
+ tests, and examples rely on them. But those files are no longer the best
49
+ place to learn the subsystem. They are the stable front desk. The chaptered
50
+ subfolders are where the real guided tour now lives.
51
+
52
+ ```mermaid
53
+ flowchart LR
54
+ classDef base fill:#08131f,stroke:#1ea7ff,color:#dff6ff,stroke-width:1px;
55
+ classDef accent fill:#0f2233,stroke:#ffd166,color:#fff4cc,stroke-width:1.5px;
56
+
57
+ Caller[Caller import]:::base --> Facade[Flat compatibility facade]:::accent
58
+ Facade --> Chapter[Chapter-owned implementation folder]:::base
59
+ Chapter --> Details[Runtime training mutation serialize ONNX details]:::base
60
+ ```
61
+
62
+ For background reading, the most relevant mathematical ideas are the directed
63
+ graph itself and the ordering questions that appear once a graph has to be
64
+ executed. See Wikipedia contributors,
65
+ [Directed graph](https://en.wikipedia.org/wiki/Directed_graph), and
66
+ Wikipedia contributors,
67
+ [Topological sorting](https://en.wikipedia.org/wiki/Topological_sorting),
68
+ for compact background on the graph and scheduling ideas that sit underneath
69
+ this chapter's public surface.
70
+
71
+ Example: start from a preset builder when you want architecture first and
72
+ wiring details second.
73
+
74
+ ```ts
75
+ const perceptron = new Architect.Perceptron(2, 3, 1);
76
+ const outputValues = perceptron.activate([0, 1]);
77
+ ```
78
+
79
+ Example: start from `Network` when you want the orchestration surface and
80
+ plan to inspect or mutate the graph more directly.
81
+
82
+ ```ts
83
+ const network = new Network(2, 1);
84
+ const outputValues = network.activate([0, 1]);
85
+ ```
86
+
87
+ Practical reading order:
88
+
89
+ 1. Start here for the high-level map of the architecture package.
90
+ 2. Continue into `network/` for the main orchestration surface and its
91
+ runtime, training, mutation, serialization, and ONNX subchapters.
92
+ 3. Continue into `node/`, `connection/`, `group/`, and `layer/` for the
93
+ graph building blocks.
94
+ 4. Continue into `architect/` for preset builders and into `nodePool/` and
95
+ `activationArrayPool/` for allocation-oriented helpers.
96
+ 5. Treat the flat `src/architecture/*.ts` files as compatibility facades that
97
+ keep public imports stable while the implementation lives in narrower,
98
+ teachable chapters.
@@ -7,6 +7,43 @@ activation paths. It sits beside the network and layer chapters because the
7
7
  pool is not a new runtime primitive; it is the memory policy that decides
8
8
  when temporary activation storage should be reused instead of reallocated.
9
9
 
10
+ Think of this boundary as scratch-space policy for activation-heavy code.
11
+ Network execution repeatedly asks for short-lived arrays whose shapes often
12
+ repeat from sample to sample. Reallocating those arrays every pass adds
13
+ garbage-collector work without changing the model's behavior. This chapter
14
+ keeps the reusable buffer story explicit while leaving graph semantics to
15
+ the node, layer, and network chapters.
16
+
17
+ The key design choice is that pooling happens by array length, not by caller
18
+ identity. A network slab path and a layer helper can share the same retained
19
+ storage as long as they request the same length and release the buffer after
20
+ use. Acquire always returns a zeroed buffer, so the pool promises clean
21
+ scratch memory rather than cached activations or memoized results.
22
+
23
+ That distinction matters when you are debugging correctness. This folder is
24
+ not a semantic cache and it does not preserve intermediate values for later
25
+ reads. It only keeps array shells alive long enough to reduce allocation
26
+ churn in hot loops, worker batches, and repeated forward passes.
27
+
28
+ ```mermaid
29
+ flowchart LR
30
+ classDef base fill:#08131f,stroke:#1ea7ff,color:#dff6ff,stroke-width:1px;
31
+ classDef accent fill:#0f2233,stroke:#ffd166,color:#fff4cc,stroke-width:1.5px;
32
+
33
+ Request[Activation request]:::base --> Acquire[acquire by length]:::accent
34
+ Acquire -->|bucket hit| Reuse[Zeroed reused buffer]:::base
35
+ Acquire -->|bucket miss| Fresh[Freshly allocated buffer]:::base
36
+ Reuse --> Execute[Layer or network activation]:::base
37
+ Fresh --> Execute
38
+ Execute --> Release[release buffer]:::accent
39
+ Release --> Bucket[Length bucket]:::base
40
+ ```
41
+
42
+ For background on the broader software pattern, see Wikipedia contributors,
43
+ [Object pool pattern](https://en.wikipedia.org/wiki/Object_pool_pattern).
44
+ This chapter applies that idea to activation scratch space, not to long-lived
45
+ model parameters.
46
+
10
47
  Read this chapter in three passes:
11
48
 
12
49
  1. start with `ActivationArray` to see which buffer shapes the runtime can
@@ -16,6 +53,22 @@ Read this chapter in three passes:
16
53
  3. finish with `stats()`, `setMaxPerBucket()`, and `prewarm()` when you want
17
54
  observability and capacity control.
18
55
 
56
+ Example: reuse one scratch buffer around a custom activation-heavy loop.
57
+
58
+ ```ts
59
+ const activationArray = activationArrayPool.acquire(128);
60
+ // fill and consume the buffer here
61
+ activationArrayPool.release(activationArray);
62
+ ```
63
+
64
+ Example: prewarm one common bucket before a large evaluation batch.
65
+
66
+ ```ts
67
+ activationArrayPool.setMaxPerBucket(32);
68
+ activationArrayPool.prewarm(256, 8);
69
+ const stats = activationArrayPool.stats();
70
+ ```
71
+
19
72
  ## architecture/activationArrayPool/activationArrayPool.ts
20
73
 
21
74
  ### ActivationArray