caelum0x 96e0591c88 fix(discovery): make SINDy sparsity scale-invariant
Discovery ran stlsq_standardized (thresholds in RMS-normalized feature
space) but then re-filtered the restored *original-unit* coefficients by
config.sparse.threshold. That defeated the standardization: genuine terms
whose coefficient is small purely because their state carries a large
magnitude (e.g. SIR's beta/N ~ 3e-4 with populations ~1e3) were pruned,
collapsing the law unless the user hand-tuned the threshold to the data
scale. Keep every non-zero term the standardized solver returns.

Fixing that unmasked a second bug: when a threshold prunes every remaining
active term in one step, STLSQ's loop broke on empty support and returned
the pre-prune *dense* fit, so an aggressive threshold silently produced a
denser model. Zero the coefficients when the support drains, matching the
reference STLSQ contract.

- Add regression tests: keeps_scale_small_coefficients_after_standardized_fit
  and threshold_above_every_coefficient_yields_the_empty_model.
- SIR now recovers the S*I interaction at raw population scale (thr 0.02);
  Lorenz/Lotka-Volterra/damped-pendulum recovery unchanged.
- Add a reproducible discovery gallery (examples/discovery-gallery) and a
  site showcase page (docs/showcase) with deterministic observed-vs-recovered
  SVG plots served from the docs site.
- .gitignore: local datasets, scratch worlds, and regenerable run/work dirs.

Workspace: 1653 tests pass; docs-site render stays byte-identical.
2026-08-19 00:34:05 +03:00
..