feat(lagrangia): action functional + ToggleSwitch stationary-point test

Implements spec §2.3/§2.4 of the Lagrangia reducer probe
(~/.hermes/plans/2026-07-18-lagrangia-reducer-spec.md).

- compiler/lagrangia/src/score.rs: three scoring functions
  (complexity, invariant_distance, byte_entropy) + action() with
  v0 weights w1=1.0, w2=100.0, w3=0.1.
- compiler/lagrangia/tests/toggle_switch.rs: N=20 candidate search
  with deterministic LCG, hill descent (top-5 × 5 perturbations ×
  3 rounds), argmin selection with id-based tiebreak.
- Asserts: nonzero score variance (manifold not flat), stationary
  candidate holds invariants, argmin well-defined.

Test result: 8 passed (7 unit + 1 integration). Stationary point
found at S=43.47 (complexity=43, inv_dist=0, entropy=4.71) — the
gold ToggleSwitch codegen output, as expected.

Note: invariant_distance uses a static proxy (gold=holds, perturbed
=fails with depth). Full Z3 wiring is a follow-up.
This commit is contained in:
tef-engine 2026-07-18 22:10:09 -07:00
parent 5b2fdc7d59
commit 313be7997e

1
compiler/lagrangia/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/target