Repository navigation
Description
Context
E2E — Elixir Scanner Pipeline is red on main. With #642 making the output visible, the
cause is now measurable rather than mysterious.
Reproduced locally (Elixir 1.18.3 / OTP 27, mix deps.get clean):
| Run | Result |
|---|---|
mix test (full suite) |
1398 tests, 20 failures |
mix test test/reflexive_test.exs (alone) |
16 tests, 0 failures |
Every one of the 20 failures is in test/reflexive_test.exs with the same shape:
** (exit) exited in: GenServer.call(Hypatia.Supervisor, {:terminate_child, Hypatia.SelfDiagnostics}, :infinity)
** (EXIT) no process: the process is not alive or there's no process currently
associated with the given name, possibly because its application isn't started
test/reflexive_test.exs:29: Hypatia.ReflexiveTest.take_supervised/1
The file passing in isolation is the key datum: this is a test-isolation defect, not a
product bug. Hypatia.Supervisor is alive at the start of an isolated run and dead by the
time reflexive tests run in the full suite.
Likely mechanism (to be confirmed, not assumed)
take_supervised/1 (test/reflexive_test.exs:29) removes a child from the live application
supervisor so start_supervised!/1 can own a clean instance:
Supervisor.terminate_child(Hypatia.Supervisor, module)
Supervisor.delete_child(Hypatia.Supervisor, module)
start_supervised!(module)
on_exit(fn -> ... Supervisor.start_child(Hypatia.Supervisor, module) end)Two candidate causes, both consistent with the evidence:
- Restore never happens. If a test crashes before
on_exitruns, orstart_child
fails (the spec was deleted), the child stays absent and latertake_supervisedcalls
compound the damage. max_restartsexceeded.lib/application.ex:90usesstrategy: :one_for_onewith
the defaultmax_restarts: 3, max_seconds: 5. Repeated terminate/restart churn across
many tests — plus any child that crash-loops — trips the limit and the whole supervisor
shuts down, takingHypatia.Supervisorwith it. This matches "no process ... its
application isn't started" exactly.
Hypatia.ReflexiveTest is async: false, so ordering is deterministic per seed — the failure
should be reproducible with a fixed --seed.
Changes
Diagnosis first — do not guess at a fix:
- Confirm which of the two mechanisms applies: run the full suite with a fixed
--seed,
and assertProcess.whereis(Hypatia.Supervisor)insetupto find the first test at
which it is alreadynil. Bisect by test file. - Then fix at the right level:
- If restore-failure: make
take_supervised/1restore idempotently and register the
on_exitbefore the mutation, so a crash mid-setup still restores. - If
max_restarts: stop mutating the live application supervisor from tests at all.
Preferred shape — start these GenServers under the test's own supervisor via
start_supervised!/1with an explicitname:, and leaveHypatia.Supervisor
untouched. A test should not need to dismantle the application to observe it.
- If restore-failure: make
- Consider raising
max_restartsinlib/application.ex:90only if it is genuinely
warranted in production — not as a way to paper over test churn.
Acceptance criteria
mix testis 0 failures on a clean checkout, at three different seeds.mix test test/reflexive_test.exsstill passes in isolation (16 tests).- No test terminates or deletes a child of
Hypatia.Supervisor, or if it must, the
restore is proven by asserting the child is alive again after the suite. E2E — Elixir Scanner Pipelinegreen onmain.
Test plan
- Unit: a regression test asserting
Process.whereis(Hypatia.Supervisor)is non-nil at the
end ofreflexive_test.exs. - Suite: full
mix testat seeds 0, 1, and a random one — all green. - CI: the E2E job green on a PR branch, with fix(tests): e2e.sh discarded all mix test output, making CI undebuggable #642 merged so a regression is legible.
Model tier
Sonnet — bounded, single-repo, no new design; the mechanism is narrowed to two
candidates and the acceptance criteria are mechanical. Escalate to Opus only if the
cause turns out to be a genuine supervision-tree design problem rather than test hygiene.
Related
- fix(tests): e2e.sh discarded all mix test output, making CI undebuggable #642 — makes this failure visible at all (
e2e.shwas discarding the output). - fix(ci): arangodb probe can never pass (401) + stress-test fake/impossible steps #640 — the other two red jobs in
tests.yml(arangodb health check); independent cause. lib/application.ex:90— the:one_for_one/max_restartssite.test/reflexive_test.exs:29—take_supervised/1.
Activity
hyperpolymath commentedon Jul 21, 2026
Correction to the original diagnosis, and a partial fix
Two things in the opening post were wrong, and the corrected picture is better.
Wrong: "
Hypatia.Supervisoris torn down mid-run"I instrumented
test_helper.exswith a monitor onHypatia.Supervisorand ran the fullsuite. No
:DOWNever fired — the supervisor survives the whole run. Themax_restartshypothesis is dead.Wrong: "20 failures, all in reflexive_test"
That was one seed. The failing set changes with the seed:
dashboard,root_hygiene,workflow_audit,metrics,recipe_healthSo this is not one bug. It is order-dependent state leakage with several independent
sources, of which reflexive was merely the loudest.
Confirmed: the actual reflexive mechanism
take_supervised/1registered its restoringon_exitafter mutating the livesupervisor. If anything in between raised, the child was deleted and never restored — for
the rest of the suite — so one root failure cascaded into all later tests needing that
module.
Proved by injecting a raise after the delete and asking the supervisor what children it has
(load-independent, unlike suite counts):
Fixed in #644: register the restore first, make it idempotent, and inspect
Supervisor.start_child/2's return instead of discarding it.Also found: the suite is load-sensitive
reflexive_test.exs(and others) synchronise with:timer.sleep(30)/:timer.sleep(50).Under load those flake, which made a whole-suite A/B of the fix inconclusive — counts
moved in both directions across seeds for reasons unrelated to the change. Worth replacing
with deterministic waits (poll-until-condition, or
assert_receiveon a telemetry event);until then, suite-count comparisons on a busy machine are not evidence.
Revised remaining work
dashboard,root_hygiene,workflow_audit,metrics,recipe_health) — find each leak; these are independent of the above:timer.sleep/1synchronisation with deterministic waitsmix testgreen at three seeds" a meaningful acceptance gateRe-tiering: the cascade was
cx/L2and is done. The remainder iscx/L3— severalindependent leaks across unrelated test files, needing real comprehension of each.
fix(test): register the supervisor restore BEFORE mutating (#643) (#644)
hyperpolymath commentedon Jul 21, 2026
The failure count is currently unmeasurable — CI does not pin the seed
Two consecutive CI runs on this branch, with zero Elixir source changed between them
(
git diff --stat 311b504..1dd31af=.github/workflows/tests.ymlonly, 0 files matching\.exs?$|^lib/|^test/):311b5041398 tests, 73 failures1dd31af1398 tests, 79 failuresSame code, different seed, ±6 failures. The dominant cluster is identical in both
(
contract_test42,blackboard_test40,reflexive_test33,kin_test30), so this isthis issue's order-dependence, not a regression.
The consequence is what matters: while the seed floats, nobody can distinguish a real
regression from reshuffled noise. A fix that genuinely removes 6 failures and a seed that
happens to be kinder look identical. I nearly mis-reported the 73→79 delta as a regression
myself, and only caught it by checking that no Elixir file had changed.
Cheap fix, worth doing before any work on this issue
Pin the seed in CI so the count is comparable run to run:
or simply
mix test --seed 0in the workflow. Then:EXUNIT_SEED=<n> mix teststill reproduces any specific ordering on demandwhich is the only place randomness actually earns its keep
Without this, the acceptance criterion "failures drop from N" is not checkable.
Related
in combination), split out so they can be fixed independently of this cascade
test: pin ExUnit seed to 0 (#643)
fix: close the order-dependent test failure class (metrics race + sup…
hyperpolymath commentedon Aug 7, 2026
Seed pinned, and the residual cluster is now closed — but the diagnosis in comment 2 needed one correction.
test/test_helper.exsnow setsseed: 0(the prerequisite from comment 2: failure-count deltas are evidence again). Pass--seed Nexplicitly to probe ordering.What pinning revealed is that not all of the residual instability was ordering at all. Three distinct mechanisms, all now fixed:
Genuine order-dependence — shared supervised state.
Hypatia.Watcher's queue-depth map keyed Prometheus labels oninspect(child_id); Bandit's id is{module, make_ref()}, so a fresh#Reference<...>landed in the label (unbounded cardinality) and its braces broke the exposition test's label parsing — but only once the 30s queue poll had fired, hence in-suite only. Ids now collapse to the module. Separately,Diagnostics.Monitor's 30s tick is now config-gated off in the test env: its recovery pathGenServer.stops supervised children mid-suite, which is invisible order-dependence by construction.Not ordering — cross-RUN state.
RecipeHealthTestderived "unique" recipe ids fromSystem.unique_integer/1, which is unique only within one BEAM instance: it restarts from a low base eachmix testand allocates stride-32 blocks whose offset moves with whatever ran before it. The outcomes log is append-only and was never truncated, so a later run redrew ids that an earlier run had already written records under, andverification_rate/2aggregated both. Measured 2026-08-07: 194 staletest-recipe-health-*ids accumulated since 07-30; one failure asserted 6 successes and observed 16 — exactly 10 stale (from a 4-day-old quarantine test) plus 6 new. This is why pinning the seed did not stabilise that file. Fixed by giving ids a monotonic-clock component and wiping the throwaway store intest_helper.exs.Not ordering — a timer race.
RateLimiter"enqueue increments queue size" enqueued for a bot that was not rate limited, then slept 50ms and assertedqueue_size >= 1. The 5s:drain_queuetick pops and dispatches any entry whose bot passes the check, so a tick inside that window emptied the queue. Where the tick falls shifts with total suite duration — seed-dependent in appearance, a pure race in fact. Fixed by saturating the burst limit first so drain returns the entry (also the realistic scenario), with delta rather than absolute counter assertions.Also on this issue's remit:
test/contract_test.exs's unhardenedtake_supervised/1is gone — #688 removed it outright, which is the better fix (those tests isolate by unique key, not by process). Thetest/reflexive_test.exshardening from #644 remains the reference pattern where a test genuinely must take a child from the supervisor;test/watcher_test.exsnow uses it, having previously raced the supervised Watcher's:permanentrestart.Current state: 1433 tests, 0 failures, 242 excluded — verified at seeds 0, 1, 42 and 777. The
:timer.sleep(30)/(50)synchronisation this issue also flags remains in place where it is not load-bearing; replacing those with deterministic waits is the honest remaining scope if you want to keep this open for it.hyperpolymath commentedon Aug 24, 2026
Re-verified after the CI lock wall was removed by #715. The supervisor defect described here was fixed by #644 / e5d6f26:
mix test test/reflexive_test.exs --seed 0is 16 tests, 0 failures. A fullmix test --seed 0 --max-failures 2no longer produces any Hypatia.Supervisor or reflexive failures; its first two failures are unrelated merge-orchestration policy assertions in StrategistTest and SensorTest. The live E2E job on #715 stopped earlier at the Elixir lint gate and did not execute the suite, so that lint failure should be tracked separately rather than keeping this stale supervisor issue open.