v4 ACL: the countdown at call, as v3 -- the call hook may redirect
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:
+26
-3
@@ -695,7 +695,28 @@ static void heartbeat_cycle(unsigned place, v4_mesh_physics *p)
|
||||
/* at `call` (exec.h), on a word -- any other target, nothing -- in v3's order (physics_pre_execute,
|
||||
* V3-PARITY.md 2.1; Captain Bob, 2026-11-13: "Every call, as v3"): decay by the ticks since, heat +1,
|
||||
* the count the Stadium is charged by, the temperature, the rolling window */
|
||||
static void on_call(void *ctx, v4_node *n, v4_cell target)
|
||||
/* The ACL's check at a call from code defined at run time (docs/v4.0.0/plans/2026-11-19-acl-at-call.md), as v3's
|
||||
* inner interpreter: the word's flags cell (compile.f18: bit 5 denied, bits 16 .. 31 the TTL). An allowed word
|
||||
* with TTL left is counted down here, and the call goes on; at a TTL of 0, or a denied word, the call is sent to
|
||||
* (ACL-CALL), the target on the data stack, which rechecks or refuses it in FORTH and goes on to the word. While
|
||||
* the policy rechecks a word ((ACL-BUSY) 1) nothing is checked, as v3 runs its policy with the check off. */
|
||||
static v4_cell acl_at_call(v4_node *n, const v4_image *im, v4_cell target)
|
||||
{
|
||||
v4_cell flags, to;
|
||||
if (im->acl_call <= 0 || im->acl_busy <= 0 || n->mem[im->acl_busy] != 0) return target;
|
||||
to = n->mem[im->acl_call];
|
||||
if (to <= 0 || to >= (v4_cell)V4_NODE_WORDS || target < 4) return target;
|
||||
flags = n->mem[target - 3];
|
||||
if ((flags & (v4_cell)0xFFFF0000) != 0 && (flags & 32) == 0) {
|
||||
n->mem[target - 3] = flags - (v4_cell)0x10000; /* one use fewer */
|
||||
return target;
|
||||
}
|
||||
if (n->ds.depth >= V4_DATA_RING + 2u) return target; /* no room for the target: as no check */
|
||||
v4_dstack_push(&n->ds, target);
|
||||
return to;
|
||||
}
|
||||
|
||||
static v4_cell on_call(void *ctx, v4_node *n, v4_cell target)
|
||||
{
|
||||
unsigned place = place_of_device(ctx);
|
||||
v4_cell id, ret = n->p; /* P is still the return address (exec.h) */
|
||||
@@ -706,9 +727,9 @@ static void on_call(void *ctx, v4_node *n, v4_cell target)
|
||||
* system's own calls among its words (v3's are C) */
|
||||
from_code = (ret >= im->dict_lo && ret < im->dict_hi) || ret == im->exec + 1;
|
||||
dispatched = ret == im->runx + 1;
|
||||
if ((!from_code && !dispatched) || !is_word(place, target)) return;
|
||||
if ((!from_code && !dispatched) || !is_word(place, target)) return target;
|
||||
id = n->mem[target - 4];
|
||||
if (id < 0 || id >= (v4_cell)V4_MESH_WORD_IDS) return;
|
||||
if (id < 0 || id >= (v4_cell)V4_MESH_WORD_IDS) return target;
|
||||
a = &accounts_of(place)[id];
|
||||
if (the->physics) {
|
||||
v4_mesh_physics *p = &the->physics[place];
|
||||
@@ -731,6 +752,8 @@ static void on_call(void *ctx, v4_node *n, v4_cell target)
|
||||
}
|
||||
a->calls++;
|
||||
a->since++;
|
||||
/* INTERPRET's own dispatch is checked by (ACL?) before it is made: only calls from code are checked here */
|
||||
return from_code ? acl_at_call(n, im, target) : target;
|
||||
}
|
||||
|
||||
void v4_mesh_set_tick(v4_mesh *ms, uint64_t tick)
|
||||
|
||||
Reference in New Issue
Block a user