feat(v4): word accounts at call -- the word ID in the header, the kernel's records, the Stadium charged per tick (#189)
ENGINE step 4 Phase 2 (plan docs/v4.0.0/plans/2026-11-13-engine-step4-phase2-word-accounts.md). Rulings, Captain Bob 2026-11-13: "ID field in the header"; "Per heartbeat tick"; the ACL "All of it in Phase 4". - The word ID, at xt-4 before the flags (ENGINE.md 3b). The system's words are numbered as they are assembled, by a new directive, #id, (and #ids, the count), in the C assembler (text.c) and in the machine ROM's (capsules/v4/rom), which counts in the system's own (NEXT-ID). (HEADER) numbers later words; FORGET gives back the IDs it frees, always the newest; COLD resets to (BOOT-ID); (SEAL) records it. All 313 system headers carry the cell. - The kernel's records (v4/mesh.h): (TELL-DEFINED) and (TELL-FORGOTTEN), requests -19/-20 on port 0, which the kernel puts in (WORD-DEFINED)/(WORD-FORGOTTEN) when it seals a node, and reads the system's own words once. A bit per address marks a word's xt (calls into the ROM or headerless code are not words); at call, the bit test and a count. v4_mesh_charge hands the owner the calls since. - The Stadium: stadium_words_charge -- N calls as N of stadium_word_dispatch's dispatches, shared by calls when the reservoir is short; sk_v4.c charges every node's words at the tick beside its opcodes, and stadium_word_forget before an ID is used again. - Tests first: test_text.c, test_host_dict.c, test_host_quit.c (numbering, FORGET, COLD), test_mesh_boot.c (44 checks), kernel/tests/test_stadium_words.c; qemu_session.py: Hera's words admitted after POST. - amd64: Stadium words: promotions=141 after POST, CONSERVED; POST 539/539; word_count=377; dict_hash 0xa854ba15b437d288 (the new cell); the boot 142 s against Phase 1's 153 s. - v4 test, test-32: all pass; v4-checks: 80 programs under the sanitizers, 0 failures; the hosted builds alike. docs/reference/v4-dictionary.tsv: the two new words; FABRIC-3 XLVIII.24. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
+16
-1
@@ -70,6 +70,7 @@ static int is_reserved(const char *s)
|
||||
|| strcmp(s, "FOR") == 0 || strcmp(s, "NEXT") == 0 || strcmp(s, "UNEXT") == 0
|
||||
|| strcmp(s, "header") == 0 || strcmp(s, "constant") == 0
|
||||
|| strcmp(s, "#,") == 0 || strcmp(s, "\",") == 0 || strcmp(s, "set") == 0 || strcmp(s, "here") == 0
|
||||
|| strcmp(s, "#id,") == 0 || strcmp(s, "#ids") == 0
|
||||
|| strcmp(s, "store") == 0 || strcmp(s, "start") == 0 || flag_of(s) != 0;
|
||||
}
|
||||
|
||||
@@ -197,7 +198,7 @@ static void lay_name(v4_text *t, const char *name)
|
||||
* out, in front of the word the next `:` starts:
|
||||
* the name: its count byte, then its characters, four bytes to a cell,
|
||||
* zero-padded to a whole cell
|
||||
* flags, the name's word address, the link to the entry before
|
||||
* its word ID (the next, #189 Phase 2), flags, the name's word address, the link to the entry before
|
||||
* and the code follows. */
|
||||
static void header(v4_text *t, reader *r)
|
||||
{
|
||||
@@ -213,6 +214,7 @@ static void header(v4_text *t, reader *r)
|
||||
end_word(t);
|
||||
nfa = v4_asm_label(&t->as);
|
||||
lay_name(t, name);
|
||||
put_cell(t, t->next_id++);
|
||||
put_cell(t, 0);
|
||||
put_cell(t, nfa);
|
||||
put_cell(t, t->latest);
|
||||
@@ -378,6 +380,7 @@ static int value_of(v4_text *t, const char *tok, v4_cell *out)
|
||||
const v4_text_symbol *s;
|
||||
int big;
|
||||
if (strcmp(tok, "here") == 0) { *out = v4_asm_label(&t->as); return 1; }
|
||||
if (strcmp(tok, "#ids") == 0) { *out = t->next_id; return 1; } /* how many word IDs so far */
|
||||
if (number_of(tok, out, &big)) {
|
||||
if (big) { fail(t, "number does not fit a cell", tok); return 0; }
|
||||
return 1;
|
||||
@@ -423,6 +426,15 @@ static void cell_directive(v4_text *t, reader *r)
|
||||
check_asm(t, "#,");
|
||||
}
|
||||
|
||||
/* `#id,`: the next word ID, as a cell of data; the count goes on (#189, Phase 2). */
|
||||
static void id_directive(v4_text *t, reader *r)
|
||||
{
|
||||
if (r->depth != 1) { fail(t, "not allowed in a macro", "#id,"); return; }
|
||||
(void)v4_asm_label(&t->as);
|
||||
put_cell(t, t->next_id++);
|
||||
check_asm(t, "#id,");
|
||||
}
|
||||
|
||||
/* `", TOKEN`: TOKEN, whatever its characters, as a counted string. */
|
||||
static void string_directive(v4_text *t, reader *r)
|
||||
{
|
||||
@@ -505,6 +517,8 @@ static void one_token(v4_text *t, reader *r, const char *tok)
|
||||
if (strcmp(tok, "macro") == 0) { define_macro(t, r); return; }
|
||||
if (strcmp(tok, "constant") == 0) { constant_directive(t, r); return; }
|
||||
if (strcmp(tok, "#,") == 0) { cell_directive(t, r); return; }
|
||||
if (strcmp(tok, "#id,") == 0) { id_directive(t, r); return; }
|
||||
if (strcmp(tok, "#ids") == 0) { fail(t, "#ids is only a value", NULL); return; }
|
||||
if (strcmp(tok, "\",") == 0) { string_directive(t, r); return; }
|
||||
if (strcmp(tok, "set") == 0) { set_directive(t, r); return; }
|
||||
if (strcmp(tok, "store") == 0) { store_directive(t, r); return; }
|
||||
@@ -630,6 +644,7 @@ void v4_text_begin(v4_text *t, v4_node *n, v4_cell origin)
|
||||
t->latest = 0;
|
||||
t->start = -1;
|
||||
t->header_pending = 0;
|
||||
t->next_id = 0;
|
||||
}
|
||||
|
||||
void v4_text_constant(v4_text *t, const char *name, v4_cell value)
|
||||
|
||||
Reference in New Issue
Block a user