372 lines
21 KiB
JavaScript
372 lines
21 KiB
JavaScript
// #1873 proxy-pickup: a running organization bus picks up the shared model proxy that another
|
|
// organization's bus initialized, with no restart, through the start path's loader and lock. A
|
|
// bus whose proxy settings the start path would refuse still refuses, and names the cause in one
|
|
// plain line. Real buses and 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 { startBroker } from '../src/runtime.mjs';
|
|
import { busOrganization } from '../src/organization-context.mjs';
|
|
import { createProxyLock } from '../src/proxy-lock.mjs';
|
|
import { Registry } 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 } from '../../model-proxy/src/settings.mjs';
|
|
import { FIXTURE_ENTRY, FIXTURE_KEY_NAME } from '../../plugins/model-provider/fixture/index.mjs';
|
|
|
|
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.
|
|
async function fakeProxy(t, key, port = 0) {
|
|
const seen = { calls: 0, wrongKey: 0 };
|
|
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');
|
|
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' ? []
|
|
: url.pathname === '/v8/management/config/access/api-keys' ? []
|
|
: 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.
|
|
// The pin keeps the shipped version, so the pinned binary path is the one loadProxy accepts.
|
|
function instance(t) {
|
|
const root = fs.mkdtempSync(join(tmpdir(), 'pk-'));
|
|
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, '<!doctype html>\n', { mode: 0o600 });
|
|
const pin = { ...PIN, binary: { ...PIN.binary, sha256: sha('fixture proxy binary\n') }, panel: { ...PIN.panel, sha256: sha('<!doctype html>\n') } };
|
|
const rolesDir = rolesCopy(root), system = systemFor(root);
|
|
const key = `pk1873-${randomBytes(24).toString('hex')}`;
|
|
return { root, configDir, dataRoot, paths, pin, rolesDir, system, key, closers: [] };
|
|
}
|
|
|
|
// A real organization bus on the instance, started with no proxy (as cli bootConfig does when the
|
|
// instance has no proxy.json at boot).
|
|
async function orgBus(t, f, id, { providers = ['cliproxy'], edit = () => {}, org = { id }, binding = {} } = {}) {
|
|
const doc = businessDoc(f.root, id);
|
|
doc.plugins = { harness: ['pi'], 'model-provider': providers };
|
|
edit(doc);
|
|
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, 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 { 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; }
|
|
}
|
|
|
|
// The proxy init through bus A writes proxy.json and the key, then the proxy starts on that port.
|
|
async function initThroughA(t, f, a) {
|
|
const settings = await a.ask('proxy.init', { key: f.key });
|
|
const proxy = await fakeProxy(t, f.key, settings.port);
|
|
return { settings, proxy };
|
|
}
|
|
|
|
const notConfigured = (pattern) => e => e.code === 'not-configured' && typeof e.reason === 'string' && pattern.test(e.reason) && e.reason.length <= 300;
|
|
|
|
test('a running organization bus answers accounts and a cliproxy catalogue once another bus initialized the shared proxy, with no restart', async t => {
|
|
const f = instance(t);
|
|
const a = await orgBus(t, f, 'alpha'), b = await orgBus(t, f, 'beta');
|
|
// Before init: bus B has nothing to pick up, and says so.
|
|
await assert.rejects(b.ask('proxy.accounts', {}), notConfigured(/not been set up/));
|
|
const before = await b.ask('routes');
|
|
assert.equal(before.catalogue.status, 'unavailable');
|
|
assert.equal(before.catalogue.reason, 'proxy-not-configured');
|
|
assert.equal(before.catalogue.notices.length, 1);
|
|
const { proxy } = await initThroughA(t, f, a);
|
|
// Bus A holds the client from its own init; bus B picks it up at its next read.
|
|
assert.deepEqual((await a.ask('proxy.accounts', {})).accounts.map(r => r.provider), ['claude']);
|
|
const accounts = await b.ask('proxy.accounts', {});
|
|
assert.deepEqual(accounts.accounts.map(r => [r.provider, r.status]), [['claude', 'ready']]);
|
|
const after = await b.ask('routes');
|
|
assert.equal(after.catalogue.status, 'ready');
|
|
assert.deepEqual(after.catalogue.models.map(m => m.key), ['claude-claude-opus-5-5']);
|
|
assert.equal(after.catalogue.reason, undefined);
|
|
assert.equal(proxy.seen.wrongKey, 0);
|
|
// Bus B reached the proxy through the same lock identity the start path uses.
|
|
assert.ok(createProxyLock({ stateDir: join(f.dataRoot, 'proxy'), identity: `${f.configDir}:${proxy.port}` }));
|
|
});
|
|
|
|
test('a bus started before the proxy existed and asked only for a catalogue picks the proxy up', async t => {
|
|
const f = instance(t);
|
|
const a = await orgBus(t, f, 'alpha'), b = await orgBus(t, f, 'beta');
|
|
assert.equal((await b.ask('routes')).catalogue.status, 'unavailable');
|
|
await initThroughA(t, f, a);
|
|
assert.equal((await b.ask('routes')).catalogue.status, 'ready');
|
|
});
|
|
|
|
// Each case writes the shared proxy's files by hand into a state the start path refuses.
|
|
const refusedStates = [
|
|
['proxy.json names an unpinned binary', /settings do not load/, f => writeJson(join(f.configDir, 'proxy.json'), { port: 40999, binary: '/elsewhere/cli-proxy-api' })],
|
|
['proxy.json is not JSON', /settings do not load/, f => fs.writeFileSync(join(f.configDir, 'proxy.json'), '{', { mode: 0o600 })],
|
|
['the management key file is readable by others', /management key does not load/, f => {
|
|
writeJson(join(f.configDir, 'proxy.json'), { port: 40999, binary: f.paths.binary });
|
|
fs.writeFileSync(join(f.configDir, 'secrets', 'proxy-management.key'), f.key, { mode: 0o644 });
|
|
fs.chmodSync(join(f.configDir, 'secrets', 'proxy-management.key'), 0o644);
|
|
}],
|
|
['the management key file is missing', /management key does not load/, f => writeJson(join(f.configDir, 'proxy.json'), { port: 40999, binary: f.paths.binary })],
|
|
['the proxy state names another port', /proxy lock/, f => {
|
|
writeJson(join(f.configDir, 'proxy.json'), { port: 40999, binary: f.paths.binary });
|
|
fs.writeFileSync(join(f.configDir, 'secrets', 'proxy-management.key'), f.key, { mode: 0o600 });
|
|
fs.mkdirSync(join(f.dataRoot, 'proxy'), { mode: 0o700 });
|
|
createProxyLock({ stateDir: join(f.dataRoot, 'proxy'), identity: `${f.configDir}:40998` });
|
|
}],
|
|
['the proxy state directory is open to others', /proxy lock/, f => {
|
|
writeJson(join(f.configDir, 'proxy.json'), { port: 40999, binary: f.paths.binary });
|
|
fs.writeFileSync(join(f.configDir, 'secrets', 'proxy-management.key'), f.key, { mode: 0o600 });
|
|
fs.mkdirSync(join(f.dataRoot, 'proxy'), { mode: 0o755 }); fs.chmodSync(join(f.dataRoot, 'proxy'), 0o755);
|
|
}],
|
|
];
|
|
for (const [name, cause, arrange] of refusedStates) test(`no pickup when ${name}: accounts and catalogue refuse with the cause`, async t => {
|
|
const f = instance(t);
|
|
const b = await orgBus(t, f, 'beta');
|
|
arrange(f);
|
|
await assert.rejects(b.ask('proxy.accounts', {}), notConfigured(cause));
|
|
const view = await b.ask('routes');
|
|
assert.equal(view.catalogue.status, 'unavailable');
|
|
assert.equal(view.catalogue.reason, 'proxy-not-configured');
|
|
assert.match(view.catalogue.notices[0], cause);
|
|
assert.equal(b.bus.modelProxy, null);
|
|
});
|
|
|
|
// The host refuses fixture-proxy-configured only when a dev fixture is recorded for the instance.
|
|
const recordFixture = f => {
|
|
fs.mkdirSync(join(f.dataRoot, 'dev-fixture'), { mode: 0o700 });
|
|
fs.writeFileSync(join(f.dataRoot, 'dev-fixture', 'fixture.json'), '{}\n', { mode: 0o600 });
|
|
};
|
|
|
|
test('no pickup for an organization on the fixture model provider, which the host refuses with a proxy', async t => {
|
|
const f = instance(t);
|
|
recordFixture(f);
|
|
const a = await orgBus(t, f, 'alpha');
|
|
const b = await orgBus(t, f, 'beta', { providers: ['fixture', 'cliproxy'], edit: doc => { doc.launch.models[FIXTURE_KEY_NAME] = { ...FIXTURE_ENTRY }; } });
|
|
await initThroughA(t, f, a);
|
|
await assert.rejects(b.ask('proxy.accounts', {}), notConfigured(/fixture-proxy-configured/));
|
|
assert.equal(b.bus.modelProxy, null);
|
|
const view = await b.ask('routes');
|
|
assert.equal(view.catalogue.reason, 'proxy-not-configured');
|
|
assert.match(view.catalogue.notices[0], /fixture/);
|
|
});
|
|
|
|
test('no pickup for an organization whose launch table names the fixture module only', async t => {
|
|
const f = instance(t);
|
|
recordFixture(f);
|
|
const a = await orgBus(t, f, 'alpha');
|
|
const b = await orgBus(t, f, 'beta', { edit: doc => { doc.launch.models[FIXTURE_KEY_NAME] = { ...FIXTURE_ENTRY }; } });
|
|
await initThroughA(t, f, a);
|
|
await assert.rejects(b.ask('proxy.accounts', {}), notConfigured(/fixture-proxy-configured/));
|
|
assert.equal(b.bus.modelProxy, null);
|
|
});
|
|
|
|
test('an organization that lists the fixture still picks the proxy up when no fixture is recorded, as the host would start it', async t => {
|
|
const f = instance(t);
|
|
const a = await orgBus(t, f, 'alpha');
|
|
const b = await orgBus(t, f, 'beta', { providers: ['fixture', 'cliproxy'] });
|
|
await initThroughA(t, f, a);
|
|
await b.ask('proxy.accounts', {});
|
|
assert.ok(b.bus.modelProxy);
|
|
// A fixture recorded later drops the client at the next request.
|
|
recordFixture(f);
|
|
await assert.rejects(b.ask('proxy.accounts', {}), notConfigured(/fixture-proxy-configured/));
|
|
assert.equal(b.bus.modelProxy, null);
|
|
});
|
|
|
|
test('a picked-up client is dropped when proxy.json goes away, its port changes, or the key stops loading', async t => {
|
|
const f = instance(t);
|
|
const a = await orgBus(t, f, 'alpha'), b = await orgBus(t, f, 'beta');
|
|
const { settings } = await initThroughA(t, f, a);
|
|
await b.ask('proxy.accounts', {});
|
|
assert.ok(b.bus.modelProxy);
|
|
const file = join(f.configDir, 'proxy.json'), keyFile = join(f.configDir, 'secrets', 'proxy-management.key');
|
|
const saved = fs.readFileSync(file);
|
|
// Port change: the lock identity is bound to the port, so the bus refuses until a restart.
|
|
writeJson(file, { ...settings, port: settings.port + 1 === 8317 ? settings.port + 2 : settings.port + 1 });
|
|
await assert.rejects(b.ask('proxy.accounts', {}), notConfigured(/proxy lock/));
|
|
assert.equal(b.bus.modelProxy, null);
|
|
assert.equal((await b.ask('routes')).catalogue.status, 'unavailable');
|
|
// Back to the original port, the bus picks it up again.
|
|
fs.writeFileSync(file, saved);
|
|
await b.ask('proxy.accounts', {});
|
|
assert.ok(b.bus.modelProxy);
|
|
// Key file no longer 0600.
|
|
fs.chmodSync(keyFile, 0o640);
|
|
await assert.rejects(b.ask('proxy.accounts', {}), notConfigured(/management key does not load/));
|
|
assert.equal(b.bus.modelProxy, null);
|
|
fs.chmodSync(keyFile, 0o600);
|
|
await b.ask('proxy.accounts', {});
|
|
// proxy.json removed.
|
|
fs.rmSync(file);
|
|
await assert.rejects(b.ask('proxy.accounts', {}), notConfigured(/not been set up/));
|
|
assert.equal(b.bus.modelProxy, null);
|
|
const view = await b.ask('routes');
|
|
assert.equal(view.catalogue.status, 'unavailable');
|
|
assert.equal(view.catalogue.reason, 'proxy-not-configured');
|
|
});
|
|
|
|
test('a default-instance bus (no organization binding, no lock) follows a port change to the new client, never the old one', async t => {
|
|
const f = instance(t);
|
|
const a = await orgBus(t, f, 'alpha'), d = await orgBus(t, f, 'delta', { org: null });
|
|
const { settings, proxy } = await initThroughA(t, f, a);
|
|
assert.deepEqual((await d.ask('proxy.accounts', {})).accounts.map(r => r.provider), ['claude']);
|
|
const old = d.bus.modelProxy;
|
|
// A listener on the new port that answers nothing to the right key: reaching it proves the move.
|
|
const moved = await fakeProxy(t, `other-${f.key.slice(0, 6)}`);
|
|
writeJson(join(f.configDir, 'proxy.json'), { ...settings, port: moved.port });
|
|
const before = proxy.seen.calls;
|
|
await assert.rejects(d.ask('proxy.accounts', {}));
|
|
assert.ok(d.bus.modelProxy && d.bus.modelProxy !== old);
|
|
assert.ok(moved.seen.calls > 0);
|
|
assert.equal(proxy.seen.calls, before);
|
|
});
|
|
|
|
test('a picked-up bus reads its catalogue through the shared lock: a fence makes it unavailable', 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, 'the client stays; the fence alone holds the catalogue');
|
|
});
|
|
|
|
test('a fixture record path in any state but absent counts as recorded', async t => {
|
|
const f = instance(t);
|
|
fs.writeFileSync(join(f.dataRoot, 'dev-fixture'), 'not a directory\n', { mode: 0o600 });
|
|
const a = await orgBus(t, f, 'alpha');
|
|
const b = await orgBus(t, f, 'beta', { providers: ['fixture', 'cliproxy'] });
|
|
await initThroughA(t, f, a);
|
|
await assert.rejects(b.ask('proxy.accounts', {}), notConfigured(/fixture-proxy-configured/));
|
|
assert.equal(b.bus.modelProxy, null);
|
|
});
|
|
|
|
test('with a fixture recorded, an organization document that no longer validates counts as using it', async t => {
|
|
const f = instance(t);
|
|
recordFixture(f);
|
|
const a = await orgBus(t, f, 'alpha'), b = await orgBus(t, f, 'beta');
|
|
await initThroughA(t, f, a);
|
|
fs.writeFileSync(join(f.configDir, 'businesses', 'beta.json'), '{', { mode: 0o600 });
|
|
await assert.rejects(b.ask('proxy.accounts', {}), notConfigured(/fixture-proxy-configured/));
|
|
assert.equal(b.bus.modelProxy, null);
|
|
});
|
|
|
|
test('the bus that ran init also drops its client when the key stops loading', async t => {
|
|
const f = instance(t);
|
|
const a = await orgBus(t, f, 'alpha');
|
|
await initThroughA(t, f, a);
|
|
await a.ask('proxy.accounts', {});
|
|
fs.rmSync(join(f.configDir, 'secrets', 'proxy-management.key'));
|
|
await assert.rejects(a.ask('proxy.accounts', {}), notConfigured(/management key does not load/));
|
|
assert.equal(a.bus.modelProxy, null);
|
|
});
|
|
|
|
test('an init whose lock refuses leaves the init bus holding no client: no ready catalogue without the lock', async t => {
|
|
const f = instance(t);
|
|
// The real init, then the proxy state dir is left readable by the group, which the lock refuses.
|
|
const initProxy = async args => { const settings = await initializeProxy({ ...args, pin: f.pin });
|
|
fs.mkdirSync(join(f.dataRoot, 'proxy'), { recursive: true }); fs.chmodSync(join(f.dataRoot, 'proxy'), 0o750); return settings; };
|
|
const a = await orgBus(t, f, 'alpha', { binding: { initProxy } });
|
|
await assert.rejects(a.ask('proxy.init', { key: f.key }));
|
|
await fakeProxy(t, f.key, JSON.parse(fs.readFileSync(join(f.configDir, 'proxy.json'), 'utf8')).port);
|
|
assert.equal(a.bus.modelProxy, null);
|
|
const view = await a.ask('routes');
|
|
assert.equal(view.catalogue.status, 'unavailable');
|
|
assert.match(view.catalogue.notices[0], /proxy-lock-invalid/);
|
|
assert.equal(a.bus.modelProxy, null);
|
|
});
|
|
|
|
test('a default-instance bus (no lock generation) refreshes its catalogue at once on pickup and on drop', async t => {
|
|
const f = instance(t);
|
|
const a = await orgBus(t, f, 'alpha'), d = await orgBus(t, f, 'delta', { org: null });
|
|
// An unavailable catalogue read before init must not be served after the pickup.
|
|
assert.equal((await d.ask('routes')).catalogue.status, 'unavailable');
|
|
await initThroughA(t, f, a);
|
|
assert.equal((await d.ask('routes')).catalogue.status, 'ready');
|
|
// A ready catalogue read through the picked-up client must not be served after the drop.
|
|
fs.rmSync(join(f.configDir, 'proxy.json'));
|
|
const gone = await d.ask('routes');
|
|
assert.equal(gone.catalogue.status, 'unavailable');
|
|
assert.equal(gone.catalogue.reason, 'proxy-not-configured');
|
|
assert.equal(d.bus.modelProxy, null);
|
|
});
|
|
|
|
test('a picked-up bus clears a proxy fence through the same client and lock', async t => {
|
|
const f = instance(t);
|
|
const a = await orgBus(t, f, 'alpha'), b = await orgBus(t, f, 'beta');
|
|
await initThroughA(t, f, a);
|
|
// proxy.fence.clear on a bus that has not read anything yet still picks the proxy up first; the
|
|
// restart evidence check is the existing one and refuses this empty evidence.
|
|
await assert.rejects(b.ask('proxy.fence.clear', { evidence: {} }));
|
|
assert.ok(b.bus.modelProxy);
|
|
});
|
|
|
|
test('a bus serving an invalid organization id never picks up a proxy', async t => {
|
|
const f = instance(t);
|
|
const a = await orgBus(t, f, 'alpha');
|
|
await initThroughA(t, f, a);
|
|
let b;
|
|
try { b = await orgBus(t, f, 'beta', { binding: { instanceConfigDir: 42 } }); }
|
|
catch (error) { assert.equal(error.code, 'invalid-host-request'); return; }
|
|
await assert.rejects(b.ask('proxy.accounts', {}), notConfigured(/organization binding/));
|
|
assert.equal(b.bus.modelProxy, null);
|
|
});
|
|
|
|
test('the management key is in no stderr line, response, refusal, event or file the pickup 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);
|
|
const outputs = [];
|
|
const { lines } = await capture(async () => {
|
|
outputs.push(await b.ask('proxy.accounts', {}));
|
|
outputs.push(await b.ask('routes'));
|
|
// A refusal after the key stops loading, and the pickup after it loads again.
|
|
fs.chmodSync(join(f.configDir, 'secrets', 'proxy-management.key'), 0o644);
|
|
await b.ask('proxy.accounts', {}).catch(error => outputs.push({ code: error.code, reason: error.reason, message: error.message, next: error.next }));
|
|
outputs.push(await b.ask('routes'));
|
|
fs.chmodSync(join(f.configDir, 'secrets', 'proxy-management.key'), 0o600);
|
|
outputs.push(await b.ask('proxy.accounts', {}));
|
|
});
|
|
assert.ok(lines.some(line => line.startsWith('model-proxy: ')), 'the pickup client writes its usual receipts');
|
|
assert.equal(lines.join('').includes(f.key), false, 'stderr');
|
|
assert.equal(JSON.stringify(outputs).includes(f.key), false, 'responses');
|
|
// Every file under bus B's data root (store, WAL, sessions) and the proxy state directory,
|
|
// except the proxy's own config.yaml that init writes for the proxy process.
|
|
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.length > 0);
|
|
for (const file of files) assert.equal(fs.readFileSync(file).includes(f.key), false, file);
|
|
});
|