Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/frontend/packages/swarm-ui/test/ruth-missing.test.mjs
atlas 7b5400ecb8 grant manage_root_agent by stored permission only, not by the name ruth
Permission::default_for and hive-sh4re's MANAGER_AGENT are gone: every
agent with no permissions key holds Permission::DEFAULT, ruth included.
The agent-name parameters that only fed default_for go with it
(permissions::effective, HiveCopy::before_read/after_read and their
callers).

swarm-controller seeds the grant ruth held by name: at start, a declared
ruth whose permissions are unset gets DEFAULT plus manage_root_agent
written into her key, once, logged. A set key is never touched. It is a
one-shot to delete once every swarm has passed it.

The swarm UI setup assistant opens the create form with
manage_root_agent checked, so a new ruth is created with the grant.
permissions_import no longer adds ruth to the import or splits her
default. Docs and help text no longer say ruth holds the grant by
default; swarmctl-cli.md regenerated.
2026-10-17 08:10:08 +02:00

63 lines
1.8 KiB
JavaScript

// The setup assistant: its "is ruth missing" check and the permissions it
// creates her with. Run by `npm test`.
import assert from "node:assert/strict";
import { test } from "node:test";
import {
RUTH_EXTRA_PERMISSIONS,
ruthIsMissing,
} from "../src/shell/ruth-missing.ts";
import {
initialSelection,
requestPermissions,
} from "../src/pages/CreateAgentPermissions.ts";
const answering =
(body, ok = true) =>
async () => ({
ok,
json: async () => body,
});
test("a roster without ruth means ruth is missing", async () => {
assert.equal(
await ruthIsMissing(answering([{ name: "atlas" }, { name: "argus" }])),
true,
);
assert.equal(await ruthIsMissing(answering([])), true);
});
test("a roster with ruth means she is not missing", async () => {
assert.equal(
await ruthIsMissing(answering([{ name: "atlas" }, { name: "ruth" }])),
false,
);
});
test("anything but a clear answer is not missing", async () => {
assert.equal(await ruthIsMissing(answering([], false)), false);
assert.equal(await ruthIsMissing(answering({ not: "a list" })), false);
assert.equal(
await ruthIsMissing(async () => {
throw new Error("offline");
}),
false,
);
});
// The assistant's create form sends `manage_root_agent` with the default
// set, so a new ruth holds it from her first start; the default alone does not.
test("the assistant creates ruth with manage_root_agent", () => {
const defaults = ["messaging", "meta", "inbox", "execution"];
const all = [...defaults, "web_tools", "manage_root_agent"];
assert.deepEqual(
requestPermissions(
initialSelection(all, defaults, RUTH_EXTRA_PERMISSIONS),
defaults,
),
[...defaults, "manage_root_agent"],
);
assert.equal(
requestPermissions(initialSelection(all, defaults, []), defaults),
undefined,
);
});