safety commit
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
* served, as the kernel does when the node writes its number to port 0. */
|
||||
#include "v4/fabric.h"
|
||||
#include "v4/manage.h"
|
||||
#include "v4/message.h"
|
||||
#include "v4/wire.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -18,6 +20,7 @@ static int used[NODES];
|
||||
static v4_place places[NODES];
|
||||
static v4_fabric f;
|
||||
static v4_manage_entry reg[NODES];
|
||||
static v4_wire_queue queues[32];
|
||||
static unsigned gone_count, parity_count;
|
||||
static v4_cell parity_number;
|
||||
static v4_manage m;
|
||||
@@ -75,6 +78,7 @@ int main(void)
|
||||
|
||||
printf("v4 manage tests: V4_CELL_BITS=%d\n", V4_CELL_BITS);
|
||||
v4_fabric_init(&f, places, NODES);
|
||||
v4_fabric_queues(&f, queues, 32);
|
||||
memset(&m, 0, sizeof m);
|
||||
m.f = &f; m.reg = reg; m.reg_cap = NODES; m.born = born; m.gone = gone;
|
||||
m.open = open_; m.cell = cell_; m.line = line_; m.parity = parity_;
|
||||
@@ -163,6 +167,36 @@ int main(void)
|
||||
}
|
||||
CHECK(place_of(h, 12) == -1 && place_of(h, 10) == (v4_cell)h, "NODE-PLACE of a number not live is -1");
|
||||
|
||||
/* ---- THE KERNEL TELLS A NODE'S GOING (MESH.md 9a, ruled 2026-10-16 after the final review of step 7) ----
|
||||
* When Hera kills a node, the kernel puts a GONE on the wire of every live node from its parent, as if its
|
||||
* parent had sent it -- so that the node believes it, its parent being its centre -- and no node hands one
|
||||
* on. Here: Hera (10) births 20 and 40; 20 births 21, wired 20:3 -- 21:2; 40 is killed. */
|
||||
{
|
||||
v4_cell p20, p21, p40;
|
||||
v4_cell hd[V4_WIRE_HEADER];
|
||||
const v4_wire_queue *q;
|
||||
p20 = birth(h, 20); p40 = birth(h, 40);
|
||||
p21 = birth((unsigned)p20, 21);
|
||||
push(h, (v4_cell)h); push(h, 6); push(h, p20); push(h, 6);
|
||||
CHECK(p20 >= 0 && p21 >= 0 && p40 >= 0 && v4_manage_serve(&m, h, V4_REQ_NODE_WIRE) == 1 && pop(h) == -1, "Hera's port 6 is wired to node 20's");
|
||||
push((unsigned)p20, p20); push((unsigned)p20, 3); push((unsigned)p20, p21); push((unsigned)p20, 2);
|
||||
CHECK(v4_manage_serve(&m, (unsigned)p20, V4_REQ_NODE_WIRE) == 1 && pop((unsigned)p20) == -1, "node 20's port 3 is wired to node 21's port 2");
|
||||
push(h, 40);
|
||||
CHECK(v4_manage_serve(&m, h, V4_REQ_NODE_KILL) == 1 && place_of(h, 40) == -1, "Hera kills 40");
|
||||
q = places[p21].wire[2].rx;
|
||||
CHECK(q && q->used == V4_WIRE_HEADER + 1u && q->arrived, "a message has come to node 21 on the wire from its parent: %u cells", q ? q->used : 0u);
|
||||
if (q && q->used) {
|
||||
v4_wire_queue copy = *q;
|
||||
v4_wire_first(©);
|
||||
CHECK(v4_wire_look(©, hd) == V4_WIRE_DONE && hd[0] == 21 && hd[1] == 20 && hd[2] == V4_MSG_GONE && hd[6] == 4
|
||||
&& copy.cell[(copy.head + V4_WIRE_HEADER) % V4_WIRE_CELLS] == 40,
|
||||
"a GONE about 40, to 21, from its parent 20: %ld %ld %ld len %ld", (long)hd[0], (long)hd[1], (long)hd[2], (long)hd[6]);
|
||||
}
|
||||
q = places[p20].wire[6].rx;
|
||||
CHECK(q && q->used == V4_WIRE_HEADER + 1u, "and one to node 20, from Hera, on the wire from her: %u cells", q ? q->used : 0u);
|
||||
CHECK(places[h].wire[6].rx == 0 || places[h].wire[6].rx->used == 0, "Hera is sent none: she has no parent, and kills");
|
||||
}
|
||||
|
||||
printf(" %d checks, %d failures\n", checks, failures);
|
||||
return failures != 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user