Coverage for src/lilbee/providers/fleet/groups.py: 100%
14 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-08-14 11:46 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-08-14 11:46 +0000
1"""Swap-group identity for the llama-swap processes that front the fleet."""
3from __future__ import annotations
5from enum import StrEnum
7from lilbee.providers.roles import WorkerRole
10class SwapGroup(StrEnum):
11 """One llama-swap process's group: a role's own, or the shared chat/vision pair."""
13 CHAT = "chat"
14 EMBED = "embed"
15 RERANK = "rerank"
16 VISION = "vision"
17 CO_TENANT = "co-tenant"
19 @property
20 def swaps(self) -> bool:
21 """Whether loading a member evicts its siblings (llama-swap ``swap: true``)."""
22 return self is SwapGroup.CO_TENANT
25def group_for(role: WorkerRole, co_tenants: frozenset[WorkerRole]) -> SwapGroup:
26 """The swap group *role* runs in: the shared co-tenant group, or its own."""
27 return SwapGroup.CO_TENANT if role in co_tenants else SwapGroup(role.value)