brainx-skill 1.0.15 → 1.0.16

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 (171) hide show
  1. package/README.md +17 -1
  2. package/manifest.json +1 -1
  3. package/mcp-servers/codex/skills.json +1 -1
  4. package/package.json +1 -1
  5. package/skills/bio-neuro-lit/SKILL.md +4 -2
  6. package/skills/bio-neuro-lit/references/required-supplements.md +27 -0
  7. package/skills/brainx-acceleration/SKILL.md +30 -437
  8. package/skills/brainx-acceleration/references/audit-and-rewrite-patterns.md +326 -0
  9. package/skills/brainx-general-guard/SKILL.md +24 -8
  10. package/skills/brainx-install/SKILL.md +3 -3
  11. package/skills/brainx-install/references/compatibility-and-release-matching.md +28 -20
  12. package/skills/brainx-install/references/uninstall-and-cleanup.md +11 -4
  13. package/skills/brainx-modeling-loop/SKILL.md +117 -36
  14. package/skills/brainx-modeling-loop/agents/openai.yaml +2 -2
  15. package/skills/brainx-modeling-loop/references/mechanism-comparison.md +62 -0
  16. package/skills/brainx-modeling-loop/references/multiscale-coupling.md +16 -0
  17. package/skills/brainx-modeling-loop/references/paper-reproduction.md +42 -0
  18. package/skills/brainx-modeling-loop/references/parameter-fitting-workflow.md +14 -14
  19. package/skills/brainx-modeling-loop/references/run-experiment.md +1 -1
  20. package/skills/brainx-modeling-loop/references/training-workflow.md +10 -8
  21. package/skills/brainx-visualization/SKILL.md +6 -2
  22. package/skills/brainx-visualization/references/neural-data-visualization.md +1 -1
  23. package/skills/brainx-visualization/references/statistical-and-model-visualization.md +1 -1
  24. package/skills/package-skills/braincell/SKILL.md +23 -14
  25. package/skills/package-skills/braincell/references/braintools/input-current.md +1 -1
  26. package/skills/package-skills/braincell/references/braintools/metric.md +72 -46
  27. package/skills/package-skills/braincell/references/mixions-for-adaptation.md +1 -1
  28. package/skills/package-skills/braincell/references/multicompartment/braincell-manual-morphology-construction.md +1 -1
  29. package/skills/package-skills/braincell/references/multicompartment/cv-policy-reference.md +1 -1
  30. package/skills/package-skills/braincell/references/multicompartment/filter-function-library.md +3 -3
  31. package/skills/package-skills/braincell/references/multicompartment/morphology-io-loading-validation.md +1 -1
  32. package/skills/package-skills/braincell/references/multicompartment/multicompartment-cell-workflow.md +31 -43
  33. package/skills/package-skills/braincell/references/multicompartment/network-workflow.md +49 -0
  34. package/skills/package-skills/braincell/references/multicompartment/probe-reference.md +26 -114
  35. package/skills/package-skills/braincell/references/multicompartment/topology-building-and-visualization.md +40 -28
  36. package/skills/package-skills/braincell/references/scripts/cell_multicompartment_reference.py +13 -17
  37. package/skills/package-skills/brainevent/SKILL.md +0 -3
  38. package/skills/package-skills/brainevent/references/synaptic-plasticity.md +1 -1
  39. package/skills/package-skills/brainmass/SKILL.md +5 -3
  40. package/skills/package-skills/brainmass/references/brainstate/parameter-constraints-regularization.md +9 -7
  41. package/skills/package-skills/brainmass/references/brainstate/parameter-transforms-regularizers-catalog.md +4 -4
  42. package/skills/package-skills/brainmass/references/braintools/data-preprocessing.md +15 -7
  43. package/skills/package-skills/brainmass/references/braintools/metric.md +72 -46
  44. package/skills/package-skills/brainmass/references/coupling-network-api.md +3 -1
  45. package/skills/package-skills/brainmass/references/fitting-with-objectives-api.md +6 -6
  46. package/skills/package-skills/brainmass/references/horn-task-training.md +9 -9
  47. package/skills/package-skills/brainmass/references/modellibrary.md +12 -10
  48. package/skills/package-skills/brainmass/references/scripts/resting-state-meg-whole-brain-pipeline.py +5 -3
  49. package/skills/package-skills/brainmass/references/scripts/wilson-cowan-ei-dynamics.py +10 -6
  50. package/skills/package-skills/brainmass/references/simulator-input-monitor-api.md +3 -1
  51. package/skills/package-skills/brainmass/references/visualization-analysis-api.md +17 -9
  52. package/skills/package-skills/brainspike/SKILL.md +201 -0
  53. package/skills/package-skills/brainspike/references/braintools/connectivity.md +40 -0
  54. package/skills/package-skills/brainspike/references/braintools/data-preprocessing.md +39 -0
  55. package/skills/package-skills/brainspike/references/braintools/input-current.md +55 -0
  56. package/skills/package-skills/brainspike/references/braintools/metric.md +36 -0
  57. package/skills/package-skills/brainspike/references/braintools/optimizer.md +50 -0
  58. package/skills/package-skills/brainspike/references/braintools/parameter-initializer.md +43 -0
  59. package/skills/package-skills/brainspike/references/braintools/surrogate.md +40 -0
  60. package/skills/package-skills/brainspike/references/migration-boundary.md +38 -0
  61. package/skills/package-skills/brainspike/references/model-and-readout-selection.md +41 -0
  62. package/skills/package-skills/brainspike/references/multirate-coupling.md +31 -0
  63. package/skills/package-skills/brainspike/references/multiscale-composition.md +28 -0
  64. package/skills/package-skills/brainspike/references/native-composition.md +52 -0
  65. package/skills/package-skills/brainspike/references/native-delays.md +34 -0
  66. package/skills/package-skills/brainspike/references/native-projections.md +43 -0
  67. package/skills/package-skills/brainspike/references/native-training.md +36 -0
  68. package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/devices.md +33 -33
  69. package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/divergence-and-parity.md +15 -15
  70. package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/integration-categories.md +1 -1
  71. package/skills/package-skills/brainspike/references/nest-compatible/model-library.md +200 -0
  72. package/skills/package-skills/brainspike/references/nest-compatible/network-building.md +276 -0
  73. package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/brette_et_al_2007.py +23 -26
  74. package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/brunel_alpha.py +18 -21
  75. package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/brunel_delta.py +16 -19
  76. package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/clopath_synapse_spike_pairing.py +11 -12
  77. package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/evaluate_tsodyks2_synapse.py +10 -11
  78. package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/spatial_gaussex.py +18 -18
  79. package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/synapsecollection.py +26 -29
  80. package/skills/package-skills/brainspike/references/nest-compatible/synapse-and-connectivity.md +166 -0
  81. package/skills/package-skills/brainspike/references/nest-delay-boundaries.md +31 -0
  82. package/skills/package-skills/brainspike/references/nonlinear-state-sharing.md +26 -0
  83. package/skills/package-skills/{brainpy-state → brainspike}/references/perturbation-experiment-validity.md +2 -2
  84. package/skills/package-skills/brainspike/references/simulator-training.md +61 -0
  85. package/skills/package-skills/brainspike/references/temporal-task-training.md +36 -0
  86. package/skills/package-skills/brainspike/scripts/advanced_native_patterns.py +76 -0
  87. package/skills/package-skills/brainspike/scripts/delay_workflow.py +44 -0
  88. package/skills/package-skills/brainspike/scripts/delayed_cue_training.py +78 -0
  89. package/skills/package-skills/brainspike/scripts/lif_smoke.py +31 -0
  90. package/skills/package-skills/brainspike/scripts/multiscale_workflow.py +35 -0
  91. package/skills/package-skills/brainspike/scripts/native_ei_network.py +47 -0
  92. package/skills/package-skills/brainspike/scripts/native_workflows.py +77 -0
  93. package/skills/package-skills/brainspike/scripts/nest_boundary_workflows.py +108 -0
  94. package/skills/package-skills/brainspike/scripts/train_native_snn.py +65 -0
  95. package/skills/package-skills/brainspike/scripts/train_nest_simulator.py +69 -0
  96. package/skills/package-skills/brainspike/scripts/train_nest_simulator_two_weights.py +220 -0
  97. package/skills/package-skills/brainstate/SKILL.md +16 -21
  98. package/skills/package-skills/brainstate/references/brainstate/brainstate-control-flow-patterns.md +1 -138
  99. package/skills/package-skills/brainstate/references/brainstate/brainstate-transformed-diagnostics.md +1 -1
  100. package/skills/package-skills/brainstate/references/brainstate/delay-buffers.md +45 -0
  101. package/skills/package-skills/brainstate/references/brainstate/parameter-constraints-regularization.md +9 -7
  102. package/skills/package-skills/brainstate/references/brainstate/parameter-transforms-regularizers-catalog.md +4 -4
  103. package/skills/package-skills/brainstate/references/brainstate/randomness-and-reproducibility.md +6 -4
  104. package/skills/package-skills/brainstate/references/brainstate/transformation-grad-expansion.md +4 -4
  105. package/skills/package-skills/brainstate/references/brainstate/transformation-vmap-expansion.md +1 -1
  106. package/skills/package-skills/brainstate/references/braintools-optimizer-reference.md +16 -0
  107. package/skills/package-skills/brainstate/references/libraries/prebuilt-layer-library.md +1 -1
  108. package/skills/package-skills/brainstate/references/simulation-environment.md +5 -5
  109. package/skills/package-skills/braintrace/SKILL.md +17 -38
  110. package/skills/package-skills/braintrace/references/Drtrl.md +9 -26
  111. package/skills/package-skills/braintrace/references/algorithm selection.md +7 -12
  112. package/skills/package-skills/braintrace/references/batching.md +15 -35
  113. package/skills/package-skills/braintrace/references/compiler_internal.md +1 -1
  114. package/skills/package-skills/braintrace/references/custom algorithms.md +1 -2
  115. package/skills/package-skills/braintrace/references/customizing_primitive_transforms.md +26 -15
  116. package/skills/package-skills/braintrace/references/pp_pprop workflow.md +5 -139
  117. package/skills/package-skills/brainunit/SKILL.md +7 -2
  118. package/skills/package-skills/brainunit/references/array-mechanics/functional-structural-api.md +1 -1
  119. package/skills/package-skills/brainunit/references/math-function-library.md +2 -2
  120. package/skills/package-skills/brainunit/references/typing-and-runtime-validation.md +5 -2
  121. package/skills/package-skills/brainevent/references/scripts/102_EI_net_1996.py +0 -107
  122. package/skills/package-skills/brainevent/references/scripts/204_joglekar_2018_propagation.py +0 -168
  123. package/skills/package-skills/brainevent/references/scripts/coba_ei_teaching.py +0 -356
  124. package/skills/package-skills/brainpy-state/SKILL.md +0 -247
  125. package/skills/package-skills/brainpy-state/references/array-creation.md +0 -158
  126. package/skills/package-skills/brainpy-state/references/brain-dynamics-delay-protocol.md +0 -147
  127. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/analysis.md +0 -150
  128. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/brainpy legacy workflow.md +0 -373
  129. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/built-in dynamic neuron model.md +0 -150
  130. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/connecting neurons.md +0 -175
  131. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/customize neuron and synpase.md +0 -286
  132. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/Input generation.md +0 -111
  133. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/More about simulation.md +0 -163
  134. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/Multi-device array sharding.md +0 -113
  135. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/Parallel experiment execution.md +0 -136
  136. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/array creation and mechanics.md +0 -222
  137. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/brainpy math environment setting.md +0 -123
  138. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/delays.md +0 -107
  139. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/object oriented transformations and control flows.md +0 -185
  140. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/integrators.md +0 -181
  141. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/route activity through connectivity.md +0 -102
  142. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/synaptic projections.md +0 -147
  143. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/synpase properties.md +0 -159
  144. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/loss library.md +0 -127
  145. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/optimizers.md +0 -167
  146. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/parameter initializers.md +0 -107
  147. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/prebuilt neural network layers.md +0 -186
  148. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/surrogate gradients.md +0 -104
  149. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/trainer library.md +0 -89
  150. package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/trainingworkflows.md +0 -253
  151. package/skills/package-skills/brainpy-state/references/braintools/brainstate-control-flow-patterns.md +0 -334
  152. package/skills/package-skills/brainpy-state/references/braintools/connectivity.md +0 -206
  153. package/skills/package-skills/brainpy-state/references/braintools/data-preprocessing.md +0 -79
  154. package/skills/package-skills/brainpy-state/references/braintools/input-current.md +0 -199
  155. package/skills/package-skills/brainpy-state/references/braintools/metric.md +0 -152
  156. package/skills/package-skills/brainpy-state/references/braintools/optimizer.md +0 -179
  157. package/skills/package-skills/brainpy-state/references/braintools/parameter-initializer.md +0 -183
  158. package/skills/package-skills/brainpy-state/references/braintools/surrogate.md +0 -147
  159. package/skills/package-skills/brainpy-state/references/component-selection.md +0 -288
  160. package/skills/package-skills/brainpy-state/references/nest-compatible/model-library.md +0 -200
  161. package/skills/package-skills/brainpy-state/references/nest-compatible/nest-workflow.md +0 -156
  162. package/skills/package-skills/brainpy-state/references/nest-compatible/network-building.md +0 -264
  163. package/skills/package-skills/brainpy-state/references/nest-compatible/synapse-and-connectivity.md +0 -153
  164. package/skills/package-skills/brainpy-state/references/projection-patterns.md +0 -127
  165. package/skills/package-skills/brainpy-state/references/scripts/103_COBA_2005.py +0 -86
  166. package/skills/package-skills/brainpy-state/references/scripts/106_COBA_HH_2007.py +0 -181
  167. package/skills/package-skills/brainpy-state/references/scripts/107_gamma_oscillation_1996.py +0 -156
  168. package/skills/package-skills/brainpy-state/references/scripts/109_fast_global_oscillation.py +0 -111
  169. package/skills/package-skills/brainpy-state/references/scripts/201_surrogate_grad_lif_fashion_mnist.py +0 -221
  170. package/skills/package-skills/brainpy-state/references/scripts/sound_localization.py +0 -240
  171. package/skills/package-skills/brainpy-state/references/scripts/training-snn.py +0 -119
