Merge branch 'master' into feat/issue-522-conflict-fix-classification

This commit is contained in:
2026-07-08 21:52:46 -05:00
7 changed files with 466 additions and 1 deletions
+81
View File
@@ -0,0 +1,81 @@
"""Doc-contract checks for the bootstrap review path (#557).
Self-hosted MCP workflow fixes can deadlock live review daemons. These tests
pin the narrow controller-authorized bootstrap path so it cannot silently
regress into a general gate bypass.
"""
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
DOC = REPO_ROOT / "docs" / "bootstrap-review-path.md"
RUNBOOK = REPO_ROOT / "docs" / "llm-workflow-runbooks.md"
SKILL = REPO_ROOT / "skills" / "llm-project-workflow" / "SKILL.md"
def _normalize(text: str) -> str:
return " ".join(text.split())
def test_bootstrap_doc_exists_and_names_authorization_marker():
text = DOC.read_text(encoding="utf-8")
assert "BOOTSTRAP REVIEW AUTHORIZATION (#557)" in text
assert "bootstrap deadlock" in text.lower() or "Bootstrap deadlock" in text
def test_bootstrap_doc_requires_validation_and_audits():
text = _normalize(DOC.read_text(encoding="utf-8"))
for phrase in (
"git diff --check",
"Duplicate-PR audit",
"Mutation ledger audit",
"Contamination audit",
"workflow-contaminated",
):
assert phrase in text, f"bootstrap doc missing: {phrase!r}"
def test_bootstrap_doc_lists_allowed_and_forbidden_actions():
text = _normalize(DOC.read_text(encoding="utf-8"))
lower = text.lower()
for phrase in (
"Allowed verification actions",
"Forbidden actions",
"project root",
"direct Python import",
"branches/",
):
assert phrase in text, f"bootstrap doc missing: {phrase!r}"
assert "curl" in lower
assert "raw" in lower
def test_bootstrap_doc_forbids_general_gate_weakening():
text = _normalize(DOC.read_text(encoding="utf-8")).lower()
assert "never weakens normal" in text or "does not weaken normal" in text
assert "general bypass" in text or "general gate" in text
def test_bootstrap_doc_post_land_restart_and_verify():
text = _normalize(DOC.read_text(encoding="utf-8"))
for phrase in (
"Restart MCP daemons",
"canonical tools",
"gitea_whoami",
):
assert phrase in text, f"post-bootstrap guidance missing: {phrase!r}"
def test_runbook_links_bootstrap_path():
text = _normalize(RUNBOOK.read_text(encoding="utf-8"))
assert "Bootstrap Review Path for self-hosted MCP fixes (#557)" in text
assert "bootstrap-review-path.md" in text
assert "BOOTSTRAP REVIEW AUTHORIZATION (#557)" in text
def test_skill_links_bootstrap_path():
text = _normalize(SKILL.read_text(encoding="utf-8"))
assert "Bootstrap Review Path (#557)" in text
assert "bootstrap-review-path.md" in text
assert "BLOCKED + DIAGNOSE" in text or "BLOCKED" in text
+75
View File
@@ -498,6 +498,81 @@ class TestCanonicalReconcileSchema(unittest.TestCase):
)
class TestReconcilerCloseProof(unittest.TestCase):
"""Issue #306: a reconciler PR close must carry its proof fields."""
def _closed_report(self, **kwargs):
# A report that claims PR #99 was closed via the reconciler path.
report = (
_reconcile_handoff(**kwargs)
.replace(
"- Capabilities proven: gitea.read, gitea.pr.comment",
"- Capabilities proven: gitea.read, gitea.pr.comment, gitea.pr.close",
)
.replace("- Missing capabilities: gitea.pr.close", "- Missing capabilities: none")
.replace("- PRs closed: none", "- PRs closed: #99")
.replace(
"- Blocker: missing gitea.pr.close capability", "- Blocker: none"
)
)
return report
def test_full_proof_close_passes(self):
result = assess_final_report_validator(
self._closed_report(), "reconcile_already_landed"
)
self.assertEqual(result["grade"], "A")
self.assertFalse(
any(f["rule_id"] == "reconcile.close_proof_fields" for f in result["findings"])
)
def test_close_without_capability_proof_blocks(self):
# Claims PRs closed: #99 but never proves gitea.pr.close capability.
report = _reconcile_handoff().replace("- PRs closed: none", "- PRs closed: #99")
result = assess_final_report_validator(report, "reconcile_already_landed")
self.assertTrue(result["blocked"])
self.assertTrue(
any(f["rule_id"] == "reconcile.close_proof_fields" for f in result["findings"])
)
def test_close_without_ancestor_proof_blocks(self):
report = self._closed_report(drop=("Ancestor proof",))
result = assess_final_report_validator(report, "reconcile_already_landed")
self.assertTrue(result["blocked"])
self.assertTrue(
any(f["rule_id"] == "reconcile.close_proof_fields" for f in result["findings"])
)
def test_close_without_linked_issue_result_blocks(self):
report = self._closed_report(drop=("Linked issue live status", "Issues closed"))
result = assess_final_report_validator(report, "reconcile_already_landed")
self.assertTrue(result["blocked"])
self.assertTrue(
any(f["rule_id"] == "reconcile.close_proof_fields" for f in result["findings"])
)
def test_close_lock_requires_proof_even_if_text_says_none(self):
# Session lock proves a PR was closed; the report omits close proof.
result = assess_final_report_validator(
_reconcile_handoff(),
"reconcile_already_landed",
reconciler_close_lock={"pr_closed": True},
)
self.assertTrue(result["blocked"])
self.assertTrue(
any(f["rule_id"] == "reconcile.close_proof_fields" for f in result["findings"])
)
def test_comment_only_reconcile_needs_no_close_proof(self):
result = assess_final_report_validator(
_reconcile_handoff(), "reconcile_already_landed"
)
self.assertEqual(result["grade"], "A")
self.assertFalse(
any(f["rule_id"] == "reconcile.close_proof_fields" for f in result["findings"])
)
class TestEntryPoint(unittest.TestCase):
def test_unknown_task_kind_blocks(self):
result = assess_final_report_validator("report", "unknown_mode")