test(calc): make the not-evaluated-inline assertion exact, not thread-id based

The first form compared the publish's managed thread id with the caller's, which flaked
(1 in 6): the evaluation pump may reuse the pooled thread the test released while awaiting
the drain, so an id match proves nothing. It now sets a ThreadLocal flag for exactly the
OnDependencyValue window, so 'published inline' is answered on the stack rather than by
thread identity. Re-falsified by making SchedulePump run the pump synchronously (red
immediately, reverted); 5 consecutive clean suite runs after.
This commit is contained in:
Joseph Doherty
2026-08-10 08:07:27 -04:00
parent 2637be8212
commit 5c8d6f6f98
2 changed files with 19 additions and 10 deletions
+6 -2
View File
@@ -262,11 +262,15 @@ run so a tag dropped mid-evaluation discards its result rather than publishing i
RED first, two tests, both failing against the pre-fix code:
`A_dependency_arrival_does_not_run_the_script_on_the_callers_thread` (the publish — which can only happen
after the script ran — landed on the caller's own thread id) and
after the script ran — landed on the caller's own stack, inside the callback) and
`A_slow_script_blocks_neither_the_dependency_callback_nor_a_concurrent_read` (a 600 ms busy-wait script:
the callback took 1.21 s, and `ReadAsync`, which needs the same state lock, was stuck behind it). Both
carry a positive control asserting the value still computes and publishes, so neither can pass against a
driver that simply evaluates nothing.
driver that simply evaluates nothing. ⚠️ The first test's original form compared the publish's **thread id**
against the caller's and was itself flaky (1 failure in 6 runs): the pump is free to reuse the pooled thread
the test released while awaiting, so an id match means nothing. It asserts on a thread-local flag set for
exactly the callback window instead — which is exact, and was re-falsified by making `SchedulePump` run the
pump synchronously (red immediately, then reverted).
Known trade, documented rather than hidden: the pending queue is unbounded. Under sustained arrival
pressure the previous inline path applied backpressure by blocking the mux actor — which is the defect —