@dreamforgestudiollc/emet 0.3.6 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/.env.example +29 -0
  2. package/CHANGELOG.md +25 -1
  3. package/README.md +9 -3
  4. package/RELEASE_NOTES-0.2.6.md +1 -1
  5. package/RELEASE_NOTES-0.3.7.md +19 -0
  6. package/docs/BOTS.md +1 -1
  7. package/docs/DEPLOY.md +14 -1
  8. package/docs/ERROR-CODES-SPEC.md +4 -0
  9. package/docs/ERROR-CODES.md +7 -0
  10. package/docs/ROADMAP.md +3 -3
  11. package/docs/SETUP.md +4 -0
  12. package/docs/SUBKEYS.md +3 -1
  13. package/docs/continuity-currency-statechart.md +34 -0
  14. package/docs/features/README.md +21 -0
  15. package/docs/features/access.md +28 -0
  16. package/docs/features/documents.md +35 -0
  17. package/docs/features/errors.md +32 -0
  18. package/docs/features/gems.md +31 -0
  19. package/docs/features/memory.md +29 -0
  20. package/docs/features/pages.md +28 -0
  21. package/docs/features/record.md +27 -0
  22. package/docs/features/search.md +27 -0
  23. package/docs/features/startup.md +29 -0
  24. package/docs/features/subkeys.md +30 -0
  25. package/docs/features/transcripts.md +33 -0
  26. package/docs/per-tag-handoff-statechart.md +147 -0
  27. package/docs/subkey-session-statechart.md +57 -0
  28. package/package.json +3 -2
  29. package/server.json +27 -2
  30. package/src/annotations.js +4 -3
  31. package/src/attribution.js +1 -1
  32. package/src/chooser.js +74 -3
  33. package/src/conformance.js +2 -0
  34. package/src/continuity-currency-statechart.js +139 -0
  35. package/src/continuity-currency.js +869 -0
  36. package/src/dispatch.js +1 -1
  37. package/src/error-codes.js +7 -0
  38. package/src/http-remote.js +27 -4
  39. package/src/index.js +1 -0
  40. package/src/pages.js +15 -0
  41. package/src/per-tag-handoff-statechart.js +264 -0
  42. package/src/per-tag-handoff.js +988 -0
  43. package/src/persons.js +16 -0
  44. package/src/session-graph.js +118 -7
  45. package/src/session.js +54 -10
  46. package/src/setup.js +22 -1
  47. package/src/startup-pages.js +13 -2
  48. package/src/subkey-lifecycle.js +105 -0
  49. package/src/subkey-session-statechart.js +253 -0
  50. package/src/subkeys.js +648 -89
  51. package/src/tools.js +157 -32
  52. package/src/version.js +1 -1
  53. package/templates/INDEX.md +1 -0
  54. package/templates/TAGHANDOFF.md +45 -0
  55. package/verification/continuity-currency/ContinuityCurrency.cfg +12 -0
  56. package/verification/continuity-currency/ContinuityCurrency.tla +239 -0
  57. package/verification/continuity-currency/tlc-output.txt +32 -0
  58. package/verification/continuity-currency/view.mjs +54 -0
  59. package/verification/per-tag-handoff/PerTagHandoff.cfg +10 -0
  60. package/verification/per-tag-handoff/PerTagHandoff.tla +191 -0
  61. package/verification/per-tag-handoff/StampCounter.cfg +10 -0
  62. package/verification/per-tag-handoff/out/report.md +6 -0
  63. package/verification/per-tag-handoff/out-counter/chart.mmd +30 -0
  64. package/verification/per-tag-handoff/out-counter/report.md +15 -0
  65. package/verification/per-tag-handoff/out-counter/tlc.out +130 -0
  66. package/verification/per-tag-handoff/split/PerTagConflict.cfg +6 -0
  67. package/verification/per-tag-handoff/split/PerTagConflict.tla +104 -0
  68. package/verification/per-tag-handoff/split/PerTagTime.cfg +8 -0
  69. package/verification/per-tag-handoff/split/PerTagTime.tla +100 -0
  70. package/verification/per-tag-handoff/split/conflict-chart.mmd +47 -0
  71. package/verification/per-tag-handoff/split/conflict-report.md +8 -0
  72. package/verification/per-tag-handoff/split/conflict-tlc.txt +19 -0
  73. package/verification/per-tag-handoff/split/conflict-view.mjs +34 -0
  74. package/verification/per-tag-handoff/split/time-chart.mmd +44 -0
  75. package/verification/per-tag-handoff/split/time-report.md +8 -0
  76. package/verification/per-tag-handoff/split/time-tlc.txt +19 -0
  77. package/verification/per-tag-handoff/split/time-view.mjs +33 -0
  78. package/verification/per-tag-handoff/tlc-output.txt +19 -0
  79. package/verification/per-tag-handoff/v1-draft/PerTagHandoff.cfg +5 -0
  80. package/verification/per-tag-handoff/v1-draft/PerTagHandoff.tla +94 -0
  81. package/verification/per-tag-handoff/v1-draft/out/chart.mmd +37 -0
  82. package/verification/per-tag-handoff/v1-draft/out/report.md +7 -0
  83. package/verification/per-tag-handoff/v1-draft/out/tlc.out +19 -0
  84. package/verification/per-tag-handoff/v1-draft/view.mjs +20 -0
  85. package/verification/per-tag-handoff/view.mjs +31 -0
  86. package/verification/subkey-session/SubkeySession.cfg +11 -0
  87. package/verification/subkey-session/SubkeySession.tla +254 -0
  88. package/verification/subkey-session/tlc-output.txt +13 -0
