engram tiered storage: engram-service wiring + elc fold-hang fix + prune-store mirror

- Wire paged store into the ENGRAM SERVICE (server.el, the authoritative durable
  owner): boot->engram_store_boot, persist_canonical->engram_store_checkpoint,
  gated by ENGRAM_STORE.
- elc (lang/elc.c + src/parser.el + codegen.el + elc-combined.el): OOB guard in
  tok_kind/tok_value + parse_block progress backstop — fixes the pre-existing
  unbounded-memory fold hang on sessions.el.
- engram_prune_telemetry mirrors ISE prune to the store (store_forget) so store
  live-count tracks resident and stale telemetry stays bounded.
- Deployed live 2026-08-12: engram :8742 on neuron.egm+WAL, count reconciled 11552.
This commit is contained in:
2026-08-12 14:14:20 -05:00
parent 9a0266cbf9
commit bb64a236ed
7 changed files with 263 additions and 26 deletions
+24
View File
@@ -49,6 +49,21 @@ fn tok_value(tokens: [Any], pos: Int) -> String {
native_list_get(tokens, pos * 2 + 1)
}
// parse_progress_fatal robustness backstop. Called by the token-consuming
// driver loops when they detect they have iterated more times than there are
// tokens (impossible for a well-formed program, where every iteration consumes
// at least one token). Names the offending token and exits non-zero instead of
// looping forever / exhausting memory.
fn parse_progress_fatal(where: String, tokens: [Any], pos: Int) -> Void {
let k: String = tok_kind(tokens, pos)
let v: String = tok_value(tokens, pos)
println("elc: FATAL: parser made no forward progress in " + where
+ " at token index " + native_int_to_str(pos) + " (kind=" + k + ")")
println("elc: likely a malformed construct near '" + v
+ "' — e.g. an unterminated string or an unescaped double-quote inside a string literal (use \\\" ).")
exit(1)
}
fn expect(tokens: [Any], pos: Int, kind: String) -> Int {
let k = tok_kind(tokens, pos)
if k == kind {
@@ -1212,7 +1227,16 @@ fn parse_block(tokens: [Any], pos: Int) -> Map<String, Any> {
let p = expect(tokens, pos, "LBrace")
let stmts: [Map<String, Any>] = native_list_empty()
let running = true
// Runaway backstop: a block can hold at most (token count) statements, since
// every iteration consumes >= 1 token. If we exceed that, the cursor has run
// off the end without terminating (malformed input) -> fail fast, don't hang.
let blk_total: Int = native_list_len(tokens) / 2
let blk_iters: Int = 0
while running {
let blk_iters = blk_iters + 1
if blk_iters > blk_total + 8 {
parse_progress_fatal("parse_block", tokens, p)
}
let k = tok_kind(tokens, p)
if k == "RBrace" {
let running = false