feat(kernel): v4 boots in the kernel's boot -- the Stadium, its checks, the opcode patrons

#189, ENGINE step 4, Phase 1 (plan 2026-11-13-engine-step4-phase1), Tasks
1-4. Captain Bob, 2026-11-13: Q1 "A new node key", Q2 "Per heartbeat
tick", Q3 "All of v3's", Q4 "In Phase 1" / "Full births now", who runs
next "Hera by compudynamics now" (Task 5, to come).

- stadium.c/.h: stadium_node_key(node) ("NODE" | number),
  stadium_boot_init_for(first), stadium_birth_node(key, name);
  stadium_boot_init() and stadium_birth_hera() are them for Hera's key, so
  v3's path is as it was (only an impossible panic's words changed).
- kernel_main.c: the system is chosen and said first, then the Stadium,
  sessions, switch-signal and kernel-Hermes tables for both systems in
  v3's order; v4: Hera, node 10, patron zero under her node key, the word,
  block and opcode layers. The quota self-test and the heartbeat's line
  are functions now, called by both systems.
- sk_v4.c/.h: sk_v4_run() goes -- sk_v4_boot() returns, the kernel's
  checks after POST (opcodes, words, conservation, quota, heartbeat), then
  sk_v4_prompt(). sk_v4_charge_opcodes() at the heartbeat's service points
  (the key wait, after each line) and once after POST.
- stadium_ops.c/.h: a node's 32 opcodes as Stadium patrons (HEAT-OP's
  feed, "Both"): retirements charged as the word layer's dispatches, a
  quantum each, the reservoir's floor kept, shared by retirements when
  short; cooling per tick as words. ~0.5 us a charge on the host: kept.
- qemu_session.py: a v4 acceptance boot fails without "Stadium: N cells",
  "Stadium conservation: CONSERVED" and the heartbeat's ticks (#189).

Tests first (logs/20261113-122142): the physics check failed on the v4
boot; test_stadium_node, test_stadium_ops (and its share case, after a
real boot showed ";" taking all the heat) failed before. Now: kernel host
tests all pass; amd64 v4 boot passes, POST 539/539, dict_hash unchanged,
"Stadium opcodes: 30 resident, hottest opcode 8", CONSERVED; a system=v3
boot prints its Stadium lines as on 2026-11-06.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
Claude
2026-11-13 12:50:02 +00:00
parent 3f4988e19e
commit b1cac339c1
35 changed files with 959 additions and 85 deletions
+2
View File
@@ -0,0 +1,2 @@
# Phase 1 (#189), Task 1 Step 1 / Task 4 Step 1: the physics check (scripts/qemu_session.py physics())
# on today's v4 boot, before the Stadium is made on it: the three physics lines FAIL; POST and the prompt pass.
@@ -0,0 +1,136 @@
LOG: logs/20261113-122142/amd64/qemu-amd64-20261113-122142.log
PASS: POST: PASSED
PASS: Boot disk: not a StarshipOS stick (an ISO or ESP boot)
PASS: Zuse: genesis minted onto attached thumbdrive (a fresh data stick)
FAIL: the Stadium: its cells allocated
--- serial log, the log's last 40 lines (logs/20261113-122142/amd64/qemu-amd64-20261113-122142.log):
125 | V4: capsule v4:sys:forth.f18 signature: missing (unsigned)
126 | PARITY:V4_F18 name=v4:sys:forth.f18 capsule_hash=0x16cab4a1268b85da
127 | V4: capsule v4:sys:numout.f18 signature: missing (unsigned)
128 | PARITY:V4_F18 name=v4:sys:numout.f18 capsule_hash=0x85a240ad3fb2b299
129 | V4: capsule v4:sys:words.f18 signature: missing (unsigned)
130 | PARITY:V4_F18 name=v4:sys:words.f18 capsule_hash=0xb1d381f927d9f14e
131 | V4: capsule v4:sys:system.f18 signature: missing (unsigned)
132 | PARITY:V4_F18 name=v4:sys:system.f18 capsule_hash=0x61c6532daa58b47d
133 | V4: capsule v4:sys:qmath.f18 signature: missing (unsigned)
134 | PARITY:V4_F18 name=v4:sys:qmath.f18 capsule_hash=0xdb4140713dd857f3
135 | V4: capsule v4:sys:blocks.f18 signature: missing (unsigned)
136 | PARITY:V4_F18 name=v4:sys:blocks.f18 capsule_hash=0x76307ef48678dc2a
137 | V4: capsule v4:sys:log.f18 signature: missing (unsigned)
138 | PARITY:V4_F18 name=v4:sys:log.f18 capsule_hash=0xfc6540e6b824a52b
139 | V4: capsule v4:sys:acl.f18 signature: missing (unsigned)
140 | PARITY:V4_F18 name=v4:sys:acl.f18 capsule_hash=0x6845aa048db7eb22
141 | V4: capsule v4:sys:end.f18 signature: missing (unsigned)
142 | PARITY:V4_F18 name=v4:sys:end.f18 capsule_hash=0x5ef01312c07b79cc
143 | PARITY:V4_ROM words=2372 rom_hash=0x87b23d3ae2643c8d instructions=59537530
144 | V4: capsule v4:forth79.4th signature: missing (unsigned)
145 | PARITY:V4_CAPSULE name=v4:forth79.4th capsule_id=0x4055641ee17d176b capsule_hash=0x4055641ee17d176b dict_hash=0x7d5965f7983485b9
146 | PARITY:V4_POST tests=539 pass=539 fail=0
147 | PARITY:V4_SYSTEM word_count=320 dict_hash=0x47570d4ced6ce255
148 | PARITY:OK
149 | POST: PASSED
150 | PCI: init...
151 | PCI: ECAM mapped (amd64)
152 | virtio-rng: no device on PCI bus 0
153 | rng: backend = rdrand
154 | entropy: ready
155 | virtio-input: no device on PCI bus 0
156 | Starting heartbeat...
157 | APIC Timer: started (LVT=0x00020020 ICR=9924004)
158 |
159 | I/O APIC: keyboard IRQ1 unmasked
160 | Heartbeat running.
161 | blkio_usb: MSC device ready
162 | Artemis: the stick's partition attached
163 | \x1b[38;2;255;165;0m[Hera]\x1b[39m Zuse: genesis minted onto attached thumbdrive
164 | \x1b[38;2;255;165;0m[zuse@Hera]\x1b[39m \x1b[38;2;85;255;255mok> \x1b[39m
---
FAIL: the Stadium: conservation CONSERVED
--- serial log, the log's last 40 lines (logs/20261113-122142/amd64/qemu-amd64-20261113-122142.log):
125 | V4: capsule v4:sys:forth.f18 signature: missing (unsigned)
126 | PARITY:V4_F18 name=v4:sys:forth.f18 capsule_hash=0x16cab4a1268b85da
127 | V4: capsule v4:sys:numout.f18 signature: missing (unsigned)
128 | PARITY:V4_F18 name=v4:sys:numout.f18 capsule_hash=0x85a240ad3fb2b299
129 | V4: capsule v4:sys:words.f18 signature: missing (unsigned)
130 | PARITY:V4_F18 name=v4:sys:words.f18 capsule_hash=0xb1d381f927d9f14e
131 | V4: capsule v4:sys:system.f18 signature: missing (unsigned)
132 | PARITY:V4_F18 name=v4:sys:system.f18 capsule_hash=0x61c6532daa58b47d
133 | V4: capsule v4:sys:qmath.f18 signature: missing (unsigned)
134 | PARITY:V4_F18 name=v4:sys:qmath.f18 capsule_hash=0xdb4140713dd857f3
135 | V4: capsule v4:sys:blocks.f18 signature: missing (unsigned)
136 | PARITY:V4_F18 name=v4:sys:blocks.f18 capsule_hash=0x76307ef48678dc2a
137 | V4: capsule v4:sys:log.f18 signature: missing (unsigned)
138 | PARITY:V4_F18 name=v4:sys:log.f18 capsule_hash=0xfc6540e6b824a52b
139 | V4: capsule v4:sys:acl.f18 signature: missing (unsigned)
140 | PARITY:V4_F18 name=v4:sys:acl.f18 capsule_hash=0x6845aa048db7eb22
141 | V4: capsule v4:sys:end.f18 signature: missing (unsigned)
142 | PARITY:V4_F18 name=v4:sys:end.f18 capsule_hash=0x5ef01312c07b79cc
143 | PARITY:V4_ROM words=2372 rom_hash=0x87b23d3ae2643c8d instructions=59537530
144 | V4: capsule v4:forth79.4th signature: missing (unsigned)
145 | PARITY:V4_CAPSULE name=v4:forth79.4th capsule_id=0x4055641ee17d176b capsule_hash=0x4055641ee17d176b dict_hash=0x7d5965f7983485b9
146 | PARITY:V4_POST tests=539 pass=539 fail=0
147 | PARITY:V4_SYSTEM word_count=320 dict_hash=0x47570d4ced6ce255
148 | PARITY:OK
149 | POST: PASSED
150 | PCI: init...
151 | PCI: ECAM mapped (amd64)
152 | virtio-rng: no device on PCI bus 0
153 | rng: backend = rdrand
154 | entropy: ready
155 | virtio-input: no device on PCI bus 0
156 | Starting heartbeat...
157 | APIC Timer: started (LVT=0x00020020 ICR=9924004)
158 |
159 | I/O APIC: keyboard IRQ1 unmasked
160 | Heartbeat running.
161 | blkio_usb: MSC device ready
162 | Artemis: the stick's partition attached
163 | \x1b[38;2;255;165;0m[Hera]\x1b[39m Zuse: genesis minted onto attached thumbdrive
164 | \x1b[38;2;255;165;0m[zuse@Hera]\x1b[39m \x1b[38;2;85;255;255mok> \x1b[39m
---
FAIL: the heartbeat: ticking
--- serial log, the log's last 40 lines (logs/20261113-122142/amd64/qemu-amd64-20261113-122142.log):
125 | V4: capsule v4:sys:forth.f18 signature: missing (unsigned)
126 | PARITY:V4_F18 name=v4:sys:forth.f18 capsule_hash=0x16cab4a1268b85da
127 | V4: capsule v4:sys:numout.f18 signature: missing (unsigned)
128 | PARITY:V4_F18 name=v4:sys:numout.f18 capsule_hash=0x85a240ad3fb2b299
129 | V4: capsule v4:sys:words.f18 signature: missing (unsigned)
130 | PARITY:V4_F18 name=v4:sys:words.f18 capsule_hash=0xb1d381f927d9f14e
131 | V4: capsule v4:sys:system.f18 signature: missing (unsigned)
132 | PARITY:V4_F18 name=v4:sys:system.f18 capsule_hash=0x61c6532daa58b47d
133 | V4: capsule v4:sys:qmath.f18 signature: missing (unsigned)
134 | PARITY:V4_F18 name=v4:sys:qmath.f18 capsule_hash=0xdb4140713dd857f3
135 | V4: capsule v4:sys:blocks.f18 signature: missing (unsigned)
136 | PARITY:V4_F18 name=v4:sys:blocks.f18 capsule_hash=0x76307ef48678dc2a
137 | V4: capsule v4:sys:log.f18 signature: missing (unsigned)
138 | PARITY:V4_F18 name=v4:sys:log.f18 capsule_hash=0xfc6540e6b824a52b
139 | V4: capsule v4:sys:acl.f18 signature: missing (unsigned)
140 | PARITY:V4_F18 name=v4:sys:acl.f18 capsule_hash=0x6845aa048db7eb22
141 | V4: capsule v4:sys:end.f18 signature: missing (unsigned)
142 | PARITY:V4_F18 name=v4:sys:end.f18 capsule_hash=0x5ef01312c07b79cc
143 | PARITY:V4_ROM words=2372 rom_hash=0x87b23d3ae2643c8d instructions=59537530
144 | V4: capsule v4:forth79.4th signature: missing (unsigned)
145 | PARITY:V4_CAPSULE name=v4:forth79.4th capsule_id=0x4055641ee17d176b capsule_hash=0x4055641ee17d176b dict_hash=0x7d5965f7983485b9
146 | PARITY:V4_POST tests=539 pass=539 fail=0
147 | PARITY:V4_SYSTEM word_count=320 dict_hash=0x47570d4ced6ce255
148 | PARITY:OK
149 | POST: PASSED
150 | PCI: init...
151 | PCI: ECAM mapped (amd64)
152 | virtio-rng: no device on PCI bus 0
153 | rng: backend = rdrand
154 | entropy: ready
155 | virtio-input: no device on PCI bus 0
156 | Starting heartbeat...
157 | APIC Timer: started (LVT=0x00020020 ICR=9924004)
158 |
159 | I/O APIC: keyboard IRQ1 unmasked
160 | Heartbeat running.
161 | blkio_usb: MSC device ready
162 | Artemis: the stick's partition attached
163 | \x1b[38;2;255;165;0m[Hera]\x1b[39m Zuse: genesis minted onto attached thumbdrive
164 | \x1b[38;2;255;165;0m[zuse@Hera]\x1b[39m \x1b[38;2;85;255;255mok> \x1b[39m
---
PASS: [zuse@Hera] ok>
PASS: 7 ok, and a prompt
RESULT: FAIL
Binary file not shown.
+7
View File
@@ -0,0 +1,7 @@
# #189 Phase 1 (plan 2026-11-13-engine-step4-phase1), Tasks 1-4, 2026-11-13
../amd64/physics-check-before.txt: the acceptance physics check (qemu_session.py physics()) on the v4 boot before: the three lines FAIL.
test_stadium_node-before.log: the node-key test before stadium_node_key/_boot_init_for/_birth_node existed: does not compile.
test_stadium_ops-before.log: the opcode-patron test before stadium_ops.c: no source to build.
test_stadium_ops-share-before.log: the share test against the first stadium_ops.c, which charged opcodes in order: ; took all 43691, the next 0 -- seen on a real boot as '1 resident, hottest opcode 0'.
bench_ops.txt (bench_ops.c): the charge on the host, every opcode retiring: about 0.5 us a charge; conservation held. Not the 'huge performance hit': it stands (Captain Bob, 2026-11-12).
The v3 path: logs/20261113-124843 (system=v3, v3_keys) prints its Stadium lines in the order of logs/20261106-192739.
+26
View File
@@ -0,0 +1,26 @@
#include "starkernel/vm/stadium.h"
#include "starkernel/vm/stadium_ops.h"
#include "starkernel/session.h"
#include "starkernel/kmalloc.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
void *kmalloc(size_t size) { return calloc(1, size); }
void kfree(void *ptr) { free(ptr); }
kmalloc_stats_t kmalloc_get_stats(void) { kmalloc_stats_t s; memset(&s, 0, sizeof s); s.free_bytes = 512u*1024u*1024u; return s; }
void log_message(int level, const char *fmt, ...) { (void)level; (void)fmt; }
void sk_hal_panic(const char *m) { printf("PANIC %s\n", m); exit(2); }
int blk_flush(uint32_t b) { (void)b; return 0; }
int main(void) {
VMUuid key = stadium_node_key(10); uint64_t c[32]; unsigned k; long i, n = 1000000;
struct timespec a, b;
stadium_boot_init_for(key); session_boot_init(); stadium_birth_node(key, "Hera"); stadium_ops_init();
memset(c, 0, sizeof c);
clock_gettime(CLOCK_MONOTONIC, &a);
for (i = 1; i <= n; i++) { for (k = 0; k < 32; k++) c[k] += 1000 + k; stadium_ops_charge(key, c, (uint64_t)i); }
clock_gettime(CLOCK_MONOTONIC, &b);
printf("%ld charges, every opcode retiring: %.1f ns a charge; conserved=%d\n", n,
((b.tv_sec - a.tv_sec) * 1e9 + (b.tv_nsec - a.tv_nsec)) / n, stadium_conserved(key));
return 0;
}
@@ -0,0 +1,3 @@
1000000 charges, every opcode retiring: 553.5 ns a charge; conserved=1
1000000 charges, every opcode retiring: 465.8 ns a charge; conserved=1
1000000 charges, every opcode retiring: 526.8 ns a charge; conserved=1
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.