mesh/merge-gate head c7c7268db08c merged into trunk d3ef6fa44caf — pass: the change touches no module of the mesh's graph (run 2)
mesh/repo-check head c7c7268db08c merged into trunk d3ef6fa44caf — pass: its merge-check.sh passed, each part in its toolchain: merge-check.sh (typescript)…
mesh/delivery delivered
The bed runs the installer from bare twice: first with a catalogue missing the nats module, so it stops at the broker step by name and the bed reads the bus there; then with the whole catalogue, through the step. It passes only when exactly one bus container runs, it is mesh-broker-nats on the module's image, every stream that held something before the step is still the same stream, and the mesh still hears from the first node. A first run that never reaches the step skips with the reason; a second run that stops at the step fails. The judgement is a pure function, test/integration/bus-kept.ts, held by unit tests without a lab.
77 lines
4.1 KiB
TypeScript
77 lines
4.1 KiB
TypeScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import { busNotKept, runningFrom, streamsFrom, written, type Seen } from "./integration/bus-kept.ts";
|
|
|
|
/**
|
|
* The judgement of the bed that raises genesis past its broker step (novox/hq ADR 0333 §5, issue 590):
|
|
* exactly one bus container, it is mesh-broker-nats, a stream written before the step is still there, and
|
|
* the first node is still connected. Held here without a lab, so the bed's verdict is the judgement's and
|
|
* not whatever a bed happened to compare.
|
|
*/
|
|
|
|
const UPSTREAM = "nats@sha256:" + "b".repeat(64);
|
|
const MODULES = "192.0.2.10:5000/nats@sha256:" + "c".repeat(64);
|
|
const PORTS = "127.0.0.1:8222->8222/tcp, 0.0.0.0:5671->4222/tcp";
|
|
|
|
function jsz(streams: Array<[string, string, number, number]>): string {
|
|
return JSON.stringify({ account_details: [{ name: "MESH", stream_detail: streams.map(([name, created, messages, last]) =>
|
|
({ name, created, state: { messages, last_seq: last } })) }] });
|
|
}
|
|
|
|
const before: Seen = {
|
|
running: runningFrom(`mesh-store\tpostgres@sha256:aa\t0.0.0.0:5432->5432/tcp\nmesh-broker-nats\t${UPSTREAM}\t${PORTS}\n` +
|
|
"mesh-controller\t192.0.2.10:5000/mesh-controller@sha256:dd\t\n"),
|
|
streams: streamsFrom(jsz([["KV_mesh-controller_lease", "2026-10-13T00:10:00Z", 3, 7], ["EMPTY", "2026-10-13T00:10:01Z", 0, 0]])),
|
|
};
|
|
|
|
const kept: Seen = {
|
|
running: runningFrom(`mesh-store\tpostgres@sha256:aa\t0.0.0.0:5432->5432/tcp\nmesh-broker-nats\t${MODULES}\t${PORTS}\n` +
|
|
"mesh-controller\t192.0.2.10:5000/mesh-controller@sha256:dd\t\n"),
|
|
streams: streamsFrom(jsz([["KV_mesh-controller_lease", "2026-10-13T00:10:00Z", 3, 9]])),
|
|
};
|
|
|
|
const SAID = "broker — the foundation's bus, adopted as the nats module\n restarting mesh-broker-nats — once, onto the nats module's image";
|
|
const HERE = "anchor here last 3s ago";
|
|
|
|
test("a bus adopted in place is kept: one bus, the module's image, its streams, the node connected", () => {
|
|
assert.deepEqual(busNotKept(before, kept, HERE, SAID), []);
|
|
});
|
|
|
|
test("only a stream holding something counts as written before the step", () => {
|
|
assert.deepEqual(written(before).map((s) => s.name), ["KV_mesh-controller_lease"]);
|
|
});
|
|
|
|
test("a second bus beside the first is not kept: the fault genesis had before ADR 0333", () => {
|
|
const two: Seen = { ...kept, running: [...kept.running,
|
|
{ name: "mesh-broker", image: UPSTREAM, ports: "0.0.0.0:5671->4222/tcp" }] };
|
|
const wrong = busNotKept(before, two, HERE, SAID);
|
|
assert.equal(wrong.length, 1);
|
|
assert.match(wrong[0] as string, /2 bus containers.*mesh-broker \(/);
|
|
});
|
|
|
|
test("a bus under another name, or none, is not kept", () => {
|
|
const renamed: Seen = { ...kept, running: kept.running.map((r) => r.name === "mesh-broker-nats" ? { ...r, name: "nats-server" } : r) };
|
|
assert.ok(busNotKept(before, renamed, HERE, SAID).some((w) => /mesh-broker-nats does not run/.test(w)));
|
|
const none: Seen = { ...kept, running: kept.running.filter((r) => r.name !== "mesh-broker-nats") };
|
|
assert.ok(busNotKept(before, none, HERE, SAID).some((w) => /0 bus containers/.test(w)));
|
|
});
|
|
|
|
test("a bus still on the bundle's image was not adopted", () => {
|
|
const same: Seen = { ...kept, running: before.running };
|
|
assert.ok(busNotKept(before, same, HERE, SAID).some((w) => /still runs .* the image the bundle raised/.test(w)));
|
|
assert.ok(busNotKept(before, kept, HERE, "broker — adopted").some((w) => /did not say the bus restarts/.test(w)));
|
|
});
|
|
|
|
test("a stream gone or made again is not kept", () => {
|
|
const gone: Seen = { ...kept, streams: [] };
|
|
assert.ok(busNotKept(before, gone, HERE, SAID).some((w) => /KV_mesh-controller_lease .* is gone/.test(w)));
|
|
const again: Seen = { ...kept, streams: streamsFrom(jsz([["KV_mesh-controller_lease", "2026-10-13T00:40:00Z", 1, 1]])) };
|
|
assert.ok(busNotKept(before, again, HERE, SAID).some((w) => /was made again/.test(w)));
|
|
});
|
|
|
|
test("a node the mesh has not heard from since the step is not connected", () => {
|
|
assert.ok(busNotKept(before, kept, "anchor out of touch 4m", SAID).some((w) => /has not heard from the first node/.test(w)));
|
|
assert.ok(busNotKept(before, kept, "", SAID).some((w) => /no record/.test(w)));
|
|
});
|