feat(v4): Phase 7 -- the tick counted as v3's: tokens taken, and words run from code defined at run time (#189)

Captain Bob, 2026-11-14: "v3" ... "we can always change it late". v3 counts an execution per token its
(C) interpreter takes and per word its definitions run. Measured on 8 lines, counting every call on v4 gave
~700 to v3's one for typed lines (the F18 interpreter's own calls) but 1:1 in compiled code, so no single
HEARTBEAT_CHECK_FREQUENCY could match v3. Now INTERPRET counts its tokens in (TOKENS) -- one F18 store, the
map gains the cell -- and the kernel adds them at each call; a call counts, and gets physics, only from
dictionary space or as INTERPRET's or EXECUTE's dispatch (the image gains their addresses). The knob stays
at v3's 256. test_inference.c out of the per-width tests (its own rule). Tests first: test_mesh_boot.c 90,
99 on, 87 without opcode physics; v4 test all pass. amd64 PASS, 181 s, dict_hash 0x5c53b2e18343a9b6.
Not pushed (held to the end of Phase 7).

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-14 01:22:35 +00:00
parent 28ffed8f57
commit 855632b3c0
14 changed files with 88 additions and 16 deletions
@@ -178,6 +178,15 @@ Phase 4).
double (qmath.f18: low cell, then high). `HEAT!` starts the word's decay from now (a word never
touched would otherwise decay at once by every tick since its definition). Test first, v3's POST
cases with v4's address units (`test_mesh_boot.c`: 86 checks; 95 on; 83 without opcode physics).
- [x] **The tick, counted as v3's** (Captain Bob, 2026-11-14: "v3"; "we can always change it late"). v3 counts
one execution per token its interpreter takes and one per word its definitions run; its interpreter is
C. v4's is F18, and counting every call made ~700 counts to v3's one on a typed line (measured on 8
lines) but 1:1 in compiled code, so no single HEARTBEAT_CHECK_FREQUENCY could match (the knob ruling,
withdrawn on that measurement). Now: `INTERPRET` counts its tokens in `(TOKENS)` (one F18 store); the
kernel adds them in at each call, and counts a call -- and gives it physics -- only when it comes from
code defined at run time (dictionary space), or is INTERPRET's or EXECUTE's dispatch; the system's own
calls among its words, none. `3 4 + .` counts 4, as v3. Test first (90 checks; 99 on; 87 without
opcode physics). amd64 PASS: promotions=136 (fewer: the interpreter's own calls are no longer words run).
- [ ] The entropy and top-words words (`starforth_words_test.c`): `ENTROPY!` `ENTROPY@` `RESET-ENTROPY`
`TOP-WORDS` `WORD-ENTROPY`.
### Task 5: the StarForth words (Phase 3's: `init.4th`, `starforth.4th`), and their POST