fix(registrar): bound slow consistency runs

Assistant: codex
Assistant-Model: gpt-5.6-sol
Assistant-Session: 01a02b22-9638-76d2-bbff-b7ea1770b118
This commit is contained in:
tegwick 2026-08-23 11:58:43 +02:00
parent 7a15f1da21
commit 7b9fdaa734
4 changed files with 65 additions and 2 deletions

View file

@ -8,6 +8,12 @@ import pytest
from repo_manager.commands import registrar_reconcile as rr
@pytest.fixture(autouse=True)
def isolate_registrar_lock(tmp_path: Path, monkeypatch) -> None:
"""Keep unit tests independent from a live workstation registrar run."""
monkeypatch.setattr(rr, "LOCK_PATH", tmp_path / "registrar.lock")
def _git(repo: Path, *args: str) -> None:
subprocess.run(["git", *args], cwd=repo, check=True, capture_output=True)
@ -324,6 +330,33 @@ def test_accepts_unrelated_assessment_fail_after_exact_requested_verification(
assert result.evidence["requested_projection"]["expected_tasks"] == 1
def test_statehub_timeout_returns_structured_failure(tmp_path: Path, monkeypatch) -> None:
repo = _fixture(tmp_path)
monkeypatch.setattr(
rr,
"_check_primary",
lambda _api: ({"status": "ok", "db": "connected"}, None),
)
monkeypatch.setattr(
rr,
"_run_statehub",
lambda command, *, env: (_ for _ in ()).throw(
subprocess.TimeoutExpired(command, rr.STATEHUB_TIMEOUT_SECONDS, output="partial")
),
)
result = rr.registrar_reconcile(
repo,
statehub_bin="statehub",
confirm_primary=True,
)
assert result.status == "failed"
assert result.error and result.error["code"] == "statehub_timeout"
assert result.evidence["statehub_stdout_tail"] == "partial"
assert result.evidence["missing_after"] == result.evidence["missing_before"]
def test_repairs_an_already_identified_workplan_projection(tmp_path: Path, monkeypatch) -> None:
repo = _fixture(tmp_path)
workplan = repo / "workplans" / "DEMO-WP-0001.md"