fix(registrar): verify scoped success amid drift

Assistant: codex
Assistant-Model: gpt-5.6-sol
Assistant-Session: 01a023c0-a0a3-7c03-b395-5a0d2757214d
This commit is contained in:
tegwick 2026-08-22 13:02:34 +02:00
parent 69adfff48d
commit c90f70122c
2 changed files with 131 additions and 1 deletions

View file

@ -155,6 +155,61 @@ def test_scopes_registrar_env_and_commits_assigned_ids(tmp_path: Path, monkeypat
assert subject == "chore(registrar): assign State Hub identifiers"
def test_accepts_unrelated_assessment_fail_after_exact_requested_verification(
tmp_path: Path, monkeypatch
) -> None:
repo = _fixture(tmp_path)
monkeypatch.setattr(
rr,
"_check_primary",
lambda _api: ({"status": "ok", "db": "connected"}, None),
)
def fake_run(command, *, env):
workplan = repo / "workplans" / "DEMO-WP-0001.md"
text = workplan.read_text(encoding="utf-8")
text = text.replace(
"status: active\n---",
'status: active\nstate_hub_workstream_id: "11111111-1111-4111-8111-111111111111"\n---',
)
text = text.replace(
"priority: high\n```",
'priority: high\nstate_hub_task_id: "22222222-2222-4222-8222-222222222222"\n```',
)
workplan.write_text(text, encoding="utf-8")
return subprocess.CompletedProcess(command, 1, "unrelated C-03 remains", "")
monkeypatch.setattr(rr, "_run_statehub", fake_run)
monkeypatch.setattr(
rr,
"_verify_full_projection",
lambda _api, workplans, tasks, records: (
{
"expected_workplans": len(workplans),
"expected_tasks": len(tasks),
"expected_intakes": len(records["intake"]),
"expected_decisions": len(records["decision"]),
"missing_workplans": [],
"missing_tasks": [],
"missing_intakes": [],
"missing_decisions": [],
},
None,
),
)
result = rr.registrar_reconcile(
repo,
statehub_bin="statehub",
confirm_primary=True,
)
assert result.status == "applied"
assert result.evidence["requested_projection_verified"] is True
assert result.evidence["requested_projection"]["expected_workplans"] == 1
assert result.evidence["requested_projection"]["expected_tasks"] == 1
def test_repairs_an_already_identified_workplan_projection(tmp_path: Path, monkeypatch) -> None:
repo = _fixture(tmp_path)
workplan = repo / "workplans" / "DEMO-WP-0001.md"