row 175 (#1673): tester reads, W1-W7 writes recorded as tester, human-only verbs refuse tester-refused
TESTER_VERBS gains usage, names, limits, plugins, instances, project.list, thread.list, name.set and project.create; TESTER_ORGANIZATION_VERBS lets a tester read limits, plugins and instances and send plugins.set, instances.set and routes.set, each logged with actor tester. The project file verbs refuse a tester tester-refused. The broker and CLI drop the [mos test] prefix rule (mos-0872 Q1). The CLI takes --tester on the seven reads and the W1-W7 write forms and refuses it (exit 4) elsewhere. project init --tester checks the project area, binds the tester with one agents read, then commits the layout as tester (mos-0872 Q2).
This commit is contained in:
1 parent
1bfc9833b1
commit
e5e64afecb
24 files changed
+629
-118
No files matched your search
+30
-16
@@ -92,8 +92,13 @@ export const WEB_UNTRUSTED =
|
||||
export const TASK_VERBS = Object.freeze(ACTIONS.filter((a) => a.startsWith('task.')));
|
||||
// Row 110 (#1604): what a tester session may do. Send to a role, receive and read the replies
|
||||
// sent to `tester`, and the human's read views. Every other verb refuses tester-refused.
|
||||
const TESTER_VERBS = ['message.send', 'message.receive', 'message.read', 'inbox', 'agents', 'tasks', 'trail', 'decisions', 'messages', 'replies'];
|
||||
const TESTER_PREFIX = '[mos test]';
|
||||
// Row 175 (#1673, Q173): the test system's reads and two writes, name.set and project.create,
|
||||
// each recorded with `tester` as its actor. The organization branch keeps its own list below.
|
||||
export const TESTER_VERBS = Object.freeze(['message.send', 'message.receive', 'message.read', 'inbox', 'agents', 'tasks', 'trail', 'decisions', 'messages', 'replies',
|
||||
'usage', 'names', 'limits', 'plugins', 'instances', 'project.list', 'thread.list', 'name.set', 'project.create']);
|
||||
// Row 175: the organization verbs a tester may call. Its writes run every check the human's do
|
||||
// and log actor `tester`; limits.set, organization.set, routes and organization.revision refuse it.
|
||||
export const TESTER_ORGANIZATION_VERBS = Object.freeze(['limits', 'plugins', 'instances', 'plugins.set', 'instances.set', 'routes.set']);
|
||||
const SELF_KINDS = new Set(['task.created', 'task.assigned', 'task.state', 'task.closed', 'task.conflict']);
|
||||
const POLL_KINDS = new Set([
|
||||
'task.changed.external',
|
||||
@@ -1230,7 +1235,9 @@ export class Broker {
|
||||
// to a role whose file lists the same grant. A read never spends the grant.
|
||||
const revisionRead = request.verb === "organization.revision";
|
||||
const role = request.verb === "organization.set" || revisionRead;
|
||||
if (!role && !s.human) fail("human-required");
|
||||
// Row 175 (#1673, Q173): the tester gate runs before any argument check, as at the store below.
|
||||
if (s.tester && !TESTER_ORGANIZATION_VERBS.includes(request.verb)) fail("tester-refused");
|
||||
if (!role && !s.human && !s.tester) fail("human-required");
|
||||
if (!this.#organization) fail("not-configured");
|
||||
if (["limits", "plugins", "instances", "routes", "organization.revision"].includes(request.verb)) keys(args, []);
|
||||
else if (request.verb === "plugins.set") keys(args, ["revision", "plugins"], ["revision", "plugins"]);
|
||||
@@ -1243,7 +1250,7 @@ export class Broker {
|
||||
// runs the same route checks.
|
||||
else if (request.verb === "routes.set") keys(args, ["revision", "routes"], ["revision", "routes"]);
|
||||
else keys(args, ORGANIZATION_KEYS, ["revision"]);
|
||||
let actor = s.human;
|
||||
let actor = s.tester ? "tester" : s.human;
|
||||
// This branch runs outside the store transaction below, so the grant is checked before the writer
|
||||
// and consumed only once the writer has committed: a refused change logs action.refused alone,
|
||||
// as a refused human limits.set does.
|
||||
@@ -1401,6 +1408,9 @@ export class Broker {
|
||||
const { verb, args } = request;
|
||||
let ProjectFailure;
|
||||
try {
|
||||
// Row 175 (#1673): these verbs dispatch before the store's tester gate, so they refuse a
|
||||
// tester here, tester-refused like every other human-only verb.
|
||||
if (s.tester) fail('tester-refused');
|
||||
this.#human(s);
|
||||
if (!this.#project?.listFiles) fail('project-not-configured');
|
||||
const { listFiles, readFile, writeFile, ProjectError } = this.#project;
|
||||
@@ -1805,11 +1815,10 @@ export class Broker {
|
||||
? this.#named(s.business, a.to) : null;
|
||||
const to = named ?? a.to;
|
||||
if (s.tester) {
|
||||
// A tester writes to a role only, says so in its first words, and cites no decision.
|
||||
// It consumes no authority and writes no human.input.
|
||||
// A tester writes to a role only and cites no decision. It consumes no authority and
|
||||
// writes no human.input. Row 175 (mos-0872 Q1): the test system needs no body prefix.
|
||||
keys(a, ['to', 'body', 'class', 'in_reply_to'], ['to', 'body']);
|
||||
if (!Object.hasOwn(b.roles, to)) fail('unknown-role');
|
||||
if (typeof a.body !== 'string' || !a.body.startsWith(TESTER_PREFIX)) fail('tester-prefix');
|
||||
} else if (!s.human) {
|
||||
const withinRole = this.#classification(s, 'message.send') === 'within-role';
|
||||
this.#consumeAuthority(s, 'message.send', {
|
||||
@@ -2207,9 +2216,11 @@ export class Broker {
|
||||
// refuses here, so neither a cross-role grant nor a decision can set a name. A name is unique
|
||||
// in the business (the store's trigger backs this up) and equals no instance key, no role
|
||||
// definition, "human" or "tester", so `to` never means two things.
|
||||
// Row 175 (#1673, Q173): the tester names an instance too, with every name check, no
|
||||
// authority consumed and `by` recorded as tester.
|
||||
case 'name.set': {
|
||||
keys(a, ['instance', 'name'], ['instance', 'name']);
|
||||
if (!s.human && this.#classification(s, 'instance.name', a.instance) !== 'within-role') {
|
||||
if (!s.human && !s.tester && this.#classification(s, 'instance.name', a.instance) !== 'within-role') {
|
||||
this.#agent(s);
|
||||
fail('not-authorized');
|
||||
}
|
||||
@@ -2220,14 +2231,14 @@ export class Broker {
|
||||
if (this.#definitions(b).has(a.name)) fail('name-is-role');
|
||||
const holder = this.#named(s.business, a.name);
|
||||
if (holder && holder !== a.instance) fail('name-taken');
|
||||
if (!s.human) this.#consumeAuthority(s, 'instance.name', { target: a.instance });
|
||||
if (!s.human && !s.tester) this.#consumeAuthority(s, 'instance.name', { target: a.instance });
|
||||
this.#store.run(
|
||||
'INSERT INTO instance_names(at,business,instance,name,by) VALUES(?,?,?,?,?)',
|
||||
this.#now(),
|
||||
s.business,
|
||||
a.instance,
|
||||
a.name,
|
||||
s.human || s.run,
|
||||
s.tester ? 'tester' : s.human || s.run,
|
||||
);
|
||||
return { instance: a.instance, name: a.name };
|
||||
}
|
||||
@@ -2246,7 +2257,7 @@ export class Broker {
|
||||
}
|
||||
case 'names': {
|
||||
keys(a, []);
|
||||
if (!s.human) this.#agent(s);
|
||||
if (!s.human && !s.tester) this.#agent(s);
|
||||
return this.#store.all(
|
||||
'SELECT instance,name,at FROM instance_names n WHERE business=? AND seq=(SELECT max(seq) FROM instance_names WHERE business=n.business AND instance=n.instance) ORDER BY instance',
|
||||
s.business,
|
||||
@@ -2254,8 +2265,9 @@ export class Broker {
|
||||
}
|
||||
// Row 121 (#1615): projects group the user's threads (REQ-ORG-2). `repo` names a
|
||||
// project from the business file; the rename to repos is a P19 follow-up.
|
||||
// Row 175 (#1673, Q173): the tester creates and lists projects too, created_by tester.
|
||||
case 'project.create': {
|
||||
this.#human(s);
|
||||
if (!s.tester) this.#human(s);
|
||||
keys(a, ['name', 'repo'], ['name']);
|
||||
if (!name(a.name)) fail('invalid-request');
|
||||
if (a.repo !== undefined && !Object.hasOwn(b.projects ?? {}, identifier(a.repo))) fail('unknown-repo');
|
||||
@@ -2269,12 +2281,12 @@ export class Broker {
|
||||
s.business,
|
||||
a.name,
|
||||
a.repo ?? null,
|
||||
s.human,
|
||||
s.tester ? 'tester' : s.human,
|
||||
);
|
||||
return { id: pid };
|
||||
}
|
||||
case 'project.list': {
|
||||
this.#human(s);
|
||||
if (!s.tester) this.#human(s);
|
||||
keys(a, []);
|
||||
return this.#store.all('SELECT id,at,name,repo FROM projects WHERE business=? ORDER BY seq', s.business);
|
||||
}
|
||||
@@ -2303,8 +2315,10 @@ export class Broker {
|
||||
);
|
||||
return { id: tid, instance: instances[0] };
|
||||
}
|
||||
// Row 175: a tester has no threads of its own (row 177 adds them), so it lists the
|
||||
// business human's, the list the human sees.
|
||||
case 'thread.list': {
|
||||
this.#human(s);
|
||||
if (!s.tester) this.#human(s);
|
||||
keys(a, ['project']);
|
||||
if (a.project !== undefined) identifier(a.project);
|
||||
return this.#store.all(
|
||||
@@ -2312,7 +2326,7 @@ export class Broker {
|
||||
(a.project === undefined ? '' : ' AND project=?') +
|
||||
' ORDER BY seq',
|
||||
s.business,
|
||||
s.human,
|
||||
s.tester ? b.human : s.human,
|
||||
...(a.project === undefined ? [] : [a.project]),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user