# Spec conformance — kido-mem (2026-10-14, third scaffold session)

Checked against kido.json (Kido: portable and adaptive from birth;
compensates BUBO's x86-bound heritage; unknown arch is a compile-time
error) and the kido_bootinfo_t contract in kido-hal-arm64.h.

## kido.json conformance
1. **Portable from birth — MET.** The parser is arch-independent C:
   manual big-endian loads, no inline asm, no libc in the parser
   itself (tiny local string helpers). It compiles and runs on the
   dev host exactly as it will on bare metal.
2. **Adaptive, never assumes — MET.** Memory comes from the firmware
   DTB at boot, never from compile-time constants. QEMU 'virt' layout
   is the first tested shape, not a baked-in assumption.
3. **Unknown arch is a compile-time error — MET by inclusion.**
   kido-mem.h includes kido-hal-arm64.h, which carries the arch
   discipline (refuses unknown arch without KIDO_HOSTED_TEST).
4. **Loud failures, no silent corruption — MET.** All discovery
   failures return KIDO_ERR_NO_MEMORY with mem_valid=0; the HAL probe
   fails loud downstream. Interior /memreserve/ fails loud rather
   than handing the allocator a region with a hole.

## bootinfo contract conformance (kido-hal-arm64.h)
5. **Fills exactly what probe() consumes — MET.** mem_base/mem_size/
   mem_valid written by kido_mem_discover(); board_id untouched
   (the shim's call, documented). Probe's `mem_valid==0 -> STUB`
   discipline is preserved: every failure path leaves mem_valid=0.
6. **Entry-shim call order — MET by documentation.** Header documents:
   shim gets DTB pointer from firmware (x0) -> kido_mem_discover()
   -> bi to kido_hal_arm64_probe(). The sibling shim builder works
   against this same documented order.
7. **Bounded, no allocation at discovery — MET.** Region table capped
   at 8, reservations at 8, walk depth at 16, cells at 4. Discovery
   never allocates; the region seed list is a static table.

## Deferred (declared, not hidden)
- UEFI memory-map discovery: loud STUB (KIDO_ERR_STUB_REACHED).
- The allocator itself: seed list exposed, allocator not written.
- Interior-reservation carving: fails loud today; relaxes when the
  allocator module implements real carving (recorded in D2).

## Test evidence
- gcc -std=c11 -Wall -Wextra -Werror -fsyntax-only: PASS, zero warnings.
- Self-test binary (synthetic DTB bytes, real parser): 21 checks,
  ALL PASS — valid multi-region DTB (largest wins, both in seed list),
  corrupt magic, truncation, NULL guards, no-memory-node, disabled
  node, reserved-memory exclusion, device_type identification,
  leading-reservation trim, interior-reservation loud failure,
  UEFI stub loudness.

**Result: 7 MET, 0 PARTIAL, 3 DEFERRED (all declared).**
