starkernel: item 3.3 -- behaviour enumeration and dispatch
Punch list §25 item 3.3 complete. StadiumBehaviour (stadium.h) enumerates exactly the four tags §18.3 already names -- MIGRATE, DELIVER, EXPIRE, COOL -- mapped from §17.1's patron table: blocks->MIGRATE, messages->DELIVER, ACLs->EXPIRE, words and VMs both->COOL. Nothing invented; the tag set and mapping were already in the document. stadium_dispatch(cell_index, behaviour) dispatches on the tag only, never asks what kind of patron departed. Handlers are stubs -- the real actions belong to subsystems not yet migrated onto the Stadium (Phase 4). Nothing calls stadium_dispatch() yet; item 3.5 is its first consumer. The switch is exhaustive with no default case, making §13's "closed enumeration, fixed at build time" a compiler-enforced property under this project's -Wall -Werror rather than just prose. Verified live: temporarily deleted the COOL case, rebuild failed with error: enumeration value 'STADIUM_BEHAVIOUR_COOL' not handled in switch [-Werror=switch], restored it, confirmed clean again. The header's behaviour field stays uint8_t, not the enum type itself, since C does not guarantee an enum's underlying type and that field's offset is load-bearing for item 3.1's validated 64-byte layout. Verified: three-architecture boot (amd64, aarch64, riscv64), all reaching ok> with identical dict_hash=0x3d4e1daf289da94f matching the item-3.2 baseline. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
eb0fd4fffa
commit
378d688898
@@ -63,7 +63,11 @@ typedef struct {
|
||||
* enforcement of that bound is item 3.5's scope, not this one's. */
|
||||
uint16_t mass; /* offset 28 -- cells this patron occupies (§19.2) */
|
||||
uint8_t flags; /* offset 30 -- bit 0 = pin; remaining bits reserved */
|
||||
uint8_t behaviour; /* offset 31 -- code field, closed enumeration (§18.3) */
|
||||
uint8_t behaviour; /* offset 31 -- code field. Valid values are StadiumBehaviour (§18.3)
|
||||
* tags cast to uint8_t -- kept as uint8_t rather than the enum type
|
||||
* itself since C does not guarantee an enum's underlying type, and
|
||||
* this field's offset is load-bearing for the 64-byte layout item
|
||||
* 3.1 validated. */
|
||||
uint8_t payload[32]; /* offset 32 -- inline payload, used when mass == 1 */
|
||||
} StadiumPatronHeader;
|
||||
|
||||
@@ -138,6 +142,42 @@ StadiumCell *stadium_cells(void);
|
||||
*/
|
||||
uint8_t *stadium_header_bitmap(void);
|
||||
|
||||
/*
|
||||
* StadiumBehaviour - the closed code-field enumeration (FABRIC.md §13, §18.3).
|
||||
* The engine dispatches on this tag and never asks a patron what kind it is
|
||||
* -- §3's entire point. Two patrons may share a tag: a VM's tag is COOL, the
|
||||
* same tag a word carries (§18.3). Mapped from §17.1's patron table:
|
||||
*
|
||||
* MIGRATE -- blocks: reap event is migration back to Artemis (§17.2)
|
||||
* DELIVER -- messages: reap event is delivery
|
||||
* EXPIRE -- ACLs: reap event is TTL expiry
|
||||
* COOL -- words and VMs: reap event is cooling off the floor
|
||||
*
|
||||
* Closed and fixed at build time -- see stadium_dispatch()'s exhaustive
|
||||
* switch for how the compiler enforces that.
|
||||
*/
|
||||
typedef enum {
|
||||
STADIUM_BEHAVIOUR_MIGRATE = 0,
|
||||
STADIUM_BEHAVIOUR_DELIVER,
|
||||
STADIUM_BEHAVIOUR_EXPIRE,
|
||||
STADIUM_BEHAVIOUR_COOL
|
||||
} StadiumBehaviour;
|
||||
|
||||
/*
|
||||
* stadium_dispatch - Calls the behaviour handler for a patron's code field.
|
||||
* The engine calls this at reap and never asks what kind of patron departed
|
||||
* (§3, §18.3) -- only cell_index and behaviour cross this boundary.
|
||||
*
|
||||
* Handlers are stubs today: the real migrate-to-Artemis / deliver / expire /
|
||||
* cool actions belong to their own subsystems, which have not been migrated
|
||||
* onto the Stadium yet (Phase 4, §25.5). Nothing calls stadium_dispatch()
|
||||
* yet either -- that begins with item 3.5 (admission and eviction).
|
||||
*
|
||||
* @param cell_index Index into the Stadium of the patron header dispatching.
|
||||
* @param behaviour Which of the closed tag set to invoke.
|
||||
*/
|
||||
void stadium_dispatch(size_t cell_index, StadiumBehaviour behaviour);
|
||||
|
||||
#endif /* __STARKERNEL__ */
|
||||
|
||||
#endif /* STARKERNEL_VM_STADIUM_H */
|
||||
Reference in New Issue
Block a user