diff --git a/packages/bus/src/broker.mjs b/packages/bus/src/broker.mjs index e556e29a1..573ea689b 100644 --- a/packages/bus/src/broker.mjs +++ b/packages/bus/src/broker.mjs @@ -11,7 +11,7 @@ import { initializeControl, processingStatus } from '../../processing-control/sr import { NAME as HARNESS_NAME } from '../../plugins/src/kinds.mjs'; import { loadRequirements } from '../../tasks/src/requirements.mjs'; import { MERGE, LandingRefusal, readLanding } from './landing.mjs'; -import { pluginName, ID_PATTERN, THREAD_DEFINITIONS, END_PROTECTED, forkProblem, forkUrl, credentialKind, validArgv, commandAllowed, HOST_ID, CREATIVE_DEFINITIONS, giteaName, parseGiteaUrl, covers, grantScopeOf, grantInScope } from '../../organization/src/vocabulary.mjs'; +import { pluginName, ID_PATTERN, THREAD_DEFINITIONS, END_PROTECTED, forkProblem, forkUrl, credentialKind, validArgv, commandAllowed, HOST_ID, CREATIVE_DEFINITIONS, giteaName, parseGiteaUrl, covers, grantScopeOf, grantInScope, SYSTEM_ONLY_REFUSAL, systemOnly } from '../../organization/src/vocabulary.mjs'; // Kept closed while S1 lands; its vocabulary is the integration authority. export const ACTIONS = Object.freeze([ @@ -6791,6 +6791,9 @@ export class Broker { #pinRole(noHire, hire) { const pin = hire?.pin; if (!object(pin)) fail('invalid-request'); + // #1873 triage-fence: a recorded pin never hires a system-only template, by reference or as the + // inline copy of one (the inline composition below drops from). + if (systemOnly(pin.template) || systemOnly(hire.entry?.from?.template)) fail(SYSTEM_ONLY_REFUSAL); if (!Object.hasOwn(pin, 'inline')) return structuredClone(pin); if (!object(hire.entry) || typeof pin.sha256 !== 'string') fail('invalid-request'); // The broker's sandbox import closure is fixed, so the digest and the composition are local @@ -7202,7 +7205,7 @@ export class Broker { // name; a file check (BusinessError) is invalid-request, anything else outcome-unknown. #packFail(e) { const code = e?.code ?? ''; - if (['credential-leak', 'pack-plan-stale', 'revision-conflict', 'invalid-request', 'human-required', 'not-configured'].includes(code) + if (['credential-leak', 'pack-plan-stale', 'revision-conflict', 'invalid-request', 'human-required', 'not-configured', SYSTEM_ONLY_REFUSAL].includes(code) || /^(starter-pack|definition|organization)-[a-z-]+$/.test(code)) fail(code); if (e?.name === 'BusinessError') fail('invalid-request'); throw new BusError('outcome-unknown'); @@ -7234,6 +7237,8 @@ export class Broker { if ((verb === "instance.hire" || verb === "instance.fire") && e.code === "definition-not-hireable") fail(e.code); // Row 194 (B7, webby-0094 N3): the limits writer's keep check, against the file, as well. if (e.code === "instance-kept") fail(e.code); + // #1873 triage-fence: a system-only template refuses by its one code on every write. + if (e.code === SYSTEM_ONLY_REFUSAL) fail(e.code); // #1873 T1: the definition writer's refusals pass by code; a composition refusal stays invalid-request. if (Object.hasOwn(DEFINITION_BUS_KEYS, verb) && /^definition-[a-z-]+$/.test(e.code ?? "")) fail(e.code); // Row 194 (brief item 8): a fire's or a delete's revoke failed, and nothing was written. diff --git a/packages/bus/src/refusals.mjs b/packages/bus/src/refusals.mjs index 6ceef7643..ce3053bf1 100644 --- a/packages/bus/src/refusals.mjs +++ b/packages/bus/src/refusals.mjs @@ -199,6 +199,13 @@ group( "R10: only the caller's own saved templates", "List your saved templates and use one of those names. A saved template is visible only to the owner who saved it." ); +// #1873 triage-fence: a template on the system-only list (organization vocabulary.mjs SYSTEM_ONLY) +// joins no organization by any path. +group( + "template-system-only", + "R8/R10: a system-only role template joins no organization", + "This role template serves the system outside every organization. Pick another template or definition; no hire, change, pack, import or instance write gives an organization one." +); group( "starter-pack-template-changed", "R8: a pack's hash pin must match the current template", diff --git a/packages/bus/src/runtime.mjs b/packages/bus/src/runtime.mjs index 99dc32771..ea669191d 100644 --- a/packages/bus/src/runtime.mjs +++ b/packages/bus/src/runtime.mjs @@ -40,6 +40,7 @@ import { instanceSettings } from '../../organization/src/instance-settings.mjs'; import { organizationWriter, OrganizationError, setReplyLimits } from '../../organization/src/organization.mjs'; import { definitionVerbs, DEFINITION_BUS_VERBS } from '../../organization/src/definition-verbs.mjs'; import { ORG_PREFIX, orgDefinitionName, compositionOf, readTemplate, entryFromTemplate, lineDiff, PRIMITIVES } from '../../organization/src/definitions.mjs'; +import { SYSTEM_ONLY_REFUSAL, systemOnly } from '../../organization/src/vocabulary.mjs'; import { installedStarterPacks, readSavedTemplate } from '../../plugins/src/starter-pack.mjs'; import { TemplateError, templateList, templatePreview, templateSave } from '../../organization/src/template-save.mjs'; import { checkComposition } from '../../organization/src/composition.mjs'; @@ -313,7 +314,10 @@ function packOps({ writer, rolesDir, dataRoot, system, registryFor, assertClean, async function loadPack(name, actor) { if (typeof name !== 'string' || name.length > 128) bad(); if (name.startsWith(SAVED_PREFIX)) return readSavedTemplate({ configDir, account: actor, name: name.slice(SAVED_PREFIX.length), rolesDir }); - const found = (await installed()).find(p => p.id === name); + const { packs, refused } = await installedStarterPacks({ dataRoot, rolesDir }); + const found = packs.find(p => p.id === name); + // #1873 triage-fence: an installed pack refused for naming a system-only template says so. + if (!found && refused.some(r => r.name === name && r.code === SYSTEM_ONLY_REFUSAL)) throw new BusError(SYSTEM_ONLY_REFUSAL); if (!found) throw new BusError('starter-pack-not-found'); return found; } @@ -332,6 +336,9 @@ function packOps({ writer, rolesDir, dataRoot, system, registryFor, assertClean, // The entry a pack definition writes: a template reference becomes the template's own entry, pinned // by its hash (a moved hash refuses), and a full entry is copied as it is. Neither carries rev. function entryOf(value) { + // #1873 triage-fence: preview and apply both refuse a pack naming a system-only template, as a + // reference or as the from of a full entry. + if (systemOnly(value?.template) || systemOnly(value?.from?.template)) throw new BusError(SYSTEM_ONLY_REFUSAL); if (Object.hasOwn(value, 'template') && Object.hasOwn(value, 'sha256') && Object.keys(value).length === 2) { const template = readTemplate(rolesDir, value.template); if (template.sha256 !== value.sha256) throw new BusError('starter-pack-template-changed'); diff --git a/packages/bus/tests/channel-proof.test.mjs b/packages/bus/tests/channel-proof.test.mjs index 2f2e8223e..a5000c671 100644 --- a/packages/bus/tests/channel-proof.test.mjs +++ b/packages/bus/tests/channel-proof.test.mjs @@ -42,7 +42,8 @@ const baselines = { // deadline; userCall shares transport(). Nonces, argv and limits are unchanged. // #1873 A3: STATUS maps credential-unbound, copy-refused, project-refused and project-agent-elsewhere // to 409; no proof or transport change. - "packages/webui/src/bus.mjs": "d8f3e0eb5299fdb192e98a1238ca693aae7c36af9a21de72d5f5d39610589377", + // #1873 triage-fence: STATUS maps template-system-only to 400; no proof or transport change. + "packages/webui/src/bus.mjs": "cd08e1beb49e9e881bb1b308f2ab3343a480b47dd9b17ccbd16e120d341d7511", }; const repoFile = path => new URL("../../../" + path, import.meta.url); diff --git a/packages/bus/tests/project-runtime.test.mjs b/packages/bus/tests/project-runtime.test.mjs index 95dc6f5ae..bdcdacbae 100644 --- a/packages/bus/tests/project-runtime.test.mjs +++ b/packages/bus/tests/project-runtime.test.mjs @@ -43,7 +43,8 @@ test('Broker keeps the sandbox client import closure: only the listed imports, n // Row 236 (#1742, #436b) reads giteaName and parseGiteaUrl for the Gitea grant path. // FED R3 r5 (row 274, #414) reads covers, a user's grant check, from it. // Row 219 reads THREAD_DEFINITIONS from the same vocabulary for creative thread admission. - "import { pluginName, ID_PATTERN, THREAD_DEFINITIONS, END_PROTECTED, forkProblem, forkUrl, credentialKind, validArgv, commandAllowed, HOST_ID, CREATIVE_DEFINITIONS, giteaName, parseGiteaUrl, covers, grantScopeOf, grantInScope } from '../../organization/src/vocabulary.mjs';", + // #1873 triage-fence reads SYSTEM_ONLY_REFUSAL and systemOnly from the same vocabulary. + "import { pluginName, ID_PATTERN, THREAD_DEFINITIONS, END_PROTECTED, forkProblem, forkUrl, credentialKind, validArgv, commandAllowed, HOST_ID, CREATIVE_DEFINITIONS, giteaName, parseGiteaUrl, covers, grantScopeOf, grantInScope, SYSTEM_ONLY_REFUSAL, systemOnly } from '../../organization/src/vocabulary.mjs';", ]); assert.doesNotMatch(source, /\bimport\s*\(/); assert.doesNotMatch(readFileSync(new URL('../src/proxy-page-vocabulary.mjs', import.meta.url), 'utf8'), /\bimport\b/); diff --git a/packages/bus/tests/system-only.test.mjs b/packages/bus/tests/system-only.test.mjs new file mode 100644 index 000000000..74566882d --- /dev/null +++ b/packages/bus/tests/system-only.test.mjs @@ -0,0 +1,165 @@ +// #1873 lane triage-fence: through the broker, no organization gains the system-only Triage +// template. Pack preview and apply, the Console hire start, the chief's hire.raise and +// decision.raise, and instances.set add as the human and the tester each refuse with +// template-system-only; the Console's hire template list omits triage. The coding pack still +// previews as before. Fixtures live in a temp directory. +import test from 'node:test'; +import assert from 'node:assert/strict'; +import { chmodSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; +import { Broker } from '../src/broker.mjs'; +import { Store } from '../src/store.mjs'; +import { pluginHash } from '../../plugins/src/pinned.mjs'; +import { installPlugin } from '../../plugins/src/install.mjs'; +import { starterPack as codingPack } from '../../plugins/starter-pack/coding/index.mjs'; +import { templateHash } from '../../organization/src/definitions.mjs'; +import { hireDecisions } from '../../organization/src/hire-decisions.mjs'; +import { organizationWriter } from '../../organization/src/organization.mjs'; +import { loadBusiness } from '../../organization/src/organization-config.mjs'; +import { businessDoc, rolesCopy, systemFor, writeJson } from '../../organization/tests/helpers.mjs'; + +const CODE = 'template-system-only'; +const SUBJECT = { provider: 'test', iss: 'https://issuer.test', sub: 'owner' }; +const ROUTE = { harness: 'pi', model: 'claude-opus-5-5' }; + +// The broker started as the runtime starts it, with the organization writer and installed packs. +async function runtime(t) { + const { startBroker } = await import('../src/runtime.mjs'); + const root = mkdtempSync(join(tmpdir(), 'sobus-')); + const rolesDir = rolesCopy(root); + const doc = businessDoc(root, 'demo'); + doc.plugins = { harness: ['pi'] }; + doc.roles.chief.vars = { ...ROUTE }; + writeJson(join(root, 'businesses/demo.json'), doc); + const data = join(root, 'data'); + mkdirSync(data, { mode: 0o700 }); + const roles = { chief: { definition: 'chief-of-staff', authority: { withinRole: ['decision.resolve.technical', 'decision.resolve.delivery', 'organization.change'], crossRole: [] } } }; + const businesses = { demo: { id: 'demo', human: 'jason', arbiters: { technical: 'chief', delivery: 'chief' }, roles, vars: { 'bus.tester': true } } }; + const bus = await startBroker({ dataRoot: data, businesses, organization: { dir: root, rolesDir, system: systemFor(root) } }); + const thaw = (p) => { const st = lstatSync(p); if (st.isSymbolicLink()) return; if (st.isDirectory()) { chmodSync(p, 0o700); for (const e of readdirSync(p)) thaw(join(p, e)); } }; + t.after(async () => { await bus.close(); thaw(root); rmSync(root, { recursive: true, force: true }); }); + const b = bus.broker; + const owner = b.bindConsole({ business: 'demo', human: 'jason', subject: SUBJECT }); + const human = b.bindHuman({ business: 'demo', human: 'jason', via: 'cli', outsideAgent: true }); + const tester = b.bindTester({ business: 'demo' }); + const call = async (verb, args = {}, cap = owner) => b.request(cap, { verb, args }); + const file = () => readFileSync(join(root, 'businesses/demo.json'), 'utf8'); + let n = 0; + const install = (pack) => { + const src = join(root, `src-${n++}`); + mkdirSync(join(src, 'starter-pack'), { recursive: true }); + writeFileSync(join(src, 'starter-pack', 'index.mjs'), `export const interfaceVersion = 1;\nexport function starterPack() { return ${JSON.stringify(pack)}; }\n`); + const manifest = { name: pack.id, version: '1.0.0', kinds: ['starter-pack'], interfaceVersions: { 'starter-pack': 1 }, sha256: '0'.repeat(64), + source: { path: 'fixture', version: '1.0.0' }, signature: null, tools: [], actions: [], services: [], roleTemplates: [] }; + writeFileSync(join(src, 'plugin.json'), JSON.stringify(manifest)); + manifest.sha256 = pluginHash(src); + writeFileSync(join(src, 'plugin.json'), JSON.stringify(manifest)); + installPlugin({ dataRoot: data, source: src, expectedHash: manifest.sha256 }); + }; + return { b, root, rolesDir, owner, human, tester, call, file, install }; +} + +// The A4 broker with the real hire service, so the chief's raise and the Console start reach it. +function hires(t) { + const root = mkdtempSync(join(tmpdir(), 'sohire-')), rolesDir = rolesCopy(root); + writeJson(join(root, 'businesses/demo.json'), { ...businessDoc(root, 'demo'), plugins: { harness: ['pi'] } }); + const storeRoot = join(root, 'data'); mkdirSync(storeRoot, { mode: 0o700 }); + const writer = organizationWriter({ dir: root, rolesDir }), store = new Store(storeRoot); + const service = hireDecisions({ writer, rolesDir, dataRoot: storeRoot, configDir: root, assertClean: () => {} }); + const loaded = () => { const doc = loadBusiness('demo', { dir: root, rolesDir }); return { ...doc, roles: Object.fromEntries(Object.entries(doc.roles).map(([k, e]) => [k, { ...doc.definitions[e.definition], ...e }])) }; }; + const b = new Broker({ store, businesses: { demo: loaded() }, hires: service }); + t.after(() => { store.close(); rmSync(root, { recursive: true, force: true }); }); + const owner = b.bindConsole({ business: 'demo', human: 'jason', subject: SUBJECT }); + const chief = b.bindLaunch({ business: 'demo', role: 'chief', run: 'chief-run', harness: 'pi' }); + b.request(chief, { verb: 'role.claim' }); + const call = (cap, verb, args = {}) => b.request(cap, { verb, args }); + const triage = { template: 'triage', sha256: templateHash(rolesDir, 'triage') }; + const hire = (extra = {}) => ({ op: 'hire', level: 'org', name: 'sorter', role: triage, route: ROUTE, reason: 'Sort the inbox', ...extra }); + const decisions = () => store.get('SELECT count(*) n FROM decisions').n; + return { owner, chief, call, hire, decisions }; +} + +const refuses = async (promise) => assert.rejects(Promise.resolve().then(() => promise), (e) => e?.code === CODE); + +test('pack preview refuses an installed pack that defines triage', async (t) => { + const h = await runtime(t); + const pack = { ...codingPack(), id: 'sorting', label: 'Sorting' }; + pack.definitions = { ...pack.definitions, triage: { template: 'triage', sha256: templateHash(h.rolesDir, 'triage') } }; + h.install(pack); + const before = h.file(); + await refuses(h.call('pack.preview.console', { pack: 'sorting' })); + assert.equal(h.file(), before); +}); + +test('pack apply refuses an installed pack that defines triage', async (t) => { + const h = await runtime(t); + const pack = { ...codingPack(), id: 'sorting', label: 'Sorting' }; + pack.definitions = { ...pack.definitions, triage: { template: 'triage', sha256: templateHash(h.rolesDir, 'triage') } }; + h.install(pack); + const before = h.file(); + await refuses(h.call('pack.apply.console', { pack: 'sorting', digest: 'a'.repeat(64) })); + assert.equal(h.file(), before); +}); + +test('instances.set add refuses triage for the human', async (t) => { + const h = await runtime(t); + const { revision } = await h.call('instances', {}, h.human); + const before = h.file(); + await refuses(h.call('instances.set', { revision, instance: 'sorter', op: 'add', definition: 'triage' }, h.human)); + assert.equal(h.file(), before); +}); + +test('instances.set add refuses triage for the tester', async (t) => { + const h = await runtime(t); + const { revision } = await h.call('instances', {}, h.human); + const before = h.file(); + await refuses(h.call('instances.set', { revision, instance: 'sorter', op: 'add', definition: 'triage' }, h.tester)); + assert.equal(h.file(), before); +}); + +test('the instances read offers no triage add', async (t) => { + const h = await runtime(t); + const view = await h.call('instances', {}, h.human); + assert.equal(Object.hasOwn(view.definitions, 'triage'), false); +}); + +test('the Console hire start refuses a triage template', async (t) => { + const f = hires(t); + await refuses(f.call(f.owner, 'hire.start.console', f.hire())); + assert.equal(f.decisions(), 0); +}); + +test('the chief hire.raise refuses a triage template at org, project and root level', async (t) => { + const f = hires(t); + await refuses(f.call(f.chief, 'hire.raise', f.hire())); + await refuses(f.call(f.chief, 'hire.raise', f.hire({ level: 'project', project: 'stack' }))); + await refuses(f.call(f.chief, 'hire.raise', f.hire({ level: 'root' }))); + assert.equal(f.decisions(), 0); +}); + +test('the chief decision.raise naming role.hire or role.change refuses a triage template', async (t) => { + const f = hires(t); + await refuses(f.call(f.chief, 'decision.raise', { action: 'role.hire', hire: f.hire() })); + await refuses(f.call(f.chief, 'decision.raise', { action: 'role.change', hire: f.hire({ op: 'change', name: 'coder' }) })); + assert.equal(f.decisions(), 0); +}); + +test('the Console hire template list omits triage and keeps the rest', async (t) => { + const f = hires(t); + const names = (await f.call(f.owner, 'hire.templates.console')).templates.map((x) => x.name); + assert.ok(!names.includes('triage')); + assert.ok(names.includes('coder') && names.includes('reviewer')); +}); + +// The guard: a shipped pack previews and applies as before, and an installed pack with no triage loads. +test('the shipped coding pack and an installed pack without triage preview as before', async (t) => { + const h = await runtime(t); + const preview = await h.call('pack.preview.console', { pack: 'coding' }); + assert.match(preview.digest, /^[a-f0-9]{64}$/); + h.install({ ...codingPack(), id: 'plain', label: 'Plain' }); + const plain = await h.call('pack.preview.console', { pack: 'plain' }); + assert.match(plain.digest, /^[a-f0-9]{64}$/); + const out = await h.call('pack.apply.console', { pack: 'coding', digest: preview.digest }); + assert.deepEqual(out.hires.map((x) => [x.name, x.state]), [['pm-1', 'hired'], ['coder-1', 'hired'], ['reviewer-1', 'hired']]); +}); diff --git a/packages/organization/src/agent-levels.mjs b/packages/organization/src/agent-levels.mjs index f69082218..7f0ec81e9 100644 --- a/packages/organization/src/agent-levels.mjs +++ b/packages/organization/src/agent-levels.mjs @@ -9,6 +9,7 @@ import { join } from "node:path"; import { refuse } from "./errors.mjs"; import { checkDefinitions } from "./definitions.mjs"; import { loadRole } from "./role.mjs"; +import { SYSTEM_ONLY_REFUSAL, systemOnly } from "./vocabulary.mjs"; import { checkVars, mergeVars, REGISTRY } from "./vars.mjs"; import { deepFreeze, isPlainObject, readJsonFile, rejectUnknownKeys, requireDistinctList, requireId, requireObject } from "./util.mjs"; @@ -27,6 +28,8 @@ export function rootAgentsPath(configDir) { function definitionOf(name, at, rolesDir, cache, definitions = {}) { if (typeof name === "string" && name.startsWith("org:") && Object.hasOwn(definitions,name)) return definitions[name]; requireId(name, `${at}.definition`); + // #1873 triage-fence: no root or project agent, and so no copy of one, names a system-only template. + if (systemOnly(name)) refuse(`${SYSTEM_ONLY_REFUSAL}: ${at}.definition names ${name}, a template no organization may hold`); if (!cache.has(name)) { // A role refusal names host paths; this message travels to the Console, so it names none. try { cache.set(name, loadRole(rolesDir, name)); } diff --git a/packages/organization/src/definition-verbs.mjs b/packages/organization/src/definition-verbs.mjs index 87316f0a5..1d596d3c1 100644 --- a/packages/organization/src/definition-verbs.mjs +++ b/packages/organization/src/definition-verbs.mjs @@ -15,6 +15,7 @@ import { OrganizationError } from "./organization.mjs"; import { diffDefinition, entryFromTemplate, instancesNaming, readTemplate, templateHashes, checkDefinitionName, ORG_PREFIX, } from "./definitions.mjs"; +import { SYSTEM_ONLY_REFUSAL, systemOnly } from "./vocabulary.mjs"; // The verb names the policy table maps, following R1's hire.resolve.console. export const DEFINITION_VERBS = Object.freeze({ @@ -64,6 +65,8 @@ export function definitionVerbs({ writer, rolesDir, assertClean }) { // Copies a template into definitions with from set to its name and current hash. function importTemplate(id, { revision, template, as = template }, caller) { authorize(caller, "import"); + // #1873 triage-fence: no organization imports a system-only template. + if (systemOnly(template)) fail(SYSTEM_ONLY_REFUSAL); checkDefinitionName(as, "definition name"); const source = readTemplate(rolesDir, template); const result = writer.setDefinition(id, as, (current) => { @@ -125,5 +128,5 @@ export function definitionVerbs({ writer, rolesDir, assertClean }) { return { organization: id, revision, ...diffDefinition(document, name, rolesDir) }; } - return { import: importTemplate, edit, invent, remove, list, show, diff, templates: () => templateHashes(rolesDir) }; + return { import: importTemplate, edit, invent, remove, list, show, diff, templates: () => templateHashes(rolesDir).filter(({ template }) => !systemOnly(template)) }; } diff --git a/packages/organization/src/definitions.mjs b/packages/organization/src/definitions.mjs index 13056173e..dd8b29081 100644 --- a/packages/organization/src/definitions.mjs +++ b/packages/organization/src/definitions.mjs @@ -23,7 +23,7 @@ import { createHash } from "node:crypto"; import { refuse } from "./errors.mjs"; import { buildRegistry, checkComposition } from "./composition.mjs"; import { validateRoleDocument } from "./role.mjs"; -import { ID_PATTERN } from "./vocabulary.mjs"; +import { ID_PATTERN, SYSTEM_ONLY_REFUSAL, systemOnly } from "./vocabulary.mjs"; import { canonicalJson, deepFreeze } from "./util.mjs"; export const ORG_PREFIX = "org:"; @@ -88,6 +88,8 @@ export function checkDefinition(name, entry, { assertClean = NO_STORE, where = " keysOnly(entry.from, FROM_KEYS, `${at}.from`); if (typeof entry.from.template !== "string" || !ID_PATTERN.test(entry.from.template)) refuse(`${at}.from.template must be a template name matching ${ID_PATTERN}`); if (typeof entry.from.sha256 !== "string" || !HEX64.test(entry.from.sha256)) refuse(`${at}.from.sha256 must be 64 lowercase hex characters`); + // #1873 triage-fence: no organization definition copies a system-only template. + if (systemOnly(entry.from.template)) refuse(`${SYSTEM_ONLY_REFUSAL}: ${at}.from.template names ${entry.from.template}, a template no organization may hold`); } if (!plain(entry.role)) refuse(`${at}.role must be a JSON object`); keysOnly(entry.role, ROLE_KEYS, `${at}.role`); diff --git a/packages/organization/src/hire-decisions.mjs b/packages/organization/src/hire-decisions.mjs index a3e3ea085..ec561672f 100644 --- a/packages/organization/src/hire-decisions.mjs +++ b/packages/organization/src/hire-decisions.mjs @@ -8,7 +8,7 @@ import { compositionOf, entryFromTemplate, readTemplate, templateHashes } from ' import { readRootAgentsFile, changeRootAgent } from './agent-levels-write.mjs'; import { validateBusinessDocument } from './organization-config.mjs'; import { canonicalJson, isPlainObject, readJsonFile } from './util.mjs'; -import { ID_PATTERN, NETWORKS } from './vocabulary.mjs'; +import { ID_PATTERN, NETWORKS, SYSTEM_ONLY_REFUSAL, systemOnly } from './vocabulary.mjs'; import { OrganizationError } from './organization.mjs'; import { resolveInstance } from './resolve.mjs'; import { checkRoutes } from './launch-settings.mjs'; @@ -204,6 +204,8 @@ export function hireDecisions({ writer, rolesDir, configDir, dataRoot, assertCle if ('template' in input.role) { id(input.role.template); if (!/^[a-f0-9]{64}$/.test(input.role.sha256??'') || Object.keys(input.role).length!==2) fail('invalid-request'); } if ('definition' in input.role) { id(input.role.definition); if (!Number.isSafeInteger(input.role.rev) || Object.keys(input.role).length!==2) fail('invalid-request'); } if ('inline' in input.role && Object.keys(input.role).length!==1) fail('invalid-request'); + // #1873 triage-fence: no hire or change at any level copies a system-only template. + if (systemOnly(input.role.template)) fail(SYSTEM_ONLY_REFUSAL); } else if (['role','route','credentials','personality'].some(k=>k in input)) fail('invalid-request'); const {document:doc,revision} = writer.read(business); const loaded = validateBusinessDocument(doc,`${business}.json`,{rolesDir,dataRoot}); @@ -226,6 +228,7 @@ export function hireDecisions({ writer, rolesDir, configDir, dataRoot, assertCle if ('template' in ref) { const template=readTemplate(rolesDir,ref.template); if(template.sha256!==ref.sha256) fail('decision-stale'); entry=entryFromTemplate(template); } else if ('definition' in ref) { entry=doc.definitions?.[ref.definition]; if(!entry || entry.rev!==ref.rev) fail('definition-rev-conflict'); entry=structuredClone(entry); } else entry={rev:1,role:{},instructions:''}; + if (systemOnly(entry.from?.template)) fail(SYSTEM_ONLY_REFUSAL); let c='inline' in ref ? structuredClone(ref.inline) : compositionOf(entry); if ('credentials' in input) c.credentials=structuredClone(input.credentials); if ('personality' in input) c.personality=structuredClone(input.personality); @@ -387,5 +390,5 @@ export function hireDecisions({ writer, rolesDir, configDir, dataRoot, assertCle const result=writer.reverseHireDecision(business,p,{...caller,beforeWrite:guard,beforePublish:publicationGuard}); return {...result,...(r.op==='change' && stopped?.running?{relaunch:publicOf(p)}:{})}; } - return {prepare,reverse,templates:()=>({templates:templateHashes(rolesDir).map(({template,sha256})=>({name:template,sha256}))}),preview:async(business,decision,caller)=>{const p=await adjusted(business,decision,caller.adjust);if(Date.parse(p.expiresAt)<=(caller.now??Date.now)())fail('decision-expired');authorizeHire(publicOf(p),caller);return publicOf(p);},rootRefusal,rootActive:name=>rootRefusal(name)===null,check:async(...args)=>{await check(...args);},apply,read: decision => publicOf(read(decision))}; + return {prepare,reverse,templates:()=>({templates:templateHashes(rolesDir).filter(({template})=>!systemOnly(template)).map(({template,sha256})=>({name:template,sha256}))}),preview:async(business,decision,caller)=>{const p=await adjusted(business,decision,caller.adjust);if(Date.parse(p.expiresAt)<=(caller.now??Date.now)())fail('decision-expired');authorizeHire(publicOf(p),caller);return publicOf(p);},rootRefusal,rootActive:name=>rootRefusal(name)===null,check:async(...args)=>{await check(...args);},apply,read: decision => publicOf(read(decision))}; } diff --git a/packages/organization/src/instance-settings.mjs b/packages/organization/src/instance-settings.mjs index a3e7214c5..98be6faed 100644 --- a/packages/organization/src/instance-settings.mjs +++ b/packages/organization/src/instance-settings.mjs @@ -14,7 +14,7 @@ import { resolveInstance } from "./resolve.mjs"; import { loadRole } from "./role.mjs"; import { refuse } from "./errors.mjs"; import { isPlainObject, canonicalJson } from "./util.mjs"; -import { CREATIVE_DEFINITIONS, CREATIVE_SERVICE, END_PROTECTED, HOST_SERVICE, ID_PATTERN, checkGrantScope, grantScopeOf } from "./vocabulary.mjs"; +import { CREATIVE_DEFINITIONS, CREATIVE_SERVICE, END_PROTECTED, HOST_SERVICE, ID_PATTERN, SYSTEM_ONLY_REFUSAL, checkGrantScope, grantScopeOf, systemOnly } from "./vocabulary.mjs"; const SET_KEYS = ["revision", "instance", "op", "definition", "vars", "launch", "tracker"]; const VETO_KEYS = ["revision", "op", "name"]; @@ -93,6 +93,8 @@ const sameCredentialServices = (before, after) => credentialServices(before).joi // Row 194 (brief item 7): the human's add passes credentials true and lifts it. The tester's add, // change and hire keep it. function definitionFor(rolesDir, name, { credentials = false } = {}) { + // #1873 triage-fence: no add or change of definition gives an instance a system-only template. + if (systemOnly(name)) throw new OrganizationError(SYSTEM_ONLY_REFUSAL); if (closed(name)) throw new OrganizationError("organization-definition-refused"); const definition = loadRole(rolesDir, name); if (definition.roleVersion !== 2) throw new OrganizationError("invalid-request", `role definition ${name} is version 1`); @@ -153,6 +155,8 @@ export function instanceSettings({ dir, rolesDir, system, levels = () => null, r const out = {}; for (const file of readdirSync(rolesDir).filter(f => f.endsWith(".json")).sort()) { const name = file.slice(0, -5); + // #1873 triage-fence: the add list never offers a system-only template. + if (systemOnly(name)) continue; let definition; try { definition = loadRole(rolesDir, name); diff --git a/packages/organization/src/organization-config.mjs b/packages/organization/src/organization-config.mjs index 7d9fc6fb0..4e295a356 100644 --- a/packages/organization/src/organization-config.mjs +++ b/packages/organization/src/organization-config.mjs @@ -12,7 +12,7 @@ import { checkVars } from "./vars.mjs"; import { parseCredentialRef } from "./credentials.mjs"; import { loadRole } from "./role.mjs"; import { checkDefinition, checkDefinitions, checkDefinitionName, orgDefinitionName, ORG_PREFIX } from "./definitions.mjs"; -import { END_PROTECTED, parseRepoRemote } from "./vocabulary.mjs"; +import { END_PROTECTED, parseRepoRemote, SYSTEM_ONLY_REFUSAL, systemOnly } from "./vocabulary.mjs"; import { checkPlugins, checkUsageSettings, NAME as KIND_NAME } from "../../plugins/src/kinds.mjs"; import { checkMapping } from "../../library/src/mapping.mjs"; import { forkProblem, giteaName, parseGiteaUrl, HOST_SERVICE, CREATIVE_DEFINITIONS } from "./vocabulary.mjs"; @@ -113,6 +113,8 @@ function checkPin(pin, where) { if (!shape) refuse(`${where} must be {template, sha256}, {definition, rev} or {inline}`); if (shape[0] === "template") { requireId(pin.template, `${where}.template`); + // #1873 triage-fence: no pack proposal pins a system-only template. + if (systemOnly(pin.template)) refuse(`${SYSTEM_ONLY_REFUSAL}: ${where}.template names ${pin.template}, a template no organization may hold`); if (typeof pin.sha256 !== "string" || !HEX64.test(pin.sha256)) refuse(`${where}.sha256 must be 64 lowercase hex characters`); } else if (shape[0] === "definition") { checkDefinitionName(pin.definition, `${where}.definition`); @@ -285,8 +287,11 @@ function checkRoles(roles, file, rolesDir, business, hasLibrary, orgDefinitions) rejectUnknownKeys(entry, ["definition", "holder", "vars", "tracker", "credentials", "identity", "publish", "hosts", "hireDecision"], at); // #1873 T1: "org:" names one of this file's definitions; anything else is a template. const orgName = orgDefinitionName(entry.definition); - if (orgName === null) requireId(entry.definition, `${at}.definition`); - else if (!Object.hasOwn(orgDefinitions, ORG_PREFIX + checkDefinitionName(orgName, `${at}.definition after org:`))) { + if (orgName === null) { + requireId(entry.definition, `${at}.definition`); + // #1873 triage-fence: no instance names a system-only template. + if (systemOnly(entry.definition)) refuse(`${SYSTEM_ONLY_REFUSAL}: ${at}.definition names ${entry.definition}, a template no organization may hold`); + } else if (!Object.hasOwn(orgDefinitions, ORG_PREFIX + checkDefinitionName(orgName, `${at}.definition after org:`))) { refuse(`definition-missing: ${at}.definition names ${ORG_PREFIX}${orgName}, which definitions doesn't declare`); } const definition = Object.hasOwn(definitions, entry.definition) ? definitions[entry.definition] diff --git a/packages/organization/src/vocabulary.mjs b/packages/organization/src/vocabulary.mjs index 4aa764ae8..06deb5f7d 100644 --- a/packages/organization/src/vocabulary.mjs +++ b/packages/organization/src/vocabulary.mjs @@ -209,6 +209,15 @@ export const THREAD_DEFINITIONS = Object.freeze([THREAD_DEFINITION, ...CREATIVE_ // organization write may give an instance one of them, except the human's instances.set for a // creative definition (row 213). export const END_PROTECTED = THREAD_DEFINITIONS; +// #1873 lane triage-fence: the shipped templates no organization may hold. Jason approved the +// Triage template on 2026-11-16; its use outside an organization waits for his ruling. Every path +// by which an organization could gain a role reads this list and refuses with SYSTEM_ONLY_REFUSAL: +// a hire or change at org, project or root level, a pack preview or apply, instances.set, the +// organization file's own validation, and every template list a page offers. The template itself +// still loads and validates as a template. +export const SYSTEM_ONLY = Object.freeze(["triage"]); +export const SYSTEM_ONLY_REFUSAL = "template-system-only"; +export const systemOnly = name => typeof name === "string" && SYSTEM_ONLY.includes(name); // Row 199 (#1697, design D9c): the Gitea URL parse. It lives here because the broker reads it and // this file imports nothing. Gitea's name rule for users and repositories: letters, digits, "_", "." diff --git a/packages/organization/tests/system-only.test.mjs b/packages/organization/tests/system-only.test.mjs new file mode 100644 index 000000000..5e2d9e46b --- /dev/null +++ b/packages/organization/tests/system-only.test.mjs @@ -0,0 +1,209 @@ +// #1873 lane triage-fence: the Triage template is system-only. Jason approved the template on +// 2026-11-16; no organization may hold it until he rules on its use outside one. Every place an +// organization could gain it refuses with one code, template-system-only, and the template itself +// still loads and validates as a template. Fixtures live in a temp directory. +import test from "node:test"; +import assert from "node:assert/strict"; +import { mkdirSync, mkdtempSync, rmSync } from "node:fs"; +import { join } from "node:path"; +import { tmpdir } from "node:os"; +// A namespace import, so a run against the commit before the fence fails test by test, not at load. +import * as vocabulary from "../src/vocabulary.mjs"; +import { checkDefinition, entryFromTemplate, readTemplate, templateHash, templateHashes } from "../src/definitions.mjs"; +import { loadRole } from "../src/role.mjs"; +import { validateBusinessDocument } from "../src/organization-config.mjs"; +import { checkProjectAgents, checkRootAgents } from "../src/agent-levels.mjs"; +import { hireDecisions } from "../src/hire-decisions.mjs"; +import { instanceSettings } from "../src/instance-settings.mjs"; +import { definitionVerbs } from "../src/definition-verbs.mjs"; +import { organizationWriter } from "../src/organization.mjs"; +import { ROLE_RIGHTS } from "../src/org-rights.mjs"; +import { checkPack, installedStarterPacks } from "../../plugins/src/starter-pack.mjs"; +import { businessDoc, rolesCopy, systemFor, tmp, writeJson } from "./helpers.mjs"; + +const CODE = "template-system-only"; +const coded = (e) => e?.code === CODE; +const prefixed = (e) => e?.name === "BusinessError" && e.message.startsWith(`${CODE}: `); +const OWNER = { actor: "jason", agent: false, rights: ["org.hire"], owner: true, instanceOwner: true, subject: { provider: "test", iss: "https://test", sub: "owner" } }; +const DEF_OWNER = { actor: "jason", rights: [...ROLE_RIGHTS.owner], agent: false }; +const ROUTE = { harness: "pi", model: "claude-opus-5-5" }; + +function rootDir(t) { + const root = tmp(); + t.after(() => rmSync(root, { recursive: true, force: true })); + return root; +} + +function hireSetup(t) { + const root = mkdtempSync(join(tmpdir(), "so-")); + t.after(() => rmSync(root, { recursive: true, force: true })); + const rolesDir = rolesCopy(root); + writeJson(join(root, "businesses/demo.json"), { ...businessDoc(root, "demo"), plugins: { harness: ["pi"] } }); + const writer = organizationWriter({ dir: root, rolesDir }); + const dataRoot = join(root, "data"); + mkdirSync(dataRoot, { mode: 0o700 }); + const service = hireDecisions({ writer, rolesDir, configDir: root, dataRoot, assertClean: () => {} }); + const triage = { template: "triage", sha256: templateHash(rolesDir, "triage") }; + let n = 0; + const prepare = (extra) => service.prepare("demo", { op: "hire", level: "org", name: "sorter", role: triage, route: ROUTE, reason: "Sort the inbox", ...extra }, + { id: `1111111${n++}-1111-4111-8111-111111111111`, expiresAt: "2099-01-01T00:00:00.000Z" }); + return { root, rolesDir, writer, service, prepare, triage }; +} + +function settingsSetup(t) { + const root = rootDir(t); + const rolesDir = rolesCopy(root); + const dir = join(root, "config"); + const doc = businessDoc(root, "acme"); + doc.plugins = { harness: ["pi", "claude-code"] }; + writeJson(join(dir, "businesses", "acme.json"), doc); + return { rolesDir, settings: instanceSettings({ dir, rolesDir, system: systemFor(root) }) }; +} + +function verbsSetup(t) { + const root = rootDir(t); + const dir = join(root, "config"); + const rolesDir = rolesCopy(root); + writeJson(join(dir, "businesses/acme.json"), businessDoc(root)); + const writer = organizationWriter({ dir, rolesDir }); + return { root, dir, rolesDir, writer, verbs: definitionVerbs({ writer, rolesDir, assertClean: () => {} }) }; +} + +test("the list is one name, triage, and its refusal code is template-system-only", () => { + assert.deepEqual([...(vocabulary.SYSTEM_ONLY ?? [])], ["triage"]); + assert.equal(vocabulary.SYSTEM_ONLY_REFUSAL, CODE); + assert.equal(vocabulary.systemOnly?.("triage"), true); + assert.equal(vocabulary.systemOnly?.("coder"), false); + assert.equal(vocabulary.systemOnly?.(undefined), false); +}); + +test("triage still loads and validates as a template", (t) => { + const rolesDir = rolesCopy(rootDir(t)); + const role = loadRole(rolesDir, "triage"); + assert.equal(role.roleVersion, 2); + const source = readTemplate(rolesDir, "triage"); + assert.match(source.sha256, /^[a-f0-9]{64}$/); + assert.ok(templateHashes(rolesDir).some(({ template }) => template === "triage")); +}); + +test("hire refuses a triage template at org level", async (t) => { + const f = hireSetup(t); + await assert.rejects(f.prepare(), coded); +}); + +test("hire refuses a triage template at project level", async (t) => { + const f = hireSetup(t); + await assert.rejects(f.prepare({ level: "project", project: "stack" }), coded); +}); + +test("hire refuses a triage template at root level", async (t) => { + const f = hireSetup(t); + await assert.rejects(f.prepare({ level: "root" }), coded); +}); + +test("a change refuses to move an org instance onto triage", async (t) => { + const f = hireSetup(t); + await assert.rejects(f.prepare({ op: "change", name: "coder" }), coded); +}); + +test("the hire template list a page offers omits triage and keeps every other template", (t) => { + const f = hireSetup(t); + const offered = f.service.templates().templates.map(({ name }) => name); + assert.ok(!offered.includes("triage")); + assert.deepEqual(offered, templateHashes(f.rolesDir).map(({ template }) => template).filter((n) => n !== "triage")); +}); + +test("instances add refuses triage for the human and the tester", (t) => { + const f = settingsSetup(t); + for (const actor of ["jason", "tester"]) { + const revision = f.settings.read("acme").revision; + assert.throws(() => f.settings.set("acme", { revision, instance: "sorter", op: "add", definition: "triage" }, actor), coded, actor); + } +}); + +test("instances change of definition refuses triage", (t) => { + const f = settingsSetup(t); + const revision = f.settings.read("acme").revision; + assert.throws(() => f.settings.set("acme", { revision, instance: "coder", op: "change", definition: "triage" }, "jason"), coded); +}); + +test("the instances add list omits triage", (t) => { + const f = settingsSetup(t); + assert.equal(Object.hasOwn(f.settings.read("acme").definitions, "triage"), false); +}); + +test("an organization file whose roles name triage is refused", (t) => { + const root = rootDir(t); + const rolesDir = rolesCopy(root); + const doc = businessDoc(root); + doc.roles.sorter = { definition: "triage" }; + assert.throws(() => validateBusinessDocument(doc, join(root, "acme.json"), { rolesDir }), prefixed); +}); + +test("an organization definition copied from triage is refused", (t) => { + const rolesDir = rolesCopy(rootDir(t)); + const entry = entryFromTemplate(readTemplate(rolesDir, "triage")); + assert.throws(() => checkDefinition("sorter", entry), prefixed); +}); + +test("a root agent naming triage is refused", (t) => { + const rolesDir = rolesCopy(rootDir(t)); + assert.throws(() => checkRootAgents({ agentsVersion: 1, agents: { sorter: { definition: "triage" } } }, { rolesDir }), prefixed); +}); + +test("a project agent naming triage is refused", (t) => { + const rolesDir = rolesCopy(rootDir(t)); + assert.throws(() => checkProjectAgents({ sorter: { definition: "triage" } }, { rolesDir, where: "projects.stack.agents" }), prefixed); +}); + +test("a pack record proposing a triage hire is refused", (t) => { + const root = rootDir(t); + const rolesDir = rolesCopy(root); + const doc = businessDoc(root); + doc.packs = [{ id: "coding", version: "1.0.0", sha256: "a".repeat(64), origin: "shipped", scope: "org", project: null, + at: "2026-11-12T20:00:00.000Z", by: "jason", added: [], proposedHires: [{ name: "sorter-1", pin: { template: "triage", sha256: "a".repeat(64) } }] }]; + assert.throws(() => validateBusinessDocument(doc, join(root, "acme.json"), { rolesDir }), prefixed); +}); + +test("import refuses triage and the definitions template list omits it", (t) => { + const f = verbsSetup(t); + const revision = f.writer.read("acme").revision; + assert.throws(() => f.verbs.import("acme", { revision, template: "triage" }, DEF_OWNER), coded); + const listed = f.verbs.templates().map(({ template }) => template); + assert.deepEqual(listed, templateHashes(f.rolesDir).map(({ template }) => template).filter((n) => n !== "triage")); +}); + +test("a starter pack naming triage is refused when checked", async (t) => { + const rolesDir = rolesCopy(rootDir(t)); + const { starterPack } = await import("../../plugins/starter-pack/coding/index.mjs"); + const doc = starterPack(); + doc.definitions = { ...doc.definitions, triage: { template: "triage", sha256: templateHash(rolesDir, "triage") } }; + assert.throws(() => checkPack(doc, { origin: "installed", rolesDir, name: doc.id }), coded); +}); + +// The guard: the fence changes nothing for any other template or any shipped pack. +test("every other shipped template imports as before and every shipped pack loads unchanged", async (t) => { + const f = verbsSetup(t); + const all = templateHashes(f.rolesDir).map(({ template }) => template); + const others = all.filter((n) => n !== "triage"); + assert.equal(others.length, all.length - 1); + // Each template's import outcome, measured on 5c7194e05 before the fence: chief-of-staff carries + // role.hire, which a hired agent may not hold, so its import refused before and still does. + const refusedBefore = ["chief-of-staff"]; + const outcome = {}; + for (const template of others) { + try { + f.verbs.import("acme", { revision: f.writer.read("acme").revision, template }, DEF_OWNER); + outcome[template] = "imported"; + } catch (e) { + assert.ok(!String(e.message).includes(CODE) && e.code !== CODE, template); + outcome[template] = "refused"; + } + } + assert.deepEqual(Object.keys(outcome).filter((n) => outcome[n] === "refused"), refusedBefore.filter((n) => others.includes(n))); + const defs = f.writer.read("acme").document.definitions; + assert.deepEqual(Object.keys(defs).sort(), others.filter((n) => outcome[n] === "imported").sort()); + const { packs, refused } = await installedStarterPacks({ dataRoot: null }); + assert.deepEqual(refused, []); + assert.deepEqual(packs.map((p) => p.id).sort(), ["business-management", "coding", "creative-writing", "marketing", "montage"]); +}); diff --git a/packages/plugins/src/starter-pack.mjs b/packages/plugins/src/starter-pack.mjs index 27781f9c6..324a8e2da 100644 --- a/packages/plugins/src/starter-pack.mjs +++ b/packages/plugins/src/starter-pack.mjs @@ -20,7 +20,7 @@ import { fileURLToPath } from "node:url"; import { types } from "node:util"; import { ENTRY_KEYS, checkDefinition, readTemplate } from "../../organization/src/definitions.mjs"; import { parseJsonFileText } from "../../organization/src/util.mjs"; -import { ID_PATTERN, NETWORKS } from "../../organization/src/vocabulary.mjs"; +import { ID_PATTERN, NETWORKS, SYSTEM_ONLY_REFUSAL, systemOnly } from "../../organization/src/vocabulary.mjs"; import { NAME, PluginError } from "./kinds.mjs"; import { hasModule, loadInstalled } from "./loader.mjs"; @@ -163,6 +163,9 @@ function checkDefinitions(definitions, { origin, rolesDir, id }) { const at = `starter pack definitions.${name}`; const entry = definitions[name]; if (!plain(entry)) fail("starter-pack-invalid", `${at} must be a JSON object`, id); + // #1873 triage-fence: a pack never carries a system-only template, as a reference or as a from. + const named = entry.template ?? (plain(entry.from) ? entry.from.template : undefined); + if (systemOnly(named)) fail(SYSTEM_ONLY_REFUSAL, `${at} names template ${named}, which no organization may hold`, id); const keys = Object.keys(entry); if (keys.length === REF_KEYS.length && REF_KEYS.every((k) => keys.includes(k))) { // A template reference: the whole template, pinned by its hash. diff --git a/packages/webui/src/bus.mjs b/packages/webui/src/bus.mjs index cbf0ea0bc..ff7aa7231 100644 --- a/packages/webui/src/bus.mjs +++ b/packages/webui/src/bus.mjs @@ -165,6 +165,8 @@ const STATUS = { // Row 155 (#1649): the assistant's settings, seat names and stop. A name in use or no run to stop // is the user's to resolve by reading again. 'organization-not-assistant': 400, 'organization-definition-refused': 400, 'unknown-model': 400, + // #1873 triage-fence: a template no organization may hold. + 'template-system-only': 400, 'name-taken': 409, 'name-is-instance': 400, 'name-is-role': 400, 'not-assistant': 400, 'not-held': 409, // Row 165 (#1662): role instances. An id already taken is the user's to resolve by reading again. 'organization-instance-exists': 409, 'organization-unknown-instance': 400, diff --git a/packages/webui/src/decision-http.mjs b/packages/webui/src/decision-http.mjs index e64d16e1e..d0ac4078c 100644 --- a/packages/webui/src/decision-http.mjs +++ b/packages/webui/src/decision-http.mjs @@ -67,6 +67,7 @@ const HIRE_START_REFUSALS = { 'unknown-model': [409, 'This model is not one of the organization\'s models. Pick a model listed under Settings > Model proxy.' + NONE], 'harness-off': [409, 'This harness is not switched on for the organization. Pick a harness listed under Settings > Routing, or ask the owner to switch it on.' + NONE], 'harness-refused': [409, 'The harness refused this route. Clear Thinking, or pick another model or harness under Settings > Routing.' + NONE], + 'template-system-only': [409, 'This role template is for the system, not for an organization. Pick another template.' + NONE], 'definition-not-hireable': [409, 'This organization does not hire agents from this role template. Pick another template.' + NONE], 'definition-shared': [409, 'Another agent uses the same role definition, so this change cannot replace it.' + NONE], 'definition-rev-conflict': [409, 'The role definition changed since it was read. Reload the page and propose again.' + EITHER], diff --git a/packages/webui/src/packs-http.mjs b/packages/webui/src/packs-http.mjs index fdf59c63b..432dd9bdd 100644 --- a/packages/webui/src/packs-http.mjs +++ b/packages/webui/src/packs-http.mjs @@ -41,7 +41,7 @@ const REVISION = /^[a-f0-9]{64}$/; // A board or workflow body stays small; the organization config caps both (WORKFLOWS_MAX, board columns). const LIMIT = 65536; const codes = { - 'invalid-request': 400, 'credential-leak': 400, 'starter-pack-invalid': 400, 'definition-invalid': 400, + 'invalid-request': 400, 'credential-leak': 400, 'starter-pack-invalid': 400, 'definition-invalid': 400, 'template-system-only': 400, 'starter-pack-not-found': 404, 'project-not-found': 404, 'pack-not-applied': 404, 'pack-plan-stale': 409, 'revision-conflict': 409, 'organization-busy': 409, 'human-required': 403, 'read-only': 403, 'right-required': 403, diff --git a/packages/webui/src/public/packs.js b/packages/webui/src/public/packs.js index 4add1b7aa..6c45699e9 100644 --- a/packages/webui/src/public/packs.js +++ b/packages/webui/src/public/packs.js @@ -20,6 +20,7 @@ 'starter-pack-template-changed': 'A role template this pack pins has changed. The pack needs a new version.', 'starter-pack-invalid': 'This pack does not pass its checks against the organization.', 'definition-invalid': 'A role in this pack does not pass the organization checks.', + 'template-system-only': 'This pack names a role template that is for the system, not for an organization. It cannot be applied.', 'project-not-found': 'That project is not in the organization file.', 'credential-leak': 'The pack carries a value the credential store holds. It cannot be applied.', 'read-only': 'This Console was started without send. Packs can be previewed, not applied.', diff --git a/packages/webui/src/serve.mjs b/packages/webui/src/serve.mjs index 73390ed37..993632a64 100644 --- a/packages/webui/src/serve.mjs +++ b/packages/webui/src/serve.mjs @@ -425,6 +425,7 @@ const INSTANCE_REASONS = { 'organization-unknown-instance': 'the business has no such instance; add it instead', 'organization-definition-refused': 'this form neither adds nor changes an assistant, and moves no instance to the assistant definition; an assistant changes only in the Assistant section', 'organization-launch-not-configured': 'the business file has no launch block, so launch membership can\'t change', + 'template-system-only': 'that role template is for the system, not for an organization; pick another definition', 'organization-no-change': 'the business file already says that', 'organization-project-mismatch': 'a project file\'s id differs from its key in the business file; mosaic org config validate shows it', 'organization-unresolvable-instance': 'an instance wouldn\'t resolve against a project file; mosaic org config validate shows why',