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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
;; supervisor.lisp — certifiable supervision + isolation honesty for the
;; actor scheduler (pure Lisp library, zero interpreter changes).
;;
;; Erlang supervises on trust; here the two trust points become checkable:
;; 1. The restart POLICY is data, and its decision core is a pure
;; function — certify-policy pins it in both directions with
;; check-exhaustive ("never restart at/over budget, always under").
;; 2. A handler can be spawned from SOURCE through a static isolation
;; check that runs BEFORE anything evaluates (2.1 gate ordering — a
;; trojan never runs): set! only on declared owned names, calls only
;; to declared names / a pure whitelist / send! (messages are the
;; sanctioned interaction). Computed calls — ((car msg)) invoking a
;; function smuggled in a message — are refused outright and cannot
;; be declared away: every named piece can be whitelisted; only the
;; call shape betrays it.
;;
;; Claim discipline: "policy proven budget-honest on the declared domain",
;; "handler source sets only its declared names" — never "safe".
;;
;; Supervision semantics (deliberate, receipted):
;; - A child is (name init-thunk); init-thunk returns a FRESH handler,
;; so restart re-initializes state (Erlang child semantics).
;; - The in-flight message that crashed a handler is LOST (dequeued
;; before handling, exactly like the plain scheduler and like Erlang's
;; in-flight loss) — the crash receipt records it.
;; - The budget is a per-child LIFETIME restart count, not Erlang's
;; per-time-window rate: a time window would break determinism, and
;; the lifetime count is the honest deterministic analog.
;; - A failed child's queued mail drains to dead letters one message per
;; step, so run-supervised still quiesces.
;; - An init-thunk that crashes during restart becomes an init-crash
;; receipt + give-up (it throws inside supervised-step's catch
;; handler, so it needs its own try-catch), never a dead supervisor.
;; Missing vs Erlang, stated plainly: flat supervisor (no supervisor of
;; supervisors yet), no one-for-all / rest-for-one strategies.
;; ── Supervision ─────────────────────────────────────────────────────────
; ((name init restarts status) ...)
; ((crash name msg err restarts decision) ...)
; ((name msg) ...) — drained after give-up
;; THE CERTIFIABLE CORE — pure, total on its domain. restart iff budget left.
;; Budget honesty, proven by exhaustion (both directions — pins the
;; function): never 'restart at/over budget, always 'restart under it.
;; Like agents-step, but: a failed child's queued messages drain to dead
;; letters (one per step, so the loop still quiesces), and a handler crash
;; becomes a receipt + policy decision instead of killing the run.
;; ── Isolation honesty ───────────────────────────────────────────────────
;; A handler is spawned from SOURCE (s-expr data, evolve.lisp-style), and
;; the source is refused BEFORE evaluation unless every (set! x ...) target
;; is in the declared owned list and every called name is declared, a
;; whitelisted pure builtin, or send!. Conservative direction throughout:
;; over-collection can only cause false refusal (e.g. set! on a handler's
;; own let-bound name needs declaring). One-level check by design —
;; declared calls are trusted; certify helpers separately (or run this
;; checker on their source too). quote is skipped (inert data);
;; quasiquote is walked in FULL (over-approximation, same safe direction).
;; Refuse-by-default spawn: static check FIRST, eval only after it passes
;; (same gate ordering as 2.1 — a trojan source is never evaluated).
;; ── Supervision TREES (escalation + strategies) ─────────────────────────
;; The Erlang-faithful layer, coexisting with the flat supervisor above
;; (which the earlier goldens pin; per-child lifetime budget documented
;; there). Trees differ deliberately:
;; - The budget is per-SUPERVISOR (restart intensity, Erlang-style —
;; lifetime count, not time-windowed, same determinism reasoning).
;; - Exceeding it fails the supervisor AS A UNIT: its whole subtree is
;; terminated and the failure ESCALATES to its parent, which decides
;; with its own policy; root exhaustion = tree-failed.
;; - Strategies are DATA: one-for-one / one-for-all / rest-for-one.
;; strategy-restart-set is pure, and certify-strategy pins its
;; semantics exhaustively (set membership per crash index).
;; - Mailboxes survive a restart (they belong to the scheduler);
;; handler STATE does not. Erlang drops the queue with the process —
;; keeping it is a divergence, stated here, receipted nowhere else.
;; Spec shape: (sup name (strategy budget) child ...), child =
;; (worker name init-thunk) | nested (sup ...). Workers spawn depth-first,
;; so scheduler order remains the spec's textual order — deterministic.
; ((name policy restarts status parent) ...)
; ((name init status sup) ...)
; ((sup ((worker w) | (sup s) ...)) ...) ordered
;; Pure, certifiable: which children restart when `crashed` crashes.
;; Pins each strategy's semantics on every (n children, crash index i)
;; pair in the domain: one-for-one = exactly the crashed child,
;; one-for-all = all of them, rest-for-one = the crashed one and every
;; child spawned after it.
;; Fresh handlers for one child entry; a (sup s) entry resets the whole
;; subtree — counters, statuses, every descendant's state.
;; Terminate a supervisor as a unit: it and every descendant marked failed
;; (their queued mail then drains to dead letters, one per step).
;; One decision at supervisor `sname` about crashed child entry
;; (worker w) | (sup s): same certified supervisor-decide core (policy is
;; (strategy budget); decide reads the budget), then the certified
;; strategy set. A re-init that itself crashes escalates — never a dead
;; supervisor, exactly like the flat version's init-crash receipt.