feat(models): expose connection affinity and native-state provenance
This commit is contained in:
@@ -82,10 +82,10 @@ test('real HTTP pool fails over 429 to another model and never repeats completed
|
||||
assert.equal(bad.requests[0].headers.authorization, 'Bearer owned-rate-limited');
|
||||
});
|
||||
|
||||
test('pool rotation and weights select members on new Runs; disabled and missing credentials are excluded without requests', async t => {
|
||||
test('explicit Run affinity rotates weighted pool members on new Runs; disabled and missing credentials are excluded without requests', async t => {
|
||||
const f = fixture(t), a = await compatibleFixture(t, () => completion()), b = await compatibleFixture(t, () => completion());
|
||||
const provider = new Provider(), hub = provider.modelHub(f.store), first = add(hub, a, 'A'), second = add(hub, b, 'B');
|
||||
const pool = hub.pool({ name: 'Weighted', strategy: 'weighted', members: [{ connectionId: first.id, weight: 2 }, { connectionId: second.id, weight: 1 }] });
|
||||
const pool = hub.pool({ name: 'Weighted', strategy: 'weighted', affinityScope: 'run', members: [{ connectionId: first.id, weight: 2 }, { connectionId: second.id, weight: 1 }] });
|
||||
hub.select({ type: 'pool', id: pool.id }); const runtime = new Runtime(f.store, provider); t.after(() => runtime.stopAll());
|
||||
for (let index = 0; index < 3; index++) { runtime.start(f.session.id, 'Finish ' + index); await until(() => !runtime.isActive(f.session.id)); }
|
||||
assert.equal(a.requests.length, 2); assert.equal(b.requests.length, 1);
|
||||
|
||||
@@ -51,7 +51,10 @@ test('automatic requirement ranking includes each member stream choice and respe
|
||||
const choices = [];
|
||||
for (let i = 0; i < 3; i++) { const lease = await f.acquire(config); choices.push(lease.member.id); assert.equal(lease.decision.candidates[0].reasons[0].capability, 'streaming'); lease.release(); }
|
||||
assert.deepEqual(choices, [a.id, a.id, b.id]);
|
||||
config.modelRouting.sticky = true; const lease = await f.acquire(config); assert.equal(lease.member.id, b.id); assert.equal(lease.decision.selectedBy, 'sticky'); lease.release();
|
||||
assert.equal(f.hub.sticky.has('owned-run'), false, 'disabled affinity does not remember a hidden connection');
|
||||
config.modelRouting.sticky = true; config.modelRouting.affinityScope = 'run';
|
||||
const first = await f.acquire(config); assert.equal(first.member.id, a.id); assert.notEqual(first.decision.selectedBy, 'sticky'); first.release();
|
||||
const continued = await f.acquire(config); assert.equal(continued.member.id, a.id); assert.equal(continued.decision.selectedBy, 'sticky'); continued.release();
|
||||
});
|
||||
|
||||
test('matching upstream negative/retired metadata excludes automatic candidates, stale model/endpoint metadata does not', async t => {
|
||||
|
||||
Reference in New Issue
Block a user