fix(retrieval-gate): row 5 reads git for the half a registration cannot assert
PM's J1. Three of row 5's ten checks now read the repository's history instead of the registration's own fields: - the registration is COMMITTED and unmodified against HEAD -- a file written in a working tree is not a pre-registration; - the commit that ADDED it is not itself a change to the ranking -- a threshold and the change it is supposed to bind, in one commit, is neither; - a change to the ranking landed AFTER it. This is the one that cannot be self-attested: it is satisfied only in the order a pre-registration actually happens, and it is red today because neither half has happened. The three come from `git_provenance`, a `Provenance` the row receives the way it already receives a path, so both directions are driven from the test and the default is the real git. Outside a git tree, or with no git on PATH, the fields come back in their REFUSING form with the reason printed -- unknown is not unknown-and-therefore-fine. WHAT GIT CANNOT PROVE IS STATED IN THE ROW, not implied: history shows ORDER, never that nobody read the number before writing the threshold -- a number can be read from an uncommitted tree. Order is what these three checks are. Row 5 is unchanged where it matters today: `0 of 1 RED`, no registration. The two existing direction tests move 7 -> 10 checks and a third arm is added that drives each git check red on its own. 54 passed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
e207935ba6
commit
30cbb69ac0
2 changed files with 169 additions and 6 deletions
|
|
@ -329,6 +329,21 @@ def test_a_covered_question_that_came_back_marked_would_fail_the_same_row(
|
|||
# --- row 5 --------------------------------------------------------------------
|
||||
|
||||
|
||||
def _carried_by_git(
|
||||
*, tracked: bool = True, same_commit: bool = False, after: int = 1
|
||||
) -> gate.Provenance:
|
||||
"""A history row 5 reads instead of believing the registration. The three
|
||||
git checks are driven from HERE, never from a file the test writes, which
|
||||
is the whole point of the row."""
|
||||
return gate.Provenance(
|
||||
tracked=tracked,
|
||||
unmodified=tracked,
|
||||
commit="0" * 40 if tracked else "",
|
||||
commit_touches_ranking=same_commit,
|
||||
ranking_commits_after=after,
|
||||
)
|
||||
|
||||
|
||||
def test_row_five_is_red_while_no_hold_out_is_registered(tmp_path: Path) -> None:
|
||||
row = gate.row_five(tmp_path / "absent.json")
|
||||
assert (row.k, row.m, row.status) == (0, 1, gate.RED)
|
||||
|
|
@ -352,8 +367,8 @@ def test_row_five_is_green_for_a_registration_that_carries_all_seven(tmp_path: P
|
|||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
row = gate.row_five(registration)
|
||||
assert (row.k, row.m, row.status) == (7, 7, gate.GREEN)
|
||||
row = gate.row_five(registration, provenance=lambda _: _carried_by_git())
|
||||
assert (row.k, row.m, row.status) == (10, 10, gate.GREEN)
|
||||
|
||||
|
||||
def test_row_five_falls_on_a_number_read_before_its_threshold_was_written(
|
||||
|
|
@ -375,11 +390,44 @@ def test_row_five_falls_on_a_number_read_before_its_threshold_was_written(
|
|||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
row = gate.row_five(registration)
|
||||
assert (row.k, row.m, row.status) == (6, 7, gate.RED)
|
||||
row = gate.row_five(registration, provenance=lambda _: _carried_by_git())
|
||||
assert (row.k, row.m, row.status) == (9, 10, gate.RED)
|
||||
assert any("no reading predates the threshold: NO" in detail for detail in row.details)
|
||||
|
||||
|
||||
def test_row_five_falls_when_the_registration_rides_in_on_the_ranking_change(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
"""The three git checks, each driven red on its own: a file nobody
|
||||
committed, a threshold committed together with the ranking change, and a
|
||||
registration no ranking change has come after."""
|
||||
held = tmp_path / "held.json"
|
||||
held.write_text('{"questions": []}', encoding="utf-8")
|
||||
registration = tmp_path / "registration.json"
|
||||
registration.write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"set": str(held),
|
||||
"sha256": gate.sha256_of(held),
|
||||
"threshold": "hit@payload at unit granularity >= 0.8",
|
||||
"threshold_written_at": "2026-09-19T10:00:00Z",
|
||||
"written_by": "somebody",
|
||||
"readings": [],
|
||||
}
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
arms = {
|
||||
"uncommitted": (_carried_by_git(tracked=False), "committed"),
|
||||
"same commit as the ranking": (_carried_by_git(same_commit=True), "same commit"),
|
||||
"nothing changed since": (_carried_by_git(after=0), "0 commit(s) touching"),
|
||||
}
|
||||
for label, (history, expected) in arms.items():
|
||||
row = gate.row_five(registration, provenance=lambda _, h=history: h)
|
||||
assert row.status == gate.RED, label
|
||||
assert any(expected in detail for detail in row.details), (label, row.details)
|
||||
|
||||
|
||||
# --- row 6 --------------------------------------------------------------------
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue