From 317466e8f7311389a3432cfd3aa8183ee345d722 Mon Sep 17 00:00:00 2001 From: Neuron Date: Sun, 16 Aug 2026 11:53:31 -0500 Subject: [PATCH] runtime: ground the node asked about, and refuse circular support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit engram_ground_json resolved each seed to a REGION, wrote the grounded-by edge between the two regions' HUBS, and then echoed those hubs back in the "claim"/"evidence" fields as if they were the caller's input: const char* cid = C->hub_id ? C->hub_id : EL_CSTR(claim); const char* eid = E->hub_id ? E->hub_id : EL_CSTR(evidence); cog_ground_edge(g_engram_store, cid, eid, grounding, fw); Three consequences, all measured against a clone of the live store: 1. The edge landed on a node the caller never named. Grounding 3b9ced5d against 6edf8c79 wrote an edge on the hubs of their regions instead. 2. When both seeds resolve into the same region the support is circular and scores near 1.0 for structural reasons, not evidential ones. Four probe nodes written together landed in one region, and every grounding among them returned 0.93-0.99 as if it were evidence. Two independent agents hit this and reported 0.885 / 0.909 self-groundings as confident. 3. The echo concealed both: the response was indistinguishable from a successful grounding of the ids that were passed in. The region is HOW a claim is evaluated; it is not WHAT the claim is about. So the edge now attaches to the requested ids, and the resolved hubs are reported separately as claim_region / evidence_region. Degeneracy is broader than hub == hub. Three circular shapes, all previously invisible: same-region both seeds resolve to one region claim-region-is-evidence the evidence IS the hub of the claim's own neighbourhood — measured at 0.98883 evidence-region-is-claim the mirror case Each sets grounding to 0 and writes no edge. Circular support is not support, and a grounding that is degenerate by construction must not enter the graph as though it were evidence. Verified: 6edf8c79 -> 6edf8c79 degenerate=same-region g=0 written=false 6edf8c79 -> d0406dfd degenerate=same-region g=0 written=false ebc1413e -> 64cc96ef degenerate=false g=0.774563 written=true 64cc96ef -> ebc1413e degenerate=false g=0.802896 written=true Legitimate grounding across distinct regions is unchanged and still writes; only circular support is refused. This is the same class as #142 and #146 — a value that looked like an answer with nothing behind it — except here it was also writing that non-answer into the canonical store. --- lang/runtime/el_runtime.c | 57 ++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/lang/runtime/el_runtime.c b/lang/runtime/el_runtime.c index b8eff06..81829bd 100644 --- a/lang/runtime/el_runtime.c +++ b/lang/runtime/el_runtime.c @@ -14062,12 +14062,57 @@ el_val_t engram_ground_json(el_val_t claim, el_val_t evidence, el_val_t for_whom double grounding = (rc == 0) ? gr.grounding : 0.0; if (rc == 0) engram_verify_grounding_free(&gr); const char* fw = EL_CSTR(for_whom); if (fw && !*fw) fw = NULL; - const char* cid = C->hub_id ? C->hub_id : EL_CSTR(claim); - const char* eid = E->hub_id ? E->hub_id : EL_CSTR(evidence); - int wr = cog_ground_edge(g_engram_store, cid, eid, grounding, fw); - JsonBuf b; jb_init(&b); char t[256]; - snprintf(t, sizeof t, "{\"relation\":\"grounded-by\",\"claim\":\"%s\",\"evidence\":\"%s\",\"for_whom\":\"%s\",\"grounding\":%.6g,\"written\":%s}", - cid, eid, fw ? fw : "-", grounding, wr == 0 ? "true" : "false"); + + /* GROUND THE NODE ASKED ABOUT, AND SAY WHAT WAS RESOLVED (2026-08-16 + * self-review). This wrote the grounded-by edge between the two REGION + * HUBS and then echoed those hubs back in the "claim"/"evidence" fields + * as though they were the caller's input. Three consequences, all measured + * against the live store: + * + * 1. The edge landed on a node the caller never named. Asking to ground + * 3b9ced5d against 6edf8c79 wrote an edge on 6edf8c79 -> d0406dfd, + * because those were the hubs of the two regions. + * 2. When both seeds resolve into the same region, the hubs coincide and + * the call grounds a node against ITSELF, returning grounding = 1 — + * a perfect score with no evidence behind it. Two independent agents + * hit this and reported 0.885 / 0.909 self-groundings as confident. + * 3. The echo concealed both, because the response looked exactly like a + * successful grounding of the ids that were passed in. + * + * The region is HOW a claim is evaluated; it is not WHAT the claim is + * about. So the edge attaches to the requested ids, and the resolved hubs + * are reported separately under claim_region / evidence_region. When the + * two regions coincide, the grounding is degenerate by construction and is + * reported as such rather than as a confident 1.0. */ + const char* cid = EL_CSTR(claim); + const char* eid = EL_CSTR(evidence); + const char* chub = C->hub_id ? C->hub_id : cid; + const char* ehub = E->hub_id ? E->hub_id : eid; + /* Degeneracy is broader than chub == ehub. Three circular shapes, each of + * which yields a high score for structural reasons rather than evidential + * ones, and all three were previously invisible: + * same-region both seeds resolve to one region — grounding a thing + * against itself. + * claim-in-ev the claim's region hub IS the evidence node: the evidence + * sits at the centre of the claim's own neighbourhood. + * ev-in-claim the mirror case. + * Measured: grounding 3b9ced5d against 6edf8c79 scored 0.98883 purely + * because 6edf8c79 is the hub of 3b9ced5d's region. */ + const char* degenerate = NULL; + if (chub && ehub && strcmp(chub, ehub) == 0) degenerate = "same-region"; + else if (chub && eid && strcmp(chub, eid) == 0) degenerate = "claim-region-is-evidence"; + else if (ehub && cid && strcmp(ehub, cid) == 0) degenerate = "evidence-region-is-claim"; + if (degenerate) grounding = 0.0; /* circular support is not support */ + + /* Do not write an edge for a grounding that is degenerate by construction. */ + int wr = degenerate ? -1 : cog_ground_edge(g_engram_store, cid, eid, grounding, fw); + JsonBuf b; jb_init(&b); char t[512]; + snprintf(t, sizeof t, "{\"relation\":\"grounded-by\",\"claim\":\"%s\",\"evidence\":\"%s\"," + "\"claim_region\":\"%s\",\"evidence_region\":\"%s\",\"degenerate\":%s%s%s," + "\"for_whom\":\"%s\",\"grounding\":%.6g,\"written\":%s}", + cid ? cid : "", eid ? eid : "", chub ? chub : "", ehub ? ehub : "", + degenerate ? "\"" : "false", degenerate ? degenerate : "", degenerate ? "\"" : "", + fw ? fw : "-", grounding, wr == 0 ? "true" : "false"); jb_puts(&b, t); engram_geo_free(C); engram_geo_free(E); return el_wrap_str(b.buf);