RPF-WP-0061-T03: ccr/* branch gate and CI workflow; first automated platform review on CCR-2026-0051
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Assistant: claude-code Assistant-Model: opus Assistant-Process: 306568@bnt-lap001 Assistant-Session: 8bdf8150-ea56-41e7-9132-13f04f6b0b91
This commit is contained in:
parent
b6148da443
commit
10fddbc98f
5 changed files with 191 additions and 7 deletions
|
|
@ -194,6 +194,59 @@ class CcrIntakeTests(unittest.TestCase):
|
|||
with self.assertRaises(SystemExit):
|
||||
ccr_intake.submit(args, cc)
|
||||
|
||||
def submitted_branch(self) -> tuple[Path, str]:
|
||||
main_root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, main_root, True)
|
||||
shutil.copytree(self.root, main_root, dirs_exist_ok=True)
|
||||
destination, _violations = ccr_intake.submit(self.submit_args(), cc)
|
||||
return main_root, destination.stem
|
||||
|
||||
def test_branch_gate_accepts_clean_submission(self) -> None:
|
||||
main_root, stem = self.submitted_branch()
|
||||
self.assertEqual(ccr_intake.branch_gate(main_root, stem, cc), [])
|
||||
|
||||
def test_branch_gate_refuses_extra_changes(self) -> None:
|
||||
main_root, stem = self.submitted_branch()
|
||||
(self.root / "registry").mkdir()
|
||||
(self.root / "registry/ccr-standard-profile.yaml").write_text("submitters: [anyone]\n")
|
||||
errors = ccr_intake.branch_gate(main_root, stem, cc)
|
||||
self.assertIn("ccr branch may not change registry/ccr-standard-profile.yaml", errors)
|
||||
|
||||
def test_branch_gate_refuses_modified_existing_policy(self) -> None:
|
||||
main_root, stem = self.submitted_branch()
|
||||
path = self.ccrs / f"{stem}.yaml"
|
||||
data = cc.load_yaml(path)
|
||||
data["openbao"]["policy_file"] = POLICY
|
||||
cc.dump_yaml(path, data)
|
||||
(self.root / POLICY).write_text((self.root / POLICY).read_text() + "# widened\n")
|
||||
errors = ccr_intake.branch_gate(main_root, stem, cc)
|
||||
self.assertTrue(any("may not modify" in e for e in errors), errors)
|
||||
|
||||
def test_branch_gate_refuses_hand_edited_review(self) -> None:
|
||||
main_root, stem = self.submitted_branch()
|
||||
path = self.ccrs / f"{stem}.yaml"
|
||||
data = cc.load_yaml(path)
|
||||
data["review"]["comments"].append({"reviewer": "founder", "decision": "approved", "comment": "ok"})
|
||||
cc.dump_yaml(path, data)
|
||||
errors = ccr_intake.branch_gate(main_root, stem, cc)
|
||||
self.assertTrue(any("policy-as-code approval" in e for e in errors), errors)
|
||||
|
||||
def test_branch_gate_refuses_unlisted_requester(self) -> None:
|
||||
main_root, stem = self.submitted_branch()
|
||||
path = self.ccrs / f"{stem}.yaml"
|
||||
data = cc.load_yaml(path)
|
||||
data["requester"]["agent"] = "someone-else"
|
||||
cc.dump_yaml(path, data)
|
||||
errors = ccr_intake.branch_gate(main_root, stem, cc)
|
||||
self.assertTrue(any("listed submitter" in e for e in errors), errors)
|
||||
|
||||
def test_branch_gate_refuses_existing_ccr(self) -> None:
|
||||
main_root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, main_root, True)
|
||||
shutil.copytree(self.root, main_root, dirs_exist_ok=True)
|
||||
errors = ccr_intake.branch_gate(main_root, Path(STANDARD).stem, cc)
|
||||
self.assertTrue(any("already exists on main" in e for e in errors), errors)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue