strip the compile-time machinery the seam replaces

PREDICTION: codegen.el drops below 4661, its size before any of these passes.
RESULT: FALSE. 5157 -> 5096. Still +435 over baseline.

  injects_at_entry   collapsed into the seam            removed
  guards_at_entry    collapsed into the seam            removed
  injects_at_exit    needs the body-helper wrapper      STRUCTURAL
  wraps_body         needs the closure + wrapper        structural
  prohibits_outside  a #error cannot be emitted at runtime

The wrapper is not a consequence of compile-time resolution. Early returns must
be routed through something no matter when the target is resolved, so exit
injection was never going to collapse. I predicted it would because I had
conflated "resolved late" with "emitted less".

What did collapse is entry injection and refusal -- 61 lines of compiler
replaced by one refusable indirection, with the capability now bindable after
the binary exists.

8 tests fail, and they are exactly the 8 controls for compile-time entry
injection and guards. No unrelated breakage: the controls reported precisely
what moved. They assert emission of something that now happens at runtime, so
they need rewriting as integration tests -- which the framework does not
currently support, because runtime binding needs a built binary and an
environment, not compile_capture.

Verified after the strip: fixpoint gen2==gen3, observation and refusal both
work through the seam with the compiler knowing nothing about either.
This commit is contained in:
bigmerge
2026-08-17 08:43:57 -05:00
parent 886626a64e
commit 28d19da7f1
+4 -65
View File
@@ -3205,38 +3205,11 @@ fn fn_has_decorator(stmt: Map<String, Any>, name: String) -> Bool {
// applies both); injection is topmost-wins, matching the VBD role convention,
// because a role is singular and a refusal is not.
fn cg_entry_seam(stmt: Map<String, Any>, fn_name: String) -> Void {
// RUNTIME SEAM: codegen cannot know which constructs will be bound to this
// fn after the binary exists, so the indirection is unconditional. What
// applies is resolved at execution against a table written later.
// The crossing is resolved at EXECUTION. One refusable indirection replaces
// the compile-time guard loop and injection loop: which constructs apply,
// and whether any of them refuses, is read from a table written after the
// binary exists.
emit_line(" { el_val_t __s = el_seam_run(EL_STR(" + c_str_lit(fn_name) + "), 0, 0); if (__s) return __s; }")
let gdl = stmt["decorators"]
let n_gdl: Int = native_list_len(gdl)
let gi = 0
while gi < n_gdl {
let gd = native_list_get(gdl, gi)
let gdn: String = gd["name"]
let g_target: String = decorator_guard(gdn)
if !str_eq(g_target, "") {
emit_line(" { el_val_t __g = " + g_target + "(EL_STR(" + c_str_lit(fn_name) + "), EL_STR(" + c_str_lit(gdn) + ")); if (__g) return __g; }")
}
let gi = gi + 1
}
let idl = stmt["decorators"]
let n_idl: Int = native_list_len(idl)
let di = 0
let did_inject: Bool = false
while di < n_idl {
if !did_inject {
let dd = native_list_get(idl, di)
let ddn: String = dd["name"]
let inj_target: String = decorator_injection(ddn)
if !str_eq(inj_target, "") {
emit_line(" " + inj_target + "(EL_STR(" + c_str_lit(fn_name) + "), EL_STR(" + c_str_lit(ddn) + "));")
let did_inject = true
}
}
let di = di + 1
}
}
// cg_exit_target / cg_exit_construct the first construct on this fn that
@@ -4310,13 +4283,7 @@ fn program_has_routes(recs: [Map<String, Any>]) -> Bool {
// inside this boundary" is a query over program structure and there is nothing
// yet to ask.
fn declare_decorator(name: String, injects: String) -> Void {
state_set("__dec_inject_" + name, injects)
}
fn decorator_injection(name: String) -> String {
state_get("__dec_inject_" + name)
}
// A GUARD is an injection that may refuse. The declared target is called at
// entry with the same (fn, construct) pair; a non-zero return short-circuits
@@ -4333,13 +4300,7 @@ fn decorator_injection(name: String) -> String {
// nothing fourteen applications that read as protection and emitted no
// instruction. The compiler still knows nothing about authentication: the
// program points the construct at its own function.
fn declare_guard(name: String, guards: String) -> Void {
state_set("__dec_guard_" + name, guards)
}
fn decorator_guard(name: String) -> String {
state_get("__dec_guard_" + name)
}
// An EXIT injection runs after the fn returns and receives the result:
// target(<fn>, <construct>, <result>)
@@ -4419,14 +4380,8 @@ fn prohibiting_constructs() -> String {
// the streaming backend discards per-fn ASTs and there is no whole-program AST
// to walk.
fn scan_declared_decorators(tokens: [Any]) -> Void {
declare_decorator("manager", "engram_boundary_beat")
declare_decorator("accessor", "engram_boundary_beat")
declare_prohibition("manager", "dharma_emit,dharma_field")
let total: Int = native_list_len(tokens) / 2
let has_pending: Bool = false
let pending_target: String = ""
let has_pending_g: Bool = false
let pending_guard: String = ""
let has_pending_x: Bool = false
let pending_exit: String = ""
let has_pending_w: Bool = false
@@ -4471,14 +4426,6 @@ fn scan_declared_decorators(tokens: [Any]) -> Void {
if str_eq(dname, "decorator") {
if native_list_len(args) >= 2 {
let dkind: String = native_list_get(args, 0)
if str_eq(dkind, "injects_at_entry") {
let has_pending = true
let pending_target = native_list_get(args, 1)
}
if str_eq(dkind, "guards_at_entry") {
let has_pending_g = true
let pending_guard = native_list_get(args, 1)
}
if str_eq(dkind, "injects_at_exit") {
let has_pending_x = true
let pending_exit = native_list_get(args, 1)
@@ -4497,14 +4444,6 @@ fn scan_declared_decorators(tokens: [Any]) -> Void {
} else {
if str_eq(k, "Fn") {
let fname: String = tok_value(tokens, pos + 1)
if has_pending {
declare_decorator(fname, pending_target)
let has_pending = false
}
if has_pending_g {
declare_guard(fname, pending_guard)
let has_pending_g = false
}
if has_pending_x {
declare_exit(fname, pending_exit)
let has_pending_x = false