The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(e2e): the mid_git hold verdict counts looks, not only seconds
Teknium9341068b6317
diff --git a/tests/ci/test_windows_update_crash_oracles.py b/tests/ci/test_windows_update_crash_oracles.pyindex bb2ad35d7eb..bcc7c923d3f 100644--- a/tests/ci/test_windows_update_crash_oracles.py+++ b/tests/ci/test_windows_update_crash_oracles.py@@ -9,6 +9,7 @@ import shleximport subprocessimport timefrom pathlib import Path+from types import SimpleNamespaceimport psutilimport pytest@@ -197,3 +198,21 @@ def test_orphan_marker_guard_fires_once_the_fix_lands(monkeypatch):monkeypatch.setattr(crash, "orphan_marker_fix_missing", lambda: [])with pytest.raises(AssertionError, match="delete ORPHAN_MARKER_GAP"):test_orphan_marker_wrapper_expires_once_its_fix_is_in_the_tree()+++# Review 5411223855 (crash-cell timing): while the hold filter blocks git, the op and index.lock+# cannot move, so a starved runner must get more wall time, never fewer looks, before the verdict.+def test_mid_git_hold_verdict_needs_looks_as_well_as_seconds(tmp_path, monkeypatch):+ clock = [0.0]+ monkeypatch.setattr(crash, "time", SimpleNamespace(monotonic=lambda: clock[0]))+ monkeypatch.setattr(crash, "_git_op", lambda proc, ops: None) # the op is not visible yet+ monkeypatch.setattr(crash, "descendants", lambda proc: [])+ machine = SimpleNamespace(root=tmp_path, install_dir=tmp_path / "install", logs=tmp_path, evidence=lambda: "")+ hold = crash._GitHold(machine)+ hold.flags.mkdir(parents=True)+ (hold.flags / "held").write_text("1", encoding="utf-8")+ for _ in range(crash.HOLD_SETTLE_LOOKS - 1): # each look takes 10 s on this runner+ assert hold.point(None, machine, "t") is None+ clock[0] += 10.0+ with pytest.raises(AssertionError, match="the hold filter ran but no merge/reset/checkout"):+ hold.point(None, machine, "t")diff --git a/tests/e2e/core/windows_update/test_crash_cells.py b/tests/e2e/core/windows_update/test_crash_cells.pyindex 76c09a294bc..ed150acd0b4 100644--- a/tests/e2e/core/windows_update/test_crash_cells.py+++ b/tests/e2e/core/windows_update/test_crash_cells.py@@ -164,6 +164,7 @@ class _GitHold:self.attributes = machine.install_dir / ".git" / "info" / "attributes"self._saved_attributes: str | None = Noneself._held_since: float | None = None+ self._held_looks = 0@propertydef held(self) -> bool:@@ -200,9 +201,15 @@ class _GitHold:lock = machine.install_dir / ".git" / "index.lock"if seen is None or not lock.is_file():# Held by a git this cell does not model (or a lock-free write): name it, never- # wait out the whole update budget on a kill point that cannot come.+ # wait out the whole update budget on a kill point that cannot come. While the+ # filter holds, git, its op and index.lock cannot move: this is a static state the+ # poll only has to observe, so the verdict needs HOLD_SETTLE_LOOKS complete looks as+ # well as HOLD_SETTLE_SECONDS. A starved runner whose tree walk takes seconds gets+ # more time, never fewer looks.self._held_since = self._held_since or time.monotonic()- if time.monotonic() - self._held_since > HOLD_SETTLE_SECONDS:+ self._held_looks += 1+ if (time.monotonic() - self._held_since > HOLD_SETTLE_SECONDS+ and self._held_looks >= HOLD_SETTLE_LOOKS):gits = []for child in descendants(proc):with contextlib.suppress(Exception):@@ -210,13 +217,16 @@ class _GitHold:gits.append(" ".join(child.cmdline()[1:6]))raise AssertionError(fail_with(machine, f"mid_git: the hold filter ran but no {'/'.join(LOCAL_GIT_OPS)} with "- f".git/index.lock held appeared in {HOLD_SETTLE_SECONDS:.0f}s "+ f".git/index.lock held appeared in {time.monotonic() - self._held_since:.0f}s "+ f"and {self._held_looks} looks "f"(index.lock={lock.is_file()}, git children: {gits or 'none'})"))return Nonereturn f"git {seen[0]} (pid {seen[1]}) held writing {self.path}, .git/index.lock held"HOLD_SETTLE_SECONDS = 30.0+# A normal runner polls every ~0.1-0.3 s, so 30 s is well past this many looks there.+HOLD_SETTLE_LOOKS = 60def _head(machine) -> str: