From 8c06a3acded16b1d8c4b2dd67ed88c14f8128532 Mon Sep 17 00:00:00 2001 From: "Angel L. Pinzon" Date: Wed, 2 Dec 2026 18:29:52 -0500 Subject: [PATCH 1/3] Collect all three commit-bound policy verdicts with fail-closed tests --- scripts/collect-ci-proof.py | 118 ++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 scripts/collect-ci-proof.py diff --git a/scripts/collect-ci-proof.py b/scripts/collect-ci-proof.py new file mode 100644 index 0000000..1727394 --- /dev/null +++ b/scripts/collect-ci-proof.py @@ -0,0 +1,118 @@ +#!/usr/bin/env python3 +"""Collect commit-bound policy proofs into one fail-closed CI verdict.""" +import argparse +import json +from pathlib import Path +import tempfile +import unittest + +POLICIES = {"Auto": (4001, 2), "Alert": (4002, 1), "Halt": (4003, 1)} + + +def collect(directory, commit, matrix_result): + results = [] + for policy, (register, writes) in POLICIES.items(): + path = directory / f"setpoint-proof-{policy}-{commit}" / "proof.json" + reasons = [] + try: + proof = json.loads(path.read_text(encoding="utf-8")) + expected = { + "schema": "setpoint.io/proof/v1", + "policy": policy, + "target_register": register, + "commit": commit, + "verdict": "PASS", + } + if not isinstance(proof, dict): + raise ValueError("proof is not a JSON object") + for key, value in expected.items(): + if proof.get(key) != value: + reasons.append(f"{key}: expected {value!r}, got {proof.get(key)!r}") + detection = proof.get("detection") + if not isinstance(detection, dict): + reasons.append("missing detection object") + else: + for key, value in {"alert_violations": 0, "mock_write_attempts": writes}.items(): + if type(detection.get(key)) is not int or detection[key] != value: + reasons.append(f"{key}: expected {value}, got {detection.get(key)!r}") + except (OSError, ValueError) as error: + reasons.append(str(error)) + results.append({"policy": policy, "register": register, "verdict": "FAIL" if reasons else "PASS", + "reasons": reasons, "artifact": path.parent.name}) + passed = matrix_result == "success" and all(row["verdict"] == "PASS" for row in results) + return {"schema": "setpoint.io/combined-proof/v1", "commit": commit, + "matrix_result": matrix_result, "verdict": "PASS" if passed else "FAIL", + "policies": results} + + +class CollectorTests(unittest.TestCase): + def setUp(self): + self.temp = tempfile.TemporaryDirectory() + self.addCleanup(self.temp.cleanup) + self.directory = Path(self.temp.name) + self.commit = "test-commit" + for policy, (register, writes) in POLICIES.items(): + self.write(policy, {"schema": "setpoint.io/proof/v1", "policy": policy, + "target_register": register, "commit": self.commit, "verdict": "PASS", + "detection": {"alert_violations": 0, "mock_write_attempts": writes}}) + + def path(self, policy): + return self.directory / f"setpoint-proof-{policy}-{self.commit}" / "proof.json" + + def write(self, policy, proof): + path = self.path(policy) + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(json.dumps(proof), encoding="utf-8") + + def result(self, matrix_result="success"): + return collect(self.directory, self.commit, matrix_result)["verdict"] + + def test_all_pass(self): + self.assertEqual(self.result(), "PASS") + + def test_missing(self): + self.path("Halt").unlink() + self.assertEqual(self.result(), "FAIL") + + def test_mismatch(self): + proof = json.loads(self.path("Auto").read_text()) + proof["commit"] = "wrong" + self.write("Auto", proof) + self.assertEqual(self.result(), "FAIL") + + def test_bad_detection(self): + proof = json.loads(self.path("Alert").read_text()) + proof["detection"]["mock_write_attempts"] = 2 + self.write("Alert", proof) + self.assertEqual(self.result(), "FAIL") + + def test_matrix_failure(self): + self.assertEqual(self.result("failure"), "FAIL") + + def test_malformed(self): + self.path("Halt").write_text("not json") + self.assertEqual(self.result(), "FAIL") + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--input", type=Path) + parser.add_argument("--output", type=Path) + parser.add_argument("--commit") + parser.add_argument("--matrix-result") + parser.add_argument("--self-test", action="store_true") + args = parser.parse_args() + if args.self_test: + suite = unittest.defaultTestLoader.loadTestsFromTestCase(CollectorTests) + return 0 if unittest.TextTestRunner(verbosity=2).run(suite).wasSuccessful() else 1 + if not all((args.input, args.output, args.commit, args.matrix_result)): + parser.error("--input, --output, --commit and --matrix-result are required") + verdict = collect(args.input, args.commit, args.matrix_result) + args.output.parent.mkdir(parents=True, exist_ok=True) + args.output.write_text(json.dumps(verdict, indent=2) + "\n", encoding="utf-8") + print(json.dumps(verdict, indent=2)) + return 0 if verdict["verdict"] == "PASS" else 1 + + +if __name__ == "__main__": + raise SystemExit(main()) From bd9463caaaf12a1341633dad6cf7c666652f8ce9 Mon Sep 17 00:00:00 2001 From: "Angel L. Pinzon" Date: Wed, 2 Dec 2026 18:29:54 -0500 Subject: [PATCH 2/3] Publish a single fail-closed matrix proof verdict in CI --- .github/workflows/e2e-proof.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.github/workflows/e2e-proof.yml b/.github/workflows/e2e-proof.yml index 441b5c5..6a97a9b 100644 --- a/.github/workflows/e2e-proof.yml +++ b/.github/workflows/e2e-proof.yml @@ -89,3 +89,32 @@ jobs: - name: Teardown if: always() run: kind delete cluster --name setpoint-e2e || true + + combined-verdict: + name: Combined policy verdict + needs: proof + if: always() + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Test collector + run: python3 scripts/collect-ci-proof.py --self-test + - name: Download policy evidence + uses: actions/download-artifact@v4 + continue-on-error: true + with: + pattern: setpoint-proof-*-${{ github.sha }} + path: artifacts/matrix + - name: Collect and verify the three policies + env: + MATRIX_RESULT: ${{ needs.proof.result }} + run: | + python3 scripts/collect-ci-proof.py --input artifacts/matrix --output artifacts/combined/proof.json --commit "$GITHUB_SHA" --matrix-result "$MATRIX_RESULT" + - name: Upload combined verdict + if: always() + uses: actions/upload-artifact@v4 + with: + name: setpoint-combined-proof-${{ github.sha }} + path: artifacts/combined/proof.json + if-no-files-found: error + retention-days: 30 From 3256370fa24dfdcb0536b1d1dc70e6829c1d0284 Mon Sep 17 00:00:00 2001 From: "Angel L. Pinzon" Date: Wed, 2 Dec 2026 18:29:57 -0500 Subject: [PATCH 3/3] Record verified policy results and bounded aggregate scope --- docs/CLAIMS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CLAIMS.md b/docs/CLAIMS.md index be11e93..18b9085 100644 --- a/docs/CLAIMS.md +++ b/docs/CLAIMS.md @@ -9,7 +9,7 @@ The flagship proof uses a disposable kind cluster and a simulated PLC, not indus | Alert policy does not write in the tested scenario | scripts/modbus-proof.py; mock PLC write-attempt log | plc-readback.json, mock-plc.log, proof.json | | Prometheus exposure | crates/operator/src/metrics.rs | prometheus-metrics.txt | -Run `make flagship-proof` against a disposable kind cluster. CI uploads evidence on failure and success. The proposed CI matrix independently exercises all three policies in separate simulated clusters. Auto requires one correction and restoration; Alert/Halt require exactly one write attempt (injection) and persistent drift. Halt also requires Failed status. Halt is an operator state, not a certified physical safety mechanism. Results on this branch are pending CI. +Run `make flagship-proof` against a disposable kind cluster. CI uploads evidence on failure and success. The CI matrix independently exercises all three policies in separate simulated clusters. Auto requires one correction and restoration; Alert/Halt require exactly one write attempt (injection) and persistent drift. Halt also requires Failed status. Halt is an operator state, not a certified physical safety mechanism. All three policy jobs passed in [run 46988705127](https://github.com/AngelP17/Setpoint/actions/runs/46988705127) at commit `2909f30`. The combined-verdict job validates the artifact schema, policy, register, commit and expected write count for every policy and fails if a result is absent or the matrix fails. This new combined job requires its own CI run. | Claim | Evidence | Status | |---|---|---|