Test the scorer's code-health weight and each failure it names

This commit is contained in:
2026-11-18 16:33:09 +01:00
parent e82e5c3876
commit c1d7ecf421
2 changed files with 30 additions and 1 deletions
+2 -1
View File
@@ -46,7 +46,7 @@ def ranked(items: list[EpicItem], formula: str, epic_goals: str, repos: dict[str
if each.repo not in scorings:
if each.repo is not None and each.repo not in repos:
return Failure(f"{name} is in the repo {each.repo}, whose goals were not read")
scoring = chain_scoring(parsed, epic_goals, each.repo, repos.get(each.repo or ""))
scoring = chain_scoring(parsed, epic_goals, each.repo, repos[each.repo] if each.repo else None)
if isinstance(scoring, Failure):
return scoring
scorings[each.repo] = scoring
@@ -69,6 +69,7 @@ def chain_scoring(formula: ast.Expression, epic_goals: str, repo: str | None, pr
overall = latest_overall(premises.history) if premises and CODE_HEALTH in dict(goals) else None
if isinstance(overall, Failure):
return Failure(f"{repo}: {overall.reason}")
# goal_weights fails only on a goal without a mark, which the check above already named by whose it is.
weights = goal_weights(goals, overall, premises.floor if premises else decimal.Decimal(0))
return weights if isinstance(weights, Failure) else ranking.Scoring(SHAPE, formula, 0, 0, dict(goals), weights)