Two processes that minted at once left the forge two tokens by one name, and a token kept in a file in the runtime state is a plain state. Both accounts' tokens (mesh-tools, mesh-packages) are now the module's own secrets in the vault, written through the seat mesh-vault's own-put and read through its get, sealed to the reading process's key. A refused or expired (token-ttl) token is minted again only by the holder of the lease mint in the state token-lease (mint-lease); each mint is named <account>-<generation>, and the token it replaces is deleted by id only after own-put landed. The Go bundles read their tokens through get at start and at secret-changed; the MESH_GITEA_*_TOKEN_FILE words go. forge_token_lease reads the lease and each token's age, never the token. Builds: design 47 H2 §808, §822; H-A-407, H-A-422, H-A-426, H-A-430 (1)
28 lines
2.3 KiB
TypeScript
28 lines
2.3 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: "calls" }, { name: "failed-steps" }, { name: "findings", readable: true }, { name: "first-views" }, { name: "idle" }, { name: "taken" }, { name: "token-lease" }, { name: "transfers" }] });
|
|
assert.deepEqual(statesAnnouncement("gitea", undefined), { v: 1, module: "gitea", states: [{ name: "announced" }, { name: "bound", readable: true }, { name: "calls" }, { name: "failed-steps" }, { name: "findings", readable: true }, { name: "first-views" }, { name: "idle" }, { name: "taken" }, { name: "token-lease" }, { name: "transfers" }] });
|
|
});
|
|
|
|
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");
|
|
});
|