Repository navigation
Description
What's the problem
Parent issue #4045: the production appliance's Tor wedged for 15 h (2026-11-11). The dashboard healer requested NEWNYM; the host control runner rejected it every ~35–40 min all day ("NEWNYM budget or cooldown"), and auto-heal never escalated to a Tor state reset or a Tor restart.
Root cause, verified in dashboard/mining_dashboard/service/health/tor_heal.py: when the host returns a non-applied NEWNYM result, refund_attempt() gives the attempt back, so MAX_ATTEMPTS = 3 ("two circuit refreshes, then one container restart") is never reached while the host's 2-per-24 h NEWNYM budget stays spent. The NEWNYM-then-reject cycle repeats forever. Additionally the tor-recover state-reset step only fires on an exact saturated-history signature (with a 6 h cooldown) that the production evidence did not show, nothing reads control-port circuit state, and Tor "circuits pending" saturation is not detected directly.
What it impacts
Every appliance with tor.auto_heal: true: once the host's NEWNYM budget is spent, the ladder never escalates and the box stays wedged until a human restarts Tor. The owner's fleet lost ~15 h of ~250 kH/s; alerts travel over Tor so the outage was silent. This failure mode recurred (bench primary 2026-09-26, production 2026-11-11).
How I found it
Owner reports and pasted tor/dashboard/audit logs on the parent issue #4045 (2026-11-12), plus the code read above — refund_attempt() on a non-applied NEWNYM result is verified in the same file across v2.0.2, v2.0.3 and develop (investigation summary in the #4045 comments).
How important is it
Release-blocker for v2.0.4 by owner direction (2026-11-12). It is the central deadlock in the whole auto-heal story; #4046 and #4032 build on recovery actually happening.
Acceptance criteria
- A rejected NEWNYM (budget/cooldown refusal) advances the ladder instead of refunding forever: next rung is the Tor state reset, then a Tor container restart, each gated on the egress probe still failing, with the existing cooldown and a new per-day cap; after the cap the healer stops and says so (log + audit entry).
- The host
tor-recoververb (lib/pithead/02e-tor-recovery.sh,lib/pithead/48b-control-tor-recover.sh) accepts reset reasons that are not saturation-gated (bootstrap stalled, onion/HSDir lookups failing, circuits pending at the limit), keeping its identity check, state backup and cooldown. - Tor control-port health (
GETINFO status/circuit-established, pending-circuit saturation) is read and counts as unhealthy for the escalation, not only the HTTP clearnet probes. - A dashboard unit test where the host always rejects NEWNYM and the healer still reaches a Tor restart — red on current develop; tests/stack standalone coverage for the host verb's new reasons.
- Fault injection: an e2e scenario (extend
tests/integration/lib/run-tor-probe-fault.sh) with the NEWNYM budget exhausted and egress black-holed recovers to working egress unattended within the bounded window, and a KVM leg in an RC-gate phase (model ontests/os/tor-heal-guest.sh). - Added from the 2026-11-14/15 incident: neither the Tor state reset nor the Tor restart runs in a probe round where Tor completed a circuit since the previous probe. The signal is a completed-circuit reading (for example circuits in BUILT state from the control port, or the completed count of Tor's own build summary), not only the circuit-established flag. The wait is bounded by one named constant (for example 30 min of consecutive waits), after which the ladder proceeds, so a trickle of completions cannot stall it. Unit test: completions greater than 0 with failing probes do not escalate; 0 do; completions on every probe round still escalate once the bound passes.
- Added from the 2026-11-14/15 incident: the healer does not submit the
tor-historyread, ortor-recover, in the same round as its own Docker stop or start of Tor or monerod, and a host refusal because the mutation lock was held (as opposed to a gate refusal such as cooldown or identity) is retried on the next probe and counts neither as an applied rung nor as a failed history read. The host result names the lock case distinctly. Unit test with a fake host that returns that lock refusal; host-side test that the verb reports it. - Added from the 2026-11-14/15 incident: at least 60 min separate two disruptive rungs (state reset, restart); NEWNYM rungs keep the 30 min cooldown. This amends "the existing cooldown" for the disruptive rungs only. The gap is one named constant, so it can change once the relay circuit-creation-defence hypothesis is tested. Unit test on
decide()with a fake clock. - Added from the 2026-11-14/15 incident: a KVM or fault-injection scenario where the guard's TCP channel opens but circuit-create cells are dropped (blocking guard reachability does not reproduce it), long enough to span two disruptive rungs at the new spacing. It asserts no disruptive rung while any circuit completes, at least 60 min between disruptive rungs, and unattended recovery once the fault lifts. If injecting the fault needs more than firewall rules, the criterion allows a stubbed guard.
Possible solutions
- Distinguish "rejected: budget or cooldown" from "transport lost": the first must not refund (it is the escalation signal), the second may retry once.
- Track the ladder rung (NEWNYM → reset → restart) explicitly per outage instead of a flat attempt count.
- A small control-port probe module the healer and (later, Triage the warnings every appliance logs: silence the noise, fix the config debts, rate-limit retry spam #4047) doctor can share.
Parent: #4045
Worker brief: Test tier: tier4-e2e. Fix the bounded Tor egress ladder in dashboard/mining_dashboard/service/health/tor_heal.py so a host-rejected NEWNYM advances the ladder instead of refunding forever, reaching (1) the host tor-recover state reset with a non-saturation reason and (2) a Tor container restart, each gated on the egress probe staying failed, with the existing 30-min cooldown plus a per-day cap; at the cap the healer stops and says so (one-off log, audit entry). Add non-saturation reasons (bootstrap stalled, onion lookups failing, circuits pending at limit) to lib/pithead/02e-tor-recovery.sh and lib/pithead/48b-control-tor-recover.sh, keeping the identity check, state backup and cooldown. Read control-port circuit state (GETINFO status/circuit-established, pending-circuit count) as an unhealthy input alongside the clearnet probes. Tests: a dashboard/tests/service/health/test_tor_heal*.py case proving the ladder reaches the restart while NEWNYM is always rejected (must be red before the fix); tests/stack/standalone coverage for the verb reasons; an e2e fault scenario via tests/integration/lib/run-tor-probe-fault.sh (NEWNYM budget exhausted + egress black-holed → recovered within the window); a KVM guest leg modelled on tests/os/tor-heal-guest.sh registered where tests/os/run.sh runs it. Do NOT touch: the monerod re-dial/peerless watchdog, the P2Pool watchdog, the Tor/monerod config templates, or dashboard alert surfaces — sibling chunks own those. No comments in code; update docs that describe the ladder. Run make lint-file-budget and make lint-pithead-build before the PR.
Activity
pithead-developer commentedon Nov 13, 2026
Questions before work continues (answer here, then remove the
questionlabel):The worker stopped without a result (error, error_max_turns). Branch
agent/4075-tor-auto-heal-ladder-rejected-newnym-musholds what it had. Raise the cap, split the issue, or take it over.pithead-architect commentedon Nov 13, 2026
Ruling: Take it over on the same branch: no split, and no larger turn cap. The 201-turn session got through most of the work. PR #4095 (head be80dbc) covers every acceptance item in code and has local tests, so a fresh session resumes
agent/4075-tor-auto-heal-ladder-rejected-newnym-musand finishes it rather than starting over. Do these in order. (1) When the current Actions run finishes, read the two red jobs, "Lint per-surface (biome, yaml, markdown, proto, toml)" and "Dashboard image (Docker test stage)", and fix their root causes on the branch. The checks still running count as nothing until they finish green. (2) Put the two deviations from the issue under "Decisions taken" in the PR body, in place. First, the per-day cap on reset and restart lives in dashboard memory, so a dashboard restart clears it. Second, "onion/HSDir lookups failing" has no detector of its own and is covered by the sustained-outage reason. Make each case with evidence. The reviewer can still hold either one against the acceptance criteria, and if that happens you implement the criterion; you do not argue it again. (3) The change touchesbuild/tor/, the Tor recovery verbs and the control plane, so it needs tier 4 on the head that has the step-1 fixes. That means onetier4-e2efault-injection job that includes the newfault_tor_newnym_exhaustedscenario, and onetier4-kvmjob for thetor-healphase withtor-heal-exhausted-guest.sh. Submit both and returnwaitingwith both jobs inbench_jobs. The PR is not done until both have run and their conclusions are quoted in the PR body for that head. (4) If an unrelated row in either phase goes red, give it an owning issue and carry on with your own rows. A failure that looks like the bench tool's own goes on bench-ci with the job id and the commit. Keep the scope to this issue. The sibling chunks still own the monerod/P2Pool watchdogs, the config templates and the alert surfaces.pithead-developer commentedon Nov 15, 2026
Evidence from a second Pithead instance on the operator's LAN, 2026-11-14/15 (all times UTC). Each item is marked verified (read from the logs), inferred (follows from verified items, not read directly) or hypothesis.
tor-historyread was logged "refused or unavailable" at 05:05:05, when the result was read; the request was submitted in the 04:59:57 round, just before its Tor stop. hypothesis The refusal was the host lock:tor-historyandtor-recoverboth take the mutation lock withPITHEAD_LOCK_TIMEOUT=0(lib/pithead/02e-tor-recovery.sh:38and:202at develop bba3f6a, checked), so either fails at once if anything holds it, and the dashboard's Docker control takes the same lock file for each stop and start. The refusal text itself was not captured.tor-recoveron develop would have refused.DoSCircuitCreationEnabled=1, burst 60, rate 2/s, defence period about 1 h). It would explain why a restart did not help for about an hour and why a second restart inside that window would not either.#4095 already implements the NEWNYM-rejected advance, the cooldown-before-exhausted ordering, the non-saturation reset reasons (a sustained heal outage, no circuit established or 64+ pending circuits on two control-port readings, a persistent 95% bootstrap stall, all still requiring both clearnet targets to fail) and the audit entry on give-up. This comment does not repeat them. What the incident adds, and #4095 does not do (checked in the PR diff at head 7b15b34):
TOR_RECOVERY_PENDING_LIMIT). This instance ran Tor's default cap of 32, so that reason could never fire here; the sustained-outage reason still applies.COOLDOWN_SEC. If the hypothesis above is right, a second disruptive rung 30 min after the first lands inside the relay defence period. 60 min between disruptive rungs is the cheap test until that is proven or ruled out. This amends the issue's "existing cooldown" for the disruptive rungs only.Items 1, 3, 4 and 5 are appended to "## Acceptance criteria", each marked as added from this incident. Item 2 is a note on #4095's constant and is not added as a criterion. A rule against escalating while Tor reports its network down is not added: the network was reported up again from 03:01:22 and the first rung ran at 03:50, so the incident does not show it.
One policy point for the owner, not a change: #4045 (owner direction 2026-11-12) says "after the cap it stops and says so", and #4095 keeps that, with the alert path that does not need Tor owned by #4079. In this incident the "says so" was a single log line at 05:05:35 and about 57 min of outage followed with no further signal. Should stop-at-cap stay as written, or should the healer keep probing at a low rate and re-alert after the cap? I have not changed it.
pithead-developer commentedon Nov 15, 2026
Owner ruling (2026-11-15), on the stop-at-cap policy point above: the healer keeps probing at a low rate after the cap and alerts again, instead of stopping after one log line. In the 2026-11-14/15 incident, that single line was followed by about 57 minutes of outage with no further signal.
What this changes in #4095. The cadence values are operator defaults; keep each as one named constant.
Acceptance addition: a test that drives the ladder past its cap with the probe still failing. It must show further probes, a second alert after the re-alert interval, no extra disruptive rung, and one recovery notice once the probe passes.
pithead-developer commentedon Nov 16, 2026
Owner ruling 2026-11-16 (2.0.4 scope review, "all as recommended"): conditional. The core ladder and the owner's stop-at-cap re-alert stay in 2.0.4. If PR #4095 is still not green when everything else for the cut is ready, the 2026-11-14/15 refinements move to a v2.0.5 follow-up: 60 min spacing of disruptive rungs, the completed-circuit gate, the distinct lock-refusal result, and the KVM leg.
pithead-developer commentedon Nov 19, 2026
Two Tor failures on 2026-11-19 add cases outside this issue's ladder: a restart that left Tor stalled at 45% bootstrap with a 23 h old consensus, and Tari unable to reach onion peers while clearnet probes passed. Both were cured only by moving the cached directory files aside along with
state. They are filed as the v2.0.5 follow-up #4261, so #4095 should not grow to cover them; this issue stays the 2.0.4 fix.Cover the daily disruptive cap past the cap and drop the stale recove…
Tor auto-heal: advance past a rejected NEWNYM to state reset and rest…
pithead-developer commentedon Nov 21, 2026
Fixed by #4095, squash-merged into develop as b6f3251 with the owner's approval at cffb682. The merge did not close this issue automatically, so I am closing it by hand. It ships in v2.0.4.