feat(adr0017): cold-image-as-ADR-0014-profile save path Verified
Adds src/cold-image.lisp implementing the cold/restart FUNCLIMG
profile codex specified in step (d): a strict subset of ADR 0014
with exactly three sections — CODE-TEXT, FN-TABLE, METADATA — and
none of the warm-tier machinery (HEAP, PACKAGES, TOPLEVEL,
CODE-MMAP, RELOC). HEAP and TOPLEVEL absence is PROFILE
SEMANTICS, not an accidental omission; startup reconstruction
still runs, the image rides on top of it.
`funcl-cold --save-image PATH` now writes a FUNCLIMG:
+0 magic u64 "FUNCLIMG"
+8 version u32 = 1
+12 arch u32 = 1 (linux-x86-64)
+16 body-size u64
+24 body-sha256 32 bytes (computed over body with this field
zeroed during hash, patched after)
+56 section-count u32 = 3
+60 section table (3 × 40 bytes)
+180 CODE-TEXT running binary bytes via /proc/self/exe
(mem-vaddr = +elf-load-vaddr+)
+N FN-TABLE count + per entry: name-len + name + fn-ptr
drained from *ag-runtime-fn-addrs*
+M METADATA 32-byte build-id = sha256 of the running binary
For step (d) this commit lands SAVE ONLY — the matching --load-
image dispatch lands in the next commit with the integrity
checks (sha256, build-id match, FN-TABLE address-in-CODE-TEXT
validation).
Wiring:
- Makefile: src/cold-image.lisp into COLD_PREFIX between
cold-bootstrap.lisp and cold-loader.lisp.
- src/main-cold.lisp: --save-image PATH dispatch, mirrors the
existing --load-warm shape (null *argv2* → usage error).
- tests/bootstrap.el funcl-cold-image-save-produces-well-formed-
image: parses the saved image, asserts header magic + version
+ arch + body-size + section-count + section types are
exactly {2,4,7} (no HEAP/CODE-MMAP/TOPLEVEL leakage) +
CODE-TEXT mem-vaddr = +elf-load-vaddr+.
Cold binary grows from 1.04M → 1.06M (~20 KiB for the save
infrastructure + flag predicates). Runtime fn-addrs count grew
from 1312 → 1335 from the new defuns.
Verified:
- funcl-cold-image-save-produces-well-formed-image: new test passes
- funcl-{cold,stage1}-self-host-fixed-point: byte-identical
- funcl-cold-loads-warm-bundle: cross-region witness intact
- funcl-warm-bundle-records-cross-region-call: contract test intact
- full suite: only pre-existing
funcl-stage1-supports-package-syntax-phase1 fails (unrelated)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By:
Claude Opus 4.7 (1M context) <noreply@anthropic.com>