chore(format): ruff format the 4 drifted files (no behavior change)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaQCFnfsh3tfq1VfzdJpoi
This commit is contained in:
Kjell Tore Guttormsen 2026-07-03 00:32:49 +02:00
commit 705c5dd49a
4 changed files with 95 additions and 31 deletions

View file

@ -73,9 +73,7 @@ class AzureFoundryBackend:
def create_chat_client(self, *, model: str) -> BaseChatClient: def create_chat_client(self, *, model: str) -> BaseChatClient:
endpoint = os.environ.get("PORTFOLIO_FOUNDRY_PROJECT_ENDPOINT") endpoint = os.environ.get("PORTFOLIO_FOUNDRY_PROJECT_ENDPOINT")
if not endpoint: if not endpoint:
raise ValueError( raise ValueError("PORTFOLIO_FOUNDRY_PROJECT_ENDPOINT is required for the AZURE profile")
"PORTFOLIO_FOUNDRY_PROJECT_ENDPOINT is required for the AZURE profile"
)
# Credential resolves lazily via Azure DefaultAzureCredential (az login / MI). # Credential resolves lazily via Azure DefaultAzureCredential (az login / MI).
return FoundryChatClient(project_endpoint=endpoint, model=model) return FoundryChatClient(project_endpoint=endpoint, model=model)

View file

@ -86,9 +86,7 @@ class BudgetMiddleware(ChatMiddleware):
self._meter = meter self._meter = meter
self._strict = strict_usage self._strict = strict_usage
async def process( async def process(self, context: ChatContext, call_next: Callable[[], Awaitable[None]]) -> None:
self, context: ChatContext, call_next: Callable[[], Awaitable[None]]
) -> None:
await call_next() await call_next()
usage = getattr(context.result, "usage_details", None) usage = getattr(context.result, "usage_details", None)
total = usage.get("total_token_count") if usage is not None else None total = usage.get("total_token_count") if usage is not None else None

View file

@ -259,30 +259,95 @@ def seed_store() -> VerdictStore:
"""Seed 12 synthetic verdicts spanning the reference domain's cost codes, measure types, """Seed 12 synthetic verdicts spanning the reference domain's cost codes, measure types,
magnitudes, and decisions (B2 store of 10-20).""" magnitudes, and decisions (B2 store of 10-20)."""
rows = [ rows = [
("V01", {"05.2", "03.1"}, "scope_reduction", 180_000, "approved", (
"asphalt + base course trimmed within feasible range"), "V01",
("V02", {"05.2"}, "rate_renegotiation", 60_000, "approved", {"05.2", "03.1"},
"renegotiated asphalt unit rate"), "scope_reduction",
("V03", {"07.4"}, "material_substitution", 120_000, "rejected", 180_000,
"granite kerb substitution unsafe"), "approved",
("V04", {"09.1"}, "scope_reduction", 240_000, "approved", "asphalt + base course trimmed within feasible range",
"fewer LED masts on low-traffic stretch"), ),
("V05", {"02.3", "03.1"}, "scope_reduction", 350_000, "rejected", (
"soil replacement is load-bearing, cannot cut"), "V02",
("V06", {"21.2"}, "rate_renegotiation", 90_000, "approved", {"05.2"},
"blasting rate renegotiated"), "rate_renegotiation",
("V07", {"22.4"}, "material_substitution", 700_000, "rejected", 60_000,
"fiber shotcrete spec is mandated"), "approved",
("V08", {"88.2"}, "scope_reduction", 150_000, "approved", "renegotiated asphalt unit rate",
"concrete repair area re-measured smaller"), ),
("V09", {"87.3"}, "material_substitution", 130_000, "approved", (
"alternative membrane qualified"), "V03",
("V10", {"05.2", "03.1"}, "rate_renegotiation", 200_000, "approved", {"07.4"},
"combined paving rate discount"), "material_substitution",
("V11", {"01.1"}, "scope_reduction", 95_000, "rejected", 120_000,
"rigging is fixed cost, no scope to cut"), "rejected",
("V12", {"31.3"}, "scope_reduction", 110_000, "approved", "granite kerb substitution unsafe",
"drainage length reduced after survey"), ),
(
"V04",
{"09.1"},
"scope_reduction",
240_000,
"approved",
"fewer LED masts on low-traffic stretch",
),
(
"V05",
{"02.3", "03.1"},
"scope_reduction",
350_000,
"rejected",
"soil replacement is load-bearing, cannot cut",
),
("V06", {"21.2"}, "rate_renegotiation", 90_000, "approved", "blasting rate renegotiated"),
(
"V07",
{"22.4"},
"material_substitution",
700_000,
"rejected",
"fiber shotcrete spec is mandated",
),
(
"V08",
{"88.2"},
"scope_reduction",
150_000,
"approved",
"concrete repair area re-measured smaller",
),
(
"V09",
{"87.3"},
"material_substitution",
130_000,
"approved",
"alternative membrane qualified",
),
(
"V10",
{"05.2", "03.1"},
"rate_renegotiation",
200_000,
"approved",
"combined paving rate discount",
),
(
"V11",
{"01.1"},
"scope_reduction",
95_000,
"rejected",
"rigging is fixed cost, no scope to cut",
),
(
"V12",
{"31.3"},
"scope_reduction",
110_000,
"approved",
"drainage length reduced after survey",
),
] ]
return VerdictStore( return VerdictStore(
verdicts=[ verdicts=[

View file

@ -28,7 +28,10 @@ def test_malformed_data_source_raises() -> None:
def test_malformed_model_map_raises() -> None: def test_malformed_model_map_raises() -> None:
bad_map = {"local": {"proposer": "qwen3:4b"}, "azure": {"default": "x"}} # local missing 'default' bad_map = {
"local": {"proposer": "qwen3:4b"},
"azure": {"default": "x"},
} # local missing 'default'
with pytest.raises(ValidationError): with pytest.raises(ValidationError):
load_contracts(_DS, _TERM, _FB, model_map=bad_map) load_contracts(_DS, _TERM, _FB, model_map=bad_map)