Repository navigation
fix(charly): end the plugin idle guard's false kills and deliver the kill's evidence (#699) - #798
Conversation
…idle guard (#699) The plugin no-progress watchdog killed calls that were plainly progressing. Its CPU progress source read ONLY the peer plugin process's own /proc/<pid>/stat counters, and cutime/cstime aggregate a descendant's CPU only after that descendant is REAPED — so a peer that forks a long-lived child and blocks in wait() reported a FROZEN count for the child's entire life. That is the shape of a deploy plugin while its overlay/engine children run. Reproduced deterministically, no bed and no host load, 3 runs of 3. Three changes: 1. procTree — the CPU source is now the peer's whole LIVE process tree. Each process contributes utime+stime+cutime+cstime, so the sum is monotone: a reaped descendant's ticks move from its own counters into its parent's cutime, which is itself summed. A zombie is summed but not counted as live, so the sum cannot dip at a child's exit and hide a real advance. A double-forked descendant is reparented to init and is not attributable to the peer — it is missed, and the kill report prints the tree it saw. 2. observe — the kill no longer happens on a single unconfirmed expiry. touch() is a NON-BLOCKING depth-1 send, so a coalesced burst can be DROPPED, and Go's select picks at RANDOM among ready cases, so an expiry can win with an unread progress event in the buffer; the CPU source is sampled, so its last observation can also lag. Both sources are re-measured once at expiry and the call is killed only when neither has anything. (The wake field's comment claimed a progress event "always resets" the deadline and that there is "NO race" — true of the event path, false of the expiry path.) 3. errPluginCallIdle states only what the watchdog measured, and every kill appends a stallReport: peer pid, host-leg events and when the last arrived, CPU advances and when the last arrived, the window, and the peer tree's live count and tick sum at the kill. The sentinel previously asserted a cause it could not prove ("the peer runs no host work"), and that unsupported claim sent a week of investigation after the wrong mechanism. This is the measurement #699 never had. Tests: TestIdleBoundedContext_PeerWaitingOnBusyChildIsProgress (fails on the parent commit, 3/3, and is re-reddened by reverting only cpu() to the root-only reader), TestObserve_PendingLegEventAtExpiryIsProgress, TestObserve_LiveChildCPUIsProgress.
… contradicts (#699) The comments around the rewritten guard still described the OLD one. Two of them were load-bearing and wrong: - idleBoundedContext's doc asserted "a progress event that arrives before the deadline always resets it, there is NO race between the producer's touch cadence and this watchdog's check cadence". That is true of the EVENT path and false of the EXPIRY path (the expiry races a depth-1 token that can be dropped), which is exactly why observe() exists. Left standing, it reads as licence to kill on the first expiry. - pluginActivity's doc said the CPU source polls "the PEER PLUGIN PROCESS's monotonic CPU" and that utime+stime+cutime+cstime "AGGREGATES reaped descendants' CPU". The second half is the false comfort that hid #699: it aggregates them only AFTER the reap, so a peer blocked in wait() on a live CPU-active child reads frozen for the child's whole life. Both now describe what the code does — the peer's whole live tree, and a kill only after BOTH sources are re-measured at expiry — and the file header names the second source. Comment-only, no behaviour change: gofmt clean, go vet clean, the 10 activity tests pass.
… the peer tree it saw (#699) The first R10 bed for the guard fix came back RED carrying the NEW sentinel text and NO report: charly: error: command "deploy": deploy-dispatch add: deploy plugin: deploy-dispatch add: prepare venue: InvokeProvider deploy:pod op=prepare-venue: InvokeProvider: plugin call made no host-visible progress within the no-progress window ... pluginInvokeErr re-wrapped the BARE sentinel — return fmt.Errorf("%s: %w", what, errPluginCallIdle) — so the report the watchdog wrapped around the cause at the cancel (fmt.Errorf("%w: %s", errPluginCallIdle, a.stallReport(noProgress))) was thrown away on the way to the surface. The instrumentation this whole change exists for never reached the bed: a conclusion with no evidence, which is the defect #699 IS, reproduced by the fix for it — and invisible to errors.Is, so nothing caught it. - pluginInvokeErr propagates the CAUSE, so the sentinel AND the report reach the caller. errors.Is(err, errPluginCallIdle) still holds, because the cause wraps the sentinel. - The report names WHAT it saw, not only how much: procTreeProcs is now the ONE tree walker (procTree sums what it returns, the report renders it, so the two cannot drift), and each member prints as pid(state,comm). A sleeping parent waiting on a running child (the guard's OWN covered case) is then distinguishable from a reparented — double-forked — worker that is simply absent, or a D-state I/O wait the guard cannot help at all. pid<=0, an unreadable /proc and a walkable-but-empty tree are three different facts and now read as three different sentences instead of one. Measured, with go test -overlay so the working tree is never touched (clean before and after, same HEAD): - reverting ONLY pluginInvokeErr re-reds the new TestPluginInvokeErr_CarriesTheStallReport with exactly the bed's symptom — the sentinel and no report; - reverting ONLY cpu() to the root-only reader re-reds the tree tests, and the report then reads "2 live process(es) summing 72 ticks (root-only reader 0): 1214055(S,sh), 1214057(R,sh)" — a sleeping peer and the running child it waits on, which is the whole defect in one line. 12/12 activity tests pass; gofmt and go vet clean.
The #699 tests fork a CPU-burning grandchild (`sh -c '…' & wait`) and then reaped only the direct child (`cmd.Process.Kill()`), orphaning the burner. Reparented to the init process, that orphan spins at 100% of a core until its 100M-iteration loop ends — minutes — invisible to the test that made it. Measured, not argued. Two of these tests in one `go test` run left three orphans (ppid=566, i.e. already reparented) at ~99% CPU, and they pinned loadavg above 3.0 — which is exactly the idle-host precondition this change's own R10 bed requires. The kill report this branch adds warns that "a starved host … reads this way"; the suite was manufacturing the starved host, and it would have made the bed red for a reason that had nothing to do with the guard. `startInOwnGroup` starts the child as the leader of its own process group (Setpgid) and the cleanup SIGKILLs the whole group (-pgid) — the only handle that still reaches a grandchild the peer has already forked. -pgid names exactly that child's tree, never the test binary's own group. All five spawn sites now go through the one helper (R3). Sensitivity, via -overlay so the working tree is never touched: * the checker sees a deliberate leak: 1 (0 after cleanup) * old kill style, SAME checker, 2 tests: 2 orphans (ppid=566) * new helper, SAME checker, same 2 tests: 0 orphans, both PASS
…everse call (#699) A peer plugin's own `exec.InvokeProvider` callback asks the HOST to perform a provider call on its behalf, and the host serves it on `executorReverseServer.InvokeProvider`. While it runs, the CALLER is parked in that callback — no CPU, no children — and the served work makes no reverse leg on the caller's clock either, because it runs entirely host-side: for `build:generate op=resolve` the target is compiled-in (plugin-build is not served at all — `grep -c 'plugin plugin-build'` = 0, so `providerPid` -> 0) and its whole host-FS prep (`host_prep.go`: `cleanStaleBuildDirs`, `writeContextIgnore`, `createRemoteCandyCopies`, and the container image-store listing) makes ZERO `ex.` calls. Both of the clock's sources are therefore blind for exactly as long as the host works hardest. Measured, not argued. The second R10 bed on this branch's fixed tree came back RED carrying the report, and every number in it describes a working call: peer pid=1407873; over the call: host reverse legs=2 (last 1m47.517s ago), CPU advances=1 (last 1m30.02s ago); peer tree at kill: 1 live process(es) summing 32 ticks (root-only reader 32): 1407873(S,github.com_open); window=1m30s `1 live process(es) ... 32 ticks`, state `S` — the guard's own covered case excluded. Reproduced with NO bed, off the pod the red bed left running, matching the bed to ~10 ms, with the missing datum taken live: the HOST burned ~1.3 cores (utime 31519 -> 33857) for the whole 90 s window while the peer stayed frozen at 33 ticks in every 5 s sample. `HostBuild` (and every executor leg) already wraps its blocking work in `withActivityHeartbeatErr(s.activity, ...)`; `startPluginActivityHeartbeat`'s doc states that invariant outright — "host_build_cli and the host reverse legs wrap their blocking work with this so the work being ALIVE is forward progress for its whole (possibly ~13min) duration". `InvokeProvider` was the one host reverse leg that did not, and the overlay resolve is exactly the caller that needs it. The fix wraps the served dispatch, mirroring HostBuild. It does NOT widen the guard: the served call still builds its own idleBoundedContext (invokeProvider), so a wedged target still fails fast on its own clock, and its error propagates through the wrapper and stops the heartbeat. The two halves are now pinned side by side in plugin_dispatch_reverse_timeout_test.go — the pre-existing TestInvokeProvider_FailsFastOnHungPeer (a hung target is still killed) and the new TestInvokeProvider_ServedHostWorkHeartbeatsTheCallerClock (a served, leg-free host call is not). The new test's caller is a REAL live process parked in its callback and its clock is WATCHED by idleBoundedContext, so the test can only pass if the served call itself supplies the progress event. Sensitivity, via -overlay so the working tree is never touched (HEAD unchanged): * heartbeat removed, new guard re-reds: peer pid=1504227; ... CPU advances=0; peer tree at kill: 1 live process(es) summing 0 ticks (root-only reader 0): 1504227(S,sleep); window=200ms — the production report's shape, one live frozen `S` process. * the SAME reverted tree leaves TestInvokeProvider_FailsFastOnHungPeer PASSing, so the bound is not widened, only made sound.
Review — BLOCKHead SHA: Change class: code (runtime behaviour of the plugin host's idle guard) + tests. Security screen (T1–T4): PASS — no injected directives, no secrets/exfiltration, no network/endpoint additions, no dependency/CI-script/pin changes, no guardrail weakening. The change makes the watchdog sound rather than looser (the hung-peer bound is preserved), and it touches no security machinery, so no T4 sign-off is required. Blocks
Notes (not the block, recorded for completeness)
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
The fresh pr-validator BLOCKED the previous head on three R1 (B5) findings: two
comments asserting behaviour the code did not have, and one unproven non-blocking
reset. All three are fixed here, in one commit.
1. The `case <-cpu.C` arm passed `observe(nil, ...)` while its comment claimed the
call drained a pending host-leg token. A nil channel never fires in a select, so
the drain was a NO-OP and a touch that raced the CPU tick was left for the expiry
path to trip over — exactly the assertion-where-the-guard-can-only-measure class
this change exists to remove. The LIVE channel is now passed, so the drain is real
and the comment describes what the code does. Draining it here is strictly
conservative: it counts a touch that really happened, so it can only ever prevent a
kill, never cause one.
2. `procTreeProcs`' doc said the walk was "breadth-first"; the implementation is a
LIFO stack, i.e. DEPTH-FIRST pre-order. The doc now says so, the variable is named
`stack` rather than `queue`, and TestProcTreeProcs_PreOrder pins the property the
tree-shaped report actually needs: the root is first and every process precedes its
own descendants (which both traversals satisfy — the doc was the defect).
3. `reset()` is invoked from the EXPIRY path itself (progress confirmed at expiry), a
call the previous code never made from the timer arm, and no pasted test exercised
it. It is now the package-level `resetDeadline`, whose drain is a
select-with-default rather than a bare `<-timer.C`: on the expiry path the value has
already been consumed, so a bare receive would block forever and wedge the watcher.
TestResetDeadline_NonBlockingOnTheExpiryPath pins that state and FAILS on a bare
drain ("resetDeadline blocked after the expiry value was consumed — a wedged
watcher"); TestResetDeadline_NonBlockingWithStalePendingExpiry pins the other state,
where the stale value is still pending and MUST be drained or the re-armed timer
fires immediately.
Also corrects `withActivityHeartbeat`'s doc, which said the clock is heartbeated
"every 5s" while `startPluginActivityHeartbeat` derives the beat from the window
(window/4, capped at 5s) — the validator recorded the tension as a note.
No behavioural widening: the fixes only add progress signal (the live-channel drain)
or name the existing behaviour truthfully.
Review — PASSHead SHA: Security screen: PASS — no directives aimed at the reviewer, no secrets/egress/network additions, no dependency/pin/CI-script edits, no guardrail weakening. The idle guard is a liveness watchdog, not the security machinery (pre-push/pre-commit/branch-protection/rulebook), so T4 is N/A; the change makes the bound sound (hung-peer fail-fast preserved) rather than looser. Checklist: All applicable rules PASS or NA (A1 body ends with the Comment dispositions (1 comment): the prior
Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
Summary
The plugin no-progress watchdog killed provider calls that were plainly making progress, and
the measurement it was supposed to leave behind never reached the caller. This fixes the guard,
makes its kill message actually carry the evidence, and names the process tree it saw.
Six defects, every one of them measured — three of the six were found only by running this
change's own R10 bed. They are listed here in full, then root-caused one by one under
Root cause (R1) below.
only the peer plugin process's own
/proc/<pid>/statcounters.cutime/cstimeaggregate adescendant's CPU only after that descendant has been reaped — so a peer that forks a long-lived
CPU-active child and blocks in
wait()reports a frozen tick count for that child's entirelife. That is exactly the shape of a deploy plugin while its overlay/engine children run.
Reproduced deterministically with no bed and no host load — the identical failure on every
run of it, nothing else on the box (two retained:
/tmp/699-r10/parent-repro.txt,parent-repro2.txt).touch()burst can dropits one token, and a
selectpicks at random among ready cases, socase <-timer.Ccan win therace while an unread progress event sits in the channel.
after a trigger that did not survive the solo reproductions.
bed, which came back RED carrying the new sentinel text and no report at all):
pluginInvokeErrre-wrapped the bare sentinel, so the report the watchdog had built was discarded.The instrumentation never reached the bed — a conclusion with no evidence, which is the defect plugin no-progress watchdog false-positives under concurrent image builds (builder:* op=resolve hung) #699
is, reproduced by the fix for it, and invisible to
errors.Is, so nothing caught it.bed): they pinned the host above the idle level the bed requires. The report this branch adds warns
that "a starved host … reads this way" — the suite was manufacturing the starved host, so the bed
could have gone red for a reason with nothing to do with the guard.
bed, the one run on this branch's own fixed tree — the deepest defect of the set): the guard was
watching a clock that a legitimately long call cannot advance. A peer plugin parked in its own
exec.InvokeProvidercallback makes no CPU and no reverse leg while the host serves itsrequest, so a call the host was burning ~1.4 cores on read as "the peer runs no host work".
InvokeProviderwas the one host reverse leg not wrapped inwithActivityHeartbeatErr. Fixed, andpinned by a test that reds in 0.24 s without the fix.
The previous head's review (
charly/pr-validator, BLOCK) raised three findings, every one of themR1 (B5) — comments asserting behaviour the code did not have, plus one reset nobody had proven. All
three are fixed in the push on this head, in ONE commit, and each fix is pinned by a test that
FAILS when that fix is reverted (section 9 below):
case <-cpu.Carm passed a nil wake channel toobservewhile its comment claimed thecall drained a pending host-leg token — and
observe's own doc, two functions up in the samefile, said a nil channel never fires in a
select. The drain was a no-op, so the comment asserteda safety property the call did not provide. The live channel is now passed, so the drain is
real and the comment describes what the code does;
procTreeProcs' doc said the walk was "breadth-first" where the LIFO stack is depth-firstpre-order. The doc now says so and the variable is named
stack;reset()is now invoked from the expiry path itself, a call the previous code never made fromthe timer arm, and no pasted test exercised it. It is now the package-level
resetDeadline, whosedrain is a
select-with-default — a bare<-timer.Cthere would block forever and wedge thewatcher — and both timer states are pinned by tests.
This change is the fix for #699 (
no-progress-guard), and it is the blockerfor the
#762bed roster.Root cause (R1) — six defects, all measured
Defect 1 — the CPU source cannot see a peer's work that lives in a child
cpu()calledprocCPUTicks(pid)=utime + stime + cutime + cstimeof the peer processalone. A shell parked in
wait()accrues noutime/stimeof its own, and its child's CPU isnot folded into
cutimeuntil the child is reaped. Measured further: the peer's own count isgenuinely 0 — and
procCPUTicksreturns the same0for "frozen" and for"error / unreadable", so the guard cannot tell them apart.
Verbatim, on the parent production code (
9cd960ea), with no bed and no host load — the newtest compiled against the parent's
plugin_activity.goand run 8 times:Repeated with nothing else running: the identical FAIL on every run, never a pass — the assertion
that reds is the new test's, on the parent's own code (two retained:
parent-repro.txt,parent-repro2.txt). Deterministic, with nothing on the box.Defect 2 — the kill fired on the FIRST unconfirmed expiry
touch()is a non-blocking depth-1 send, so a coalesced burst collapses to one token that canbe dropped when the buffer is already full; and Go's
selectpicks at random among readycases, so
case <-timer.Ccan win the race while an unread progress event sits in the channel.The CPU source is also sampled, so its last observation can lag. The doc comment above the
wakefield claimed a progress event "always resets" the deadline and that there is "therefore NOrace" — true of the event path, false of the expiry path.
Defect 3 — the sentinel asserted a cause it could not prove
The error text ended
(hung plugin — the peer runs no host work). That is a conclusion, not ameasurement, and it sent a week of investigation after the wrong mechanism (the issue title's
"under concurrent image builds" trigger, which did not survive the solo reproductions).
Defect 4 — the report was thrown away on the way to the caller (found by the R10 bed)
The watchdog cancels with the report wrapped around the sentinel:
but
pluginInvokeErrre-wrapped the bare sentinel, discarding it:Type-checks identically, satisfies
errors.Isidentically — and silently deletes the evidence. Thefirst R10 run of this change reproduced it verbatim, at the same step and the same line as the
second one would (
2026.278.0153/update.log:39):That is the new sentinel and nothing else. No report.
Defect 5 — the test suite orphaned its own CPU burners (found while gating the bed)
The tests this change adds fork a CPU-burning grandchild (
sh -c '…' & wait) and thenreaped only the direct child with
cmd.Process.Kill(). Reparented to the init process,the grandchild spins at 100% of a core until its loop ends — minutes — invisible to the test
that made it.
Measured two ways. Reproducibly, with the checker this change adds (its output is pasted in
section 4 below): under the old kill style two of those tests leave 2 orphans reparented to
ppid=566, and under the new helper the same two tests leave 0. Live, while waiting onthis very bed, the same shape was seen with
psas three reparented burners (ppid=566is thishost's user manager, so their parents were already gone) at ~99% of a core each — enough to pin
loadavg above the idle-host level the bed requires. A single burner of exactly that shape, started
and then orphaned on this host, reads verbatim:
That is the defect and the fix side by side in the tests' own shape: a waiting peer (
S) with aburning child (
R, 99.6 % of a core); kill the peer alone and the burner survives, reparentedto
ppid=566and still at 99.2 % — which is why the old tests could pin the host and never notice;kill the peer's group and nothing survives.
This one is worth stating precisely, because it inverts: the kill report this branch adds
warns that "a starved host … reads this way" — and the suite was manufacturing the
starved host, so the bed could have gone red for a reason with nothing to do with the
guard, and the report would have blamed the host. Test hygiene is load-bearing evidence here.
Defect 6 — the ONE host reverse leg that was not heartbeated (found by this change's second R10 bed)
The second R10 bed — on this branch's own fixed tree (
1e8c71d4, rebased to714e1842when thebranch was caught up to
origin/main) — came back RED, and this timeit carried the report. That is what makes it decidable. Verbatim from that run's own log
(
.check/check-pod-overlay/2026.278.0249/update.log:39, the failing step insummary.yml):Every number in that report is consistent with a legitimately working call, and the tree it names
says so: one live process, state
S, 32 ticks — frozen. So this is not the guard's covered case.It is the guard looking at the wrong clock.
Reproduced with no bed, off the pod the red bed left running (the identical deploy,
charly deploy add check-pod-overlay) — matching the bed's numbers to ~10 ms:And the missing datum — the host's own CPU, which the guard never measures — taken live by a
sampler reading
utime/stimefrom/proc/<pid>/statof everycharlyand__plugin serveprocess at a 5 s cadence (
/tmp/699-cpu.sh, log retained at/tmp/699-cpu.log). During the resolvethe host process alone advanced 8,665 ticks between 03:28:17Z and 03:29:18Z = 86.65 s of CPU in
61 s (~1.4 cores), while the plugin processes the same sampler watched sat frozen — e.g. pid
1472605,
ut=0 st=0 cut=0 cst=0in all 51 of its samples:So the host was busy for the whole window that the guard read as "the peer runs no host work" — and
that sampler is the one thing the guard's own report cannot show, which is why the report says what
it measured (
host reverse legs,CPU advances, the peer tree at the kill) rather than assertinga cause.
The mechanism. A peer plugin's own
exec.InvokeProvidercallback asks the HOST to perform aprovider call on its behalf, and the host serves it on
executorReverseServer.InvokeProvider. Whilethe host serves it the CALLER is parked in that callback — no CPU, no children — and the served work
produces no reverse leg on the caller's clock either, because it runs entirely host-side: for
build:generate op=resolvethe target is compiled-in (plugin-build is not served at all —grep -c 'plugin plugin-build'= 0 in the run above, soproviderPid→ 0) and its whole host-FSprep (
host_prep.go:cleanStaleBuildDirs,writeContextIgnore,createRemoteCandyCopies, and thecontainer image-store listing) makes zero
ex.calls. So both of the clock's sources are blindfor exactly as long as the host works hardest — 90 s of the host at ~1.3 cores, then killed as "the
peer runs no host work".
The clock it fires on is the CALLER's:
plugin_dispatch_reverse.gothreads it onto the nested channel(
inv.InvokeWithExecutor(withPluginActivity(ctx, activity), …)), and the nested server is built withactivity: pluginActivityFrom(ctx)(plugin_grpc.go:422) — sos.activityinside the handler isthe clock that fired, which is why the report names the caller's peer.
HostBuildand every executor leg already wrap their blocking work inwithActivityHeartbeatErr(s.activity, …);startPluginActivityHeartbeat's own doc states theinvariant — "host_build_cli and the host reverse legs wrap their blocking work with this so the work
being ALIVE is forward progress for its whole (possibly ~13min) duration".
InvokeProviderwasthe one host reverse leg that did not, and the overlay resolve is precisely the caller that needs
it.
The fix — heartbeat the served dispatch, mirroring
HostBuild:This does not widen the guard: the served call keeps its own
idleBoundedContext(
invokeProvider), so a genuinely hung target still fails fast on that clock and its error propagatesthrough the wrapper and stops the heartbeat. The two halves are now pinned side by side in
plugin_dispatch_reverse_timeout_test.go— the pre-existingTestInvokeProvider_FailsFastOnHungPeer(a hung target must still be killed) and the new
TestInvokeProvider_ServedHostWorkHeartbeatsTheCallerClock(a served, leg-free host-side call mustnot be).
One design note, because it is the difference between a test and a vacuous test: the new guard's
caller is a REAL live process parked in its callback (
sleep 30, its own process group), and itsclock is watched by
idleBoundedContext. The first version built the clock asnewPluginActivity(0)and passed the full duration even with the heartbeat removed — a clock nobodywatches cannot kill anything, so it proved nothing. A pid-0 clock would also have been ambiguous
against the in-proc target's own idle bound (below). With the real, watched caller clock, the test
can only pass if the served dispatch itself supplies the progress event.
The same command that idle-killed at ~4 m 29 s, re-run on the fixed binary (no bed needed — the
defect is reproducible off the live pod):
What changed
1.
procTree— the CPU source is now the peer's whole LIVE process tree.Every process contributes
utime+stime+cutime+cstime, so the sum is monotone: a reapeddescendant's ticks move out of its own counters and into its parent's
cutime, which is itselfsummed. A zombie is summed but not counted as live, so the sum cannot dip at a child's exit
and hide a real advance.
/procunreadable degrades to the root-only reader rather than to afalse kill.
2.
observe— one progress measurement, and no kill on an unconfirmed expiry.It drains a pending host-leg token (counting it) or compares the tree CPU against the high-water
mark. On expiry it re-measures both sources and cancels only when neither has anything.
3.
errPluginCallIdle+stallReport— the kill carries the measurement, and names the tree.procTreeProcsis now the one tree walker:procTreesums what it returns and the reportrenders it, so the two can never describe different trees. Every kill appends:
The member list is what makes it decisive: a sleeping parent waiting on a running child (the
guard's own covered case) is then distinguishable from a reparented — double-forked — worker
that is simply absent, or a
D-state I/O wait the guard cannot help at all.pid<=0, anunreadable
/procand a walkable-but-empty tree are three different facts and read as threedifferent sentences.
4.
pluginInvokeErrpropagates the CAUSE, so the sentinel and its report reach the caller.errors.Is(err, errPluginCallIdle)still holds, because the cause wraps the sentinel.5.
startInOwnGroup— the tests kill the peer's whole process group, not just the peer.The child is started with
Setpgid: trueand the cleanup SIGKILLs-pgid: the only handle thatstill reaches a grandchild the peer has already forked.
-pgidnames exactly that child's tree —never the test binary's own group. All five spawn sites go through the one helper (R3).
6.
executorReverseServer.InvokeProviderheartbeats the CALLER's clock while it serves the call.The served body is split out to
invokeProviderso the wrapper can holdwithActivityHeartbeatErraround it — the same shape
HostBuildalready uses for the builds it runs on a plugin's behalf, andthe invariant
startPluginActivityHeartbeat's doc states. The served call keeps its ownidleBoundedContext, so a wedged target still fails fast on its own clock (defect 6, above).7. The review-fix commit — the guard's own claims made true (see section 9). The
case <-cpu.Carm now passes the live
wakechannel, so the drain its comment claimed is real;procTreeProcs'doc names the depth-first pre-order walk its LIFO stack performs (the variable is
stack, notqueue); and the reset is the package-levelresetDeadline, whose drain is aselect-with-defaultso it cannot block on the expiry path it is now called from. No behaviour is widened: the changed call
only adds progress signal, and the rest is naming what the code already did.
How tested
1. The changed path, unit level, on the final committed tree
15 PASS / 0 FAIL. Seven of those tests are new (
PeerWaitingOnBusyChildIsProgress,Observe_PendingLegEventAtExpiryIsProgress,Observe_LiveChildCPUIsProgress,PluginInvokeErr_CarriesTheStallReport,ResetDeadline_NonBlockingOnTheExpiryPath,ResetDeadline_NonBlockingWithStalePendingExpiry,ProcTreeProcs_PreOrder).2. Sensitivity A — reverting ONLY
pluginInvokeErrre-reds the report testDone with
go test -overlayso the working tree is never touched (it was clean before and after,at the same HEAD). Note what the failure contains: the reverted code's error is the sentinel and
nothing else, while the cause — built by the unchanged watchdog — plainly carries the report. That
asymmetry is defect 4.
3. Sensitivity B — reverting ONLY
cpu()re-reds the tree testsWith
cpu()back to the root-only reader, the guard kills a peer whose tree is 2 live processessumming 72 ticks while the reader it trusted said
0— and the report now names them:1214055(S,sh), 1214057(R,sh)— a sleeping peer and the running child it waits on. That isthe whole defect in one line, and it is only legible because the walk is now shared between the
sum and the report.
4. Sensitivity C — the leaked burners are real, and the same check proves the fix
The check counts burners whose parent is already gone (
/tmp/699-orphan-check.sh). It isfalsifiable in both directions: it must see a deliberate leak, and it must stop seeing the
leak under the new helper while still seeing it under the old one. The overlay keeps the tree
untouched.
ppid=566on both survivors — the burner has been reparented to the init process, which iswhat "orphaned" means and why nothing in the test could see it. With the helper in place the same
two tests leave nothing, and the full package suite is clean too:
5. Defect 6 — its own unit proof and falsification
The two halves of the reverse seam, side by side on the final committed tree — a hung target is
still killed, and a served leg-free host call is not:
Falsification, via
-overlayso the working tree is never touched (clean before and after, sameHEAD): with only the heartbeat wrapper removed, the new guard re-reds almost immediately, in the
production report's own shape — while the pre-existing hung-peer test still passes, which is the
proof the bound was made sound rather than widened:
The overlay's own file is a copy of the committed
plugin_dispatch_reverse.gowith only theheartbeat wrapper removed (
/tmp/699-r10/plugin_dispatch_reverse_noheartbeat.go), so the failureabove is that one removal and nothing else — and the working tree was clean before and after the run.
The fixed repro of the exact failing step (no bed, off the live pod) is pasted in defect 6 above.
6. R10 — the changed runtime path, run live on the final committed tree
check-pod-overlayis the full assembled bed (disposable: true) this change class requires, runSOLO on this head — gated on a measured idle host, and it is the very bed that produced both of
this PR's RED runs. The step it is decided by is the step the change is about:
update, whichre-runs the deploy (
charly deploy add) and so reaches the servedInvokeProviderwhere the guardfired. Verdict read from the run's own
summary.ymland the driver's own log — never from thedriver's exit code:
Every step is
ok: true(the file's ownok:at the top istrue). The one that matters:updatepasses in 612 s — the step that killed both RED beds at 375 s, with the idle-kill verbatim at
update.log:39. 612 s is 6.8× the guard's own 90 s no-progress window, so the served dispatchwas alive across a window nearly seven times longer than the one it used to be killed in: the fix is
exercised, not merely present. No idle-kill text appears anywhere in this run's logs:
The bed's own precondition — an idle host — is measured rather than assumed, and the state it
settled on is logged by the gate:
— no other session's bed, no
charly task sync|verify, loadavg/cores and runnable-procs-per-coreboth under the half-idle bar, held for three consecutive 20 s samples. And it left nothing behind:
the worktree is still clean at the same head, and the orphan check reads 0.
7. The generated-file drift gate
TestPluginsGenReproducibleis green on this head. It was red on the parent9cd960ea(independent of this change: stashing the guard files reproduces the identical failure), and
another session landed the same one-line regeneration as #794 while this branch was in flight —
byte-identical to the one this branch momentarily carried, so that commit was dropped on rebase
and the change is now guard-only. Verified on the final tree:
8. The repo's own CI checks, run on this head
A validation PASS is not the repo's CI: the checker judges formatting only, and its PASS arms
auto-merge whatever state the head is in. So the repository's own steps are run here, on the final
committed tree, before the push —
gofmt,go vet, and the repo'sgolangci-lintrun:gofmt -lprinted nothing (0 files unformatted —gofmt_lines=0),go vetexited 0 with nodiagnostics, and golangci-lint reports
0 issues.(lint_exit=0). The lint invocation is not alookalike: it is CI's own step copied verbatim —
.github/workflows/ci.yml:92-93pins[email protected]and runs( cd charly && "$(go env GOPATH)/bin/golangci-lint" run ./... ),and the tool on this host is that same version (
golangci-lint has version 2.13.2 built with go1.27.1-X:nodwarf5), run fromcharly/so the repo's CWD-selected config applies — which is thehole that makes this worth running by hand at all.
9. The previous head's review findings — all three fixed in ONE commit, each pinned by a test
The fresh
charly/pr-validatorBLOCKED the previous head (40209961) on three findings, all of themR1 (B5): two comments asserting behaviour the code did not have, and one reset nobody had proven. One
commit carries all three — nothing was deferred, nothing was argued — and the whole of the code
change is pasted below, so each disposition can be checked against the code rather than the prose.
Finding 1 — the
case <-cpu.Carm's comment claimed a drain the call could not perform. Itpassed
nil, andobserve's own doc two functions up said plainly that a nil channel never fires ina
select. Fixed by passing the live channel, which is what the comment already claimed:Draining there is strictly conservative — it counts a touch that really happened, so it can only
ever prevent a kill, never cause one — and
observe's doc is corrected to match (a nil channel stayslegal for a caller with no event source; the watcher now passes one at both of its call sites).
Being straight about the limit of the evidence: a touch racing a CPU tick is a
select-schedulingevent, so no test can force it deterministically. What is pinned is the behaviour the call site
depends on —
TestObserve_PendingLegEventAtExpiryIsProgressprovesobservedoes drain apending token when given the live channel, which is exactly what the nil call site could not do.
Finding 2 — the traversal doc. The walk is a LIFO stack, i.e. depth-first pre-order, and the
doc said "breadth-first". The doc now names the real traversal, the variable is
stackrather thanqueue, and the property the tree-shaped report actually needs is pinned:TestProcTreeProcs_PreOrderasserts that property over the peer's real tree — root first, and noprocess visited before its parent. (Both traversals satisfy it; the doc was the defect, and the test
is written to survive the choice.)
Finding 3 — the reset, on a path nothing tested.
reset()is now called from insidecase <-timer.C(progress confirmed at expiry), which the previous code never did. It is thepackage-level
resetDeadlinenow, and its drain is the non-blocking form:The sensitivity proof — each pin reds when its own fix is reverted, one patch at a time, with the
tree restored afterwards (the patched halves are the ONLY change in each run; the tree was clean at
141f2d34before and after):The wedged-watcher failure message is the whole point of finding 3: with a bare drain the test does
not merely fail, it hangs — a watcher that never returns never kills either, which is the worst
possible failure for a guard.
TestResetDeadline_NonBlockingWithStalePendingExpirypins the otherstate (a value still pending and unread, which MUST be drained or the re-armed timer fires at once),
so both states the reset can meet are covered.
One non-blocking note from the same review is also addressed:
withActivityHeartbeat's doc said theclock is heartbeated "every 5s", while
startPluginActivityHeartbeatderives the beat from thewindow (
window/4, capped at 5s — which is why a 200 ms-window test still passes). The doc now saysso.
Rulebook compliance
/charly-internals:git-workflowloaded before any git/PR action;/charly-internals:root-cause-analyzerfor the RCA;/charly-check:checkfor the bed."flake", "transient" or "out of scope" classification anywhere. The fourth was found by running
the bed rather than by reasoning about it, the fifth while gating it, and the sixth by the second
bed on this branch's own fixed tree — each reported as what it is.
observeis the one progress measurement the watchdog makes;procTreeProcsis theone
/proctree walk, and both the sum (treeTicks) and the kill report are derived from it,so a report can never describe a tree the guard did not measure. The duplicate pluginsgen
regeneration that fix(charly): regenerate plugins_refs_generated.go — stale after plugin-pipeline v2026.277.2104 #794 had already merged was dropped rather than carried. The test scaffolding
deliberately parses
/procitself (procStatFields) rather than calling the productionreader, so a bug shared with it cannot make a test pass. Defect 6's fix adds no second heartbeat
mechanism: it wraps the served dispatch in the existing
withActivityHeartbeatErr, exactly asHostBuildalready does, and it reuses the existingnewPluginActivity/idleBoundedContextclockrather than inventing a parallel one.
suppressed nor widened; it is made sound, and when it does fire it now explains itself. Nothing
live is faked: the failing case is a real deploy on the real pod, the CPU attribution is read from
the real
/proc, and the fixed case is the same command on the same venue.is no flag or env var that restores it), and the false "therefore NO race" claim in the
wakedoc comment is deleted, not annotated with a correction.
main. The branch was rebased ontoorigin/mainlocally with a backup ref, before anything was pushed.-overlaysensitivities, the parent-commit reproduction, and the leak check that the old kill style
fails while the new helper passes); the changed path is executed live in the R10 bed; all
commands and exits are pasted here.
/procwalks and the bed run against the real host.bootstrap-charly.shstamps the CalVerfrom the HEAD commit, and the stamp matches to the minute. HEAD
141f2d34committed2026-10-05T06:38:40+02:00(=04:38:40Z); the built binary reportsversion=2026.278.0438(day 278, 04:38Z), and the driver asserts the tree was clean before the build and that HEAD did
not move across it — printed by the run itself:
binary stamped from that HEAD). The bed's own precondition — an idle host — is stated and
measured rather than assumed: the gate waits for no other session's bed, no
charly task sync|verify,and loadavg/cores < 0.5, and logs the state it settled on:
Defect 5 was found by taking that precondition seriously, and defect 6 by running the bed twice.
Change classification
charly/plugin_activity.go+386/−72,charly/plugin_activity_test.go+364/−12,charly/plugin_dispatch_reverse.go+33,charly/plugin_dispatch_reverse_timeout_test.go+71 (854 insertions, 84 deletions overorigin/main).parent-commit reproduction + a live
disposable: truebed on the final committed tree.(
check-pod-overlay,disposable: true, green on the final committed tree, theupdatestep thatused to be idle-killed passing in 612 s), the full package suite passes on that same tree, the
repo's own CI steps (
gofmt,go vet,[email protected]) pass on it, and every new test isshown to fail without the change (sections 2–5 above, plus section 9 for the three review findings).
Coordination
check-pod-overlayred that opened thisinvestigation routes here, and the roster lands zero-failure after this merges.
branch briefly carried, and is credited above.
Agent:
no-progress-guard· session2a317871-ba03-4713-89ba-8edbd4059c27Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)