Files
el/engram/test/test_interoception_p4_afferent.c
T
will.anderson 65ca0a3253 M-INTEROCEPTION P4: afferent input counters in act-stats (additive observability)
Extends engram_act_stats_json with five monotonic counters for the raw incoming
signals the mind receives — aff_activations (spreading activations run),
aff_queries (activate_json entries), aff_node_creates, aff_ise_ingests (ISE
nodes), aff_edge_creates. Module-scope statics incremented at the entry points,
emitted via the existing act-stats mechanism and rotated with it — MEASURED, and
never accreted as memory nodes. Process-lifetime totals, reset on restart like
the other _eg_act_* gauges. Additive JSON fields (backward-compatible); no graph
behavior changes. act-stats buffer grown 896->1088 to hold them.

MEASURED on a copy: after 5 node creates (2 ISE), 2 edge creates, then 4+3
queries — counters read exactly node_creates=5, ise_ingests=2, edge_creates=2,
queries=activations=4 then 7; create counters unchanged by queries; queries
strictly monotonic across readings. ASan+UBSan clean.
2026-08-12 23:47:43 -05:00

36 lines
1.8 KiB
C

/* test_interoception_p4_afferent.c — M-INTEROCEPTION Priority 4.
* Afferent input counters in engram_act_stats_json: additive observability.
* Drives KNOWN counts and asserts the emitted counters match and are monotonic.
*/
#include "el_runtime.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static el_val_t S(const char* s){ return EL_STR(s); }
static el_val_t F(double d){ return el_from_float(d); }
int main(void){
/* 3 plain node creates + 2 ISE creates = 5 node_creates, 2 ise_ingests */
el_val_t a=engram_node_full(S("alpha concept about memory and time"),S("Concept"),S("a"),F(0.9),F(0.8),F(1.0),S("Semantic"),S("x"));
el_val_t b=engram_node_full(S("beta concept about memory and links"),S("Concept"),S("b"),F(0.9),F(0.8),F(1.0),S("Semantic"),S("x"));
engram_node_full(S("gamma distractor"),S("Fact"),S("c"),F(0.4),F(0.4),F(1.0),S("Semantic"),S("y"));
engram_node_full(S("heartbeat internal state one"),S("InternalStateEvent"),S("i1"),F(0.5),F(0.5),F(1.0),S("Working"),S("ise"));
engram_node_full(S("curiosity internal state two"),S("InternalStateEvent"),S("i2"),F(0.5),F(0.5),F(1.0),S("Working"),S("ise"));
/* 2 edge creates */
engram_connect(a,b,F(0.8),S("associate"));
engram_connect(b,a,F(0.3),S("associate"));
/* first reading (0 queries so far) */
printf("STATS0 %s\n", EL_CSTR(engram_act_stats_json()));
/* 4 queries -> 4 activations */
for(int i=0;i<4;i++) engram_activate_json(S("memory and time and links"), (el_val_t)2);
printf("STATS1 %s\n", EL_CSTR(engram_act_stats_json()));
/* 3 more queries -> monotonic increase */
for(int i=0;i<3;i++) engram_activate_json(S("memory and time and links"), (el_val_t)2);
printf("STATS2 %s\n", EL_CSTR(engram_act_stats_json()));
return 0;
}