From 6b24b971114f2a399509e9a7ae64b08b7c03b263 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Wed, 18 Nov 2026 09:57:37 +0000 Subject: [PATCH 1/2] fix: batch claim gate uses a declared Repos: block alone, not Target: declared_repos() unioned a prompt's Target: into its Repos: header. Target is often only an epic label, so the claim gate held tasks on repos they never touch (readiness ruling Q8, 2026-11-18). Repos: now wins when it names a known repo; Target, then the survey repos, are fallbacks only. Closes #675 Co-Authored-By: Claude Opus 5.5 --- agents/conductors/batch/_batch.py | 16 ++++++--- tests/test_batch_declared_repos.py | 55 ++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 tests/test_batch_declared_repos.py diff --git a/agents/conductors/batch/_batch.py b/agents/conductors/batch/_batch.py index c1a794e..05eaf53 100644 --- a/agents/conductors/batch/_batch.py +++ b/agents/conductors/batch/_batch.py @@ -117,8 +117,14 @@ def lane_absent_why(r: dict) -> str: def declared_repos(p: dict) -> list[str]: - """A parsed prompt's `Repos:` header and known target, normalised; its - survey `repos` when it declares neither.""" + """The repos a parsed prompt will touch, normalised: its `Repos:` header + when that names any known repo; otherwise its `Target:` when that is a + known repo; otherwise its survey `repos`. + + `Target:` is not unioned into a declared `Repos:` block: it is often only + an epic label (a prompt with `Target: autofit` whose `Repos:` lists only + PyAutoCortex), so adding it made the claim gate report a false conflict + on a repo the prompt never touches (PyAutoBrain#675).""" from _sizing import KNOWN_REPOS # noqa: E402 out = set() block = re.search(r"^Repos:\n((?:- .+\n)+)", p.get("text") or "", re.M) @@ -126,10 +132,12 @@ def declared_repos(p: dict) -> list[str]: r = normalise_repo(ln[1:].strip()) if r in KNOWN_REPOS: out.add(r) + if out: + return sorted(out) t = normalise_repo(p.get("target") or "") if t in KNOWN_REPOS: - out.add(t) - return sorted(out) or list(p.get("repos") or []) + return [t] + return list(p.get("repos") or []) def grade(path: Path, mind: Path, text: str | None = None) -> dict: diff --git a/tests/test_batch_declared_repos.py b/tests/test_batch_declared_repos.py new file mode 100644 index 0000000..4a790c1 --- /dev/null +++ b/tests/test_batch_declared_repos.py @@ -0,0 +1,55 @@ +"""`declared_repos` and the batch claim gate (PyAutoBrain#675). + +A prompt's `Target:` is often only an epic label: a prompt with +`Target: autofit` whose `Repos:` lists only PyAutoCortex never touches +PyAutoFit, so a claim on PyAutoFit must not hold it. +""" + +from __future__ import annotations + +import sys +from pathlib import Path + +BRAIN = Path(__file__).resolve().parents[1] +BATCH = BRAIN / "agents" / "conductors" / "batch" +sys.path.insert(0, str(BRAIN / "agents" / "faculties" / "sizing")) +sys.path.insert(0, str(BATCH)) +import _batch # noqa: E402 +import _orchestrator as orch # noqa: E402 +from _sizing import normalise_repo # noqa: E402 + +ACTIVE = ("# Active\n\n## fit-work\n- prompt: active/feature/autofit/fit-work.md\n" + "- session: claude-code desktop (WSL)\n- repos:\n - PyAutoFit\n") + + +def _prompt(target: str, repos: list[str] | None) -> dict: + text = f"Target: {target}\n" + if repos is not None: + text += "Repos:\n" + "".join(f"- {r}\n" for r in repos) + return {"target": target, "text": text + "\nBody.\n", "repos": ["survey_only"]} + + +def test_repos_block_wins_over_an_epic_label_target(): + p = _prompt("autofit", ["PyAutoCortex"]) + assert _batch.declared_repos(p) == [normalise_repo("PyAutoCortex")] + + +def test_claim_on_the_target_does_not_hold_a_prompt_that_never_touches_it(): + sections = orch.claim_sections(ACTIVE) + cortex_only = _batch.declared_repos(_prompt("autofit", ["PyAutoCortex"])) + assert orch._held_for(sections, "cortex-ledger", cortex_only) is None + touches_fit = _batch.declared_repos(_prompt("autofit", ["PyAutoFit", "PyAutoCortex"])) + assert orch._held_for(sections, "fit-follow-up", touches_fit) == ("PyAutoFit", "fit-work") + + +def test_no_repos_block_falls_back_to_target(): + assert _batch.declared_repos(_prompt("autofit", None)) == [normalise_repo("autofit")] + + +def test_repos_block_of_unknown_names_falls_back_to_target(): + p = _prompt("autofit", ["not_a_repo", "another_unknown"]) + assert _batch.declared_repos(p) == [normalise_repo("autofit")] + + +def test_unknown_target_and_no_repos_falls_back_to_survey(): + assert _batch.declared_repos(_prompt("epic-label", None)) == ["survey_only"] From 0bde26bbcfa771a7731a0aa450362d7b9c79f824 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Wed, 18 Nov 2026 10:01:40 +0000 Subject: [PATCH 2/2] test: use organ names in declared_repos tests (tenant firewall) Co-Authored-By: Claude Opus 5.5 --- tests/test_batch_declared_repos.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/test_batch_declared_repos.py b/tests/test_batch_declared_repos.py index 4a790c1..cc0e481 100644 --- a/tests/test_batch_declared_repos.py +++ b/tests/test_batch_declared_repos.py @@ -1,8 +1,8 @@ """`declared_repos` and the batch claim gate (PyAutoBrain#675). A prompt's `Target:` is often only an epic label: a prompt with -`Target: autofit` whose `Repos:` lists only PyAutoCortex never touches -PyAutoFit, so a claim on PyAutoFit must not hold it. +`Target: pyautoeyes` whose `Repos:` lists only PyAutoCortex never touches +PyAutoEyes, so a claim on PyAutoEyes must not hold it. """ from __future__ import annotations @@ -18,8 +18,8 @@ import _orchestrator as orch # noqa: E402 from _sizing import normalise_repo # noqa: E402 -ACTIVE = ("# Active\n\n## fit-work\n- prompt: active/feature/autofit/fit-work.md\n" - "- session: claude-code desktop (WSL)\n- repos:\n - PyAutoFit\n") +ACTIVE = ("# Active\n\n## eyes-work\n- prompt: active/feature/pyautoeyes/eyes-work.md\n" + "- session: claude-code desktop (WSL)\n- repos:\n - PyAutoEyes\n") def _prompt(target: str, repos: list[str] | None) -> dict: @@ -30,25 +30,25 @@ def _prompt(target: str, repos: list[str] | None) -> dict: def test_repos_block_wins_over_an_epic_label_target(): - p = _prompt("autofit", ["PyAutoCortex"]) + p = _prompt("pyautoeyes", ["PyAutoCortex"]) assert _batch.declared_repos(p) == [normalise_repo("PyAutoCortex")] def test_claim_on_the_target_does_not_hold_a_prompt_that_never_touches_it(): sections = orch.claim_sections(ACTIVE) - cortex_only = _batch.declared_repos(_prompt("autofit", ["PyAutoCortex"])) + cortex_only = _batch.declared_repos(_prompt("pyautoeyes", ["PyAutoCortex"])) assert orch._held_for(sections, "cortex-ledger", cortex_only) is None - touches_fit = _batch.declared_repos(_prompt("autofit", ["PyAutoFit", "PyAutoCortex"])) - assert orch._held_for(sections, "fit-follow-up", touches_fit) == ("PyAutoFit", "fit-work") + touches_eyes = _batch.declared_repos(_prompt("pyautoeyes", ["PyAutoEyes", "PyAutoCortex"])) + assert orch._held_for(sections, "eyes-follow-up", touches_eyes) == ("PyAutoEyes", "eyes-work") def test_no_repos_block_falls_back_to_target(): - assert _batch.declared_repos(_prompt("autofit", None)) == [normalise_repo("autofit")] + assert _batch.declared_repos(_prompt("pyautoeyes", None)) == [normalise_repo("pyautoeyes")] def test_repos_block_of_unknown_names_falls_back_to_target(): - p = _prompt("autofit", ["not_a_repo", "another_unknown"]) - assert _batch.declared_repos(p) == [normalise_repo("autofit")] + p = _prompt("pyautoeyes", ["not_a_repo", "another_unknown"]) + assert _batch.declared_repos(p) == [normalise_repo("pyautoeyes")] def test_unknown_target_and_no_repos_falls_back_to_survey():