From 196505e6ef84e144b49dc17d86b634fc69ae20be Mon Sep 17 00:00:00 2001 From: Jason Woltje Date: Thu, 19 Nov 2026 11:23:16 -0600 Subject: [PATCH] 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 => {