feat(v4): Phase 7 Task 3 -- L8, v3's Jacquard selector, in each node's heartbeat cycle (#189)

v3's vm_heartbeat_update_l8 with its table (ssm_jacquard.c, compudynamics.c), rewritten in integers: the
regime from the window's entropy, the prediction CV and the locality of the last 32 calls; the current card
scored (ANOVA from inference, joint convergence under L5/L6), decayed 0.99, the next chosen by UCB1 over 64
cards; its gates L1-L7 applied to the loops, L1 and L4 within the build's ceilings. Every gate off and card 8
at the start, as v3's kernel boot. Applied through card_bits: v3 applies the card's number, one bit off --
filed #196, ruled "v4 correct, v3 as is". v4_mesh_l8_force as v3's ssm_l8_force_config; the exact decay
and window tests hold a card. Test first: test_mesh_boot.c 67 checks, 75 on. amd64 PASS, 156 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 22:38:36 +00:00
parent 2379503900
commit d09eee9a08
7 changed files with 205 additions and 12 deletions
+35
View File
@@ -111,6 +111,31 @@ typedef struct {
#define HEARTBEAT_CHECK_FREQUENCY 256
#endif
#define V4_MESH_CHECK_FREQUENCY ((uint32_t)HEARTBEAT_CHECK_FREQUENCY)
/* L8, the Jacquard selector (v3's ssm_jacquard.c and compudynamics.c, #188: 64 cards, L7 always on): a card's
* gates are ((card & 0x3F) << 1) | L7, in v3's SSM_CFG_* bits. Applied as card_bits() -- not as v3's
* ssm_l8_tick_score_and_select does, one bit off (#196; Captain Bob, 2026-11-13: "v4 correct, v3 as is"). */
#define V4_L8_CARDS 64u
#define V4_L8_REGIMES 8u
#define V4_L8_START 8u /* v3's first card: C4, L3 and L7 */
#define V4_L8_L1 0x40u
#define V4_L8_L2 0x20u
#define V4_L8_L3 0x10u
#define V4_L8_L4 0x08u
#define V4_L8_L5 0x04u
#define V4_L8_L6 0x02u
#define V4_L8_L7 0x01u
typedef struct {
uint32_t regime_scores[V4_L8_REGIMES * V4_L8_CARDS];
uint32_t regime_ticks[V4_L8_REGIMES * V4_L8_CARDS];
uint32_t total_regime_ticks[V4_L8_REGIMES];
uint32_t prev_window[V4_L8_CARDS];
uint32_t prev_locality_q16[V4_L8_CARDS];
uint8_t has_prev[V4_L8_CARDS];
uint8_t current_card, current_regime;
uint8_t hold; /* a card forced (v3's ssm_l8_force_config): L8 does not move from it */
uint64_t changes; /* how many times the card has changed */
} v4_mesh_l8;
typedef struct {
uint64_t tick; /* the node's heartbeat cycles (v3's tick_count): by execution, as v3 */
uint32_t check_counter; /* word calls since the last cycle */
@@ -136,6 +161,12 @@ typedef struct {
/* the hot-words cache (the node's (HOT), v4/image.h): L8's gate (v3's L1_heat_tracking), and its counts */
uint8_t l1_cache;
uint64_t hot_promotions, hot_evictions;
/* L8 and the gates it sets that the other loops read: l1_cache .. l4_pipelining above, and these */
uint8_t l5_window_inference, l6_decay_inference, l7_adaptive_heartrate;
v4_mesh_l8 l8;
/* inference (v3's last_inference_outputs): did it run at the last tick, and exit early */
uint64_t last_inference_tick;
uint8_t inference_early_exited;
} v4_mesh_physics;
typedef struct v4_mesh v4_mesh;
@@ -214,6 +245,10 @@ int v4_mesh_busy(const v4_mesh *ms);
/* A word's record on the node in `place`, by its xt: 0 if that is not a word's xt. */
const v4_mesh_account *v4_mesh_account_at(const v4_mesh *ms, unsigned place, v4_cell xt);
/* L8 held on `card` (0..63) on the node in `place`, its gates applied (v3's ssm_l8_force_config); `hold` 0 lets
* it choose again from there. */
void v4_mesh_l8_force(v4_mesh *ms, unsigned place, unsigned card, int hold);
/* Every node's tick set to `tick` (for tests: a node's tick is its own count of heartbeat cycles). */
void v4_mesh_set_tick(v4_mesh *ms, uint64_t tick);