feat(v4): Phase 7 Task 3b -- compudynamics on the 32 F18 opcodes as on the words, behind OPCODE_PHYSICS (#189)

Captain Bob, 2026-11-14: "we're supposed to be working on f18 opcode as well as our composed f18
dictionary"; ruled every loop on both, "and an easy revert if opcodes are too granular".

- The engine: a hook at retire (exec.h on_retire), as Part A's at call; NULL unless set. test_exec.c.
- The mesh: 32 opcode records per node, an opcode window, opcode transitions under L4; at every retired
  instruction decay at the opcodes' own slope, heat, temperature, the window, the transition; in each cycle
  all 32 cooled, the opcode window's service, inference on its heat. L8 scores from the words and its gates
  govern both; the tick stays paced by word calls. The window is now one type for words and opcodes.
- The revert: OPCODE_PHYSICS (Kconfig.physics, default y; the kernel's flags) -- 0 and the opcodes are
  counted and charged to the Stadium as in Phase 1. make -C v4 mesh-boot-noop builds and tests it.
- Tests first: test_mesh_boot.c 77 checks as built, 86 with pipelining on, 74 with the revert.
- Measured on amd64, back to back: 219 s on, 196 s off (+12% under TCG). Both boots' logs labelled.
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-14 00:29:08 +00:00
parent b5d99ba98b
commit e1b731f444
16 changed files with 296 additions and 57 deletions
+6
View File
@@ -44,10 +44,16 @@
* target (so P is still the return address). NULL: no hook. */
typedef void (*v4_call_hook)(void *ctx, v4_node *n, v4_cell target);
/* Called when an instruction retires, after HEAT-OP counts it, with its opcode (0..31): compudynamics on the
* opcodes (#189 Phase 7, ruling 7). NULL: no hook. */
typedef void (*v4_retire_hook)(void *ctx, v4_node *n, unsigned op);
typedef struct {
v4_uheat_t anticlock;
v4_call_hook on_call; /* reset leaves NULL */
void *on_call_ctx;
v4_retire_hook on_retire; /* reset leaves NULL */
void *on_retire_ctx;
/* A node blocked at its port in the middle of an instruction word
* (node.h) goes on, when it has been served, from the slot after the
+36 -7
View File
@@ -144,14 +144,26 @@ typedef struct {
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;
/* COMPUDYNAMICS ON THE OPCODES (#189 Phase 7, ruling 7; Captain Bob, 2026-11-14: every loop on the 32 F18
* opcodes as on the composed words, "and an easy revert if opcodes are too granular"): this is the revert --
* 0, and the opcodes are counted and charged to the Stadium as in Phase 1, and nothing more. */
#ifndef OPCODE_PHYSICS
#define OPCODE_PHYSICS 1
#endif
#define V4_MESH_OPCODES 32u
typedef struct {
v4_uheat_t heat; /* +1 a retirement, decayed by the ticks since (Loop #3) */
uint64_t last_decay_tick;
uint16_t temperature_q8;
uint8_t state_flags; /* V4_MESH_STATE_FROZEN */
uint8_t most_likely_next; /* pipelining: the opcode that most often comes next */
uint64_t most_likely_count, total_transitions;
uint64_t transitions[V4_MESH_OPCODES];
} v4_mesh_opcode;
/* a Rolling Window of Truth (v3's RollingWindowOfTruth): IDs in the order they came, 4096 of them, warm at
* 1024, its effective size tuned (Loop #5) */
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 */
uint32_t cycle_every; /* V4_MESH_CHECK_FREQUENCY */
uint64_t decay_slope_q48;
uint8_t l3_decay; /* L8's gate on Loop #3 */
uint8_t l2_window; /* L8's gate on Loop #2 */
/* the Rolling Window of Truth (Loop #2; v3's RollingWindowOfTruth): the IDs of the words called, in order */
uint32_t history[V4_MESH_WINDOW];
uint32_t window_pos; /* where the next is written */
uint64_t total_executions;
@@ -160,6 +172,17 @@ typedef struct {
uint8_t is_warm;
uint8_t adaptive_pending; /* the heartbeat should check the window's diversity */
uint64_t last_pattern_diversity, diversity_checks;
} v4_mesh_window;
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 */
uint32_t cycle_every; /* V4_MESH_CHECK_FREQUENCY */
uint64_t decay_slope_q48;
uint8_t l3_decay; /* L8's gate on Loop #3 */
uint8_t l2_window; /* L8's gate on Loop #2 */
/* the Rolling Window of Truth (Loop #2): the words called, in order; and the opcodes retired (ruling 7) */
v4_mesh_window win, opwin;
v4_cell decay_cursor; /* background decay: the next word's xt, down the dictionary; 0: from LATEST */
uint64_t decay_cycles;
/* pipelining (Loop #4): the word called before, L8's gate, and the node's counts */
@@ -179,6 +202,12 @@ typedef struct {
uint8_t inference_early_exited;
uint64_t inference_runs, inference_early_exits;
uint64_t tick_target_ns; /* v3's tick_target_ns: HEARTBEAT_TICK_NS, a quarter to four times it */
/* the opcodes' physics (ruling 7): their records, the one before, their decay slope, their inference */
v4_mesh_opcode op[V4_MESH_OPCODES];
uint32_t prev_op; /* V4_MESH_NO_WORD: none yet */
uint64_t op_decay_slope_q48;
v4_inference_out op_inference;
uint64_t op_inference_runs;
/* the dictionary as inference last counted it (v3's *_at_check): words over heat 50, words cooling (heat
* 1..9), the heat in all; and the snapshot each cycle publishes (v3's HeartbeatSnapshot) */
uint64_t hot_at_check, stale_at_check, total_heat_at_check;