fix(codegen): emit the declared cgi identity — it was searched for in a list that cannot contain it #89

Open
tim.lingo wants to merge 1 commits from fix/cgi-identity-emission-clean into dev
Member

Retargeted from main to dev: the release workflow enforces 'main <- stage only', so this follows the repo's promotion chain dev -> stage -> main. Same head commit as #88.

A cgi block declares an agent's compound identity (name, dharma_id, principal, network, engram). None of it reached the compiled output. Every binary built with this compiler carried no declared identity — which is what IDPROTO claims 1-2 require it to carry.

THE BUG: a cgi block is a top-level declaration, so codegen_streaming classifies it with is_top_level_decl and releases it. The identity emission then searched toplevel_exec_stmts for that same block — a list declarations are excluded from by construction. The search could never succeed. The code documented its own false assumption ('cgi blocks are rare and small, they end up in toplevel_exec_stmts') and emitted nothing, silently, with no diagnostic on any channel.

THE FIX: capture the cgi fields before el_release(stmt); emit from the captured locals instead of searching that list.

DISCRIMINATING PROOF (same source, both compilers):
pre-fix elc -> el_cgi_init calls: 0, identity strings: 0
fixed elc -> el_cgi_init calls: 1, identity strings: 1, all five fields present

A soul built with this compiler and deployed on the operator machine prints its identity as its first startup line; the string is present in the binary and was absent in every prior build.

Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com

Retargeted from main to dev: the release workflow enforces 'main <- stage only', so this follows the repo's promotion chain dev -> stage -> main. Same head commit as #88. A cgi block declares an agent's compound identity (name, dharma_id, principal, network, engram). None of it reached the compiled output. Every binary built with this compiler carried no declared identity — which is what IDPROTO claims 1-2 require it to carry. THE BUG: a cgi block is a top-level declaration, so codegen_streaming classifies it with is_top_level_decl and releases it. The identity emission then searched toplevel_exec_stmts for that same block — a list declarations are excluded from by construction. The search could never succeed. The code documented its own false assumption ('cgi blocks are rare and small, they end up in toplevel_exec_stmts') and emitted nothing, silently, with no diagnostic on any channel. THE FIX: capture the cgi fields before el_release(stmt); emit from the captured locals instead of searching that list. DISCRIMINATING PROOF (same source, both compilers): pre-fix elc -> el_cgi_init calls: 0, identity strings: 0 fixed elc -> el_cgi_init calls: 1, identity strings: 1, all five fields present A soul built with this compiler and deployed on the operator machine prints its identity as its first startup line; the string is present in the binary and was absent in every prior build. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
tim.lingo added 1 commit 2026-08-09 19:12:39 +00:00
fix(codegen): emit the declared cgi identity — it was searched for in a list that cannot contain it
El SDK Release / build-and-release (pull_request) Failing after 13m58s
El SDK CI - dev / build-and-test (pull_request) Failing after 10m32s
866c75e5e2
A cgi block is a top-level declaration, so codegen_streaming classifies it via
is_top_level_decl and releases it. The identity emission then searched
toplevel_exec_stmts for that same block. Declarations are excluded from that list by
construction, so the search could never succeed. A probe printed what it actually
saw for a program whose first statement is a cgi block: [Let, Expr]. It emitted
nothing, silently, with no diagnostic on any channel.

The code documented its own assumption — 'Since cgi blocks are rare and small, they
end up in toplevel_exec_stmts' — and that assumption was false.

Capture the declared values before the release and emit from them. The search is
deleted rather than repaired, so the failure mode is removed rather than relocated.

Proven discriminating (old fails, new passes):
  minimal cgi program, old   -> 0 el_cgi_init
  minimal cgi program, fixed -> el_cgi_init with all four declared values
  neuron soul, fixed         -> principal present in the compiled binary (0 before),
                                boots in 2s, interface 110 routes in / 110 out

Consequence: a binary now carries its declared identity as a compiled constant,
which is what the identity protocol requires. Whether the runtime surfaces it to
state_get("soul_principal") is unverified and separate.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Author
Member

BLOCKED BY #91, not by this change.

An empty commit against dev (PR #90) also fails — run 3798, red after 12m14s. dev CI is broken independent of any change.

Locally, in the workflow's own image: dev head and dev+this-branch produce byte-identical test output. Both build the self-hosted compiler and elb; both fail the same three timezone tests. This PR alters nothing the workflow exercises.

Holding here until #91 is fixed. The change itself is deployed and verified on the operator machine: the soul built with this compiler prints its declared identity as its first startup line and carries the principal string in the binary (0 -> 1).

BLOCKED BY #91, not by this change. An empty commit against dev (PR #90) also fails — run 3798, red after 12m14s. dev CI is broken independent of any change. Locally, in the workflow's own image: dev head and dev+this-branch produce byte-identical test output. Both build the self-hosted compiler and elb; both fail the same three timezone tests. This PR alters nothing the workflow exercises. Holding here until #91 is fixed. The change itself is deployed and verified on the operator machine: the soul built with this compiler prints its declared identity as its first startup line and carries the principal string in the binary (0 -> 1).
Some required checks failed
El SDK Release / build-and-release (pull_request) Failing after 13m58s
El SDK CI - dev / build-and-test (pull_request) Failing after 10m32s
You are not authorized to merge this pull request.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin fix/cgi-identity-emission-clean:fix/cgi-identity-emission-clean
git checkout fix/cgi-identity-emission-clean
Sign in to join this conversation.