Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/e2e-proof.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/CLAIMS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
|---|---|---|
Expand Down
118 changes: 118 additions & 0 deletions scripts/collect-ci-proof.py
Original file line number Diff line number Diff line change
@@ -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())
Loading