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:
dewey committed 2026-10-19 18:44:06 -05:00
1 parent 9e74925c2a
commit c0b06ed89b
24 files changed
+629 -118

No files matched your search

+7 -5
View File
@@ -4,10 +4,10 @@ import {
} from 'node:fs';
import { dirname, join, normalize } from 'node:path';
import { randomUUID } from 'node:crypto';
import { ProjectError, checkedId, documentPath, noLinks, projectRepo } from './paths.mjs';
import { ProjectError, checkedId, documentPath, noLinks, projectRepo, testerProjectArea } from './paths.mjs';
import { git, identity, inspectGit, requireClean } from './git.mjs';
import { validateRecord } from './validate.mjs';
export { ProjectError, projectRepo, validateRecord };
export { ProjectError, projectRepo, testerProjectArea, validateRecord };
const DIRECTORIES = ['spec', 'docs', 'requirements', 'decisions', 'templates'];
const TEMPLATES = ['project.json', 'requirement.json', 'decision.json', 'document.md', 'north-star.md'];
@@ -92,8 +92,10 @@ export async function checkProject(context) {
return result;
}
export async function initProject(context) {
const repo = projectRepo(context), human = checkedId(context.business.human);
// Row 175 (#1673): `author` names the layout commit's author and committer; without it the
// business human commits, as before. The tester's init passes "tester".
export async function initProject(context, { author } = {}) {
const repo = projectRepo(context), committer = checkedId(author ?? context.business.human);
if (existsSync(repo) && readdirSync(repo).length) throw new ProjectError('project-not-empty', 'refusing existing non-empty directory');
const parents = [];
for (let path = repo; !existsSync(path); path = dirname(path)) parents.unshift(path);
@@ -130,7 +132,7 @@ export async function initProject(context) {
const result = await checkLayout(context);
if (!result.ok) throw new ProjectError('project-invalid', result.problems.join('\n'));
await git(repo, ['add', '--', 'project.json', ...DIRECTORIES]);
await git(repo, ['commit', '-m', 'Initialize project layout v1'], identity(human));
await git(repo, ['commit', '-m', 'Initialize project layout v1'], identity(committer));
return { repo, commit: await git(repo, ['rev-parse', 'HEAD']) };
} catch (error) {
for (const entry of created.reverse()) {
+12 -4
View File
@@ -27,6 +27,10 @@ export function noLinks(path) {
if (part === dirname(part)) break;
}
}
const contains = (base, child) => {
const rel = relative(base, child);
return rel === '' || (rel !== '..' && !rel.startsWith('..' + sep) && !isAbsolute(rel));
};
export function projectRepo({ business, project, dataRoot }) {
checkedId(business?.id); checkedId(project);
if (!Object.hasOwn(business?.projects ?? {}, project))
@@ -34,10 +38,6 @@ export function projectRepo({ business, project, dataRoot }) {
absolute(dataRoot);
const entry = business.projects[project];
const repo = absolute(entry.repo ?? join(dataRoot, 'projects', business.id, project));
const contains = (base, child) => {
const rel = relative(base, child);
return rel === '' || (rel !== '..' && !rel.startsWith('..' + sep) && !isAbsolute(rel));
};
for (const project of Object.values(business.projects)) {
const code = absolute(project.root);
if (contains(code, repo) || contains(repo, code))
@@ -46,3 +46,11 @@ export function projectRepo({ business, project, dataRoot }) {
noLinks(repo);
return repo;
}
// Row 175 (#1673, mos-0872 Q2): the tester initializes only a repository in the data root's
// project area, <dataRoot>/projects/<business id>/. It writes nothing; projectRepo only lstats the path.
export function testerProjectArea(context) {
const repo = projectRepo(context);
if (!contains(join(context.dataRoot, 'projects', context.business.id), repo))
throw new ProjectError('tester-project-area', `the tester initializes only a repository under ${join(context.dataRoot, 'projects', context.business.id)}`);
return repo;
}