-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimulate_audit.py
More file actions
50 lines (37 loc) · 1.06 KB
/
simulate_audit.py
File metadata and controls
50 lines (37 loc) · 1.06 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
import hashlib
import json
import os
import time
AUDIT_FILE = "simulated_audit.ndjson"
_sequence_counter = 0
def next_sequence():
global _sequence_counter
_sequence_counter += 1
return _sequence_counter
def append_record(verdict):
record = {
"schema_version": 1,
"sequence": next_sequence(),
"verdict_kind": verdict,
"input_hash": hashlib.sha256(verdict.encode()).hexdigest(),
"total_elapsed_us": 100,
"decided_at_ns": int(time.time() * 1_000_000_000),
}
with open(AUDIT_FILE, "a") as f:
f.write(json.dumps(record) + "\n")
try:
os.remove(AUDIT_FILE)
except FileNotFoundError:
pass
print(f"Simulating audit trail in {AUDIT_FILE}...")
# 1. Add 10 Pass records
for _ in range(10):
append_record("Pass")
time.sleep(0.1)
# 2. Add 10 DiagnosticDisagreement records (should trigger >5% alert)
for _ in range(10):
append_record("DiagnosticDisagreement")
time.sleep(0.1)
# 3. Add a DiagnosticDisagreement
append_record("DiagnosticDisagreement")
print("Simulation finished.")