v4 ACL: the countdown at call, as v3 -- the call hook may redirect
Build / Image PC (push) Successful in 6m13s
Build / Image MILKV (push) Successful in 6m40s
Build / v4 tests (32- and 64-bit cells) (push) Successful in 14m18s
Build / Image RASPI (push) Successful in 3m11s

Captain Bob ruled "As v3: add at call", "Engine: call redirects" and
"Build it".
- The engine's call hook returns where P goes.
- The kernel checks every call from code defined at run time. A TTL is
  counted down at the call. At a TTL of 0, or a denied word, the call is
  sent to (ACL-CALL), with the target on the data stack, which rechecks
  or refuses it by the word's own name, then goes on to it.
- A word being compiled is no longer checked, as in v3.

Two things were added while building, both from v3:
- (ACL-BUSY) turns the check off while the policy rechecks. Without it
  the recheck recursed.
- (ACL-CALL) does its own refusal and leaves WORD's buffer alone. A first
  version broke POST's CONVERT.digits.

Test first: test_mesh_boot's five new checks failed before; now 120 pass
and POST is 990/990. test_exec tests the redirect. test_host_quit's two
v4-only expectations now follow v3: a denied word compiles.

All 52 tests, test-32 and ASan/UBSan pass. An amd64 session passes 18/18.
Five alternating host boots: +1.4% median, inside the noise.
DECOMPOSITION.md 5.20 is updated, and the FPGA's call opcode is recorded
as owing the same redirect.

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 14:10:16 +00:00
parent 666cf39b8b
commit 7af88cc704
30 changed files with 1383 additions and 35 deletions
+14 -5
View File
@@ -892,11 +892,20 @@ is rechecked, otherwise the TTL is counted down; then a denied word is refused w
is in the variable `ACL-HOOK`; with none there, the word is allowed and given the longest TTL. `ACL.fth` puts
its `ACL-RECHECK` there (v3 finds it by name each time).
**Where this is weaker than v3.** v3's inner interpreter checks every execution, inside definitions too. v4
code is native: a compiled call goes straight to its word, and no opcode asks permission. So v4 checks a
word when it is *compiled* as well as when it is interpreted — a denied word cannot be built into anything
new — but a call compiled while the word was allowed is not checked again when it runs. Closing that needs
the check in the node itself (the `call` opcode), which is a hardware decision and is not taken here.
**Where this was weaker than v3, and is not now** (2026-11-19, Captain Bob: "As v3: add at call"; "Engine: call
redirects"; `docs/v4.0.0/plans/2026-11-19-acl-at-call.md`).
- **The old gap:** v3's inner interpreter checks every execution, inside definitions too. v4 checked a word
when it was compiled and when it was interpreted, and a compiled call was never checked again.
- **Now, at the call:** the engine's call hook may send a call elsewhere. The kernel checks every call from
code defined at run time. A word with TTL left is counted down at the call. At a TTL of 0, or for a denied
word, the call goes to `(ACL-CALL)` (`acl.f18`), which rechecks or refuses it by the word's name and goes on
to it.
- **No compile-time check:** a word being compiled is not checked, as in v3.
- **The policy runs unchecked:** while the policy rechecks a word, `(ACL-BUSY)` is 1 and nothing is checked,
as v3 runs its policy with the check off.
- **A node with no kernel has no check at call:** the hosted node is one. Its compiled calls are not checked.
- **On the FPGA,** the `call` opcode must offer its kernel the same redirect. That is to be designed with the
FPGA.
| Word | Fate | Notes |
| --- | --- | --- |
+45 -1
View File
@@ -4,7 +4,7 @@ Written 2026-11-19. Captain Bob ruled "As v3: add at call", then "Engine: call r
decision DECOMPOSITION.md §5.20 left open: "Closing that needs the check in the node itself (the `call`
opcode), which is a hardware decision and is not taken here."
**Nothing here is built.**
**Built 2026-11-19, ruled "Build it"; section 6 is as built.**
## 1. v3, and v4 today
@@ -81,3 +81,47 @@ Each is seen to fail before the change.
1. The design above, 2.1 to 2.4?
2. The FPGA: record the redirect as the call opcode's requirement, to be designed with the FPGA?
## 6. As built (2026-11-19)
**Two things changed from the design, both found while building.** Both are needed to match v3, so
neither is a new ruling:
1. **`(ACL-BUSY)`, a recursion guard.** The policy's `ACL-RECHECK` is code defined at run time. Its own
calls would be checked, and at a TTL of 0 they would recheck themselves without end. v3 runs its policy
with the check off (`emergency_console`). `(ACL-RECHECK)` now sets `(ACL-BUSY)` around the policy, and
the kernel checks nothing while it is set.
2. **`(ACL-CALL)` has its own check and refusal.** It prints the word's name from its entry, not from
`WORD`'s buffer. A first version copied the name into that buffer and broke POST's
`CONVERT.digits`, which reads that buffer after `WORD`.
**The target goes on the data stack** for `(ACL-CALL)`, so it needs no variable. Two map cells were added
from free memory:
- `(ACL-CALLX)`, at `BUF0_W - 113`: `(ACL-CALL)`'s address, stored by `end.f18`;
- `(ACL-BUSY)`, at `BUF0_W - 144`.
**What changed:**
- `exec.h` and `exec.c`: the hook returns where P goes.
- `mesh.c`: `acl_at_call()`, applied to calls from code; `INTERPRET`'s dispatch is left to `(ACL?)`.
- `compile.f18`: `INTERPRET`'s compile path no longer checks, and `(ACL-RECHECK)` sets `(ACL-BUSY)`.
- `acl.f18`: `(ACL-CALL)`.
- `end.f18`, `host_map.h`, `mkmap.c`, `image.h`: the two cells.
**Test first** (`logs/20261119-acl-at-call/`):
- `test_mesh_boot`, with the policy on. Five checks failed before:
- a call from a definition is counted down;
- a denied word called from a definition is refused by its own name, and does not run;
- a denied word compiles;
- it is refused when the definition runs.
The sixth, that a word at the prompt is counted once, passed before and after.
- `test_exec`: a hook that returns another address redirects the call, which returns to the caller.
- `test_host_quit`'s two v4-only expectations changed to v3's: a denied word compiles. That host node has
no kernel, so its compiled calls are not checked there.
**Verified:**
- `test_mesh_boot` passes 120 checks, with POST 990/990.
- All 52 tests at 64 bits, test-32, and ASan/UBSan pass.
- The amd64 kernel builds, and one amd64 session passes 18/18.
- **The cost** (`timing.txt`, five alternating host mesh boots): median 15.227 s old against 15.439 s new,
+1.4%. That is inside the old runs' own spread, 15.06 to 15.99 s, so no measurable cost.