Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
fix(risk): rank a change against the commits before it however it is spelled, and name that sample on the checklist (#4503)
Raghav Chamadiyae41577fa0459
diff --git a/docs/architecture/change-risk.md b/docs/architecture/change-risk.mdindex 6ee32a21c..b08873a51 100644--- a/docs/architecture/change-risk.md+++ b/docs/architecture/change-risk.md@@ -127,8 +127,10 @@ the full `risk_scales` dictionary) never varies, so MCP returns it only for## Baseline sample`repowise risk` samples recent commits live; the web UI reads the indexed-commit history. One walk is reused for every change scored against the same-anchor and filters in a process, so a long-running MCP server pays for it once.+commit history. The sample runs back from the change's parent (a range's+merge-base, uncommitted work's `HEAD`), the same ref its fix history is read at.+One walk is reused for every change scored against the same anchor and filters+in a process, so a long-running MCP server pays for it once per anchor.## Independent changes groupingdiff --git a/docs/layers/CHANGE_RISK.md b/docs/layers/CHANGE_RISK.mdindex 73274cfb4..d9813b7c8 100644--- a/docs/layers/CHANGE_RISK.md+++ b/docs/layers/CHANGE_RISK.md@@ -106,12 +106,13 @@ the indexed commit history.| Subject | Sample runs back from ||---|---|-| A commit in `HEAD`'s history | `HEAD` |-| A commit on another branch | that commit |+| A commit | its first parent || A `base..head` range | the merge-base of the two sides || Uncommitted work | `HEAD` |-A change never ranks against itself.+A change never ranks against itself or anything after it, so a merge reads the same+rank as `sha` or `sha^1..sha`, and in its `changes show` checklist, which names the+sample size and the commit it ran back from.### PR mode (`get_risk` with `changed_files`)diff --git a/packages/core/src/repowise/core/analysis/change_risk/baseline.py b/packages/core/src/repowise/core/analysis/change_risk/baseline.pyindex 6067e3b90..bd1029a04 100644--- a/packages/core/src/repowise/core/analysis/change_risk/baseline.py+++ b/packages/core/src/repowise/core/analysis/change_risk/baseline.py@@ -31,11 +31,11 @@ class BaselineSample(NamedTuple):# Process-wide memo for the 200-commit baseline walk, which is the dominant cost# of a default get_change_risk call and is identical for every change scored-# against the same repo state. Keyed on the *resolved anchor sha* (not the ref-# name) so a new commit on HEAD busts the entry, plus every other input that-# changes the sample (sample size, filters). Deliberately NOT keyed on the-# target being scored: the sample is stored whole and the target's own score is-# dropped when ranking, so two changes against the same history share one walk.+# from the same anchor (a commit's parent, a range's merge-base, HEAD for+# uncommitted work). Keyed on the *resolved anchor sha* (not the ref name) so a+# new commit on HEAD busts the entry, plus every other input that changes the+# sample (sample size, filters), so a commit and its ``sha^..sha`` range, or a+# clean HEAD scored twice, share one walk._BASELINE_CACHE: dict[tuple, list[BaselineSample]] = {}# Crude bound so a long-lived MCP server that scores many distinct changes does# not grow the memo without limit. On overflow the whole cache is dropped@@ -49,7 +49,7 @@ def clear_baseline_cache() -> None:_BASELINE_CACHE.clear()-def _resolve_anchor_sha(repo_path: str, anchor: str) -> str | None:+def resolve_anchor_sha(repo_path: str, anchor: str) -> str | None:"""Resolve *anchor* to a full sha for cache keying, or None if it cannot be.check=False: a bad anchor is not fatal here - it just means we skip caching@@ -62,11 +62,10 @@ def _resolve_anchor_sha(repo_path: str, anchor: str) -> str | None:def _retained(samples: list[BaselineSample], excluded_ref: str) -> list[BaselineSample]:"""The sample with the target commit's own entry removed.- Self-exclusion is a rank-time filter, not a property of the sample, so the- walk is cached whole and each target removes only itself. *excluded_ref* is- a commit sha, full or abbreviated - a ref *name* matches nothing, since the- sample is keyed by sha. Empty means nothing to exclude (a range or an- uncommitted change is not in the sample to begin with). An abbreviation+ The live scorers pass empty: their sample runs back from before the change+ (``service.history_ref``), so the change is never in it. A caller that ranks+ against a sample holding the target passes its sha, full or abbreviated - a+ ref *name* matches nothing, since the sample is keyed by sha. An abbreviationshort enough to prefix-match several shas will drop all of them."""if not excluded_ref:@@ -118,10 +117,9 @@ def baseline_samples() -> list[BaselineSample]:"""Score the repo's recent commits to build a local risk distribution.- Returns :class:`BaselineSample` rows so a caller can exclude the change it- is ranking (see :func:`scores_excluding`) without needing a sample of its- own, and can rank a fix density against the same commits- (see :func:`densities_excluding`).+ Returns :class:`BaselineSample` rows so a caller can rank a diff-shape+ score (see :func:`scores_excluding`) and a fix density+ (see :func:`densities_excluding`) against the same commits.One ``git log --numstat`` call (no per-commit author lookup), so it stayscheap enough for a pre-merge gate. Experience is left unknown for the@@ -186,7 +184,7 @@ def baseline_samples_cached(the entry as soon as a new commit lands. When the anchor cannot be resolvedthe call falls through to an uncached computation."""- sha = _resolve_anchor_sha(repo_path, anchor)+ sha = resolve_anchor_sha(repo_path, anchor)if sha is None:return baseline_samples(repo_path, anchor, limit, extensions, exclude_patterns, include_pathsdiff --git a/packages/core/src/repowise/core/analysis/change_risk/service.py b/packages/core/src/repowise/core/analysis/change_risk/service.pyindex b36112522..719f57bf1 100644--- a/packages/core/src/repowise/core/analysis/change_risk/service.py+++ b/packages/core/src/repowise/core/analysis/change_risk/service.py@@ -10,7 +10,13 @@ from pathlib import Pathfrom ...owned_paths import OWNED_PATTERNSfrom ..git_cli import generated_worktree_pathsfrom ..risk_semantics import change_risk_authority, change_risk_scales-from .baseline import BaselineSample, baseline_samples_cached, densities_excluding, scores_excluding+from .baseline import (+ BaselineSample,+ baseline_samples_cached,+ densities_excluding,+ resolve_anchor_sha,+ scores_excluding,+)from .features import (GIT_TIMEOUT_SECONDS,ChangeFeatures,@@ -66,6 +72,10 @@ class ChangeRiskResult:# line-scoped fix record can be read at the same point. ``None`` when the# change came from file stats with no checkout behind it.history_ref: str | None = None+ # The commit the baseline sample runs back from (the same ref as+ # ``history_ref``, resolved), so a kept rank can say what it ranked+ # against. ``None`` when no sample was walked.+ baseline_as_of: str | None = Nonedef riskignore_patterns(repo_path: str) -> tuple[str, ...]:@@ -103,32 +113,6 @@ def riskignore_patterns(repo_path: str) -> tuple[str, ...]:)-def _commit_anchor(repo_path: str, target: str) -> tuple[str, str]:- """Return ``(anchor, resolved sha)`` for a commit target.-- A commit in ``HEAD``'s history is ranked against the repo's current sample- rather than building a private one, so every such target in a process shares- a single walk. A commit that is not (another branch, an unrelated ref) keeps- its own anchor, since HEAD's history is not its cohort.-- The sha comes back because self-exclusion needs it: the sample holds commit- shas, while the target is whatever the caller spelled — ``"HEAD"`` most of- the time, which matches no sha and so excluded nothing.- """- # ^{commit} peels an annotated tag to the commit it points at. Without it the- # tag object's own sha comes back, which is in no sample and is never equal- # to a merge-base, so both the anchor and the self-exclusion below miss.- target_sha = _git(- ["rev-parse", "--verify", "--quiet", f"{target}^{{commit}}"], repo_path, check=False- ).strip()- if target == "HEAD" or not target_sha:- return "HEAD" if target == "HEAD" else target, target_sha- # merge-base == the target itself is exactly "target is an ancestor of HEAD",- # read off stdout because _git does not surface a return code.- merge_base = _git(["merge-base", target, "HEAD"], repo_path, check=False).strip()- return ("HEAD" if merge_base == target_sha else target), target_sha--def range_anchor(repo_path: str, base: str, head: str) -> str:"""Anchor a range's baseline to where its two sides diverged.@@ -142,9 +126,11 @@ def range_anchor(repo_path: str, base: str, head: str) -> str:def history_ref(repo_path: str, revspec: str | None, *, working_tree: bool = False) -> str:- """The ref a change's fix history is read at: strictly before the change.+ """The ref a change's fix history and baseline sample are read at, before the change.- Uncommitted work reads at ``HEAD``; a range at its merge-base, not at+ One anchor for every spelling, so a merge scored as ``sha`` and as+ ``sha^1..sha`` ranks against the same commits, wherever HEAD has moved+ since. Uncommitted work reads at ``HEAD``; a range at its merge-base, not at``base``'s tip (with three dots the diff starts there, so base's latercommits are not this change's ground); a commit at its parent, so it isnever credited with fixes that only landed because of it. A root commit's@@ -215,11 +201,10 @@ def score_live_change(if working_tree:from_riskignore = worktree_ignoreseffective_excludes = from_riskignore + exclude_patterns- # Ref whose history the fix record is read from (see ``history_ref``).+ # Ref the fix record and the baseline sample are read from (see ``history_ref``).history = history_ref(repo_path, target, working_tree=working_tree)if working_tree:features = uncommitted- anchor, excluded_ref = "HEAD", ""elif (parts := split_revspec(target)) is not None:base, sep, head = partsfeatures = extract_range_features(@@ -231,9 +216,6 @@ def score_live_change(include_paths=include_paths,sep=sep,)- # The baseline shares the fix history's anchor: the range's merge-base.- anchor = history- excluded_ref = ""else:features = extract_commit_features(repo_path,@@ -242,7 +224,6 @@ def score_live_change(exclude_patterns=effective_excludes,include_paths=include_paths,)- anchor, excluded_ref = _commit_anchor(repo_path, target)try:pressure: dict[str, float] | None = fix_pressure(repo_path, history)@@ -250,10 +231,12 @@ def score_live_change(pressure = Nonesamples: list[BaselineSample] = []+ as_of = Noneif baseline:+ as_of = resolve_anchor_sha(repo_path, history)samples = baseline_samples_cached(repo_path,- anchor,+ history,baseline,extensions,exclude_patterns=baseline_excludes,@@ -263,15 +246,16 @@ def score_live_change(result = assess_change(features,fix_pressure=pressure,- baseline_scores=scores_excluding(samples, excluded_ref),- baseline_fix_densities=densities_excluding(samples, excluded_ref, pressure or {}),+ # The sample ends before the change, so there is no self to exclude.+ baseline_scores=scores_excluding(samples, ""),+ baseline_fix_densities=densities_excluding(samples, "", pressure or {}),working_tree=working_tree,riskignore_excludes=from_riskignore,request_excludes=exclude_patterns,)owned = tuple(p for p in from_riskignore if p in OWNED_PATTERNS)owned += generated if working_tree else ()- return replace(result, history_ref=history, owned_excludes=owned)+ return replace(result, history_ref=history, owned_excludes=owned, baseline_as_of=as_of)def assess_change(diff --git a/packages/core/src/repowise/core/changes/evidence.py b/packages/core/src/repowise/core/changes/evidence.pyindex 4605badc9..072e611d1 100644--- a/packages/core/src/repowise/core/changes/evidence.py+++ b/packages/core/src/repowise/core/changes/evidence.py@@ -518,7 +518,11 @@ def _risk(bundle: ChangeReviewBundle) -> EvidenceItem:[{"baseline_sample_size": risk.baseline_sample_size,- "note": "ranks diff size against recent commits; not a defect probability",+ # The commit the sample runs back from: the change's parent+ # (a range's merge-base), so the rank is fixed at the change+ # and matches ``repowise risk`` however the change is spelled.+ "baseline_as_of": risk.baseline_as_of,+ "note": "ranks diff size against the commits before it; not a defect probability",}],source,@@ -652,7 +656,14 @@ def _provenance_line(kind: str, value: Any, rows: list[Mapping[str, Any]]) -> _Ldef _risk_line(kind: str, value: Any, rows: list[Mapping[str, Any]]) -> _Line:- return kind, {"percentile": value.get("percentile")}+ params = {"percentile": value.get("percentile")}+ row = rows[0] if rows else {}+ # A checklist kept before the sample was stamped ranked against HEAD at+ # build time, so it keeps the unlabelled line rather than claim a cohort.+ if not row.get("baseline_as_of"):+ return kind, params+ sample = {"sample": row.get("baseline_sample_size", 0), "as_of": row["baseline_as_of"][:10]}+ return "risk_score_before", {**params, **sample}def _outcomes_line(kind: str, value: Any, rows: list[Mapping[str, Any]]) -> _Line:@@ -773,6 +784,10 @@ _TEXT: dict[str, Any] = {"provenance": _provenance_text,"provenance_named": _provenance_text,"risk_score": lambda k, p: f"Larger than {p['percentile']}% of recent commits",+ "risk_score_before": lambda k, p: (+ f"Larger than {p['percentile']}% of the {_n(p['sample'], 'commit')} before this change "+ f"(as of {p['as_of']})"+ ),"outcomes": _outcomes_text,"outcomes_rate": _outcomes_text,}diff --git a/packages/web/messages/en.json b/packages/web/messages/en.jsonindex c0b6f59a9..870e19d75 100644--- a/packages/web/messages/en.json+++ b/packages/web/messages/en.json@@ -456,6 +456,7 @@"provenance": "provenance: {label}, known for {known} of {commits, plural, one {# commit} other {# commits}}","provenance_named": "provenance: {label}, known for {known} of {commits, plural, one {# commit} other {# commits}} ({names})","risk_score": "Larger than {percentile}% of recent commits",+ "risk_score_before": "Larger than {percentile}% of the {sample, plural, one {# commit} other {# commits}} before this change (as of {as_of})","outcomes": "{reverts, plural, one {# revert} other {# reverts}}, {references, plural, one {# cause reference} other {# cause references}}","outcomes_rate": "{reverts, plural, one {# revert} other {# reverts}}, {references, plural, one {# cause reference} other {# cause references}}; {fixed} of {files, plural, one {# file} other {# files}} fixed within {days} days"},diff --git a/packages/web/messages/zh-CN.json b/packages/web/messages/zh-CN.jsonindex 59815ab62..d36757d36 100644--- a/packages/web/messages/zh-CN.json+++ b/packages/web/messages/zh-CN.json@@ -456,6 +456,7 @@"provenance": "来源:{label},{commits} 个提交中已知 {known} 个","provenance_named": "来源:{label},{commits} 个提交中已知 {known} 个({names})","risk_score": "大于 {percentile}% 的近期提交",+ "risk_score_before": "大于此变更之前的 {sample} 个提交中的 {percentile}%(截至 {as_of})","outcomes": "{reverts} 次回滚,{references} 次被引为原因","outcomes_rate": "{reverts} 次回滚,{references} 次被引为原因;{files} 个文件中有 {fixed} 个在 {days} 天内被修复"},diff --git a/packages/web/src/lib/changes.test.ts b/packages/web/src/lib/changes.test.tsindex 795efb6ed..3aa2c125e 100644--- a/packages/web/src/lib/changes.test.ts+++ b/packages/web/src/lib/changes.test.ts@@ -26,6 +26,7 @@ const LINES: [string, Record<string, unknown>][] = [["provenance", { label: "human attested", known: 3, commits: 4 }],["provenance_named", { label: "agent", known: 1, commits: 1, names: "claude-code, claude-opus-4-5" }],["risk_score", { percentile: 97.5 }],+ ["risk_score_before", { percentile: 72.5, sample: 200, as_of: "6bb3c0c293" }],["outcomes", { reverts: 0, references: 1 }],["outcomes_rate", { reverts: 1, references: 0, fixed: 2, files: 5, days: 90 }],];diff --git a/tests/unit/analysis/test_change_risk.py b/tests/unit/analysis/test_change_risk.pyindex b35e5caf8..fe0ae276f 100644--- a/tests/unit/analysis/test_change_risk.py+++ b/tests/unit/analysis/test_change_risk.py@@ -399,16 +399,72 @@ def test_baseline_cache_hits_on_second_call_and_busts_on_new_commit(baseline.clear_baseline_cache()-def test_baseline_cache_shared_across_distinct_commits(git_repo: Path, monkeypatch) -> None:- # The memo exists for the long-lived MCP server that scores many changes- # against one repo state. Keying it on the target defeated that, so two- # different merged commits must now share a single walk.+def _merged_change(repo: Path) -> str:+ """A merge commit with history before it and larger commits landing after it."""+ for i in range(10):+ _commit(repo, {f"src/f{i}.py": f"x = {i}\n"}, f"feat: file {i}", author="Dev")+ _git(["checkout", "-q", "-b", "feature"], repo)+ _commit(repo, {"src/pr.py": "".join(f"p{i} = {i}\n" for i in range(6))}, "feat: pr", "Dev")+ _git(["checkout", "-q", "-"], repo)+ _commit(repo, {"src/main.py": "m = 1\n"}, "feat: main moves", author="Dev")+ merge_cmd = ["merge", "-q", "--no-ff", "feature", "-m", "Merge pr"]+ _git(["-c", "user.name=Dev", "-c", "[email protected]", *merge_cmd], repo)+ merge = subprocess.run(+ ["git", "rev-parse", "HEAD"], cwd=repo, check=True, capture_output=True, text=True+ ).stdout.strip()+ # Larger commits after the merge: a sample read at HEAD would rank it lower.+ for i in range(10):+ body = "".join(f"y{j} = {j}\n" for j in range(40))+ _commit(repo, {f"src/later{i}.py": body}, f"feat: later {i}", author="Dev")+ return merge+++def test_a_change_ranks_the_same_however_it_is_spelled(git_repo: Path) -> None:+ # The commit, its first-parent range and its checklist rank against one+ # sample: the commits before the change, wherever HEAD has moved since.+ import asyncio++ from repowise.core.analysis.change_risk import baseline+ from repowise.core.changes.collect import evidence_for_revspec+ from repowise.core.changes.evidence import item_line++ merge = _merged_change(git_repo)+ parent = subprocess.run(+ ["git", "rev-parse", f"{merge}^1"],+ cwd=git_repo,+ check=True,+ capture_output=True,+ text=True,+ ).stdout.strip()+ baseline.clear_baseline_cache()++ commit = score_live_change(str(git_repo), merge, baseline=200)+ ranged = score_live_change(str(git_repo), f"{merge}^1..{merge}", baseline=200)+ checklist = asyncio.run(evidence_for_revspec(None, "", str(git_repo), merge))+ row = next(i for i in checklist.items if i.kind == "risk_score").to_dict()+ line = item_line(row)++ assert commit.percentile is not None+ assert commit.percentile == ranged.percentile+ assert commit.baseline_as_of == ranged.baseline_as_of == parent+ assert commit.baseline_sample_size == ranged.baseline_sample_size+ assert line["key"] == "risk_score_before"+ assert line["params"] == {+ "percentile": round(commit.percentile, 1),+ "sample": commit.baseline_sample_size,+ "as_of": parent[:10],+ }+ baseline.clear_baseline_cache()+++def test_baseline_cache_shared_by_spellings_of_one_change(git_repo: Path, monkeypatch) -> None:+ # The memo is keyed on the anchor, so a commit and its first-parent range+ # share one walk.from repowise.core.analysis.change_risk import baselinefor i in range(10):_commit(git_repo, {f"src/f{i}.py": f"x = {i}\n"}, f"feat: file {i}", author="Dev")- older = _commit(git_repo, {"src/a.py": "a = 1\n"}, "feat: a", author="Dev")- newer = _commit(git_repo, {"src/b.py": "b = 2\n"}, "feat: b", author="Dev")+ head = _commit(git_repo, {"src/b.py": "b = 2\n"}, "feat: b", author="Dev")baseline.clear_baseline_cache()calls = {"n": 0}@@ -420,15 +476,11 @@ def test_baseline_cache_shared_across_distinct_commits(git_repo: Path, monkeypatmonkeypatch.setattr(baseline, "baseline_samples", _counting)- first = score_live_change(str(git_repo), older, baseline=200)- second = score_live_change(str(git_repo), newer, baseline=200)- third = score_live_change(str(git_repo), baseline=200) # clean tree -> HEAD+ score_live_change(str(git_repo), head, baseline=200)+ score_live_change(str(git_repo), f"{head}^..{head}", baseline=200)+ score_live_change(str(git_repo), baseline=200) # clean tree -> HEADassert calls["n"] == 1- # Each still excludes only itself, so every sample is the same size.- assert first.baseline_sample_size == second.baseline_sample_size- assert third.baseline_sample_size == first.baseline_sample_size-baseline.clear_baseline_cache()@@ -442,8 +494,7 @@ def test_commit_does_not_rank_against_itself(git_repo: Path) -> None:samples = baseline.baseline_samples(str(git_repo), "HEAD", 200, ())result = score_live_change(str(git_repo), "HEAD", baseline=200)- # The cached walk holds every commit; the ranking drops exactly one - the- # target - so the two sizes differ by one and no more.+ # The sample runs back from the parent, so it is every commit but the target.assert result.baseline_sample_size == len(samples) - 1baseline.clear_baseline_cache()diff --git a/tests/unit/analysis/test_change_risk_fix_history.py b/tests/unit/analysis/test_change_risk_fix_history.pyindex ef651ec72..0310c63f1 100644--- a/tests/unit/analysis/test_change_risk_fix_history.py+++ b/tests/unit/analysis/test_change_risk_fix_history.py@@ -281,11 +281,11 @@ def test_zero_density_commits_stay_in_the_population() -> None:def test_percentile_uses_the_repos_own_commits(repo_with_history: Path) -> None:"""End to end: a change to the fragile file outranks one to the safe file."""- hot_sha = _commit(repo_with_history, {"hot.py": "v = 9\n"}, "feat: touch the hot file")- cold_sha = _commit(repo_with_history, {"cold.py": "c = 9\n"}, "feat: touch the cold file")- # Enough commits for the sample to clear MIN_DENSITY_POPULATION.+ # Enough commits before the change for its sample to clear MIN_DENSITY_POPULATION.for i in range(4, 8):_commit(repo_with_history, {"cold.py": f"c = {i}\n"}, f"feat: add capability {i}")+ hot_sha = _commit(repo_with_history, {"hot.py": "v = 9\n"}, "feat: touch the hot file")+ cold_sha = _commit(repo_with_history, {"cold.py": "c = 9\n"}, "feat: touch the cold file")hot = score_live_change(str(repo_with_history), hot_sha, baseline=200)cold = score_live_change(str(repo_with_history), cold_sha, baseline=200)diff --git a/tests/unit/core/test_change_evidence.py b/tests/unit/core/test_change_evidence.pyindex 694904579..683021f37 100644--- a/tests/unit/core/test_change_evidence.py+++ b/tests/unit/core/test_change_evidence.py@@ -153,7 +153,7 @@ def test_statuses_follow_the_facts():paths,health=_delta([_finding()]),tests=_tests({"src/a.py": "inferred", "src/b.py": "unknown", "tests/test_a.py": "unknown"}),- risk=SimpleNamespace(percentile=97.5, baseline_sample_size=200),+ risk=SimpleNamespace(percentile=97.5, baseline_sample_size=200, baseline_as_of="6bb3c0c293" * 4),)inputs = EvidenceInputs(code_paths=["src/a.py", "src/b.py"],@@ -254,7 +254,7 @@ def test_every_item_reads_as_a_plain_line():["src/a.py", "src/b.py"],health=_delta([_finding()]),tests=_tests({"src/a.py": "inferred", "src/b.py": "unknown"}),- risk=SimpleNamespace(percentile=97.5, baseline_sample_size=200),+ risk=SimpleNamespace(percentile=97.5, baseline_sample_size=200, baseline_as_of="6bb3c0c293" * 4),)inputs = dataclasses.replace(_full_inputs(), code_paths=None)evidence = build_change_evidence(bundle, inputs, change_id="c", revspec="r").to_dict()@@ -266,7 +266,10 @@ def test_every_item_reads_as_a_plain_line():assert lines["contracts"] == "1 workspace contract touched; signatures not compared"assert lines["decisions_crossed"] == "1 accepted decision, 0 candidates"assert lines["cross_repo_consumers"] == "No consumer in another repo"- assert lines["risk_score"] == "Larger than 97.5% of recent commits"+ assert lines["risk_score"] == "Larger than 97.5% of the 200 commits before this change (as of 6bb3c0c293)"+ # A row kept before the sample was stamped ranked against HEAD at build time: unlabelled.+ kept = {"kind": "risk_score", "value": {"percentile": 79.8}, "details": [{"baseline_sample_size": 200}]}+ assert line_text(item_line(kept)) == "Larger than 79.8% of recent commits"assert lines["outcomes"].startswith("Not known: ")assert lines["provenance"] == "provenance: agent, known for 0 of 0 commits"named = item_line(