@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
@@ -6,16 +6,104 @@
6
6
  * hot path: evolving generations, materializing playback state, advancing the
7
7
  * simulation, and packaging compact snapshots back to the host.
8
8
  *
9
- * Read this file as the worker chapter's public spine. It is not the place for
10
- * low-level simulation math or message-shape detail. Instead it shows how the
11
- * worker turns a small typed protocol into one long-lived deterministic runtime.
12
- *
13
- * Protocol flow at a glance:
14
- * 1. `init` seeds deterministic worker state and creates the NEAT runtime.
15
- * 2. `request-generation` evolves one generation and posts a summary message.
16
- * 3. `start-playback` materializes worker-local simulation state.
17
- * 4. `request-playback-step` advances playback and streams packed snapshots.
18
- * 5. `stop` marks the worker as cooperatively stopped.
9
+ * That separation is doing two jobs at once. It protects the browser from
10
+ * heavy simulation work, and it turns responsibility into something a reader
11
+ * can see directly because every cross-thread handoff must become an explicit
12
+ * typed message.
13
+ *
14
+ * Read this folder as the protocol chapter between the browser host and the
15
+ * deterministic runtime that actually evolves and replays the flock. The
16
+ * important design question is not merely "how do Web Workers run code?" It is
17
+ * "which side should own each piece of truth when evolution, playback, and
18
+ * inspection all need the same population?"
19
+ *
20
+ * In this example, the answer is deliberate:
21
+ *
22
+ * - the host owns controls, HUD state, and network visualization,
23
+ * - the worker owns generation requests, playback stepping, and winner
24
+ * selection,
25
+ * - packed snapshots are the narrow bridge between those two worlds.
26
+ *
27
+ * ## What This Folder Is Trying To Teach
28
+ *
29
+ * The worker chapter is organized around four reader questions:
30
+ *
31
+ * 1. How does the browser request evolution work without becoming the
32
+ * simulation authority?
33
+ * 2. How does one evolved population become a replayable playback session?
34
+ * 3. Why are snapshots packed into typed arrays instead of posted as nested
35
+ * render objects?
36
+ * 4. Where should you read next when the protocol is clear but one runtime step
37
+ * still feels opaque?
38
+ *
39
+ * ## Core Worker Map
40
+ *
41
+ * ```mermaid
42
+ * flowchart LR
43
+ * Host["browser-entry/\nhost UI and controls"] --> Protocol["protocol service\nlegal message transitions"]
44
+ * Protocol --> Runtime["runtime service\nworker-local NEAT controller"]
45
+ * Runtime --> Evolution["evolution service\nadvance one generation"]
46
+ * Runtime --> Playback["playback service\nmaterialize and step population"]
47
+ * Playback --> Snapshot["snapshot utils\npacked typed-array transport"]
48
+ * Snapshot --> Host
49
+ *
50
+ * WarmStart["warm-start service\ngeneration zero bootstrap"] -.-> Evolution
51
+ * Types["worker types\nmessage and DTO contracts"] -.-> Protocol
52
+ *
53
+ * classDef boundary fill:#001522,stroke:#0fb5ff,color:#9fdcff,stroke-width:2px;
54
+ * classDef runtime fill:#03111f,stroke:#00e5ff,color:#d8f6ff,stroke-width:2px;
55
+ * classDef highlight fill:#2a1029,stroke:#ff4a8d,color:#ffd7e8,stroke-width:3px;
56
+ *
57
+ * class Host,Protocol,Types boundary;
58
+ * class Runtime,Evolution,Playback,Snapshot runtime;
59
+ * class Snapshot highlight;
60
+ * ```
61
+ *
62
+ * Read the diagram left to right. The host is allowed to request work, but it
63
+ * never takes ownership of the worker's mutable simulation state. The worker
64
+ * can then optimize for determinism and throughput while the browser optimizes
65
+ * for explanation.
66
+ *
67
+ * ## Choose Your Route
68
+ *
69
+ * - Start with `flappy-evolution-worker.ts` if you want the high-level message
70
+ * lifecycle.
71
+ * - Read `flappy-evolution-worker.protocol.service.ts` next if you want the
72
+ * legal sequencing rules.
73
+ * - Read `flappy-evolution-worker.runtime.service.ts` if you want the worker's
74
+ * NEAT runtime setup.
75
+ * - Read `flappy-evolution-worker.playback.service.ts` and
76
+ * `flappy-evolution-worker.simulation.frame.service.ts` if you want the hot
77
+ * playback path.
78
+ * - Read `flappy-evolution-worker.snapshot.utils.ts` if you want the typed-array
79
+ * transport story.
80
+ *
81
+ * Minimal host-side sketch:
82
+ *
83
+ * ```ts
84
+ * worker.postMessage({
85
+ * type: 'init',
86
+ * payload: { populationSize: 50, elitismCount: 10, rngSeed: 12345 },
87
+ * });
88
+ * worker.postMessage({ type: 'request-generation' });
89
+ * worker.postMessage({
90
+ * type: 'start-playback',
91
+ * payload: { visibleWorldWidthPx: 1280, visibleWorldHeightPx: 720 },
92
+ * });
93
+ * worker.postMessage({
94
+ * type: 'request-playback-step',
95
+ * payload: {
96
+ * requestId: 1,
97
+ * simulationSteps: 2,
98
+ * visibleWorldWidthPx: 1280,
99
+ * visibleWorldHeightPx: 720,
100
+ * },
101
+ * });
102
+ * ```
103
+ *
104
+ * If you want background reading before the symbol shelf, the MDN Web Workers
105
+ * guide is the fastest practical reference for why this example pushes both
106
+ * evolution and playback off the main thread.
19
107
  */
