feat(reviewer): require trust-gate proof in empty-queue reports (#198)
Add assess_empty_queue_report to block empty-queue claims without pr_inventory_trust_gate.status == trusted_empty, reject weak merge-commit corroboration, extend inventory handoff fields, and wire the gate into build_final_report and capability-stop terminal validation. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This commit is contained in:
@@ -27,6 +27,7 @@ from review_proofs import ( # noqa: E402
|
||||
assess_controller_handoff,
|
||||
assess_inventory_completeness,
|
||||
assess_reviewer_queue_inventory,
|
||||
assess_empty_queue_report,
|
||||
assess_live_state_recheck,
|
||||
assess_review_mutation_final_report,
|
||||
assess_role_boundary,
|
||||
@@ -1020,6 +1021,10 @@ class TestControllerHandoff(unittest.TestCase):
|
||||
complete = self.BASE_HANDOFF + "\n" + "\n".join([
|
||||
"- Repositories checked: Gitea-Tools, mcp-control-plane",
|
||||
"- Open PR counts: 2 / 0",
|
||||
"- PR inventory trust gate: trusted_nonempty / trusted_empty",
|
||||
"- Trust gate reasons: none",
|
||||
"- Trust gate corroborated: true",
|
||||
"- Inventory profile: prgs-reviewer",
|
||||
"- Selected PR or reason: none eligible (self-authored)",
|
||||
"- Inventory completeness: complete, no pagination needed",
|
||||
])
|
||||
@@ -1280,6 +1285,89 @@ class TestAssessReviewerQueueInventory(unittest.TestCase):
|
||||
self.assertEqual(result["trust_gates"], {})
|
||||
|
||||
|
||||
class TestAssessEmptyQueueReport(unittest.TestCase):
|
||||
"""Issue #198: empty-queue reports require formal trust-gate proof."""
|
||||
|
||||
def _trusted_report(self, **extra):
|
||||
lines = [
|
||||
"Queue inventory complete.",
|
||||
"Repository: Scaled-Tech-Consulting/Gitea-Tools",
|
||||
"Open PR count: 0",
|
||||
"pr_inventory_trust_gate.status: trusted_empty",
|
||||
"pr_inventory_trust_gate.corroborated: true",
|
||||
"Inventory profile: prgs-reviewer",
|
||||
"Workflow correctly stops with nothing to review.",
|
||||
]
|
||||
lines.extend(extra)
|
||||
return "\n".join(lines)
|
||||
|
||||
def test_non_empty_report_not_claimed(self):
|
||||
result = assess_empty_queue_report("Reviewed PR #236 and merged.")
|
||||
self.assertFalse(result["claimed"])
|
||||
self.assertTrue(result["proven"])
|
||||
|
||||
def test_empty_claim_without_trust_gate_blocked(self):
|
||||
report = (
|
||||
"Open PR count: 0\n"
|
||||
"Pagination complete: yes\n"
|
||||
"Queue cleared."
|
||||
)
|
||||
result = assess_empty_queue_report(report)
|
||||
self.assertTrue(result["claimed"])
|
||||
self.assertFalse(result["proven"])
|
||||
self.assertTrue(result["block"])
|
||||
|
||||
def test_trusted_empty_report_with_required_fields_passes(self):
|
||||
result = assess_empty_queue_report(self._trusted_report())
|
||||
self.assertTrue(result["proven"])
|
||||
|
||||
def test_weak_merge_commit_corroboration_blocked(self):
|
||||
report = (
|
||||
"Open PR count: 0\n"
|
||||
"Master latest commit is merge of PR #79 so queue is empty."
|
||||
)
|
||||
result = assess_empty_queue_report(report)
|
||||
self.assertFalse(result["proven"])
|
||||
self.assertTrue(
|
||||
any("weak corroboration" in r for r in result["reasons"])
|
||||
)
|
||||
|
||||
def test_author_session_reviewer_queue_wording_blocked(self):
|
||||
result = assess_empty_queue_report(
|
||||
self._trusted_report(),
|
||||
task_role="author",
|
||||
)
|
||||
self.assertFalse(result["proven"])
|
||||
|
||||
def test_build_final_report_downgrades_weak_empty_queue(self):
|
||||
final = build_final_report(
|
||||
checkout_proof=_good_checkout(),
|
||||
inventory=_good_inventory(),
|
||||
validation=_good_validation(),
|
||||
contamination=_good_contamination(),
|
||||
identity_eligible=True,
|
||||
merge_performed=False,
|
||||
issue_status_verified=True,
|
||||
capability_evidence=_good_capability_evidence(),
|
||||
sweep=_good_sweep(),
|
||||
live_state=_good_live_state(),
|
||||
role_boundary=_good_role_boundary(),
|
||||
review_mutation=_good_review_mutation(),
|
||||
controller_handoff=_good_handoff(),
|
||||
capability_proof=_good_capability_proof(),
|
||||
sweep_proof=_good_secret_sweep(),
|
||||
worktree_proof={
|
||||
"worktree_path": "/repo/branches/review-pr-1",
|
||||
"porcelain_status": "",
|
||||
"scratch_used": True,
|
||||
"scratch_path": "/repo/branches/review-pr-1",
|
||||
},
|
||||
report_text="Open PR count: 0. Queue cleared.",
|
||||
)
|
||||
self.assertNotEqual(final["grade"], "A")
|
||||
self.assertFalse(final["empty_queue_trust_gate_proven"])
|
||||
|
||||
|
||||
class TestCapabilityEvidence(unittest.TestCase):
|
||||
"""#179 gap 1: capability claims need exact evidence."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user