From f7c0e4f46c4f8dd41a6d6f90149c92c5d856bcc7 Mon Sep 17 00:00:00 2001 From: Jason Woltje Date: Thu, 19 Nov 2026 11:14:06 -0600 Subject: [PATCH 1/2] fix(bus): a bus that picked up the shared proxy says on its catalogue that a restart is needed to start agents on these models (#1873, lane pickup-launch) A picked-up client serves accounts and the catalogue, but a launch on it is refused at bus admission (model-provider-unavailable): the host launcher keeps its boot system with no proxy, and the bus has no ModelKeys. While the bus holds a late client and the catalogue is not disabled, the catalogue appends one notice after its own: "Restart this organization to start agents on these models." A boot proxy, a disabled catalogue, refused settings and a dropped client carry no such notice. Tests cover the launch refusal, refused settings, a dropped client and a key scan over the launch path. --- packages/bus/src/runtime.mjs | 13 +- packages/bus/tests/pickup-launch.test.mjs | 290 ++++++++++++++++++++++ 2 files changed, 301 insertions(+), 2 deletions(-) create mode 100644 packages/bus/tests/pickup-launch.test.mjs diff --git a/packages/bus/src/runtime.mjs b/packages/bus/src/runtime.mjs index e6e10a8dd..35b839828 100644 --- a/packages/bus/src/runtime.mjs +++ b/packages/bus/src/runtime.mjs @@ -887,8 +887,17 @@ export async function startBroker({ // One check at a time; an unexpected failure drops a late client, never keeps it. const syncProxy = () => (proxySync = proxySync.then(pickProxy).catch(() => dropLateProxy('The model proxy could not be checked (proxy-down). Try again shortly.'))); // Unavailable with no client: the catalogue names the cause instead of a bare unavailable. - const explainCatalogue = value => value?.status === 'unavailable' && value.reason === undefined && !modelProxyClient && proxyCause - ? { ...value, reason: 'proxy-not-configured', notices: [proxyCause] } : value; + // pickup-launch: a late client serves accounts and the catalogue, but a launch on it needs what + // only the start path builds (ModelKeys here, the proxy in the host launcher's boot system), so + // while this bus holds one its catalogue says plainly that a restart is needed. + const RESTART_TO_LAUNCH = 'Restart this organization to start agents on these models.'; + const explainCatalogue = value => { + if (value?.status === 'unavailable' && value.reason === undefined && !modelProxyClient && proxyCause) + return { ...value, reason: 'proxy-not-configured', notices: [proxyCause] }; + if (lateProxy && value?.status !== 'disabled') + return { ...value, notices: [...(value?.notices ?? []), RESTART_TO_LAUNCH] }; + return value; + }; const baseCatalogue = settings ? createModelCatalogue({ pluginDataRoot:instanceRoot ?? dataRoot, client: () => modelProxyClient, settings: id => settings.current(id).plugins ?? {}, // A view, so a lock taken by a later pickup or init counts as it does for the start path's. proxyLock: { assertCertain: () => proxyLock?.assertCertain(), generation: () => proxyLock?.generation() } }) : null; diff --git a/packages/bus/tests/pickup-launch.test.mjs b/packages/bus/tests/pickup-launch.test.mjs new file mode 100644 index 000000000..579e87f5f --- /dev/null +++ b/packages/bus/tests/pickup-launch.test.mjs @@ -0,0 +1,290 @@ +// #1873 pickup-launch: a bus that picked up the shared proxy late serves accounts and a ready +// catalogue, but a launch on a proxy model still needs a restart (no ModelKeys on the bus, no proxy +// in the host launcher's boot system). While it holds such a client, its catalogue answer says so +// in one plain notice, and a launch refuses exactly as before. A refused or dropped client shows +// its cause instead. Real buses, a real launcher whose model ops go to the bus, a fake loopback +// management server; no live config. +import test from 'node:test'; +import assert from 'node:assert/strict'; +import fs from 'node:fs'; +import http from 'node:http'; +import { join } from 'node:path'; +import { tmpdir } from 'node:os'; +import { createHash, randomBytes } from 'node:crypto'; +import { pathToFileURL } from 'node:url'; +import { startBroker } from '../src/runtime.mjs'; +import { busOrganization } from '../src/organization-context.mjs'; +import { createProxyLock } from '../src/proxy-lock.mjs'; +import { Registry, launchLogFile } from '../../seat/src/session.mjs'; +import { loadBusiness } from '../../organization/src/organization-config.mjs'; +import { resolveInstance } from '../../organization/src/resolve.mjs'; +import { businessDoc, rolesCopy, systemFor, writeJson } from '../../organization/tests/helpers.mjs'; +import { PIN } from '../../model-proxy/src/common.mjs'; +import { initializeProxy, installPaths, loadProxy } from '../../model-proxy/src/settings.mjs'; +import { createLauncher } from '../../cli/src/launcher.mjs'; +import { initializeControl } from '../../processing-control/src/state.mjs'; +import { ZAI_URL } from '../../plugins/model-provider/cliproxy/index.mjs'; +import { fakeHarnesses, humanEnv, withoutHostCredentials } from '../../cli/tests/helpers.mjs'; +import { REPO_SKILLS } from '../../harness/tests/helpers.mjs'; + +const RESTART = 'Restart this organization to start agents on these models.'; +const MODEL = 'claude-claude-opus-5-5'; +const sha = value => createHash('sha256').update(value).digest('hex'); + +// A loopback stand-in for the proxy's management API: one ready Claude account with one model, +// and an access key list that keeps what a PUT sends, so a boot ModelKeys reconciles against it. +async function fakeProxy(t, key, port = 0, { groups = [] } = {}) { + const seen = { calls: 0, wrongKey: 0 }; + let accessKeys = []; + const server = http.createServer((req, res) => { + seen.calls++; + if (req.headers.authorization !== `Bearer ${key}`) { seen.wrongKey++; res.writeHead(401); res.end('{}'); return; } + const url = new URL(req.url, 'http://127.0.0.1'); + if (url.pathname === '/v8/management/config/access/api-keys' && req.method === 'PUT') { + const chunks = []; + req.on('data', c => chunks.push(c)); + req.on('end', () => { accessKeys = JSON.parse(Buffer.concat(chunks)); res.end(JSON.stringify({ status: 'ok' })); }); + return; + } + const answer = url.pathname === '/v8/management/credentials' ? { files: [{ id: 'acct-1', name: 'acct-1', provider: 'claude', status: 'ready', priority: 1 }] } + : url.pathname === '/v8/management/credentials/models' ? { models: [{ id: 'claude-opus-5-5' }] } + : url.pathname === '/v8/management/config/api-keys/claude' ? groups + : url.pathname === '/v8/management/config/access/api-keys' ? accessKeys + : null; + if (answer === null) { res.writeHead(404); res.end('{}'); return; } + res.end(JSON.stringify(answer)); + }); + await new Promise((resolve, reject) => { server.once('error', reject); server.listen(port, '127.0.0.1', resolve); }); + t.after(async () => { server.closeAllConnections(); await new Promise(resolve => server.close(resolve)); }); + return { port: server.address().port, seen, server }; +} + +// One instance (config dir + data root) and a fake proxy install whose bytes a test pin names. +function instance(t) { + const root = fs.mkdtempSync(join(tmpdir(), 'pl-')); + t.after(() => fs.rmSync(root, { recursive: true, force: true })); + const configDir = join(root, 'config'), dataRoot = join(root, 'instance'); + fs.mkdirSync(join(configDir, 'secrets', 'agents'), { recursive: true, mode: 0o700 }); + fs.chmodSync(join(configDir, 'secrets'), 0o700); + fs.mkdirSync(dataRoot, { mode: 0o700 }); + const paths = installPaths(dataRoot); + fs.mkdirSync(join(paths.dir, 'static'), { recursive: true, mode: 0o700 }); + fs.writeFileSync(paths.binary, 'fixture proxy binary\n', { mode: 0o700 }); + fs.writeFileSync(paths.panel, '\n', { mode: 0o600 }); + const pin = { ...PIN, binary: { ...PIN.binary, sha256: sha('fixture proxy binary\n') }, panel: { ...PIN.panel, sha256: sha('\n') } }; + const rolesDir = rolesCopy(root), system = systemFor(root); + const key = `pl1873-${randomBytes(24).toString('hex')}`; + return { root, configDir, dataRoot, paths, pin, rolesDir, system, key }; +} + +// A real organization bus on the instance, started with no proxy unless `binding.proxy` gives one. +async function orgBus(t, f, id, { providers = ['cliproxy'], binding = {} } = {}) { + const doc = businessDoc(f.root, id); + doc.plugins = { harness: ['pi'], 'model-provider': providers }; + writeJson(join(f.configDir, 'businesses', `${id}.json`), doc); + const business = loadBusiness(id, { dir: f.configDir, rolesDir: f.rolesDir }), resolved = {}; + for (const name of Object.keys(business.roles)) resolved[name] = resolveInstance({ system: f.system, business, instance: name }); + const dataRoot = join(f.root, `${id}-bus`); fs.mkdirSync(dataRoot, { mode: 0o700 }); new Registry(dataRoot); + const bus = await startBroker({ dataRoot, businesses: { [id]: busOrganization(business, resolved) }, + organization: { dir: f.configDir, rolesDir: f.rolesDir, system: f.system }, + instanceRoot: f.dataRoot, org: { id }, instanceDataRoot: f.dataRoot, instanceConfigDir: f.configDir, + initProxy: args => initializeProxy({ ...args, pin: f.pin }), ...binding }); + t.after(() => bus.close().catch(() => {})); + const human = bus.broker.bindHuman({ business: id, human: 'jason', via: 'cli', outsideAgent: true }); + const ask = (verb, args) => Promise.resolve().then(() => bus.broker.request(human, { verb, args })); + return { id, bus, ask, dataRoot }; +} + +// Every stderr line written while `run` is in flight. +async function capture(run) { + const write = process.stderr.write, lines = []; + process.stderr.write = (chunk, ...rest) => { lines.push(String(chunk)); return write.call(process.stderr, chunk, ...rest); }; + try { return { value: await run(), lines }; } finally { process.stderr.write = write; } +} + +async function initThroughA(t, f, a, options) { + const settings = await a.ask('proxy.init', { key: f.key }); + const proxy = await fakeProxy(t, f.key, settings.port, options); + return { settings, proxy }; +} + +// The owner picks the catalogue's proxy model for the coder on the Routing page, through the bus. +async function pickModel(o) { + const view = await o.ask('routes'); + assert.equal(view.catalogue.status, 'ready'); + assert.ok(view.catalogue.models.some(m => m.key === MODEL)); + await o.ask('routes.set', { revision: view.revision, routes: { coder: { harness: 'pi', model: MODEL, thinking: 'low', fallback: null } } }); +} + +// The host launcher as cli.mjs builds it for a bus that booted with no proxy.json: its system has +// no proxy. The model ops go to the bus itself; the rest are the launch-routes stub, and +// authorizeLaunch stops a launch that passed every check before it. +async function hostLauncher(t, f, o, { system = {} } = {}) { + initializeControl(o.dataRoot); + // A launch whose role names a skill that is not enabled refuses before the model gate. + if (!fs.existsSync(join(f.dataRoot, 'skills-enabled'))) fs.cpSync(REPO_SKILLS, join(f.dataRoot, 'skills-enabled'), { recursive: true }); + const env = withoutHostCredentials(humanEnv({ MOSAIC_CONFIG: join(f.configDir, 'config.json'), MOSAIC_ROLES_DIR: f.rolesDir }), { piKey: true }); + const answers = [], ops = []; + const host = { business: o.id, beforeClose: () => {}, op: async m => { + ops.push(m.op); + if (m.op === 'identity') return { business: o.id, role: 'pm' }; + if (m.op === 'mayLaunch') return { allow: true }; + if (m.op === 'modelAdmission' || m.op === 'modelPreflight') { const answer = await o.bus[m.op](m); answers.push({ op: m.op, answer }); return answer; } + if (m.op === 'authorizeLaunch') throw Object.assign(Error('fixture authorization stop'), { code: 'fixture-policy' }); + return {}; + } }; + const cliproxy = JSON.stringify(pathToFileURL(new URL('../../plugins/model-provider/cliproxy/index.mjs', import.meta.url).pathname).href); + const makeLoader = await fakeHarnesses(t, { pi: null }, write => write('model-provider', 'cliproxy', `export * from ${cliproxy};\n`)); + // The validated system config shape (mosaic-config.mjs), as cli.mjs passes it with the org root. + const config = { configVersion: 1, environment: 'development', dataRoot: o.dataRoot, instanceRoot: f.dataRoot, + execution: { backend: 'docker', provider: 'zai', model: 'glm-5.3-flash', adapter: 'mock' }, ...system }; + const launcher = createLauncher({ host, system: config, env, makeLoader, bwrap: '/usr/bin/true', log: () => {} }); + t.after(() => launcher.close?.().catch?.(() => {})); + const events = () => { try { return fs.readFileSync(launchLogFile(o.dataRoot, o.id), 'utf8').trim().split('\n').filter(Boolean).map(l => JSON.parse(l)); } catch { return []; } }; + return { launch: () => launcher.fromSession('fixture-cap', 'coder'), answers, ops, events }; +} + +const restartNotices = view => view.catalogue.notices.filter(n => n === RESTART).length; + +test('a bus that picked up the proxy says on its ready catalogue that a restart starts agents on these models, and the launch refuses as before', async t => { + const f = instance(t); + const a = await orgBus(t, f, 'alpha'), b = await orgBus(t, f, 'beta'); + const before = await b.ask('routes'); + assert.equal(before.catalogue.status, 'unavailable'); + assert.equal(restartNotices(before), 0, 'no client yet: the not-set-up cause, not the restart notice'); + await initThroughA(t, f, a); + await pickModel(b); + const view = await b.ask('routes'); + assert.equal(view.catalogue.status, 'ready'); + assert.equal(restartNotices(view), 1); + assert.equal(restartNotices(await b.ask('routes')), 1, 'one notice at every read'); + // The bus that ran init holds a client it did not boot with too. + const own = await a.ask('routes'); + assert.equal(own.catalogue.status, 'ready'); + assert.equal(restartNotices(own), 1); + // The launch refuses as before, with the existing code and line, before any key or run: the + // launcher booted with no proxy sends no proxy transport, and the bus's admission refuses that. + const host = await hostLauncher(t, f, b); + assert.deepEqual(await host.launch(), { ok: false, error: 'model-provider-unavailable' }); + assert.deepEqual(host.answers, [{ op: 'modelAdmission', answer: { allow: false, code: 'model-provider-unavailable' } }]); + assert.equal(host.ops.includes('authorizeLaunch'), false); + assert.equal(host.ops.includes('modelPreflight'), false); + const refused = host.events().filter(e => e.event === 'refused'); + assert.equal(refused.length, 1); + assert.equal(refused[0].code, 'model-provider-unavailable'); + assert.equal(refused[0].why, 'model cliproxy/claude/claude-opus-5-5 unavailable (model-provider-unavailable)'); + // The bus side has no ModelKeys: a preflight issues no key. + assert.equal(await b.bus.modelPreflight({ business: 'beta', role: 'coder' }), null); +}); + +test('the restart notice is added after the notices the catalogue already carries', async t => { + const f = instance(t); + const a = await orgBus(t, f, 'alpha'), b = await orgBus(t, f, 'beta'); + // A z.ai upstream group with no models: the cliproxy catalogue's own notice. + await initThroughA(t, f, a, { groups: [{ 'base-url': ZAI_URL, keys: [{ name: 'group-1' }] }] }); + const view = await b.ask('routes'); + assert.equal(view.catalogue.status, 'ready'); + assert.deepEqual(view.catalogue.notices, ['z.ai account has no models configured. Add them on Model proxy.', RESTART]); +}); + +test('a bus started with the proxy shows no restart notice', async t => { + const f = instance(t); + const a = await orgBus(t, f, 'alpha'); + await initThroughA(t, f, a); + const c = await orgBus(t, f, 'gamma', { binding: { proxy: loadProxy(f.configDir, f.dataRoot) } }); + const view = await c.ask('routes'); + assert.equal(view.catalogue.status, 'ready', JSON.stringify(view.catalogue)); + assert.deepEqual(view.catalogue.notices, []); +}); + +test('an organization with no model provider shows a disabled catalogue with no restart notice', async t => { + const f = instance(t); + const a = await orgBus(t, f, 'alpha'), b = await orgBus(t, f, 'beta', { providers: [] }); + await initThroughA(t, f, a); + await b.ask('proxy.accounts', {}); + assert.ok(b.bus.modelProxy, 'the client is held'); + const view = await b.ask('routes'); + assert.equal(view.catalogue.status, 'disabled'); + assert.deepEqual(view.catalogue.notices, []); +}); + +test('a fenced catalogue on a picked-up client reads unavailable and still says a restart is needed', async t => { + const f = instance(t); + const a = await orgBus(t, f, 'alpha'), b = await orgBus(t, f, 'beta'); + const { proxy } = await initThroughA(t, f, a); + assert.equal((await b.ask('routes')).catalogue.status, 'ready'); + createProxyLock({ stateDir: join(f.dataRoot, 'proxy'), identity: `${f.configDir}:${proxy.port}` }).fence({ org: 'alpha' }); + const view = await b.ask('routes'); + assert.equal(view.catalogue.status, 'unavailable'); + assert.ok(b.bus.modelProxy); + assert.equal(restartNotices(view), 1); +}); + +test('refused settings still refuse the launch and name their cause, not the restart notice', async t => { + const f = instance(t); + const a = await orgBus(t, f, 'alpha'), b = await orgBus(t, f, 'beta'); + await initThroughA(t, f, a); + await pickModel(b); + // The management key file stops being private: the start path refuses it. + fs.chmodSync(join(f.configDir, 'secrets', 'proxy-management.key'), 0o644); + const view = await b.ask('routes'); + assert.equal(view.catalogue.status, 'unavailable'); + assert.equal(view.catalogue.reason, 'proxy-not-configured'); + assert.equal(view.catalogue.notices.length, 1); + assert.match(view.catalogue.notices[0], /management key does not load/); + assert.equal(b.bus.modelProxy, null); + const host = await hostLauncher(t, f, b); + // The bus itself refuses now: the catalogue keeps the model it saw, marked unavailable. + assert.deepEqual(await host.launch(), { ok: false, error: 'model-provider-unavailable' }); + assert.deepEqual(host.answers, [{ op: 'modelAdmission', answer: { allow: false, code: 'model-provider-unavailable' } }]); + assert.match(host.events().at(-1).why, /^model cliproxy\/claude\/claude-opus-5-5 unavailable \(model-provider-unavailable\)$/); +}); + +test('a dropped client refuses the next launch, and the catalogue names the cause instead of the restart notice', async t => { + const f = instance(t); + const a = await orgBus(t, f, 'alpha'), b = await orgBus(t, f, 'beta'); + await initThroughA(t, f, a); + await pickModel(b); + const host = await hostLauncher(t, f, b); + assert.deepEqual(await host.launch(), { ok: false, error: 'model-provider-unavailable' }); + assert.equal(restartNotices(await b.ask('routes')), 1); + fs.rmSync(join(f.configDir, 'proxy.json')); + // The next launch refuses with the same code and line. + assert.deepEqual(await host.launch(), { ok: false, error: 'model-provider-unavailable' }); + assert.deepEqual(host.answers.map(a => a.answer), [{ allow: false, code: 'model-provider-unavailable' }, { allow: false, code: 'model-provider-unavailable' }]); + assert.equal(host.events().filter(e => e.event === 'refused').length, 2); + // The page's next read drops the client and names the cause. + const view = await b.ask('routes'); + assert.equal(b.bus.modelProxy, null); + assert.equal(view.catalogue.status, 'unavailable'); + assert.equal(view.catalogue.reason, 'proxy-not-configured'); + assert.deepEqual(view.catalogue.notices.length, 1); + assert.match(view.catalogue.notices[0], /not been set up/); +}); + +test('the management key is in no stderr line, response, refusal, launch log or file the launch path writes', async t => { + const f = instance(t); + const a = await orgBus(t, f, 'alpha'), b = await orgBus(t, f, 'beta'); + await initThroughA(t, f, a); + await pickModel(b); + const host = await hostLauncher(t, f, b); + const outputs = []; + const { lines } = await capture(async () => { + outputs.push(await b.ask('routes')); + outputs.push(await host.launch()); + outputs.push(await b.bus.modelPreflight({ business: 'beta', role: 'coder' })); + fs.chmodSync(join(f.configDir, 'secrets', 'proxy-management.key'), 0o644); + outputs.push(await b.ask('routes')); + outputs.push(await host.launch()); + fs.chmodSync(join(f.configDir, 'secrets', 'proxy-management.key'), 0o600); + outputs.push(await b.ask('routes')); + outputs.push(await host.launch()); + }); + outputs.push(host.answers, host.events()); + assert.equal(lines.join('').includes(f.key), false, 'stderr'); + assert.equal(JSON.stringify(outputs).includes(f.key), false, 'responses, answers and launch log'); + const walk = dir => fs.readdirSync(dir, { withFileTypes: true }).flatMap(e => e.isDirectory() ? walk(join(dir, e.name)) : e.isFile() ? [join(dir, e.name)] : []); + const files = [...walk(b.dataRoot), ...walk(join(f.dataRoot, 'proxy')).filter(p => !p.endsWith('/config.yaml'))]; + assert.ok(files.some(p => p === launchLogFile(b.dataRoot, 'beta')), 'the launch log is scanned'); + for (const file of files) assert.equal(fs.readFileSync(file).includes(f.key), false, file); +}); -- 2.54.0 From 196505e6ef84e144b49dc17d86b634fc69ae20be Mon Sep 17 00:00:00 2001 From: Jason Woltje Date: Thu, 19 Nov 2026 11:23:16 -0600 Subject: [PATCH 2/2] fix(bus): review round: the restart notice shows only on a ready catalogue, since a fenced, colliding or down proxy still refuses after a restart (#1873, lane pickup-launch) A bus booted with the proxy on a fenced instance reads the same unavailable catalogue, so the notice sent the owner to a restart that stops running agents and starts none. The test proves that and shows the notice again once the fence is gone. The disabled check goes away with it; the disabled test now says the routes verb answers disabled itself. --- packages/bus/src/runtime.mjs | 5 +++-- packages/bus/tests/pickup-launch.test.mjs | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/bus/src/runtime.mjs b/packages/bus/src/runtime.mjs index 35b839828..413028914 100644 --- a/packages/bus/src/runtime.mjs +++ b/packages/bus/src/runtime.mjs @@ -889,12 +889,13 @@ export async function startBroker({ // Unavailable with no client: the catalogue names the cause instead of a bare unavailable. // pickup-launch: a late client serves accounts and the catalogue, but a launch on it needs what // only the start path builds (ModelKeys here, the proxy in the host launcher's boot system), so - // while this bus holds one its catalogue says plainly that a restart is needed. + // while this bus holds one a ready catalogue says plainly that a restart is needed. Not on an + // unavailable one: a fence, a collision or a down proxy still refuses after a restart. const RESTART_TO_LAUNCH = 'Restart this organization to start agents on these models.'; const explainCatalogue = value => { if (value?.status === 'unavailable' && value.reason === undefined && !modelProxyClient && proxyCause) return { ...value, reason: 'proxy-not-configured', notices: [proxyCause] }; - if (lateProxy && value?.status !== 'disabled') + if (lateProxy && value?.status === 'ready') return { ...value, notices: [...(value?.notices ?? []), RESTART_TO_LAUNCH] }; return value; }; diff --git a/packages/bus/tests/pickup-launch.test.mjs b/packages/bus/tests/pickup-launch.test.mjs index 579e87f5f..a0fd89810 100644 --- a/packages/bus/tests/pickup-launch.test.mjs +++ b/packages/bus/tests/pickup-launch.test.mjs @@ -197,7 +197,7 @@ test('a bus started with the proxy shows no restart notice', async t => { assert.deepEqual(view.catalogue.notices, []); }); -test('an organization with no model provider shows a disabled catalogue with no restart notice', async t => { +test('an organization with no model provider shows a disabled catalogue with no restart notice (the routes verb answers disabled itself)', async t => { const f = instance(t); const a = await orgBus(t, f, 'alpha'), b = await orgBus(t, f, 'beta', { providers: [] }); await initThroughA(t, f, a); @@ -208,16 +208,25 @@ test('an organization with no model provider shows a disabled catalogue with no assert.deepEqual(view.catalogue.notices, []); }); -test('a fenced catalogue on a picked-up client reads unavailable and still says a restart is needed', async t => { +test('a fenced catalogue on a picked-up client reads unavailable with no restart notice, since a restart would not help', async t => { const f = instance(t); const a = await orgBus(t, f, 'alpha'), b = await orgBus(t, f, 'beta'); const { proxy } = await initThroughA(t, f, a); - assert.equal((await b.ask('routes')).catalogue.status, 'ready'); + assert.equal(restartNotices(await b.ask('routes')), 1); createProxyLock({ stateDir: join(f.dataRoot, 'proxy'), identity: `${f.configDir}:${proxy.port}` }).fence({ org: 'alpha' }); const view = await b.ask('routes'); assert.equal(view.catalogue.status, 'unavailable'); assert.ok(b.bus.modelProxy); - assert.equal(restartNotices(view), 1); + assert.equal(restartNotices(view), 0); + // A bus that booted with the proxy on the same fenced instance, which is what a restart gives, + // reads the same unavailable catalogue: the restart notice would have sent the owner nowhere. + const c = await orgBus(t, f, 'gamma', { binding: { proxy: loadProxy(f.configDir, f.dataRoot) } }); + assert.equal((await c.ask('routes')).catalogue.status, 'unavailable'); + // Once the fence is gone, the ready catalogue says again that a restart is needed. + fs.rmSync(join(f.dataRoot, 'proxy', 'mosaic-keys.uncertain')); + const after = await b.ask('routes'); + assert.equal(after.catalogue.status, 'ready', JSON.stringify(after.catalogue)); + assert.equal(restartNotices(after), 1); }); test('refused settings still refuse the launch and name their cause, not the restart notice', async t => { -- 2.54.0