Skip to content

Commit d27248f

Browse files
Define safety invariants for Phase C5 formal model
1 parent af9ab6c commit d27248f

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed

formal/INVARIANTS.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# XSTRP Phase C5 — Safety Invariants
2+
3+
## Purpose
4+
5+
This document defines the safety invariants for the Phase C5
6+
formal verification model of XSTRP.
7+
8+
These invariants must hold in all reachable states of the model.
9+
Violation of any invariant constitutes a protocol safety failure.
10+
11+
---
12+
13+
## Invariant 1 — Valid State Space
14+
15+
The intent_state variable must always be one of the defined protocol states:
16+
17+
- Created
18+
- Committed
19+
- Completed
20+
- Expired
21+
- Refunded
22+
- Invalid
23+
24+
No other value is permitted.
25+
26+
---
27+
28+
## Invariant 2 — Terminal State Immutability
29+
30+
If intent_state is one of:
31+
32+
- Completed
33+
- Refunded
34+
- Invalid
35+
36+
Then intent_state must never change in any future state.
37+
38+
---
39+
40+
## Invariant 3 — No Completion Without Authorization
41+
42+
If intent_state = Completed, then:
43+
44+
- authorization_valid = TRUE
45+
- proof_present = TRUE
46+
- is_expired = FALSE
47+
48+
Completion without explicit authorization is impossible.
49+
50+
---
51+
52+
## Invariant 4 — No Completion After Expiry
53+
54+
If intent_state = Completed, then:
55+
56+
- is_expired = FALSE
57+
58+
Expired intents cannot complete.
59+
60+
---
61+
62+
## Invariant 5 — Deterministic Termination
63+
64+
From any reachable non-terminal state, the protocol must eventually reach
65+
exactly one terminal state:
66+
67+
- Completed
68+
- Refunded
69+
- Invalid
70+
71+
No execution path may avoid termination indefinitely.
72+
73+
---
74+
75+
## Invariant 6 — No Stranded Funds
76+
77+
There exists no reachable state in which:
78+
79+
- intent_state is non-terminal
80+
- and no transition is possible
81+
- and intent_state is not Expired
82+
83+
All non-terminal states must have a valid outgoing transition
84+
or be eligible for expiry and refund.
85+
86+
---
87+
88+
## Invariant 7 — Authorization Gating
89+
90+
Any transition that advances intent_state toward Completed
91+
must require authorization_valid = TRUE.
92+
93+
Unauthorized advancement is forbidden.
94+
95+
---
96+
97+
## Status
98+
99+
Safety invariants defined.
100+
No formal specification written yet.

0 commit comments

Comments
 (0)