v4 init.4th, steps 1 and 2: the ACL policy loaded after POST, then the search order
Captain Bob ruled "ACL at boot", loaded "From init.4th", the include "Compose[d] in FORTH". - capsules/v4/init.4th, at block 3980: S" v4:ACL.4th" CAPSULE-INCLUDE, then STARSHIPOS. - capsules/v4/ACL.4th is the policy, git mv'ed from v4/capsule/ACL.fth and reflowed into chained 64x16 blocks, its text unchanged. - CAPSULE-INCLUDE in centre.4th places a capsule and LOADs its lowest block. It is composed from CAPSULE-OPEN and CAPSULE-LINE, with no new C word. - The mesh loads v4:init.4th after POST and COLD, its one fixed step there. Test first in test_mesh_boot: the parity line, DOE without naming STARSHIPOS, and ACL-BOOT pinned. The before-run failed. After: 113 checks pass and POST is 990/990. All 52 tests, test-32 and ASan/UBSan pass. The dictionary has 405 words. One amd64 session passes 18/18 with "ACL: active". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
@@ -482,6 +482,9 @@ static int load_source(const char *name)
|
||||
while (fgets(line, sizeof line, f)) {
|
||||
size_t len = strlen(line);
|
||||
num++;
|
||||
/* a capsule's blocks, typed at the prompt in order: its headers are not FORTH, and `-->`, which chains
|
||||
* to the next block when the kernel LOADs it, is an error at the terminal */
|
||||
if (strncmp(line, "Block ", 6) == 0 || strcmp(line, "-->\n") == 0) continue;
|
||||
if (len == 0 || line[len - 1] != '\n' || len > 80) { printf(" %s line %u: too long\n", name, num); fclose(f); return 0; }
|
||||
(void)say(line);
|
||||
/* every line is accepted: whatever it printed, it ended with " ok" and never with ERROR */
|
||||
@@ -1632,9 +1635,9 @@ int main(void)
|
||||
CHECK(is(say("SEE NOSUCH\n"), "SEE: not found\n ok\nok> ") && is(say("SEE\n"), "SEE: not found\n ok\nok> "), "a word that is not there");
|
||||
CHECK(is(say("(.\")\n"), "(.\"): compile-only\n ERROR\nok> ") && is(say("(S\")\n"), "(S\"): compile-only\n ERROR\nok> "), "the string run-time words have names but cannot be run from the prompt");
|
||||
|
||||
/* ---- access control with its policy loaded: ACL.fth, FORTH source ---- */
|
||||
/* ---- access control with its policy loaded: capsules/v4/ACL.4th, FORTH source ---- */
|
||||
boot_bare();
|
||||
CHECK(load_source("ACL.fth"), "ACL.fth compiles, every line of it");
|
||||
CHECK(load_source("../../capsules/v4/ACL.4th"), "ACL.4th compiles, every line of it");
|
||||
CHECK(strstr(out, "\033[32mINFO: \033[0mACL: active\n") == out && n.mem[ACL_HOOK] != 0, "and its last line switches access control on");
|
||||
CHECK(is(say(": FOO 65 EMIT ; FOO ' FOO ACL-TTL@ . FOO ' FOO ACL-TTL@ .\n"), "A256 A255 ok\nok> "), "a word's first use is rechecked and earns it a TTL, which is then counted down");
|
||||
CHECK(is(say(": SFOO 66 EMIT ; ' SFOO ACL-STRICT SFOO SFOO ' SFOO ACL-TTL@ .\n"), "BB0 ok\nok> ") && is(say("' SFOO ACL-MODE@ .\n"), "1 ok\nok> "),
|
||||
|
||||
@@ -131,6 +131,7 @@ int main(void)
|
||||
CHECK(strstr(said, "PARITY:V4_CAPSULE name=v4:forth79.4th ") && strstr(said, "PARITY:V4_CAPSULE name=v4:centre.4th ")
|
||||
&& strstr(said, "PARITY:V4_CAPSULE name=v4:hera.4th "), "FORTH-79 and the kernel's capsules, each with its parity line");
|
||||
CHECK(strstr(said, "PARITY:V4_CAPSULE name=v4:starshipos.4th ") != 0, "starshipos.4th, with its parity line");
|
||||
CHECK(strstr(said, "PARITY:V4_CAPSULE name=v4:init.4th ") != 0, "init.4th, after POST and COLD, with its parity line (MACHINE.md 3, step 5)");
|
||||
{ /* every case, the kernel's too: Hera has its words (#189 Phase 7) */
|
||||
char want[64];
|
||||
const unsigned runs = v4_post_runs(v4_post_cases, v4_post_case_count, 1);
|
||||
@@ -145,6 +146,12 @@ int main(void)
|
||||
CHECK(how == V4_TEXT_COMPLETED && strcmp(r, "7 ") == 0, "a line to Hera: \"%s\" (%d)", r, how);
|
||||
/* the capsules were placed in RAM, block n at n - R, and loaded from there (capsule blocks plan, step 4):
|
||||
* forth79.4th's lowest block, 3948, is RAM block 1900 */
|
||||
/* init.4th (docs/v4.0.0/plans/2026-11-18-v4-init.md, steps 1 and 2): security on, then the search order --
|
||||
* checked first, before any line below changes the system (the COLD further down takes it all away) */
|
||||
r = line(V4_MESH_HERA, "S\" ok\" DOE", &how);
|
||||
CHECK(how == V4_TEXT_COMPLETED && strcmp(r, "ok") == 0, "init.4th set the search order: DOE is found without naming STARSHIPOS: \"%s\" (%d)", r, how);
|
||||
r = line(V4_MESH_HERA, "' ACL-BOOT ACL-PINNED? . ' ACL-RECHECK ACL-PINNED? .", &how);
|
||||
CHECK(how == V4_TEXT_COMPLETED && strcmp(r, "-1 -1 ") == 0, "init.4th turned security on: the ACL policy is loaded, its words pinned: \"%s\" (%d)", r, how);
|
||||
r = line(V4_MESH_HERA, "1900 BLOCK 16 TYPE", &how);
|
||||
CHECK(how == V4_TEXT_COMPLETED && strncmp(r, "( forth79.4th --", 16) == 0, "forth79.4th's lowest block is in RAM block 1900: \"%.20s\" (%d)", r, how);
|
||||
/* starshipos.4th, a system capsule loaded before POST (MACHINE.md 3, step 3; ruled 2026-11-18) */
|
||||
|
||||
Reference in New Issue
Block a user