feat(author): add continuation-mode selection wall for open-PR issues (#188)
Issues already represented by open PRs must not be selected for fresh work unless the operator explicitly requests continuation. Adds classification, continuation report proofs (old/new head SHA, PR author, branch), contradictory no-PR claim detection, and edited-PR inventory coverage checks. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This commit is contained in:
@@ -21,12 +21,19 @@ import unittest
|
||||
sys.path.insert(0, str(__import__("pathlib").Path(__file__).resolve().parent.parent))
|
||||
|
||||
from review_proofs import ( # noqa: E402
|
||||
ISSUE_SELECTION_CONTINUATION_EXPLICIT,
|
||||
ISSUE_SELECTION_REPRESENTED_BY_OPEN_PR,
|
||||
assess_author_pr_report,
|
||||
assess_capability_evidence,
|
||||
assess_capability_proof,
|
||||
assess_contradictory_no_pr_claim,
|
||||
assess_continuation_mode_report,
|
||||
assess_controller_handoff,
|
||||
assess_edited_pr_inventory_coverage,
|
||||
assess_empty_queue_report,
|
||||
assess_fresh_issue_selection,
|
||||
assess_inventory_completeness,
|
||||
assess_issue_selection_final_report,
|
||||
assess_reviewer_queue_inventory,
|
||||
assess_live_state_recheck,
|
||||
assess_review_mutation_final_report,
|
||||
@@ -36,6 +43,7 @@ from review_proofs import ( # noqa: E402
|
||||
assess_sweep_evidence,
|
||||
assess_validation_report,
|
||||
build_final_report,
|
||||
classify_issue_for_selection,
|
||||
pr_inventory_trust_gate,
|
||||
resolve_repos_from_user_reference,
|
||||
verify_pinned_head_checkout,
|
||||
@@ -1662,5 +1670,120 @@ class TestAuthorReporting(unittest.TestCase):
|
||||
self.assertFalse(result["complete"])
|
||||
|
||||
|
||||
class TestIssueSelectionContinuation(unittest.TestCase):
|
||||
"""Issue #188: continuation mode wall for issues with open PRs."""
|
||||
|
||||
OLD_SHA = PINNED
|
||||
NEW_SHA = OTHER
|
||||
OPEN_PR = [{"number": 187, "head": {"ref": "feat/issue-183-harden-author-run-reporting"}}]
|
||||
|
||||
def test_open_pr_issue_excluded_from_fresh_selection(self):
|
||||
classified = classify_issue_for_selection(
|
||||
183, open_prs=self.OPEN_PR,
|
||||
)
|
||||
self.assertEqual(classified["status"], ISSUE_SELECTION_REPRESENTED_BY_OPEN_PR)
|
||||
self.assertFalse(classified["selectable_for_fresh_work"])
|
||||
blocked = assess_fresh_issue_selection([classified])
|
||||
self.assertTrue(blocked["downgraded"])
|
||||
|
||||
def test_explicit_continuation_allows_represented_issue(self):
|
||||
classified = classify_issue_for_selection(
|
||||
183,
|
||||
open_prs=self.OPEN_PR,
|
||||
operator_continuation_requested=True,
|
||||
)
|
||||
self.assertEqual(classified["status"], ISSUE_SELECTION_CONTINUATION_EXPLICIT)
|
||||
blocked = assess_fresh_issue_selection([classified])
|
||||
self.assertFalse(blocked["downgraded"])
|
||||
|
||||
def test_contradictory_no_pr_claim_downgrades(self):
|
||||
report = (
|
||||
"Selected issue #183; no duplicate PR open. "
|
||||
"Updated PR #187 on branch feat/issue-183-harden-author-run-reporting."
|
||||
)
|
||||
result = assess_contradictory_no_pr_claim(
|
||||
report, edited_pr_numbers=[187], issue_open_pr_map={183: 187},
|
||||
)
|
||||
self.assertTrue(result["downgraded"])
|
||||
|
||||
def test_edited_pr_must_appear_in_inventory(self):
|
||||
report = "Open PR inventory: PR #195 only."
|
||||
result = assess_edited_pr_inventory_coverage(
|
||||
report,
|
||||
edited_pr_numbers=[187],
|
||||
inventoried_pr_numbers=[195],
|
||||
)
|
||||
self.assertTrue(result["downgraded"])
|
||||
|
||||
def test_continuation_report_requires_old_and_new_head(self):
|
||||
report = (
|
||||
"Issue #182 continuation mode. PR #186. "
|
||||
f"old head {self.OLD_SHA} -> new head {self.NEW_SHA}. "
|
||||
"PR author: jcwalker3. Branch: feat/issue-182-controller-handoff. "
|
||||
"Session authored PR: yes. Continuation allowed: operator requested."
|
||||
)
|
||||
result = assess_continuation_mode_report(
|
||||
report,
|
||||
pr_number=186,
|
||||
pr_author="jcwalker3",
|
||||
branch="feat/issue-182-controller-handoff",
|
||||
old_head_sha=self.OLD_SHA,
|
||||
new_head_sha=self.NEW_SHA,
|
||||
session_authored_pr=True,
|
||||
continuation_allowed_reason="operator requested continuation",
|
||||
)
|
||||
self.assertTrue(result["complete"])
|
||||
|
||||
def test_issue_selection_final_report_continuation_earns_a(self):
|
||||
report = "\n".join([
|
||||
"Issue #182 continuation mode — no new issue claimed.",
|
||||
f"PR #186 updated: old head {self.OLD_SHA}, "
|
||||
f"new head {self.NEW_SHA}.",
|
||||
"PR author: jcwalker3. Branch: feat/issue-182-controller-handoff.",
|
||||
"Session authored PR: yes.",
|
||||
"Continuation allowed: operator requested rebase.",
|
||||
"Open PR inventory included PR #186.",
|
||||
"## Controller Handoff",
|
||||
"- Task: continuation",
|
||||
"- Repo: Scaled-Tech-Consulting/Gitea-Tools",
|
||||
"- Role: author",
|
||||
"- Identity: prgs-author",
|
||||
"- Issue/PR: #182 / PR #186",
|
||||
"- Branch/SHA: feat/issue-182-controller-handoff",
|
||||
"- Files changed: review_proofs.py",
|
||||
"- Validation: tests passed",
|
||||
"- Mutations: push_branch",
|
||||
"- Workspace mutations: none",
|
||||
"- Current status: PR mergeable",
|
||||
"- Blockers: none",
|
||||
"- Next: review",
|
||||
"- Safety: no review/merge",
|
||||
"- Continuation mode: issue #182 continuation",
|
||||
"- Existing PR: #186",
|
||||
"- PR author: jcwalker3",
|
||||
"- Branch: feat/issue-182-controller-handoff",
|
||||
f"- Old PR head: {self.OLD_SHA}",
|
||||
f"- New PR head: {self.NEW_SHA}",
|
||||
"- Session authored PR: yes",
|
||||
"- Why continuation allowed: operator requested rebase",
|
||||
])
|
||||
result = assess_issue_selection_final_report(
|
||||
report,
|
||||
mode="continuation",
|
||||
continuation_proof={
|
||||
"pr_number": 186,
|
||||
"pr_author": "jcwalker3",
|
||||
"branch": "feat/issue-182-controller-handoff",
|
||||
"old_head_sha": self.OLD_SHA,
|
||||
"new_head_sha": self.NEW_SHA,
|
||||
"session_authored_pr": True,
|
||||
"continuation_allowed_reason": "operator requested rebase",
|
||||
},
|
||||
edited_pr_numbers=[186],
|
||||
inventoried_pr_numbers=[186],
|
||||
)
|
||||
self.assertEqual(result["grade"], "A")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user