20
108
  /// <reference lib="webworker" />
21
109
 
@@ -9,10 +9,94 @@ duplicate types. The payoff is consistency: when a policy sees a gap, or when
9
9
  a helper estimates urgency, those meanings stay aligned across the whole
10
10
  example.
11
11
 
12
- Read this file as the common language layer beneath the larger subsystems.
13
- It is intentionally small, geometry-heavy, and runtime-neutral so the same
14
- concepts can move cleanly between Node training, worker playback, and browser
15
- inspection tools.
12
+ This is the common language layer for the control problem. It does not own
13
+ full simulation stepping, scoring, or rendering. It owns the smaller
14
+ contracts those larger boundaries must agree on: difficulty profiles, pipe
15
+ geometry, observation features, temporal memory, and action decoding.
16
+
17
+ That shared vocabulary is what keeps the demo honest across runtimes. The
18
+ environment can advance the world, the evaluation layer can score policies,
19
+ the worker can stream playback, and browser helpers can inspect decisions
20
+ without silently redefining what "next gap" or "urgent correction" means.
21
+
22
+ ## What This Folder Is Trying To Teach
23
+
24
+ Read this chapter if you want to answer three practical questions:
25
+
26
+ 1. Which geometric signals does the policy actually see?
27
+ 2. How does the example add short-horizon memory without requiring recurrent
28
+ networks?
29
+ 3. How do difficulty, spawn, observation, and control helpers stay reusable
30
+ across Node training and browser playback?
31
+
32
+ ## Shared Vocabulary Map
33
+
34
+ ```mermaid
35
+ flowchart LR
36
+ Difficulty["difficulty utils\ncurriculum profile"] --> Spawn["spawn utils\nnext pipe cadence and gap"]
37
+ Spawn --> World["environment + worker playback\nconcrete world state"]
38
+ World --> Features["observation/\nfeature synthesis"]
39
+ Features --> Memory["memory utils\nstack recent frames and actions"]
40
+ Features --> Vector["observation/\ncanonical policy vectors"]
41
+ Vector --> Control["control utils\nresolve flap decision"]
42
+ Memory --> Control
43
+
44
+ Browser["browser inspection helpers"] -.-> Features
45
+ Evaluation["evaluation/"] -.-> Features
46
+ Worker["flappy-evolution-worker/"] -.-> Memory
47
+
48
+ classDef boundary fill:#001522,stroke:#0fb5ff,color:#9fdcff,stroke-width:2px;
49
+ classDef runtime fill:#03111f,stroke:#00e5ff,color:#d8f6ff,stroke-width:2px;
50
+ classDef highlight fill:#2a1029,stroke:#ff4a8d,color:#ffd7e8,stroke-width:3px;
51
+
52
+ class Difficulty,Spawn,Features,Memory,Vector,Control boundary;
53
+ class World,Browser,Evaluation,Worker runtime;
54
+ class Features highlight;
55
+ ```
56
+
57
+ The key teaching point is that the policy does not read pixels. It reads a
58
+ curated state representation: gap geometry, velocity, urgency, and a short
59
+ action-conditioned memory trail. That makes the control problem easier to
60
+ inspect and keeps training, evaluation, and playback aligned around the same
61
+ semantics.
62
+
63
+ ## Choose Your Route
64
+
65
+ - Start with `simulation-shared.types.ts` if you want the stable nouns of the
66
+ subsystem.
67
+ - Read `simulation-shared.difficulty.utils.ts` and
68
+ `simulation-shared.spawn.utils.ts` if you want the curriculum and course
69
+ generation rules.
70
+ - Read [simulation-shared/observation/README.md](./observation/README.md) if
71
+ you want the feature-engineering story in more detail.
72
+ - Read `simulation-shared.memory.utils.ts` if you want the frame-stacking and
73
+ recent-action channels.
74
+ - Read `simulation-shared.control.utils.ts` if you want the final step from
75
+ network outputs to `flap` versus `no flap`.
76
+
77
+ Example sketch:
78
+
79
+ ```ts
80
+ const difficultyProfile = resolveAdaptiveDifficultyProfile(pipesPassed, 1);
81
+ const features = resolveObservationFeatures({
82
+ birdYPx,
83
+ velocityYPxPerFrame,
84
+ pipes,
85
+ visibleWorldWidthPx,
86
+ difficultyProfile,
87
+ activeSpawnIntervalFrames: difficultyProfile.pipeSpawnIntervalFrames,
88
+ });
89
+ const networkInput = resolveTemporalObservationVector(
90
+ features,
91
+ observationMemoryState,
92
+ );
93
+ const didFlap = resolveFlapDecision(network.activate(networkInput));
94
+ ```
95
+
96
+ If you want background reading, Wikipedia contributors on feature
97
+ engineering, curriculum learning, and frame stacking are useful bridges, but
98
+ this folder is where those ideas become concrete contracts for the Flappy
99
+ Bird example.
16
100
 
