starkernel: item 3.4 -- density ranking

Punch list §25 item 3.4 complete.

stadium_density(cell_index) reads a header's heat and mass and returns
heat / mass -- a division on demand from fields already stored in the
cell, matching §19.3's "read, not computed by a scheduler" literally.
Stays valid Q48.16 without a special fixed-point routine, since heat
is already Q48.16 and mass is a plain integer divisor.

mass == 0 and an out-of-range cell_index both return 0 rather than
dividing by zero -- an empty or never-admitted slot has no footprint
to be dense within.

Deliberately not built here, per the item's own wording: finding the
densest or least-dense resident (§19.3's admission/eviction
comparison) is item 3.5's scope, not this one's. Nothing calls
stadium_density() yet either.

Verified: three-architecture boot (amd64, aarch64, riscv64), all
reaching ok> with identical dict_hash=0x3d4e1daf289da94f matching the
item-3.3 baseline.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Robert Allan James
2026-08-04 17:16:46 -04:00
co-authored by Claude Sonnet 5
parent 378d688898
commit 0b47c256fc
10 changed files with 31369 additions and 2 deletions
+23 -1
View File
@@ -2773,7 +2773,29 @@ document and committing that amendment as its own item.*
> `dict_hash=0x3d4e1daf289da94f`, matching the item-3.2 baseline — amd64
> (`logs/20260804-170226`), aarch64 (`logs/20260804-170309`), riscv64
> (`logs/20260804-170407`).
- [ ] **3.4 — Density ranking.** Heat ÷ mass, read not computed. *Refs:* §19.2, §19.3.
- [x] **3.4 — Density ranking.** Heat ÷ mass, read not computed. *Refs:* §19.2, §19.3.
> **DONE 2026-08-04.** `stadium_density(cell_index)` (`stadium.c`) reads a header's `heat`
> and `mass` and returns `heat / mass` — a division on demand from fields already stored
> in the cell, matching §19.3's "read, not computed by a scheduler" literally: no
> background process maintains this value. Stays valid Q48.16 without any special
> fixed-point routine, since `heat` is already Q48.16 and `mass` is a plain integer
> divisor.
>
> `mass == 0` and an out-of-range `cell_index` both return 0 rather than dividing by zero
> — an empty or never-admitted slot (everything is zero-initialized by item 3.2's
> `stadium_boot_init()`, and nothing yet births a patron into the Stadium) has no
> footprint to be dense within.
>
> **Deliberately not built here, per the item's own wording:** finding the densest or
> least-dense resident (§19.3's admission/eviction comparison) is item 3.5's scope — this
> function supplies the per-cell value that comparison will read, not the ranking/min-max
> machinery itself. Nothing calls `stadium_density()` yet either.
>
> **Regression: clean.** All three architectures boot to `ok>` with identical
> `dict_hash=0x3d4e1daf289da94f`, matching the item-3.3 baseline — amd64
> (`logs/20260804-171332`), aarch64 (`logs/20260804-171414`), riscv64
> (`logs/20260804-171513`).
- [ ] **3.5 — Admission and eviction.** Admit if denser than the least dense resident.
*Refs:* §19.3.
- [ ] **3.6 — Hera as patron zero, pinned.** Assert at the eviction site; selecting Hera is