@@ -0,0 +1,94 @@
1
+ ---- MODULE PerTagHandoff ----
2
+ EXTENDS Naturals
3
+ \* Design sketch: per-tag handoffs, a merged view computed on read,
4
+ \* one shared board under optimistic versioning. Two write tags, one read-only tag.
5
+ Writers == {"hub", "writer"}
6
+ Readers == {"guest"}
7
+ Tags == Writers \cup Readers
8
+ MaxV == 1
9
+ MaxB == 1
10
+
11
+ VARIABLES phase, hv, author, board, seen, patches, refused
12
+ vars == <<phase, hv, author, board, seen, patches, refused>>
13
+
14
+ None == [w \in Writers |-> 0]
15
+
16
+ Init ==
17
+ /\ phase = [t \in Tags |-> "out"]
18
+ /\ hv = [w \in Writers |-> 0]
19
+ /\ author = [w \in Writers |-> "none"]
20
+ /\ board = 0
21
+ /\ seen = [t \in Tags |-> 0]
22
+ /\ patches = 0
23
+ /\ refused = FALSE
24
+
25
+ \* Any tag starts: reads the merged view (every write tag's latest handoff) and the board.
26
+ Start(t) ==
27
+ /\ phase[t] = "out"
28
+ /\ phase' = [phase EXCEPT ![t] = "in"]
29
+ /\ seen' = IF t \in Writers THEN [seen EXCEPT ![t] = board] ELSE seen
30
+ /\ refused' = FALSE
31
+ /\ UNCHANGED <<hv, author, board, patches>>
32
+
33
+ \* A write tag patches the board it last read.
34
+ PatchBoard(t) ==
35
+ /\ t \in Writers /\ phase[t] = "in" /\ seen[t] = board /\ board < MaxB
36
+ /\ board' = board + 1 /\ patches' = patches + 1
37
+ /\ seen' = [seen EXCEPT ![t] = board + 1]
38
+ /\ refused' = FALSE
39
+ /\ UNCHANGED <<phase, hv, author>>
40
+
41
+ \* A patch on a board that moved since this tag read it is refused; the tag re-reads.
42
+ StalePatch(t) ==
43
+ /\ t \in Writers /\ phase[t] = "in" /\ seen[t] # board
44
+ /\ seen' = [seen EXCEPT ![t] = board]
45
+ /\ refused' = TRUE
46
+ /\ UNCHANGED <<phase, hv, author, board, patches>>
47
+
48
+ \* Wrap-up: a write tag supersedes only its own handoff, last.
49
+ WrapOwn(t) ==
50
+ /\ t \in Writers /\ phase[t] = "in" /\ hv[t] < MaxV
51
+ /\ hv' = [hv EXCEPT ![t] = hv[t] + 1]
52
+ /\ author' = [author EXCEPT ![t] = t]
53
+ /\ phase' = [phase EXCEPT ![t] = "out"]
54
+ /\ refused' = FALSE
55
+ /\ UNCHANGED <<board, seen, patches>>
56
+
57
+ \* A tag tries to write another tag's handoff: the credential check refuses it.
58
+ ForeignWrite(t, u) ==
59
+ /\ phase[t] = "in" /\ u \in Writers /\ u # t
60
+ /\ refused' = TRUE
61
+ /\ UNCHANGED <<phase, hv, author, board, seen, patches>>
62
+
63
+ \* A read-only tag leaves without writing anything.
64
+ LeaveReadOnly(t) ==
65
+ /\ t \in Readers /\ phase[t] = "in"
66
+ /\ phase' = [phase EXCEPT ![t] = "out"]
67
+ /\ refused' = FALSE
68
+ /\ UNCHANGED <<hv, author, board, seen, patches>>
69
+
70
+ Done == \A w \in Writers : hv[w] = MaxV /\ UNCHANGED vars
71
+
72
+ Next ==
73
+ \/ \E t \in Tags : Start(t)
74
+ \/ \E t \in Writers : PatchBoard(t)
75
+ \/ \E t \in Writers : StalePatch(t)
76
+ \/ \E t \in Writers : WrapOwn(t)
77
+ \/ \E t \in Tags, u \in Writers : ForeignWrite(t, u)
78
+ \/ \E t \in Readers : LeaveReadOnly(t)
79
+ \/ Done
80
+
81
+ Spec == Init /\ [][Next]_vars
82
+
83
+ TypeOK ==
84
+ /\ phase \in [Tags -> {"out", "in"}]
85
+ /\ hv \in [Writers -> 0..MaxV]
86
+ /\ board \in 0..MaxB
87
+
88
+ \* Each handoff is written only by its own tag.
89
+ OwnHandoffOnly == \A w \in Writers : author[w] \in {w, "none"}
90
+ \* No board patch is lost: every applied patch is one board version.
91
+ NoLostBoardUpdate == board = patches
92
+ \* A read-only tag never authors a handoff.
93
+ ReadOnlyWritesNothing == \A w \in Writers : author[w] \notin Readers
94
+ ====
@@ -0,0 +1,37 @@
1
+ ---
2
+ title: "Per-tag handoffs: write, merge on read, init"
3
+ ---
4
+ stateDiagram-v2
5
+ state "Legend" as legend {
6
+ lg0: refused
7
+ lg1: session
8
+ lg2: rest
9
+ }
10
+ class lg0 pink
11
+ class lg1 blue
12
+ class lg2 teal
13
+ s0: No handoffs yet
14
+ s1: In session, merged view read
15
+ s2: Handoffs at rest
16
+ s3: Write refused, nothing written
17
+ s4: In session, board moved since read
18
+ [*] --> s0
19
+ s0 --> s1: an AI starts and reads the merged view and the board
20
+ s1 --> s2: a write AI writes its own handoff last or a read-only AI leaves, writing nothing
21
+ s1 --> s3: an AI tries to write another AI's handoff
22
+ s1 --> s0: a read-only AI leaves, writing nothing
23
+ s1 --> s4: a write AI patches the board it read or an AI starts and reads the merged view and the board
24
+ s2 --> s1: an AI starts and reads the merged view and the board
25
+ s3 --> s1: an AI starts and reads the merged view and the board or a write AI patches the board it read or a write AI writes its own handoff last or a read-only AI leaves, writing nothing
26
+ s3 --> s2: a write AI writes its own handoff last or a read-only AI leaves, writing nothing
27
+ s3 --> s0: a read-only AI leaves, writing nothing
28
+ s3 --> s4: a write AI patches the board it read or an AI starts and reads the merged view and the board or a write AI writes its own handoff last or a read-only AI leaves, writing nothing
29
+ s4 --> s1: a write AI writes its own handoff last or a read-only AI leaves, writing nothing
30
+ s4 --> s3: an AI tries to write another AI's handoff or a patch on a moved board is refused
31
+ s2 --> s4: an AI starts and reads the merged view and the board
32
+ s4 --> s2: a write AI writes its own handoff last or a read-only AI leaves, writing nothing
33
+ class s0 teal
34
+ class s1 blue
35
+ class s2 teal
36
+ class s3 pink
37
+ class s4 blue
@@ -0,0 +1,7 @@
1
+ # PerTagHandoff
2
+
3
+ TLC reached 187 states and 799 steps. The chart draws 5 states and 14 arrows.
4
+ The chart does not draw 335 steps that stay in one chart state.
5
+
6
+ ## Rules that hold
7
+ TypeOK, OwnHandoffOnly, NoLostBoardUpdate, ReadOnlyWritesNothing, NoDeadlock
@@ -0,0 +1,19 @@
1
+ TLC2 Version 2.19 of 08 August 2024
2
+ Warning: Please run the Java VM which executes TLC with a throughput optimized garbage collector by passing the "-XX:+UseParallelGC" property.
3
+ (Use the -nowarning option to disable this warning.)
4
+ Running breadth-first search Model-Checking with fp 0 and seed 2588593274694591080 with 1 worker on 8 cores with 4002MB heap and 64MB offheap memory [pid: 528452] (Linux 6.12.113+ amd64, Eclipse Adoptium 25.0.5 x86_64, MSBDiskFPSet, DiskStateQueue).
5
+ Parsing file PerTagHandoff.tla
6
+ Parsing file Naturals.tla
7
+ Semantic processing of module Naturals
8
+ Semantic processing of module PerTagHandoff
9
+ Starting... (2026-11-10 09:39:09)
10
+ Computing initial states...
11
+ Finished computing initial states: 1 distinct state generated at 2026-11-10 09:39:09.
12
+ Model checking completed. No error has been found.
13
+ Estimates of the probability that TLC did not check all reachable states
14
+ because two distinct states had the same fingerprint:
15
+ calculated (optimistic): val = 8.7E-15
16
+ 1042 states generated, 187 distinct states found, 0 states left on queue.
17
+ The depth of the complete state graph search is 10.
18
+ The average outdegree of the complete state graph is 1 (minimum is 0, the maximum 6 and the 95th percentile is 3).
19
+ Finished in 00s at (2026-11-10 09:39:09)
@@ -0,0 +1,20 @@
1
+ export const title = "Per-tag handoffs: write, merge on read, init";
2
+ const busy = (v) => Object.values(v.phase).some((p) => p === "in");
3
+ export const state = (v) => {
4
+ const anyIn = Object.entries(v.phase).filter(([, p]) => p === "in").map(([t]) => t);
5
+ if (v.refused) return "Write refused, nothing written";
6
+ if (anyIn.length === 0) return (v.hv.hub + v.hv.writer === 0) ? "No handoffs yet" : "Handoffs at rest";
7
+ const stale = anyIn.some((t) => v.seen[t] !== v.board);
8
+ return stale ? "In session, board moved since read" : "In session, merged view read";
9
+ };
10
+ export const group = (v) => (v.refused ? "refused" : busy(v) ? "session" : "rest");
11
+ export const colors = { refused: "pink", session: "blue", rest: "teal" };
12
+ export const step = (a) => ({
13
+ Start: "an AI starts and reads the merged view and the board",
14
+ PatchBoard: "a write AI patches the board it read",
15
+ StalePatch: "a patch on a moved board is refused",
16
+ WrapOwn: "a write AI writes its own handoff last",
17
+ ForeignWrite: "an AI tries to write another AI's handoff",
18
+ LeaveReadOnly: "a read-only AI leaves, writing nothing",
19
+ Done: null,
20
+ }[a] ?? a);
@@ -0,0 +1,31 @@
1
+ export const title = "Per-tag handoffs: own handoff, opener-only rows, merged view on read";
2
+ const busy = (v) => Object.values(v.phase).some((p) => p === "in");
3
+ export const state = (v) => {
4
+ if (v.refused) return "Write refused, nothing written";
5
+ const anyIn = Object.entries(v.phase).filter(([, p]) => p === "in").map(([t]) => t);
6
+ if (anyIn.length === 0) {
7
+ if (v.hv.hub + v.hv.writer === 0) return "No handoffs yet";
8
+ return v.conflict ? "At rest, row conflict waiting for the hub" : "Handoffs at rest";
9
+ }
10
+ if (v.conflict) return "In session, row conflict waiting for the hub";
11
+ if (anyIn.some((t) => v.epiOpen[t] && v.openAge[t] === 1)) return "In session, open work marked stale (24h)";
12
+ if (anyIn.some((t) => v.epiOpen[t])) return "In session, work shown in progress";
13
+ if (anyIn.some((t) => v.seen[t] !== v.board)) return "In session, board moved since read";
14
+ return "In session, merged view read";
15
+ };
16
+ export const group = (v) => (v.refused ? "refused" : busy(v) ? "session" : "rest");
17
+ export const colors = { refused: "pink", session: "blue", rest: "teal" };
18
+ export const step = (a) => ({
19
+ Start: "an AI starts, reads the merged view, and stamps it",
20
+ OpenRow: "a write AI opens a board row",
21
+ PatchOwnRow: "the opener patches its row",
22
+ ForeignRowPatch: "an AI tries to patch a row it did not open",
23
+ ResolveConflict: "the hub resolves a marked row conflict",
24
+ StalePatch: "a write on a moved board is refused",
25
+ SaveMaterial: "a write AI saves work in an open session",
26
+ Tick: "time passes (24 hours open, 7 days aging)",
27
+ WrapOwn: "a write AI writes its own handoff last",
28
+ ForeignWrite: "an AI tries to write another AI's handoff",
29
+ LeaveReadOnly: "a read-only AI leaves, writing nothing",
30
+ Done: null,
31
+ }[a] ?? a);
@@ -0,0 +1,11 @@
1
+ SPECIFICATION Spec
2
+ INVARIANT TypeOK
3
+ INVARIANT AtMostOneLive
4
+ INVARIANT HealthyOccupies
5
+ INVARIANT NoBareMint
6
+ INVARIANT ReadLeavesStore
7
+ INVARIANT NoForeignClose
8
+ INVARIANT ClosedHasCloser
9
+ INVARIANT RevokedByOwner
10
+ INVARIANT UnwrappedIdle
11
+ PROPERTY EventuallyClosed
@@ -0,0 +1,254 @@
1
+ ---- MODULE SubkeySession ----
2
+ \* One sub-key, one session slot.
3
+ \* Renewal and reclaim replace that slot. They do not add a second live session.
4
+ \* A handle with no key does not mint the next session.
5
+ \* Another key's credential does not close this session.
6
+ \* Time is a phase: fresh, window, grace, beyond. Handles and key bytes are not states.
7
+ \* `store` counts session-record writes. A status read and a leaked handle leave it unchanged.
8
+
9
+ EXTENDS Integers
10
+
11
+ VARIABLES sess, phase, kind, wrap, gen, live, reclaims, bareMint, closedBy, prevClosed, store, prevStore, act
12
+ vars == <<sess, phase, kind, wrap, gen, live, reclaims, bareMint, closedBy, prevClosed, store, prevStore, act>>
13
+ session == <<sess, phase, kind, wrap, gen, live, reclaims, bareMint, closedBy, prevClosed>>
14
+
15
+ Sess == {
16
+ "opening", "live", "renewal_offered", "ended", "expired",
17
+ "unwrapped", "closed", "auto_closed", "revoked"
18
+ }
19
+ Phase == {"fresh", "window", "grace", "beyond"}
20
+ Kind == {"bot", "chat"}
21
+ Closed == {"closed", "auto_closed", "revoked"}
22
+ Closer == {"none", "same", "owner", "sweep"}
23
+ Act == {"init", "write", "status", "bare", "idle"}
24
+
25
+ TypeOK ==
26
+ /\ sess \in Sess
27
+ /\ phase \in Phase
28
+ /\ kind \in Kind
29
+ /\ wrap \in BOOLEAN
30
+ /\ gen \in 0..1
31
+ /\ live \in 0..1
32
+ /\ reclaims \in 0..1
33
+ /\ bareMint \in BOOLEAN
34
+ /\ closedBy \in Closer
35
+ /\ prevClosed \in BOOLEAN
36
+ /\ store \in Nat
37
+ /\ prevStore \in Nat
38
+ /\ act \in Act
39
+
40
+ Init ==
41
+ /\ sess = "opening"
42
+ /\ phase = "fresh"
43
+ /\ kind \in Kind
44
+ /\ wrap \in BOOLEAN
45
+ /\ gen = 0
46
+ /\ live = 0
47
+ /\ reclaims = 0
48
+ /\ bareMint = FALSE
49
+ /\ closedBy = "none"
50
+ /\ prevClosed = FALSE
51
+ /\ store = 0
52
+ /\ prevStore = 0
53
+ /\ act = "init"
54
+
55
+ \* A step that changes the session record.
56
+ Wrote ==
57
+ /\ store' = store + 1
58
+ /\ prevStore' = store
59
+ /\ act' = "write"
60
+
61
+ \* A step that does not change the session record.
62
+ Read(name) ==
63
+ /\ store' = store
64
+ /\ prevStore' = store
65
+ /\ act' = name
66
+
67
+ Terminal == sess \in Closed
68
+
69
+ Commit ==
70
+ /\ sess = "opening"
71
+ /\ phase \in {"fresh", "window"}
72
+ /\ sess' = "live"
73
+ /\ live' = 1
74
+ /\ Wrote
75
+ /\ UNCHANGED <<phase, kind, wrap, gen, reclaims, bareMint, closedBy, prevClosed>>
76
+
77
+ Lose ==
78
+ /\ sess = "opening"
79
+ /\ sess' = "ended"
80
+ /\ live' = 0
81
+ /\ Wrote
82
+ /\ UNCHANGED <<phase, kind, wrap, gen, reclaims, bareMint, closedBy, prevClosed>>
83
+
84
+ Offer ==
85
+ /\ sess = "live"
86
+ /\ phase = "window"
87
+ /\ live = 1
88
+ /\ sess' = "renewal_offered"
89
+ /\ Wrote
90
+ /\ UNCHANGED <<phase, kind, wrap, gen, live, reclaims, bareMint, closedBy, prevClosed>>
91
+
92
+ Advance ==
93
+ /\ phase /= "beyond"
94
+ /\ phase' = IF phase = "fresh" THEN "window"
95
+ ELSE IF phase = "window" THEN "grace"
96
+ ELSE "beyond"
97
+ /\ IF sess \in {"live", "renewal_offered"} /\ phase' \in {"grace", "beyond"}
98
+ THEN /\ sess' = "expired"
99
+ /\ live' = 0
100
+ ELSE /\ sess' = sess
101
+ /\ live' = live
102
+ /\ Wrote
103
+ /\ UNCHANGED <<kind, wrap, gen, reclaims, bareMint, closedBy, prevClosed>>
104
+
105
+ \* The sub-key and the previous handle. One slot. The previous session is closed.
106
+ Renew ==
107
+ /\ gen < 1
108
+ /\ phase \in {"window", "grace"}
109
+ /\ sess \in {"live", "renewal_offered", "expired"}
110
+ /\ sess' = "live"
111
+ /\ phase' = "fresh"
112
+ /\ gen' = gen + 1
113
+ /\ live' = 1
114
+ /\ prevClosed' = TRUE
115
+ /\ closedBy' = "same"
116
+ /\ bareMint' = FALSE
117
+ /\ Wrote
118
+ /\ UNCHANGED <<kind, wrap, reclaims>>
119
+
120
+ \* The same key, once. A bot's healthy slot is not reclaimed. A chat slot is.
121
+ Reclaim ==
122
+ /\ reclaims < 1
123
+ /\ sess /= "opening"
124
+ /\ ~Terminal
125
+ /\ \/ kind = "chat"
126
+ \/ sess \in {"ended", "expired", "unwrapped"}
127
+ \/ phase \in {"grace", "beyond"}
128
+ /\ sess' = "live"
129
+ /\ phase' = "fresh"
130
+ /\ live' = 1
131
+ /\ reclaims' = reclaims + 1
132
+ /\ prevClosed' = TRUE
133
+ /\ closedBy' = "same"
134
+ /\ bareMint' = FALSE
135
+ /\ Wrote
136
+ /\ UNCHANGED <<kind, wrap, gen>>
137
+
138
+ Unwrap ==
139
+ /\ kind = "chat"
140
+ /\ wrap = FALSE
141
+ /\ phase = "grace"
142
+ /\ sess = "expired"
143
+ /\ sess' = "unwrapped"
144
+ /\ live' = 0
145
+ /\ bareMint' = FALSE
146
+ /\ Wrote
147
+ /\ UNCHANGED <<phase, kind, wrap, gen, reclaims, closedBy, prevClosed>>
148
+
149
+ OwnerClose ==
150
+ /\ ~Terminal
151
+ /\ sess' = "closed"
152
+ /\ live' = 0
153
+ /\ closedBy' = "owner"
154
+ /\ prevClosed' = TRUE
155
+ /\ Wrote
156
+ /\ UNCHANGED <<phase, kind, wrap, gen, reclaims, bareMint>>
157
+
158
+ Sweep ==
159
+ /\ ~Terminal
160
+ /\ \/ phase = "beyond"
161
+ \/ sess = "ended"
162
+ /\ sess' = "auto_closed"
163
+ /\ live' = 0
164
+ /\ closedBy' = "sweep"
165
+ /\ prevClosed' = TRUE
166
+ /\ Wrote
167
+ /\ UNCHANGED <<phase, kind, wrap, gen, reclaims, bareMint>>
168
+
169
+ Revoke ==
170
+ /\ ~Terminal
171
+ /\ sess' = "revoked"
172
+ /\ live' = 0
173
+ /\ closedBy' = "owner"
174
+ /\ Wrote
175
+ /\ UNCHANGED <<phase, kind, wrap, gen, reclaims, bareMint, prevClosed>>
176
+
177
+ \* A leaked handle. It does not mint, and it does not write. Unwrapped is the next open, which presents the key.
178
+ Bare ==
179
+ /\ ~Terminal
180
+ /\ Read("bare")
181
+ /\ UNCHANGED session
182
+
183
+ \* Another tag. The session does not change.
184
+ Foreign ==
185
+ /\ ~Terminal
186
+ /\ Read("idle")
187
+ /\ UNCHANGED session
188
+
189
+ Collision ==
190
+ /\ kind = "bot"
191
+ /\ sess \in {"live", "renewal_offered"}
192
+ /\ phase \in {"fresh", "window"}
193
+ /\ Read("idle")
194
+ /\ UNCHANGED session
195
+
196
+ Rest ==
197
+ /\ Terminal
198
+ /\ Read("idle")
199
+ /\ UNCHANGED session
200
+
201
+ \* A status read. The session record is unchanged, and `store` does not move.
202
+ Status ==
203
+ /\ Read("status")
204
+ /\ UNCHANGED session
205
+
206
+ Next ==
207
+ \/ Commit
208
+ \/ Lose
209
+ \/ Offer
210
+ \/ Advance
211
+ \/ Renew
212
+ \/ Reclaim
213
+ \/ Unwrap
214
+ \/ OwnerClose
215
+ \/ Sweep
216
+ \/ Revoke
217
+ \/ Bare
218
+ \/ Foreign
219
+ \/ Collision
220
+ \/ Status
221
+ \/ Rest
222
+
223
+ Spec == Init /\ [][Next]_vars /\ WF_vars(Advance) /\ WF_vars(Sweep) /\ WF_vars(Commit) /\ WF_vars(Lose)
224
+
225
+ \* One live session, including across renewal.
226
+ AtMostOneLive == live <= 1
227
+
228
+ \* A healthy slot is the one live session.
229
+ HealthyOccupies ==
230
+ (sess \in {"live", "renewal_offered"} /\ phase \in {"fresh", "window"}) => live = 1
231
+
232
+ \* A handle alone never mints.
233
+ NoBareMint == bareMint = FALSE
234
+
235
+ \* A status read and a leaked handle leave the store counter where it was.
236
+ ReadLeavesStore ==
237
+ act \in {"status", "bare"} => store = prevStore
238
+
239
+ \* Another credential does not become the closer.
240
+ NoForeignClose == closedBy /= "foreign"
241
+
242
+ \* A close records who closed it. The sweep, the owner, or the same key.
243
+ ClosedHasCloser ==
244
+ sess \in {"closed", "auto_closed"} => closedBy \in {"same", "owner", "sweep"}
245
+
246
+ RevokedByOwner == sess = "revoked" => closedBy = "owner"
247
+
248
+ \* An unwrapped chat is not a live session.
249
+ UnwrappedIdle == sess = "unwrapped" => live = 0
250
+
251
+ \* Every session reaches a closed state. Renewal is optional. The sweep is not.
252
+ EventuallyClosed == <> (sess \in Closed)
253
+
254
+ ====
@@ -0,0 +1,13 @@
1
+ # SubkeySession
2
+
3
+ TLC reached 4,074 distinct states. The depth of the complete state graph is 19.
4
+ No error. Deadlock checking was on. `store` counts a session-record write.
5
+ A status read and a leaked handle leave `store` unchanged (`ReadLeavesStore`).
6
+ A leaked handle does not mark the session unwrapped.
7
+ Handles and key bytes are not states.
8
+
9
+ ## Rules that hold
10
+ TypeOK, AtMostOneLive, HealthyOccupies, NoBareMint, ReadLeavesStore, NoForeignClose, ClosedHasCloser, RevokedByOwner, UnwrappedIdle, EventuallyClosed
11
+
12
+ The private model check reported 4,074 distinct states, depth 19, and no error.
13
+ This public note does not include the model-checker stdout.