Commit da8db01
feat(formal/tla): TLA+ model of Invoker — isolation + classification coverage (#253)
## Summary
- Adds `specs/elixir-harness/Invoker.tla` — TLA+ model of
`BojRest.Invoker` (Phase 2 fork-per-request Zig FFI dispatcher)
- Adds `specs/elixir-harness/Invoker.cfg` — TLC config: 3 requests, 8
possible result kinds
- Updates `specs/elixir-harness/README.adoc` — adds Invoker section,
moves it out of "Not yet modelled"; updates sanity-control shell loop
## What the model covers
`Invoker` is **stateless and synchronous**: `System.cmd/3` blocks until
`boj-invoke` exits; there is no pool, no GenServer, no shared mailbox.
The interesting formal question is not a state machine but an
**isolation** guarantee: N concurrent callers cannot interfere with each
other's result.
**State variables**: `status[r]` (new/running/done), `result[r]` (one of
8 terminal kinds), `doneCount[r]` (double-resolution detector).
**Actions**:
- `Invoke(r)` — CLI found, subprocess spawned (new → running)
- `CliMissing(r)` — `cli_path()` returns nil, short-circuits immediately
(new → done)
- `RespondOk / RespondCliCrashed / RespondArgs / RespondOpen /
RespondMissingSym / RespondInitFailed` — subprocess exits (running →
done)
**Properties verified**:
- `DoneOnce` — each invocation resolves at most once; no race can
deliver two results for the same call (since `System.cmd` is blocking,
the subprocess exits exactly once)
- `Consistent` — running ↔ no result yet; done ↔ exactly one result
- `EventuallyDone` [ASSUMED] — running ~> done, under the assumption
that the subprocess exits on its own
**Known gap documented**: Phase 2 has no per-invocation timeout.
`System.cmd` blocks indefinitely if `boj-invoke` hangs. ADR-0005
specifies 5 s for the future pool (not yet implemented).
`EventuallyDone` rests on an [ASSUMED] liveness condition.
**Non-vacuity**: all 7 result kinds refuted by TLC with witness traces.
## Formal coverage after this PR
| Component | Model | Headline properties |
|---|---|---|
| `JsWorker` (single slot) | `JsWorker.tla` | `ReplyOnce`,
`EventuallyReplied` |
| `JsWorkerPool` (N slots) | `JsWorkerPool.tla` | + `RouteConsistency`,
crash isolation |
| `Invoker` (Zig-FFI, Phase 2) | `Invoker.tla` | `DoneOnce`,
classification coverage |
| Zig FFI ABI | `abi_axioms.zig` + `abi_verify.zig` | comptime proofs +
40 boundary tests |
| Idris2 ABI | `SafetyLemmas.idr` | 4 class-J axioms + `charEqSym`
discharged |
## Test plan
- [ ] `java -cp tla2tools.jar tlc2.TLC Invoker.tla` — no invariant
violation, `EventuallyDone` holds
- [ ] All 7 sanity controls (`ReachOk` … `ReachInitFailed`) each refuted
by TLC with a short witness trace
- [ ] `JsWorker.tla` and `JsWorkerPool.tla` still pass (no regression)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01F8pqMfJViUaKabWKNQ9wUg
---
_Generated by [Claude
Code](https://claude.ai/code/session_01F8pqMfJViUaKabWKNQ9wUg)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent 9fb8223 commit da8db01
3 files changed
Lines changed: 256 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
186 | 192 | | |
187 | 193 | | |
188 | 194 | | |
189 | 195 | | |
190 | 196 | | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
191 | 272 | | |
192 | 273 | | |
193 | | - | |
194 | | - | |
195 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
0 commit comments