FABRIC-3.8.md Stage B: kernel-side idle loop in the switch trampoline

sk_vm_switch_entry() stops being the Stage-2 placeholder bounce and becomes
every switch participant's own idle loop: it drains one of its own
kernel-Hermes messages per pass, on its own native stack (driven by the drain's
return value, so a non-consuming drain cannot spin), and when nothing is
drained it marks the VM parked_idle and yields back. It is entirely OS-driven,
with no VM-side yield word. sk_hermes_drain_checkpoint() gains a per-VM
hermes_draining guard so a payload's own in-word checkpoint cannot drain a
second message inside the first. Still inert in normal operation: nothing
marks work until Stage C.

Finding fixed here: amd64 sk_vm_switch_prime built the first-entry frame at
top-56, entering with rsp 16-aligned instead of the SysV-required 8 mod 16, so
the first aligned SSE spill in a callee took #GP (logs/20260923-142526, kept).
It had been latent since SXXVIII Stage 2 because the placeholder never called
anything. The frame is now at top-64 with a zeroed pad slot. aarch64 and
riscv64 were already correct.

Evidence: a temporary kernel_main probe (reverted, not in this commit) queued
two messages to Hestia, the first calling a colon word, and switched into her.
It passed on all three ISAs: 0 pending, parked_idle, depth 0, context saved on
her own stack, SB-SEQ=12 (drained one at a time, not nested), ledger and
stadium_conserved restored. Formal acceptance without the probe on all three
ISAs: dict_hash identical and unchanged, zero UNKNOWN WORD or faults, and the
live WIREBIND mint -> USE -> 1 2 + . -> 3 relay.

FABRIC-3.8.md also records Captain Bob's rulings that no VM-side word ever gives
up control and that multitasking is a compudynamic hybrid, and opens SS3.12
(VM frames for per-VM execution state).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Robert Allan James
2026-09-23 14:57:51 -04:00
co-authored by Claude Opus 5.5
parent 2aa338483a
commit 56da55aba9
20 changed files with 64228 additions and 5 deletions
+13
View File
@@ -677,6 +677,19 @@ typedef struct VM
* count across all VMs stops meaning "this VM is
* at its own outermost frame." 0 = not
* interpreting; 1 = outermost frame. */
int hermes_draining; /**< FABRIC-3.8.md §3.3 (Stage B): nonzero while
* sk_hermes_drain_checkpoint() is interpreting one
* of this VM's own messages. No drain site drains
* again while it is set -- a payload running at the
* VM's depth 1 would otherwise let its own in-word
* checkpoint drain a SECOND message inside the
* first one's execution. */
int parked_idle; /**< FABRIC-3.8.md §3.5 (Stage B): nonzero only while
* this VM is parked in its switch trampoline's idle
* branch -- nothing borrowed on its stack, no work
* in progress. Distinct from VM_STATE_SWITCHED_OUT,
* which is also true of a VM parked mid-work.
* Consumed by the kill path in Stage D. */
/** @} */
/** @name Stadium Identity (item 4.2, FABRIC-0.md §25.5)