Files
LithosAnanke/kernel/include/starkernel/vm/stadium_ops.h
T
Claude 046ce0be65 feat(v4): the mesh boot to spec -- Hera born empty in the kernel's fabric; births, kills, every node stepping together (#189)
ENGINE step 4 Phase 1, Tasks 5b-5d, and the edge cases (Captain Bob, 2026-11-13: "Build it to proper
spec"; "Check for the edge cases"; "Yes, add it to v4-checks").

- v4/system/mesh.c, v4/include/v4/mesh.h: the nucleus assembled by the ROM and given to Hera as F18
  cells; Hera born empty at place 0, the kernel on port 0, the console on port 1; told she is 10, in the
  registry, the kernel's words, FORTH-79, sealed, POST, the kernel's capsules. NODE-BORN / NODE-KILL in
  the owner's room.
- No scheduler: v4_mesh_tell returns once the node told says how its text ended, and
  v4_mesh_step / v4_mesh_busy let the host step the fabric while it waits, so nodes run between
  lines as during them. A text left "waiting" is owed its end: the next line ends it "Interrupted"
  and is then run (MESH.md 7b.6).
- kernel: sk_v4.c boots through the mesh; its idle steps the fabric while a node can run, and halts
  only when none can (#151 kept). stadium_return_quota and stadium_ops_forget on a kill.
- Tests: v4/tests/test_mesh_boot.c (32 checks: the boot, births, kills, rebirth, a live number, a
  fault, no such node, Hera not killing herself, no room, a line too long, a node running for ever,
  a wait broken by the next line), run by `make -C v4 test` and under ASan+UBSan by `sanitize`
  (v4-checks); kernel/tests quota return; scripts/qemu_session.py births() and the edges on bare
  metal.
- Docs: ENGINE.md 6 "who runs next" struck (settled: no scheduler); the Phase 1 plan; FABRIC-3
  XLVIII.23; .claude/memory/rules.md: alpha.5 closed to new work.
- Evidence: v4-checks 80 programs under the sanitizers, 0 failures; the hosted builds alike; two
  stopped v4-checks runs labelled STOPPED; three development amd64 boots labelled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
2026-11-13 17:00:08 +00:00

53 lines
2.6 KiB
C

/* SPDX-License-Identifier: LicenseRef-Starship-1.0
* Copyright (c) 2023-2026 Robert A. James
*/
/* stadium_ops.h -- a v4 node's opcodes as Stadium patrons (#189; plan
* 2026-11-13-engine-step4-phase1, Task 3).
*
* Captain Bob, 2026-11-12: "Add HEAT-OP. If it's a huge performance hit, we'll revert it" -- "Both":
* the registers (v4/include/v4/node.h) and the Stadium feed; 2026-11-13: "Per heartbeat tick".
* docs/v4.0.0/V3-PARITY.md 1c's reading -- "a VM's word patrons become its 32 opcode patrons" -- held
* since 1h left the opcodes unwired "for now"; this wires them, beside the word patrons, not instead.
*
* A node's 32 opcodes are patrons of its quota, behaviour COOL, each made resident on its first
* retirement as a word is on its first dispatch (stadium_words.c). At a charge, an opcode's
* retirements since the last charge are charged as that many of the word layer's dispatches -- the
* same quantum (STADIUM_WORD_HEAT_QUANTUM), the same floor left in the reservoir (a third); when
* they want more than there is, what there is is shared in proportion to the retirements, not taken
* by whichever opcode is charged first -- and a resident one first cools by the ticks since, as a
* word does
* (STADIUM_WORD_COOL_RATE_Q48). The kernel charges at its heartbeat's service points (sk_v4.c):
* where the node's host waits, and after each line. Conservation is the Stadium's: what is pulled is
* the node's own share.
*/
#ifndef STARKERNEL_VM_STADIUM_OPS_H
#define STARKERNEL_VM_STADIUM_OPS_H
#ifdef __STARKERNEL__
#include <stdint.h>
#include "starkernel/vm_uuid.h"
#define STADIUM_OPS_COUNT 32u /* the F18 opcodes, 0 .. 31 */
#define STADIUM_OPS_IDENTITY 0x4F50000000000000ULL /* "OP" in a patron's identity, | the opcode */
/* The per-quota tables; after stadium_boot_init_for(). Not re-entrant. */
void stadium_ops_init(void);
/* Charge the node `vm_id`'s opcodes: `counts` are its 32 running retirement counts (v4_heat.op),
* `tick` the heartbeat's count now. Nothing for a key with no quota. */
void stadium_ops_charge(VMUuid vm_id, const uint64_t counts[STADIUM_OPS_COUNT], uint64_t tick);
/* A node is gone: its opcode counts are forgotten, so a node that later has its quota's slot starts
* from none (#189). Before stadium_return_quota(), while the key still has its slot. */
void stadium_ops_forget(VMUuid vm_id);
/* An opcode patron's heat now (Q48.16), or 0: not resident, or no quota. */
uint64_t stadium_ops_heat(VMUuid vm_id, unsigned op);
/* "Stadium opcodes: N resident, hottest opcode K" -- one line, at most 63 characters. */
void stadium_ops_print_boot_diagnostics(VMUuid vm_id);
#endif /* __STARKERNEL__ */
#endif