# Kido scaffold ledger

## 2026-10-17 — Session 13: kido-reloc phase 2 — relocation adaptation (builder crew)

**Goal:** build the named phase 2 from session-12 deliberation dissent D1
(delta-aware SP in the entry .S, relocated image bounds, delta-shifted
allocator reservation). One solid piece: the relocation ENVIRONMENT
becomes delta-aware. Execution under relocation is deliberately NOT
this piece.

**Deliberation:** `deliberations/2026-10-17-kido-reloc-adapt-design.md`
(P1 entry realist / P2 linker purist / P3 honesty auditor /
P4 adaptivity advocate (converged) / P5 portability auditor /
P6 test keeper; C1–C6 answered; D1 preserved — execution adaptation
via -fPIE overruled as a different-sized piece, named phase 3).

**Drafted/changed:**
- `modules/kido-entry-arm64.S` — delta measured in registers before SP
  exists (adrp/add runtime vs literal-pool absolute, one probe two
  instruments); SP = _stack_top + delta; x20 (callee-saved) survives
  eret; delta + valid flag stashed in BSS via adrp stores. WRITTEN,
  NOT ASSEMBLED — cross toolchain absent this session (apt main
  mirror unreachable); proof gate queued (readelf ABS64 on the
  literal + disassembly adrp/add), stated not hand-waved.
- `modules/kido-reloc.h` — `kido_reloc_crosscheck()` API; BSS slot
  contract (`kido_reloc_entry_delta/valid`); honesty law rewritten
  (phase 2 = safe environment + loud execution refusal; phase 3 named).
- `modules/kido-reloc.c` — BSS slot definitions; crosscheck (bare
  metal valid==0 = stale .S = loud; hosted valid==0 = vacuous OK);
  verify() = detect + crosscheck + refuse-if-relocated (contract
  unchanged: OK or EARLY_ENV). Self-test 13 → 21 checks.
- `modules/kido-image.h/.c` — NEW `kido_image_actual_bounds()`:
  linked + last-delta (one query, no duplicated truth); size
  invariant; under/overflow → EARLY_ENV loud. `kido_image_bounds()`
  keeps LINKED semantics — detect() uses it (deliberation C1:
  the actual query would double-shift). Self-test 9 → 15 checks.
- `modules/kido-sched.c` — init consumes `kido_image_actual_bounds`;
  the reservation shifts with the image, ZERO allocator changes.
  Self-test 64 → 75 checks (new shifted-carve section 40–49).
- `modules/kido-sched.h` — ALLOCATION LAW: carve is the ACTUAL bounds.
- `modules/kido-entry-arm64.c/.h` — comments only; the wiring line
  `kido_reloc_verify()` is UNCHANGED (phase 2 lives inside verify
  and the .S). Session-12's declared exposure CLOSES.
- `modules/kido-resonate.c` — TESTING build line gains kido-reloc.c.
- `architecture/module-map.md` — reloc row: phase 2 landed.

**Key decisions + why:**
1. Environment adapts, execution refuses (P3/P4 convergence). The image
   is non-PI by the session-12 load-bearing invariant; running
   relocated would corrupt through absolute references. Phase 2 makes
   the REFUSAL safe (real stack) and the books truthful (bounds/carve
   describe the real image) — Kido adapts what it can honestly adapt.
2. One probe, two instruments (P2): the .S reuses `kido_reloc_probe`
   (adrp/add vs literal ABS64); crosscheck treats disagreement as
   instrument fault = EARLY_ENV. Two measurements, one physical fact.
3. Linked/actual split (C1): `kido_image_bounds()` stays LINKED for
   the detector; `kido_image_actual_bounds()` is the new consumer
   query. No circularity, no double-shift.
4. verify()'s contract unchanged — the entry C wiring line didn't
   move. Phase 2 is inside verify() + the .S, not smeared across
   callers.
5. Bare-metal valid==0 is LOUD (stale .S = build inconsistency);
   hosted valid==0 is vacuously OK (no .S exists). Distinguished at
   compile time, never guessed.

**Two real finds during testing:** both self-tests initially failed
because they injected a reloc delta without calling
kido_reloc_detect() — `kido_reloc_last()` is only populated by
detect(), exactly like the real boot order (entry verify runs before
sched_init). The tests were fixed to mirror the entry's call order;
the modules were right. The order is now pinned by test.

**Test results (all real, gcc 13.3.0, -Wall -Wextra -Werror):**
- Syntax, all 9 TUs: PASS, zero warnings.
- reloc 21/21, image 15/15, sched 75/75, alloc 31/31, mem ALL PASS,
  hal PASS, resonate 59/59, interop 75/75, entry PASS,
  boot integration PASS (kido_boot() → 0, AAAABBBBCCCC).
