# Deliberation record: QEMU execution proof of the reserved tree (2026-10-16)

Builder crew (micro-agent circle). Session 10 closed sched D2 with
kido-image: the allocator now reserves the kernel-image bounds
(`_image_start`/`_image_end`, boot stack included) from linker
symbols, fed through `kido_alloc_init`'s reserve carve-out. The
session-10 ledger left one open item: "bare-metal execution of the
reserved tree is queued for the next QEMU session (assembled +
linked + symbol-verified, not yet executed)". This session is that
verification. No new module, no source changes — pristine scaffold
sources throughout.

## Positions

- **P1 (Verifier):** the delta under test is strictly the
  reservation path: `kido_sched_init` -> `kido_image_bounds`
  (bare-metal branch, linker symbols) -> `kido_alloc_init` with
  (img_base, img_size) reserve. Everything else on this path is
  already proven (QEMU multitask proof 2026-10-14; allocator-tree
  re-proof 2026-10-15). The acceptance bar is the session-8 bar,
  unchanged, plus the reservation criterion: the console must reach
  `kido_main: 3 tasks created`, which it cannot do unless the bounds
  query returned OK from real symbols (a mislinked image halts LOUD
  at `sched_init` with EARLY_ENV, before any task exists).
- **P2 (Harness keeper):** reuse the proven recipe exactly. Raw
  binary via `-kernel` (x0 = DTB; the ELF path gives x0 = 0),
  harness-only /tmp copy of `kido-link-arm64.ld` at 0x40080000, the
  scaffold script untouched (its header now states the load-address
  law, so the copy's only diff is the RAM_BASE line). Image = entry
  .S/.c, boot, hal-arm64, mem, alloc, sched, sched-arm64.S,
  image — 9 TUs, cross-compiled `-ffreestanding -O0 -Wall
  -Wextra -Werror`, zero warnings. resonate/interop not linked
  (not in the boot path; the proof measures the delta).
- **P3 (Memory auditor):** with the carve active, first-fit must
  place the three 16 KiB stacks (plus 32-byte headers) below the
  carved image at [0x40080000, _image_end). Geometry: region =
  0x40000000 + 128 MiB (measured session 5 vs the real virt DTB);
  allocator builds its free list from the region base; the reserve
  splits off the image range; first-fit allocates low->high below
  it. Any stack overlapping .text/.rodata corrupts live code and
  produces exceptions — zero exceptions under `-d int` plus a clean
  `ABCABCABCABC` interleave (the assembled switch EXECUTED on those
  stacks) is the bare-metal non-overlap evidence. The exact carve
  geometry is pinned by the hosted injected-image test (same
  kido-alloc.c source) — sections 30-39 of the sched self-test.
- **P4 (Constraint ledger):** pristine-source discipline forbids
  adding stack-address prints to the console path (task bodies emit
  only their marks). Therefore the bare-metal run cannot *print*
  the allocated stack addresses. The chain is stated, not
  hand-waved: (a) readelf proves the image bounds from the linked
  image; (b) hosted injection proves the carve rule of the same
  .c code; (c) zero-exception clean interleave proves no
  corruption happened. No claim is made beyond what the chain
  supports.
- **P5 (Regression keeper):** run the full hosted self-test suite
  BEFORE QEMU: image 9/9, sched 64/64, alloc 31/31, mem ALL,
  resonate 59/59, hal 7/7, entry 5/5, boot integration (rc 0,
  AAAABBBBCCCC). Any failure gates the QEMU run — a red hosted
  suite invalidates the proof.

## Challenges

- **C1:** does linking 9 TUs change what session 8 proved? No —
  the only delta since the accepted re-proof is kido-image.c (one
  query, two symbol reads) plus sched_init's reserve arguments.
  The boot path is otherwise byte-for-byte the proven tree.
- **C2:** is the hosted vacuity path a risk to the bare-metal
  run? No: the STUB_REACHED -> vacuous 0,0 branch is `#ifdef
  KIDO_HOSTED_TEST`-guarded; the bare-metal image never compiles
  it. Bare metal reads symbols or dies loud. (Verified by the
  acceptance criterion in P1.)
- **C3:** QEMU's `-d int` and the timeout. Session-6/8 recipe:
  `timeout 6` -> exit 124 is the expected terminator (the kernel
  spins in the designed loud-halt on the emptied queue). `-d int`
  writes to a separate log file; empty of exceptions = pass.
- **C4:** does the /tmp linker copy's RAM_BASE edit risk a stale
  canonical script? No: generate the copy by sed on the RAM_BASE
  *definition line only*, diff against the scaffold file after the
  run to prove the canonical script is byte-identical. The copy is
  harness configuration, same as sessions 6 and 8.

## Convergence

P1–P5 with C1–C4 answered. Deliverables: this deliberation record,
the QEMU console log
(`deliberations/2026-10-16-qemu-reserved-proof.log`), a ledger
entry, and a module-map note. Expected console: breath ->
`arch: arm64` -> `kido_main: scheduler init` -> `3 tasks created`
-> `entering scheduler` -> `ABCABCABCABC` -> timeout 124, zero
exceptions. Success also closes session 10's last remains item
(bare-metal execution of the reserved tree).

## Preserved dissent

- **D1:** stack addresses are not printed on bare metal (P4). A
  future `kido-debug` console verb could emit the allocator's
  address map — out of scope here; adding prints now would violate
  the pristine-source rule.
- **D2:** KIDO_ERR_NO_TASKS dedicated code still N8toriousAi's call —
  the empty-queue halt still maps to KIDO_ERR_STUB_REACHED.
- **D3:** DTB-region trim (kido-mem's future) and relocation
  detection (future kido-reloc) remain open; the reserved tree is
  safe by design for the image, by measured layout for the DTB.

## Addendum: harness link order (the first attempt died here)

The first QEMU run of this session produced an Undefined Instruction
storm at PC 0x200 with a silent console — a HARNESS bug, not a kernel
bug. The link used shell glob order (`*.o`), so `alloc.o`'s `.text`
landed at 0x40080000 ahead of `_start`; QEMU `-kernel` with a raw
binary jumps to the LOAD ADDRESS (0x40080000), not the ELF ENTRY.
It executed kido-alloc's code bytes as the entry point and faulted.
Fix: link `entry.o entry-c.o` FIRST, so `_start == _image_start ==
0x40080000` (readelf-verified). The recipe going forward: the two
entry objects always lead the link line.
