# Spec conformance — kido_sched_destroy (2026-10-21)

Additive teardown API on the fenced scheduler. Checked against
`imports/kido.json` (portable + adaptive from birth), the session-20
deliberation (`deliberations/2026-10-21-kido-sched-destroy-design.md`),
and the Gate-approved scheduler surface (init/create/yield/run
signatures and semantics must not move).

## kido.json conformance

- **Portable:** destroy is portable C11; the only arch-conditional code
  mirrors the existing ctx-type #if split (x[10]/fp/lr/sp vs opaque[13])
  and introduces no new arch facts. MET (hosted; cross-compile pending
  on this VM — see note below).
- **Adaptive:** destroy touches no HAL, board, or boot state; it is
  medium- and platform-agnostic by construction. MET.
- **Honest status:** refusal is loud, partial teardown is never
  misreported OK, and the allocator/carve-out split is documented in the
  header. MET.

## Deliberation conformance (P1–P5, C1–C6)

- P1 teardown inverse: MET — every scheduler-owned stack freed via
  kido_free, the first production caller of free (closes session-6 D1's
  queued item). No steady-state churn invented.
- P2 refusal law: MET — EARLY_ENV on (a) never-initialized, (b) already
  destroyed, (c) any READY or RUNNING task; refusal precedes any free,
  table and allocator provably untouched (self-test 50/51).
- P3 ownership: MET — allocator and image carve-out untouched; post-
  destroy stats show allocs == frees, allocated_bytes == 0, total_bytes
  still carved (self-test 52).
- P4 never-initialized: MET — sched_hal NULL on success; create goes
  loud until re-init; re-init keeps its existing law (self-test 53–55).
- P5 fence: MET — one new function; zero changes to existing signatures
  or semantics; no asm touched; no scheduler proof-chain invalidation.
- C1 live = READY|RUNNING: MET (DONE/EMPTY are teardown-eligible).
- C2 free-then-clear, fail-stop: MET — slot cleared only after a
  successful free; a failed free aborts with the allocator's status
  propagated and the slot kept. (Unreachable in practice for valid
  stacks; the path is honest, not exercised by a fabricated failure.)
- C3 allocator not reset: MET — deliberate split documented in the
  header (destroy = free what I own; init = rebuild the world).
- C4 sched_hal==NULL convention: MET — no new flag, existing guard
  reused.
- C5 idle ctx zeroed: MET — field-wise, no libc (bare-metal law).
- C6 self-test contract: MET — sections 50–59: refusal over READY,
  refusal over RUNNING (self-shape), happy path with allocator proof,
  create-loud-after, destroy-twice-loud, re-init round trip ending at
  rest. 35 new checks, all PASS.

## Gate-approved header

- No new status codes: refusal reuses KIDO_ERR_EARLY_ENV (the
  codebase's misuse code). D1's KIDO_ERR_NO_TASKS remains N8toriousAi's call.
  MET.

## Evidence

- Hosted: gcc 13.3.0, -std=c11 -Wall -Wextra -Werror, zero warnings.
  sched self-test: **110/110** (75 prior + 35 new). Full battery:
  mem PASS, alloc 31/31, resonate 136/136, interop 75/75, image 15/15,
  boot integration PASS. reloc self-test pending (rerun after tree
  settle — destroy does not touch reloc; run for completeness).
- Cross-compile (aarch64-linux-gnu-gcc, -ffreestanding): PENDING on this
  VM — the cross toolchain present in session 19 is absent here; apt
  install in progress at write time. The new code's only arch-sensitive
  lines are the ctx-zeroing #if branches, which mirror the file's
  existing split. Update: cross-compile and reloc rerun before closing
  this entry.
- QEMU: none owed — no asm, boot path, or relocation logic touched.

## Score

**16 MET / 0 PARTIAL / 0 DEFERRED / 2 PENDING (environmental).**

PENDING (not design debt — this VM lacks the session-19 toolchain):
1. aarch64 cross-compile of the touched TUs.
2. kido-reloc self-test rerun on the settled tree.
