import test from 'node:test'; import assert from 'node:assert/strict'; const live = await import('../live/request-lifecycle.mjs').catch(e => { if (e.code === 'ERR_MODULE_NOT_FOUND' && e.message.includes('live/request-lifecycle.mjs')) return {}; throw e; }); const args = ['--instance','pomo797','--config','/isolated/config.json','--business','demo','--owner','jason','--evidence','/evidence','--request-file','/request.json','--authorize-isolated-run']; test('live runner requires an explicit named isolated instance and owner authorization before reading config', () => { assert.equal(typeof live.parseOptions, 'function'); assert.throws(() => live.parseOptions([]), /instance/); assert.throws(() => live.parseOptions(args.filter(a => a !== '--authorize-isolated-run')), /authorization/); for (const name of ['dev','production','prod','../live','pomo-797']) assert.throws(() => live.parseOptions(args.map(a => a === 'pomo797' ? name : a)), /instance/); assert.equal(live.parseOptions(args).instance, 'pomo797'); }); test('live preflight refuses a production instance, wrong marker/owner, unavailable host or missing factory staff', () => { assert.equal(typeof live.checkResources, 'function'); const options = live.parseOptions(args); const input = { options, system: { environment: 'development', dataRoot: '/isolated/data' }, marker: { instanceVersion: 1, name: options.instance }, business: { id: 'demo', human: 'jason', projects: { factory: { root: '/isolated/factory' } }, roles: { pm: { definition: 'pm' }, cto: { definition: 'cto' }, chief: { definition: 'chief-of-staff' }, coder: { definition: 'coder' }, reviewer: { definition: 'reviewer' } }, arbiters: { technical: 'cto' }, launch: { by: 'chief', instances: ['pm','cto','coder','reviewer'] } }, tracker: { project: 1 }, host: { live: true } }; assert.doesNotThrow(() => live.checkResources(input)); assert.throws(() => live.checkResources({ ...input, system: { ...input.system, environment: 'production' } }), /isolated/); assert.throws(() => live.checkResources({ ...input, marker: { instanceVersion: 1, name: 'other' } }), /instance/); assert.throws(() => live.checkResources({ ...input, options: { ...options, owner: 'other' } }), /owner/); assert.throws(() => live.checkResources({ ...input, host: { live: false } }), /host/); assert.throws(() => live.checkResources({ ...input, tracker: null }), /tracker/); assert.throws(() => live.checkResources({ ...input, business: { ...input.business, launch: { by: 'chief', instances: ['pm','coder'] } } }), /staff/); });