- Honest limits: .S unassembled (no cross toolchain); no QEMU run
  (would need the toolchain; and the supported path is
  definitionally delta-0 — a relocated QEMU run is queued with the
  toolchain as the .S's first execution proof).

**Remains:** D1 KIDO_ERR_NO_TASKS header code (N8toriousAi's call);
kido-reloc phase 3 — PI build + self-relocation (dissent D1, named);
.S assemble + readelf ABS64 + disassembly proof (queued on toolchain);
relocated QEMU execution proof (queued on toolchain); DTB-region trim
(kido-mem's future); destroy API; resonate deferred delivery-at-yield;
real BUBO peer + bare-metal transport (Phase 4); UEFI/RPi4/MMU.
First boot is N8toriousAi's to witness.

## 2026-10-14 — Session 1: kido-boot draft (builder crew)
**Goal:** Draft the Kido boot-sequence module — power-on to first adaptive breath.

**Drafted:**
- `modules/kido-boot.h` — public interface: arch selection (compile-time error on unknown, never silent), status codes, capability struct, HAL function-pointer table, four stage prototypes.
- `modules/kido-boot.c` — four stages: early (BSS/stack sanity) → probe (capability detection) → adapt (driver selection from HAL by caps) → breath (announce + handoff). Hosted test harness (`-DKIDO_HOSTED_TEST`) runs the real stage logic on the dev machine.
- `architecture/module-map.md` — five-module plan: kido-boot → kido-hal → kido-mem → kido-sched → kido-resonate.
- `deliberations/2026-10-14-kido-boot-design.md` — circle record: positions, challenges, convergence, preserved dissent (D1: probe cost vs adaptivity; D2: STUB-error confusion risk).
- `deliberations/2026-10-14-kido-boot-conformance.md` — kido.json line-by-line: 5 MET, 1 PARTIAL (ARM64 bare-metal prober), 2 DEFERRED (doll-layer placement, inter-kernel protocol), 1 MET-by-discipline (no finalized boot without N8toriousAi).

**Key decisions + why:**
1. Portable-first, zero x86-isms in the boot path — compensates BUBO's defining flaw at the source, not as a patch.
2. Probe-before-adapt (not compile-time driver selection) — adaptivity at boot is Kido's spec identity; overruled the leaner two-stage proposal for this reason.
3. Hosted harness proving the stage logic — BUBO's second flaw was untestable-until-hardware; Kido's boot is testable from day one. STUBs are marked, never silent.
4. Loud halt codes, never silent death.

**Test results (ran for real):**
- `gcc -std=c11 -Wall -Wextra -Werror -fsyntax-only`: PASS, zero warnings.
- Full compile + hosted harness run: PASS. Output: early/probe/adapt stages passed; `kido_boot()` returned 5 (KIDO_ERR_HANDOFF) exactly as documented — the handoff to the unwritten `kido_main` refused loudly, which is the honest expected result.

**Remains:**
- Bare-metal entry shims + ARM64 device-tree prober (kido-hal).
- `kido_main` / kernel proper — explicitly NOT written; first boot is N8toriousAi's to witness.
- Inter-kernel protocol (kido-resonate), memory + scheduler modules.
- D1 revisit only with measured boot-time data.

## 2026-10-14 — Session 2: kido-hal-arm64 draft (builder crew)
**Goal:** Draft the Kido ARM64 bare-metal HAL — the per-arch shim behind kido-boot's HAL table. Closes the PARTIAL item (ARM64 bare-metal prober was a declared STUB).

**Drafted:**
- `modules/kido-hal-arm64.h` — board IDs (QEMU virt real, RPi4 declared-stub), `kido_bootinfo_t` firmware-handoff contract, probe/fill prototypes, arch discipline (compile-time error on unknown arch), entry-shim contract (EL1+, bootinfo before probe).
- `modules/kido-hal-arm64.c` — real: generic timer (CNTPCT_EL0/CNTFRQ_EL0), FPU/MMU-presence/MIDR probing (ID_AA64*), QEMU virt PL011 TX console (TXFF-polled), runtime board table with loud unknown-board refusal. Loud stubs: memory map without bootinfo (DTB parse = kido-mem's job), RPi4 UART init, MMU bring-up. Hosted test double + self-test main (table-fill/probe contract); syntax-test macro for ARM64 asm paths on x86_64 host.
- `deliberations/2026-10-14-kido-hal-arm64-design.md` — circle record: P1 registers-are-honest / P2 one-real-UART / P3 test-the-contract; C1 firmware-config assumption (documented), C2 EL1 requirement (entry-shim contract), C3 parse-vs-execution limits (stated); preserved dissent D1 (DTB now vs later — overruled, kido-mem's job), D2 (double fidelity — mitigated).
- `deliberations/2026-10-14-kido-hal-arm64-conformance.md` — kido.json + HAL interface line-by-line: all four pointers honestly wired, caps fields sourced, 4 MET / 1 DEFERRED / 1 MET-by-discipline.
- `architecture/module-map.md` — kido-hal: PLANNED → DRAFT (arm64).

**Key decisions + why:**
1. Registers-are-honest: everything readable from arch registers is real; only firmware-handoff items (memory map, board UART choice) are stubs. The HAL never invents platform facts.
2. One real UART (QEMU virt PL011) — the board N8toriousAi will actually boot first gets a working console; RPi4 is declared with loud-stub init. Unknown board halts with NO_CONSOLE rather than scribbling at a guessed address.
3. bootinfo struct as the entry-shim→HAL seam — memory discovery without a firmware map fails loud (STUB_REACHED), never faked. DTB parsing belongs to kido-mem.
4. Did NOT modify the Gate-approved kido-boot.c — the one-line wiring (adapt's bare-metal branch → kido_hal_arm64_fill) is documented as the explicit next step for N8toriousAi's review.

**Test results (ran for real, gcc 13.3.0):**
- Syntax, hosted double path: PASS, zero warnings.
- Syntax, ARM64 asm paths (parse-only on x86_64 host): PASS, zero warnings.
- Self-test binary, 7 checks: PASS (0 failures) — table wiring, unknown-board refusal, RPi4 loud stub, probe with/without bootinfo, NULL guards, live console emit.

**Remains:**
- Bare-metal entry shim (stack/BSS, EL1, bootinfo from DTB) — the HAL's caller.
- The one-line wiring into kido-boot.c adapt() — awaiting N8toriousAi's review (boot was Gate-approved as-is).
- RPi4 UART init, DTB memory-map parse (kido-mem), MMU bring-up, kido_main.
- Execution proof of ARM64 paths: needs QEMU virt or hardware — N8toriousAi's call.

## 2026-10-14 — Session 3: kido-mem draft (builder crew)
**Goal:** Draft kido-mem — memory discovery via DTB parsing, producing the memory map that fills kido_bootinfo_t. The module the HAL builder explicitly deferred DTB parsing to (its D1 dissent, resolved here).

**Drafted:**
- `modules/kido-mem.h` — kido_mem_discover(dtb, len, bi) interface, region seed list (kido_mem_region_count/regions), loud UEFI stub prototype, call-order documentation for the parallel entry-shim builder.
- `modules/kido-mem.c` — real, portable DTB parser: header validation (magic, totalsize sanity, block bounds), /memreserve/ parsing, structure-block walk (depth cap 16), memory-node identification (name prefix "memory" OR device_type="memory", status="disabled" skipped, reserved-memory subtrees excluded), reg parsing with parent #address-cells/#size-cells, bounded region collection (8), largest-region primary selection, leading-reservation trim, interior-reservation loud failure. Zero libc in the parser (local string helpers, manual big-endian loads) — runs identically on host and bare metal.
- `deliberations/2026-10-14-kido-mem-design.md` — circle record: P1 parse-is-portable / P2 never-invent / P3 largest-wins; C1 spec-drift (bounded + 21 tests), C2 interior-reservation refusal (loud now, allocator relaxes later), C3 parallel-shim handoff (defensive (ptr,len) contract); preserved dissent D1 (multi-region bootinfo — overruled, raw list preserved via seed), D2 (split around interior holes — overruled, allocator's job).
- `deliberations/2026-10-14-kido-mem-conformance.md` — 7 MET / 0 PARTIAL / 3 DEFERRED (UEFI, allocator, interior carving — all declared).
- `architecture/module-map.md` — kido-mem: PLANNED → DRAFT.

**Key decisions + why:**
1. Parse-is-portable: full DTB parser in arch-independent C, not a stub — the format is big-endian by spec, so manual byte loads need no arch shim, and the module is genuinely testable on the dev host.
2. Never-invent: every failure mode (corrupt magic, truncation, no regions, overflow) returns KIDO_ERR_NO_MEMORY with mem_valid=0, so the HAL probe fails loud downstream. No DTB, no regions.
3. Largest-wins + honest reservations: primary = largest region; leading /memreserve/ trims the base upward; interior reservation fails LOUD (a single-region bootinfo cannot represent a hole — failing beats silent corruption). Fine carving is the future allocator's job.
4. Did NOT modify Gate-approved files (kido-boot.h/c untouched); board_id left for the entry shim — mem fills the map, not the board.

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

**Remains:**
- Entry shim (sibling builder, in parallel) — calls kido_mem_discover(dtb, len, &bi) with the firmware DTB, then passes bi to kido_hal_arm64_probe().
- UEFI discovery path (loud stub today).
- The allocator module (seed list exposed and waiting).
- Interior-reservation carving relaxation when the allocator lands (D2).
- Execution proof on QEMU virt / hardware — N8toriousAi's call; first boot is his to witness.

## 2026-10-14 — Session 3: kido-entry-arm64 draft (builder crew)
**Goal:** Draft the ARM64 bare-metal entry shim — the power-on entry point that makes kido_boot() a genuine boot path instead of a function called by nobody.

**Drafted:**
- `modules/kido-entry-arm64.S` — _start: stash DTB (x0->x19), EL2->EL1 drop (HCR_EL2/SPSR_EL2/eret; EL1 direct; else spin), SP=_stack_top, 16-byte BSS zero loop (linker 16-aligns both ends: no overrun), `bl kido_entry_c_main`, spin on return.
- `modules/kido-entry-arm64.c` — C continuation: DTB-magic check (0xd00dfeed), bootinfo fill (board = loud QEMU-virt assumption; mem_valid=0 loud stub), stash in BSS with accessors for kido-mem + pending HAL wiring, then kido_boot() -> kido_halt() (never returns). Hosted test double + self-test main (fill/DTB contract; kido_boot/kido_halt stubbed locally to avoid main() collision with the approved boot file).
- `modules/kido-entry-arm64.h` — interface + arch discipline + never-returns contract.
- `modules/kido-link-arm64.ld` — minimal script: image @0x40000000, 16-aligned BSS ends, 16 KiB stack.
- `deliberations/2026-10-14-kido-entry-arm64-design.md` — circle record: P1 .S/C split / P2 minimal linker script / P3 verify-DTB / P4 loud board assumption; C1-C4 (parallel-build boundary, QEMU observability limits, hosted halt untestable, no UART ping — layering); preserved dissent D1 (BSS-zero proof gap on QEMU).
- `deliberations/2026-10-14-kido-entry-arm64-conformance.md` — 10 MET (2 by discipline) / 1 PARTIAL / 3 DEFERRED / 2 unproven.
- `architecture/module-map.md` — added kido-entry row: DRAFT (arm64).

**Key decisions + why:**
1. Thin honest sandwich: ~40 instructions of .S create a C environment, C holds all policy. Assembly minimized because assembly is where bugs hide.
2. Board = loud assumption, not detection. DTB compatible-string parsing is the sibling kido-mem builder's bounded space; forking a half-parser here would split the contract.
3. DTB verified, not trusted: one word-read for the FDT magic. Invalid/missing DTB -> flagged + mem_valid=0, never a fabricated map.
4. No UART alive-ping in the shim — the UART belongs to the HAL; observability comes from QEMU's `-d int`, not from breaking the Gate-approved layering.
5. Did NOT modify Gate-approved kido-boot.c or kido-hal-arm64.h — the bootinfo accessor is the seam kido-mem and the pending wiring read.

**Test results (ran for real):**
- Cross assemble + compile (aarch64-linux-gnu-gcc, -ffreestanding): PASS, zero warnings. Real assembler checked the MRS/MSR strings.
- Cross link (-T kido-link-arm64.ld): PASS. _start @0x40000000 confirmed as entry. (One benign RWX-segment note from ld on a bare-metal image.)
- QEMU boot (qemu-system-aarch64, virt, cortex-a57, -kernel, -d int): PASS — guest ran 4s+ (timeout exit 124 = spinning in halt, expected), ZERO exceptions logged. Proves: EL drop path executed without fault, SP valid (8 KiB stack probe ran), BSS loop + DTB read fault-free, kido_boot() reached the probe stub -> loud halt. Does NOT prove which EL path was taken or cycle-level BSS correctness (stated in D1).
- Hosted self-test, 5 checks: PASS (0 failures) — valid/junk/NULL DTB handling, no faked memory map, NULL guards, bootinfo accessor.

**Remains:**
- kido-mem: DTB parser -> real memory map (mem_valid=1) + board detection replacing the shim's assumption. The shim's loud stub points straight at it.
- The one-line wiring of kido_hal_arm64_fill() into kido-boot.c adapt() — still awaiting N8toriousAi's review (boot approved as-is).
- BSS poison-fill debug build before any hardware claim (D1).
- RPi4 UART init, MMU bring-up, kido_main — unchanged.
- First boot is N8toriousAi's to witness.

## 2026-10-14 — Session 4: Gate-approved HAL wiring + kido-sched draft (builder crew)

**Wiring applied (N8toriousAi approved at the Gate):** kido-boot.c adapt()'s
bare-metal branch now calls kido_hal_arm64_fill() instead of the stub
table. Diff: (1) guarded includes of kido-hal-arm64.h + kido-entry-arm64.h
(ARM64 bare-metal only); (2) stub fns now x86_64-bare-metal-only (avoids
-Wunused-function on ARM64); (3) adapt() ARM64 branch calls
kido_hal_arm64_fill(hal, kido_entry_bootinfo()->board_id), propagating
non-OK loudly. Board identity comes from the entry shim's firmware
handoff — the shim is the single source of truth; unknown board fails
NO_CONSOLE, never scribbles at a guessed UART. Verified: compiles hosted
+ ARM64 + x86_64 bare-metal; hosted boot regression PASS (HANDOFF=5,
unchanged approved path).

**Files:**
- `modules/kido-sched.h` — interface + honesty laws (P1 cooperative, P2 no-alloc, SMP UP-only, arch discipline).
- `modules/kido-sched.c` — portable core (TCB table, round-robin pick, explicit carving, yield, run, task_start) + hosted test double + 33-check self-test.
- `modules/kido-sched-arm64.S` — kido_ctx_switch (x19-x28/FP/LR/SP save-restore) + kido_task_trampoline; separate .S because inline asm cannot reliably capture the caller's callee-saved regs.
- `deliberations/2026-10-14-kido-sched-design.md` — circle record: P1-P6 / C1-C4; preserved dissent D1 (halt-code mapping), D2 (carve direction vs image bounds).
- `deliberations/2026-10-14-kido-sched-conformance.md` — 14 MET / 0 PARTIAL / 3 DEFERRED / 2 unproven.
- `architecture/module-map.md` — kido-sched: PLANNED → DRAFT.

**Key decisions + why:**
1. Cooperative round-robin, no fake preemption. Timer IRQ + GIC are HAL loud stubs; claiming preemption would be a lie.
2. Static 16-TCB table; the scheduler never allocates (the allocator doesn't exist).
3. Explicit stack carving: top-down 16 KiB from the largest kido-mem region (bare metal), static array (hosted). DONE slots recycle WITH their stacks — a DONE task's stack is provably idle, so churn can't leak carve space (found by the self-test, fixed in the module).
4. Context switch in .S, not inline asm: the compiler may spill/reuse callee-saved regs in a prologue before inline asm runs; the .S function sees the caller's true register state.
5. Timer ticks are accounting only (ticks_run per task); NULL timer tolerated, never faked.
6. Empty queue halts LOUD via documented D1 mapping (KIDO_ERR_STUB_REACHED); dedicated KIDO_ERR_NO_TASKS code queued for N8toriousAi (touches the approved header).

**Test results (ran for real):**
- Hosted syntax (gcc -Wall -Wextra -Werror -fsyntax-only): PASS.
- Hosted self-test, 33 checks: ALL PASS (0 failures) — init/create guards, TCB + carve bounds/alignment, round-robin order 0,1,2 ×2, DONE-skip, yield switching/states/accounting, sole-task no-op, NULL-current no-op, DONE recycling with stack reuse, table-full NO_MEMORY, empty-queue loud halt, body execution + DONE + halt.
- Cross-assemble kido-sched-arm64.S (aarch64-linux-gnu-gcc): PASS — disassembly verified: save x19-x30/SP to old ctx at offsets 0..96, restore from new, ret; trampoline moves x19/x20 → x0/x1 and calls kido_task_start with a loud-halt backstop.
- Cross-compile kido-sched.c ARM64 (-ffreestanding): PASS.
- Honest limits: register switching cross-assembled, not executed (queued: QEMU task-switch integration at kido_main wiring); bare-metal carving not exercised (probe stub fires first).

**Remains:**
- kido_main wiring: scheduler integration → first multitasking boot (designed seam; QEMU task-switch proof lives there).
- The allocator (replaces explicit carving).
- D1: KIDO_ERR_NO_TASKS header code — N8toriousAi's call.
- Probe path still calls the stub kido_probe_arm64 (wiring probe → kido_mem_discover is a future Gate item, not this session's).
- First boot is N8toriousAi's to witness.

## Session 5 — kido-alloc (2026-10-14)

**Goal:** the memory allocation layer replacing the scheduler's explicit stack carving.

**Files:**
- `modules/kido-alloc.h` — interface + honesty laws (fragments, identity-map assumption, loud exhaustion, no VM).
- `modules/kido-alloc.c` — first-fit free-list, address-ordered, coalesce-on-free, 32-byte headers with magic, reservation carve-out, stats + 31-check self-test.
- `modules/kido-sched.h/.c` — rewired: stacks allocated from kido-alloc (init wires regions/arena); interface unchanged; 34-check self-test adapted (contiguity check replaced by order + non-overlap; recycle check now pins allocated_bytes).
- `deliberations/2026-10-14-kido-alloc-design.md` — circle record: P1-P7 / C1-C5; preserved dissent D1 (slab would be simpler for stacks), D2 (free(NULL) no-op vs loud).
- `deliberations/2026-10-14-kido-alloc-conformance.md` — 10 MET / 0 PARTIAL / 4 DEFERRED / 2 unproven.
- `architecture/module-map.md` — kido-alloc: PLANNED → DRAFT; dependency order now ... -> kido-mem -> kido-alloc -> kido-sched.

**Key decisions + why:**
1. First-fit free-list with immediate coalescing (P1). The honest first-kernel allocator: general, correct, testable. Fragmentation declared; largest_free stat exposes it.
2. Explicit region-list parameter (P2). No hidden kido-mem coupling — bare metal passes the discovery output, hosted passes an arena, tests pass synthetic regions.
3. Loud exhaustion: KIDO_ERR_NO_MEMORY, *out = NULL, never a silent NULL (P3).
4. Magic-checked free: double/invalid/NULL free → KIDO_ERR_EARLY_ENV, defined and loud (P4).
5. Reservation carve-out implemented now (P5); scheduler passes 0,0 until the linker exposes image symbols (sched D2 still open).
6. Scheduler keeps its interface; carving became a client call. DONE-slot stack reuse preserved and re-verified via allocator accounting.

**One real find during testing:** the first draft set the allocated block size to `block_end - payload`, swallowing the trailing free fragment into the live block — the self-test hung on the corrupted free list. Fixed to `need_end - payload`; the hang became the proof. A second expectation was also wrong (full single-block coalescing is impossible by design after a misaligned alloc — the <64-byte alignment gap is bounded documented waste, deliberation C2); the test now pins the bound instead of wishing it away.

**Test results (ran for real, gcc 13.3.0):**
- Hosted syntax (-Wall -Wextra -Werror -fsyntax-only): PASS, zero warnings.
- Allocator self-test, 31 checks: ALL PASS — init guards, alignment 1..256, loud free failures, exhaustion→recovery, reservation carve-out (64 allocs avoid it), 120-churn bounds.
- Scheduler regression, 34 checks: ALL PASS against the allocator backing.
- Cross-compile ARM64 (-ffreestanding): kido-alloc.c + kido-sched.c PASS, zero warnings.
- Honest limits: bare-metal region consumption unexercised (probe stub fires first); adversarial fragmentation characterized only via largest_free.

**Remains:**
- kido_main wiring: scheduler integration → first multitasking boot (a sibling builder is on this in parallel).
- D1: KIDO_ERR_NO_TASKS header code — N8toriousAi's call.
- Sched D2: image-bounds reservation wiring (linker symbols).
- First boot is N8toriousAi's to witness.

## Session 5 — kido_main integration (2026-10-14, scheduler-integration builder)

**Goal:** wire the scheduler into kido_main; prove task switching under QEMU.

**Diagnosis:** the bare-metal boot path could not reach kido_main — kido_probe_arm64
was still a STUB (returned before adapt), and the entry fill never called
kido_mem_discover (mem_valid always 0). Both are now wired (see deliberations/
2026-10-14-kido-main-integration.md D1/D2 — needs Gate ratification).

**Decisions + why:**
- D1: kido_mem_discover wired into kido_entry_fill_bootinfo (the documented call
  order; HAL header's ENTRY-SHIM CONTRACT obligates the shim). Totalsize BE32@+4
  with 1 MiB sanity cap; failures leave mem_valid=0 → loud downstream.
- D2: kido_probe_arm64 delegates to kido_hal_arm64_probe (real register reads,
  no asm in boot.c — PORTABILITY LAW preserved).
- D3: kido_main — sched init, 3 tasks (A/B/C, 4 prints + yields), kido_sched_run()
  on bare metal; hosted drives bodies directly (no real switch there). Hosted
  main() expectation 5 → 0 (handoff now accepted).
- D4: kido_strlen test-guarded in kido-mem.c (was breaking -Werror bare-metal).
- D5: entry self-test build line corrected (never linked kido-boot.c).

**Tests (hosted, real):** boot self-test PASS (AAAABBBBCCCC, rc 0); sched 33/33;
entry PASS; hal PASS; mem ALL PASS. Cross-compile 7 TUs clean; link clean;
_start @0x40000000. kido_mem_discover vs real QEMU virt DTB: OK, 1 region
(0x40000000+128MiB).

**BLOCKED:** QEMU runs silent (no console, no exceptions) — cause not yet
isolated. Debug-marker approach prepared and reverted. FINAL BLOCKER: sibling
allocator builder rewrote kido-sched.c/h mid-task (23:15:36 UTC) to depend on
kido_alloc_* — contradicts this task's no-allocator-dependency brief and
destabilized the target. Parent must fence/sequence before the QEMU proof.

**Remains:** QEMU multitasking proof (ABCABCABCABC interleave, zero exceptions);
Gate ratification of D1/D2/D4; D1 KIDO_ERR_NO_TASKS code — N8toriousAi's call.

## Session 6 — fence + QEMU multitask proof (2026-10-14, integration cont.)

**Gate orders executed:** prober/discover wiring ratified; kido-alloc approved
standalone; allocator FENCED off the scheduler until this proof lands.

**The fence:** kido-sched.c/h decoupled from kido-alloc (include removed;
explicit top-down carve restored with underflow-guarded watermark; DONE-slot
reuse preserved; self-test adapted to carve semantics). kido-alloc.h/.c
untouched. Zero kido_alloc references remain in the scheduler.

**Silent-halt root causes (debug-marker builds, fully reverted):**
1. `-kernel` with ELF → x0 = 0 (no DTB handoff); shim correctly failed loud.
2. `-kernel` with raw binary → loads at 0x40080000 (RAM+TEXT_OFFSET), not
   the linked 0x40000000 → every PC-relative function address off by
   0x80000 → first task entry missed into unmapped memory → Undefined
   Instruction storm. Both are QEMU harness details, not kernel bugs.

**THE PROOF (pristine fenced sources, linked at actual load address):**
QEMU virt/cortex-a57/128MiB console: breath → arm64 → kido_main →
"3 tasks created" → `ABCABCABCABC` (12 marks, perfect round-robin
interleave) → loud halt on empty queue. Zero exceptions. Log saved as
deliberations/2026-10-14-qemu-multitask-proof.log.

**Tests (all real):** sched 34/34; boot PASS; entry PASS; hal PASS; mem ALL
PASS. Cross-compile clean; link clean.

**Remains:** D1 KIDO_ERR_NO_TASKS header code (N8toriousAi's call); D2 carve vs
image bounds (open); linker-script comment update for raw-binary load
address (recommended, not done unilaterally); allocator's scheduler
integration sequenced after this proof.

## Session 7 — kido-resonate (2026-10-14)

**Goal:** kernel-side agent signaling on the resonant mesh — scheduler tasks
as transmitter-agents, Lorentzian-gated delivery. N8toriousAi accepted the QEMU
proof and chose this over allocator integration (which stays queued).

**Decisions:**
1. Frequency IS the address (P1): transmit() takes a band, never a task id.
   Every tuned task gets its own eta evaluation. BROADCAST evaluates all.
2. eta in float (P2/D1): AArch64 mandates FP; fixed-point would quantize the
   selectivity curve. Dissent preserved.
3. Threshold 0.5 = the half-power point (D3): detuning of f/(2Q). Below it,
   REJECTED — a counted result, never silent. Full queue on a deliverable
   signal: DROPPED — counted, never silent.
4. Receiver state = bounded pending queue (8) + rx/tx/drop counters (P3):
   no fake neurons, no activation variables. recv() frees the slot
   (reuptake, honest structural analog).
5. Cooperative: delivery evaluates synchronously in transmit(); consumption
   via recv() at the task's own pace (P4/D2). No scheduler hooks (fenced).
6. Q=0 defined as unselective (eta=1.0) — the Lorentzian's limit, not a hack.
   Band 0 = untuned, never receives (no div-by-zero).
7. Inter-kernel transport DECLARED (C5): no bus exists; wire shape carried
   whole for the future. Single-hop decay is identity. Coherence metric out
   of scope (C6): tasks aren't neurons.

**One real find during testing:** self-reception — a task tuned to its own
transmit band receives its own signal. Kept deliberately: honest pub/sub
bus semantics, and the test pins it (d==2 on the forge test).

**Tests (all real, gcc 13.3.0):** syntax PASS; self-test 59 checks, 0
failures (tuned delivery, detuned rejection, threshold edges 540/541,
forge constant, broadcast selectivity, queue-full drops, untuned silence,
arg validation, stats); ARM64 cross-compile PASS; no kido-alloc include or
symbol use (grep-verified); scheduler regression 34/34 green.
Conformance: 13 MET / 0 PARTIAL / 3 DEFERRED / 1 OUT OF SCOPE.

**Files:** modules/kido-resonate.h, modules/kido-resonate.c,
deliberations/2026-10-14-kido-resonate-design.md,
deliberations/2026-10-14-kido-resonate-conformance.md.
Module map: kido-resonate PLANNED → DRAFT.

**Remains:** inter-kernel transport (declared); deferred delivery-at-yield
(D2, queued); allocator's scheduler integration (still queued, sequenced
after the QEMU proof per Gate order).

## 2026-10-14 — Session 7: kido-alloc × kido-sched integration (builder crew)
**Goal:** Integrate the approved allocator with the scheduler — explicit stack carving
becomes a client of kido-alloc, properly sequenced after the fence order was fulfilled.

**Changed:**
- `modules/kido-sched.h` — allocation law rewritten (fence fulfilled): sched_init
  initializes kido-alloc from kido-mem's region list (hosted: arena as synthetic
  region); init order alloc → sched → create documented; `kido-alloc.h` included;
  draft status updated (QEMU multitasking proof accepted).
- `modules/kido-sched.c` — carve watermark removed; `kido_sched_init` wires
  `kido_alloc_init` in one place (reserve 0,0, D2 still open); `kido_sched_create`
  allocates 16 KiB/16-aligned stacks via `kido_alloc` (slot left EMPTY on failure —
  never half-created); DONE-slot reuse preserved and now allocator-accounted;
  self-test adapted to allocator semantics (order + non-overlap, not carve
  direction) plus 20 new integration checks. kido-alloc.h/.c untouched.
- `deliberations/2026-10-14-kido-alloc-sched-integration.md` — circle record:
  P1 wire-in-sched_init chosen over P2 caller-inits; C1–C5 answered; D1
  (free-on-recycle) overruled and preserved.
- `deliberations/2026-10-14-kido-alloc-sched-integration-conformance.md` —
  10 MET / 0 PARTIAL / 3 DEFERRED, with honest limits (cross-toolchain lost to
  VM replacement; ARM64 delta is portable C, asm blocks untouched).
- `architecture/module-map.md` — scheduler row now allocator-backed; fence note
  updated (fulfilled).

**Key decisions + why:**
1. Wire alloc_init inside sched_init (deliberated P1) — one place, no kido-boot.c
   churn, kido-resonate's test keeps working unchanged.
2. DONE recycle keeps its stack (deliberation C3) — the QEMU-proof cycle already
   fixed fresh-carve churn; free+realloc would reintroduce it. Reuse is visible
   in kido_alloc_stats.
3. No destroy API invented (deliberation D1/C4) — kido_free's steady-state caller
   doesn't exist; the free path is proven directly by test, and teardown frees
   when a destroy API is specified.

**Test results (all real, gcc 13.3.0, -Wall -Wextra -Werror, zero warnings):**
- Scheduler self-test: 54 checks, 0 failures (34 adapted + 20 new: allocator
  accounting, churn-no-leak, loud exhaustion + consistency, free path, misuse).
- Allocator suite: 31/31. Resonate suite: 59/59 unchanged on the integrated tree
  (build line now links kido-alloc.c).
- Boot integration: kido_boot() → 0 through the allocator-backed scheduler.
- ARM64 cross-compile / QEMU re-proof: NOT RUN — toolchain lost to VM
  replacement, apt locked by system update. Stated as an honest limit, not
  hand-waved.

**Files:** modules/kido-sched.h, modules/kido-sched.c, deliberations/2026-10-14-
kido-alloc-sched-integration.md, deliberations/2026-10-14-kido-alloc-sched-
integration-conformance.md, architecture/module-map.md.
Module map: kido-sched now allocator-backed (fence fulfilled).

**Remains:** D1 dedicated KIDO_ERR_NO_TASKS code; D2 image-bounds reservation;
ARM64 cross + QEMU re-proof when the toolchain is available; destroy API
(future).

## 2026-10-15 — Session 8: QEMU re-proof of the allocator-integrated tree (builder crew)

**Goal:** close session 7's honest limit — the integrated (allocator-backed)
scheduler had never been cross-compiled or executed on bare metal. The cross
toolchain is back (aarch64-linux-gnu-gcc 13.3.0, qemu-system-aarch64); this
session re-proves multitasking on the integrated tree. Verification session,
no new module, pristine sources (zero Gate-file modifications).

**Deliberation:** `deliberations/2026-10-15-qemu-reproof-design.md` — circle
record: P1 pristine sources + like-for-like image (no resonate in the boot
image) / P2 proven session-6 harness recipe (raw binary, `-kernel` gives
x0=DTB, /tmp harness-only linker copy at 0x40080000) / P3 allocator-on-bare-
metal layout analysis (region 0x40000000+128MiB; first-fit stacks land at
~0x40000000, image linked at 0x40080000 — no overlap at this volume; D2 stays
OPEN as a design gap, this run safe by measured layout) / P4 d8–d15 not in
the context (FP-using tasks unsupported until a future module; not in this
path) / P5 session-6 acceptance bar; C1–C4 answered; D1/D2 preserved.

**Regression gate (all real, gcc 13.3.0, before QEMU):** boot hosted PASS
(kido_boot() → 0, AAAABBBBCCCC); sched 54/54; alloc 31/31; mem ALL PASS;
resonate 59/59 (regression only — not in the QEMU image).

**THE RE-PROOF (pristine sources, 8 TUs cross-compiled -ffreestanding -O0
-Wall -Wextra -Werror, zero warnings; linked at 0x40080000; QEMU virt /
cortex-a57 / 128 MiB):**
```
[Kido] outer kernel, first adaptive breath
[Kido] arch: arm64 | handing off to kido_main...
[Kido] kido_main: scheduler init
[Kido] kido_main: 3 tasks created
[Kido] kido_main: entering scheduler (never returns)
ABCABCABCABC
```
- `ABCABCABCABC`: 12 marks, perfect round-robin interleave — the assembled
  context switch EXECUTED with allocator-backed stacks.
- Zero exceptions in `-d int`. Exit 124 = timeout in the designed loud-halt
  spin (empty queue halts loud, as documented).
- Proves on bare metal for the first time: kido_alloc_init from kido-mem's
  region list, kido_alloc delivering 16 KiB/16-aligned stacks, DONE-slot
  reuse path reachable in the real switch loop.
- Log: `deliberations/2026-10-15-qemu-reproof.log`.

**Remains:** D1 KIDO_ERR_NO_TASKS header code (N8toriousAi's call); D2 image-bounds
reservation (open — run safe by layout, gap not closed); destroy API (future);
deferred delivery-at-yield for resonate; inter-kernel transport; UEFI/RPi4/MMU.
First boot is N8toriousAi's to witness.

## 2026-10-15 — Session 9: kido-interop (builder crew)

**Goal:** the inter-kernel protocol (Kido <-> BUBO) + doll-layer placement —
the two items the boot/HAL conformance reviews explicitly DEFERRED, and the
resonate C5 "DECLARED, not built" verdict. One solid piece, not five thin ones.

**Drafted:**
- `architecture/doll-layers.md` — the seats fixed: inner (BUBO: deep, stable,
  x86 heritage) / outer (Kido: adaptive, portable, language ball). What lives
  where, what crosses (ANNOUNCE/ACK, SYS, LANG), what never crosses
  (scheduler/allocator/memory/HAL internals). No leader election, no
  cross-kernel preemption — divided by layer, not by competition.
- `modules/kido-interop.h` — envelope wraps `kido_signal_t` WHOLE (resonate
  C5 honored; kido-resonate.h untouched); `kido_kernel_t` seats;
  `kido_link_t` driver table (HAL pattern, medium-agnostic); state machine
  UNBOUND -> ANNOUNCED -> LINKED | SOLO; decay law
  `strength_rx = strength_tx * 950/1000` (MEDUSA: readable equation);
  minimal type registry (ANNOUNCE/ACK 0x0001/0x0002, SYS 0x0010, LANG 0x0020).
- `modules/kido-interop.c` — Kido's side real: init/bind/announce (bounded
  poll; 0 = fire-and-forget)/send (LINKED-only, loud otherwise)/recv
  (magic+version validation, ingress decay + hop_count++).
  Hosted self-test: two-queue loopback pipe + SIMULATED BUBO peer
  (declared simulation — proves Kido's side, not BUBO's existence).
- `deliberations/2026-10-15-kido-interop-design.md` — circle record:
  P1 asymmetry (Kido adapts, BUBO ACKs) / P2 envelope purist / P3 loud-link
  auditor / P4 MEDUSA mathematician / P5 testability; C1-C8 answered;
  preserved dissent D1 (beacon-only overruled), D2 (lossless carrier
  overruled — 5%/hop draft, N8toriousAi tunes), D3 (standalone struct overruled).
- `deliberations/2026-10-15-kido-interop-conformance.md` — kido.json
  line-by-line: 6 MET (incl. both prior DEFERRED items now resolved);
  still DEFERRED: real BUBO peer (Phase 4), bare-metal transport medium,
  ordering/dup guarantees (explicitly unclaimed).
- `architecture/module-map.md` — kido-interop row added (DRAFT).

**Key decisions + why:**
1. Asymmetric protocol (P1): every adaptive behavior on Kido's side —
   "compensates BUBO's flaws" made into protocol law. BUBO owes one
   behavior: answer ANNOUNCE.
2. Envelope wraps, never rebuilds (P2/D3): the wire shape resonate carried
   whole plugs straight in; zero Gate-approved files modified this session.
3. SOLO is a state, not an error (C7): bounded ANNOUNCE wait, no ACK ->
   SOLO + one loud console note. Kido boots and runs peerless; absence is
   a fact. Sends in SOLO/ANNOUNCED/UNBOUND are loud errors, never silent.
4. Decay applied by the receiver on ingress (C8): the wire stays honest
   about what was sent; decay is a receiver-measured fact. Integer math,
   pinned by test (800 -> 760 exact).
5. No new status codes: EARLY_ENV (uninitialized) / STUB_REACHED (no
   transport or no peer) via documented mappings — a new header code stays
   N8toriousAi's call (sched D1 precedent).
6. No ordering/dup guarantees claimed (C5): sequence numbers would be fake
   reliability on a link with no retransmission.

**Test results (ran for real, gcc 13.3.0):**
- Hosted syntax (-Wall -Wextra -Werror): PASS, zero warnings.
- Self-test: 75 checks, 0 failures — init guards, unbound loudness,
  half-table loudness, solo transition + single loud note, ANNOUNCE
  envelope well-formedness, LINKED handshake via simulated ACK,
  idempotent re-announce, LANG send (wire honest: strength 800 unchanged
  pre-receipt), ingress decay (1000 -> 950, 800 -> 760 exact),
  version/magic rejection counted not errored, full arg-validation.
- ARM64 cross-compile (-ffreestanding): PASS, zero warnings.
- Honest limits: peer is simulated; ARM64 paths assembled not executed;
  interop not yet wired into any boot image (future Gate item).

**Remains:** D1 KIDO_ERR_NO_TASKS header code (N8toriousAi's call); D2
image-bounds reservation (open); real BUBO peer + bare-metal transport
(Phase 4); destroy API; resonate deferred delivery-at-yield; UEFI/RPi4/MMU.
First boot is N8toriousAi's to witness.

## 2026-10-16 — Session 10: kido-image — closing sched D2 (builder crew)

**Goal:** close sched deliberation D2 (open since session 4): the allocator
did not know the kernel image bounds (reserve 0,0); every boot since has
been "safe by measured layout" rather than by design.

**Drafted:**
- `modules/kido-image.h` — `kido_image_bounds(&base, &size)`; hosted-only
  `kido_image_test_set_bounds()` injector; honesty law (bare metal: symbols
  are truth, mislinked image fails LOUD; hosted: no image -> refused query,
  declared-vacuous 0,0; link-at-load law stated, relocation detection out
  of scope).
- `modules/kido-image.c` — bare-metal ARM64: extern `_image_start`/
  `_image_end`, subtraction, EARLY_ENV on NULL outs or inverted bounds.
  Hosted: STUB_REACHED unless injected; injection guards (zero-size and
  overflow -> EARLY_ENV). Self-test (KIDO_IMAGE_SELFTEST): 9 checks.
- `modules/kido-link-arm64.ld` — `_image_start` added; `_image_end` moved
  AFTER the 16 KiB boot stack (the script now advances `.` through it, so
  the stack is inside the image; `_stack_top` byte-identical, proven by
  old-vs-new link comparison); header documents the load-address law
  (QEMU `-kernel` raw binary loads at RAM+0x80000, not RAM_BASE —
  measured 2026-10-14, now law, not lore).
- `modules/kido-sched.c` — `kido_sched_init` unified: bounds query first,
  then `kido_alloc_init(regions, n, img_base, img_size)`. Hosted
  STUB_REACHED -> vacuous 0,0 (declared); bare-metal failure propagates
  LOUD before the allocator initializes. Self-test section 30-39 (10 new
  checks): injected 4 KiB fake image at arena base -> total_bytes reduced
  by exactly 4096, 3 stacks created, all avoiding the reserved range.
- Doc updates: kido-sched.h (ALLOCATION LAW, init contract, draft status),
  kido-alloc.h (reserve doc, draft status), kido-sched.c TESTING line,
  kido-resonate.c TESTING line (build gains kido-image.c — its self-test
  links kido-sched.c).
- `deliberations/2026-10-16-kido-image-design.md` — circle record:
  P1 one query no coupling / P2 symbols are truth / P3 boot stack is
  image / P4 hosted vacuity / P5 link-at-load law; C1–C5 answered
  (C2 proven: _stack_top identical 0x40088b10 old vs new; C4 DTB trim
  honestly out of scope -> kido-mem's future); preserved dissent D1
  (relocation detection overruled -> future kido-reloc), D2 (wiring in
  kido-boot overruled -> alloc-init-in-one-place stands).
- `deliberations/2026-10-16-kido-image-conformance.md` — 7 MET
  (incl. D2 closed, no-new-status-codes, no Gate-file churn) / 3
  DEFERRED (QEMU execution, DTB trim, relocation) / 1 unproven-by-design.
- `architecture/module-map.md` — kido-image row added (DRAFT); D2 note
  updated.

**Key decisions + why:**
1. One query, no coupling (P1): bounds flow sched_init -> alloc_init's
   existing reserve carve-out. Zero allocator logic changes; kido-boot.c
   untouched.
2. Boot stack inside the image (P3): reserving 16 KiB of 128 MiB forever
   is honest waste; handing the live boot stack to a task would be
   silent corruption.
3. Hosted vacuity declared (P4): uninjected hosted builds reserve 0,0
   because there is no image to protect — stated in design + both
   headers, never a silent fallback. The real carve path is exercised
   via injection.
4. Link-at-load is law (P5): the session-6 raw-binary finding is now
   documented in the canonical script; the harness copy stays config.

**Test results (all real, gcc 13.3.0):**
- kido-image self-test: 9/9. Sched self-test: 64/64 (54 + 10 new).
  Alloc: 31/31. Resonate: 59/59 (new build line). Boot integration:
  PASS (kido_boot() -> 0, AAAABBBBCCCC).
- ARM64 cross-compile (-ffreestanding -O0 -Wall -Wextra -Werror): all 9
  TUs clean, zero warnings. Linked clean (known benign RWX note).
- readelf: _image_start=0x40080000, _image_end=_stack_top=0x40088b10
  (image 35,600 bytes incl. stack); _stack_top identical to old script.

**Remains:** QEMU execution proof of the reserved tree (next verification
session — expect first-fit stacks below the carved image, zero overlap);
D1 KIDO_ERR_NO_TASKS header code (N8toriousAi's call); DTB-region trim
(kido-mem's future); relocation detection (future kido-reloc); destroy
API; resonate deferred delivery-at-yield; real BUBO peer + bare-metal
transport; UEFI/RPi4/MMU. First boot is N8toriousAi's to witness.

## 2026-10-16 — Session 11: QEMU execution proof of the reserved tree (builder crew)

**Goal:** close session 10's last remains item — the reserved tree
(kido-image bounds carved into the allocator) had been assembled,
linked, and symbol-verified but never EXECUTED on bare metal.
Verification session; zero source changes (pristine scaffold tree).

**One real miss, owned:** the first QEMU run died in 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, not the ELF
ENTRY. Fixed by linking `entry.o entry-c.o` first (readelf:
`_start == _image_start == 0x40080000`). Recipe going forward:
entry objects always lead the link line.

**Deliberation:** `deliberations/2026-10-16-qemu-reserved-proof-design.md`
(P1 verifier / P2 harness keeper / P3 memory auditor / P4 constraint
ledger / P5 regression keeper; C1–C4 answered; D1–D3 preserved —
D1: stack addresses not printed on bare metal by pristine-source
discipline; D2: KIDO_ERR_NO_TASKS still N8toriousAi's call; D3: DTB trim
and kido-reloc still future).

**Tests (all real):**
- Regression gate BEFORE QEMU: image 9/9, alloc 31/31, sched 64/64,
  resonate 59/59, mem ALL, hal 7/7, entry 5/5; boot integration PASS
  (kido_boot() -> 0, AAAABBBBCCCC). Zero warnings everywhere.
- Cross-compile: 9 TUs, aarch64-linux-gnu-gcc 13.3.0,
  -ffreestanding -O0 -Wall -Wextra -Werror: PASS, zero warnings.
- Link: clean (known benign RWX-segment note). readelf:
  _image_start=0x40080000, _image_end=_stack_top=0x40088f70.

**THE PROOF (QEMU virt / cortex-a57 / 128 MiB, raw binary at
0x40080000, -d int):**
```
[Kido] outer kernel, first adaptive breath
[Kido] arch: arm64 | handing off to kido_main...
[Kido] kido_main: scheduler init
[Kido] kido_main: 3 tasks created
[Kido] kido_main: entering scheduler (never returns)
ABCABCABCABC
```
- `ABCABCABCABC`: 12 marks, perfect round-robin interleave — the
  assembled context switch EXECUTED on allocator-backed stacks.
- ZERO exceptions in the -d int log (0 bytes).
- Exit 124 = timeout in the designed loud-halt spin (expected).
- The reservation path is proven on bare metal: the console reaching
  "3 tasks created" means kido_image_bounds returned OK from REAL
  linker symbols — a mislinked image would have halted LOUD at
  sched_init with EARLY_ENV before any task existed.
- Non-overlap: first-fit allocates low->high from 0x40000000; the
  image is carved at [0x40080000, 0x40088f70). Any stack overlapping
  .text corrupts live code and faults — zero exceptions on a clean
  interleave is the bare-metal evidence. Exact carve geometry is
  pinned by the hosted injected-image test (same kido-alloc.c).
- Log: `deliberations/2026-10-16-qemu-reserved-proof.log`.
- `architecture/module-map.md` updated (reserved-tree proof landed).

**Remains:** D1 KIDO_ERR_NO_TASKS header code (N8toriousAi's call);
relocation detection (future kido-reloc); DTB-region trim
(kido-mem's future); destroy API; resonate deferred
delivery-at-yield; real BUBO peer + bare-metal transport (Phase 4);
UEFI/RPi4/MMU. First boot is N8toriousAi's to witness.

## 2026-10-17 — Session 12: kido-reloc — relocation detection (builder crew)

**Goal:** close the open D1 from the kido-image deliberation
(2026-10-16) — self-relocation detection, deferred there as "a future
kido-reloc module can own detection." One solid piece: detection +
loud tripwire + earliest-C wiring. Adaptation deliberately NOT this
piece.

**Deliberation:**
`deliberations/2026-10-17-kido-reloc-design.md` (P1 linker purist /
P2 entry realist / P3 portability auditor / P4 adaptivity advocate /
P5 test keeper; C1–C5 answered; D1 preserved — fail-loud is
BUBO-posture, adaptation is phase 2, named not faked).

**Design:** delta = runtime(probe) − linked(probe). The probe is a
never-called global `kido_reloc_probe`. Runtime address via
`adrp`/`add :lo12:` inline asm (PC-relative, true wherever we run);
linked address via a `static const uintptr_t` in .rodata initialized
to `(uintptr_t)&kido_reloc_probe` — a GNU-C constant the linker
resolves to the absolute linked address. Load-bearing invariant,
documented in the source: NEVER take `&kido_reloc_probe` at runtime
(-fno-pic would emit PC-relative adrp and hide the delta); only the
.rodata constant is trusted.

**Policy:** `kido_reloc_verify()` returns KIDO_ERR_EARLY_ENV on
delta != 0 — refuse LOUD, not adapt. `kido_reloc_detect()` fills
{delta, linked_base, actual_base} (linked base from kido_image_bounds
— one query, no duplicated truth); `kido_reloc_last()` keeps the
report in BSS for a future console. Hosted: KIDO_ERR_STUB_REACHED
unless the test injects a delta (exercises the pure verify policy,
never a fake relocation).

**Wiring:** `kido_reloc_verify()` at the top of `kido_entry_c_main`,
before `kido_entry_fill_bootinfo`. The entry .S is untouched (proven
path). Declared exposure: the .S sets SP from the absolute
_stack_top before the tripwire runs — on the supported QEMU -kernel
path the load address always equals the linked base (delta is
definitionally 0), so the tripwire guards future loaders
(UEFI/GRUB), not today's path.

**Tests (all real, gcc 13.3.0):**
- kido-reloc self-test (hosted): 13/13, zero warnings.
- ARM64 cross-compile (-ffreestanding -O0 -Wall -Wextra -Werror):
  clean, zero warnings.
- Technique proof (the honest check, not a theater boot):
  `readelf -r` shows R_AARCH64_ABS64 on the probe constant in
  .rela.data.rel.ro.local (link-time absolute, as the invariant
  requires); disassembly shows the adrp/add pair inside
  kido_reloc_detect. A QEMU run was deliberately NOT claimed as
  detector proof — the supported path is definitionally delta-0.
- Entry self-test with the reloc wiring compiled in: PASS
  (0 failures).

**Remains:** D1 KIDO_ERR_NO_TASKS header code (N8toriousAi's call);
kido-reloc phase 2 — delta-aware SP in the entry .S, relocated image
bounds, delta-shifted allocator reservation (dissent D1, named);
DTB-region trim (kido-mem's future); destroy API; resonate deferred
delivery-at-yield; real BUBO peer + bare-metal transport (Phase 4);
UEFI/RPi4/MMU. First boot is N8toriousAi's to witness.

## 2026-10-18 — Session 13: reconcile + verify the phase-2 implementation (builder crew)

**Reconciliation:** the phase-2 relocation-adaptation code was already in
the tree (file timestamps 2026-10-17 ~21:26-21:48, one hour after the
Session 12 ledger entry) but never got a ledger record and was never
formally verified. This session reconciles that gap: the tree now
matches the adapt deliberation (`deliberations/2026-10-17-kido-
reloc-adapt-design.md`) deliverable-for-deliverable, and the full
hosted test battery passes on the current tree.

**Verified present (all 8 adapt-deliberation deliverables):**
- `modules/kido-entry-arm64.S` — delta-aware SP (adrp/add vs literal
  `=probe`, x20 across eret, SP = _stack_top + delta), BSS stash of
  delta + valid flag via PC-relative adrp stores.
- `modules/kido-reloc.h` — `kido_reloc_crosscheck()` API, BSS slot
  contract (extern `kido_reloc_entry_delta/valid`), phase-2 honesty law.
- `modules/kido-reloc.c` — BSS slot definitions, crosscheck (bare-metal
  valid==0 -> EARLY_ENV loud; hosted valid==0 -> vacuous OK), verify() =
  detect + crosscheck + refuse-if-relocated; self-test 21 checks.
- `modules/kido-image.h` — `kido_image_actual_bounds()` API.
- `modules/kido-image.c` — actual = linked + last-delta, overflow and
  underflow guards loud; self-test 15 checks.
- `modules/kido-sched.c` — `kido_sched_init` consumes
  `kido_image_actual_bounds` (line 125); shifted-carve self-test
  section present. NOTE (honest drift): the self-test runs 75 checks,
  not the deliberation's projected 72 — the implementation added 3
  more checks than planned. Count is real either way.
- `modules/kido-entry-arm64.c` — comment updates; the
  `kido_reloc_verify()` wiring line UNCHANGED (verify's contract is
  unchanged: OK or EARLY_ENV).
- `architecture/module-map.md` — reloc row already describes phase 2;
  no edit needed.

**Tests (all real, hosted, gcc 13.3.0, -std=c11 -Wall -Wextra -Werror,
zero warnings everywhere):**
- reloc 21/21; image 15/15; alloc 31/31; sched 75/75;
  resonate 59/59; interop 75/75; mem ALL PASS; entry PASS; hal PASS;
  boot integration PASS (kido_boot() -> 0, AAAABBBBCCCC).
- The shifted-carve proof: injected image (0x40000000) + injected delta
  (+0x1000) -> task stacks avoid [shifted_base, shifted_base + size);
  first stack starts at/after the shifted carve end. Same kido-alloc.c
  that runs on bare metal — the bookkeeping the tripwire protects is
  relocation-true.

**Still queued, honestly:** the .S object proof (assemble + readelf:
R_AARCH64_ABS64 on the literal-pool entry for the probe + disassembly
showing the adrp/add pair). The cross toolchain is STILL absent — apt
cannot even locate gcc-aarch64-linux-gnu (main pocket unreachable;
only security pocket reachable). Per the adapt deliberation's
conformance gate and the scaffold honesty law, the .S is written but
unproven; marked in the .S header and here. No QEMU run this session
either: bare-metal proof needs the toolchain that is not here.

**Deltas closed by this record:** session-12 dissent D1 (phase 2
adaptation) — built, verified on hosted, recorded. Session-12's
declared exposure (relocated image crashing before the tripwire on a
garbage SP) — closed by the delta-aware SP line in the .S (unproven
by assembly, pending toolchain).

**Remains:** phase-3 PI build + self-relocation deliberation (dissent
D1, named); D1 KIDO_ERR_NO_TASKS header code (N8toriousAi's call); DTB-
region trim (kido-mem's future); destroy API; resonate deferred
delivery-at-yield; real BUBO peer + bare-metal transport (Phase 4);
UEFI/RPi4/MMU. First boot is N8toriousAi's to witness.

## 2026-10-18 — Session 14: close the queued phase-2 proofs (builder crew)

**Goal:** close the two proof gates phase 2 left open — (a) the .S
object proof (assemble + readelf ABS64 + disassembly, queued
2026-10-17 for the toolchain's return), (b) the relocated-load
QEMU execution proof (queued in the session-12 ledger). The cross
toolchain is back (aarch64-linux-gnu-gcc 13.3.0,
qemu-system-aarch64). Verification session; pristine sources
(comment-only proof-status updates, no logic changes).

**One owned harness error:** the first ("control") link used a
harness linker copy whose sed replaced `RAM_BASE = 0x40000000`
with itself — the canonical script was misread as already
`0x40080000` (sessions 8/11 linked harness copies at 0x40080000;
canonical is 0x40000000). The image linked at 0x40000000, QEMU
-kernel loaded it at 0x40080000: delta = +0x80000. The planned
control was accidentally the relocated experiment. The evidence
is real and is labeled accidental everywhere.

**Deliberation:**
`deliberations/2026-10-18-kido-phase2-proof-design.md` (P1 object
prover / P2 addressing auditor / P3 relocation experimenter
(owns the harness error) / P4 honesty auditor / P5 regression
keeper; C1–C4 answered; D1 preserved — no deliberate second
relocated run; the register trace already gave ground truth).

**The accidental relocated run (delta = +0x80000) — register
trace (-d cpu), the strongest evidence the harness can give:**
after `_start`: X09=0x400836c0 (runtime probe, PC-relative),
X10=0x400036c0 (linked probe, literal absolute), X20=0x00080000
(the TRUE delta, measured in registers before SP existed),
X19=0x44000000 (DTB stashed). Branch trace: el1_entry → BSS loop
→ stash → kido_entry_c_main → verify → detect → crosscheck with
the AGREEMENT branch taken (both instruments measured +0x80000)
→ delta policy → KIDO_ERR_EARLY_ENV → kido_halt spin. Console:
silent (halt doesn't print; the signal is breath-vs-silence).
-d int: zero exceptions. Exit 124 (designed halt spin). Proves:
safe stack under relocation (no exception storm), true
measurement by both instruments, loud refusal by design.
Session-12's declared exposure (relocated image dying before the
tripwire) closes EMPIRICALLY. Also observed: the BSS loop zeroed
the LINKED region (x0=0x40004618) — the known non-PI exposure;
execution refused, so harmless; phase 3's problem, stated.

**The deliberate delta-0 control** (harness copy, single-line
diff RAM_BASE 0x40000000 → 0x40080000, diff-verified; canonical
untouched; entry objects first; _start == _image_start ==
0x40080000 readelf-verified):
```
[Kido] outer kernel, first adaptive breath
[Kido] arch: arm64 | handing off to kido_main...
[Kido] kido_main: scheduler init
[Kido] kido_main: 3 tasks created
[Kido] kido_main: entering scheduler (never returns)
ABCABCABCABC
```
Zero exceptions, exit 124. Re-proves the CURRENT tree on bare
metal — sessions 12/13 (reloc detect, phase-2 .S, actual bounds,
shifted carve) had never been QEMU-run since session 11. The
tripwire's delta-0 path (measure 0, crosscheck agree, proceed)
is proven by the boot proceeding past it.

**Addressing-model findings (empirical, P2):**
1. Same-TU globals (reloc BSS slots, last_cache) compile to
   direct PC-relative adrp/add — relocation-TRUE. The crosscheck
   genuinely compares under relocation (proven by the accidental
   run's agreement); an earlier GOT-based worry was wrong and was
   corrected by the disassembly before any claim was made.
2. Cross-TU globals (_image_start/_image_end via kido-image.c)
   compile GOT-relative; the static EXEC link leaves
   R_AARCH64_RELATIVE in .rela.dyn, never applied on bare metal
   (no dynamic linker) — so GOT accesses resolve to LINKED
   addresses permanently. kido_image_bounds() keeps its LINKED
   semantics under relocation: deliberation C1's premise
   VERIFIED, not assumed.
3. The probe constant: R_AARCH64_ABS64 at object level
   (session-12 proof); in the linked image it lands in .data with
   an unapplied RELATIVE holding the correct linked value
   (0x400036c0, dumped). Same observable (linker-resolved
   absolute, never PC-relative); the gate's intent holds, the
   spelling changed at link time — stated precisely for phase 3.
4. The .rela.dyn RELATIVE entries (10) are inert today and are
   phase 3's self-relocation manifest, already sitting in the
   image. Named, not built.

**Comment-only updates:** kido-entry-arm64.S PROOF STATUS header
("written, not assembled" → gate closed, with the
ABS64→RELATIVE nuance); kido-reloc.h PROOF STATUS note;
architecture/module-map.md reloc row.

**Test results (all real):** object gate — assemble PASS, readelf
ABS64 present, disassembly matches the design instruction for
instruction. Hosted battery (before QEMU): reloc 21/21, image
15/15, alloc 31/31, sched 75/75, resonate 59/59, interop 75/75,
mem ALL PASS, hal PASS, entry PASS, boot integration PASS
(kido_boot() → 0, AAAABBBBCCCC). QEMU: relocated run (silent
console, zero exceptions, loud halt — the tripwire path);
delta-0 control (breath → ABCABCABCABC, zero exceptions).

**Closed by this session:** the phase-2 .S object proof gate
(queued 2026-10-17); the relocated-load execution proof (queued
session 12); session-12's declared exposure, empirically; the
"current tree never QEMU-run since session 11" gap.

**Remains:** phase-3 PI build + self-relocation deliberation
(dissent D1, named — the .rela.dyn manifest is now confirmed
real); D1 KIDO_ERR_NO_TASKS header code (N8toriousAi's call);
DTB-region trim (kido-mem's future); destroy API; resonate
deferred delivery-at-yield; real BUBO peer + bare-metal
transport (Phase 4); UEFI/RPi4/MMU. First boot is N8toriousAi's to
witness.

## 2026-10-19 — Session 15: kido-reloc phase-3 design deliberation (builder crew)

**Goal:** the design behind session-12's preserved dissent D1,
explicitly named in the session-14 remains — "phase-3 PI build +
self-relocation deliberation." Design record only: no code written,
no proofs claimed. The module draft is the named next session.

**Deliberation:**
`deliberations/2026-10-19-kido-phase3-selfreloc-design.md`
(P1 relocation mechanic / P2 instrument keeper / P3 linker purist /
P4 honesty auditor / P5 portability auditor / P6 test keeper;
C1–C7 answered; D1–D3 preserved).

**Design (the equations):** loc_i = r_offset_i + delta;
*loc_i += delta for each R_AARCH64_RELATIVE except the probe
carve-out; BSS_zero = [_bss_start + delta, _bss_end + delta);
linked_base = actual_base − delta.

**Key decisions + why:**
1. Self-relocator in the entry .S, registers only, between the
   EL drop and SP setup (P1/C7). After it runs, every GOT-based
   C access resolves to the ACTUAL address — the C world becomes
   relocation-true by construction. Pure .S over C-with-args:
   a C relocator's safety would rest on "no cross-TU access ever,"
   which no compiler checks; the ~15-instruction .S loop is
   auditable instruction-for-instruction.
2. The probe constant MUST stay linked — it is manifest-visible
   (session-14 finding 3), so a blind walk would silently kill the
   detector (delta would read 0 forever). Linker script puts it in
   its own section (.rodata.kido_probe_linked); the relocator
   carves that range out (P2/C2). The .S literal instrument needs
   no carve-out — no reloc entry exists for it (finding 4).
3. Name the manifest in the linker script (P3): explicit .rela.dyn
   section with __rela_dyn_start/end — no orphan-placement luck.
   -fPIE overruled for this phase (D1): the manifest already
   exists under current flags; the image is small enough to audit
   (10 RELATIVEs + known .S literals + the probe constant).
4. The bounds split INVERTS (C3): post-fixup, kido_image_bounds()
   reads ACTUAL via the fixed GOT; linked_base = actual − delta
   (reloc owns the delta, one query, reversed). Phase-2's
   shifted-carve machinery becomes the normal path; zero
   allocator changes.
5. The tripwire is NOT deleted (P4): verify() gains a gated
   policy flip — relocation report (applied == expected, probe
   still linked) → OK; any failure → EARLY_ENV loud, as today.
   The flip waits on the build-time completeness audit (P6/C6):
   a script that fails the build on any uncovered absolute
   reference. No flip without the audit.
6. Proof plan (P5): session-14's relocated recipe (+0x80000) must
   now PROCEED to ABCABCABCABC, zero exceptions; the negative-
   delta run session-14's D1 named (−0x80000) finally gets its
   run (D3 adopted).

**Named next (module draft, one solid piece):** entry-.S
relocator loop + BSS-at-actual + report stash; linker-script
manifest + probe sections; kido-reloc.h/.c policy flip +
bounds inversion + hosted tests; the build-time completeness
audit script.

**Remains:** D1 KIDO_ERR_NO_TASKS header code (N8toriousAi's call);
DTB-region trim (kido-mem's future); destroy API; resonate
deferred delivery-at-yield; real BUBO peer + bare-metal
transport (Phase 4); UEFI/RPi4/MMU. First boot is N8toriousAi's to
witness.

## 2026-10-19 — Session 16: kido-reloc phase-3 module draft (builder crew)

**Goal:** the module draft session 15 named — entry-.S self-relocator +
BSS-at-actual + report stash; linker-script manifest + probe sections;
kido-reloc.h/.c policy flip (gated) + bounds inversion + hosted tests;
the build-time completeness audit script. One solid piece.

**Deliberation:** `deliberations/2026-10-19-kido-phase3-draft-design.md`
(P1 entry mechanic / P2 instrument keeper / P3 linker purist /
P4 honesty auditor / P5 portability auditor / P6 test keeper;
C1–C7 answered; D1–D2 preserved — D1: -fPIE still overruled,
inherited; D2: ship the .S without the probe-literal guard,
overruled as fail-closed).

**Constraining fact, stated first:** the cross toolchain is ABSENT
again (VM replacement; apt main pocket unreachable — the session-13
pattern). Proof posture is session-13's: .S WRITTEN, NOT ASSEMBLED;
audit script WRITTEN, NOT RUN; QEMU proofs QUEUED. Stated in every
file that carries it, not hand-waved.

**Drafted/changed:**
- `modules/kido-entry-arm64.S` — rewritten. Sequence: delta measure
  (unchanged) -> EL drop (unchanged) -> RELOCATE (new) -> SP =
  _stack_top + delta -> BSS zero at ACTUAL bounds (wrap-guarded;
  fixes the session-14 linked-BSS exposure) -> five-slot BSS stash
  (delta/valid/total/applied/carved/skipped) -> kido_entry_c_main.
  The relocator: register map x8(carved) x9(cursor) x10(end)
  x11(scratch) x12(loc) x13(r_info) x14/x15(carve range, actual)
  x16(total) x17(applied) x18(skipped); x19/x20 untouched; no SP
  use; sign-aware wrap guards (spin on wrap — the pre-console halt
  idiom); manifest-bounds sanity; per-entry loc wrap check; TWO
  carve-outs (probe section range + the .S's own probe_literal
  word via adr — the finding-4 ambiguity defended at runtime, ~3
  instructions, a no-op if finding 4 holds). Explicit
  `probe_literal:` label replaces the assembler-generated literal.
  Runs exactly once per boot; no re-entry path (stated).
- `modules/kido-link-arm64.ld` — explicit `.rela.dyn` with
  __rela_dyn_start/end (8-aligned, KEEP, inside image as law) and
  `.rodata.kido_probe_linked` with __probe_sec_start/end, placed
  BEFORE the generic .rodata (first-match idiom — *(.rodata*)
  would otherwise swallow it). Canonical RAM_BASE untouched.
- `modules/kido-reloc.h` — phase-3 honesty law; four new BSS-slot
  externs; kido_reloc_test_set_probe_ok (hosted); the stamp-gate
  documentation (NEVER hand-write the stamp); verify()'s gated
  contract; linked_base now DERIVED (actual - delta) on bare metal.
- `modules/kido-reloc.c` — probe constant moved to
  .rodata.kido_probe_linked via section attribute; stamp include via
  __has_include (the ONLY gate input); detect() bare-metal bounds
  inversion (actual from the fixed GOT, linked = actual - delta,
  wrap-guarded); new static helpers kido_reloc_report_check()
  (total>0, skipped==0, applied==total-carved, carved>=1 —
  overflow-free formulation) and kido_reloc_probe_still_linked()
  (C-side carve-out pin); verify() gated flip (gate closed: the
  phase-2 refusal, unchanged; gate open: report + probe pin, then
  a relocated image PROCEEDS). Self-test rewritten: 19 checks
  gate-closed (incl. the pin "perfect report still refuses") +
  28 checks flip-engaged (proceed matrix, loud on every report
  defect, crosscheck still precedes the policy, -0x80000 shape).
- `modules/kido-image.h/.c` — bounds inversion: bare-metal
  kido_image_actual_bounds() is now the thin alias (the GOT reads
  actual post-fixup); hosted keeps the injected+delta body.
  kido_sched_init untouched (its only consumer).
- `modules/kido-entry-arm64.c` — comment-only: WHAT IS REAL
  updated to phase 3; the kido_reloc_verify() wiring line UNCHANGED.
- `scripts/kido-audit-abs-refs.sh` — the gate (checks A-D):
  manifest sane + inside image; probe section inside image with
  exactly one OBJECT occupant; every dynamic reloc is RELATIVE and
  classified (manifest self-target -> FAIL; probe range or
  probe_literal addr -> carved; .got -> applied; else FAIL);
  total>=1, carved>=1; entry-object ABS* allowlist (8 symbols,
  each with its manual-+delta or by-design-linked justification).
  --stamp writes modules/kido-reloc-audit-stamp.h (sha256+counts+
  date) — the only way KIDO_RELOC_AUDIT_PASS gets defined.
- `scripts/fixtures/` + `scripts/test-audit-fixtures.sh` —
  fixture test for the audit's parsing/decision core (no toolchain
  needed): positive -> PASS with exact counts 10/9/1; rogue .text
  reloc -> FAIL ("uncovered absolute"); rogue ABS symbol -> FAIL
  (allowlist). Real pass/fail; the thin readelf-invocation layer
  is untested by construction, stated in the script header.
- `architecture/module-map.md` — reloc row: phase-3 drafted,
  proof status stated. `README.md` — layout gains scripts/.

**Key decisions + why:**
1. Three-layer defense for the finding-4 ambiguity (P2/C1/D2):
   runtime literal-guard + build-time audit enumeration + the
   existing crosscheck as detector. The ambiguity was unmeasurable
   without the toolchain; the draft refuses to bet the instrument
   on either reading.
2. The flip defaults CLOSED via a generated stamp, never a flag
   (P4): the .S mechanism runs unconditionally (fixups only make
   addresses correct), but the POLICY needs the audit's proof.
   A relocated image under the closed gate now refuses with
   correct addresses — strictly safer than phase 2.
3. Four report slots, not three (P2/C2): the .S counts carved on
   its skip branch so the hosted test's "unaccounted entry" case
   is meaningful.
4. Bounds inversion is bare-metal-only (P5): hosted keeps its
   declared fiction (no .S, no fixup there). kido_image_actual_
   bounds() becomes the alias on bare metal; sched untouched (C6).
5. Wrap-guarded .S arithmetic with spin (P1/C5): pre-console there
   is no louder; the C side re-validates with full knowledge.

**Test results (all real, hosted, gcc 13.3.0, -std=c11 -Wall
-Wextra -Werror, zero warnings everywhere):**
- reloc gate-closed 19/19; reloc flip-engaged 28/28 (both flavors
  compiled and run — the gate-closed pin proves "no flip without
  the audit").
- image 15/15; alloc 31/31; sched 75/75; resonate 59/59;
  interop 75/75; mem ALL PASS; hal PASS; entry PASS; boot
  integration PASS (kido_boot() -> 0, AAAABBBBCCCC).
- Syntax, all 10 TUs: PASS.
- Audit fixture test: ALL PASS (positive 10/9/1; both negatives
  fail for the right reasons, verified by message).
- Honest limits: .S unassembled (no cross toolchain); audit not
  run on a real image; no QEMU run (needs the toolchain; the
  session-15 proof plan +0x80000/-0x80000 stands queued).

**One real find during testing:** the flip-engaged self-test
failed once on "verify clean again after reset" — the test reset
the report slots to (0,0,0,0) while the flip flavor requires a
valid report even at delta 0. Test bug, not module bug; fixed by
resetting to a valid report. (The module was right: the walk
validates even when it adds nothing.)

**Remains:** assemble the .S + readelf + disassembly (queued on
toolchain); run the audit on the linked image (queued); the QEMU
relocated-proceed proofs (+0x80000, -0x80000 — the session-15
proof plan); D1 KIDO_ERR_NO_TASKS header code (N8toriousAi's call);
DTB-region trim (kido-mem's future); destroy API; resonate
deferred delivery-at-yield; real BUBO peer + bare-metal transport
(Phase 4); UEFI/RPi4/MMU. Phase 3 ENDS when a relocated image
PROCEEDS on QEMU with zero exceptions — not with a bootable
kernel claim. First boot is N8toriousAi's to witness.

## 2026-10-20 — Session 17: kido-resonate deferred delivery at yield (builder crew)

**Goal:** close the D2 refinement queued since the 2026-10-14 resonate
design ("Deferred delivery at yield. Overruled for v1: evaluating at
yield would need hooks in the fenced scheduler files. Queued as a
future refinement with its justification intact."). One solid piece:
the design record + the module draft. Phase-3 QEMU proofs stay queued
— the cross toolchain is absent again (no aarch64-linux-gnu-gcc, no
qemu-system-aarch64, apt cannot locate the package; session-13 pattern).

**Deliberation:**
`deliberations/2026-10-20-kido-resonate-deferred-design.md`
(P1 medium realist / P2 fence keeper / P3 honesty auditor /
P4 radio semanticist / P5 courier advocate / P6 static-tables keeper;
C1–C8 answered; D1–D3 preserved — D1 scheduler-hook drain overruled,
fence stands; D2 transmit-time eta overruled, radio semantics;
D3 unbounded outbox overruled, static-tables law).

**Drafted/changed:**
- `modules/kido-resonate.h` — COOPERATIVE LAW rewritten for two modes;
  `KIDO_RESONATE_OUTBOX_DEPTH 32u`; new API: `kido_resonate_defer()`
  (the door: accepted/refused out-params, arg errors loud),
  `kido_resonate_drain()` (delivery at the caller's pace, three
  aggregates required non-NULL), `kido_resonate_courier()` (canonical
  drain/yield/forever task body — never returns by design),
  `kido_resonate_mesh_stats()` + `kido_resonate_mesh_stats_t`
  (outbox_pending, deferred_total, mesh_dropped, dissipated).
- `modules/kido-resonate.c` — static 32-deep outbox ring (allocator
  stays fenced); the receiver-evaluation loop extracted into one
  shared `mesh_deliver_entry()` used by BOTH paths (no duplicated
  truth); transmit() rewritten on the helper (one release-moment
  arrival stamp per call instead of per receiver — no test
  distinguishes; noted); defer() (door: full outbox = counted
  refusal, tx_sent only on accepted); drain() (FIFO walk, eta vs
  CURRENT tuning, arrival stamped at drain, zero-candidate entries
  consumed + counted as dissipated); courier body; init() resets all
  mesh state. `kido_signal_t` UNCHANGED — interop's envelope wraps it
  whole, zero interop changes. Zero kido-sched.c/h changes — the
  courier is a plain task on public create/yield.
- Self-test section 12 (77 new checks): door arg guards; defer
  accepted + receiver sees nothing until drain; drain delivers with
  arrival-at-drain; eta-at-drain pinned by varying Q (narrow→wide
  flips reject→deliver on the same deferred signal, and back);
  outbox-full door refusal loud + counted; drain of 32 into an
  8-deep queue = 8 delivered + 24 dropped; unheard signal dissipates
  counted; tx_sent counts accepted defers only.

**One real find during testing:** the first 12d draft conflated band
addressing with eta selectivity (retuned the receiver to a different
band, so the signal was never a candidate — the module correctly
dissipated it, and the test wrongly expected rejection). Fixed by
holding the band constant and varying Q — the true selectivity axis.
Test bug, not module bug; the module was right.

**Key decisions + why:**
1. No scheduler hooks, ever (P2/D1): the courier task delivers the
   yield rhythm through public API. The fence and the QEMU proof
   chain it protects are worth more than a hook's elegance.
2. eta at drain, arrival at drain (P4/C4): radio semantics — you hear
   what is on when you are listening; arrival means arrival at the
   receiver. Defer-time is transit, not arrival.
3. defer() reports only what the door knows (P3/C1): accepted vs
   refused. Projecting receiver outcomes at defer time would be
   fiction.
4. Unheard signals dissipate LOUD (C8): consumed at drain, counted —
   a broadcast with no listeners vanishes, visibly.
5. Synchronous path bit-identical (C5): deferred is additive opt-in;
   the 59 original checks pass unmodified.

**Test results (all real, hosted, gcc 13.3.0, -std=c11 -Wall
-Wextra -Werror, zero warnings everywhere):**
- resonate 136/136 (59 original unmodified + 77 new).
- Regression: sched 75/75; alloc 31/31; image 15/15; reloc 19/19
  gate-closed + 28/28 flip-engaged; interop 75/75 (against the new
  header — envelope untouched, confirmed); mem ALL PASS; hal PASS;
  entry PASS; boot integration PASS (kido_boot() -> 0, AAAABBBBCCCC).
- Audit fixture test: ALL PASS (unchanged).
- Honest limits: .S unassembled, audit not run on a real image, no
  QEMU run — cross toolchain absent (queued, unchanged).

**Remains:** phase-3 proofs — assemble .S + readelf + disassembly,
run the audit on the linked image, QEMU relocated-proceed (+0x80000,
-0x80000) — all queued on the toolchain; D1 KIDO_ERR_NO_TASKS header
code (N8toriousAi's call); DTB-region trim (kido-mem's future); destroy
API; real BUBO peer + bare-metal transport (Phase 4); UEFI/RPi4/MMU.
First boot is N8toriousAi's to witness.

## 2026-10-20 — Session 18: kido-reloc phase-3 PROOFS (builder crew)

**Goal:** close the phase-3 proof gates the session-16 draft left
open — assemble the rewritten entry .S + readelf + disassembly, run
the completeness audit on the real linked image, and execute the
session-15 proof plan (QEMU relocated-proceed at +0x80000 and
-0x80000). The cross toolchain is PRESENT (aarch64-linux-gnu-gcc
13.3.0, qemu-system-aarch64 8.2.2). Phase 3 ENDS when a relocated
image PROCEEDS on QEMU with zero exceptions — that bar is met.

**Deliberation:**
`deliberations/2026-10-20-kido-phase3-proof-design.md`
(P1 regression keeper / P2 object prover / P3 audit gatekeeper /
P4 relocation experimenter / P5 honesty auditor; C1–C5 answered;
D1–D2 preserved — D1: -fPIE still overruled, sharpened by F4;
D2: per-image stamping overruled as theater, kept honest).

**Regression gate first (all real, hosted, gcc 13.3.0, zero
warnings):** reloc 19/19 gate-closed + 28/28 flip-engaged, image
15/15, alloc 31/31, sched 75/75, resonate 136/136, interop 75/75,
mem ALL PASS, hal PASS, entry PASS, boot integration PASS
(kido_boot() -> 0, AAAABBBBCCCC), audit fixture test ALL PASS.
One battery-script bug of mine (interop over-linked six TUs;
its core only needs kido_signal_t's type) — fixed, 12/12.
Re-run after ALL source changes: still 12/12.

**Four real finds — each diagnosed once, fixed once:**

- **F1 (assembler warning):** first cross compile warned
  "setting incorrect section attributes for
  .rodata.kido_probe_linked" — GCC marks the section writable
  ("aw") because the static linker only emits the load-bearing
  R_AARCH64_RELATIVE for the probe word in a writable section;
  GAS expects readonly for `.rodata*`. The writability is
  functionally required (carved >= 1 is fail-closed). Fix:
  renamed to `.data.kido_probe_linked` (reloc.c/.h, linker
  script, audit script, fixture) + comment stating the
  writability is load-bearing. Zero warnings restored.
- **F2 (manifest bounds stale — the gate's first catch):** the
  audit failed CLOSED (`__rela_dyn_start == __rela_dyn_end`
  while the section header carried 0x150). Cause: `.rela.dyn`
  content is LINKER-GENERATED (no input section is ever named
  `.rela.dyn`); in-section `.` assignments don't see the
  generated size. Fix: `__rela_dyn_start = ADDR(.rela.dyn)`,
  `__rela_dyn_end = ADDR(.rela.dyn) + SIZEOF(.rela.dyn)`
  post-layout. Verified by readelf (0x40084608/0x40084758).
- **F3 (readelf -SW bracket fragility — the gate's second
  catch):** the audit's section parser assumed `$3 == name`;
  binutils 2.42 prints `[ 2]` (two fields) for single-digit
  indices but `[13]` (one field) for double-digit ones —
  `.got` (index 13) misread as absent on a 21-section image.
  The fixture only had single-digit indices. Fix: collapse
  `[ *N]` to `[N]` once in analyze(); fixture extended with 5
  dummy sections pushing `.got` to index 10; counts re-pinned
  10/8/2. Also fixed a `trap ... RETURN` + `set -u` expansion
  bug in the same edit.
- **F4 (finding 4 REFUTED — the gate's third catch, the big
  one):** session-14's finding 4 ("the probe_literal word
  carries NO dynamic reloc entry") was an unmeasured reading.
  Measured now: the linked `.rela.dyn` carries RELATIVEs for
  ALL EIGHT literal-pool words. The draft's exact-address guard
  would have let the walk patch the other seven — and the
  post-walk loads of _stack_top/_bss_start/_bss_end would have
  double-added the delta (linked + 2*delta: wrong SP, wrong
  BSS — a real boot-killer, caught at the audit gate, never on
  hardware). Fix: literal-pool RANGE carve-out in the .S
  (`adr` of literal_pool_start/end, `.ltorg` for a deterministic
  layout) + audit check-C rework (pool range -> carved; any
  other .text absolute -> FAIL fail-closed; .got/.data/... ->
  applied).

**Changed:**
- `modules/kido-entry-arm64.S` — range carve-out replaces the
  exact-address guard; `.ltorg` + pool-bound labels; finding-4
  refutation note; PROOF STATUS -> gates closed.
- `modules/kido-link-arm64.ld` — manifest bounds via
  ADDR/SIZEOF; probe section renamed with corrected
  first-match comments.
- `modules/kido-reloc.c` — section attribute renamed;
  load-bearing-writability comment. `modules/kido-reloc.h` —
  PROOF STATUS updated.
- `scripts/kido-audit-abs-refs.sh` — bracket normalization;
  check-C rework; trap fix.
- `scripts/fixtures/` + `scripts/test-audit-fixtures.sh` —
  double-digit coverage; counts 10/8/2.
- `architecture/module-map.md` — reloc row: phase-3 proven.

**Object gate:** 10 TUs cross-compile, zero warnings; entry.o
23 relocs (8 ABS64, all allowlisted; adrp/add instrument
PC-relative); disassembly matches the .S
instruction-for-instruction (`cmp w11, #0x403`, wrap guards,
both carve-outs, counters).

**Audit on the real image:** PASS total=14 applied=5 carved=9
on all three link addresses (8 pool + 1 probe + 2 .data +
3 .got; carved 9 = 8 pool + 1 probe; applied 5 = 2 .data +
3 .got). Stamp loop per image (audit -> stamp -> rebuild ->
re-audit); tree left WITHOUT the stamp (gate-closed is the
honest default; the stamp is generated per build).

**THE PROOFS (QEMU virt / cortex-a57 / 128 MiB, raw binary,
-kernel, -d int; logs in deliberations/
2026-10-20-qemu-phase3-proof*.log):**
1. delta-0, gate open: breath -> scheduler init -> 3 tasks ->
   ABCABCABCABC -> halt spin. Zero exceptions.
2. +0x80000, gate open: PROCEED -> breath -> ABCABCABCABC.
   Zero exceptions. **Phase-3 end criterion, first half.**
3. -0x80000, gate open: PROCEED -> breath -> ABCABCABCABC.
   Zero exceptions. **Phase-3 end criterion, second half**
   (session-14 D1's named run; sign-aware .S path + C-side
   linked = actual - delta both execute).
4. +0x80000, gate CLOSED: silent console, zero exceptions,
   timeout in the halt spin — correct addresses AND a loud
   refusal, never correct addresses silently.

**Phase 3 ENDS here:** a relocated image PROCEEDS on QEMU with
zero exceptions, both signs, with the gated audit as the flip's
only key. Not a bootable kernel claim — the full build plan
still queues for N8toriousAi's review; first boot is his to witness.

**Remains:** D1 KIDO_ERR_NO_TASKS header code (N8toriousAi's call);
DTB-region trim (kido-mem's future); destroy API; real BUBO peer
+ bare-metal transport (Phase 4); UEFI/RPi4/MMU. First boot is
N8toriousAi's to witness.

## 2026-10-21 — Session 19: kido-mem DTB-extent trim (builder crew)

**Goal:** close the named future from session-10 deliberation C4 and
session-16 D3 — "DTB-region trim (kido-mem's future)": the firmware
DTB blob lives in RAM inside the /memory regions, so the raw seed
list handed the DTB's own pages to the allocator. Safe until now by
measured layout only (first-fit grows low->high; the DTB sits
higher) — the exact posture kido-image closed for the kernel image.
One solid piece: the seed list becomes usable-by-construction.

**Deliberation:**
`deliberations/2026-10-21-kido-dtb-trim-design.md` (P1 discovery
purist / P2 honesty auditor / P3 portability auditor / P4 allocator
client / P5 bound keeper / P6 test keeper; C1–C6 answered; D1–D2
preserved — D1: 8->16 vs fail-loud-on-9th-split, overruled;
D2: injector-honesty standing note).

**Drafted/changed:**
- `modules/kido-mem.h` — KIDO_MEM_MAX_REGIONS 8->16 (still static,
  never allocates; the bound is a documented bet); discover doc
  gains the DTB-trim law (extent = re-validated totalsize, never
  dtb_len slack; split/drop/no-op semantics; overflow/bound loud);
  seed-list doc rewritten (usable regions, no longer raw);
  hosted-only `kido_mem_test_set_dtb_extent()` injector prototype
  (vacuous (0,0) default — the kido-image precedent).
- `modules/kido-mem.c` — pure trimmer (`kido_mem_trim_emit/one/
  regions`, half-open intervals, `x+y<x` overflow idiom); discover
  trims BEFORE primary selection and seed publication (bare metal:
  `(uint64_t)(uintptr_t)dtb` + totalsize; hosted: injector);
  primary = largest TRIMMED region; /memreserve/ honoring
  unchanged on the trimmed primary (its interior-hole loud rule
  stands — C1 distinguishes it from the multi-region seed split);
  `g_regions` publishes the trimmed list. Self-test: fixtures
  `tb_one_region/tb_two_regions` + `region_is`, sections 12–20
  (interior split, head trim, tail trim, full cover -> NO_MEMORY,
  no-overlap no-op, two-region straddle, zero-size no-op, primary
  falls to survivor, injector reset -> raw). kido-sched.c,
  kido-boot.c, entry, HAL: ZERO changes (P4 — the seed list is the
  seam).
- `architecture/module-map.md` — kido-mem row: trim landed +
  measured virt numbers.

**Key decisions + why:**
1. Trim inside discover, not a new API (P1): discover is the single
   producer of the seed list; a separate trim call would be a
   call-order trap for sched_init.
2. Split is honest HERE though session-3 D2 forbade it THERE (C1):
   D2 was /memreserve/ interior vs the single-region primary
   (unrepresentable -> loud); the seed list is multi-region by
   design, and the extent is discover's own input.
3. No-overlap is a no-op, never an error (P2): absence is a fact.
   Full cover of all regions is NO_MEMORY loud.
4. totalsize, not dtb_len, bounds the extent (P2/C3) — exactly what
   discover vouches for.

**One corrected assumption:** the design assumed the virt DTB sits
at the top of RAM; measured on the real run it loads at
0x44000000 (1 MiB extent). The trim executed the interior-split
path, not the tail-trim path — measurement beat the assumption,
and the hosted test had already pinned both geometries.

**Test results (all real):**
- Hosted battery: mem 53/53 (22 old + 31 new), alloc 31/31, sched
  75/75, resonate 136/136, interop 75/75, image 15/15, reloc 19/19
  closed + 28/28 flip, entry PASS, boot integration PASS
  (kido_boot() -> 0, AAAABBBBCCCC); audit fixture test ALL PASS.
  Zero warnings everywhere (gcc 13.3.0, -Wall -Wextra -Werror).
- Cross-compile: all 10 TUs, aarch64-linux-gnu-gcc 13.3.0,
  -ffreestanding -O0 -Wall -Wextra -Werror: PASS, zero warnings.
- QEMU virt/cortex-a57/128MiB, raw binary at 0x40080000, -d int
  (pristine tree, harness linker copy only): breath ->
  `kido_main: 3 tasks created` -> ABCABCABCABC -> timeout 124
  (designed halt spin). ZERO exceptions. Log:
  deliberations/2026-10-21-qemu-dtb-trim-proof.log.
- Measurement build (SCRATCH, /tmp only, never committed): the
  same kido-mem.c + a raw-PL011 puts TU printed the live trim:
  dtb_extent=[0x44000000, 0x44100000), ntrimmed=2,
  r0=[0x40000000, 64MiB). The allocator's real seed on virt is
  now 64MiB + 63MiB with the DTB's megabyte excluded — by design.
  Log: deliberations/2026-10-21-qemu-dtb-trim-measure.log.

**Remains:** D1 KIDO_ERR_NO_TASKS header code (N8toriousAi's call);
destroy API; real BUBO peer + bare-metal transport (Phase 4);
UEFI/RPi4/MMU. First boot is N8toriousAi's to witness.

## 2026-10-21 — Session 20: kido_sched_destroy — teardown at rest (builder crew)

**Goal:** close the destroy API queued since session 6 (D1: "When a destroy
API is specified, it will free — and be tested then"). kido_free had been
test-only since day one; destroy is the API that makes it live in
production. One solid piece: the teardown at rest.

**Deliberation:**
`deliberations/2026-10-21-kido-sched-destroy-design.md` (P1 teardown
realist / P2 refusal purist / P3 ownership accountant / P4 state-law
keeper / P5 fence keeper; C1–C6 answered; D1–D2 preserved — D1:
force-teardown over live tasks, overruled; D2: destroy resets the
allocator too, overruled).

**Drafted/changed:**
- `modules/kido-sched.h` — `kido_sched_destroy()` prototype + the REFUSAL
  LAW / OWNERSHIP LAW doc block; draft-status paragraph notes the
  teardown. No existing signature or semantic moved (fence).
- `modules/kido-sched.c` — the destroy implementation (after
  kido_sched_run): refusal gate BEFORE any free (EARLY_ENV on never-
  initialized / already-destroyed / any READY or RUNNING task —
  self-destruction from inside a task refused by the same rule);
  free-then-clear per slot (kido_free needs the stack_base the slot
  holds), fail-stop on a failed free with the allocator's status
  propagated and the slot kept (partial teardown caller-visible, never
  misreported OK); module state back to never-initialized (sched_hal
  NULL — the existing "init not called" convention, no new flag); ctx
  zeroed field-wise, no libc. The allocator and its image carve-out are
  NOT sched's property: untouched by destroy.
- Self-test sections 50–59 (35 new checks): destroy over READY refuses
  and leaves table+allocator byte-identical; destroy over RUNNING with
  the current-task pointer set (the self-destruction shape) refuses the
  same way; happy path frees every stack (allocs == frees,
  allocated_bytes == 0) with total_bytes still carved; create after
  destroy -> EARLY_ENV; destroy twice -> EARLY_ENV; re-init round trip
  ends at rest (allocator reset per existing law, carve-out survives).
- `deliberations/2026-10-21-kido-sched-destroy-conformance.md` —
  16 MET / 0 PARTIAL / 0 DEFERRED / 2 PENDING (environmental).
- `architecture/module-map.md` — kido-sched row: teardown landed.

**Key decisions + why:**
1. Refusal instead of force-teardown (P2/D1): freeing the stack of a
   READY/RUNNING task — especially the RUNNING one the caller stands on —
   is use-after-free with no safe default. Refusal is the safe default
   that exists; forcing is N8toriousAi's call, and he is away.
2. Allocator untouched (P3/D2): the image carve-out protects the image
   that is still executing the caller. destroy = free what I own;
   init = rebuild the world.
3. No new header code: refusal reuses KIDO_ERR_EARLY_ENV; D1's
   KIDO_ERR_NO_TASKS stays N8toriousAi's call.
4. No QEMU owed: no asm, boot path, or relocation logic touched.

**Test results (all real):**
- Hosted battery, gcc 13.3.0, -Wall -Wextra -Werror, zero warnings:
  sched 110/110 (75 prior + 35 new), mem PASS, alloc 31/31, resonate
  136/136, interop 75/75, image 15/15, reloc 19/19, boot integration
  PASS.
- Cross-compile (aarch64, -ffreestanding): PENDING — this VM has no
  aarch64-linux-gnu-gcc (session 19's toolchain absent); apt install was
  still in flight at session end. The new code's only arch-sensitive
  lines are the ctx-zeroing #if branches, which mirror the file's
  existing split.

**Remains:** D1 KIDO_ERR_NO_TASKS header code (N8toriousAi's call); destroy
API — CLOSED this session; real BUBO peer + bare-metal transport
(Phase 4); UEFI/RPi4/MMU; cross-compile rerun on a tooled VM. First boot
is N8toriousAi's to witness.

## 2026-10-22 — Session 21: current-tree verification — close session-20's environmental PENDINGs (builder crew)

**Goal:** close the 2 PENDING items session 20's conformance review left
open (cross-compile rerun; kido-reloc self-test rerun on the settled
tree). Verification session in the sessions-6/8/11/14/18 lineage: run
what the VM can run, attempt what it might run, record the outcome as
evidence. Pristine sources; /tmp scratch only.

**Deliberation:** `deliberations/2026-10-22-kido-session21-verify-design.md`
(P1 regression keeper / P2 pending closer / P3 toolchain realist /
P4 honesty auditor / P5 scope keeper; C1–C5 answered — C4 resolved in-run:
the boot-integration link set kido-boot.c + kido-sched.c + kido-alloc.c +
kido-image.c + kido-reloc.c links clean, hosted probe is a stub so mem/HAL
stay out; D1–D2 preserved — D1: defer-everything-till-toolchain overruled,
D2: skip-the-battery overruled).

**Toolchain re-attempt (PENDING #1 — STAYS OPEN):** `apt-get install -y
gcc-aarch64-linux-gnu` executed this session: "E: Unable to locate
package" — main pocket still unreachable (4th occurrence: sessions
13/17/20/21). Harder fact than before: the binutils present in
/usr/bin are analysis-only (as, ld, objcopy, readelf, nm, objdump —
NO `aarch64-linux-gnu-as`, NO cross gcc, NO qemu-system-aarch64).
Even the deliberation's .S drift-detector run could not execute
(`as: command not found`). There is no substitute path: the C
compiler is the gate, and it is absent. PENDING #1 remains open with
this dated evidence; nothing about the hosted results below
substitutes for it.

**PENDING #2 — CLOSED:** kido-reloc self-test rerun on the settled tree
(session-20's exact deferred item): gate-closed 19/19 + flip-engaged
28/28, zero warnings.

**Full hosted battery on the settled tree** (gcc 13.3.0, -std=c11
-Wall -Wextra -Werror, zero warnings everywhere; tree byte-untouched
since session 20's destroy, timestamps confirmed):
- reloc gate-closed 19/19, flip-engaged 28/28
- image 15/15; alloc 31/31
- sched 110/110 (incl. destroy §§50–59 — teardown at rest re-proven)
- resonate 136/136; interop 75/75; mem ALL PASS; hal PASS; entry PASS
- boot integration PASS (kido_boot() -> 0, AAAABBBBCCCC)
- audit fixture test ALL PASS (positive 10/8/2; both negatives fail
  for the right reasons)
- 12/12 binaries PASS, 0 failures.

**Key decisions + why:**
1. No QEMU owed (P4): nothing in the boot path, asm, or relocation
   logic changed since session 19's QEMU run. A re-run would be
   theater, not verification — stated, not hidden.
2. Destroy's ARM64 ctx-zeroing #if branches are NOT covered by the
   hosted battery (C2) — inspection-only (they mirror the file's
   existing #if split). This is exactly PENDING #1's territory.
3. The battery TU sets are now derived-from-source and recorded in
   the design deliberation (C4), so the next battery re-run has no
   recipe ambiguity.

**Remains:** PENDING #1 — aarch64 cross-compile of the touched TUs
(5th data point: toolchain absent again; apt main pocket
unreachable); D1 KIDO_ERR_NO_TASKS header code (N8toriousAi's call);
destroy API — CLOSED; real BUBO peer + bare-metal transport
(Phase 4); UEFI/RPi4/MMU. First boot is N8toriousAi's to witness.

## 2026-10-22 — Session 22: kido-mmu draft (builder crew)

**Pivot, stated first:** this session opened as the destroy-on-bare-
metal verification session (deliberation
`2026-10-22-kido-session22-destroy-proof-design.md` — close PENDING
#1, delta-0 re-proof, scratch destroy-gate image). The toolchain was
PRESENT at session start (`aarch64-linux-gnu-gcc` resolved via
`which`, full binutils family listed, `apt-get install` reported the
package newest) and ABSENT minutes later (binary gone from
`/usr/bin`, `ls | grep -c aarch64` = 0, `apt-get install` ->
"E: Unable to locate package" — main pocket unreachable). The hosted
battery had already passed 12/12 before the toolchain vanished. Per
the destroy-proof design's own C6, the session degraded honestly:
PENDING #1 stays OPEN with a 5th dated data point (observed present
then absent within one session — harder evidence than the prior
four "absent" notes), the QEMU halves could not run, and the session
picked up the next unbuilt module: **kido-mmu**, the last named
remains item ("UEFI/RPi4/MMU") draftable without hardware. The
destroy-proof deliberation keeps a marked post-hoc outcome note; its
design stands ready for the next tooled VM.

**Deliberation:**
`deliberations/2026-10-22-kido-session22-mmu-design.md`
(P1 table-builder / P2 static-tables keeper / P3 attribute realist /
P4 enable-order purist / P5 seam declarer / P6 test keeper;
C1–C7 answered; D1–D3 preserved — D1 48-bit overruled, D2
kido-mem coupling overruled, D3 wiring the seam now overruled as a
future Gate item).

**Drafted:**
- `modules/kido-mmu.h` — interface + design law + PROOF STATUS
  (construction REAL/host-tested; register sequence WRITTEN NOT
  ASSEMBLED NEVER EXECUTED; call site DECLARED NOT WIRED).
- `modules/kido-mmu.c` — 4 KiB granule, 39-bit VA (T0SZ=25), walk
  from L1; largest-fitting blocks (L1 1 GiB / L2 2 MiB / L3 4 KiB
  pages), exact coverage, identity map (VA == PA — the MMU's job
  here is caches + memory attributes, not virtual-memory
  theater); 16-page bounded static BSS tables, caller-supplied
  map (no kido-mem/HAL coupling); MAIR {0x00 device-nGnRnE,
  0xFF normal WBWA}; pure-C TCR/MAIR values; enable sequence
  TLBI -> TTBR0 -> TCR -> MAIR -> DSB/ISB -> SCTLR |= M|C|I ->
  ISB as real inline asm with a hosted double recording
  order + values. Declared seam: after kido_reloc_verify() OK,
  before kido_boot() (the phase-3 relocator runs MMU-off;
  wiring waits for the Gate — zero approved files touched).
- `architecture/module-map.md` — kido-mmu row added (DRAFT).

**One real find during testing (the session's catch):** the first
self-test run segfaulted, and diagnosis showed the static
`s_tables` array was only 8/16-byte aligned — the architecture
ignores descriptor/TTBR address bits [11:0], so every table
address was silently corrupted (the test caught bit 6 being
masked out of a descriptor). Fix: `__attribute__((aligned(4096)))`
on the tables — alignment is load-bearing, now stated in the
module and pinned by a self-test check ("L1 root 4KiB-aligned").
On bare metal this would have been a silent MMU-death; the
scaffold's test-everything law earned its keep again.

**Two test bugs of mine (module was right):** L2 indices for the
RAM blocks (wrote the test expecting 0x200+i; the walker's
bits-[29:21] gives 0..63 — the module's placement was correct)
and the "RAM tail" address (0x47FFFFF, dropped an F — the last
byte is 0x47FFFFFF). Fixed; the module was right both times.

**Test results (all real, gcc 13.3.0, -std=c11 -Wall -Wextra
-Werror, zero warnings):**
- kido-mmu self-test: 121/121, 0 failures — TCR/MAIR bit-exact
  (0x200993519 / 0xFF00); 9 arg-guard loudness checks (NULL,
  empty, zero-size, misaligned base/size, wrap, VA-limit breach,
  bad attr, overlap); canonical map (128 MiB RAM + UART) walked
  by the independent walker (64 exact 2 MiB blocks, device attrs
  on UART, unmapped VAs fault); 1 GiB block path; L3 4 KiB page
  path; exhaustion -> NO_MEMORY loud (8th scattered page);
  idempotent rebuild; enable double (TLBI->TTBR0->TCR->MAIR->
  SCTLR order + values, SCTLR sets M|C|I only).
- Full battery re-run: 13/13 PASS (sched, resonate, alloc, mem,
  image, reloc-closed, reloc-flip, interop, entry, hal, mmu,
  boot integration, audit fixtures). Zero warnings everywhere.
- Honest limits: enable asm unassembled + unexecuted (no
  toolchain — 5th data point); call site not wired (Gate item);
  PENDING #1 still open; destroy bare-metal proof still queued
  for a tooled VM.

**Remains:** PENDING #1 — aarch64 cross-compile (5th data point:
toolchain observed present then absent within this session; apt
main pocket unreachable); destroy bare-metal proof (design
ready: deliberations/2026-10-22-kido-session22-destroy-proof-
design.md); D1 KIDO_ERR_NO_TASKS header code (N8toriousAi's call);
kido-mmu call-site wiring (future Gate item); real BUBO peer +
bare-metal transport (Phase 4); UEFI/RPi4. First boot is N8toriousAi's
to witness.

## 2026-10-23 — Session 23: kido-mem UEFI discovery (builder crew)

**Goal:** close the last open DEFERRED item from the session-3
conformance review — the UEFI memory-map discovery path, a loud
`KIDO_ERR_STUB_REACHED` stub since 2026-10-14. The "UEFI/RPi4/MMU"
remains had MMU drafted (session 22); UEFI is the next unbuilt
module-path draftable without hardware: pure data parsing, portable
C, host-testable. One solid piece.

**Deliberation:**
`deliberations/2026-10-23-kido-uefi-design.md` (P1 contract realist /
P2 classifier / P3 pipeline keeper / P4 honesty auditor / P5 test
keeper; C1–C8 answered; D1–D3 preserved — D1: separate kido-uefi
module overruled (one seed table, one law); D2: fail-loud on
map-buffer overlap overruled (trim-and-survive, the DTB precedent);
D3: trust-firmware-ordering overruled (insertion sort, no bet)).

**Drafted/changed:**
- `modules/kido-mem.h` — `kido_mem_discover_uefi` prototype extended
  to the real `GetMemoryMap` contract: `(mmap, mmap_len, desc_size,
  desc_version, bi)`. The stub's 3-arg seam could not name the
  stride or version — a v2 descriptor would have been silently
  mis-parsed. Zero downstream churn (the stub was never called).
  Full doc: EBS caller contract, the type law, the pipeline, the
  portability law (little-endian manual loads, no struct casts).
- `modules/kido-mem.c` — the implementation: descriptor v1 fields
  read with bounds-checked little-endian loads (the `fdt_u32`
  idiom's LE twin); version gate first; stride >= 40 (wider
  strides parse the v1 prefix); ragged maps loud; page-count and
  address overflow loud (`x+y<x` idiom); zero-page entries no-op;
  pairwise overlap audit over a bounded 64-entry walk
  (contradictory firmware -> loud, never merged); type
  classification (Conventional + BootServices code/data seeded —
  the EBS contract; loader/ACPI-reclaim/persistent/reserved/
  runtime/MMIO/PAL/unknown excluded, each declared); insertion
  sort by base; coalesce adjacent contiguous usable; the map
  buffer's own `[mmap, mmap+len)` extent trimmed with the SHARED
  trimmer (the DTB-extent-trim precedent — no duplicated truth);
  one 16-region bound; shared `kido_mem_publish()`. The DTB path's
  tail was extracted into `kido_mem_publish()` (selection +
  bootinfo fill + seed publication); its memreserve honoring now
  runs against the published primary, clearing `mem_valid` on its
  loud paths — observable behavior byte-identical, pinned by the
  suite. VirtualStart ignored (no SetVirtualAddressMap), Attribute
  unread — both declared.
- Self-test: old §11 (stub test) replaced by 11 UEFI arg-guard
  checks; new §§21–32 (39 checks): mixed-type classification,
  all-excluded loud, zero-page no-op, overflow loud, coalescing,
  overlap loud, 64-entry bound, unknown-type skip, stride-48,
  BS-large primary, real-address buffer-trim split (a synthetic
  region straddling the test buffer's REAL address — the trimmer
  runs on real addresses), unsorted-input sort+coalesce. The
  emitter writes garbage VirtualStart/Attribute to prove they are
  unread.
- `architecture/module-map.md` — kido-mem row: UEFI landed.

**Key decisions + why:**
1. Five-arg seam (P1/C1): the contract says what the firmware
   says. The version check is the first gate — a newer layout
   must never be silently mis-parsed.
2. BootServices code/data seeded under the EBS contract (P2/C2):
   reclaimable after ExitBootServices; the future entry-shim UEFI
   path owns the call order. Calling pre-EBS would hand live
   firmware pages to the allocator — stated, not assumed.
3. Overlap -> loud (P4/C3): a self-contradictory map is
   untrustworthy ground truth. Merging would invent geometry.
4. Map-buffer trim, not declaration (P4/C4): trim-and-survive
   beats fail-loud on a loader quirk; the buffer holds our
   already-parsed ground truth, so trimming cannot corrupt the
   parse. Vacuous on honest loaders.
5. Shared publish (P3/C6): one selection law for both paths. The
   DTB path's memreserve adjustment is preserved exactly —
   publish first, adjust the published primary after.
6. ACPI reclaim + persistent memory excluded, declared (C7/C8):
   reclaiming ACPI needs an ACPI parser (named future); PM needs
   a PM driver. Claiming either as DRAM would be fiction.

**One real find during drafting:** none in the module — the suite
passed 100/100 on the first run. One bookkeeping correction: the
ledger's session-19 "mem 53/53" count is off by one against the
current source (the pre-existing suite is 50 checks: §§1–10 = 19,
§§12–20 = 31); the old §11's 2 checks are replaced, not kept.

**Test results (all real, hosted, gcc 13.3.0, -std=c11
-Wall -Wextra -Werror, zero warnings everywhere):**
- kido-mem: 100/100 (50 pre-existing + 50 new UEFI).
- Full battery 12/12: alloc 31, image 15, reloc 19 closed + 28
  flip-engaged, sched 110, mem 100, hal PASS, entry PASS, mmu 121,
  resonate 136, interop 75, boot integration PASS. (Battery TU
  sets re-derived this session: hal/entry self-test macro names
  are KIDO_HAL_ARM64_SELFTEST / KIDO_ENTRY_ARM64_SELFTEST; entry
  links mem+reloc+image; reloc flip flavor is -DKIDO_RELOC_
  AUDIT_PASS.)
- Audit fixture test: ALL PASS (unchanged).
- Honest limits: cross-compile + QEMU queued on the toolchain —
  ABSENT again this session (6th data point: `apt-get install
  gcc-aarch64-linux-gnu` -> "Unable to locate package", main
  pocket unreachable). PENDING #1 stays open. The new code's only
  arch-sensitive surface is the `(uintptr_t)mmap` extent line,
  mirroring the DTB path's existing line.

**Remains:** D1 KIDO_ERR_NO_TASKS header code (N8toriousAi's call);
kido-mmu call-site wiring (future Gate item); destroy bare-metal
proof (design ready, queued on the toolchain); RPi4 UART init
(board-specific; queued); real BUBO peer + bare-metal transport
(Phase 4); PENDING #1 cross-compile (6th data point: toolchain
absent). First boot is N8toriousAi's to witness.

## 2026-10-23 — Session 24: kido-hal RPi4 UART init (builder crew)

**Goal:** close the session-2 (2026-10-14) loud stub — the RPi4 board
entry in `kido-hal-arm64` (`fill(RPI4) -> KIDO_ERR_STUB_REACHED`).
The oldest open draftable item in the scaffold, and the last of the
"UEFI/RPi4/MMU" remains (MMU drafted session 22, UEFI closed session
23). One solid piece: AUX mini-UART init sequence + polled TX.

**Deliberation:**
`deliberations/2026-10-23-kido-rpi4-uart-design.md` (P1 spec realist /
P2 TX-only minimalist / P3 baud-math auditor / P4 fence keeper /
P5 hosted-double keeper / P6 test keeper; C1–C8 answered; D1–D3
preserved — D1: PL011 instead of mini-UART, overruled; D2: mailbox
VPU-clock query, overruled; D3: RX/console input, overruled).

**Sources verified this session (not from memory alone):** BCM2835
ARM Peripherals doc (AUX block bus 0x7E215000, baud law
sysclock/(8*(reg+1))); OSDev Pi4 /proc/iomem (ARM-physical base
0xFE000000); Ultibo BCM2711 (UART1 = GPIO14/15 ALT5); rpi4os bare-
metal Part 4 (PERIPHERAL_BASE 0xFE000000, AUX_UART_CLOCK 500 MHz
paired with core_freq_min=500); azat.cc serial summary (on the Pi 4
the mini UART is the PRIMARY header UART, PL011 goes to Bluetooth —
the reverse of the Pi 1/2 layout, so the mini UART is the header
UART, not the consolation prize).

**Drafted/changed (only kido-hal-arm64.h/.c — zero Gate files):**
- `modules/kido-hal-arm64.c` — RPi4 AUX mini-UART driver: register
  block (GPIO 0xFE200000, AUX 0xFE215000, MU offsets +0x40/+0x44/
  +0x4C/+0x58/+0x54/+0x60/+0x68; LSR bit 5 TX-empty); 8-write init
  (AUX_ENABLES|=1, CNTL=0, IER=0, LCR=3, MCR=0, BAUD=541,
  GPIO14/15->ALT5 read-modify-write, CNTL=3); polled putc on LSR
  bit 5. THE ONE FIRMWARE BET named: KIDO_RPI4_VPU_HZ = 500 MHz
  (config.txt core_freq_min=500); 541 -> 115315 baud (+0.1%).
  GPIO pulls deliberately untouched (cannot affect driven TX;
  firmware owns them). Board table gains init+putc hooks;
  qemu-virt init NULL (firmware owns the PL011); the old
  uart_base==0->STUB law is gone — every row is a real board.
  Hosted double: scratch register file + write log; same 8-write
  sequence in the same order; LSR armed by the test.
- `modules/kido-hal-arm64.h` — board comment, draft status, fill()
  doc: RPi4 is REAL.
- Self-test 7 -> 19 checks: check 3 FLIPPED (RPi4 was STUB_REACHED,
  now OK); 12 new pin the 8-write sequence order+values exactly
  (incl. GPFSEL1 RMW preservation of pre-armed junk bits),
  putc-to-IO-register, and idempotent re-init replay.
- `architecture/module-map.md` — kido-hal row: RPi4 UART landed.

**Key decisions + why:**
1. Mini-UART, not PL011 (P2/C2): on the Pi 4 it IS the header UART
   (BT takes the PL011); one named clock constant vs a firmware-
   dependent UARTCLK divider + BT contention. PL011 stays a named
   future (D1).
2. The VPU clock is a named constant, not a buried number (P1/P3/
   C1): wrong bet = baud skew, never a crash — stated next to the
   constant with its config.txt pairing.
3. No pulls, no RX (C3/D3): pulls can't break driven TX; the HAL
   table has no read entry. Documented omissions, not oversights.
4. WRITTEN, NOT EXECUTED ON HARDWARE — stated in the source's
   PROOF STATUS block. The hosted double pins the sequence; a real
   Pi4 run is N8toriousAi's to witness.

**Test results (all real, hosted, gcc 13.3.0, -std=c11 -Wall
-Wextra -Werror, zero warnings everywhere):**
- Full battery 12/12 PASS: reloc 19/19 closed + 28/28 flip-engaged,
  image 15/15, alloc 31/31, sched 110/110, mem ALL PASS, hal 19/19
  (new), entry PASS, mmu 121/121, resonate 136/136, interop 75/75,
  boot integration PASS (kido_boot() -> 0, AAAABBBBCCCC).
- ARM64 syntax-test flavor (-DKIDO_HAL_ARM64_SYNTAX_TEST,
  -fsyntax-only): PASS — the new MMIO code parses on the x86_64
  host.
- Audit fixture test: ALL PASS (unchanged).
- Honest limits: no cross-compile, no QEMU — toolchain absent a
  7th time (apt lock held by the system updater on both attempts
  this session; `which` finds no cross gcc). PENDING #1 stays open.

**Remains:** D1 KIDO_ERR_NO_TASKS header code (N8toriousAi's call);
kido-mmu call-site wiring (future Gate item); destroy bare-metal
proof (design ready, queued on the toolchain); RPi4 execution proof
on real hardware (N8toriousAi's Pi4, his witness); mailbox driver (removes
the VPU-clock bet); PL011 as second UART; real BUBO peer +
bare-metal transport (Phase 4); PENDING #1 cross-compile (7th data
point: toolchain absent). First boot is N8toriousAi's to witness.

## 2026-10-24 — Session 25: kido-mbox — VideoCore mailbox driver (builder crew)

**Goal:** close session 24's named future "mailbox driver (removes the
VPU-clock bet)": the RPi4 mini-UART baud register is computed from a
NAMED constant (500 MHz + config.txt core_freq_min=500) instead of a
measured clock. One solid piece: the driver only. The HAL wiring that
consumes it is a future Gate item, not this session's — zero
Gate-approved files touched (the session-22/24 fence pattern).

**Deliberation:**
`deliberations/2026-10-24-kido-mbox-design.md` (P1 protocol realist /
P2 timeout keeper / P3 static-buffer keeper / P4 validation purist /
P5 fence keeper / P6 hosted-double keeper; C1–C6 answered; D1–D3
preserved — D1 fold-into-HAL overruled, D2 infinite poll overruled,
D3 HAL-adopts-now overruled).

**Sources verified this session (not from memory alone):** OSDev Pi4
/proc/iomem (`fe00b880` mailbox, ARM-physical base 0xFE00B880);
rpi4os Part 5 (channel 8 = property tags, 16-byte-aligned buffer,
28 address bits + channel nibble); Pi forum mailbox example + DeepWiki
(register layout READ 0x00 / STATUS0 0x18 EMPTY 0x40000000 / WRITE1
0x20 / STATUS1 0x38 FULL 0x80000000; success code 0x80000000); Linux
rpi_firmware_property driver (get-clock-rate tag 0x00030002, packet
[clock_id, rate_hz], firmware returns rate 0 on unknown clock).

**Drafted (new files only):**
- `modules/kido-mbox.h` — interface + honesty law + the CLOCK IDS
  note (VPU 5 carried, NOT re-verified — see below) + declared HAL
  seam (kido_mbox_vpu_hz() -> BAUD = hz/(8*115200)-1).
- `modules/kido-mbox.c` — the driver: single static 16-byte-aligned
  BSS buffer, one in-flight call, no allocator/timer/HAL dependency;
  mail = (buf & ~0xF) | 8; bounded polls everywhere (1<<20, never
  infinite); read loop discards stale mail; five validations (mail
  echo, success bit, tag echo, length 8, clock echo + nonzero rate)
  all loud EARLY_ENV with *hz untouched; `kido_mbox_clock_rate()`
  (generic id) + `kido_mbox_vpu_hz()` wrapper. Hosted double scripts
  the firmware's in-place buffer write (10 scenarios).
- `architecture/module-map.md` — kido-mbox row added (DRAFT).

**One real catch during drafting (fixed before any test ran):** the
first draft decoded the mail's 28 address bits back into a pointer
inside the hosted double and guarded the buffer address to <4 GiB —
both wrong on a hosted PIE binary (addresses live high, truncation
would corrupt the pointer). Fixed honestly: the 32-bit/align guard
is bare-metal-only, and the double writes the known single-flight
buffer directly (on hardware the firmware does the decode). The
double's shortcut is stated in the source, not hidden.

**Key decisions + why:**
1. Driver only, HAL unwired (P5/D3): the query is WRITTEN NOT
   EXECUTED ON HARDWARE; wiring it into the console path before any
   hardware run would move the VPU bet from a named constant to an
   unproven query. The HAL keeps the constant until the Pi4 run.
2. Bounded polls, never infinite (P2/D2): the mailbox HAS a caller
   and a return code, unlike the PL011 putc spin. A wedged firmware
   is a loud EARLY_ENV, not a hang. No new header code (N8toriousAi's
   call, sched-D1 precedent).
3. VPU id 5 is a caller fact, not module logic (C4): the API takes
   clock_id; the wrapper names the HAL's need. First Pi4 run must
   show a sane rate (near 500 MHz under core_freq_min=500) before
   HAL adoption; a wrong id fails loud (rate 0), never silently.
4. Bus-address alias risk covered by echo + timeout (C1): if the
   firmware wrote elsewhere, the echo never matches and the call
   fails loud — never a baud divisor from garbage.

**Test results (all real, hosted, gcc 13.3.0, -Wall -Wextra -Werror,
zero warnings):**
- kido-mbox self-test: 33/33, 0 failures — VPU 500 MHz exact, generic
  ARM-clock path, mail encoding (channel nibble 8, buffer address),
  buffer shape, 16-byte alignment, wrapper equivalence, stale-mail
  discard, all 8 loud failures with *hz untouched (wrong echo,
  no-reply timeout, bad code, zero rate, wrong tag, wrong clock,
  short length, FULL-stuck write side), recovery after failures.
- No regression risk to the tree: zero existing files modified.
- Honest limits: no cross-compile, no QEMU — toolchain absent an
  8th time (`which` finds no aarch64-linux-gnu-gcc, no
  qemu-system-aarch64). Bare-metal MMIO path unassembled +
  unexecuted; Pi4 hardware run is N8toriousAi's to witness.

**Remains:** D1 KIDO_ERR_NO_TASKS header code (N8toriousAi's call);
kido-mmu call-site wiring (future Gate item); HAL mailbox wiring
(Gate item, seam declared); destroy bare-metal proof (design ready,
queued on the toolchain); RPi4 execution proof on real hardware
(N8toriousAi's Pi4, his witness — including the VPU-rate sanity read);
PL011 as second UART; real BUBO peer + bare-metal transport
(Phase 4); PENDING #1 cross-compile (8th data point: toolchain
absent). First boot is N8toriousAi's to witness.

## 2026-10-24 — Session 26: kido-pl011 — standalone PL011 UART driver (builder crew)

**Goal:** close session 25's named remains item "PL011 as second
UART": the HAL's PL011 is TX-only and firmware-configured (no
init, no baud control, no RX). One solid piece: the full driver
only. The HAL wiring that could consume it is a future Gate item,
not this session's — zero Gate-approved files touched (the
session-24/25 fence pattern).

**Deliberation:**
`deliberations/2026-10-24-kido-pl011-design.md` (P1 standalone /
P2 polled-no-IRQ / P3 caller-clock / P4 bounded-everywhere /
P5 stateless-idempotent-init / P6 hosted-double keeper;
C1–C6 answered; D1–D4 preserved — D1 fold-into-HAL overruled,
D2 IRQ-now overruled, D3 -1-sentinel getc overruled,
D4 name-the-Pi4-clock-by-lore overruled).

**Sources verified this session (not from memory alone):** ARM
PL011 TRM DDI 0183 register summary (DR 0x000, RSR/ECR 0x004,
FR 0x018, ILPR 0x020, IBRD 0x024, FBRD 0x028, LCR_H 0x02C,
CR 0x030, IFLS 0x034, IMSC 0x038, RIS 0x03C, MIS 0x040,
ICR 0x044, DMACR 0x048; divisor = UARTCLK/(16 x baud) =
IBRD + FBRD/64, FBRD = round(fraction x 64)); OSDev Pi Bare
Bones (Pi4 MMIO 0xFE000000, UART0 = 0xFE201000; Pi4 kernel log
confirms fe201000.serial ttyAMA0 PL011 rev2); QEMU virt PL011
0x09000000 @ 24 MHz (DTB clock-frequency). One correction
applied, not copied: a secondary writeup masks IRQs with
IMSC = 0x7FF — in the PL011, IMSC bits SET unmask, so 0x7FF
would unmask everything; this driver writes IMSC = 0.

**Drafted (new files only):**
- `modules/kido-pl011.h` — interface + honesty law + known
  bases + the declared HAL seam. NO Pi4 UART-clock constant:
  no verified source supplied it this session, so a Pi4 caller
  supplies the clock (candidate source: mbox clock id 2 —
  a candidate, not a claim, until a Pi4 run confirms it).
- `modules/kido-pl011.c` — the driver: init (CR=0, bounded
  BUSY wait, FIFO flush via LCR_H FEN=0, IBRD/FBRD from a
  uint64 rounded divisor with IBRD-carry, LCR_H 8N1+FEN =
  0x70, IMSC=0, DMACR=0, ECR clear, CR=UARTEN|TXE|RXE =
  0x301); putc (bounded TXFF wait); puts; poll (RXFE as a
  flag, never an error for empty); getc (bounded RXFE wait,
  DR error bits OE/BE/PE/FE rejected with ECR clear and
  nothing delivered). Stateless, idempotent init; putc
  works firmware-configured with no init call (the HAL's
  current QEMU use, preserved). GPIO mux explicitly the
  board layer's job, never the driver's.
- `architecture/module-map.md` — kido-pl011 row added (DRAFT).

**Two real catches during verification (both fixed/noted
before the session closed):**
1. Plain hosted `-c` build failed under `-Werror`: the
   test-only helpers were unused without the self-test flag.
   Fixed by guarding them behind KIDO_PL011_SELFTEST; plain
   hosted compile and self-test build are now both clean.
   The same latent pattern was confirmed in kido-mbox.c
   (its test setter fails a plain `-c` too) — noted in the
   deliberation, NOT changed (mbox is Gate-adjacent and this
   session touches no existing files).
2. Name overlap: the HAL already has a `static
   kido_pl011_putc`. Verified: a hosted hal.o carries NO
   pl011 symbol (the hosted double path compiles the helper
   out), so no hosted collision; bare-metal coexistence is
   legal by linkage (static vs global, different TUs) but
   was NOT link-tested (no toolchain), and the future HAL
   rewire must delete the helper rather than live with two
   functions of one name.

**Key decisions + why:**
1. Standalone, not a HAL fold (P1/D1): the PL011 is a device
   with its own baud contract, usable by non-console callers.
2. Caller clock, never a guessed clock (P3/D4): QEMU's 24 MHz
   is verified and named; Pi4's UART clock is not, so no
   constant exists to mistune a baud rate silently.
3. RX split poll/getc (C4/D3): no-data is a flag via poll();
   getc is the waiting path whose timeout is EARLY_ENV (a
   wedged UART, the mbox-timeout mapping) — no conflation
   of "no byte" with "error" in one integer.
4. Corrupt bytes never delivered (C3): a DR byte with any
   error bit is rejected, ECR cleared, *out untouched.
5. Bounded everywhere, no new header codes (P4): every poll
   is 1 << 20 spins, a loop count with no timer dependency.

**Test results (all real, hosted, gcc 13.3.0, -Wall -Wextra
-Werror, zero warnings):**
- kido-pl011 self-test: 49/49, 0 failures — divisor table
  (24M/115200 = 13,1; 24M/9600 = 156,16; 48M/115200 = 26,3),
  init register image (LCR_H 0x70, CR 0x301, IMSC 0, DMACR 0),
  divisor refusals (IBRD 0, IBRD > 0xFFFF), TX capture +
  TXFF-stuck loudness, stateless putc, RX order + drain +
  empty-FIFO loudness, OE rejection + ECR clear + recovery,
  re-init idempotence, all NULL/base-0 guards.
- Plain hosted `-c` compile: PASS (after the guard fix).
- Honest limits: no cross-compile, no QEMU — toolchain
  absent a 9th time (`which` finds no aarch64-linux-gnu-gcc,
  no qemu-system-aarch64). Bare-metal MMIO path unassembled
  + unexecuted; QEMU/Pi4 runs are N8toriousAi's to witness.

**Remains:** D1 KIDO_ERR_NO_TASKS header code (N8toriousAi's call);
kido-mmu call-site wiring (future Gate item); HAL wiring
(Gate item, seam declared — HAL putc -> kido_pl011_putc, HAL
init -> kido_pl011_init for RPi4 uart0 once pin mux + UART
clock are confirmed, helper deletion included); GIC module
(unlocks interrupt-driven RX, D2); RPi4 execution proof on
real hardware (N8toriousAi's Pi4, his witness — including the
UART-clock confirmation + the VPU-rate sanity read in one
run); destroy bare-metal proof (design ready, queued on the
toolchain); real BUBO peer + bare-metal transport (Phase 4);
PENDING #1 cross-compile (9th data point: toolchain absent).
First boot is N8toriousAi's to witness.

## 2026-10-25 — Session 27: kido-gic — GICv2 interrupt controller driver (builder crew)

**Goal:** close session 26's named remains item "GIC module (unlocks
interrupt-driven RX, D2)": the PL011's polled-only design (IMSC = 0)
was honest only because no GIC module existed. One solid piece:
the controller driver only. The exception-vector module that could
call it (VBAR table, DAIF unmask, IRQ stub) is a future module,
not this session's — zero Gate-approved files touched (the
session-24/25/26 fence pattern).

**Deliberation:**
`deliberations/2026-10-25-kido-gic-design.md` (P1 GICv2-MMIO-only /
P2 UP-only / P3 Group0-primary / P4 dispatch-owns-EOIR / P5
init-routability-only / P6 static-1020-table / P7 core-is-not-
this-module; C1–C9 answered; D1–D5 preserved — D1 GICv3
overruled, D2 Group1 classification overruled, D3 allocator
table overruled, D4 .S dispatch overruled, D5 broadcast SGI
overruled).

**Sources verified this session (not from memory alone):** ARM GIC
Architecture Specification IHI 0048B Table 4-1 (distributor map:
CTLR 0x000, TYPER 0x004, IGROUPR 0x080, ISENABLER 0x100,
ICENABLER 0x180, ISPENDR 0x200, ICPENDR 0x280, ISACTIVER 0x300,
ICACTIVER 0x380, IPRIORITYR 0x400, ITARGETSR 0x800 with
0x800-0x81C RO, ICFGR 0xC00, SGIR 0xF00) + CPU interface summary
(CTLR 0x000, PMR 0x004, BPR 0x008, IAR 0x00C, EOIR 0x010, IIDR
0x0FC, DIR 0x1000); QEMU virt GICv2 bases (distributor
0x08000000, CPU interface 0x08010000, via the DTB intc@8000000
reg dump) + PL011 UART as SPI 33; ID classes SGI 0-15 / PPI
16-31 / SPI 32+, spurious 1023, ICFGR 0b00 level / 0b10 edge,
SGIR filter/target/NSATT layout, IAR CPUID bits 12:10 with
EOIR echoing the full IAR value.

**Drafted (new files only):**
- `modules/kido-gic.h` — interface + honesty law + known bases.
  NO Pi4 GIC base named (unverified this session — same
  discipline as the PL011 clock; a Pi4 caller supplies both
  bases).
- `modules/kido-gic.c` — the driver: init (distributor off ->
  SPI targets CPU0 -> enables/pending/active cleared -> PMR
  0xFF, BPR 0, CPU CTLR 1 -> distributor CTLR 1); enable/
  disable; priority byte RMW; target byte RMW (SPI only);
  config 2-bit RMW (SPI only); pending/trigger/clear;
  send_sgi (explicit target list only); static 1020-slot
  handler table (fn + arg, ~16 KiB BSS, no allocator
  dependency); dispatch (IAR -> handler if any -> EOIR with
  the full IAR value; spurious 1023 = OK with no EOIR;
  reserved 1020-1022 = EOIR + EARLY_ENV). IRQ bound from
  GICD_TYPER ITLinesNumber, capped at 1020 sources. No new
  header code (N8toriousAi's call, sched-D1 precedent).
- `architecture/module-map.md` — kido-gic row added (DRAFT).

**Test results (all real):**
- kido-gic self-test: 115/115, 0 failures — init guards +
  TYPER count 160, init register image (both CTLRs 1, PMR
  0xFF, BPR 0, enables 0, SPI targets 0x01), enable/disable
  bits, priority/target/config RMW with neighbor pins,
  SGI/PPI/zero/range refusals, pending/trigger/clear,
  enable-gated delivery (pending-but-disabled stays
  spurious), handlerless dispatch + spurious no-op,
  handler path with arg, SGI send->pending->dispatch->EOIR
  0, priority arbitration (0x10 beats 0x20), re-init
  clears handlers, TYPER lines 0 -> 32 sources.
- Plain hosted `-c`: PASS (test helpers guarded behind
  KIDO_GIC_SELFTEST — the PL011 lesson, applied proactively).
- Full hosted battery 15/15 PASS: alloc, image, reloc-closed,
  reloc-flip, sched, mem, hal, entry, mmu, resonate, interop,
  mbox, pl011, gic, boot integration (kido_boot() -> 0,
  AAAABBBBCCCC). Zero warnings everywhere (gcc 13.3.0,
  -Wall -Wextra -Werror).
- Bare-metal cross-compile sweep, all 14 TUs clean
  (aarch64-linux-gnu-gcc 13.3.0, -ffreestanding -O0 -Wall
  -Wextra -Werror), plus both .S files assembled clean.
  One noted non-failure: compiling mbox with
  -DKIDO_HOSTED_TEST but WITHOUT its self-test flag trips
  the known latent unused-helper warning — the exact
  pattern session 26 already recorded; it is not a
  regression and mbox was not touched (fence).

**THE QEMU PROOF (scratch harness, /tmp only, committed module
functions only):** QEMU virt / cortex-a57 / 128 MiB,
-machine virt,gic-version=2, raw binary at 0x40080000, -d int.
Scratch .S (EL2->EL1 drop, VBAR table, IRQ stub ->
kido_gic_dispatch) + scratch main (init -> register SGI 0
handler -> enable -> DAIF unmask -> send SGI to CPU0).
Console: `SKIG` — S start, K init OK, I about to send, G
handler ran for SGI 0. -d int log: exactly one IRQ taken
(exception 5, EL1->EL1, ELR 0x40081138) and one clean
exception return; ZERO fault-class entries. The single G
(not a storm) proves EOIR deactivated the SGI. The C1
ladder stops at rung 1: Group0-only routing (CTLR = 1)
delivers on this QEMU build — no rung-2/3 experiment was
needed. Log: `deliberations/2026-10-25-qemu-gic-proof.log`.
Honest limits of this proof: SGI delivery only — SPI
delivery through a real device (UART RX IRQ 33) is NOT
proven; the Pi4 GIC is NOT proven; the scratch vector stub
is NOT a module (it dies in /tmp; the exception-vector
module is still the named next piece).

**Toolchain data point (10th): PRESENT.** `which` finds
aarch64-linux-gnu-gcc 13.3.0 and qemu-system-aarch64 8.2.2
this session — PENDING #1 (cross-compile) is no longer
blocked on this VM for the GIC's TUs. The destroy bare-metal
proof was deliberately NOT swallowed into this session: it
has its own design (session 22) and its own proof bar, and
it stays queued.

**Remains:** D1 KIDO_ERR_NO_TASKS header code (N8toriousAi's call);
exception-vector module (VBAR + DAIF + IRQ stub ->
kido_gic_dispatch — the named next piece, with this
session's scratch stub as its starting sketch); SPI delivery
proof (UART RX IRQ 33 on QEMU); kido-mmu call-site wiring
(future Gate item); HAL wiring (Gate items — HAL putc ->
kido_pl011_putc, HAL init -> kido_pl011_init, HAL mailbox
adoption after the Pi4 VPU-rate read); destroy bare-metal
proof (design ready, session 22); real BUBO peer +
bare-metal transport (Phase 4). First boot is N8toriousAi's to
witness.

## 2026-10-25 — Session 28: kido-vec — ARM64 exception-vector module (builder crew)

**Goal:** close session 27's named next piece — "exception-vector
module (VBAR + DAIF + IRQ stub -> kido_gic_dispatch — the named
next piece, with this session's scratch stub as its starting
sketch)." One solid piece: the table, the IRQ stub, and the
DAIF/VBAR controls only. The session-27 scratch stub is promoted
properly, not copied blindly: it saved nothing (its proof needed
only the marker); the committed stub saves the full frame,
because a real IRQ can land mid-task.

**Deliberation:**
`deliberations/2026-10-25-kido-vec-design.md` (P1 table-in-.S
branches-only / P2 only-EL1h-IRQ-live / P3 full-frame stub /
P4 no-nesting-by-hardware / P5 install-is-adr / P6 DAIF-no-
status-codes / P7 wiring-is-a-Gate-item; C1–C7 answered;
D1–D4 preserved — D1 FIQ-to-dispatch overruled, D2
caller-saved-only frame overruled, D3 C sync dispatcher
overruled, D4 wire-install-now overruled).

**Sources verified this session (not from memory alone):** ARM
AArch64 exception model (VBAR_ELx undefined after reset, must
be configured before interrupts are enabled); vector-table
layout confirmed by three writeups (2 KiB-aligned base,
16 entries x 128 bytes, EL1t/EL1h/EL0-64/EL0-32 groups ordered
Sync/IRQ/FIQ/SErr — live IRQ entry is entry 5); the rpi4-osdev
handler shape (256-byte frame x0-x30, dispatch, restore,
eret), adopted with attribution.

**Drafted (new files only — zero Gate-approved files touched):**
- `modules/kido-vec-arm64.S` — the table (`.align 11`, 16
  `vec_entry` branches each `.balign 128`); entry 5 ->
  vec_irq_el1h (256-byte frame: stp x0-x30 pairs at 0..224 +
  x30 at 240, `bl kido_gic_dispatch`, reverse restore, `eret`;
  SP moved and moved back, never saved); the 15 other entries
  -> tiny handlers (mov w0, #index) -> vec_unhandled (stash
  index + ESR_EL1 into BSS via adrp stores, then spin —
  no console contract at this layer, HAL owns the UART);
  kido_vec_install (adr + msr vbar_el1 + isb),
  kido_vec_irq_enable (daifclr #2), kido_vec_irq_disable
  (daifset #2), kido_vec_irq_masked (DAIF.I readback);
  BSS evidence slots kido_vec_last_kind / kido_vec_last_esr.
- `modules/kido-vec-arm64.h` — interface + honesty law +
  install order law (install -> GIC init -> handlers ->
  IRQ enable LAST) + vector-index constants 0-15 +
  declared Gate seam (wiring after kido_reloc_verify OK).
- `architecture/module-map.md` — kido-vec row added (DRAFT).

**Key decisions + why:**
1. Branches only in the table (P1): the 128-byte slot fits a
   branch, not a frame save — so the table carries no
   literals, no absolute addresses, nothing for the phase-3
   relocator to patch or the audit to classify.
2. Only EL1h IRQ is live (P2): Kido has no EL0, no EL1t
   stack, no FIQ source under Group0 routing. Any other
   entry firing is a broken assumption — stash index + ESR
   and spin, never return to an unvouched state.
3. Full frame, not ABI-trusting (P3): dispatch is a normal
   C call that may clobber caller-saved registers, so the
   stub saves all of x0-x30 rather than trusting the split.
4. No nesting by hardware default (P4): entry masks IRQ and
   the stub never unmasks. Long handlers delay the next
   IRQ — stated; a future IRQ-stack module is the named fix.
5. Install is adr, not ldr = (P5): PC-relative, true after
   relocation, zero .rela.dyn entries by design — to be
   confirmed by disassembly at the proof gate, not claimed
   today.
6. Wiring is a Gate item (P7/D4): the proven entry .S path
   is not touched for a module whose own QEMU proof cannot
   run this session.

**Verification (all real, but source-text level only — stated):**
- 16 vector entries counted, in table order; 15 unhandled
  mov indices = all except 5 (the live entry).
- IRQ frame: 15 stp pairs + x30, load list identical to
  store list pair-for-pair, same offsets (x30 at 240 both
  ways); x0-x30 all present, 31 unique; frame 256 (16-aligned);
  sub/add #256 matched.
- Header constants 0-15 in table order; header syntax
  PASS (gcc 13.3.0, -Wall -Wextra -Werror, -DKIDO_HOSTED_TEST).
- Zero `kido_vec` collisions before writing (grep).

**Honest limits (stated, not hand-waved):** WRITTEN, NOT
ASSEMBLED, NEVER EXECUTED — toolchain absent an 11th time
(`which` finds no aarch64-linux-gnu-gcc, no
qemu-system-aarch64; session 27's "present" did not survive
the VM cycle). The source-text checks above check the text,
not the machine code. Queued proof gate (toolchain return):
assemble + disassembly (base 2048-aligned, entries 128 apart,
save/restore match, install adr+msr+isb, no absolute literal)
+ QEMU virt/gic-version=2 SGI proof through this committed
module (install -> VBAR readback == table address -> GIC init
-> SGI 0 -> marker -> resume past the send -> one IRQ, one
clean return, zero fault entries). SPI delivery (UART RX IRQ
33) is the proof after that.

**Remains:** QEMU proof of this module + SPI delivery proof
(queued on the toolchain); Gate item — wire kido_vec_install
into the boot path and retire the session-27 scratch stub;
destroy bare-metal proof (design ready, session 22);
kido-mmu call-site wiring (future Gate item); HAL wiring
(Gate items); real BUBO peer + bare-metal transport
(Phase 4); D1 KIDO_ERR_NO_TASKS header code (N8toriousAi's call);
PENDING #1 cross-compile (11th data point: toolchain absent).
First boot is N8toriousAi's to witness.

## 2026-10-26 — Session 29: kido-timer — ARM Generic Timer driver (builder crew)

**Goal:** draft the next module the tree can actually carry.
Session 28's remains were all blocked or fenced: the vec QEMU
proof + SPI delivery proof need the toolchain (absent a 12th
time this session — see below); vec/MMU/HAL wirings are Gate
items; the destroy bare-metal proof has its own design
(session 22, not swallowed here); D1 KIDO_ERR_NO_TASKS is
N8toriousAi's call; the BUBO peer is Phase 4. Per the session-22
precedent (degrade honestly to the next draftable module),
this session drafts the timer: the EL1 physical timer as a
drivable device, and the session-27/28 interrupt chain's first
real interrupt source (PPI 30). Zero existing files touched
(the session-24/25/26 fence pattern).

**Deliberation:**
`deliberations/2026-10-26-kido-timer-design.md` (P1 EL1
physical, not virtual / P2 CVAL-only arming / P3 frequency
read, never written / P4 poll + IRQ both real / P5 reuse the
existing NO_TIMER code / P6 hosted double, guarded test
setters; C1–C7 answered; D1–D4 preserved — D1 virtual timer
overruled, D2 auto-rearming periodic overruled, D3 fold-into-
HAL overruled, D4 write CNTFRQ overruled).

**Drafted (new files only):**
- `modules/kido-timer.h` — interface + honesty law + IRQ
  identity (PPI 30) + declared Gate seam (GIC enable(30) +
  handler + arm). No Pi4/QEMU frequency constant: the module
  reads CNTFRQ wherever it runs (62.5 MHz is the QEMU virt
  expectation, never asserted).
- `modules/kido-timer.c` — the driver: init (disarm first,
  then read CNTFRQ; 0 -> NO_TIMER with the driver unready
  and the timer silent); hz/now; arm_ticks (CVAL = now +
  ticks, wrap-guarded, CVAL written before ENABLE so a
  stale compare cannot fire immediately); arm_us (checked
  multiply, truncation to 0 refused); disarm; mask/unmask
  (IMASK RMW, CVAL + ENABLE untouched); pending() as the
  three-term SIGNAL (ENABLE and not IMASK and ISTATUS).
  Hosted double: scripted freq/count/CTL/CVAL with ISTATUS
  computed on read (count >= CVAL), never stored; CTL
  writes keep ENABLE/IMASK only (ISTATUS is read-only).
  Test setters guarded behind KIDO_TIMER_SELFTEST (the
  PL011 lesson, applied proactively).
- `architecture/module-map.md` — kido-timer row added (DRAFT).

**One real catch during verification (test bug, module
right):** the first self-test draft asserted CTL == 0 after
init/disarm, but with CVAL still 0 the computed ISTATUS bit
reads set — the condition bit is honest, not a driver
failure. Fixed by masking ISTATUS out of the disarm
assertions (ENABLE/IMASK are the bits disarm owns). The
same reasoning is why pending() ANDs all three terms
instead of trusting the raw bit.

**Key decisions + why:**
1. Physical, not virtual (P1/D1): Kido runs EL1 on bare
   metal; the virtual timer is a guest's timer.
2. CVAL-only (P2/C2): TVAL is a second spelling of the
   same register with a 32-bit window (~68 s cap at
   62.5 MHz). One arming path, one truth.
3. NO_TIMER reused, nothing invented (P5/C5): the code
   already exists in kido-boot.h for exactly "no usable
   timer"; every other failure is EARLY_ENV.
4. HAL keeps its probe (C1): reads are ownerless; the
   driver owns ARMING. No file moved, no state duplicated.
5. Pending is the signal, not the bit (C6): a masked or
   disabled timer never reports pending, even with the
   condition met — the right answer for both the poll
   path and the future IRQ path.

**Test results (all real, hosted, gcc 13.3.0, -Wall -Wextra
-Werror, zero warnings everywhere):**
- kido-timer self-test: 54/54, 0 failures — pre-init
  guards, NO_TIMER on zero freq, exact CVAL (1500),
  pending edges (1499/1500), zero + wrap refusals with
  CVAL untouched, mask suppresses / unmask releases,
  disarm silences, arm_us conversions (1000 us = 62500
  ticks, 1 us = 62 ticks at 62.5 MHz), multiply-overflow
  + sub-tick (1 us at 1 kHz) refusals, re-arm replaces,
  re-init disarms, NULL guards.
- Plain hosted `-c`: PASS (guarded setters).
- Full hosted battery 16/16 PASS: timer, alloc 31, image
  15, reloc-closed 19 + reloc-flip 28, sched 110, resonate
  136, mem 100, hal 19, entry PASS, mmu 121, mbox 33,
  pl011 49, gic 115, interop 75, boot integration PASS
  (kido_boot() -> 0, AAAABBBBCCCC).
- Audit fixture test: ALL PASS (unchanged).
- Two battery-recipe corrections made in passing (test
  harness only, no module touched): mem needs
  -DKIDO_MEM_SELFTEST for its main; interop links
  interop.c alone (its core needs only kido_signal_t's
  type — the session-18 fix, re-derived after a link
  error). Both are recorded here so the next battery
  re-run has no recipe ambiguity.

**Honest limits (stated, not hand-waved):** WRITTEN, NOT
ASSEMBLED, NEVER EXECUTED — toolchain absent a 12th time
(`which` finds no aarch64-linux-gnu-gcc, no
qemu-system-aarch64). The bare-metal mrs/msr strings are
text, not machine code, until the toolchain returns.
QEMU PPI-30 proof queued (vec install -> GIC enable(30)
-> arm -> IRQ through the committed stub -> eret resume
-> one IRQ, one clean return, zero fault entries).

**Remains:** QEMU proof of the vec module + PPI-30 timer
delivery through this driver + SPI delivery proof (UART RX
IRQ 33) — all queued on the toolchain; Gate items — wire
kido_vec_install into the boot path, wire GIC enable(30)
+ timer arm into the scheduler tick, HAL wiring (PL011
init, mailbox adoption), kido-mmu call-site wiring;
destroy bare-metal proof (design ready, session 22);
real BUBO peer + bare-metal transport (Phase 4); D1
KIDO_ERR_NO_TASKS header code (N8toriousAi's call); PENDING #1
cross-compile (12th data point: toolchain absent).
First boot is N8toriousAi's to witness.

## 2026-10-26 — Session 30: kido-serial-irq — interrupt-driven PL011 RX (builder crew)

**Goal:** draft the next module the tree can actually carry, and
the first consumer of the session-27/28 interrupt chain. Session
29's remains were all blocked or fenced: the vec/timer/SPI QEMU
proofs need the toolchain (absent a 13th time this session — apt
locked by the system updater, process 2998, so even an install
attempt could not run); vec/MMU/HAL wirings are Gate items; the
destroy bare-metal proof has its own design (session 22, not
swallowed here); D1 KIDO_ERR_NO_TASKS is N8toriousAi's call; the BUBO
peer is Phase 4. Per the session-22 precedent (degrade honestly
to the next draftable module), this session drafts serial-irq:
the GIC handler that drains the PL011 RX FIFO into a ring. Zero
existing files touched (the session-24/25/26 fence pattern).

**Deliberation:**
`deliberations/2026-10-26-kido-serial-irq-design.md` (P1
integration realist / P2 ring keeper / P3 PL011-boundary keeper /
P4 honesty auditor / P5 test keeper / P6 fence keeper; C1–C8
answered; D1–D3 preserved — D1 single-owner purist overruled,
D2 edge trigger overruled, D3 blocking consumer getc overruled).

**Drafted (new files only):**
- `modules/kido-serial-irq.h` — interface + honesty law + IRQ
  window rule + init order law + declared Gate seam (Gate item
  calls init after GIC init, before DAIF unmask, vec installed).
  SPI 33 named (QEMU virt, DTB); NO Pi4 UART0 IRQ named
  (unverified — same discipline as the PL011 clock and GIC
  bases). Ring 256, stats struct, init/stop/available/getc/
  stats API. No new header codes.
- `modules/kido-serial-irq.c` — the driver: 5-register IRQ
  window (DR/FR/IMSC/IFLS/ICR/RSR, DDI 0183); init order
  handler -> level config -> GIC enable -> UART unmask (IFLS
  1/4 trigger, IMSC RXIM, ICR clear), GIC failure rolls back
  the registration and touches no UART register; handler drains
  at most the 16-deep FIFO per invocation, error bytes
  discarded + ECR cleared + counted, full ring drops + counted,
  ICR cleared even on empty drains; stop() reverses init and
  keeps the ring (delivery ends, history stays). Hosted double
  (own UART double; MIS computed as raw-AND-mask) + test
  setters guarded behind KIDO_SERIAL_IRQ_SELFTEST (the PL011
  lesson, applied proactively).
- `architecture/module-map.md` — kido-serial-irq row added (DRAFT).

**Two real finds during verification (one module bug, one
test bug — both fixed, neither hidden):**
1. Module bug: the handler pushed bytes into the ring but never
   incremented stats.received — the ring count was right, the
   counter was 0. Caught by the section-C stats assertion, fixed
   with one line (received++ on push). The counter is now pinned
   by every section that drains.
2. Test bug: section I read stats() after stop() — but stats()
   refuses while stopped, by design. Restructured honestly:
   the count is captured BEFORE stop, and read AFTER the
   re-init; the post-stop dispatch provably added nothing.
   (The module was right: stats after stop must refuse.)

**Key decisions + why:**
1. Handler before enable before unmask (P1): no interrupt can
   arrive without a handler or a drain path; stop reverses it.
2. The 5-register IRQ window, not a call into pl011 (P3/C1):
   the pl011 double's feed setter is static inside pl011.c's
   self-test TU and unreachable from another TU (main
   collision + static). A module untestable end to end is worse
   than a declared window from the same TRM source, pinned by
   test, with a stated both-files-change-together rule.
3. Level trigger, drain-to-empty (C2/D2): the PL011 asserts
   while the FIFO sits at/above trigger; edge would lose bytes
   arriving mid-drain.
4. IFLS 1/4 trigger (C3): 1 byte per IRQ is polling with extra
   steps; 1/2+ risks a 16-deep FIFO overrun on bursts. 1/4 is the
   middle with both bounds comfortable, stated as a constant
   with a reason, not a tuned value.
5. Non-blocking consumer (D3): available() is the flag, getc()
   is the drain; empty is EARLY_ENV immediately. No scheduler
   hook exists to wait on, and the scheduler is fenced.
6. Priority untouched (C7): assigning one is caller policy via
   kido_gic_set_priority, not smuggled in here.

**Test results (all real, hosted, gcc 13.3.0, -Wall -Wextra
-Werror, zero warnings everywhere):**
- kido-serial-irq self-test: 354/354, 0 failures — pre-GIC
  init refusal with IMSC/IFLS untouched, init register image
  (IMSC RXIM, IFLS 1/4, ICR clear), PPI/out-of-range refusals,
  double-init refusal, delivery through the REAL dispatch chain
  (feed -> gic trigger -> dispatch -> handler -> ring, order
  kept), MIS at/below trigger, OE rejection + ECR + recovery,
  ring-full geometry (17x16 offered -> 256 kept + 16 dropped),
  spurious empty-drain counting, GIC-disable gating (handler
  never runs), stop mask/disable/unregister + restart delivery.
- Plain hosted `-c`: PASS (guarded setters).
- Full hosted battery 17/17 PASS: serial-irq 354, timer 54,
  alloc 31, image 15, reloc-closed 19 + reloc-flip 28, sched
  110, mem ALL PASS, hal PASS, entry PASS, mmu 121, resonate
  136, interop 75, mbox 33, pl011 49, gic 115, boot integration
  PASS (kido_boot() -> 0, AAAABBBBCCCC).
- Audit fixture test: ALL PASS (unchanged).
- Fence verified: only the 3 new files carry this session's
  timestamps; zero existing files modified.

**Honest limits (stated, not hand-waved):** WRITTEN,
HOSTED-PROVEN, NOT ASSEMBLED, NEVER EXECUTED — toolchain absent
a 13th time (apt lock, not "unable to locate" — a new variant of
the same absence). The hosted proof is the dispatch chain, which
is exactly what the vec stub calls; SPI delivery through a real
UART is NOT proven. QEMU proofs queued unchanged: vec SGI proof,
timer PPI-30 delivery, SPI delivery (UART RX IRQ 33).

**Remains:** QEMU proof of the vec module + PPI-30 timer
delivery through the timer driver + SPI delivery proof through
this module (all queued on the toolchain); Gate items — wire
kido_vec_install into the boot path, wire GIC enable(30) +
timer arm into the scheduler tick, wire serial-irq init into
the boot path (after GIC init, before DAIF unmask), HAL wiring
(PL011 init, mailbox adoption), kido-mmu call-site wiring;
destroy bare-metal proof (design ready, session 22);
real BUBO peer + bare-metal transport (Phase 4); D1
KIDO_ERR_NO_TASKS header code (N8toriousAi's call); PENDING #1
cross-compile (13th data point: toolchain absent, apt locked).
First boot is N8toriousAi's to witness.

## 2026-10-27 — Session 31: interrupt-chain QEMU proof — vec + timer PPI 30 + serial-irq SPI 33 (builder crew)

**Goal:** close the three queued proofs from sessions 28/29/30 in
one run, because they are one chain: vec install -> GIC init ->
handlers -> DAIF unmask -> timer IRQ -> UART RX IRQ -> clean
return. Verification session; pristine scaffold tree; scratch
harness only (/tmp). The toolchain was PRESENT at session start
(aarch64-linux-gnu-gcc 13.3.0, qemu-system-aarch64) and ABSENT by
the final check — the 14th data point, and the sharpest yet:
present-then-absent inside one session, same shape as session 22.
Every proof artifact below was produced while it was present.

**Deliberation:**
`deliberations/2026-10-27-kido-irq-proof-design.md` (P1 proof
keeper / P2 harness keeper / P3 IRQ realist / P4 honesty auditor /
P5 fence keeper; C1–C7 answered; D1–D3 preserved — D1 separate
runs overruled, D2 handler prints overruled, D3 re-arming tick
overruled as a Gate policy).

**Regression gate first (all real):** hosted battery 18/18 PASS
(alloc 31, image 15, reloc-closed 19 + reloc-flip 28, sched 110,
mem ALL, hal PASS, entry PASS, mmu 121, resonate 136, interop 75,
mbox 33, pl011 49, gic 115, timer 54, serial-irq 354, boot
integration PASS kido_boot() -> 0, AAAABBBBCCCC) + audit fixture
test ALL PASS. Full-tree cross-compile: all 17 C TUs + 3 .S
files (entry, sched, vec) clean, zero warnings — this closes the
PENDING #1 cross-compile item for the CURRENT tree (the vec .S
assembles for the first time; timer/serial-irq inline asm
assembles with it). Vec object gate: table 2048-aligned, install
is adr+msr+isb, dispatch call present.

**The harness (scratch, /tmp only):** scratch entry .S (EL2->EL1
drop, stack, BSS zero) + scratch main + the COMMITTED
kido-vec-arm64.S (the session-27 scratch stub is NOT reused —
this proof retires its qualifier) + committed kido-gic.c,
kido-timer.c, kido-serial-irq.c, linked at 0x40080000 with the
scratch entry first (session-11 link lesson; readelf: _start ==
0x40080000, vec table 0x40080800, 2048-aligned). Console and RX
share the virt PL011 (0x09000000); injected bytes arrive over a
QEMU socket chardev (server=on, wait=on — QEMU blocks until the
driver connects, so no early marker is lost). Handlers set flags
only; the main loop is the only printer (deliberation P3).

**One real harness bug, owned and fixed in-run:** the first
harness printed DONE on the first partial drain (U:KI) and spun
before the 200 ms timer fired — the driver then killed QEMU and
the timer half never ran. Fixed in scratch only: DONE requires
BOTH halves (timer observed AND 4 bytes drained). A second
driver-side chunking bug (breaking on "ST:" before its digit
arrived) was fixed the same way. Neither bug was in a module.

**THE PROOF (QEMU virt / gic-version=2 / cortex-a57 / 128 MiB,
raw binary, -d int; log: deliberations/
2026-10-27-qemu-irq-proof.log):**
```
SVGTRIREADY
U:K
U:KID
U:KIDO
T1:1
DONE
ST:4
```
- S start, V VBAR readback == table address, G GIC init OK,
  T timer init OK, R serial-irq init OK, I DAIF unmask, READY.
- U:K -> U:KID -> U:KIDO: QEMU's socket chardev delivers the
  4 injected bytes in chunks; the poll loop accumulates them
  in order to the full "KIDO". Chunking varies run to run
  (3 IRQs one run, 5 the next); the invariants do not.
- T1:1: the timer handler ran exactly once — one-shot +
  disarm before EOIR, no storm.
- ST:4: serial-irq stats received == 4, exactly the sent
  bytes, byte-identical and in order.
- -d int log: 5 IRQ exceptions, ALL entry 5 (the live EL1h
  IRQ entry), ALL with clean exception returns to the
  interrupted PC, ZERO fault-class entries (no sync,
  data-abort, or undefined-instruction entries).
- Acceptance bar met as written in the design (every marker
  in order, drained bytes == sent bytes, clean returns,
  zero faults). Exit is the driver's terminate, not a guest
  halt — the proof ends at DONE by design.

**What this does NOT prove (stated, not hidden):** the
scheduler-tick policy (re-arm in the handler is a Gate item,
not run here); HAL wiring (PL011 init, mailbox adoption);
MMU call-site wiring; vec/MMU/HAL boot-path wiring (all Gate
items, untouched); any Pi4 identity (GIC base, UART0 IRQ,
clocks all still unnamed). The proof is QEMU virt only.

**Scaffold edits (fence held — verified: zero module files
carried this session's timestamps before the edits below):**
- `architecture/module-map.md` — vec/timer/serial-irq rows:
  proof notes landed, scratch-stub qualifier retired.
- Comment-only PROOF STATUS updates in kido-vec-arm64.h,
  kido-timer.h, kido-serial-irq.h (session-18 precedent; no
  logic, no wiring). Hosted syntax re-verified after the
  edits (gic/timer/serial-irq clean); the post-edit cross
  re-check could not run — the toolchain vanished between
  the proof link and that check (14th data point). The edits
  touch comments only, and the same files cross-compiled
  clean minutes earlier this session.
- `deliberations/2026-10-27-qemu-irq-proof.log` — the final
  run's -d int log (5 IRQs, 5 clean returns, zero faults).

**Remains:** Gate items — wire kido_vec_install into the boot
path, wire GIC enable(30) + timer arm into the scheduler tick,
wire serial-irq init into the boot path (after GIC init,
before DAIF unmask), HAL wiring (PL011 init, mailbox
adoption), kido-mmu call-site wiring; destroy bare-metal
proof (design ready, session 22); real BUBO peer + bare-metal
transport (Phase 4); D1 KIDO_ERR_NO_TASKS header code
(N8toriousAi's call); PENDING #1 cross-compile — CLOSED for the
current tree this session, re-opens on the next tree change
while the toolchain stays intermittent (14th data point:
present at session start, gone by the post-edit check). First boot is
N8toriousAi's to witness.

## 2026-10-27 — Session 32: kido-psci — ARM PSCI conduit (builder crew)

**Goal:** draft the next module the tree can actually carry.
Session 31's remains were all blocked or fenced: the Gate
wirings (vec into the boot path, GIC enable(30) + timer arm
into the scheduler tick, serial-irq init into the boot path,
HAL wiring, MMU call-site wiring) are Gate items, not things
a scaffold session takes unilaterally; the destroy
bare-metal proof has its own design (session 22, not
swallowed here); D1 KIDO_ERR_NO_TASKS is N8toriousAi's call;
the BUBO peer is Phase 4. Per the session-22 precedent
(degrade honestly to the next draftable module), this
session drafts PSCI: the firmware call layer for CPU
power control and system off/reset — the one power
module the tree lacked. Zero existing files touched (the
session-24/25/26 fence pattern); the module-map row and
this entry are the only other edits.

**Deliberation:**
`deliberations/2026-10-27-kido-psci-design.md` (P1 SMC
only, not HVC / P2 version-gated, not version-blind / P3
never-returning calls never pretend to return / P4 the
firmware validates, Kido does not second-guess / P5 opaque
platform data stays opaque / P6 no new header code;
C1–C7 answered; D1–D4 preserved — D1 HVC conduit
overruled, D2 driver-side entry validation overruled,
D3 PSCI 1.1 functions overruled as scope, D4 CPU_OFF
state record overruled).

**Drafted (new files only):**
- `modules/kido-psci.h` — interface + honesty law +
  function IDs (DEN0022 0.2 core: VERSION 0x84000000,
  CPU_SUSPEND 0xC4000001 SMC64, CPU_OFF 0x84000002,
  CPU_ON 0xC4000003 SMC64, AFFINITY_INFO 0xC4000004
  SMC64, SYSTEM_OFF 0x84000008, SYSTEM_RESET
  0x84000009) + 1.0 FEATURES probe (0x8400000A,
  version-gated) + return-code law (NOT_SUPPORTED ->
  STUB_REACHED, all other negatives -> EARLY_ENV,
  AFFINITY_INFO states are not errors) + the stated
  hosted divergence (SYSTEM_OFF/SYSTEM_RESET/CPU_OFF
  record and return OK on hosted; on bare metal they
  never return).
- `modules/kido-psci.c` — the conduit: `smc #0` with
  x0 = function ID, x1–x3 arguments, result in x0
  (bare-metal path); hosted scripted firmware double
  (version, 4-CPU stand-in state table — values 0..3,
  NOT MPIDR format — call records, firmware-side
  validation of entry != 0 and known affinity so the
  error mapping is tested, not assumed). Version gate:
  major<<16 | minor, below 0.2 refuses (0.2 encodes as
  0x00000002, pinned by test, not guessed as
  0x00020000). MIGRATE family NOT offered (no Trusted
  OS to migrate — declared, not silent).
- `architecture/module-map.md` — kido-psci row added
  (DRAFT).

**Sources verified this session (not from memory alone):**
DEN0022 via public spec summary + vendor tables:
PSCI_VERSION 0x84000000, CPU_SUSPEND 0x84000001
SMC32 / 0xC4000001 SMC64, SYSTEM_OFF/SYSTEM_RESET
mandatory 0.2 functions, FEATURES introduced in 1.0
and mandatory from 1.0 on, MIGRATE family optional,
SYSTEM_RESET2/CPU_FREEZE/SYSTEM_SUSPEND 1.1 optional,
VERSION encoding bits[31:16] major / bits[15:0]
minor, SMCCC conduit shape (x0 ID, x1–x3 args,
x0 result). The sequential 0.2 IDs (CPU_OFF 02,
CPU_ON 03, AFFINITY_INFO 04, SYSTEM_OFF 08,
SYSTEM_RESET 09) follow the documented sequence;
SMC64 forms used where the call carries a 64-bit
argument, as an AArch64 caller must.

**Key decisions + why:**
1. SMC only (P1/D1): Kido runs EL1 under a monitor;
   HVC is a hosted-Kido future, not an untestable
   branch on this driver.
2. Version-gated init (P2): below 0.2 refuses — a
   pre-0.2 monitor is not a dialect to guess at.
   FEATURES refuses below 1.0, by spec.
3. Never-return law + stated hosted divergence (P3/
   C5): bare-metal SYSTEM_OFF/SYSTEM_RESET/CPU_OFF
   return only on firmware error; the double records
   and returns OK because the host must not halt.
4. Firmware validates (P4/D2): no driver-side entry
   pre-check; INVALID_ADDRESS / NOT_PRESENT come from
   the firmware through the mapping, and the double
   enforces the same rules so the mapping is proven.
5. Opaque platform data (P5): power_state and
   affinity are carried, never parsed or invented —
   the HAL's guessed-UART sin, not repeated.
6. No new header codes (P6): the sched-D1 precedent
   holds; a new code stays N8toriousAi's call.
7. NOT wired into the boot path (C3, Gate item):
   init cannot detect a missing monitor — an SMC with
   no monitor faults at the instruction. The boot path
   must never fault on monitor-less firmware, so the
   gating policy is a Gate decision, not this session's.

**One fix during verification (cosmetic, owned):** the
first draft carried a self-assign no-op line in the
hosted CPU_OFF case; removed before testing — a
self-assign is exactly the kind of line -Werror exists
to catch, and it said nothing.

**Test results (all real, hosted, gcc 13.3.0, -Wall
-Wextra -Werror, zero warnings everywhere):**
- kido-psci self-test: 48/48, 0 failures — pre-init
  guards, init + version at 1.0 (0x00010000), FEATURES
  known/unknown IDs, affinity states (ON/OFF/
  ON_PENDING/unknown), CPU_ON OFF->ON + ALREADY_ON +
  ON_PENDING + unknown-affinity + zero-entry loudness,
  CPU_SUSPEND records (state/entry/context, count 2),
  SYSTEM_OFF/SYSTEM_RESET records, CPU_OFF hosted OK,
  NULL guards, 0.2 init OK + FEATURES refusal + CPU_ON
  still works at 0.2, pre-0.2 (0x00000001) init refusal
  + driver left unready, re-init at 1.0 restores.
- Plain hosted `-c`: PASS (guarded setters).
- Header syntax (`-fsyntax-only`): PASS.
- Collision check: zero `kido_psci` references outside
  the two new files.

**Honest limits (stated, not hand-waved):** WRITTEN,
NOT ASSEMBLED, NEVER EXECUTED — toolchain absent a
15th time (`which` finds no aarch64-linux-gnu-gcc, no
qemu-system-aarch64). The bare-metal `smc #0` strings
are text, not machine code, until the toolchain
returns. QEMU virt PSCI proof queued (VERSION
readback, CPU_ON record, SYSTEM_OFF exit, scratch
harness per the session-31 pattern). Nothing about
bare-metal behavior is claimed from the hosted run.

**Remains:** QEMU virt PSCI proof (queued on the
toolchain); Gate items — wire kido_vec_install into
the boot path, wire GIC enable(30) + timer arm into
the scheduler tick, wire serial-irq init into the boot
path (after GIC init, before DAIF unmask), HAL wiring
(PL011 init, mailbox adoption), kido-mmu call-site
wiring, psci-init gating policy (C3); destroy
bare-metal proof (design ready, session 22); real BUBO
peer + bare-metal transport (Phase 4); D1
KIDO_ERR_NO_TASKS header code (N8toriousAi's call);
PENDING #1 cross-compile — re-opens on this tree
change while the toolchain stays intermittent (15th
data point: absent). First boot is N8toriousAi's to
witness.

## 2026-10-28 — Session 33: kido-smp — secondary-CPU bring-up policy (builder crew)

**Goal:** draft the next module the tree can actually carry.
Session 32's remains were all blocked or fenced: the QEMU virt
PSCI proof needs the toolchain (absent a 16th time this session
— `which` finds no aarch64-linux-gnu-gcc, no qemu-system-aarch64);
the Gate wirings (vec into the boot path, GIC enable(30) + timer
arm into the scheduler tick, serial-irq init into the boot path,
HAL wiring, MMU call-site wiring, psci-init gating policy) are
Gate items, not things a scaffold session takes unilaterally; the
destroy bare-metal proof has its own design (session 22, not
swallowed here); D1 KIDO_ERR_NO_TASKS is N8toriousAi's call; the BUBO
peer is Phase 4. Per the session-22 precedent (degrade honestly
to the next draftable module), this session drafts kido-smp: the
bring-up policy on top of the session-32 PSCI conduit — the exact
future the psci header named. Zero existing files touched (the
session-24/25/26 fence pattern); the module-map row and this entry
are the only other edits.

**Deliberation:**
`deliberations/2026-10-28-kido-smp-design.md` (P1 coordinator not
conduit / P2 firmware-truth keeper / P3 fence keeper / P4
static-tables keeper / P5 honesty auditor / P6 test keeper;
C1–C8 answered; D1–D4 preserved — D1 FAILED-slot retry
overruled, D2 allocator-owned stacks overruled, D3 secondary
stub now overruled, D4 single-phase bring_up overruled).

**Drafted (new files only):**
- `modules/kido-smp.h` — interface + honesty law + the
  secondary stub contract (declared, not built) + the two-phase
  law (STARTED vs ARRIVED) + futures.
- `modules/kido-smp.c` — the policy: 8-slot static table;
  kido_smp_init (requires psci ready, refuses while any
  secondary is live); kido_smp_bring_up (guards -> duplicate
  scan -> reserve + mailbox write -> cpu_on with the slot
  index as context_id -> bounded AFFINITY_INFO poll ->
  STARTED); kido_smp_secondary_arrived (STARTED -> ARRIVED);
  kido_smp_release + kido_smp_secondary_wait_release
  (spin-bound, no timer dependency); kido_smp_secondary_off
  (propagates psci_cpu_off, marks nothing — bare-metal
  success never returns); kido_smp_slot_state;
  kido_smp_query (firmware OFF moves ARRIVED/STARTED ->
  OFF; firmware ON leaves smp state alone); kido_smp_stats.
  Per-slot BSS mailbox kido_smp_secondary_stack_top[slot]
  written before cpu_on so the future stub can load SP with
  a PC-relative read and no C call. No `smc` in this module;
  no allocator, scheduler, or GIC coupling; no new header
  codes.
- `architecture/module-map.md` — kido-smp row added (DRAFT).

**Key decisions + why:**
1. Two phases, two facts (C1): STARTED = firmware reports ON
   after the poll; ARRIVED = the stub called secondary_arrived
   from real Kido code. The scheduler/Gate wiring consumes
   ARRIVED, never STARTED — ON proves a start, not an arrival.
2. Refused cpu_on frees its slot, failed poll does not (C4):
   a refusal changes no firmware state, so retry with corrected
   arguments is safe (pinned: entry-0 failure, then the same
   affinity succeeds). A poll timeout after a successful cpu_on
   leaves firmware state genuinely unknown, so that slot goes
   FAILED and terminal for its affinity (D1).
3. No "off another CPU" API (P5): PSCI CPU_OFF powers down
   the CALLER. A primary-side off-a-secondary call would be
   fiction; the primary learns via query instead.
4. Caller stacks, not allocator stacks (D2): bring-up must
   work before any allocator policy exists for secondaries,
   and the free-ownership question stays with the caller.
5. The stub is declared, not written (D3): the psci header
   names it a scheduler/Gate item, and a stub without its
   scheduler consumer is untestable shape. The mailbox +
   context_id contract is fixed here so the stub has a target.

**Test results (all real, hosted, gcc 13.3.0, -Wall -Wextra
-Werror, zero warnings everywhere):**
- kido-smp self-test: 56/56, 0 failures — pre-init guards,
  init-requires-conduit, re-init at rest, all guards leave
  the table empty, retry-after-refusal, mailbox values
  (0x41004000 / 0x41104000), duplicate refusal,
  release/wait-before-arrival refusals, arrival + double-
  arrival refusal, release-then-wait, three CPUs through
  one path, secondary_off hosted-OK with slot unchanged,
  query leaves ARRIVED on firmware ON, firmware refusal
  frees its slot (mailbox word 3 stays zero, failed == 0),
  re-init refusal while live (last check).
- Plain hosted `-c`: PASS (guarded self-test main).
- Full hosted battery 19/19 PASS: smp 56, psci 48, alloc 31,
  image 15, reloc-closed 19 + reloc-flip 28, sched 110,
  resonate 136, mem ALL PASS, hal PASS, entry PASS, mmu 121,
  mbox 33, pl011 49, gic 115, timer 54, serial-irq 354,
  boot integration PASS (kido_boot() -> 0, AAAABBBBCCCC);
  interop `-c` PASS (no main — compile-check module, as
  prior sessions recorded); audit fixture test ALL PASS.
- Collision check: zero `kido_smp` references outside the
  two new files.

**Honest limits (stated, not hand-waved):** WRITTEN, NOT
ASSEMBLED, NEVER EXECUTED — toolchain absent a 16th time.
The hosted proof drives the REAL psci API against psci.c's
scripted double, but that double reports ON immediately
after cpu_on, so the ON_PENDING-transient and poll-timeout
paths are code-reviewed, not hosted-proven (deliberation
C5). Table-full is unproven (the 4-CPU double cannot fill
8 slots). QEMU virt -smp proof waits on the future stub
as well as the toolchain.

**Remains:** QEMU virt PSCI proof + QEMU virt -smp proof
(both queued on the toolchain; the -smp proof also waits
on the Gate stub item); Gate items — wire kido_vec_install
into the boot path, wire GIC enable(30) + timer arm into
the scheduler tick, wire serial-irq init into the boot path
(after GIC init, before DAIF unmask), HAL wiring (PL011
init, mailbox adoption), kido-mmu call-site wiring,
psci-init gating policy, secondary entry stub (contract in
kido-smp.h); destroy bare-metal proof (design ready,
session 22); real BUBO peer + bare-metal transport
(Phase 4); D1 KIDO_ERR_NO_TASKS header code (N8toriousAi's
call); PENDING #1 cross-compile — re-opens on this tree
change while the toolchain stays intermittent (16th data
point: absent). First boot is N8toriousAi's to witness.

## 2026-10-28 — Session 34: kido-sync — the SMP spinlock (builder crew)

**Goal:** draft the next module the tree can actually carry.
Session 33's remains were, again, all blocked or fenced: the
QEMU virt PSCI proof and the QEMU virt -smp proof need the
toolchain (absent a 17th time this session — `which` finds no
aarch64-linux-gnu-gcc, no qemu-system-aarch64); the Gate
wirings (vec into the boot path, GIC enable(30) + timer arm
into the scheduler tick, serial-irq init into the boot path,
HAL wiring, MMU call-site wiring, psci-init gating policy,
secondary entry stub) are Gate items, not things a scaffold
session takes unilaterally; the destroy bare-metal proof has
its own design (session 22, not swallowed here); D1
KIDO_ERR_NO_TASKS is N8toriousAi's call; the BUBO peer is Phase
4. Per the session-22 precedent (degrade honestly to the
next draftable module), this session drafts kido-sync: the
spinlock session 33's secondaries need before they can
share anything. Zero existing files touched (the
session-24/25/26/33 fence pattern); the module-map row and
this entry are the only other edits.

**Deliberation:**
`deliberations/2026-10-28-kido-sync-design.md` (P1
exclusives realist / P2 portability auditor / P3 honesty
auditor / P4 static-tables keeper / P5 fence keeper /
P6 test keeper; C1–C8 answered; D1–D4 preserved — D1
bounded-spin lock overruled (try_lock is the bounded
door), D2 ownerless lock overruled (stranger-unlock is
silent corruption), D3 ticket/FIFO fairness overruled
(low contention today, named future), D4 IRQ masking
inside lock overruled (vec/GIC policy, not a leaf's)).

**Drafted (new files only):**
- `modules/kido-sync.h` — interface + honesty laws (owner
  law, IRQ law, dead-holder law, contention-is-not-
  failure, snapshot law, init law) + proof status + futures.
- `modules/kido-sync.c` — the primitive: caller-embedded
  16-byte `kido_spinlock_t` {word, magic, owner}; init
  (refuses a held lock, stamps magic); lock (spinning
  take); try_lock (OK + acquired 0/1, never a failure
  code for contention); unlock (refuses free-lock and
  stranger unlock, state untouched); is_locked (one-read
  snapshot, honestly labeled); hosted-only
  `kido_sync_test_set_cpu_id()` injector (refuses the
  free sentinel). ARM64 backend: LDAXR/STLXR pair,
  SEVL/WFE/SEV with WFE only on the observed-held branch
  (a failed STLXR retries immediately — the liveness
  trap is closed in the asm, not hoped away). Hosted
  backend: `__atomic_compare_exchange_n` take,
  `__atomic_store_n` release — real atomics, proving
  the state machine exactly. No new header codes; no
  scheduler, entry, boot, HAL, smp, or psci coupling.
- `architecture/module-map.md` — kido-sync row added (DRAFT).

**Key decisions + why:**
1. Contention is a fact, not a failure (C1): the enum has
   no BUSY code and inventing one is N8toriousAi's call, so
   try_lock returns KIDO_OK with *acquired = 0 — the
   resonate-defer precedent. NULL/uninitialized stay
   real EARLY_ENV errors.
2. lock() spins by definition (C2): a live holder always
   progresses, so waiting is correct; a timeout would
   convert a dead holder into two holders — silent
   corruption instead of a loud hang. try_lock is the
   bounded door.
3. Owner tracking is load-bearing, not decoration (C4):
   MPIDR_EL1 raw on ARM64 (never parsed), injector value
   on hosted; stranger unlock refuses and the lock stays
   held. The owner word is written while the lock word
   is held and cleared before the STLR release store.
4. WFE placement is a liveness decision (C5): sleep only
   after observing held; STLXR failure retries at once.
   A spurious exclusive failure with a free lock and no
   future SEV must never sleep forever.
5. IRQ law stated, not solved (C3): the lock does not
   mask interrupts, so IRQ handlers must use try_lock or
   a separate discipline. Masking policy belongs to the
   vec/GIC wiring, and on SMP local masking excludes
   nothing anyway.

**One owned harness error:** the battery's first interop
build line omitted the `kido_halt` provider (sched links
it from boot.c, whose hosted main collides with interop's
own main). Fixed with a /tmp-only halt stub TU — interop
75/75 confirmed, and the session-33 `-c` recipe also
re-verified clean. Separately, the first reloc-flip run
used a nonexistent `-DKIDO_RELOC_FLIP_TEST` macro and
silently re-ran the closed gate (19); rerun with the
documented `-DKIDO_RELOC_AUDIT_PASS` gives the real
28/28. Both errors were mine, both caught by counts,
neither in the tree.

**Test results (all real, hosted, gcc 13.3.0, -Wall
-Wextra -Werror, zero warnings everywhere):**
- kido-sync self-test: 49/49, 0 failures — NULL +
  uninitialized guards, init stamping, take/contend/
  snapshot, init-refusal on a held lock, injector-
  proven stranger-unlock refusal (CPU 1 refused, owner
  0 kept), free-lock unlock refusal, try_lock taking
  as CPU 7, re-init on a free used lock + reuse.
- Plain hosted `-c`: PASS.
- Full hosted battery 20/20 PASS: sync 49, smp 56,
  psci 48, alloc 31, image 15, reloc-closed 19 +
  reloc-flip 28, sched 110, resonate 136, mem ALL PASS,
  hal PASS, entry PASS, mmu 121, mbox 33, pl011 49,
  gic 115, timer 54, serial-irq 354, boot integration
  PASS (kido_boot() -> 0, AAAABBBBCCCC), interop 75/75
  (via the /tmp halt stub; `-c` recipe also clean),
  audit fixture test ALL PASS.
- Collision check: zero `kido_sync`/`kido_spin`
  references outside the two new files.

**Honest limits (stated, not hand-waved):** WRITTEN, NOT
ASSEMBLED, NEVER EXECUTED — toolchain absent a 17th
time. The ARM64 LDAXR/STLXR/WFE/SEV sequence awaits
assemble + disassembly + a QEMU virt -smp 2 run, which
also needs the Gate secondary stub — so that proof
waits on both, stated. The hosted proof uses real
atomics but proves the state machine, not the asm.

**Remains:** QEMU virt PSCI proof + QEMU virt -smp proof
(both queued on the toolchain; the -smp proof also waits
on the Gate stub item); Gate items — wire kido_vec_install
into the boot path, wire GIC enable(30) + timer arm into
the scheduler tick, wire serial-irq init into the boot path
(after GIC init, before DAIF unmask), HAL wiring (PL011
init, mailbox adoption), kido-mmu call-site wiring,
psci-init gating policy, secondary entry stub (contract in
kido-smp.h), first kido-sync consumer (scheduler/Gate
wiring or an smp shared-state guard); destroy bare-metal
proof (design ready, session 22); real BUBO peer +
bare-metal transport (Phase 4); D1 KIDO_ERR_NO_TASKS header
code (N8toriousAi's call); PENDING #1 cross-compile — re-opens
on this tree change while the toolchain stays intermittent
(17th data point: absent). First boot is N8toriousAi's to witness.

## 2026-10-29 — Session 35: kido-barrier — the SMP rendezvous (builder crew)

**Goal:** the next module the tree can actually carry. Session 34's
remains are, again, all blocked or fenced: the QEMU virt PSCI proof
and the QEMU virt -smp proof need the toolchain (absent an 18th time
this session — `which` finds no aarch64-linux-gnu-gcc, no
qemu-system-aarch64); the Gate wirings (vec into the boot path, GIC
enable(30) + timer arm into the scheduler tick, serial-irq init into
the boot path, HAL wiring, MMU call-site wiring, psci-init gating
policy, secondary entry stub, first kido-sync consumer) are Gate
items, not things a scaffold session takes unilaterally; the destroy
bare-metal proof has its own design (session 22, not swallowed here);
D1 KIDO_ERR_NO_TASKS is N8toriousAi's call; the BUBO peer is Phase 4.
Per the session-22 precedent (degrade honestly to the next draftable
module), this session drafts kido-barrier: the rendezvous primitive
named as a future in kido-sync's header and its deliberation C6.
SMP brought CPUs up (session 33) and gave them a lock (session 34);
nothing yet lets N CPUs all arrive and all proceed together. Zero
existing files touched (the session-24/25/26/33 fence pattern); the
module-map row and this entry are the only other edits.

**Deliberation:**
`deliberations/2026-10-29-kido-barrier-design.md` (P1 rendezvous
realist / P2 ordering auditor / P3 static-tables keeper / P4 fence
keeper / P5 test keeper / P6 portability auditor; C1–C8 answered;
D1–D4 preserved — D1 bounded wait with a timeout overruled (a
timeout releases a partial group: silent corruption, not recovery),
D2 sense-reversing local sense overruled (generation counter is
equivalent and caller-keeps-nothing), D3 per-CPU arrival slots /
double-arrive detection overruled (second invention duplicating
smp's table; one-call-per-round contract stated), D4 barrier
inside the scheduler tick overruled as this session's scope (Gate
item)).

**Drafted (new files only):**
- `modules/kido-barrier.h` — interface + honesty laws (ordering
  chain, caller contract, deadlock law, IRQ law, init law,
  participant cap, snapshot law) + proof status + futures.
- `modules/kido-barrier.c` — the primitive: caller-embedded
  `kido_barrier_t` {spinlock, arrived, generation, participants,
  magic}; init (refuses NULL, 0/>8 participants, a round in
  flight; preserves generation monotonic, never reset);
  wait (lock, note generation, arrived++; last arriver resets
  arrived then bumps generation under the lock, unlocks,
  returns; others unlock and spin on an acquire load of
  generation until it differs); arrived (one-read diagnostic
  snapshot, sync is_locked precedent). ARM64 backend: one LDAR
  inline asm; hosted backend: __atomic acquire load — real
  acquire semantics proving the generation logic exactly. No new
  header codes; no scheduler, entry, boot, HAL, smp, psci, or
  sync coupling beyond sync's public API.
- `architecture/module-map.md` — kido-barrier row added (DRAFT).

**Key decisions + why:**
1. Generation counter, not sense-reversing local sense (C1): the
   caller keeps nothing, the struct holds one more word, and the
   semantics are identical. Simpler is auditable.
2. Release race closed by construction (C2): reset-then-bump both
   under the lock; waiters spin on generation, never on arrived,
   so the reset can never release a waiter early.
3. Ordering chain stated exactly (P2): last arriver's generation
   write under the lock + unlock's STLR release + waiter's LDAR
   acquire load = a waiter that sees the new generation sees
   everything every arriver wrote before arrival. No DMB claimed.
4. No timeout, no try_wait (C3): a timeout would release a
   partial group past the starting line — the exact corruption
   the barrier exists to prevent. Callers that cannot wait do
   not use a barrier.
5. Pthreads in the TEST TU ONLY (C8, a first for the scaffold):
   a single-threaded test proves guards and nothing about
   rendezvous — the module's entire purpose. The module TU
   compiles clean without -pthread (proven by the plain -c
   check); if a future session dislikes the dependency, the
   pthread section is one fenced block to replace.
6. Participant cap 8 = KIDO_SMP_MAX_CPUS (C7): the only CPU
   census the tree has. A larger rendezvous would be a guess.

**One owned harness error:** the battery's first interop build
line put `#include "kido-boot.h"` after the stub function that
uses its type (unknown type name). Fixed with a /tmp-only stub
that includes first — interop 75/75 confirmed. The error was
mine, in the harness, not in the tree.

**Test results (all real, hosted, gcc 13.3.0, -Wall -Wextra
-Werror, zero warnings everywhere):**
- kido-barrier self-test: 53/53, 0 failures — NULL +
  uninitialized + range guards, N=1 immediate release with
  generation counting rounds (0->1->2, preserved across
  re-init, then 3), 4-thread 2-round pthread rendezvous
  (every thread's post-barrier sum == 10, proving all
  pre-barrier writes visible to all threads; post count 4;
  generation exactly 2; arrived 0), in-flight re-init refusal
  proven with a genuinely blocked thread (arrived==1,
  generation still 0, init EARLY_ENV, round untouched, B's
  arrival releasing both to generation 1, idle re-init OK
  with generation preserved). Three repeat runs: 53/53 each.
- Plain hosted `-c` (no -pthread): PASS — the pthread
  separation is proven, not asserted.
- Collision check: zero `kido_barrier` references outside the
  two new files.
- Full hosted battery 21/21 PASS: barrier 53, sync 49, smp 56,
  psci 48, alloc 31, image 15, reloc-closed 19 +
  reloc-flip 28, sched 110, resonate 136, mem ALL PASS,
  hal PASS, entry PASS, mmu 121, mbox 33, pl011 49,
  gic 115, timer 54, serial-irq 354, boot integration
  PASS (kido_boot() -> 0, AAAABBBBCCCC), interop 75/75
  (via the /tmp halt stub), audit fixture test ALL PASS.

**Honest limits (stated, not hand-waved):** WRITTEN, NOT
ASSEMBLED, NEVER EXECUTED — toolchain absent an 18th time.
The ARM64 LDAR spinner awaits assemble + disassembly + a
QEMU virt -smp 2 run, which also needs the Gate secondary
stub — so that proof waits on both, stated. The hosted proof
uses real threads and real acquire loads but proves the
generation logic, not the LDAR spelling.

**Remains:** QEMU virt PSCI proof + QEMU virt -smp proof
(both queued on the toolchain; the -smp proof also waits on
the Gate stub item); Gate items — wire kido_vec_install
into the boot path, wire GIC enable(30) + timer arm into
the scheduler tick, wire serial-irq init into the boot path
(after GIC init, before DAIF unmask), HAL wiring (PL011
init, mailbox adoption), kido-mmu call-site wiring,
psci-init gating policy, secondary entry stub (contract in
kido-smp.h), first kido-sync consumer, first kido-barrier
consumer (scheduler-tick rendezvous, smp shared-state
guard, or a Gate wiring); destroy bare-metal proof (design
ready, session 22); real BUBO peer + bare-metal transport
(Phase 4); D1 KIDO_ERR_NO_TASKS header code (N8toriousAi's call);
PENDING #1 cross-compile — re-opens on this tree change
while the toolchain stays intermittent (18th data point:
absent). First boot is N8toriousAi's to witness.

## 2026-10-29 — Session 36: kido-ipi — the SMP signaling discipline (builder crew)

**Goal:** the next module the tree can actually carry. Session 35's
remains are, again, all blocked or fenced: the QEMU virt PSCI proof
and the QEMU virt -smp proof need the toolchain (absent a 19th time
this session — `which` finds no aarch64-linux-gnu-gcc, no
qemu-system-aarch64); the Gate wirings (vec into the boot path, GIC
enable(30) + timer arm into the scheduler tick, serial-irq init into
the boot path, HAL wiring, MMU call-site wiring, psci-init gating
policy, secondary entry stub, first kido-sync consumer, first
kido-barrier consumer) are Gate items, not things a scaffold session
takes unilaterally; the destroy bare-metal proof has its own design
(session 22, not swallowed here); D1 KIDO_ERR_NO_TASKS is N8toriousAi's
call; the BUBO peer is Phase 4. Per the session-22 precedent
(degrade honestly to the next draftable module), this session drafts
kido-ipi: the inter-processor interrupt discipline the SMP line has
been missing. Session 33 brought CPUs up, 34 gave them a lock, 35
gave them a rendezvous — nothing yet let one CPU SIGNAL another.
The GIC can send an SGI, but an SGI number means nothing without a
discipline. Zero existing files touched (the session-24/25/26/33
fence pattern); the module-map row and this entry are the only
other edits.

**Deliberation:**
`deliberations/2026-10-29-kido-ipi-design.md` (P1 signaling realist
/ P2 transport injector / P3 IRQ-context auditor / P4 SMP census
keeper / P5 minimal-types advocate / P6 test keeper; C1–C8
answered; D1–D4 preserved — D1 STOP type overruled (a spinning
handler blocks its own EOIR; parking is scheduler policy at a safe
point), D2 CALL type overruled (needs a cross-CPU function mailbox,
a second invention behind the scheduler), D3 direct kido-gic
dependency overruled (leaf/MMIO coupling, breaks the hosted proof),
D4 acknowledged send overruled (reverse IPI + timeout; rendezvous
is the barrier's job, already built)).

**Drafted (new files only):**
- `modules/kido-ipi.h` — interface + honesty laws (module-global
  registry, injected transport, mask law, send-handoff law,
  dispatch law, IRQ law, proof status, futures) + TESTING line.
- `modules/kido-ipi.c` — the discipline: module-global registry
  {magic, ops, base, handlers[2], args[2], stats}; init (refuses
  NULL ops, NULL send slot, base > 14; re-init rebuilds the
  world — handlers/args/stats cleared); sgi_id (base + type, so
  the wiring never recomputes the mapping); register (NULL
  unregisters, GIC precedent); send (refuses bad type, zero
  mask, mask bits >= 8 — never truncated — then narrows to
  uint8_t; transport failure propagates unchanged and counts
  nothing; success counts sent[type]); dispatch (in-range:
  received[type]++, handler if any, OK; out-of-range:
  unknown++, EARLY_ENV); stats copy. Plain portable C — no
  MMIO, no asm, no arch backend at all. Self-test 54 checks
  (§0 pre-init refusals, §1 init guards, §2 base-14 mapping,
  §3–§4 register/send guards incl. bit-8 and bit-31 masks,
  §5 RESCHED handoff recorded, §6 transport failure
  propagation, §7 unknown dispatch, §8 handler delivery with
  type/source/arg pinned, §9 no-handler delivery OK + counted,
  §10 self-send path, §11 unregister, §12 re-init rebuild,
  §13 post-re-init delivery on the new ids).
- `architecture/module-map.md` — kido-ipi row added (DRAFT).

**Key decisions + why:**
1. Module-global registry, not caller-embedded (C1): SGI ids
   are one system-wide namespace — two registries would
   double-claim ids. The GIC's static handler table is the
   precedent.
2. Transport injected, never included (P2/D3): the ops send
   slot matches kido_gic_send_sgi's signature exactly, so
   the Gate binding is one line and the leaf stays host-
   testable with no GIC bases.
3. Two types only (P5): RESCHED + PING. CALL/STOP/TLB are
   named futures with stated blockers, not bare enum values
   claiming capabilities with no contract behind them.
4. Mask validated as uint32_t before narrowing (P4): the
   GIC's uint8_t mask cannot even express the bit-8 refusal
   case; this layer refuses bits >= 8 rather than silently
   dropping a CPU the caller meant to signal.
5. Send claims handoff, never delivery (C8): sent and
   received are separate counters because an SGI is
   fire-and-forget by architecture — delivery is proven by
   dispatch() on the target, or not at all.
6. No send-to-all-but-self helper (C3): it would need a
   current-CPU query the tree does not have (MPIDR parsing
   is a future, not a guess); the caller knows its smp slot
   and computes the mask in one expression.
7. No new header codes (sched-D1 precedent): every failure
   is KIDO_ERR_EARLY_ENV or a propagated transport status.

**Test results (all real, hosted, gcc 13.3.0, -Wall
-Wextra -Werror, zero warnings everywhere):**
- kido-ipi self-test: 54/54, 0 failures, four runs identical
  (first run + three repeats).
- Plain hosted `-c`: PASS.
- Collision check: zero `kido_ipi`/`KIDO_IPI` references
  outside the two new files.
- Neighbor regressions (tree untouched, verified not
  assumed): barrier 53/53, sync 49/49, gic 115/115.

**Honest limits (stated, not hand-waved):** WRITTEN, NOT
ASSEMBLED, NEVER EXECUTED — toolchain absent a 19th time.
The hosted proof uses a scripted transport and direct
dispatch() calls: it proves the discipline (mapping, masks,
counting, every refusal), not the SGI actually arriving on
another CPU. That proof waits on the Gate wiring (bind
kido_gic_send_sgi, register dispatch for the owned ids,
unmask) plus a QEMU virt -smp 2 run, stated. The module has
no asm, so unlike sessions 33–35 there is no ARM64 spelling
awaiting disassembly — only the cross-CPU delivery itself.

**Remains:** QEMU virt PSCI proof + QEMU virt -smp proof
(both queued on the toolchain; the -smp proof also waits on
the Gate stub item); Gate items — wire kido_vec_install
into the boot path, wire GIC enable(30) + timer arm into
the scheduler tick, wire serial-irq init into the boot path
(after GIC init, before DAIF unmask), HAL wiring (PL011
init, mailbox adoption), kido-mmu call-site wiring,
psci-init gating policy, secondary entry stub (contract in
kido-smp.h), first kido-sync consumer, first kido-barrier
consumer, first kido-ipi consumer (scheduler-tick RESCHED
broadcast, or a Gate wiring binding the transport);
destroy bare-metal proof (design ready, session 22); real
BUBO peer + bare-metal transport (Phase 4); D1
KIDO_ERR_NO_TASKS header code (N8toriousAi's call); PENDING #1
cross-compile — re-opens on this tree change while the
toolchain stays intermittent (19th data point: absent).
First boot is N8toriousAi's to witness.

## 2026-10-30 — Session 37: kido-call — the cross-CPU function mailbox (builder crew)

**Goal:** the next module the tree can actually carry. Session 36's
remains are, again, all blocked or fenced: the QEMU virt PSCI proof
and the QEMU virt -smp proof need the toolchain (absent a 20th time
this session — `which` finds no aarch64-linux-gnu-gcc, no
qemu-system-aarch64); the Gate wirings (vec into the boot path, GIC
enable(30) + timer arm into the scheduler tick, serial-irq init into
the boot path, HAL wiring, MMU call-site wiring, psci-init gating
policy, secondary entry stub, first sync/barrier/ipi consumers) are
Gate items, not things a scaffold session takes unilaterally; the
destroy bare-metal proof has its own design (session 22, not swallowed
here); D1 KIDO_ERR_NO_TASKS is N8toriousAi's call; the BUBO peer is Phase
4. Per the session-22 precedent (degrade honestly to the next
draftable module), this session drafts kido-call: the work carrier
session 36's ipi deliberation D2 named as the blocker for a future
CALL type. Session 33 brought CPUs up, 34 gave them a lock, 35 gave
them a rendezvous, 36 gave them a signal — nothing yet let one CPU
ask another to DO something. Zero existing files touched (the
session-24/25/26/33 fence pattern); the module-map row and this entry
are the only other edits.

**Deliberation:**
`deliberations/2026-10-30-kido-call-design.md` (P1 work-queue
realist / P2 ordering auditor / P3 IRQ-context auditor / P4 census
keeper / P5 fence keeper / P6 test keeper; C1–C10 answered; D1–D4
preserved — D1 blocking post/wait with a timeout overruled (a
timeout converts a busy callee into a lost call, an unfinished call
into a wrong answer), D2 a queue of N per CPU overruled (queue
policy is unasked-for invention), D3 running the function in the
IPI handler overruled (handlers must stay short, non-blocking,
allocator-free; arbitrary code satisfies none), D4 injecting an
ipi notify transport now overruled (fence; the binding is one Gate
line when the wiring lands)).

**Drafted (new files only):**
- `modules/kido-call.h` — interface + honesty laws (state machine,
  claim-not-custody, poster law, arg law, poll-first, CPU identity,
  idle-loop contract, IRQ law, init law, snapshot law) + proof
  status + futures.
- `modules/kido-call.c` — the mailbox: module-global table of 8
  slots {spinlock, state, poster, fn, arg, result}; init (refuses
  over any non-EMPTY slot, rebuilds only an empty table, clears
  stats); post (door: busy = OK + accepted 0, counted; empty =
  store + POSTED, counted); poll (POSTED -> RUNNING under the
  lock, function runs OUTSIDE the lock, RUNNING -> DONE under
  the lock, counted; any other state is a no-op); reap
  (stranger refusal before any touch when non-EMPTY, counted;
  DONE + owner = copy result, DONE -> EMPTY, counted; otherwise
  OK + done 0); state (one-read diagnostic snapshot); stats
  (copied under the stats lock). Lock order slot -> stats,
  stats lock held only across one increment. No new header
  codes; no scheduler, entry, boot, HAL, smp, psci, ipi, or
  GIC coupling beyond sync's public API.
- `architecture/module-map.md` — kido-call row added (DRAFT).

**Key decisions + why:**
1. Module-global table, not caller-embedded (C1): a slot belongs
   to its target CPU, which never "holds" it — an address in a
   system-wide address book, like ipi's SGI namespace. Two
   tables would double-deliver calls. The sync/barrier
   precedent was distinguished, not ignored.
2. The function never runs under the lock (C3): the claim is
   the critical section, not the work. Running under the lock
   would serialize reaps against an arbitrary body and deadlock
   the day a function posts a call of its own.
3. Poster law (C4): reap by a non-poster refuses EARLY_ENV with
   the slot untouched, at POSTED and at DONE alike — the sync
   stranger-unlock precedent applied to results.
4. Poll-first, no wakeup in the leaf (C6): no ipi include, no
   transport, no MMIO — the mailbox works from the target's
   idle loop, and the Gate wiring binds the wakeup later.
   Polling without wakeup is slower, not wrong.
5. Both CPU indices passed explicitly (C8): the caller knows
   its smp slot (ipi C6); MPIDR parsing stays a named future
   (ipi C3). No hosted injector was needed — the test plays
   two CPUs by passing two indices.
6. Stats exactness without a second invention: a leaf-internal
   stats lock, always taken after the slot lock, held only
   across one increment, so no counter increment is ever lost
   and no lock-order inversion exists.

**Test results (all real, hosted, gcc 13.3.0, -Wall -Wextra
-Werror, zero warnings everywhere):**
- kido-call self-test: 79/79, 0 failures, three runs identical
  — pre-init refusals, post guards, full lifecycle, error
  result storage, busy door with first call intact, stranger
  refusal at POSTED and DONE, self-post, re-init refusal over
  a busy slot + clean rebuild, poll no-ops (completed count
  unmoved), exact stats pin (1/1/1/1/1), pthread proof that
  the function runs on the poller's thread (fn thread id ==
  poller thread id, not the poster's).
- Plain hosted `-c` (no -pthread): PASS — the pthread
  separation is proven, not asserted.
- Collision check: zero `kido_call` references outside the
  two new files.
- Neighbor regressions (tree untouched, verified not
  assumed): barrier 53/53, sync 49/49, ipi 54/54.

**Honest limits (stated, not hand-waved):** WRITTEN, NOT
ASSEMBLED, NEVER EXECUTED — toolchain absent a 20th time.
The module has no asm, so unlike sessions 33–35 there is no
ARM64 spelling awaiting disassembly — only the cross-CPU
execution itself, which awaits the Gate secondary stub + a
QEMU virt -smp 2 run, stated. The hosted proof uses real
spinlocks and a real poller thread but proves the mailbox
discipline, not delivery across silicon. The ipi CALL type
itself stays a named future until the Gate wiring binds
transport + handler + wakeup policy together.

**Remains:** QEMU virt PSCI proof + QEMU virt -smp proof
(both queued on the toolchain; the -smp proof also waits on
the Gate stub item); Gate items — wire kido_vec_install
into the boot path, wire GIC enable(30) + timer arm into
the scheduler tick, wire serial-irq init into the boot path
(after GIC init, before DAIF unmask), HAL wiring (PL011
init, mailbox adoption), kido-mmu call-site wiring,
psci-init gating policy, secondary entry stub (contract in
kido-smp.h), first kido-sync consumer, first kido-barrier
consumer, first kido-ipi consumer, first kido-call consumer
(scheduler-tick work half, or a Gate wiring binding ipi
transport + a CALL-type handler that polls); destroy
bare-metal proof (design ready, session 22); real BUBO peer
+ bare-metal transport (Phase 4); D1 KIDO_ERR_NO_TASKS header
code (N8toriousAi's call); PENDING #1 cross-compile — re-opens
on this tree change while the toolchain stays intermittent
(20th data point: absent). First boot is N8toriousAi's to witness.

## 2026-10-30 — Session 38: kido-mpidr — the CPU-identity leaf (builder crew)

**Goal:** close the named future three modules refused in writing —
MPIDR parsing (smp's opaque-affinity law, ipi C3, call C8) — as
its own leaf, not smuggled into a proven file. Session 33's D3
(secondary stub is a Gate item, untestable shape without its
scheduler consumer) stands UNREOPENED: this session does not
draft the stub by another name; a register decoder with a
hosted proof is testable on its own terms.

**Deliberation:**
`deliberations/2026-10-30-kido-mpidr-design.md` (P1 identity
realist / P2 opaque-affinity auditor / P3 no-linear-index
auditor / P4 sync-compat keeper / P5 test keeper / P6 honesty
auditor; C1–C9 answered; D1–D3 preserved — D1 a linear index
for the single-cluster common case overruled (a platform
accident, not architecture), D2 decoding inside sync overruled
(sync's owner needs only raw equality), D3 validating reserved
bits overruled (a decoder is not the firmware police)).

**Drafted (new files only):**
- `modules/kido-mpidr.h` — interface + honesty laws (field law
  per Arm MPIDR_EL1: Aff0 [7:0], Aff1 [15:8], Aff2 [23:16],
  MT [24], RES0 [29:25], U [30], RES1 [31], Aff3 [39:32],
  RES0 [63:40]; no-linear-index law; same-CPU law; reserved-
  bit law; EL1+ caller law) + proof status + futures.
- `modules/kido-mpidr.c` — read() (one MRS, sync's spelling
  verbatim; hosted injector, sync precedent) + pure decode()
  (read calls decode, the paths can never drift) + same_cpu()
  (Aff3..Aff0 only; MT/U are not identity). No new header
  codes; NULL guards -> EARLY_ENV. No scheduler, entry,
  boot, HAL, smp, psci, ipi, GIC, or sync coupling.
- `architecture/module-map.md` — kido-mpidr row added (DRAFT).

**Key decisions + why:**
1. No linear CPU index, deliberately (C2): the Aff tuple is
   hierarchical and only guaranteed unique as a whole;
   Aff0-as-index aliases PEs on multi-cluster systems.
   Slot-from-affinity is a Gate table lookup, never
   arithmetic in this leaf.
2. Same CPU = all four Aff levels (C3): MT is a
   performance hint about Aff0 siblings, U describes the
   system shape — neither changes which PE a tuple names.
   No "same cluster" helper: Aff2/Aff1 physical meaning
   is IMPLEMENTATION DEFINED, and naming it would be the
   C2 invention one level up.
3. Reserved bits masked, never policed (C4): bit 31 is
   RES1 (real hardware always returns it set); RES0
   fields are masked out. A decoder that refused firmware
   values would turn the cheapest question in the tree
   into a loud halt. Raw carried whole in the struct.
4. decode() as a pure function (C8): a future consumer
   can decode a recorded affinity from the smp table
   ("which PE was that?") without reading its own
   register.
5. Zero existing files touched (the session-24/25/26/33
   fence pattern); sync keeps its raw MPIDR owner.

**Test results (all real, hosted, gcc 13.3.0, -Wall -Wextra
-Werror, zero warnings everywhere):**
- kido-mpidr self-test: 37/37, 0 failures — NULL guards,
  zero tuple, every field at once, MT/U alone and together,
  reserved-bit masking (RES1 set, RES0 garbage, bit-31-clear
  injector value all decode), QEMU-virt-shaped pair
  (Aff0 0 vs 1 -> not same), same_cpu true across MT/U
  differences and false on each single Aff level, read()
  through the injector field-exact + decode idempotence,
  injector reset + self-comparison.
- Plain hosted `-c`: PASS. Plain `-fsyntax-only` without
  KIDO_HOSTED_TEST correctly REFUSES on the x86 host
  (the arch-discipline error, working as designed).
- Collision check: zero `kido_mpidr` references outside
  the two new files.
- Neighbor regressions (tree untouched, verified not
  assumed): call 79/79, sync 49/49, ipi 54/54, barrier 53/53.

**Honest limits (stated, not hand-waved):** WRITTEN, NOT
ASSEMBLED, NEVER EXECUTED — toolchain absent a 21st time.
The module's one asm instruction is sync's already-carried
MRS spelling; what awaits a tooled VM is the disassembly
check that the MRS is present, plus a QEMU virt -smp 2 run
showing two distinct Aff tuples. The hosted proof pins the
decode, not delivery across silicon. No wiring is
authorized by this record: ipi/call/scheduler consumers
and the secondary stub stay Gate items.

**Remains:** QEMU virt PSCI proof + QEMU virt -smp proof
(both queued on the toolchain; the -smp proof also waits on
the Gate stub item); Gate items — wire kido_vec_install
into the boot path, wire GIC enable(30) + timer arm into
the scheduler tick, wire serial-irq init into the boot path
(after GIC init, before DAIF unmask), HAL wiring (PL011
init, mailbox adoption), kido-mmu call-site wiring,
psci-init gating policy, secondary entry stub (contract in
kido-smp.h, session-33 D3 stands), first kido-sync consumer,
first kido-barrier consumer, first kido-ipi consumer, first
kido-call consumer, first kido-mpidr consumer (scheduler
placement, CALL-handler self-slot, or Gate CPU-to-mailbox
binding); destroy bare-metal proof (design ready, session
22); real BUBO peer + bare-metal transport (Phase 4); D1
KIDO_ERR_NO_TASKS header code (N8toriousAi's call); PENDING #1
cross-compile — re-opens on this tree change while the
toolchain stays intermittent (21st data point: absent).
First boot is N8toriousAi's to witness.

## 2026-10-31 — Session 39: kido-cache — the cache-maintenance leaf (builder crew)

**Goal:** the next module the tree can actually carry. Session 38's
remains are, again, all blocked or fenced: the QEMU virt PSCI proof
and the QEMU virt -smp proof need the toolchain (absent a 22nd time
this session — `which` finds no aarch64-linux-gnu-gcc, no
qemu-system-aarch64); the Gate wirings (vec into the boot path, GIC
enable(30) + timer arm into the scheduler tick, serial-irq init into
the boot path, HAL wiring, MMU call-site wiring, psci-init gating
policy, secondary entry stub, first sync/barrier/ipi/call/mpidr
consumers) are Gate items, not things a scaffold session takes
unilaterally; the destroy bare-metal proof has its own design
(session 22, not swallowed here); D1 KIDO_ERR_NO_TASKS is N8toriousAi's
call; the BUBO peer is Phase 4. Per the session-22 precedent
(degrade honestly to the next draftable module), this session drafts
kido-cache: the primitive the tree has lacked since session 22 turned
caches on and session 33 gave secondaries a mailbox to read — no
module offered a clean-to-PoC, so the mailbox works only while caches
are off, exactly the state mmu's enable sequence leaves behind. Zero
existing files touched (the session-24/25/26/33 fence pattern); the
module-map row and this entry are the only other edits.

**Deliberation:**
`deliberations/2026-10-31-kido-cache-design.md` (P1 coherence realist
/ P2 ordering auditor / P3 destructive-op auditor / P4 sequence
keeper / P5 fence keeper / P6 test keeper; C1–C8 answered; D1–D4
preserved — D1 bare dsb()/isb() API overruled (barriers ride inside
ops), D2 set/way maintenance overruled (geometry-addressed, discards
unrelated lines), D3 unaligned invalidate with a warning overruled
(a warning is not a refusal), D4 one line size for both caches
overruled (C2: D and I lines differ)).

**Drafted (new files only):**
- `modules/kido-cache.h` — interface + honesty laws (point law,
  two-line-sizes law, alignment law, zero-length law, barrier law,
  no-set/way law, EL law, destructive-op warning) + proof status +
  futures. Hosted trace log API (reset/count/at, capacity 16, drops
  past capacity rather than wrapping — a wrapped log would lie
  about order).
- `modules/kido-cache.c` — the leaf: CTR_EL0 DminLine/IminLine
  reads (one MRS each, bare metal; injector fields on hosted, same
  4 << field formula so the formula is tested though the register
  is not); shared round_range helper (base down, end up,
  double wrap-guard: addr+len, then the round-up); clean_range
  (DC CVAC + DSB SY), invalidate_range (DC IVAC + DSB SY, with
  the C3 refusal: unaligned addr or len -> EARLY_ENV before any
  walk), clean_invalidate_range (DC CIVAC + DSB SY),
  sync_icache_range (CVAU walk by D-size, DSB, IVAU walk by
  I-size, DSB, ISB — one function so the order is unreorderable),
  icache_invalidate_all (IC IALLU + DSB + ISB). No new header
  codes; no scheduler, entry, boot, HAL, smp, mmu, or sync coupling
  beyond kido-boot.h.
- `architecture/module-map.md` — kido-cache row added (DRAFT).

**Key decisions + why:**
1. Two line sizes, not one (C2): CTR_EL0's DminLine and IminLine
   are separate fields; DC walks step by D, IVAU by I. A single
   size would skip lines on any core whose I and D lines differ
   — silent stale data or stale instructions, no fault to
   announce it. The test proves it by making the sizes differ
   (D=64, I=32: same range yields 4 CVAU lines, 8 IVAU lines).
2. Invalidate refuses unaligned ranges, clean rounds them (C3):
   cleaning a line writes a neighbor's dirty bytes back
   (harmless); invalidating a line DISCARDS them. Only the
   destructive op gets the refusal — not a blanket rule the
   tree would then carve exceptions out of.
3. Zero length refuses everywhere (C4): rounding a zero range
   up to one line would maintain a line nobody asked about —
   the C3 hazard wearing a no-op's clothes.
4. DSB SY, not ISH (C5): PoC visibility is owed to every
   observer, not just the inner shareable domain, and the cost
   is one barrier per op, never per line.
5. No set/way ops (C6/D2): they address cache geometry, not
   memory, and would discard other agents' lines. IC IALLU is
   the principled exception — re-fetchable instructions, no
   data lost.

**Two owned test errors (module was right both times):** the §4
tail case (0x103c + 8 spans two lines, not one — fixed to len 4,
which ends exactly on the boundary) and the §7 second case
(0x4004 + 1 rounds the 32-byte I-walk to one line, not two —
fixed to len 33, which spans two I-lines and one D-line).
Both caught by recomputation before the run, neither in the tree.
Also discarded mid-draft: a shared walk helper with a placeholder
step — replaced by one real loop per op, since a runtime-selected
maintenance instruction is not expressible in inline asm.

**Test results (all real, hosted, gcc 13.3.0, -Wall -Wextra -Werror,
zero warnings everywhere):**
- kido-cache self-test: 74/74, 0 failures, three runs identical —
  NULL guards, line-size formula (64/256/128/4), range guards
  (0 addr, 0 len, wrap, unaligned invalidate) recording nothing,
  clean rounding (4 geometries), invalidate aligned pass +
  C3 refusals, clean-invalidate rounding, sync two-walk order
  with differing line sizes, icache-all DSB+ISB, trace log
  capacity/reset/order.
- Plain hosted `-c`: PASS. Non-hosted `-fsyntax-only` on the x86
  host correctly REFUSES (the arch-discipline error, working as
  designed).
- Collision check: zero `kido_cache` references outside the two
  new files.
- Neighbor regressions (tree untouched, verified not assumed):
  mpidr 37/37, call 79/79 (with kido-sync.c, its real dependency),
  sync 49/49, ipi 54/54, barrier 53/53 (with kido-sync.c, -pthread).

**Honest limits (stated, not hand-waved):** WRITTEN, NOT ASSEMBLED,
NEVER EXECUTED — toolchain absent a 22nd time. The DC/IC/DSB/ISB
spellings await assemble + disassembly + a QEMU virt -smp 2 run
with caches on, which also needs the Gate smp-mailbox wiring
(deliberation C7) before the mailbox proof means anything. The
hosted proof pins arithmetic, guards, walk counts, and barrier
order — not the silicon. EL law: maintenance by VA traps from
EL0 (SCTLR_EL1.UCI unset in this tree); call at EL1+, stated
not enforced, the mpidr precedent.

**Remains:** QEMU virt PSCI proof + QEMU virt -smp proof (both queued
on the toolchain; the -smp proof also waits on the Gate stub item);
Gate items — wire kido_vec_install into the boot path, wire GIC
enable(30) + timer arm into the scheduler tick, wire serial-irq init
into the boot path (after GIC init, before DAIF unmask), HAL wiring
(PL011 init, mailbox adoption), kido-mmu call-site wiring, psci-init
gating policy, secondary entry stub (contract in kido-smp.h,
session-33 D3 stands), first kido-sync consumer, first kido-barrier
consumer, first kido-ipi consumer, first kido-call consumer, first
kido-mpidr consumer, first kido-cache consumer (smp mailbox clean
at the writer side, or a post-mmu-enable I-cache invalidate);
destroy bare-metal proof (design ready, session 22); real BUBO peer
+ bare-metal transport (Phase 4); D1 KIDO_ERR_NO_TASKS header code
(N8toriousAi's call); PENDING #1 cross-compile — re-opens on this tree
change while the toolchain stays intermittent (22nd data point:
absent). First boot is N8toriousAi's to witness.

## 2026-10-31 — Session 40: kido-topo — the CPU-topology registry (builder crew)

**Goal:** the next module the tree can actually carry. Session 39's
remains are, again, all blocked or fenced: the QEMU virt PSCI proof
and the QEMU virt -smp proof need the toolchain (absent a 23rd time
this session — `which` finds no aarch64-linux-gnu-gcc, no
qemu-system-aarch64); the Gate wirings (vec into the boot path, GIC
enable(30) + timer arm into the scheduler tick, serial-irq init into
the boot path, HAL wiring, MMU call-site wiring, psci-init gating
policy, secondary entry stub, first sync/barrier/ipi/call/mpidr/
cache consumers) are Gate items, not things a scaffold session takes
unilaterally; the destroy bare-metal proof has its own design
(session 22, not swallowed here); D1 KIDO_ERR_NO_TASKS is N8toriousAi's
call; the BUBO peer is Phase 4. Per the session-22 precedent
(degrade honestly to the next draftable module), this session drafts
kido-topo: the binding session 33 (slots by bring_up order) and
session 38 (decoded Aff identity) never recorded — without it, the
only answers to "which PE is slot 3?" are re-reading firmware state
(query answers state, not identity) or assuming Aff0 == slot (the
QEMU-virt accident mpidr forbade as arithmetic). Zero existing files
touched (the session-24/25/26/33 fence pattern); the module-map row
and this entry are the only other edits.

**Deliberation:**
`deliberations/2026-10-31-kido-topo-design.md` (P1 binding realist /
P2 no-arithmetic auditor / P3 conflict auditor / P4 absence auditor /
P5 fence keeper / P6 test keeper; C1–C8 answered; D1–D4 preserved —
D1 auto-register the primary in init() overruled (init must not
crown slot 0 by fiat), D2 raw-affinity lookup API overruled (one
comparison path via pure decode), D3 linear-index helper overruled
(the mpidr D1 refusal restated), D4 re-init clears the table
overruled (append-only, no wipe under live CPUs)).

**Drafted (new files only):**
- `modules/kido-topo.h` — interface + honesty laws (table law,
  slot law, identity law, conflict law, absence law, primary law,
  lock law, init law) + proof status + futures. Own
  KIDO_TOPO_MAX_CPUS 8 (the ipi precedent; moves with the smp
  census as a Gate item, never by drift).
- `modules/kido-topo.c` — the leaf: module-global 8-entry table
  {decoded aff, slot, occupied} under one module-global kido-sync
  spinlock held across each whole operation; register() (both
  conflict arms in one scan, exact-pair idempotent, full table
  refuses through the slot-conflict arm — no separate FULL code),
  slot_for()/aff_for() (OK + found 0 on absence, out-pointer
  untouched), count(); init() succeeds exactly once and registers
  nothing. No asm of its own (ARM64 content is sync's exclusive
  pair); no scheduler, entry, boot, HAL, smp, ipi, or call coupling
  beyond mpidr's decoded struct + sync's public lock API.
- `architecture/module-map.md` — kido-topo row added (DRAFT).

**Key decisions + why:**
1. Module-global table, not caller-embedded (C1): topology has one
   answer per machine; two caller tables could disagree about the
   machine. The ipi/call precedents, not the sync/barrier shape.
2. Slot passed explicitly, never computed (C2): the slot is an
   smp-assigned label. Any Aff->slot formula would be mpidr's C2
   invention in a new header.
3. Decoded struct only, no raw API (C3): a raw path could drift
   from the decoded comparison (e.g. comparing MT/U bits same_cpu
   ignores). Consumers decode once via pure mpidr_decode().
4. Two conflict arms + idempotent arm (C4): aliasing and theft
   refuse loud, table untouched; exact-pair re-register is OK so
   arrival retries are safe.
5. Absence is found = 0, never an error (C5): "has it arrived yet?"
   is a clean no, not a failure — the try_lock precedent.
6. Init registers nothing (C6): crowning slot 0 would invent the
   primary's slot policy. The Gate wiring reads + registers the
   boot CPU; until then count 0 / found 0 is honest absence.

**Test results (all real, hosted, gcc 13.3.0, -Wall -Wextra
-Werror, zero warnings everywhere):**
- kido-topo self-test: 52/52, 0 failures, three runs identical —
  pre-init refusals with out-pointers untouched, init-once,
  UP zero-tuple registration, unoccupied-slot absence, MT/U
  blindness (MT=1 register, U=1 lookup finds slot 3),
  multi-cluster alias guard (Aff1 1/Aff0 0 distinct from zero
  tuple), both conflict arms with the table pinned unchanged,
  idempotent re-register, full-table refusal through the
  slot-conflict arm, 2-thread concurrent registration under
  the real spinlock (both OK, count +2 exactly, lookups exact).
- Plain hosted `-c` (no -pthread): PASS — threads live in the
  test TU only (barrier precedent).
- Non-hosted `-fsyntax-only` on the x86 host correctly REFUSES
  (the arch-discipline error, working as designed, the
  mpidr/cache precedent).
- Collision check: zero `kido_topo` references outside the two
  new files.
- Neighbor regressions (tree untouched, verified not assumed):
  mpidr 37/37, barrier 53/53, sync 49/49, cache 74/74, call
  79/79, ipi 54/54.

**Honest limits (stated, not hand-waved):** WRITTEN, NOT
ASSEMBLED, NEVER EXECUTED — toolchain absent a 23rd time. The
leaf has no asm, so unlike sessions 33–35 there is no ARM64
spelling awaiting disassembly — only the QEMU virt -smp 2 run
showing two distinct Aff tuples at two distinct slots, which
also needs the Gate arrival wiring (deliberation C6) before
the registration proof means anything on silicon. The hosted
proof pins the table discipline, not delivery across silicon.

**Remains:** QEMU virt PSCI proof + QEMU virt -smp proof (both queued
on the toolchain; the -smp proof also waits on the Gate stub item);
Gate items — wire kido_vec_install into the boot path, wire GIC
enable(30) + timer arm into the scheduler tick, wire serial-irq init
into the boot path (after GIC init, before DAIF unmask), HAL wiring
(PL011 init, mailbox adoption), kido-mmu call-site wiring,
psci-init gating policy, secondary entry stub (contract in
kido-smp.h, session-33 D3 stands), first kido-sync consumer, first
kido-barrier consumer, first kido-ipi consumer, first kido-call
consumer, first kido-mpidr consumer, first kido-cache consumer, first
kido-topo consumer (smp arrival registration at the context_id slot,
or the primary's own registration at boot); destroy bare-metal proof
(design ready, session 22); real BUBO peer + bare-metal transport
(Phase 4); D1 KIDO_ERR_NO_TASKS header code (N8toriousAi's call); PENDING
#1 cross-compile — re-opens on this tree change while the toolchain
stays intermittent (23rd data point: absent). First boot is N8toriousAi's
to witness.

## 2026-11-01 — Session 41: kido-time — the monotonic clock leaf (builder crew)

**Goal:** the next module the tree can actually carry. Session 40's
remains are, again, all blocked or fenced: the QEMU virt PSCI proof
and the QEMU virt -smp proof need the toolchain (absent a 24th time
this session — `which` finds no aarch64-linux-gnu-gcc, no
qemu-system-aarch64); the Gate wirings (vec into the boot path, GIC
enable(30) + timer arm into the scheduler tick, serial-irq init into
the boot path, HAL wiring, MMU call-site wiring, psci-init gating
policy, secondary entry stub, first sync/barrier/ipi/call/mpidr/
cache/topo consumers, the timer binding) are Gate items, not things
a scaffold session takes unilaterally; the destroy bare-metal proof
has its own design (session 22, not swallowed here); D1
KIDO_ERR_NO_TASKS is N8toriousAi's call; the BUBO peer is Phase 4. Per
the session-22 precedent (degrade honestly to the next draftable
module), this session drafts kido-time: session 29's timer reports
a count and arms a compare, but nothing since has turned that count
into time — ticks are not a unit, and every future timeout,
quantum, and log timestamp needs one shared unit. Zero existing
files touched (the session-24/25/26/33 fence pattern); the
module-map row and this entry are the only other edits.

**Deliberation:**
`deliberations/2026-11-01-kido-time-design.md` (P1 timekeeper
realist / P2 math auditor / P3 monotonicity auditor / P4 fence
keeper / P5 honesty auditor / P6 test keeper; C1–C8 answered;
D1–D4 preserved — D1 refuse-on-regression overruled (a clock
must answer; the clamp answers and the counter testifies),
D2 re-init allowed overruled (two epochs in one boot is two
clocks wearing one name), D3 __int128 converter overruled
(an assumption the freestanding build does not own), D4
round-to-nearest overruled (would overstate elapsed time)).

**Drafted (new files only):**
- `modules/kido-time.h` — interface + honesty laws (conversion
  law, source law, hz law, monotonicity law, init law, elapsed
  law, stats law) + proof status + futures. The Gate binding is
  named, not taken: { kido_timer_now, kido_timer_hz }.
- `modules/kido-time.c` — the leaf: pure converter
  (ns = (ticks/hz)*1e9 + (ticks%hz)*1e9/hz, both overflow
  guards, out untouched on refusal); init (source failure
  propagates unchanged, failed init leaves state untouched,
  hz == 0 -> NO_TIMER); now_ns (monotonic clamp +
  regression count; failed reads count nothing, move
  nothing); now_us (truncation); elapsed_ns (future
  stamp refuses, the read still counts); stats (reads +
  regressions only; last_ns deliberately unexposed).
  The source is an injected ops table — the ipi
  precedent, and the concrete reason is timer's own
  harness: its hosted setters live behind
  KIDO_TIMER_SELFTEST, which also defines timer's
  main, so linking timer.c into this test would
  collide mains. The scripted source lives in the
  test TU only.
- `architecture/module-map.md` — kido-time row added (DRAFT).

**Key decisions + why:**
1. Injected source, not direct timer coupling (C1): the
   main-collision fact above, plus timer's own futures
   naming a virtual-timer driver — hard-wiring one
   counter would foreclose it.
2. hz == 0 split by layer (C2): EARLY_ENV in the
   converter (argument error), NO_TIMER at init
   (missing time base, the timer's own code).
3. Clamp + count on regression (C3): refusing a clock
   read breaks callers at the moment they most need
   time; trusting bets monotonicity on one
   architecture's guarantee surviving every future
   binding. The clamp preserves ordering, the counter
   preserves honesty.
4. Init-once (C4): a second init would need an epoch
   policy, and resetting the floor would let the clock
   jump backwards through its own clamp.
5. Elapsed refuses a future stamp (C5): with a
   monotonic clock, since > now is a caller bug or a
   foreign timestamp, and the unsigned wrap complement
   would be a lie dressed as a duration.
6. Truncation, never rounding up (C6): the timer
   arm_us precedent refuses a sub-tick request rather
   than rounding it into existence; same law here.

**One real check during testing:** the stats expectation
had to be derived, not guessed — reads = 6 now_ns + 2
now_us + 2 elapsed = 10, regressions = 1 — and the run
pinned exactly that (the overflow-fail and NULL-guard
reads correctly count nothing). The module was right;
the count was verified, not assumed.

**Test results (all real, hosted, gcc 13.3.0, -Wall -Wextra
-Werror, zero warnings everywhere):**
- kido-time self-test: 38/38, 0 failures — pure converter
  incl. both overflow guards (sec-cap refusal at hz = 1,
  sum-crossing refusal at hz = 4 / ticks = 73786976295
  vs boundary-fit at 73786976292 = 18446744073000000000
  exactly), truncation (hz = 3, 1 tick -> 333,333,333),
  init guards (NULL table/slots, failing source, hz = 0
  -> NO_TIMER, failed init leaves state usable, second
  init refuses), live-source sequence (0 -> 1e9 ->
  1000001008 ns, backwards step clamped, conversion
  overflow leaves floor untouched, us truncation,
  elapsed ok + future refusal), stats 10 reads / 1
  regression.
- Plain hosted `-c`: PASS. Non-hosted `-fsyntax-only` on
  the x86 host correctly REFUSES (the arch-discipline
  error, working as designed, the mpidr/cache/topo
  precedent).
- Collision check: zero `kido_time` references outside
  the two new files.
- Neighbor regressions (tree untouched, verified not
  assumed): topo 52/52, cache 74/74, mpidr 37/37, sync
  49/49, ipi 54/54.

**Honest limits (stated, not hand-waved):** WRITTEN, NOT
ASSEMBLED, NEVER EXECUTED — toolchain absent a 24th time.
The leaf has no asm, so unlike sessions 33–35 there is no
ARM64 spelling awaiting disassembly — only the Gate
binding ({ kido_timer_now, kido_timer_hz }) plus a QEMU
virt run showing now_ns advancing at the real 62.5 MHz
CNTFRQ, which also needs the Gate timer-init wiring
before the proof means anything on silicon. The hosted
proof pins the conversion math and the clock discipline,
not delivery across silicon.

**Remains:** QEMU virt PSCI proof + QEMU virt -smp proof (both queued
on the toolchain; the -smp proof also waits on the Gate stub item);
Gate items — wire kido_vec_install into the boot path, wire GIC
enable(30) + timer arm into the scheduler tick, wire serial-irq init
into the boot path (after GIC init, before DAIF unmask), HAL wiring
(PL011 init, mailbox adoption), kido-mmu call-site wiring,
psci-init gating policy, secondary entry stub (contract in
kido-smp.h, session-33 D3 stands), first kido-sync consumer, first
kido-barrier consumer, first kido-ipi consumer, first kido-call
consumer, first kido-mpidr consumer, first kido-cache consumer, first
kido-topo consumer (smp arrival registration at the context_id slot,
or the primary's own registration at boot), first kido-time consumer
(the Gate timer binding); destroy bare-metal proof (design ready,
session 22); real BUBO peer + bare-metal transport (Phase 4); D1
KIDO_ERR_NO_TASKS header code (N8toriousAi's call); PENDING #1
cross-compile — re-opens on this tree change while the toolchain
stays intermittent (24th data point: absent). First boot is N8toriousAi's
to witness.
