Rename mesh-control -> mesh-controller, substrate -> foundation
One name per thing, per the HQ glossary: the module/container/image/binary/repo becomes mesh-controller, the seat the-controller, and the store+broker pair the foundation (embedded base bundles, default template and example lock renamed with their go:embed directives). No behaviour change — a pure vocabulary rename. Claude-Session: https://claude.ai/code/session_01D6qtiYU3P9jk3pnAXyAFyx
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* The usage context store, proved end to end (novox/hq ADR 0054).
|
||||
*
|
||||
* model-usage is a MODULE, not a control-plane feature, because mesh-control is a CLI and cannot
|
||||
* model-usage is a MODULE, not a control-plane feature, because mesh-controller is a CLI and cannot
|
||||
* consume events: the store that keeps the latest usage reading has to be something that subscribes
|
||||
* to `module.*.usage.*` and upserts. This bed raises a real mesh, provisions model-usage its own
|
||||
* postgres store, emits usage events into the mesh, and reads the store back to prove the three
|
||||
@@ -14,15 +14,15 @@
|
||||
* 3. IN THE CLEAR — the value and its raw payload are ordinary columns an ordinary select returns;
|
||||
* nothing about usage is sealed.
|
||||
*
|
||||
* The topology mirrors two-node-db: the app-postgres provider and the mesh's own substrate store both
|
||||
* want host port 5432, so the substrate (store, broker, control) owns `anchor` and NOTHING else, and
|
||||
* The topology mirrors two-node-db: the app-postgres provider and the mesh's own foundation store both
|
||||
* want host port 5432, so the foundation (store, broker, control) owns `anchor` and NOTHING else, and
|
||||
* `laptop` runs the postgres PROVIDER and the model-usage CONSUMER co-located. Only enrolment crosses
|
||||
* to anchor, over the underlay both machines share.
|
||||
*
|
||||
* It needs a host binary and the substrate bundle:
|
||||
* It needs a host binary and the foundation bundle:
|
||||
*
|
||||
* MESH_LAB_HOST_BINARY=.../mesh-host
|
||||
* MESH_LAB_BUNDLE=.../examples/substrate-first-node.lock
|
||||
* MESH_LAB_BUNDLE=.../examples/foundation-first-node.lock
|
||||
*
|
||||
* HELPER — stock the two runtimes into the local daemon before the run (some may already be there):
|
||||
* scripts/build-module-runtime.sh postgres /tmp/postgres.tar
|
||||
@@ -38,7 +38,7 @@ import { loadScenario } from "../../src/declaration/parse.ts";
|
||||
import { raise } from "../../src/lifecycle/raise.ts";
|
||||
import { destroy, exec } from "../../src/lifecycle/operate.ts";
|
||||
import { hostBinaryPath, HOST_PATH } from "../../src/lifecycle/place.ts";
|
||||
import { labIsUsable, destroyAll, substrateBundle, onTheMachine } from "./harness.ts";
|
||||
import { labIsUsable, destroyAll, foundationBundle, onTheMachine } from "./harness.ts";
|
||||
import type { HeldImage } from "../../src/pinning.ts";
|
||||
|
||||
const capability = await labIsUsable();
|
||||
@@ -50,12 +50,12 @@ const skip = !capability.usable
|
||||
: !binary || !existsSync(binary)
|
||||
? "MESH_LAB_HOST_BINARY is not set to a built mesh-host"
|
||||
: !bundle || !existsSync(bundle)
|
||||
? "MESH_LAB_BUNDLE is not set to a substrate bundle (mesh-host examples/)"
|
||||
? "MESH_LAB_BUNDLE is not set to a foundation bundle (mesh-host examples/)"
|
||||
: false;
|
||||
|
||||
const SCENARIO = "model-usage-bed";
|
||||
/** The node that carries the postgres provider and the model-usage consumer. anchor carries only the
|
||||
* substrate. */
|
||||
* foundation. */
|
||||
const NODE = "laptop";
|
||||
|
||||
let instanceId = "";
|
||||
@@ -83,7 +83,7 @@ async function must(machine: string, command: string, timeoutMs?: number): Promi
|
||||
|
||||
/** The control plane, a container on the first node. */
|
||||
async function mesh(command: string, timeoutMs?: number): Promise<string> {
|
||||
return must("anchor", `docker exec mesh-control /mesh-control ${command}`, timeoutMs);
|
||||
return must("anchor", `docker exec mesh-controller /mesh-controller ${command}`, timeoutMs);
|
||||
}
|
||||
|
||||
/** The reference a manifest should carry, once this scenario has been raised. */
|
||||
@@ -92,9 +92,9 @@ function pinned(reference: string): string {
|
||||
return onTheMachine(reference, held);
|
||||
}
|
||||
|
||||
/** The substrate bundle: ours by the ID the machine holds, everything else upstream. */
|
||||
/** The foundation bundle: ours by the ID the machine holds, everything else upstream. */
|
||||
function bundleFor(images: HeldImage[]): string {
|
||||
return substrateBundle(bundle, images);
|
||||
return foundationBundle(bundle, images);
|
||||
}
|
||||
|
||||
function tokenFrom(said: string): string {
|
||||
@@ -120,7 +120,7 @@ async function settled(node: string, withinMs = 1_200_000): Promise<void> {
|
||||
} | undefined;
|
||||
let said = "";
|
||||
try {
|
||||
const asked = await on("anchor", `docker exec mesh-control /mesh-control status --json`);
|
||||
const asked = await on("anchor", `docker exec mesh-controller /mesh-controller status --json`);
|
||||
said = asked.out;
|
||||
if (asked.ok) state = JSON.parse(said);
|
||||
} catch (err) {
|
||||
@@ -160,11 +160,11 @@ before(async () => {
|
||||
instanceId = raised.instanceId;
|
||||
held = raised.images;
|
||||
|
||||
await must("anchor", `cat > /tmp/substrate.lock <<'MESHBUNDLE'\n${bundleFor(raised.images)}\nMESHBUNDLE`);
|
||||
await must("anchor", `${HOST_PATH} apply /tmp/substrate.lock`, 600_000);
|
||||
await must("anchor", `cat > /tmp/foundation.lock <<'MESHBUNDLE'\n${bundleFor(raised.images)}\nMESHBUNDLE`);
|
||||
await must("anchor", `${HOST_PATH} apply /tmp/foundation.lock`, 600_000);
|
||||
const up = await must("anchor", `docker ps --format '{{.Names}}'`);
|
||||
for (const c of ["mesh-store", "mesh-broker", "mesh-control"]) {
|
||||
assert.match(up, new RegExp(c), `the substrate did not raise ${c}:\n${up}`);
|
||||
for (const c of ["mesh-store", "mesh-broker", "mesh-controller"]) {
|
||||
assert.match(up, new RegExp(c), `the foundation did not raise ${c}:\n${up}`);
|
||||
}
|
||||
|
||||
for (const [machine, node] of [["anchor", "anchor"], ["laptop", "laptop"]] as const) {
|
||||
@@ -269,7 +269,7 @@ test("usage events are upserted into model-usage's store — latest-per-key, bot
|
||||
});
|
||||
|
||||
async function addIssueAssign(name: string, manifest: string): Promise<void> {
|
||||
await must("anchor", `printf %s ${quote(manifest)} > /tmp/${name}.json && docker cp /tmp/${name}.json mesh-control:/${name}.json`);
|
||||
await must("anchor", `printf %s ${quote(manifest)} > /tmp/${name}.json && docker cp /tmp/${name}.json mesh-controller:/${name}.json`);
|
||||
await mesh(`module add /${name}.json`);
|
||||
await mesh(`module issue ${name} --node ${NODE}`);
|
||||
await mesh(`assign ${NODE} ${name}`);
|
||||
@@ -289,7 +289,7 @@ test("usage events are upserted into model-usage's store — latest-per-key, bot
|
||||
await mesh(`push ${NODE}`);
|
||||
await settled(NODE);
|
||||
|
||||
// The provider owns 5432 on laptop; the substrate store owns it on anchor.
|
||||
// The provider owns 5432 on laptop; the foundation store owns it on anchor.
|
||||
const onLaptop = await must(NODE, `docker ps --format '{{.Names}}'`);
|
||||
for (const name of ["postgres", "mesh-postgres", "mesh-model-usage"]) {
|
||||
assert.match(onLaptop, new RegExp(`(^|\\n)${name}(\\n|$)`),
|
||||
@@ -331,7 +331,7 @@ test("usage events are upserted into model-usage's store — latest-per-key, bot
|
||||
assert.match(tableReady, /^t$/m, `the usage table was never created (the consumer did not migrate):\n${tableReady}`);
|
||||
|
||||
// Inject a usage event into the mesh. model-usage is a PURE CONSUMER, so its own broker account has
|
||||
// no publish right (mesh-control grants write to mesh.events only to a module that declares `emits`).
|
||||
// no publish right (mesh-controller grants write to mesh.events only to a module that declares `emits`).
|
||||
// So publish from the postgres provider's container — a publisher already on the node — overriding
|
||||
// the source header to the real producer the key names, exactly as events.test.ts injects with
|
||||
// `-e MESH_MODULE=...`. Write permission is per-exchange, not per-key, so postgres may carry any
|
||||
|
||||
Reference in New Issue
Block a user