A8 gave gitea a findings state and the keeper its read; gitea's announcement did not name it, so the read was refused on the mesh (checks/readable) and its own kept test failed. Rows in test/kept.test.ts; they failed before the change. Claude-Session: https://claude.ai/code/session_01JG73KJNrH5EgFXMKKYSrig
28 lines
2.0 KiB
TypeScript
28 lines
2.0 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { test } from "node:test";
|
|
import { readFileSync } from "node:fs";
|
|
|
|
// 1790: the states the module announces are the states its manifest declares, no more, no fewer; `bound` is readable,
|
|
// because mesh-provisioner's manifest reads it (the sweep of 2026-10-30, issue 774: announced unreadable, the read was
|
|
// refused and no forge account was bound).
|
|
test("the states the module announces are the states its manifest declares", async () => {
|
|
const { KEPT } = await import("../kept.ts");
|
|
const manifest = JSON.parse(readFileSync(new URL("../module.json", import.meta.url), "utf8"));
|
|
const declared = (manifest.state as (string | { name: string })[]).map((s) => (typeof s === "string" ? s : s.name)).sort();
|
|
assert.deepEqual(KEPT.map((k) => k.name).sort(), declared);
|
|
assert.deepEqual(KEPT.filter((k) => k.readable).map((k) => k.name), ["bound", "findings"],
|
|
"bound and findings alone are readable: mesh-provisioner reads bound, the condition keeper findings");
|
|
});
|
|
|
|
test("the announcement has the layout mesh-sdk's go/announce reads: version 1, the module, the node, the states sorted by name", async () => {
|
|
const { statesAnnouncement } = await import("../kept.ts");
|
|
assert.deepEqual(statesAnnouncement("gitea", "ace"), { v: 1, module: "gitea", node: "ace", states: [{ name: "announced" }, { name: "bound", readable: true }, { name: "findings", readable: true }] });
|
|
assert.deepEqual(statesAnnouncement("gitea", undefined), { v: 1, module: "gitea", states: [{ name: "announced" }, { name: "bound", readable: true }, { name: "findings", readable: true }] });
|
|
});
|
|
|
|
test("index.ts says the announcement as the event `states` before the tools are served", () => {
|
|
const source = readFileSync(new URL("../index.ts", import.meta.url), "utf8");
|
|
assert.match(source, /await emit\("states", statesAnnouncement\(/);
|
|
assert.ok(source.indexOf('await emit("states"') < source.indexOf('registerModuleTools("gitea"'), "announced before the tools are served");
|
|
});
|