feat(v4): Phase 7 Task 3 -- the inference engine and Loop #7 in each node's heartbeat cycle (#189)

v4/system/inference.c: v3's inference_engine.c and its Q48.16 arithmetic ported to the bit, no C library --
the variance, the window width (Levene), the decay slope (log-linear regression), the run with its 5%
early exit. v4/tests/test_inference.c links v3's own and compares them: POST's fixed cases, 20000 random
multiply/log pairs, 400 random trajectories (make -C v4 inference; in make -C v4 test). In each node's
cycle every 1000 ticks (HEARTBEAT_INFERENCE_FREQUENCY), once the window is warm: the trajectory from the
window's words' heat, the width and slope applied unless it exits early, then Loop #7 -- the heartrate
slower when stable, faster when not, within 1/4..4x; Hera's re-arms the kernel's heartbeat
(heartbeat_set_adaptive_period_ns), as v3's Hera. L8 reads its outcome. Test first: test_mesh_boot.c 72
checks, 80 on. amd64 PASS, 163 s. Not pushed (held to the end of Phase 7).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
Claude
2026-11-13 23:59:18 +00:00
parent d09eee9a08
commit 6d954ac279
13 changed files with 434 additions and 14 deletions
@@ -128,7 +128,14 @@ Phase 4).
dictionary, so a word not called cools. The window's adaptive pass (v3's
`rolling_window_run_adaptive_pass`): diversity against the last; halve to 256, double to 4096.
Test first (`test_mesh_boot.c`: 62 checks; 70 on).
- [ ] Inference every 1000 ticks (v3's `vm_tick_inference_engine`, `inference_engine.c`).
- [x] Inference every 1000 ticks (v3's `vm_tick_inference_engine`): `v4/system/inference.c`, v3's
`inference_engine.c` and Q48.16 arithmetic ported to the bit -- `v4/tests/test_inference.c` links
v3's own and compares them on POST's cases, 20000 random multiply and log pairs, and 400
trajectories (`make -C v4 inference`). The trajectory from the window's newest words' heat; the
window width and slope applied unless it exits early (as v3, the last inferred slope re-applied
on a full run even with L6 off). Loop #7: the heartrate 25% slower when stable, 20% faster when
not, within 1/4..4x; Hera's re-arms the kernel's heartbeat. Test first (72 checks; 80 on).
amd64 PASS, 163 s.
- [x] L8's update (v3's `vm_heartbeat_update_l8` with its table, `ssm_jacquard.c`, `compudynamics.c`): the
regime (window entropy >= 0.75, prediction CV >= 0.15, locality >= 1/2, as exact integer
comparisons), the card scored (ANOVA from inference; joint convergence when L5 or L6), the next by