17
101
  ## simulation-shared/simulation-shared.types.ts
18
102
 
@@ -8,10 +8,94 @@
8
8
  * a helper estimates urgency, those meanings stay aligned across the whole
9
9
  * example.
10
10
  *
11
- * Read this file as the common language layer beneath the larger subsystems.
12
- * It is intentionally small, geometry-heavy, and runtime-neutral so the same
13
- * concepts can move cleanly between Node training, worker playback, and browser
14
- * inspection tools.
11
+ * This is the common language layer for the control problem. It does not own
12
+ * full simulation stepping, scoring, or rendering. It owns the smaller
13
+ * contracts those larger boundaries must agree on: difficulty profiles, pipe
14
+ * geometry, observation features, temporal memory, and action decoding.
15
+ *
16
+ * That shared vocabulary is what keeps the demo honest across runtimes. The
17
+ * environment can advance the world, the evaluation layer can score policies,
18
+ * the worker can stream playback, and browser helpers can inspect decisions
19
+ * without silently redefining what "next gap" or "urgent correction" means.
20
+ *
21
+ * ## What This Folder Is Trying To Teach
22
+ *
23
+ * Read this chapter if you want to answer three practical questions:
24
+ *
25
+ * 1. Which geometric signals does the policy actually see?
26
+ * 2. How does the example add short-horizon memory without requiring recurrent
27
+ * networks?
28
+ * 3. How do difficulty, spawn, observation, and control helpers stay reusable
29
+ * across Node training and browser playback?
30
+ *
31
+ * ## Shared Vocabulary Map
32
+ *
33
+ * ```mermaid
34
+ * flowchart LR
35
+ * Difficulty["difficulty utils\ncurriculum profile"] --> Spawn["spawn utils\nnext pipe cadence and gap"]
36
+ * Spawn --> World["environment + worker playback\nconcrete world state"]
37
+ * World --> Features["observation/\nfeature synthesis"]
38
+ * Features --> Memory["memory utils\nstack recent frames and actions"]
39
+ * Features --> Vector["observation/\ncanonical policy vectors"]
40
+ * Vector --> Control["control utils\nresolve flap decision"]
41
+ * Memory --> Control
42
+ *
43
+ * Browser["browser inspection helpers"] -.-> Features
44
+ * Evaluation["evaluation/"] -.-> Features
45
+ * Worker["flappy-evolution-worker/"] -.-> Memory
46
+ *
47
+ * classDef boundary fill:#001522,stroke:#0fb5ff,color:#9fdcff,stroke-width:2px;
48
+ * classDef runtime fill:#03111f,stroke:#00e5ff,color:#d8f6ff,stroke-width:2px;
49
+ * classDef highlight fill:#2a1029,stroke:#ff4a8d,color:#ffd7e8,stroke-width:3px;
50
+ *
51
+ * class Difficulty,Spawn,Features,Memory,Vector,Control boundary;
52
+ * class World,Browser,Evaluation,Worker runtime;
53
+ * class Features highlight;
54
+ * ```
55
+ *
56
+ * The key teaching point is that the policy does not read pixels. It reads a
57
+ * curated state representation: gap geometry, velocity, urgency, and a short
58
+ * action-conditioned memory trail. That makes the control problem easier to
59
+ * inspect and keeps training, evaluation, and playback aligned around the same
60
+ * semantics.
61
+ *
62
+ * ## Choose Your Route
63
+ *
64
+ * - Start with `simulation-shared.types.ts` if you want the stable nouns of the
65
+ * subsystem.
66
+ * - Read `simulation-shared.difficulty.utils.ts` and
67
+ * `simulation-shared.spawn.utils.ts` if you want the curriculum and course
68
+ * generation rules.
69
+ * - Read [simulation-shared/observation/README.md](./observation/README.md) if
70
+ * you want the feature-engineering story in more detail.
71
+ * - Read `simulation-shared.memory.utils.ts` if you want the frame-stacking and
72
+ * recent-action channels.
73
+ * - Read `simulation-shared.control.utils.ts` if you want the final step from
74
+ * network outputs to `flap` versus `no flap`.
75
+ *
76
+ * Example sketch:
77
+ *
78
+ * ```ts
79
+ * const difficultyProfile = resolveAdaptiveDifficultyProfile(pipesPassed, 1);
80
+ * const features = resolveObservationFeatures({
81
+ * birdYPx,
82
+ * velocityYPxPerFrame,
83
+ * pipes,
84
+ * visibleWorldWidthPx,
85
+ * difficultyProfile,
86
+ * activeSpawnIntervalFrames: difficultyProfile.pipeSpawnIntervalFrames,
87
+ * });
88
+ * const networkInput = resolveTemporalObservationVector(
89
+ * features,
90
+ * observationMemoryState,
91
+ * );
92
+ * const didFlap = resolveFlapDecision(network.activate(networkInput));
93
+ * ```
94
+ *
95
+ * If you want background reading, Wikipedia contributors on feature
96
+ * engineering, curriculum learning, and frame stacking are useful bridges, but
97
+ * this folder is where those ideas become concrete contracts for the Flappy
98
+ * Bird example.
15
99
  */
16
100
  /**
17
101
  * Minimal deterministic random contract used by shared spawn helpers.