diff --git a/fleetd/src/test/java/dev/ltms/fleet/member/CompositePeerLauncherTest.java b/fleetd/src/test/java/dev/ltms/fleet/member/CompositePeerLauncherTest.java index afbe51f..f06d74e 100644 --- a/fleetd/src/test/java/dev/ltms/fleet/member/CompositePeerLauncherTest.java +++ b/fleetd/src/test/java/dev/ltms/fleet/member/CompositePeerLauncherTest.java @@ -1147,12 +1147,17 @@ class CompositePeerLauncherTest { Map profiles = ordered( "sol", stubWorker("sol", "shared-openai"), "b", stubWorker("b")); - StubLauncher adapter = new StubLauncher("claude", herdr, profiles, "sol", Set.of()); + // The adapter's OWN fallback default is "b", deliberately different from the profile place() + // decides ("sol") — see the note below on why this must not be "sol" too. + StubLauncher adapter = new StubLauncher("claude", herdr, profiles, "b", Set.of()); BackendQuarantine quarantine = new BackendQuarantine(() -> 0L, TimeUnit.MINUTES.toNanos(30)); CompositePeerLauncher composite = new CompositePeerLauncher(List.of(adapter), "sol", profiles, PlacementPolicies.fixed(), _ -> 0, null, quarantine); // 1. Resolve BEFORE anything is quarantined — sol (definition order first, fixed policy) wins. + // composite's own defaultProfile ("sol", the constructor arg above) never enters this: the + // pool poolFor(DEV) resolves to is never empty here, so place() only ever reads that field as + // a fallback for an empty pool, which this test does not exercise. PlacementDecision decision = composite.place(MemberRole.DEV); assertEquals("sol", decision.profile(), "sanity: nothing is quarantined yet, so sol is placed"); @@ -1167,9 +1172,18 @@ class CompositePeerLauncherTest { assertEquals("sol", handle.profile(), "the decision from place() is honored even though sol is now quarantined"); + // A fixture whose adapter falls back to "sol" too would let an UNSTAMPED request (one + // routed but never given req.withProfile("sol")) land on spawnCount("sol") == 1 by + // COINCIDENCE, since StubLauncher.spawn falls back to its own defaultProfile whenever + // req.profileName() is blank. Giving the adapter "b" as its fallback instead means only an + // actually-stamped request can produce this count — an unstamped one would count against + // "b" and this assertion would fail. assertEquals(1, adapter.spawnCount("sol"), - "the request that reached the delegate actually carried sol as its profile"); - assertEquals(0, adapter.spawnCount("b"), "b must never be touched — the decision named sol"); + "the request that reached the delegate actually carried sol as its profile " + + "(the adapter's own fallback default is 'b', so this can't happen by accident)"); + assertEquals(0, adapter.spawnCount("b"), + "b must never be touched — neither as the decision's profile nor as an unstamped " + + "request's accidental fallback"); } @Test