@@ -0,0 +1,326 @@
1
+ # Audit and rewrite patterns
2
+
3
+ Use this reference to classify a hot path or compare execution-axis patterns after reading the acceleration skill.
4
+
5
+ ## Investigation protocol
6
+
7
+ ### 1. Build a hot-path inventory
8
+
9
+ For each candidate function (`step`, `update`, `forward`, `run`, `simulate`, `loss`, `train_step`, data/RNG helper), record:
10
+
11
+ ```text
12
+ function/call site:
13
+ inputs: shapes, dtypes, axis meanings
14
+ states read: State/ParamState/RandomState, shapes, shared or per-trial
15
+ states written: State/ParamState/RandomState, shapes, shared or per-trial
16
+ loops: axis, trip count, nested axes
17
+ current transforms: none / raw jax / brainstate.transform
18
+ outputs: full history vs summary metrics
19
+ RNG: source, key/stream split policy, per-step/per-trial independence
20
+ shape changes: yes/no, cause
21
+ host interaction: print/log/float/item/np.asarray/callbacks
22
+ connectivity: dense/sparse/event/structured
23
+ ```
24
+
25
+ Use searches as a first pass, then read the code before editing:
26
+
27
+ ```bash
28
+ rg -n "import numpy|np\." .
29
+ rg -n "for .*range|while " .
30
+ rg -n "\.append\(|np\.array\(|np\.stack\(|jnp\.stack\(|concatenate\(" .
31
+ rg -n "jax\.jit|jax\.grad|jax\.vmap|brainstate\.transform" .
32
+ rg -n "\.value\s*=|\[[^\]]+\]\s*=" .
33
+ rg -n "random|np\.random|jax\.random|RandomState|split_key|seed" .
34
+ rg -n "finite|epsilon|eps|perturb|theta_plus|theta_minus|jacobian|hessian" .
35
+ rg -n "\.item\(|float\(|int\(|bool\(|np\.asarray|print\(|logging\." .
36
+ rg -n "jit\(|grad\(|vmap\(|scan\(" .
37
+ ```
38
+
39
+ ### 2. Classify every inefficient pattern
40
+
41
+ Use these labels in audit notes when useful.
42
+
43
+ | Label | Evidence | Why slow/risky | Rewrite target |
44
+ |---|---|---|---|
45
+ | `loop-N-scalar` | `for i in range(N)` updates neuron/synapse scalars | Python overhead; no fused population kernel | array-shaped state + `jnp.where`/broadcast/scatter/sparse ops under `jit` |
46
+ | `object-neurons` | list/dict of neuron/synapse objects updated one by one | compiler sees Python objects, not arrays | one population/module with state arrays shaped `[N,...]` |
47
+ | `loop-T-python` | Python loop calls `step(x[t])` | dispatch per step; no compiled recurrent loop | `scan`, `for_loop`, or `while_loop` inside `jit` |
48
+ | `dynamic-list-history` | append outputs/states then stack | dynamic Python accumulation; memory waste | `scan` outputs or summary carry |
49
+ | `memory-T-full-history` | stores all `V[t]`/state when only rates/loss needed | unnecessary memory; worse autodiff storage | carry summary; record sparse snapshots; `checkpointed_scan` for differentiable long runs |
50
+ | `loop-B-python` | loop over trials/batch/stimuli | serial Python batch | `vmap` or batched state |
51
+ | `loop-E-sweep` | loop over seeds/configs/model copies | serial ensemble sweep | `vmap` with leading `[E,...]` state/param/RNG axes |
52
+ | `loop-P-finite-diff` | `eps`, `theta_plus`, `theta_minus`, perturb each param | O(P) or O(2P) simulations; noisy gradients | `grad`/`value_and_grad` over args or `ParamState` |
53
+ | `raw-jax-stateful` | `jax.jit/grad/vmap` wraps BrainState module/state writes | state updates may be lost or mishandled | `brainstate.transform.*` or explicit split/pass/return/merge |
54
+ | `np-in-transform` | `np.*` in code used by `jit/grad/vmap/scan` | host execution, tracer conversion, frozen constants | replace with `jnp.*` or move outside transform |
55
+ | `python-control-array` | Python `if/while/bool/int/float` depends on array value | tracer errors or host sync | `jnp.where`, `cond`, `while_loop`, `for_loop`, masks |
56
+ | `wrong-jit-boundary` | jitting tiny helpers, or making jitted functions inside loops | compile overhead; poor fusion | jit largest stable unit: `run`, `loss`, `train_step` |
57
+ | `transform-inside-loop` | `jit(...)`, `vmap(...)`, `grad(...)` constructed repeatedly | repeated tracing/compilation | define transforms once at module/init scope |
58
+ | `dynamic-shape` | shape depends on data/spikes/runtime length | recompilation or unsupported traced shape | static config, padding, masks, bucketing |
59
+ | `hidden-mutable-attr` | ordinary attrs mutated in transformed method | untracked state semantics | `State`/`ParamState`/explicit return value |
60
+ | `state-vmap-ambiguous` | `vmap` over stateful model without explicit state-axis decision | shared vs independent state bugs | set/verify `state_in_axes`, `state_out_axes`, unexpected state policy |
61
+ | `rng-reuse` | same key/seed reused across trials/time; `np.random` in hot path | correlated trials; unreproducible behavior | BrainState random streams or explicit split; map RNG axis under `vmap` |
62
+ | `host-sync` | `print`, `.item()`, `float(x)`, `np.asarray(x)` in hot loop | device-host synchronization | aggregate metrics; log outside compiled loop; debug-only callbacks |
63
+ | `accidental-densify` | converts sparse/event connectivity to dense `[N,N]` | memory/bandwidth blow-up | preserve sparse/event/structured representation |
64
+ | `already-fused` | large `jnp` matmul/conv/reduction already dominates | transforms may not help much | benchmark first; avoid churn |
65
+
66
+ ### 3. Rank findings before rewriting
67
+
68
+ Score each finding:
69
+
70
+ ```text
71
+ impact = loop trip count × work per iteration × call frequency
72
+ risk = state/RNG/gradient/memory semantic risk
73
+ confidence = evidence quality + shape clarity + API certainty
74
+ ```
75
+
76
+ Rewrite high-impact, high-confidence items first. Do not refactor low-impact style issues unless they block a larger transform.
77
+
78
+ ## Rewrite playbook
79
+
80
+ ### A. Population axis `N`: scalar/object loop -> array state
81
+
82
+ Bad:
83
+
84
+ ```python
85
+ for i in range(num_neurons):
86
+ v[i] += dt * (-v[i] + i_ext[i]) / tau[i]
87
+ if v[i] > threshold[i]:
88
+ spike[i] = 1
89
+ v[i] = reset[i]
90
+ ```
91
+
92
+ Good shape pattern:
93
+
94
+ ```python
95
+ v_new = V.value + dt * (-V.value + i_ext) / tau
96
+ spike = v_new > threshold
97
+ V.value = jnp.where(spike, reset, v_new)
98
+ ```
99
+
100
+ Use `jnp.where`/masks for elementwise conditional reset. Use `.at[]` scatter or segment/sparse/event operations when updates are indexed. Avoid Python object-per-neuron design in hot paths.
101
+
102
+ ### B. Time axis `T`: Python simulation loop -> transformed control flow
103
+
104
+ Bad:
105
+
106
+ ```python
107
+ ys = []
108
+ for t in range(T):
109
+ ys.append(step(xs[t]))
110
+ y = jnp.stack(ys)
111
+ ```
112
+
113
+ Good full-history pattern:
114
+
115
+ ```python
116
+ def body(carry, x_t):
117
+ y_t = net(x_t) # may read/write BrainState State
118
+ return carry, y_t
119
+
120
+ @brainstate.transform.jit
121
+ def run(xs_T):
122
+ _, ys_T = brainstate.transform.scan(body, None, xs_T)
123
+ return ys_T
124
+ ```
125
+
126
+ Good summary-only pattern:
127
+
128
+ ```python
129
+ def body(summary, x_t):
130
+ y_t = net(x_t)
131
+ summary = summary + metric(y_t)
132
+ return summary, None
133
+ ```
134
+
135
+ Use `checkpointed_scan` when differentiating through long `T` and activation/state storage dominates memory. Before applying exact control-flow APIs, read `brainstate` → `references/brainstate/brainstate-control-flow-patterns.md`.
136
+
137
+ ### C. Batch/trial axis `B`: Python batch loop -> `vmap` or batched state
138
+
139
+ Bad:
140
+
141
+ ```python
142
+ outs = []
143
+ for b in range(B):
144
+ outs.append(run_one(xs_B[b]))
145
+ outs = jnp.stack(outs)
146
+ ```
147
+
148
+ Good pattern:
149
+
150
+ ```python
151
+ run_batch = brainstate.transform.jit(
152
+ brainstate.transform.vmap(run_one, in_axes=0, out_axes=0)
153
+ )
154
+ outs = run_batch(xs_B)
155
+ ```
156
+
157
+ Before rewriting, decide for every state:
158
+
159
+ ```text
160
+ shared across B? parameters, shared read-only config, global constants
161
+ independent per B? membrane voltage, refractory state, synaptic traces, trial RNG, optimizer-free simulation state
162
+ written back? final per-trial state, shared aggregate, or discarded temporary?
163
+ ```
164
+
165
+ If independent state is required, use `vmap(..., in_states=..., out_states=...)` for explicit State instances or `vmap2(..., state_in_axes=..., state_out_axes=...)` for State filters. Read `brainstate` → `references/brainstate/transformation-vmap-expansion.md` before editing exact arguments.
166
+
167
+ ### D. Ensemble/sweep axis `E`: serial model copies -> mapped states/params
168
+
169
+ Bad:
170
+
171
+ ```python
172
+ for e in range(E):
173
+ set_params(params[e])
174
+ results.append(run(inputs, seed=e))
175
+ ```
176
+
177
+ Good shape intent:
178
+
179
+ ```text
180
+ params/state/RNG: [E, ...]
181
+ inputs: [E, T, ...] or shared [T, ...]
182
+ outputs: [E, T, ...] or [E, summary]
183
+ ```
184
+
185
+ Good transform intent:
186
+
187
+ ```python
188
+ run_ensemble = brainstate.transform.jit(
189
+ brainstate.transform.vmap2(
190
+ run_one_model,
191
+ in_axes=..., out_axes=...,
192
+ state_in_axes=..., state_out_axes=...,
193
+ )
194
+ )
195
+ ```
196
+
197
+ Use this for parameter sweeps, random initial conditions, seeds, lesions, perturbations, and independent circuit replicas. Verify memory: mapping `E` full histories can be huge.
198
+
199
+ ### E. Parameter axis `P`: manual gradients -> `grad`
200
+
201
+ Bad finite differences:
202
+
203
+ ```python
204
+ for i in range(num_params):
205
+ theta_p = theta.at[i].add(eps)
206
+ theta_m = theta.at[i].add(-eps)
207
+ g = (loss(theta_p) - loss(theta_m)) / (2 * eps)
208
+ ```
209
+
210
+ Good training intent:
211
+
212
+ ```python
213
+ params = model.states(brainstate.ParamState)
214
+
215
+ def loss_fn(x, target):
216
+ pred = run(x)
217
+ return jnp.mean((pred - target) ** 2)
218
+
219
+ grad_fn = brainstate.transform.grad(loss_fn, grad_states=params, return_value=True)
220
+
221
+ @brainstate.transform.jit
222
+ def train_step(x, target):
223
+ grads, loss = grad_fn(x, target)
224
+ optimizer.update(grads)
225
+ return loss
226
+ ```
227
+
228
+ Use `grad(loss_over_batch)` for normal batch training. Use `vmap(grad(single_loss))` only for per-sample gradients, influence functions, uncertainty, or diagnostics; it can be memory-heavy. Read `brainstate` → `references/brainstate/transformation-grad-expansion.md` before exact state/argument gradient edits.
229
+
230
+ ### F. JIT boundary: compile the largest stable unit
231
+
232
+ Prefer:
233
+
234
+ ```python
235
+ @brainstate.transform.jit
236
+ def train_step(batch):
237
+ loss = ...
238
+ grads = ...
239
+ optimizer.update(grads)
240
+ return loss, metrics
241
+ ```
242
+
243
+ Avoid:
244
+
245
+ ```python
246
+ for t in range(T):
247
+ y = brainstate.transform.jit(tiny_op)(x[t])
248
+ ```
249
+
250
+ Common good boundaries:
251
+
252
+ ```text
253
+ step if called many times and shape-stable
254
+ run when it contains scan/control flow
255
+ loss_fn when repeatedly evaluated
256
+ train_step best boundary for training: forward + loss + grad + optimizer update
257
+ ```
258
+
259
+ Read `brainstate` → `references/brainstate/transformation-jit-expansion.md` before changing static args, diagnosing recompilation, or replacing raw `jax.jit` around stateful code.
260
+
261
+ ### G. Composition patterns
262
+
263
+ Use these as intent patterns, then adapt to local BrainState API:
264
+
265
+ ```text
266
+ single trial over time: jit(scan(step))
267
+ batch of independent trials: jit(vmap(run_one_trial))
268
+ time loop with batched state: jit(scan(vmapped_step_or_batched_step))
269
+ ensemble of models: jit(vmap(run_one_model, mapped states))
270
+ normal training: jit(train_step using grad(loss_over_batch))
271
+ per-sample gradients: jit(vmap(grad(single_sample_loss)))
272
+ long differentiable sequence: jit(checkpointed_scan(step))
273
+ multi-device batch/ensemble/shard: pmap2/shard_map after single-device cleanup
274
+ ```
275
+
276
+ Axis order matters. Choose the order that preserves state semantics and minimizes memory. For example, `vmap(scan(step))` creates independent trials with independent recurrent state; `scan(vmap(step))` uses a time loop whose step is already batched.
277
+
278
+ ### H. Randomness
279
+
280
+ Tiny RNG block: use one reproducible root seed or stream, then split/fold/map independent randomness for trials, parameter sweeps, stochastic dynamics, dropout/noise, and transformed execution. Route deeper seed/key restoration details to `brainstate` → `references/brainstate/randomness-and-reproducibility.md`.
281
+
282
+ Bad:
283
+
284
+ ```python
285
+ for b in range(B):
286
+ y = run_one(xs[b], key) # same key reused
287
+ ```
288
+
289
+ Good intent:
290
+
291
+ ```text
292
+ one reproducible root seed/stream
293
+ split/fold/map independent keys for B/E/trials
294
+ split or advance per time step when stochastic dynamics require it
295
+ store RNG in BrainState-compatible state/stream if transformed code mutates it
296
+ ```
297
+
298
+ Under `vmap`, verify each mapped element receives independent randomness. RNG correctness is part of validation, not a style preference.
299
+
300
+ ### I. Multi-device `D`
301
+
302
+ Use `pmap2`, `shard_map`, or explicit sharding only after the single-device program is already transform-friendly. Good candidates: large independent trials, large ensembles, or explicit population/connectivity shards. Bad candidates: tiny Python-bound loops, logging-heavy code, shape-changing workloads, or dense memory blow-ups.
303
+
304
+ ## Audit response template
305
+
306
+ ```markdown
307
+ ## BrainX acceleration audit
308
+
309
+ | File/area | Pattern | Evidence | Axis | Impact | Risk | Rewrite | Confidence |
310
+ |---|---|---|---|---|---|---|---|
311
+ | ... | `loop-T-python` | `for t ... step(...)` | T | High | Medium | `scan` inside `jit` | High |
312
+
313
+ ## Patch / rewrite plan
314
+
315
+ [Small concrete diff or code blocks. State which reference markdown was used for exact transform semantics. State API assumptions if any.]
316
+
317
+ ## Validation plan
318
+
319
+ [Old/new tiny test, final-state check, RNG check, shape/recompile check, gradient check if training, warm timing method.]
320
+
321
+ ## Remaining risks
322
+
323
+ [State sharing, RNG independence, sparse/dense memory, dynamic shapes, numerical differences, unresolved API questions.]
324
+ ```
325
+
326
+ If the user asks for an actual code rewrite, include the patch. If the user asks only for an audit, do not rewrite yet; provide the table and prioritized plan.
@@ -1,13 +1,24 @@
1
1
  ---
2
2
  name: brainx-general-guard
3
- description: Use first for every BrainX modeling, simulation, training, review, debugging, or optimization task. Identify every modeling scale explicitly represented, open only the BrainX package skills that own those scales, and keep the implementation BrainX-native.
3
+ description: Use first for every BrainX modeling, simulation, training, review, debugging, or optimization task. For an end-to-end project involving a new model, mechanism comparison, simulation, fitting, or experimental predictions, immediately route to brainx-modeling-loop before selecting package skills; use this skill alone for focused package or API work with the model design fixed.
4
4
  ---
5
5
 
6
6
  # BrainX general guard
7
7
 
8
8
  ## Purpose and boundary
9
9
 
10
- Use this guard first to identify the represented modeling scales, open their owning package skills, and keep package orchestration ahead of lower-level infrastructure. Keep it active for cross-cutting API selection, execution, interoperability, and validation decisions.
10
+ Use this guard first to identify the represented modeling scales, route end-to-end scientific work to `brainx-modeling-loop`, open the owning package skills, and keep package orchestration ahead of lower-level infrastructure. Keep it active for cross-cutting API selection, execution, interoperability, and validation decisions.
11
+
12
+ ### Workflow routing
13
+
14
+ Treat workflow ownership separately from biological-scale ownership. This guard is the mandatory first pass; it does not replace the modeling workflow.
15
+
16
+ | Request shape | Next route |
17
+ |---|---|
18
+ | A new or changed model, mechanism comparison, simulation or fitting study, experiment-derived prediction, or scientific result report | Open `brainx-modeling-loop` immediately after this guard. Complete its step-0 clarification gate before opening package-specific modeling skills. |
19
+ | A focused implementation, API, debugging, or optimization task with the model design and acceptance criteria already fixed | Continue with this guard and the package skill that owns the represented scale. |
20
+
21
+ Do not route an end-to-end project directly from this guard to `brainmass`, `brainspike`, `braincell`, or other package skills. The modeling loop owns clarification, specification, literature gating, implementation order, review, and handoff; package skills own the selected biological scale after step 0.
11
22
 
