feat(v4): Phase 7 Task 1 -- v3's physics fields on the word records, and each node's physics state (#189)
v4_mesh_account gains v3's DictPhysics: heat (execution_heat), last_decay_tick, temperature_q8, and the kernel's own state flags (pinned, frozen); v4_mesh_physics gives each node v3's VM fields -- its tick, the decay slope (v3's initial 21845, Q48.16), L8's gate on Loop #3. v4_mesh_state_flags derives a word's flags as v3 does, immediate and hidden read from the node's header when asked. Test first: test_mesh_boot.c, 48 checks. The kernel gives each of its 16 places its physics. Not pushed (held, Captain Bob 2026-11-13: "Hold it, go ahead with Task 1"). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
@@ -56,8 +56,29 @@ typedef struct {
|
||||
v4_uheat_t calls; /* every call since the word was defined */
|
||||
v4_uheat_t since; /* calls since the owner last charged them */
|
||||
v4_cell xt; /* the word's xt; 0: no word has this ID */
|
||||
/* v3's physics on a word (DictPhysics, v3/include/vm.h; #189 Phase 7, Task 1) */
|
||||
v4_uheat_t heat; /* v3's execution_heat: +1 a call, decayed by the ticks since (Loop #3) */
|
||||
uint64_t last_decay_tick; /* the node's tick when decay was last applied: the only clock decay reads */
|
||||
uint16_t temperature_q8; /* the heat, smoothed (an EMA), in Q8 */
|
||||
uint8_t state_flags; /* the kernel's own: V4_MESH_STATE_PINNED, _FROZEN */
|
||||
} v4_mesh_account;
|
||||
|
||||
/* A word's state flags, as v3's (PHYSICS_STATE_*): immediate and hidden are the node's (its header's
|
||||
* flags); pinned and frozen are the kernel's, on the record. */
|
||||
#define V4_MESH_STATE_IMMEDIATE 0x01u
|
||||
#define V4_MESH_STATE_PINNED 0x02u
|
||||
#define V4_MESH_STATE_HIDDEN 0x04u
|
||||
#define V4_MESH_STATE_FROZEN 0x10u
|
||||
|
||||
/* Each node's physics (v3's VM fields): its heartbeat's tick, the decay slope (Q48.16 heat a tick;
|
||||
* v3's INITIAL_DECAY_SLOPE_Q48, which the inference engine tunes), and L8's gate on Loop #3. */
|
||||
#define V4_MESH_INITIAL_DECAY_SLOPE_Q48 21845u
|
||||
typedef struct {
|
||||
uint64_t tick;
|
||||
uint64_t decay_slope_q48;
|
||||
uint8_t l3_decay;
|
||||
} v4_mesh_physics;
|
||||
|
||||
typedef struct v4_mesh v4_mesh;
|
||||
struct v4_mesh {
|
||||
/* ---- the owner's: set before v4_mesh_boot ---- */
|
||||
@@ -91,6 +112,7 @@ struct v4_mesh {
|
||||
* bytes, a bit for each address of a node: set for a word's xt (0: none kept) */
|
||||
v4_mesh_account *accounts;
|
||||
unsigned char *is_word;
|
||||
v4_mesh_physics *physics; /* `capacity` of them: each node's (#189, Phase 7) */
|
||||
/* a word has gone, its ID free for the next: the owner forgets what it keeps by it (may be 0) */
|
||||
void (*forgot)(void *self, unsigned place, v4_cell id);
|
||||
void *self;
|
||||
@@ -130,6 +152,9 @@ 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);
|
||||
|
||||
/* A word's state flags (V4_MESH_STATE_*), or 0 if xt is not a word's. */
|
||||
unsigned v4_mesh_state_flags(const v4_mesh *ms, unsigned place, v4_cell xt);
|
||||
|
||||
/* For each word on the node in `place` called since the last charge: `each(ctx, id, calls)`, and its
|
||||
* count since is cleared. */
|
||||
void v4_mesh_charge(v4_mesh *ms, unsigned place, void (*each)(void *ctx, v4_cell id, v4_uheat_t calls), void *ctx);
|
||||
|
||||
Reference in New Issue
Block a user