| @@ -81,7 +81,7 @@ The reference interpreter implements this model before the native runtime. It is |
| 81 | 81 | **The `proc` effect:** |
| 82 | 82 | - `proc` is an ordinary effect declared in `std/process`: `spawn`, `self`, `subject`, `send`, `receive` (with a timeout), `link`, `monitor`, `kill`, `trap_exits`, `exits`, `sleep`. |
| 83 | 83 | - Operations not handled inside an actor reach its root, where the scheduler answers them. |
| 84 | | −- Because it is an ordinary effect, a test *can* handle `proc` itself. It must then handle every operation (E0504), so mocking is verbose. |
| 84 | +- Because it is an ordinary effect, a test *can* handle `proc` itself. It must then handle every operation (E0504), so mocking is verbose. A mock with scripted replies is not type-safe either: see the note on testing and supervision below. |
| 85 | 85 | |
| 86 | 86 | **Determinism:** |
| 87 | 87 | - The run queue is round-robin, and an actor is preempted after 2000 calls. |
| @@ -312,3 +312,24 @@ Measured on top of Revision 4 (`v1-speed-runtime`), against it, on a quiet machi |
| 312 | 312 | - The loom models: the existing hand-offs, plus `timers::loom_models` (an add racing a firing thread; two adds racing a scan). |
| 313 | 313 | - Every `tests/run` program, 20 times each on 8 threads: the same exit status as one thread, with the leak oracle at 0. |
| 314 | 314 | - `scripts/stress.sh` on 8 threads and on 1. |
| 315 | + |
| 316 | +## Note — 2026-10-12: supervision uses links, and how to test actors (issue #159) |
| 317 | +**Status:** for review (#44). |
| 318 | + |
| 319 | +**Why supervision uses links, not handlers.** A common idea is to make a supervisor an effect handler wrapped around its children, catching their crashes. In Louise it can't work: |
| 320 | +- **A child runs on a fiber of its own,** maybe on another thread, so a handler on the parent's stack never sees the child's code. |
| 321 | +- **Panics are not effects** (ADR 0001, "let it crash"), so no handler catches one. |
| 322 | + |
| 323 | +So crashes travel as exit signals over links, and `std/supervisor` traps them (`trap_exits`, `spawn_link`). `spawn_link` is one operation, so that a child can't stop before its link exists (above). A mock that does `spawn` then `link` would bring that race back. |
| 324 | + |
| 325 | +**Mocking `proc` is not practical.** A handler of `proc` must cover its 14 operations (E0504). Worse, scripted replies are not type-safe: |
| 326 | +- the subjects are created inside the code under test, so a test can't name their message types; |
| 327 | +- a reply of the wrong type would be read as another type. Issue #169 found that handler clauses aren't checked against an operation's polymorphism. |
| 328 | + |
| 329 | +**What to do instead:** |
| 330 | +- **Real actors as fakes:** a spawned stand-in that answers from a script. |
| 331 | +- **Subjects as parameters:** the code under test takes its collaborators' subjects as parameters. |
| 332 | +- **Virtual time:** it makes timeouts deterministic (Revision 3: virtual until a socket opens). |
| 333 | + |
| 334 | +The demo's store tests call the store's message handler directly, which needs no actor at all. |
| 335 | + |