-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathddw_cli.py
More file actions
69 lines (55 loc) · 1.84 KB
/
ddw_cli.py
File metadata and controls
69 lines (55 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import argparse
import json
import subprocess
import sys
from pathlib import Path
RECEIPT_FILE = Path("drift_receipt.json")
def run_verify():
result = subprocess.run(
[sys.executable, "drift_verifier.py"],
capture_output=True,
text=True
)
if result.returncode != 0:
print(result.stdout)
print(result.stderr)
sys.exit(result.returncode)
print(result.stdout)
def show_receipt():
if not RECEIPT_FILE.exists():
print("No drift_receipt.json found. Run: python ddw_cli.py verify")
sys.exit(1)
print(RECEIPT_FILE.read_text())
def show_summary():
if not RECEIPT_FILE.exists():
print("No drift_receipt.json found. Run: python ddw_cli.py verify")
sys.exit(1)
receipt = json.loads(RECEIPT_FILE.read_text())
summary = receipt.get("decision_summary", {})
print("Dimensional Drift Witness Summary")
print("---------------------------------")
print(f"Policy: {receipt.get('policy_id', 'UNKNOWN')}")
print(f"Receipt Hash: {receipt.get('receipt_hash', 'UNKNOWN')}")
print(f"Total Cases: {summary.get('total_cases', 0)}")
print(f"Drift Detected: {summary.get('drift_detected', 0)}")
print(f"No Drift: {summary.get('no_drift', 0)}")
print(f"Operational Divergence: {summary.get('operational_divergence', 0)}")
print(f"P4 Drift: {summary.get('p4_drift', 0)}")
def main():
parser = argparse.ArgumentParser(
description="Dimensional Drift Witness CLI"
)
parser.add_argument(
"command",
choices=["verify", "receipt", "summary"],
help="Command to run"
)
args = parser.parse_args()
if args.command == "verify":
run_verify()
elif args.command == "receipt":
show_receipt()
elif args.command == "summary":
show_summary()
if __name__ == "__main__":
main()