test(model-proxy): models-offered re-check round 3: a model kept on while its account is signed out counts against the 256 limit, so a save past it is models-invalid before any in-use ask and writes nothing; a save keeps every model seen before, so one away at the save and back later is not New (#1873, lane models-offered)
This commit was merged in pull request #2022.
This commit is contained in:
1 parent
dde3ee4140
commit
d752e75359
1 file changed
+34
@@ -155,6 +155,40 @@ test('a model in use whose account is signed out: the seed keeps it on, the firs
|
|||||||
assert.deepEqual(readOffered(fresh.dataRoot).offered.providers.codex, { on: ['gpt-5', 'gpt-5-pro'], seen: ['gpt-5', 'gpt-5-pro'] });
|
assert.deepEqual(readOffered(fresh.dataRoot).offered.providers.codex, { on: ['gpt-5', 'gpt-5-pro'], seen: ['gpt-5', 'gpt-5-pro'] });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test(`a model kept on while its account is signed out counts against the ${MAX_ON} limit; a save past it is models-invalid before any ask, and writes nothing`, async t => {
|
||||||
|
const present = Array.from({ length: MAX_ON - 3 }, (_, i) => entry('zai', `glm-${i}`));
|
||||||
|
const away = Array.from({ length: 10 }, (_, i) => `gone-${i}`);
|
||||||
|
const routes = { instances: { chief: { model: 'first' } }, providerModels: { first: entry('zai', 'glm-0') } };
|
||||||
|
const c = control(t, { riders: [rider('acme', present, routes)] });
|
||||||
|
const all = present.map(m => m.model);
|
||||||
|
writeOffered(c.dataRoot, { version: 1, providers: { 'z.ai': { on: [...away, ...all.slice(0, MAX_ON - 10)], seen: [...away, ...all] } } });
|
||||||
|
const before = readOffered(c.dataRoot);
|
||||||
|
// glm-0 is in use and this switches it off, but the list is too long first: no ask for a save that cannot be written.
|
||||||
|
await assert.rejects(c.modelsSet({ provider: 'z.ai', on: all.slice(1), revision: before.revision }), { code: 'models-invalid' }, `${all.length - 1} on plus 10 kept is past ${MAX_ON}`);
|
||||||
|
await assert.rejects(c.modelsSet({ provider: 'z.ai', on: all.slice(1), revision: before.revision, confirmInUse: true }), { code: 'models-invalid' });
|
||||||
|
assert.equal(readOffered(c.dataRoot).revision, before.revision);
|
||||||
|
assert.deepEqual(c.receipts, []);
|
||||||
|
const saved = await c.modelsSet({ provider: 'z.ai', on: all.slice(7), revision: before.revision, confirmInUse: true });
|
||||||
|
assert.equal(saved.on, MAX_ON - 10);
|
||||||
|
const after = readOffered(c.dataRoot);
|
||||||
|
assert.equal(after.state, 'ok', 'the file it writes still reads');
|
||||||
|
assert.equal(after.offered.providers['z.ai'].on.length, MAX_ON);
|
||||||
|
assert.deepEqual(after.offered.providers['z.ai'].on.slice(-10), away);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('a save keeps every model seen before, so one away at the save and back later is not New', async t => {
|
||||||
|
let models = [entry('codex', 'gpt-5')];
|
||||||
|
const acme = { ...rider('acme', []), call: async () => ({ instances: {}, catalogue: { status: 'ready', models } }) };
|
||||||
|
const c = control(t, { riders: [acme] });
|
||||||
|
writeOffered(c.dataRoot, { version: 1, providers: { codex: { on: ['gpt-5'], seen: ['gpt-5', 'gpt-old'] } } });
|
||||||
|
await c.modelsSet({ provider: 'codex', on: ['gpt-5'], revision: readOffered(c.dataRoot).revision });
|
||||||
|
assert.deepEqual(readOffered(c.dataRoot).offered.providers.codex.seen, ['gpt-5', 'gpt-old']);
|
||||||
|
models = [entry('codex', 'gpt-5'), entry('codex', 'gpt-old')];
|
||||||
|
const view = await c.models();
|
||||||
|
const old = view.providers.find(p => p.provider === 'codex').models.find(m => m.id === 'gpt-old');
|
||||||
|
assert.deepEqual([old.on, old.isNew], [false, false]);
|
||||||
|
});
|
||||||
|
|
||||||
test('the receipt bounds every list at 32 with a count of the rest', async t => {
|
test('the receipt bounds every list at 32 with a count of the rest', async t => {
|
||||||
const many = Array.from({ length: 40 }, (_, i) => entry('zai', `glm-${i}`));
|
const many = Array.from({ length: 40 }, (_, i) => entry('zai', `glm-${i}`));
|
||||||
const instances = Object.fromEntries(many.map((m, i) => [`agent-${i}`, { model: `k${i}` }]));
|
const instances = Object.fromEntries(many.map((m, i) => [`agent-${i}`, { model: `k${i}` }]));
|
||||||
|
|||||||
Reference in new issue
Block a user