12
23
  ## Check package presence without inspecting installed BrainX
13
24
 
@@ -28,16 +39,19 @@ Select every row supported by the user's task. A single-scale task opens one mod
28
39
 
29
40
  | The task explicitly represents | Open |
30
41
  |---|---|
31
- | Point neurons, synapses, or point-neuron spiking networks | BrainPy-State |
42
+ | Point neurons, their synapses, spiking networks, training, or point-neuron coupling | BrainSpike; check its migration boundary for workflows beyond the verified Simulator path |
32
43
  | Ions, channels, compartments, or cellular morphology | BrainCell |
33
44
  | Aggregate neural populations, local circuits, brain regions, or whole-brain dynamics | BrainMass |
34
- | Detailed cells connected into a spiking network | BrainCell + BrainPy-State |
35
- | Point-neuron spiking networks coupled to aggregate regional dynamics | BrainPy-State + BrainMass |
45
+ | Detailed cells connected through spatially placed synapses | BrainCell |
46
+ | Detailed cells coupled to point neurons | BrainCell + BrainSpike |
47
+ | Point-neuron spiking networks coupled to aggregate regional dynamics | BrainSpike + BrainMass |
36
48
  | Cellular mechanisms coupled to aggregate neural-mass dynamics | BrainCell + BrainMass |
