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:
Claude
2026-11-19 11:57:42 +00:00
parent fdf9c1946c
commit b13d452e66
17 changed files with 975 additions and 59 deletions
+60
View File
@@ -0,0 +1,60 @@
Block 3984
\ ACL.4th -- word-level access control: the policy.
\ v3's capsules/ACL.4th, as FORTH source the node compiles.
\ The capsule supplies an entry's fields and the check
\ (acl.f18, compile.f18); what is strict, how long a TTL
\ lasts and what is pinned is decided here. Loading it
\ switches access control on: its last line runs ACL-BOOT.
\ A system that does not load it has none. init.4th loads
\ it after POST (MACHINE.md 1.1: the init turns on security).
\ The xt these words take is what FIND and ['] give.
FORTH DEFINITIONS
1 CONSTANT ACL-STRICT-MODE
0 CONSTANT ACL-TTL-MODE-VAL
\ the TTL of a cold word, tuned 2026-06-15 on v3
256 CONSTANT ACL-BASE-TTL
65535 CONSTANT ACL-MAX-TTL
-->
Block 3985
\ ( xt -- xt ) for symmetry: the xt is the entry
: ACL-ENTRY ;
: ACL-STRICT ( xt -- )
DUP ACL-PINNED? IF DROP EXIT THEN
ACL-STRICT-MODE SWAP ACL-MODE! ;
: ACL-TTL-MODE ( xt -- )
DUP ACL-PINNED? IF DROP EXIT THEN
ACL-TTL-MODE-VAL SWAP ACL-MODE! ;
\ ( xt -- ttl ) a hotter word earns a longer TTL:
\ heat/4 + 256, at most 65535
: ACL-TTL-COMPUTE
ACL-HEAT@ 4 / ACL-BASE-TTL + ACL-MAX-TTL MIN ;
-->
Block 3986
\ ( xt -- ) what the check runs when a word's TTL is 0.
\ STRICT: allow, and leave the TTL 0 so that every use
\ comes back here. TTL: compute a TTL from the word's
\ heat; allow.
: ACL-RECHECK
DUP ACL-PINNED? IF DROP EXIT THEN
DUP ACL-MODE@ ACL-STRICT-MODE = IF
1 OVER ACL-ALLOW! 0 OVER ACL-TTL! DROP EXIT
THEN
DUP ACL-TTL-COMPUTE OVER ACL-TTL! 1 SWAP ACL-ALLOW! ;
\ the system CA's public key; placeholders, as in v3
0 CONSTANT ACL-CA-KEY-LO
0 CONSTANT ACL-CA-KEY-HI
-->
Block 3987
\ ( req-hi req-lo -- allow? ) the fabric asks this word
\ whether a channel may be opened. The default approves
\ every request; a policy edits this.
: HERMES-CHANNEL-OPEN? 2DROP 1 ;
\ ( -- ) default fields on every word; the words that
\ enforce the policy pinned; the recheck switched on
: ACL-BOOT
ACL-INIT-PRIMITIVES
['] ACL-RECHECK ACL-PIN ['] ACL-INIT-PRIMITIVES ACL-PIN
['] ACL-RECHECK ACL-HOOK !
LOG-INFO" ACL: active" ;
' ACL-BOOT ACL-PIN
ACL-BOOT
+5
View File
@@ -38,6 +38,11 @@ Block 3966
: (LINES) ( baddr u -- ) CAPSULE-OPEN 0= IF (FAIL) THEN
BEGIN PAD CAPSULE-LINE DUP 0< 0= WHILE PAD SWAP (TELL) REPEAT
DROP ;
( a capsule of FORTH blocks into this node: its lowest LOADed )
: CAPSULE-INCLUDE ( baddr u -- )
CAPSULE-OPEN 0= IF -1 NODE-ERROR ! EXIT THEN
PAD CAPSULE-LINE 0< IF EXIT THEN
0 0 PAD 1- CONVERT DROP DROP LOAD ;
-->
Block 3967
( Who it is, where its printing goes, which of its ports )
+9
View File
@@ -0,0 +1,9 @@
Block 3980
( init.4th -- the system's init, run after POST and COLD. )
( MACHINE.md 1.1 and 3, step 5: everything after POST is )
( init.4th's. docs/v4.0.0/plans/2026-11-18-v4-init.md. )
( Step 2, security on: the ACL policy, ACL.4th. )
S" v4:ACL.4th" CAPSULE-INCLUDE
( Step 1, the search order: STARSHIPOS, then FORTH. Last, )
( since ACL.4th ends in FORTH DEFINITIONS. )
STARSHIPOS