chore(engine): make dist/soul.c drift a build failure instead of a silent ship (#133)

#133 regenerated the amalgam once and said so itself: 'Nothing in the tree
regenerates this file. Only a human running the recipe. It lags in batches, never
per-change, and it will drift again.'

It drifted again. Every binary deployed on 2026-08-09 was built by build-soul.sh
from a scratch amalgam that never touches dist/soul.c, so the committed build
input fell 2,761 bytes behind the sources by a different route than #133 describes.

Auto-regeneration is not available: the CI workflow records that elc needs 24GB+
of virtual memory and would OOM the runner. So the build cannot regenerate the
file. It can refuse to compile a stale one, for free and with no compiler.

tools/soulc-stamp.sh records a content fingerprint of every .el source at the
moment the amalgam is generated. --check recomputes and compares; divergence exits
1 and names the changed files and the recipe. Wired into CI ahead of the compile.

dist/soul.c regenerated from current sources: 1,176,361 -> 1,179,122 bytes, 1,247
inlined bodies (gate wants >=1200), and verified to compile clean at 903,552 bytes.

Demonstrated to FAIL on the bad input, per postmortem 0004's rule that a gate which
only passes on good input proves nothing:
  fresh stamp        -> OK,   exit 0
  one .el modified   -> FAIL, exit 1, names memory.el
  source restored    -> OK,   exit 0

Refs #133, #111

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Neuron
2026-08-09 11:32:56 -05:00
parent be0f9d1afe
commit 9fd8c11670
4 changed files with 212 additions and 2 deletions
Generated Vendored
+101 -2
View File
@@ -974,6 +974,10 @@ el_val_t wt_commit(el_val_t id);
el_val_t tier_working(void);
el_val_t tier_episodic(void);
el_val_t tier_canonical(void);
el_val_t mem_assoc_skip_label(el_val_t label);
el_val_t mem_assoc_ok(el_val_t cand_id, el_val_t cand_label, el_val_t self_id);
el_val_t mem_assoc_slot(el_val_t results, el_val_t idx, el_val_t new_id);
el_val_t mem_associate(el_val_t new_id, el_val_t content, el_val_t label);
el_val_t mem_store(el_val_t content, el_val_t label, el_val_t tags);
el_val_t mem_remember(el_val_t content, el_val_t tags);
el_val_t mem_recall(el_val_t query, el_val_t depth);
@@ -25573,6 +25577,97 @@ el_val_t tier_canonical(void) {
return 0;
}
el_val_t mem_assoc_skip_label(el_val_t label) {
if (str_contains(label, EL_STR("state-event"))) {
return 1;
}
if (str_contains(label, EL_STR("soul-response"))) {
return 1;
}
if (str_contains(label, EL_STR("soul-outbox"))) {
return 1;
}
if (str_contains(label, EL_STR("boot_count"))) {
return 1;
}
if (str_contains(label, EL_STR("loop-outcome"))) {
return 1;
}
if (str_contains(label, EL_STR("search-result"))) {
return 1;
}
return 0;
return 0;
}
el_val_t mem_assoc_ok(el_val_t cand_id, el_val_t cand_label, el_val_t self_id) {
if (str_eq(cand_id, EL_STR(""))) {
return 0;
}
if (str_eq(cand_id, self_id)) {
return 0;
}
el_val_t lab = str_lower(cand_label);
if (str_starts_with(lab, EL_STR("self"))) {
return 0;
}
if (str_starts_with(lab, EL_STR("value"))) {
return 0;
}
if (str_contains(lab, EL_STR("values"))) {
return 0;
}
if (str_contains(lab, EL_STR("identity"))) {
return 0;
}
if (mem_assoc_skip_label(cand_label)) {
return 0;
}
return 1;
return 0;
}
el_val_t mem_assoc_slot(el_val_t results, el_val_t idx, el_val_t new_id) {
if (idx >= json_array_len(results)) {
return 0;
}
el_val_t cand = json_array_get(results, idx);
el_val_t cid = json_get(cand, EL_STR("id"));
el_val_t clabel = json_get(cand, EL_STR("label"));
el_val_t ctype = json_get(cand, EL_STR("node_type"));
if (str_eq(ctype, EL_STR("Value"))) {
return 0;
}
if (str_eq(ctype, EL_STR("DharmaSelf"))) {
return 0;
}
if (str_eq(ctype, EL_STR("Safety"))) {
return 0;
}
if (mem_assoc_ok(cid, clabel, new_id)) {
wt_edge(new_id, cid, el_from_float(0.5), EL_STR("related"));
}
return 0;
}
el_val_t mem_associate(el_val_t new_id, el_val_t content, el_val_t label) {
if (str_eq(new_id, EL_STR(""))) {
return 0;
}
if (mem_assoc_skip_label(label)) {
return 0;
}
el_val_t probe = str_slice(content, 0, 400);
el_val_t results = engram_recall_json(probe, 4);
if (str_eq(results, EL_STR(""))) {
return 0;
}
mem_assoc_slot(results, 0, new_id);
mem_assoc_slot(results, 1, new_id);
mem_assoc_slot(results, 2, new_id);
return 0;
}
el_val_t mem_store(el_val_t content, el_val_t label, el_val_t tags) {
el_val_t id = wt_node(content, EL_STR("Memory"), label, el_from_float(0.5), el_from_float(0.5), el_from_float(0.8), EL_STR("Working"), tags);
if (str_eq(id, EL_STR(""))) {
@@ -25580,6 +25675,7 @@ el_val_t mem_store(el_val_t content, el_val_t label, el_val_t tags) {
return EL_STR("");
}
el_val_t durable = wt_commit(id);
mem_associate(id, content, label);
if (durable) {
println(el_str_concat(el_str_concat(el_str_concat(EL_STR("[memory] write persisted at owner: "), id), EL_STR(" label=")), label));
} else {
@@ -29709,7 +29805,9 @@ el_val_t handle_api_begin_session(el_val_t body) {
el_val_t state_events = api_compact_node_array(state_events_raw, 5, 500);
el_val_t recent_raw = engram_scan_nodes_json(10, 0);
el_val_t recent = api_compact_node_array(recent_raw, 10, 240);
return el_str_concat(el_str_concat(el_str_concat(el_str_concat(el_str_concat(el_str_concat(el_str_concat(el_str_concat(el_str_concat(EL_STR("{\"stats\":"), stats), EL_STR(",\"recent\":")), recent), EL_STR(",\"activated\":")), activated), EL_STR(",\"self_neighbors\":[]")), EL_STR(",\"recent_state_events\":")), state_events), EL_STR("}"));
el_val_t self_raw = engram_neighbors_json(EL_STR("kn-efeb4a5b-5aff-4759-8a97-7233099be6ee"), 1, EL_STR("both"));
el_val_t self_slice = api_compact_node_array(self_raw, 24, 240);
return el_str_concat(el_str_concat(el_str_concat(el_str_concat(el_str_concat(el_str_concat(el_str_concat(el_str_concat(el_str_concat(el_str_concat(EL_STR("{\"stats\":"), stats), EL_STR(",\"recent\":")), recent), EL_STR(",\"activated\":")), activated), EL_STR(",\"self_neighbors\":")), self_slice), EL_STR(",\"recent_state_events\":")), state_events), EL_STR("}"));
return 0;
}
@@ -29739,6 +29837,7 @@ el_val_t handle_api_remember(el_val_t body) {
if (!api_persisted(id)) {
return api_not_persisted(id);
}
mem_associate(id, content, EL_STR("memory:remembered"));
return el_str_concat(el_str_concat(EL_STR("{\"id\":\""), id), EL_STR("\",\"ok\":true}"));
return 0;
}
@@ -29830,7 +29929,7 @@ el_val_t handle_api_recall(el_val_t method, el_val_t path, el_val_t body) {
if (str_eq(eff_q, EL_STR(""))) {
return api_or_empty(engram_scan_nodes_json(limit, 0));
}
el_val_t results = engram_search_json(eff_q, limit);
el_val_t results = engram_recall_json(eff_q, limit);
return api_or_empty(results);
return 0;
}