# Deliberation record: kido-image — closing sched D2 (2026-10-16)

Builder crew (micro-agent circle). Sched deliberation D2 has been open
since session 4 (2026-10-14): the allocator does not know the kernel
image bounds (reserve 0,0), and every boot since has been "safe by
measured layout" (session 8, P3) rather than by design. This session
closes D2 with one small module and one wiring — not five thin pieces.

## Positions

- **P1 (Memory auditor):** one query, no coupling. `kido_image_bounds
  (&base, &size)` is the only new seam: `kido_sched_init` asks,
  `kido_alloc_init` consumes. The allocator's reserve carve-out is
  already real and tested (kido-alloc.c) — zero allocator logic
  changes. No Gate-approved logic file gains new behavior except
  sched_init's reserve arguments.
- **P2 (Linker purist):** symbols are the truth. `_image_start` /
  `_image_end` in kido-link-arm64.ld; the module reads two addresses
  and subtracts. Bare metal gets no test double, no fallback, no
  invention. Inverted bounds (end <= start) mean a mislinked image
  and fail LOUD (KIDO_ERR_EARLY_ENV) — the allocator must never run
  on a mislinked image.
- **P3 (Stack realist):** the boot stack is image. `_image_end` moves
  to AFTER the 16 KiB boot stack — the script now advances `.` through
  it, so the stack is literally inside the loaded binary. Reserving
  16 KiB of 128 MiB forever is honest waste; handing the live boot
  stack to a task would be silent corruption. No consumers of the old
  `_image_end` (end-of-BSS) meaning exist — the change is free
  (C1, verified by grep + symbol comparison).
- **P4 (Hosted honest):** no image, no reservation. Hosted builds have
  no linked kernel image, so an uninjected bounds query refuses with
  KIDO_ERR_STUB_REACHED, and `kido_sched_init` treats that — on
  hosted ONLY — as a vacuous 0,0 reservation. This is declared in the
  design, not a silent fallback: there is no image to protect on
  hosted. The self-test injects a fake image (a slice of the arena)
  to exercise the real carve path honestly.
- **P5 (Harness keeper):** link-at-load becomes law. The symbols are
  absolute to the LINKED base; the script now documents the measured
  2026-10-14 finding (QEMU `-kernel` raw binary loads at RAM+0x80000,
  not RAM_BASE; `-kernel` ELF gives x0=0, no DTB). The harness's
  generated 0x40080000 copy is configuration; the scaffold script
  stays canonical at RAM_BASE. kido-image does NOT detect
  relocation — stated, out of scope (preserved dissent D1).

## Challenges

- **C1 — `_image_end` semantics change (was end-of-BSS).** No code
  consumes the old meaning (grep-verified across modules/); the
  re-proof log's `_image_end` reference was observational, not a
  dependency. The new meaning is documented in the script header.
- **C2 — does advancing `.` through the stack change `_stack_top`?**
  No. Old: `_stack_top = (16-aligned .) + 0x4000`. New:
  `. = . + 0x4000; _stack_top = .` — the identical value. The entry
  .S's SP setup and BSS loop are untouched (verified by comparing
  symbol values pre/post change via readelf on the linked test
  image).
- **C3 — mislinked image.** Answered by P2: EARLY_ENV propagates out
  of `kido_sched_init` before the allocator initializes. Loud, never
  a guessed layout.
- **C4 — the DTB also occupies RAM the allocator must avoid.** Honest
  scope cut: DTB-region trimming belongs to kido-mem's discovery
  output, not to the image module. Recorded as a future item, not
  smuggled into this piece.
- **C5 — resonate's self-test links kido-sched.c → new undefined
  symbol.** Its TESTING build line gains `modules/kido-image.c`
  (one-line comment update, matching the alloc-integration
  precedent). Zero logic changes to kido-resonate.

## Convergence

P1–P5 with C1–C5 answered. Deliverables: `modules/kido-image.h`,
`modules/kido-image.c` (self-test via KIDO_IMAGE_SELFTEST),
kido-link-arm64.ld (`_image_start`, `_image_end` after the stack,
load-address law in the header), `kido-sched.c` (unified init:
bounds query → reserve args), doc updates in kido-sched.h and
kido-alloc.h, one-line TESTING comment in kido-resonate.c, new
section 30+ in the sched self-test (injected-image carve checks).
Conformance: kido.json's "portable and adaptive from the start" and
the scaffold's no-silent-invention law (see
2026-10-16-kido-image-conformance.md). D2 CLOSES. D1
(KIDO_ERR_NO_TASKS) stays N8toriousAi's call.

## Preserved dissent

- **D1:** self-relocation detection (compare linked base against the
  actual PC via `adr`) — overruled. One module, one job: kido-image
  states the link-at-load law; a future kido-reloc module can own
  detection. Half-enforcing it here would blur the seam.
- **D2:** wire the reservation in kido-boot (before sched_init)
  instead of inside `kido_sched_init` — overruled. The
  alloc-sched-integration deliberation already chose "alloc init in
  one place" (sched_init); moving it would touch the Gate-approved
  boot sequence for zero gain.