37
- | Cellular biophysics, point-neuron networks, and aggregate population dynamics interacting in one workflow | BrainCell + BrainPy-State + BrainMass |
49
+ | Cellular biophysics, point-neuron networks, and aggregate population dynamics interacting in one workflow | BrainCell + BrainSpike + BrainMass |
38
50
 
39
51
  Keep the implementation at the selected scale. Do not introduce aggregate population-rate State into a point-neuron model, or point neurons into an aggregate model, merely to simplify execution. When both mechanisms are scientifically represented, treat the task as multiscale and open both owning skills.
40
52
 
53
+ When represented scales exchange signals, open `brainx-modeling-loop` → `references/multiscale-coupling.md` for exchanged observables, units, axes, clocks, and causal order.
54
+
41
55
  ## Write BrainX-native code
42
56
 
43
57
  Start from the scientific concept and use the selected BrainX skills to construct the workflow. Keep ordinary Python, NumPy, or JAX at explicit boundaries for documented dimensionless model inputs, host-side statistics, serialization, timing, device reporting, or custom presentation logic. Preserve units and State until that boundary, and verify an API gap before writing generic numerical infrastructure.
@@ -95,6 +109,8 @@ An unavailable optional backend does not establish a general BrainTools gap when
95
109
 
96
110
  Derive claims from observables that distinguish the claimed mechanism; validate the baseline and mechanism before calibration, and mark unsourced calibrated regimes as phenomenological.
97
111
 
112
+ - Before production, verify that the model preserves the differences required by the original question. Prioritize unmeasured assumptions whose plausible alternatives could change the main conclusion; constrain claims to the supported measurement and tested conditions. For phenomenon-driven mechanism comparisons, open `brainx-modeling-loop` → `references/mechanism-comparison.md` for causal-chain design, structural distinguishability, and decisive assumption checks.
113
+
98
114
  - Freeze parameters, evaluation seeds, metrics or scores, thresholds or windows, and displayed cases before viewing intervention outcomes; otherwise calibrate separately and report held-out or nearby sensitivity.
99
115
  - Validate each matched control independently, then compare and save control and intervention evidence at every nuisance setting and aligned physical time or event landmark; a normalized summary is not a substitute for those paired observables.
100
116
  - At each causal branch, verify and save every relevant State and protocol input, vary only the declared intervention, and preserve per-condition evidence plus its aggregation. State causality at the intervention level; claim event mediation only when a mediator-specific manipulation and per-condition event dose agree with the outcome.
@@ -126,9 +142,9 @@ Use the owning package's orchestrator for workflows it already implements. When
126
142
 
127
143
  Do not add a transform only to construct parameter axes or satisfy a named-API checklist. When the owning package already represents independent conditions through a native batch or `size` axis, use that path and reserve `vmap` for a callable the owning package does not already batch.
128
144
 
129
- Map only independent operations. If trial N mutates weights or other State that trial N+1 consumes, keep those trials sequential; batch only independent evaluation trials or ensembles, with separate dynamical State and deliberately shared read-only State. Mapping input construction or offline scoring does not batch the stateful simulation itself. Open `skills/package-skills/brainstate/references/brainstate/transformation-vmap-expansion.md` when a complete mapped operation reads or writes State, for the State-axis contracts and independent-lane pattern.
145
+ Map only independent operations. If trial N mutates weights or other State that trial N+1 consumes, keep those trials sequential; batch only independent evaluation trials or ensembles, with separate dynamical State and deliberately shared read-only State. Mapping input construction or offline scoring does not batch the stateful simulation itself. Open `brainstate` → `references/brainstate/transformation-vmap-expansion.md` when a complete mapped operation reads or writes State, for the State-axis contracts and independent-lane pattern.
130
146
 
131
- A mapped complete per-step transition called inside one `for_loop` is a stateful simulation batch: the mapping owns independent conditions and the loop owns time. Select mapped State by semantic role, such as `Any(OfType(HiddenState), OfType(ShortTermState))`; do not infer State ownership from array rank, shape, or a coincidental leading size. Open `skills/package-skills/brainstate/references/brainstate/transformation-vmap-expansion.md` for the canonical initialization, mapping, and loop composition.
147
+ A mapped complete per-step transition called inside one `for_loop` is a stateful simulation batch: the mapping owns independent conditions and the loop owns time. Select mapped State by semantic role, such as `Any(OfType(HiddenState), OfType(ShortTermState))`; do not infer State ownership from array rank, shape, or a coincidental leading size. Open `brainstate` → `references/brainstate/transformation-vmap-expansion.md` for the canonical initialization, mapping, and loop composition.
132
148
 
133
149
  Describe the transform that actually runs. Native batched State, vmapped input construction, and vmapped host scoring are not stateful `vmap`. When the user explicitly requires `vmap`, map the complete independent operation or report why the requirement cannot be met.
134
150
 
@@ -17,7 +17,7 @@ For installation, upgrade, downgrade, migration, device-target, or compatibility
17
17
 
18
18
  ## Core Rules
19
19
 
20
- 1. BrainX package must use a Python interpreter at version `>=3.11`.
20
+ 1. Match the interpreter to the selected release's `Requires-Python` metadata. BrainX `2026.10.25`, the target for the skill examples, requires Python `>=3.12`. Some historical releases support Python 3.11.
21
21
  2. For a clean environment with no requested version, prefer to use the unpinned BrainX install matching the confirmed device, but resolve and name the current latest Python-compatible BrainX date-style release before confirmation. Critically, if a BrainX component already exists in the environment, or a requested version is specified, you must open [compatibility-and-release-matching.md](references/compatibility-and-release-matching.md), use it as the primary release source, and select one non-separated release. Never mix component versions from different rows.
22
22
  3. Require the user to explicitly choose `cpu`, `cuda12`, `cuda13`, or `tpu`. Detection is evidence, not consent.
23
23
  4. Before any mutation, must present the complete specification to the user clearly, show the run location, interpreter, venv path, device extra, release, complete component set, existing packages, expected results, and exact commands.
@@ -53,7 +53,7 @@ Collect enough evidence to identify:
53
53
  - visible NVIDIA or TPU hardware and the driver, toolkit, container, or runtime evidence needed to distinguish `cuda12`, `cuda13`, and `tpu`;
54
54
  - the active Python executable and version, environment-manager state, pip version, and viable candidate interpreters;
55
55
  - existing `.venv`, `.venv-brainx`, or user-designated target environments without creating or activating them;
56
- - installed versions of BrainX, BrainUnit, BrainState, BrainEvent, BrainTools, BrainTrace or BrainScale, BrainCell, BrainPy, BrainPy-State, BrainMass, PINNx, JAX, JAXlib, and Optax in every environment relevant to the request;
56
+ - installed versions of BrainX, BrainUnit, BrainState, BrainEvent, BrainTools, BrainTrace or BrainScale, BrainCell, BrainPy, BrainPy-State, BrainSpikes (`brainspikes`), BrainMass, PINNx, JAX, JAXlib, and Optax in every environment relevant to the request;
57
57
  - for a clean unpinned install, the exact latest BrainX release compatible with the proposed interpreter, resolved from read-only official package-index metadata.
58
58
 
59
59
  Prefer package metadata and platform-native tools over imports or newly installed helpers. Record missing evidence explicitly as `unknown`, `not_detected`, or a command error rather than guessing. Organize the result in whatever concise structured form best fits the task.
@@ -89,7 +89,7 @@ Critically, for the second case, when BrainX packages are already installed or t
89
89
 
90
90
  ## 4. Choose the Venv
91
91
 
92
- Prefer reusing an existing relevant Python virtual environment whose interpreter is Python `>=3.11`. This includes environments managed by `venv`, Conda, or another environment manager; inspect the environment before proposing reuse.
92
+ Prefer reusing an existing relevant Python virtual environment only when its interpreter satisfies the selected release. This includes environments managed by `venv`, Conda, or another environment manager. If a clean install can use either Python 3.11 or a compatible newer interpreter, compare the resolved releases before proposing reuse.
93
93
 
94
94
  - If no suitable existing environment is available, propose creating a fresh virtual environment.
95
95
  - Never delete, rebuild, overwrite, or silently repurpose an existing environment.
@@ -14,29 +14,37 @@ Use this matrix for the second release-selection case: the target environment al
14
14
 
15
15
  ## Version compatibility matrix
16
16
 
