bacaf3d39c
El SDK CI - dev / build-and-test (pull_request) Failing after 4m49s
Lands feat/reframe-region-setop (PR #109: native set-based reframe_region, decorator-as-seam @route port, teacher-summon, and the M8.1 activate-latency work — lazy-memoized cosq via eg_cosq_at + engram_vindex HNSW-accelerated seed discovery + vindex_harvest_from_store/vindex_bench oracle) onto dev's actual current HEAD, plus engram-tiered-storage's still-unique test suite. RECONCILING #109 WITH engram-tiered-storage (M4-M10 HNSW/geometry/reason/ verify work): not a two-way merge. engram_vindex.c's HNSW core (search_layer/ select_neighbors/prune_links/insert) is BYTE-IDENTICAL between the two branches; #109's copy is a strict superset (adds vindex_harvest_from_store, used by vindex_bench.c's brute-force-vs-HNSW oracle). engram_reason.c and engram_verify.c are also byte-identical. #109's own branch point already carried engram-tiered-storage's M4-M10 lineage forward, so there was nothing left to merge into #109 for those files. The one thing engram-tiered-storage had that #109's tree dropped: its full test suite (test_vindex.c, test_geometry.c, test_reason.c, test_verify.c, test_m7_traversal.c, the interoception P0-P5 tests, bufpool/compaction tests, and their run_*.sh harnesses) — ported over here unchanged. WHY THIS NEEDED HAND RECONCILIATION, NOT A MECHANICAL MERGE: #109's branch forked from dev on 2026-08-14 15:40 (before restructure-adjacent history diverged the file's merge-base for `git merge` — it presented as an add/add conflict). A straight two-dot diff (dev tip -> PR tip) applied cleanly, but it silently reverted THREE dev fixes landed on 2026-08-14/15, after the branch point, that the PR's diff had no way to know about: 1. qgate rescale (2026-08-14 self-review): PR's lazy eg_cosq_at rewrite of the query-aware propagation gate dropped the shift-and-floor rescale about ENGRAM_EMBED_S0 (measured: unrelated-pair median 0.562->raw gate 0.67, i.e. "a small tax, not a gate"). Restored the rescale, wrapped around the lazy accessor -- the PR's actual improvement (WHEN cosq[oi] is computed) is orthogonal to WHAT it gates on and both are kept. 2. Eviction cause decomposition (2026-08-14 self-review): dev decomposes wm_evicted into evict_floor/evict_cap/evict_bll so WM churn is diagnosable (identity: evicted == floor+cap+bll+dup_wm+dup_wm_global). PR's tree predates this and dropped all three counters + their JSON stats fields. Restored declarations, all 4 direct increment sites, the eg_wm_carry_over bll increment, and the act-stats JSON fields -- alongside (not instead of) the PR's own P4 afferent / API-reshape counters already in that same struct/JSON. 3. Hebbian link-formation selection (2026-08-15 self-review, TODAY): dev selects the STRONGEST qualifying candidate for consolidation each call; PR's tree predates this and reverted to hash-slot order (arbitrary wrt association strength) for edge formation -- the one path that writes PERMANENT structure. Restored the strongest-candidate while-loop, keeping the PR's own genuine improvement at that site (engram_adj_on_edge_added incremental-index append instead of a bare adj_dirty=1 full-rebuild flag). engram/src/server.el's 3-way conflicts (autoconnect_on/ise_offgraph_on env flags, /api/nodes connected-count in responses) were pure additive: dev's side was empty, PR's side added the feature. Took PR's side whole. VERIFIED (nsbx sandbox only, live :8742/:7770 never touched): - cc -std=c11 -O2, clean link against the real engram/src/server.el via elc, zero errors. - vindex_bench (built standalone, read-only harvest) against the real production store clone (13,671 embedded nodes, 768-dim nomic-embed-text): recall@10 = 1.0000 at ef 64/128/200; HNSW search 0.28-0.79ms/query vs 2.03ms/query brute-force oracle (2.6x-7.2x). HNSW build itself: 46.5s for the full 13,671-node set -- see the flagged risk below. - Booted the reconciled binary in an isolated nsbx sandbox (:8905, cloned snapshot of the live store, 13,424 nodes / 37,656 edges) and called /api/activate for real: first call after boot 41.5s (pays the one-time HNSW build inline -- matches the standalone bench), second/third calls 356ms/605ms, no crash, correct results, act-stats JSON (including the restored evict_floor/cap/bll fields) reads correctly. KNOWN RISK TO FLAG BEFORE ANY LIVE CUTOVER (not fixed here; out of scope for this dev-only land per instructions not to touch :8742/:7770): eg_vindex_sync builds the HNSW index synchronously, inline, on the first engram_activate() call after every process start (or index invalidation). On the real node count that is a ~46s blocking stall on a single-threaded server -- the first request after every restart (or its concurrent siblings) waits the full build. Recommend a background/incremental build (or a bounded per-call build budget) before this ever reaches the live daemon. See PR description / final report for the fuller writeup.
125 lines
6.5 KiB
C
125 lines
6.5 KiB
C
/* test_interoception_p1_consol.c — M-INTEROCEPTION Priority 1.
|
|
* Two-threshold consolidation (ENGRAM_CONSOLIDATION, default OFF).
|
|
*
|
|
* Modes:
|
|
* accrual — flag OFF (pure trunk). Drive N co-activations of a WIRED pair and
|
|
* print act-stats at sampled N so the run script can plot the
|
|
* hebb accrual curve (headline measurement). No consolidation code
|
|
* runs; this measures the EXISTING EWMA accrual.
|
|
* connect — flag ON. Seed, activate to populate WM, then create a STRONG ISE
|
|
* (connects to wm_top) and a WEAK ISE (below the bar → nothing).
|
|
* Exports the graph so edges from each ISE can be counted.
|
|
* perm — flag ON. Load two OLD InternalStateEvent nodes; promote one to
|
|
* permanence; prune telemetry; export so the durable one is shown
|
|
* to survive while the ephemeral one is swept.
|
|
* offcheck — flag OFF. Prove creating an ISE forms NO edges and
|
|
* engram_consolidate_permanence is a no-op (byte-identical OFF path).
|
|
*/
|
|
#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); }
|
|
|
|
static void build_seed(void){
|
|
el_val_t a = engram_node_full(S("hebbian potentiation strengthens co-active memory links"),
|
|
S("Concept"), S("hebb-a"), F(0.9), F(0.85), F(1.0), S("Semantic"),
|
|
S("hebbian,memory,activation"));
|
|
el_val_t b = engram_node_full(S("co-active memory links accrue hebbian associative weight"),
|
|
S("Concept"), S("hebb-b"), F(0.9), F(0.85), F(1.0), S("Semantic"),
|
|
S("hebbian,memory,weight"));
|
|
el_val_t c = engram_node_full(S("unrelated culinary recipe for sourdough bread"),
|
|
S("Fact"), S("distractor-1"), F(0.4), F(0.4), F(1.0), S("Semantic"), S("food"));
|
|
el_val_t d = engram_node_full(S("the weather forecast predicts rain tomorrow afternoon"),
|
|
S("Fact"), S("distractor-2"), F(0.4), F(0.4), F(1.0), S("Semantic"), S("weather"));
|
|
engram_connect(a, b, F(0.8), S("associate"));
|
|
engram_connect(a, c, F(0.3), S("associate"));
|
|
engram_connect(b, d, F(0.3), S("associate"));
|
|
}
|
|
static const char* QUERY =
|
|
"hebbian potentiation co-active memory links associative weight";
|
|
|
|
int main(int argc, char** argv){
|
|
if (argc < 3){ fprintf(stderr,"usage: %s <accrual|connect|perm|offcheck> <dir>\n",argv[0]); return 2; }
|
|
const char* mode = argv[1];
|
|
const char* dir = argv[2];
|
|
char p[1024];
|
|
|
|
if (!strcmp(mode,"accrual")){
|
|
build_seed();
|
|
int samples[] = {1,10,50,100,250,500,1000,1625,2000,2500,3000};
|
|
int ns = (int)(sizeof samples/sizeof samples[0]);
|
|
int NMAX = samples[ns-1];
|
|
int si = 0;
|
|
for (int n=1; n<=NMAX; n++){
|
|
engram_activate_json(S(QUERY), (el_val_t)3);
|
|
if (si<ns && n==samples[si]){
|
|
printf("SAMPLE %d %s\n", n, EL_CSTR(engram_act_stats_json()));
|
|
si++;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
if (!strcmp(mode,"connect")){
|
|
build_seed();
|
|
engram_activate_json(S(QUERY), (el_val_t)3);
|
|
long long e_before = (long long)(int64_t)engram_edge_count();
|
|
/* STRONG ISE — should connect to wm_top */
|
|
el_val_t ise_strong = engram_node_full(S("strong internal state: focused on hebbian consolidation"),
|
|
S("InternalStateEvent"), S("ise-strong"), F(0.9), F(0.8), F(1.0), S("Working"), S("ise"));
|
|
long long e_after_strong = (long long)(int64_t)engram_edge_count();
|
|
/* WEAK ISE — below the connection bar (salience 0.3 < default 0.6) */
|
|
el_val_t ise_weak = engram_node_full(S("weak internal state: idle drift"),
|
|
S("InternalStateEvent"), S("ise-weak"), F(0.3), F(0.3), F(1.0), S("Working"), S("ise"));
|
|
long long e_after_weak = (long long)(int64_t)engram_edge_count();
|
|
printf("ISE_STRONG_ID %s\n", EL_CSTR(ise_strong));
|
|
printf("ISE_WEAK_ID %s\n", EL_CSTR(ise_weak));
|
|
printf("EDGES before=%lld after_strong=%lld after_weak=%lld\n",
|
|
e_before, e_after_strong, e_after_weak);
|
|
snprintf(p,sizeof p,"%s/connect.json",dir);
|
|
el_val_t g = engram_save(S(p)); (void)g;
|
|
return 0;
|
|
}
|
|
|
|
if (!strcmp(mode,"perm")){
|
|
/* Two OLD ISE nodes (created_at far in the past → prunable at 48h). */
|
|
snprintf(p,sizeof p,"%s/seed.json",dir);
|
|
FILE* f=fopen(p,"w");
|
|
fprintf(f,"{\"nodes\":["
|
|
"{\"id\":\"ise-durable\",\"content\":\"promoted internal state\",\"node_type\":\"InternalStateEvent\","
|
|
"\"label\":\"ise-durable\",\"salience\":0.5,\"confidence\":1.0,\"created_at\":1000},"
|
|
"{\"id\":\"ise-ephemeral\",\"content\":\"transient internal state\",\"node_type\":\"InternalStateEvent\","
|
|
"\"label\":\"ise-ephemeral\",\"salience\":0.5,\"confidence\":1.0,\"created_at\":1000}"
|
|
"],\"edges\":[]}");
|
|
fclose(f);
|
|
if(!engram_load(S(p))){ fprintf(stderr,"load failed\n"); return 2; }
|
|
long long n_before = (long long)(int64_t)engram_node_count();
|
|
el_val_t promoted = engram_consolidate_permanence(S("ise-durable"));
|
|
long long removed = (long long)(int64_t)engram_prune_telemetry((el_val_t)0); /* default 48h */
|
|
long long n_after = (long long)(int64_t)engram_node_count();
|
|
printf("PROMOTED %lld\n", (long long)(int64_t)promoted);
|
|
printf("NODES before=%lld after=%lld removed=%lld\n", n_before, n_after, removed);
|
|
printf("DURABLE_NODE %s\n", EL_CSTR(engram_get_node_json(S("ise-durable"))));
|
|
printf("EPHEMERAL_NODE %s\n", EL_CSTR(engram_get_node_json(S("ise-ephemeral"))));
|
|
return 0;
|
|
}
|
|
|
|
if (!strcmp(mode,"offcheck")){
|
|
build_seed();
|
|
engram_activate_json(S(QUERY), (el_val_t)3);
|
|
long long e_before = (long long)(int64_t)engram_edge_count();
|
|
engram_node_full(S("strong internal state with flag OFF"),
|
|
S("InternalStateEvent"), S("ise-off"), F(0.9), F(0.8), F(1.0), S("Working"), S("ise"));
|
|
long long e_after = (long long)(int64_t)engram_edge_count();
|
|
el_val_t perm = engram_consolidate_permanence(S("ise-off"));
|
|
printf("OFF edges before=%lld after=%lld perm_ret=%lld\n",
|
|
e_before, e_after, (long long)(int64_t)perm);
|
|
return (e_before==e_after && (int64_t)perm==0) ? 0 : 1;
|
|
}
|
|
|
|
fprintf(stderr,"unknown mode %s\n",mode); return 2;
|
|
}
|