fix(hunt): diff producer records where a push removed lines; worktree checkout is proven complete

Two instrument findings from the first access-control feature table (952 rows, 74 positive rows):

1. A fix that adds a guard is, replayed base-to-head, a push that removes it. The diff producer only kept
   hunks with added lines at head, so 38 of 74 positive rows had no hunk in their file at all and 69 of 74
   were "not on a changed line", while 60% of ordinary rows were. The diff annotation separated the labels
   by construction and was blind to exactly the access-control shape. The producer (version 2) now records
   per file the head lines after which the push removed code; distance and on_changed_line count them, the
   model's hunks input renders them as removed_after_line, and diff.deletion_count is an engineered feature.

2. 150 rows (16%, every positive of one repository) read empty files from the worktree although git holds
   the blobs; the build ran while another process checked out from the same clone. _full_checkout now
   proves the checkout: git status must be clean, a dirty tree is restored once, then InstrumentFailure
   checkout_incomplete. The table script cross-checks every unread row against the blob size and refuses
   to screen a partly unread tree, and records the diff-scoped recall ceiling (positive rows a label-blind
   enumeration would reach).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
Marius Ciepluch
2026-10-13 23:17:15 +02:00
co-authored by Claude Fable 5.1
parent 60cbefec9b
commit 537b61e8d9
10 changed files with 273 additions and 22 deletions
+19
View File
@@ -108,3 +108,22 @@ def test_instrument_failure_is_recorded_with_a_type_only(repository, tmp_path):
assert record["status"] == "instrument_failure"
assert record["instrument"]["failure"] == "CalledProcessError"
assert record["push"]["admission"]["defects"] == []
def test_full_checkout_restores_a_truncated_file_and_refuses_an_unread_tree(repository, tmp_path, monkeypatch):
root, _manifest, changes = repository
worktree = tmp_path / "head"
subprocess.run(
["git", "-C", str(root), "worktree", "add", "--detach", str(worktree), changes[0]["head"]], check=True, capture_output=True
)
(worktree / "app.py").write_bytes(b"")
runner._full_checkout(worktree)
assert (worktree / "app.py").read_bytes() # the truncated file was restored, not read as empty
real = runner._git
def still_dirty(target, *args):
return " M app.py\n" if args[:2] == ("status", "--porcelain") else real(target, *args)
monkeypatch.setattr(runner, "_git", still_dirty)
with pytest.raises(runner.InstrumentFailure, match="checkout_incomplete"):
runner._full_checkout(worktree)