17
- | BrainX release | JAX | BrainUnit | BrainState | BrainEvent | BrainTools | BrainTrace / BrainScale | BrainCell | BrainPy | BrainPy-State | BrainMass | PINNx | Optax |
18
- | ------------------------ | ------------------- | --------- | ---------- | ---------- | ---------- | ----------------------- | --------- | ------- | ------------- | --------- | --------------- | --------- |
19
- | `v2026.7.9` | `>=0.8.0, <=0.10.2` | `0.5.1` | `0.5.2` | `0.1.2` | `0.3.0` | BrainTrace `0.2.4` | `0.1.0` | `2.8.1` | `0.1.0` | `0.1.1` | **Not bundled** | `>=0.2.8` |
20
- | `v2026.6.29` | `>=0.8.0, <=0.10.2` | `0.5.1` | `0.5.2` | `0.1.1` | `0.3.0` | BrainTrace `0.2.2` | `0.1.0` | `2.8.0` | `0.1.0` | `0.1.1` | **Removed** | — |
21
- | `v2026.6.19` | `>=0.8.0, <=0.10.2` | `0.5.1` | `0.5.1` | `0.1.1` | `0.3.0` | BrainTrace `0.2.1` | `0.1.0` | `2.8.0` | `0.1.0` | `0.1.1` | `0.0.3` | — |
22
- | `v2026.6.18` | `>=0.7.1, <=0.10.1` | `0.4.0` | `0.5.0` | `0.1.0` | `0.1.10` | BrainTrace `0.2.0` | `0.0.8` | `2.7.8` | `0.1.0` | `0.0.5` | `0.0.3` | — |
23
- | `v2026.6.14` | `>=0.7.1, <=0.10.1` | `0.4.0` | `0.5.0` | `0.1.0` | `0.1.10` | BrainTrace `0.2.0` | `0.0.8` | `2.7.8` | `0.0.4` | `0.0.5` | `0.0.3` | — |
24
- | `v2026.6.11` | `>=0.7.1, <=0.10.1` | `0.4.0` | `0.4.2` | `0.1.0` | `0.1.10` | BrainTrace `0.2.0` | `0.0.8` | `2.7.8` | `0.0.4` | `0.0.5` | `0.0.3` | — |
25
- | `v2026.6.8` | `>=0.6.0, <=0.10.1` | `0.3.2` | `0.4.0` | `0.1.0` | `0.1.9` | BrainTrace `0.2.0` | `0.0.8` | `2.7.8` | `0.0.4` | `0.0.5` | `0.0.3` | — |
26
- | `v2026.3.12` | `>=0.6.0, <=0.9.1` | `0.2.0` | `0.3.0` | `0.0.7` | `0.1.8` | BrainTrace `0.1.2` | `0.0.8` | `2.7.7` | `0.0.4` | `0.0.5` | `0.0.3` | — |
27
- | `v2026.1.31` | `>=0.6.0, <0.9.0` | `0.1.4` | `0.2.10` | `0.0.5` | `0.1.8` | BrainTrace `0.1.2` | `0.0.7` | `2.7.6` | `0.0.3` | `0.0.5` | `0.0.3` | — |
28
- | `v2026.1.22` | `>=0.6.0, <=0.9.0` | `0.1.3` | `0.2.9` | `0.0.5` | `0.1.8` | BrainTrace `0.1.2` | `0.0.7` | `2.7.6` | `0.0.3` | `0.0.5` | `0.0.3` | — |
29
- | `v2026.1.21` | `>=0.6.0, <=0.9.0` | `0.1.3` | `0.2.9` | `0.0.5` | `0.1.7` | BrainTrace `0.1.2` | `0.0.7` | `2.7.6` | `0.0.3` | `0.0.5` | `0.0.3` | — |
30
- | `v2026.1.19` | `>=0.6.0, <=0.8.2` | `0.1.3` | `0.2.9` | `0.0.5` | `0.1.7` | BrainTrace `0.1.2` | `0.0.7` | `2.7.5` | `0.0.3` | `0.0.5` | `0.0.3` | — |
31
- | `v2026.1.16` | `>=0.6.0, <=0.8.2` | `0.1.3` | `0.2.9` | `0.0.5` | `0.1.7` | BrainTrace `0.1.2` | `0.0.6` | `2.7.5` | `0.0.2` | `0.0.4` | `0.0.3` | — |
32
- | `v2025.12.26` | `>=0.6.0, <=0.8.2` | `0.1.3` | `0.2.8` | `0.0.5` | `0.1.6` | BrainTrace `0.1.2` | `0.0.6` | `2.7.5` | `0.0.2` | `0.0.4` | `0.0.3` | — |
33
- | `v2025.12.25` | `>=0.6.0, <=0.8.2` | `0.1.3` | `0.2.8` | `0.0.5` | `0.1.6` | BrainTrace `0.1.2` | `0.0.6` | — | `0.0.1` | `0.0.4` | `0.0.3` | — |
34
- | `v2025.12.2` | `>=0.6.0, <=0.8.1` | `0.1.2` | `0.2.6` | `0.0.4` | `0.1.4` | BrainTrace `0.1.1` | `0.0.6` | `2.7.2` | — | `0.0.4` | `0.0.3` | — |
35
- | `v2025.10.13` | `>=0.6.0, <0.8.0` | `0.1.1` | `0.2.3` | `0.0.4` | `0.1.3` | BrainScale `0.1.0` | `0.0.6` | `2.7.1` | — | `0.0.4` | — | — |
36
- | `v2025.9.15` | `>=0.4.35, <0.8.0` | `0.1.1` | `0.1.10` | `0.0.4` | `0.0.11` | BrainScale `0.0.10` | `0.0.4` | — | — | `0.0.3` | — | — |
17
+ | BrainX release | JAX | BrainUnit | BrainState | BrainEvent | BrainTools | BrainTrace / BrainScale | BrainCell | BrainPy | BrainPy-State | BrainSpikes | BrainMass | PINNx | Optax |
18
+ | ------------------------ | ------------------- | --------- | ---------- | ---------- | ---------- | ----------------------- | --------- | ------- | ------------- | ----------- | --------- | --------------- | --------- |
19
+ | `v2026.10.25` | `>=0.9.0, <=0.12.0.1` | `0.6.0` | `0.6.0` | `0.3.0` | `0.4.0` | BrainTrace `0.2.8` | `0.2.0` | `2.9.0` | **Not bundled** | `0.2.0` | `0.1.1` | **Not bundled** | `>=0.2.8` |
20
+ | `v2026.8.18` | `>=0.8.0, <=0.11.1` | `0.5.2` | `0.5.4` | `0.2.1` | `0.3.0` | BrainTrace `0.2.6` | `0.1.0` | `2.8.2` | `0.1.0` | — | `0.1.1` | **Not bundled** | `>=0.2.8` |
21
+ | `v2026.7.9` | `>=0.8.0, <=0.10.2` | `0.5.1` | `0.5.2` | `0.1.2` | `0.3.0` | BrainTrace `0.2.4` | `0.1.0` | `2.8.1` | `0.1.0` | — | `0.1.1` | **Not bundled** | `>=0.2.8` |
22
+ | `v2026.6.29` | `>=0.8.0, <=0.10.2` | `0.5.1` | `0.5.2` | `0.1.1` | `0.3.0` | BrainTrace `0.2.2` | `0.1.0` | `2.8.0` | `0.1.0` | — | `0.1.1` | **Removed** | — |
23
+ | `v2026.6.19` | `>=0.8.0, <=0.10.2` | `0.5.1` | `0.5.1` | `0.1.1` | `0.3.0` | BrainTrace `0.2.1` | `0.1.0` | `2.8.0` | `0.1.0` | — | `0.1.1` | `0.0.3` | — |
24
+ | `v2026.6.18` | `>=0.7.1, <=0.10.1` | `0.4.0` | `0.5.0` | `0.1.0` | `0.1.10` | BrainTrace `0.2.0` | `0.0.8` | `2.7.8` | `0.1.0` | — | `0.0.5` | `0.0.3` | — |
25
+ | `v2026.6.14` | `>=0.7.1, <=0.10.1` | `0.4.0` | `0.5.0` | `0.1.0` | `0.1.10` | BrainTrace `0.2.0` | `0.0.8` | `2.7.8` | `0.0.4` | — | `0.0.5` | `0.0.3` | — |
26
+ | `v2026.6.11` | `>=0.7.1, <=0.10.1` | `0.4.0` | `0.4.2` | `0.1.0` | `0.1.10` | BrainTrace `0.2.0` | `0.0.8` | `2.7.8` | `0.0.4` | — | `0.0.5` | `0.0.3` | — |
27
+ | `v2026.6.8` | `>=0.6.0, <=0.10.1` | `0.3.2` | `0.4.0` | `0.1.0` | `0.1.9` | BrainTrace `0.2.0` | `0.0.8` | `2.7.8` | `0.0.4` | — | `0.0.5` | `0.0.3` | — |
28
+ | `v2026.3.12` | `>=0.6.0, <=0.9.1` | `0.2.0` | `0.3.0` | `0.0.7` | `0.1.8` | BrainTrace `0.1.2` | `0.0.8` | `2.7.7` | `0.0.4` | — | `0.0.5` | `0.0.3` | — |
29
+ | `v2026.1.31` | `>=0.6.0, <0.9.0` | `0.1.4` | `0.2.10` | `0.0.5` | `0.1.8` | BrainTrace `0.1.2` | `0.0.7` | `2.7.6` | `0.0.3` | — | `0.0.5` | `0.0.3` | — |
30
+ | `v2026.1.22` | `>=0.6.0, <=0.9.0` | `0.1.3` | `0.2.9` | `0.0.5` | `0.1.8` | BrainTrace `0.1.2` | `0.0.7` | `2.7.6` | `0.0.3` | — | `0.0.5` | `0.0.3` | — |
31
+ | `v2026.1.21` | `>=0.6.0, <=0.9.0` | `0.1.3` | `0.2.9` | `0.0.5` | `0.1.7` | BrainTrace `0.1.2` | `0.0.7` | `2.7.6` | `0.0.3` | — | `0.0.5` | `0.0.3` | — |
32
+ | `v2026.1.19` | `>=0.6.0, <=0.8.2` | `0.1.3` | `0.2.9` | `0.0.5` | `0.1.7` | BrainTrace `0.1.2` | `0.0.7` | `2.7.5` | `0.0.3` | — | `0.0.5` | `0.0.3` | — |
33
+ | `v2026.1.16` | `>=0.6.0, <=0.8.2` | `0.1.3` | `0.2.9` | `0.0.5` | `0.1.7` | BrainTrace `0.1.2` | `0.0.6` | `2.7.5` | `0.0.2` | — | `0.0.4` | `0.0.3` | — |
34
+ | `v2025.12.26` | `>=0.6.0, <=0.8.2` | `0.1.3` | `0.2.8` | `0.0.5` | `0.1.6` | BrainTrace `0.1.2` | `0.0.6` | `2.7.5` | `0.0.2` | — | `0.0.4` | `0.0.3` | — |
35
+ | `v2025.12.25` | `>=0.6.0, <=0.8.2` | `0.1.3` | `0.2.8` | `0.0.5` | `0.1.6` | BrainTrace `0.1.2` | `0.0.6` | — | `0.0.1` | — | `0.0.4` | `0.0.3` | — |
36
+ | `v2025.12.2` | `>=0.6.0, <=0.8.1` | `0.1.2` | `0.2.6` | `0.0.4` | `0.1.4` | BrainTrace `0.1.1` | `0.0.6` | `2.7.2` | — | — | `0.0.4` | `0.0.3` | — |
37
+ | `v2025.10.13` | `>=0.6.0, <0.8.0` | `0.1.1` | `0.2.3` | `0.0.4` | `0.1.3` | BrainScale `0.1.0` | `0.0.6` | `2.7.1` | — | — | `0.0.4` | — | — |
38
+ | `v2025.9.15` | `>=0.4.35, <0.8.0` | `0.1.1` | `0.1.10` | `0.0.4` | `0.0.11` | BrainScale `0.0.10` | `0.0.4` | — | — | — | `0.0.3` | — | — |
37
39
 
38
40
  ## Installation rule
39
41
 
42
+ BrainX `2026.10.25` requires Python 3.12 or newer. The BrainSpikes distribution
43
+ is `brainspikes`. Import it as `brainspike`. BrainPy `2.9.0` provides
44
+ `brainpy.state` directly.
45
+
46
+ [BrainX 2026.10.25 release metadata](https://pypi.org/pypi/BrainX/2026.10.25/json)
47
+
40
48
  Treat each row as one declared BrainX package set.
41
49
 
42
50
  Do not independently combine the newest release of every subpackage. Choose a BrainX release and use the package versions declared for that release.
@@ -12,6 +12,7 @@ brainunit
12
12
  brainstate
13
13
  brainpy
14
14
  brainpy-state
15
+ brainspikes
15
16
  brainevent
16
17
  braincell
17
18
  braintrace
@@ -83,13 +84,19 @@ Prefer distribution metadata over imports. Use the exact interpreter for read-on
83
84
  "<exact-python>" -m pip check
84
85
  ```
85
86
 
86
- The placeholder is illustrative. Replace it with the platform-appropriate exact interpreter path. Use `importlib.metadata` or another read-only metadata method to inspect declared requirements and find reverse dependencies. Classify each target before planning removal:
87
+ Replace the placeholder with the platform-appropriate exact interpreter path.
88
+ Verify the environment before classifying its distributions. Compare resolved paths.
87
89
 
88
- - **Local to venv:** its package location is under the virtual environment's `site-packages`; it is eligible for uninstall.
90
+ - For a Python `venv`, verify that `sys.prefix` matches the target and differs from `sys.base_prefix`.
91
+ - For Conda, verify that `sys.prefix` matches the target listed by `conda env list --json`, contains `conda-meta`, and differs from the base path reported by `conda info --base`. A Conda interpreter can have equal `sys.prefix` and `sys.base_prefix`.
92
+ - Stop if the interpreter belongs to Conda base or the evidence establishes neither a `venv` nor a non-base Conda environment.
93
+
94
+ Use `importlib.metadata` or another read-only metadata method to inspect declared requirements and find reverse dependencies. Classify each target before planning removal:
95
+
96
+ - **Local to the verified environment.** Its distribution location is under the target's `site-packages`; it is eligible for the uninstall specification.
89
97
  - **Visible from external Python:** it is exposed through `--system-site-packages` or another external path; preserve it.
90
- - **Global interpreter:** `sys.prefix == sys.base_prefix`; stop and do not uninstall.
91
98
 
92
- Only the first case may enter the uninstall specification. If the user asks to uninstall a package visible from external Python or from a global interpreter, explicitly warn that this would modify an external or shared Python environment and stop without uninstalling it. Do not import target packages, upgrade pip, or install a helper merely to inspect the environment.
99
+ Include only local distributions in the uninstall specification. If the user asks to uninstall a package visible from external Python or from a global interpreter, explain which external or shared Python environment owns it and stop. Inspect target packages through metadata using the existing pip and interpreter.
93
100
 
94
101
  Evaluate reverse dependencies against the final proposed scope. Ignore requirements from distributions that are themselves being removed, but list every remaining distribution that requires a planned BrainX or JAX target. Do not automatically add those dependents to the uninstall command. If the target environment cannot be proven non-global, stop and request a virtual or Conda environment instead.
95
102