style(fase1): ruff format spike modules
This commit is contained in:
parent
f7a36b59ac
commit
c1317689f1
6 changed files with 123 additions and 26 deletions
|
|
@ -63,9 +63,12 @@ def similarity(query: ProposalFeatures, candidate: ProposalFeatures) -> float:
|
|||
"""Weighted structural similarity in [0, 1] — text is ignored by design."""
|
||||
codes = _jaccard(query.affected_codes, candidate.affected_codes)
|
||||
measure = 1.0 if query.measure_type == candidate.measure_type else 0.0
|
||||
magnitude = 1.0 if _magnitude_bucket(query.claimed_saving_nok) == _magnitude_bucket(
|
||||
candidate.claimed_saving_nok
|
||||
) else 0.0
|
||||
magnitude = (
|
||||
1.0
|
||||
if _magnitude_bucket(query.claimed_saving_nok)
|
||||
== _magnitude_bucket(candidate.claimed_saving_nok)
|
||||
else 0.0
|
||||
)
|
||||
return _W_CODES * codes + _W_MEASURE * measure + _W_MAGNITUDE * magnitude
|
||||
|
||||
|
||||
|
|
@ -106,7 +109,9 @@ class ExpeLContextProvider(ContextProvider):
|
|||
body = "\n".join(f"- [{v.id}] {v.decision}: {v.rationale}" for v in hits)
|
||||
return f"Relevant prior verdicts (ExpeL few-shot):\n{body}"
|
||||
|
||||
async def before_run(self, *, agent: object, session: object, context: object, state: dict) -> None:
|
||||
async def before_run(
|
||||
self, *, agent: object, session: object, context: object, state: dict
|
||||
) -> None:
|
||||
context.extend_instructions([self.format_fewshot()]) # type: ignore[attr-defined]
|
||||
|
||||
|
||||
|
|
@ -114,18 +119,95 @@ def seed_store() -> VerdictStore:
|
|||
"""Seed 12 synthetic verdicts spanning the reference domain's cost codes, measure
|
||||
types, magnitudes, and decisions (B2 store of 10–20)."""
|
||||
rows = [
|
||||
("V01", {"05.2", "03.1"}, "scope_reduction", 180_000, "approved", "asphalt + base course trimmed within feasible range"),
|
||||
("V02", {"05.2"}, "rate_renegotiation", 60_000, "approved", "renegotiated asphalt unit rate"),
|
||||
("V03", {"07.4"}, "material_substitution", 120_000, "rejected", "granite kerb substitution unsafe"),
|
||||
("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"),
|
||||
(
|
||||
"V01",
|
||||
{"05.2", "03.1"},
|
||||
"scope_reduction",
|
||||
180_000,
|
||||
"approved",
|
||||
"asphalt + base course trimmed within feasible range",
|
||||
),
|
||||
(
|
||||
"V02",
|
||||
{"05.2"},
|
||||
"rate_renegotiation",
|
||||
60_000,
|
||||
"approved",
|
||||
"renegotiated asphalt unit rate",
|
||||
),
|
||||
(
|
||||
"V03",
|
||||
{"07.4"},
|
||||
"material_substitution",
|
||||
120_000,
|
||||
"rejected",
|
||||
"granite kerb substitution unsafe",
|
||||
),
|
||||
(
|
||||
"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"),
|
||||
(
|
||||
"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(
|
||||
verdicts=[
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue