Files
jason.woltje e6ab8bc1fd feat(bus,plugins,organization,cli,webui): SP9 remove system types outright, bus schema 3v-3w drops project_system_types (#1873)
Jason's 2026-11-12 ruling: the only deployed system is the dev environment on
dragon-lin, so the system-type plug-in kind goes with no retired kind, fence,
conversion or new refusal code.

- plugins: system-type leaves KINDS; system-types.mjs and the five modules are
  deleted. An org file naming the kind refuses unknown-kind.
- organization: the plugins.system-type check, systemTypesFence and the
  system-types.console right are removed.
- bus: system-types.console, project.system-types[.set], the system-type half
  of the tester check, the runtime reads and system-type-not-enabled are
  removed. Step 3v-3w drops project_system_types, its index, its four guards
  and its rows; SCHEMA_VERSION is 3w (32 tables, 126 triggers, 5 views).
- cli: mosaic org system-types and mosaic project system-types[-set] are
  removed; stack-release COUNTED and the budget supervisor's closed list move
  to 3w.
- channel: the project.system-types verbs are removed.
- webui: the System types page, route, dashboard row, chips and project
  selection are removed.
- docs: REQ-SYS-1/2 now describe starter packs; README system-type text and
  the requirements titles follow.
2026-11-12 21:02:46 -06:00

32 lines
4.2 KiB
JavaScript

import { test } from 'node:test';
import assert from 'node:assert/strict';
import { mkdtempSync, readFileSync } from 'node:fs';
import { join, resolve } from 'node:path';
import { tmpdir } from 'node:os';
import { spawnSync } from 'node:child_process';
const repo = resolve(import.meta.dirname, '../../..');
function run(env, ...args) { return spawnSync(join(repo, 'scripts/mosaic'), args, { cwd: repo, env, encoding: 'utf8' }); }
test('organization CLI renders, validates, creates, updates and initializes git', () => {
const home = mkdtempSync(join(tmpdir(), 'org-cli-')); const env = { ...process.env, HOME: home, MOSAIC_CONFIG: join(home, '.config/mosaic-orgtest/config.json') };
const boot = spawnSync(join(repo, 'scripts/bootstrap.sh'), ['--instance', 'orgtest'], { cwd: repo, env, encoding: 'utf8' }); assert.equal(boot.status, 0, boot.stderr);
const file = join(home, 'alpha.json'); const invoke = (...args) => { const r = run(env, ...args); assert.equal(r.status, 0, r.stderr); return r.stdout; };
invoke('org', 'template', 'render', 'alpha', '--fixture', 'local', '--output', file);
invoke('org', 'validate', file); invoke('org', 'create', 'alpha', '--from', file);
const bootCheck = spawnSync(process.execPath, ['--input-type=module', '-e', `import {loadSystem, bootConfig} from './packages/cli/src/config.mjs'; const system=loadSystem({env:process.env, instance:'orgtest'}); bootConfig({system,businessId:'alpha',env:process.env});`], { cwd: repo, env, encoding: 'utf8' }); assert.equal(bootCheck.status, 0, bootCheck.stderr);
let info = JSON.parse(invoke('org', 'show', 'alpha', '--json')); assert.equal(info.id, 'alpha'); assert.equal(JSON.parse(invoke('org', 'list', '--json')).length, 1);
invoke('org', 'update', 'alpha', '--from', file, '--if-revision', String(info.revision));
invoke('org', 'queue', 'init', 'alpha', '--local-only', '--accept-local-loss-risk'); assert.equal(JSON.parse(invoke('org', 'queue', 'show', 'alpha', '--json')).riskAccepted, true);
invoke('org', 'project', 'repo', 'init', 'alpha', 'work', '--local-only', '--accept-local-loss-risk'); assert.equal(JSON.parse(invoke('org', 'project', 'repo', 'show', 'alpha', 'work', '--json')).project, 'work'); assert.equal(JSON.parse(readFileSync(file)).id, 'alpha');
info = JSON.parse(invoke('org', 'show', 'alpha', '--json')); const archived = JSON.parse(invoke('org', 'archive', 'alpha', '--if-revision', String(info.revision), '--json')); assert.equal(archived.revision, info.revision + 1);
assert.equal(JSON.parse(invoke('org', 'list', '--json'))[0].state, 'archived');
const restored = JSON.parse(invoke('org', 'restore', 'alpha', '--if-revision', String(archived.revision), '--json')); assert.equal(restored.revision, archived.revision + 1);
// E1 (P1-4): restore brings the organization back running; the delete below stops the bus again.
assert.equal(restored.bus.outcome, 'started'); assert.ok(Number.isInteger(restored.bus.pid)); assert.equal(JSON.parse(invoke('bus', 'status', 'alpha', '--json')).healthy, true);
info = JSON.parse(invoke('org', 'show', 'alpha', '--json')); const receipt = JSON.parse(invoke('org', 'delete', 'alpha', '--confirm', 'alpha', '--if-revision', String(info.revision), '--json')); assert.equal(receipt.org, 'alpha'); assert.deepEqual(JSON.parse(invoke('org', 'list', '--json')), []);
});
test('business and org aliases conflict in either order', () => { for (const args of [['--business','alpha','--org','beta'], ['--org','beta','--business','alpha']]) { const r = run(process.env, 'tasks', ...args); assert.notEqual(r.status, 0); assert.match(r.stderr, /conflict/i); } });
import { main } from '../src/cli.mjs';
import { io } from './helpers.mjs';
test('org alias preserves existing command output and matching aliases are accepted', async () => { const seen = []; const deps = { system: { dataRoot: '/unused' }, transport: business => async () => { seen.push(business); return []; } }; const outputs = []; for (const options of [['--business','alpha'], ['--org','alpha'], ['--org','alpha','--business','alpha'], ['--business','alpha','--org','alpha']]) { const x = io(); await main(['tasks', '--json', ...options], x, deps); outputs.push(x.out.text); } assert.deepEqual(seen, ['alpha','alpha','alpha','alpha']); assert.equal(new Set(outputs).size, 1); });