honker: row 194 b3 (sage-1605, sage-1610): fire and delete revoke before the write (T20), a human add takes a tracker bot, a store-only delete names the bot; the tester keeps the credential refusal (row 175 W2); channel-proof and project-runtime pins

This commit is contained in:
jason.woltje committed 2026-10-21 19:34:28 -05:00
1 parent 7a0553e06d
commit a22cc77acd
23 files changed
+589 -52

No files matched your search

+18 -6
View File
@@ -10,7 +10,7 @@ import { readFileSync } from "node:fs";
import { CliError } from "./errors.mjs";
export const INSTANCES_USAGE = "mosaic business instances BUSINESS [--json] [--tester] | " +
"business instance add BUSINESS INSTANCE --definition DEF [--vars FILE] [--launch] --revision REV [--tester] | " +
"business instance add BUSINESS INSTANCE --definition DEF [--vars FILE] [--launch] [--bot BOT --bot-id N] --revision REV [--tester] | " +
"business instance set BUSINESS INSTANCE [--definition DEF] [--vars FILE] [--launch | --no-launch] --revision REV [--tester] | " +
"business instance launch|regenerate BUSINESS INSTANCE [--wait SECONDS] [--tester] | " +
"business instance terminate BUSINESS INSTANCE [--reason TEXT] [--tester] | " +
@@ -19,8 +19,12 @@ export const INSTANCES_USAGE = "mosaic business instances BUSINESS [--json] [--t
// The bus answers a refusal with its code alone, so the reason a human reads is here.
export const REASONS = {
"organization-credentials-out-of-scope": "this command binds no credentials, so it refuses a definition that declares them " +
"and a definition change on an instance that holds them; that stays a hand edit of the business file",
"organization-credentials-out-of-scope": "only add binds credentials, as store references; set refuses a definition that " +
"declares them and a definition change on an instance that holds them, and delete refuses a file or env reference; " +
"those stay a hand edit of the business file",
// Row 194 (brief item 7, sage-1610 a): add names an existing Vikunja bot; it makes no account.
"organization-tracker-required": "the definition uses vikunja; add needs --bot BOT --bot-id N, an existing Vikunja bot",
"organization-tracker-bot-taken": "another instance already uses that Vikunja bot name or id",
"organization-instance-exists": "the business already has that instance; change it with `mosaic business instance set`",
"organization-unknown-instance": "the business has no such instance; add it with `mosaic business instance add`",
"organization-definition-refused": "this command neither adds nor changes an assistant, and moves no instance to the assistant " +
@@ -66,7 +70,7 @@ function parse(args) {
if (["--json", "--launch", "--no-launch", "--tester"].includes(arg)) {
if (out.flags.has(arg)) throw new CliError(INSTANCES_USAGE, 4);
out.flags.add(arg);
} else if (["--definition", "--vars", "--revision", "--wait", "--reason"].includes(arg)) {
} else if (["--definition", "--vars", "--revision", "--wait", "--reason", "--bot", "--bot-id"].includes(arg)) {
if (!args[i + 1] || Object.hasOwn(out.values, arg)) throw new CliError(INSTANCES_USAGE, 4);
out.values[arg] = args[++i];
} else if (arg.startsWith("--")) throw new CliError(INSTANCES_USAGE, 4);
@@ -80,6 +84,10 @@ function setArgs(parsed) {
const [, op, , instance] = parsed.positional;
const { values, flags } = parsed;
if (values["--wait"] !== undefined || values["--reason"] !== undefined) throw new CliError(INSTANCES_USAGE, 4);
const bot = values["--bot"] !== undefined || values["--bot-id"] !== undefined;
if (bot && (op !== "add" || values["--bot"] === undefined || !/^[0-9]{1,15}$/.test(values["--bot-id"] ?? ""))) {
throw new CliError(INSTANCES_USAGE, 4);
}
const launch = flags.has("--launch") ? true : flags.has("--no-launch") ? false : undefined;
if (parsed.positional.length !== 4 || !["add", "set"].includes(op) || !values["--revision"] || flags.has("--json") ||
(flags.has("--launch") && flags.has("--no-launch")) || (op === "add" && (!values["--definition"] || launch === false)) ||
@@ -96,6 +104,7 @@ function setArgs(parsed) {
}
}
if (launch !== undefined) args.launch = launch;
if (bot) args.tracker = { bot: values["--bot"], botId: Number(values["--bot-id"]) };
return args;
}
@@ -165,7 +174,10 @@ function refusal(code, why) {
}
function lifecycleLine(business, op, instance, r) {
if (op === "delete") return `business ${business}: deleted ${instance}, now retired\ntransaction ${r.done.transaction}\n`;
if (op === "delete") {
const bot = r.done.bot ? `tracker bot ${r.done.bot}: remove the Vikunja bot user and any token it holds by hand in Vikunja\n` : "";
return `business ${business}: deleted ${instance}, now retired\ntransaction ${r.done.transaction}\n${bot}`;
}
return `business ${business}: ${op === "launch" ? "launched" : "regenerated"} ${instance}, run ${r.done.run} (request ${r.request})\n`;
}
@@ -189,7 +201,7 @@ export function formatInstances(view) {
const accepted = definitions.filter(([, d]) => d.accepted).map(([name]) => name);
const bound = definitions.filter(([, d]) => d.services.length).map(([name, d]) => `${name} (${d.services.join(", ")})`);
lines.push(`definitions add and set accept: ${accepted.join(", ") || "none"}`);
if (bound.length) lines.push(`definitions that declare credentials, a hand edit: ${bound.join(", ")}`);
if (bound.length) lines.push(`definitions that declare credentials, added with store references and a restart: ${bound.join(", ")}`);
if (view.retired?.length) lines.push(`retired: ${view.retired.join(", ")}`);
if (view.noHire?.length) lines.push(`the chief may not hire: ${view.noHire.join(", ")}`);
return `${lines.join("\n")}\n`;
+4 -3
View File
@@ -793,8 +793,9 @@ export function createLauncher({
}
const transaction = out?.transaction ?? null;
if (transaction === null) return { refusal: "workspace-rename-failed" };
const bot = out.bot ? { bot: out.bot } : {};
const from = workspaceDir(dataRoot, b.id, r.instance);
if (!existsSync(from)) return { transaction };
if (!existsSync(from)) return { transaction, ...bot };
const to = join(dirname(from), ".retired", `${r.instance}-${transaction}`);
try {
mkdirSync(dirname(to), { recursive: true, mode: 0o700 });
@@ -804,10 +805,10 @@ export function createLauncher({
chmodSync(to, 0o700);
} catch (e) {
log(`request ${r.request} (${r.instance}): workspace rename failed: ${e.message}; left at ${from}`);
return { transaction, refusal: "workspace-rename-failed", why: `${e.message}; left at ${from}` };
return { transaction, ...bot, refusal: "workspace-rename-failed", why: `${e.message}; left at ${from}` };
}
record({ event: "workspace-retired", instance: r.instance, request: r.request, transaction, path: to });
return { transaction };
return { transaction, ...bot };
}
// endLaunch's answer ({ released, limit? }), or null when it refused.
+4 -2
View File
@@ -75,7 +75,7 @@ test("row 165 CLI: instance add puts an instance in the file, validate exits 0,
// Row 65: the cli fixture gives every instance its route vars, so the view lists them.
assert.match(view.out, /^ {2}chief: chief-of-staff \(launcher\) vars \{"harness":"pi","model":"glm-5\.3-flash","thinking":"high"\}$/m);
assert.match(view.out, /^definitions add and set accept: .*\bmerge-gate\b.*\bsecurity-reviewer\b/m);
assert.match(view.out, /^definitions that declare credentials, a hand edit: .*\breviewer \(gitea, vikunja\)/m);
assert.match(view.out, /^definitions that declare credentials, added with store references and a restart: .*\breviewer \(gitea, vikunja\)/m);
const added = await s.mosaic(["instance", "add", "acme", "sec-1", "--definition", "security-reviewer", "--launch", "--revision", await s.revision()]);
assert.equal(added.code, 0, added.err);
const entry = s.log().at(-1);
@@ -123,7 +123,9 @@ test("row 165 CLI: a refusal names its code and why, exits 2 and keeps the bytes
const rev = await s.revision();
const before = readFileSync(s.file, "utf8");
const cases = [
[["instance", "add", "acme", "reviewer-2", "--definition", "reviewer", "--revision", rev], /^mosaic: organization-credentials-out-of-scope: this command binds no credentials/],
// Row 194 (brief item 7, sage-1610 a): a vikunja definition needs --bot and --bot-id.
[["instance", "add", "acme", "reviewer-2", "--definition", "reviewer", "--revision", rev], /^mosaic: organization-tracker-required: the definition uses vikunja; add needs --bot BOT --bot-id N/],
[["instance", "add", "acme", "reviewer-2", "--definition", "reviewer", "--bot", "bot-acme-reviewer", "--bot-id", "40", "--revision", rev], /^mosaic: organization-tracker-bot-taken: /],
[["instance", "set", "acme", "coder", "--definition", "security-reviewer", "--revision", rev], /^mosaic: organization-credentials-out-of-scope: /],
[["instance", "add", "acme", "coder", "--definition", "merge-gate", "--revision", rev], /^mosaic: organization-instance-exists: /],
[["instance", "set", "acme", "ghost", "--launch", "--revision", rev], /^mosaic: organization-unknown-instance: /],
+20
View File
@@ -412,6 +412,26 @@ test("row 194 D1.1 item 5: the CLI's launch, regenerate, terminate and delete en
assert.match((await s.cli(["instances", "acme"])).out, /^retired: sec-1$/m);
});
// Row 194 (brief item 8, sage-1610 b): an instance whose every credential is a store reference
// deletes with its tracker bot. The launcher carries the bot to the close, and the CLI names it for
// removal in Vikunja, since the bus makes and removes no Vikunja account.
test("row 194 T20: a store-only delete with a tracker bot closes naming the bot, and the CLI says to remove it in Vikunja", { skip, timeout: 60000 }, async (t) => {
const p = prepare(t, (doc) => {
doc.roles["rev-2"] = { definition: "reviewer", vars: { harness: "pi", model: "claude-sonnet-5-5", thinking: "high" }, tracker: { bot: "bot-acme-rev-2", botId: 40 },
credentials: { gitea: { store: true, rotateBy: "2099-01-01" }, vikunja: { store: true, expires: "2099-01-01" } } };
return doc;
});
// The agents' store root beside the business files, private as the boot check needs it.
mkdirSync(join(p.root, "config", "secrets", "agents"), { recursive: true, mode: 0o700 });
const s = await start(t, p);
const revision = JSON.parse((await s.cli(["instances", "acme", "--json"])).out).revision;
const del = await s.cli(["instance", "delete", "acme", "rev-2", "--revision", revision]);
assert.equal(del.code, 0, del.err);
assert.match(del.out, /^business acme: deleted rev-2, now retired\ntransaction [^\n]+\ntracker bot bot-acme-rev-2: remove the Vikunja bot user and any token it holds by hand in Vikunja\n$/);
// The line reads done.bot, which only the launcher's close writes.
assert.equal(Object.hasOwn(JSON.parse((await s.cli(["instances", "acme", "--json"])).out).instances, "rev-2"), false);
});
test("row 194 T2a: a launch.revoke between the request and the pass closes it launch-revoked with no process; a done that fails once leaves the request taken and the next pass starts nothing", { skip, timeout: 60000 }, async (t) => {
const p = prepare(t);
const s = await start(t, p);