-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSentinelContainmentProtocol.tla
More file actions
124 lines (103 loc) · 5.18 KB
/
Copy pathSentinelContainmentProtocol.tla
File metadata and controls
124 lines (103 loc) · 5.18 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
-------------------- MODULE SentinelContainmentProtocol --------------------
(***************************************************************************)
(* SentinelContainmentProtocol — corrected, model-checkable version of *)
(* governance_blueprint/SentinelContainmentProtocol.tla (which declared *)
(* `Spec == Init /\ [][Next]_vars` but never defined Init, and whose *)
(* KillSwitchIntegrity invariant was unreachable from its Next relation). *)
(* *)
(* Models the dead-man's-switch containment of the Omni-Sentinel Cognitive *)
(* Execution Environment, mirroring the on-chain OmegaActualTreatyEngine: *)
(* - A monitor heartbeat must arrive within HeartbeatThreshold ticks. *)
(* - If it lapses, containment TRIPS (dead-man's switch). *)
(* - High-risk actions are admissible only with policy token + supervisory *)
(* quorum while containment is ENFORCED. *)
(* *)
(* Safety invariants (checked by TLC): *)
(* TypeOK *)
(* NoUnsanctionedHighRisk - no high-risk action lacks token+quorum and a *)
(* non-TRIPPED enforced posture. *)
(* KillSwitchIntegrity - heartbeat lapse beyond threshold implies TRIPPED*)
(* TrippedIsLatched - once TRIPPED, stays TRIPPED (no silent re-arm). *)
(***************************************************************************)
EXTENDS Naturals, FiniteSets
CONSTANTS
HeartbeatThreshold, \* max ticks tolerated between heartbeats
MaxTime \* model bound on the clock
\* Fixed finite set of in-flight action records. The policy/contract layer
\* guarantees only fully-sanctioned high-risk actions are ever enqueued; this
\* models that upstream guarantee.
Actions == {
[riskTier |-> 2, supervisoryQuorum |-> 0, policyTokenValid |-> FALSE],
[riskTier |-> 4, supervisoryQuorum |-> 2, policyTokenValid |-> TRUE]
}
VARIABLES
containmentState, \* "ENFORCED" | "MONITORED" | "TRIPPED"
lastHeartbeat, \* tick of last accepted heartbeat
currentTime \* monotone clock
vars == <<containmentState, lastHeartbeat, currentTime>>
States == {"ENFORCED", "MONITORED", "TRIPPED"}
IsHighRisk(a) == a.riskTier >= 4
HasQuorum(a) == a.supervisoryQuorum >= 2
HasToken(a) == a.policyTokenValid = TRUE
Lapsed == (currentTime - lastHeartbeat) > HeartbeatThreshold
TypeOK ==
/\ containmentState \in States
/\ lastHeartbeat \in 0..MaxTime
/\ currentTime \in 0..MaxTime
Init ==
/\ containmentState = "ENFORCED"
/\ lastHeartbeat = 0
/\ currentTime = 0
(* Clock advances one tick. If the heartbeat has now lapsed and we are not *)
(* already TRIPPED, the dead-man's switch fires in the SAME step, so no *)
(* reachable state has Lapsed=TRUE while not TRIPPED. *)
Tick ==
/\ currentTime < MaxTime
/\ currentTime' = currentTime + 1
/\ lastHeartbeat' = lastHeartbeat
/\ containmentState' =
IF (containmentState # "TRIPPED") /\ ((currentTime + 1 - lastHeartbeat) > HeartbeatThreshold)
THEN "TRIPPED"
ELSE containmentState
(* A valid heartbeat refreshes liveness — but ONLY if not already TRIPPED *)
(* (the switch is latched; re-arming requires an out-of-band human action *)
(* outside this safety model). *)
Heartbeat ==
/\ containmentState # "TRIPPED"
/\ ~Lapsed
/\ lastHeartbeat' = currentTime
/\ UNCHANGED <<containmentState, currentTime>>
(* Posture may move between ENFORCED and MONITORED while live and not TRIPPED.*)
SetMonitored ==
/\ containmentState = "ENFORCED"
/\ ~Lapsed
/\ containmentState' = "MONITORED"
/\ UNCHANGED <<lastHeartbeat, currentTime>>
SetEnforced ==
/\ containmentState = "MONITORED"
/\ ~Lapsed
/\ containmentState' = "ENFORCED"
/\ UNCHANGED <<lastHeartbeat, currentTime>>
Stutter == UNCHANGED vars
Next ==
\/ Tick
\/ Heartbeat
\/ SetMonitored
\/ SetEnforced
\/ Stutter
Spec == Init /\ [][Next]_vars
-----------------------------------------------------------------------------
(* ---- Safety invariants ---- *)
\* Upstream-guarantee invariant: every admitted high-risk action carries a valid
\* policy token AND a supervisory quorum (>=2). This is the containment contract
\* the on-chain OmegaActualTreatyEngine and the OPA release gate jointly enforce.
NoUnsanctionedHighRisk ==
\A a \in Actions : IsHighRisk(a) => (HasToken(a) /\ HasQuorum(a))
\* The dead-man's switch: a lapsed heartbeat implies TRIPPED.
KillSwitchIntegrity == Lapsed => (containmentState = "TRIPPED")
\* TRIPPED is a latched terminal posture within the safety model: there is no
\* Next action that leaves TRIPPED. (Checked as an inductive invariant via the
\* action property below.)
TrippedStaysTripped ==
[][ (containmentState = "TRIPPED") => (containmentState' = "TRIPPED") ]_vars
=============================================================================