Skip to content

fix(charly): end the plugin idle guard's false kills and deliver the kill's evidence (#699) - #798

Merged
github-actions[bot] merged 6 commits into
mainfrom
feat/no-progress-guard
Oct 5, 2026
Merged

github-actions[bot] merged 6 commits into
mainfrom
feat/no-progress-guard

Conversation

@aitrawog

@aitrawog aitrawog commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

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.

  • Defect 1 — the kill fired on calls that were progressing. The guard's CPU progress source read
    only the peer plugin process's own /proc/<pid>/stat counters. cutime/cstime aggregate a
    descendant'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 entire
    life. 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).
  • Defect 2 — the kill fired on the FIRST unconfirmed expiry. A coalesced touch() burst can drop
    its one token, and a select picks at random among ready cases, so case <-timer.C can win the
    race while an unread progress event sits in the channel.
  • Defect 3 — the sentinel asserted a cause it could not prove, which sent a week of investigation
    after a trigger that did not survive the solo reproductions.
  • Defect 4 — the report was thrown away on the way to the caller (found by this change's first R10
    bed, which came back RED carrying the new sentinel text and no report at all):
    pluginInvokeErr re-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.
  • Defect 5 — the tests this change adds orphaned their own CPU burners (found while gating that
    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.
  • Defect 6 — the one host reverse leg that was not heartbeated (found by this change's second R10
    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.InvokeProvider callback makes no CPU and no reverse leg while the host serves its
    request, so a call the host was burning ~1.4 cores on read as "the peer runs no host work".
    InvokeProvider was the one host reverse leg not wrapped in withActivityHeartbeatErr. Fixed, and
    pinned 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 them
R1 (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):

  • the case <-cpu.C arm passed a nil wake channel to observe while its comment claimed the
    call drained a pending host-leg token — and observe's own doc, two functions up in the same
    file, said a nil channel never fires in a select. The drain was a no-op, so the comment asserted
    a 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-first
    pre-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 from
    the timer arm, and no pasted test exercised it. It is now the package-level resetDeadline, whose
    drain is a select-with-default — a bare <-timer.C there would block forever and wedge the
    watcher — and both timer states are pinned by tests.

This change is the fix for #699 (no-progress-guard), and it is the blocker
for the #762 bed 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() called procCPUTicks(pid) = utime + stime + cutime + cstime of the peer process
alone
. A shell parked in wait() accrues no utime/stime of its own, and its child's CPU is
not folded into cutime until the child is reaped. Measured further: the peer's own count is
genuinely 0 — and procCPUTicks returns the same 0 for "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 new
test compiled against the parent's plugin_activity.go and run 8 times:

$ go test -overlay=/tmp/699-r10/overlay-parent.json ./charly/ -count=1 -v -run TestIdleBoundedContext_PeerWaitingOnBusyChildIsProgress
=== RUN   TestIdleBoundedContext_PeerWaitingOnBusyChildIsProgress
    plugin_activity_test.go:378: a peer blocked in wait() on a CPU-active child must not be idle-killed, got plugin call made no host-visible progress within the no-progress window (hung plugin — the peer runs no host work)
--- FAIL: TestIdleBoundedContext_PeerWaitingOnBusyChildIsProgress (0.75s)
FAIL
FAIL	github.com/opencharly/charly/charly	3.775s
FAIL
exit=1

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 can
be dropped when the buffer is already full; and Go's select picks at random among ready
cases
, so case <-timer.C can 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
wake field claimed a progress event "always resets" the deadline and that there is "therefore NO
race" — 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 a
measurement, 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:

cancel(fmt.Errorf("%w: %s", errPluginCallIdle, a.stallReport(noProgress)))

but pluginInvokeErr re-wrapped the bare sentinel, discarding it:

if errors.Is(context.Cause(ctx), errPluginCallIdle) {
    return fmt.Errorf("%s: %w", what, errPluginCallIdle)   // <- the report dies here
}

Type-checks identically, satisfies errors.Is identically — and silently deletes the evidence. The
first 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):

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 (no host reverse leg and no CPU advance from the peer process or any of its live descendants)

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 then
reaped 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 on
this very bed, the same shape was seen with ps as three reparented burners (ppid=566 is this
host'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:

## OLD cleanup (the peer only — what the tests did before this change)
# peer=1659249  burner=1659251   (peer: sh -c '<burner> & wait')
1659249 1659245 Ss    0.0 sh -c sh -c 'i=0; while [ $i -lt 100000000 ]; do i=$((i+1)); done' & echo $! > /tmp/699-burner-child.pid; wait
1659251 1659249 R    99.6 sh -c i=0; while [ $i -lt 100000000 ]; do i=$((i+1)); done
# after killing the peer:
1659251     566 R    99.2 sh -c i=0; while [ $i -lt 100000000 ]; do i=$((i+1)); done
#   ^ SURVIVED — reparented to the init process (ppid=566 on this host), still burning
## NEW cleanup (startInOwnGroup: the peer's whole process group)
# peer=1659704  burner=1659706   (peer: sh -c '<burner> & wait')
1659704 1659245 Ss    0.0 sh -c sh -c 'i=0; while [ $i -lt 100000000 ]; do i=$((i+1)); done' & echo $! > /tmp/699-burner-child.pid; wait
1659706 1659704 R    99.6 sh -c i=0; while [ $i -lt 100000000 ]; do i=$((i+1)); done
# after killing the group:
#   burner gone — nothing survived (want this for the group kill)
## orphans after both, by the checker this change adds:
0

That is the defect and the fix side by side in the tests' own shape: a waiting peer (S) with a
burning child (R, 99.6 % of a core); kill the peer alone and the burner survives, reparented
to ppid=566
and 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 to 714e1842 when the
branch was caught up to origin/main) — came back RED, and this time
it 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 in summary.yml):

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 (no host reverse leg and no CPU advance from the peer process or any of its live descendants): 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. A starved host, a double-forked descendant and a genuinely wedged peer all read this way — if the tree shows live processes, re-run on an idle host before reading it as a hang

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:

peer pid=1433099; over the call: host reverse legs=2 (last 1m47.507s ago), CPU advances=1 (last 1m30.015s ago); peer tree at kill: 1 live process(es) summing 33 ticks (root-only reader 33): 1433099(S,plugin-deploy-p); window=1m30s. A starved host, a double-forked descendant and a genuinely wedged peer all read this way — if the tree shows live processes, re-run on an idle host before reading it as a hang

And the missing datum — the host's own CPU, which the guard never measures — taken live by a
sampler reading utime/stime from /proc/<pid>/stat of every charly and __plugin serve
process at a 5 s cadence (/tmp/699-cpu.sh, log retained at /tmp/699-cpu.log). During the resolve
the 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=0 in all 51 of its samples:

1791170897 1472609 ut=15842 st=367 cut=0 cst=0
1791170958 1472609 ut=24507 st=528 cut=489 cst=315
1791170801..1791171055 1472605 ut=0 st=0 cut=0 cst=0   (51 samples, no advance)

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 asserting
a cause.

The mechanism. 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
the 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=resolve the target is compiled-in (plugin-build is not served at all —
grep -c 'plugin plugin-build' = 0 in the run above, 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. So both of the clock's sources are blind
for 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.go threads it onto the nested channel
(inv.InvokeWithExecutor(withPluginActivity(ctx, activity), …)), and the nested server is built with
activity: pluginActivityFrom(ctx) (plugin_grpc.go:422) — so s.activity inside the handler is
the clock that fired, which is why the report names the caller's peer.

HostBuild and every executor leg already wrap their blocking work in
withActivityHeartbeatErr(s.activity, …); startPluginActivityHeartbeat's own doc states the
invariant — "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 precisely the caller that needs
it.

The fix — heartbeat the served dispatch, mirroring HostBuild:

func (s *executorReverseServer) InvokeProvider(ctx context.Context, req *pb.InvokeProviderRequest) (*pb.InvokeReply, error) {
	var reply *pb.InvokeReply
	err := withActivityHeartbeatErr(s.activity, func() error {
		var serr error
		reply, serr = s.invokeProvider(ctx, req)
		return serr
	})
	return reply, err
}

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 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 must still be killed) and the new
TestInvokeProvider_ServedHostWorkHeartbeatsTheCallerClock (a served, leg-free host-side call must
not 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 its
clock is watched by idleBoundedContext. The first version built the clock as
newPluginActivity(0) and passed the full duration even with the heartbeat removed — a clock nobody
watches 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):

$ ./bin/charly deploy add check-pod-overlay --tag repro-fixed-699-1791170797
charly: listing local images (first run — may take a moment)...
charly: listed 584 local images in 6.592s — consider pruning the image store
charly: resolving project (first run — may take a moment)...
Overlay image ready: check-pod-overlay-overlay:21453d30d84e
To start the container, run: charly start check-pod-overlay

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 reaped
descendant's ticks move out of its own counters and 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. /proc unreadable degrades to the root-only reader rather than to a
false 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.
procTreeProcs is now the one tree walker: procTree sums what it returns and the report
renders it, so the two can never describe different trees. Every kill appends:

peer pid=%d; over the call: host reverse legs=%d (last %s), CPU advances=%d (last %s);
peer tree at kill: %d live process(es) summing %d ticks (root-only reader %d): <pid(state,comm), …>;
window=%s. A starved host, a double-forked descendant and a genuinely wedged peer all read this
way — if the tree shows live processes, re-run on an idle host before reading it as a hang

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, an
unreadable /proc and a walkable-but-empty tree are three different facts and read as three
different sentences.

4. pluginInvokeErr propagates 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: true and the cleanup SIGKILLs -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 go through the one helper (R3).

6. executorReverseServer.InvokeProvider heartbeats the CALLER's clock while it serves the call.
The served body is split out to invokeProvider so the wrapper can hold withActivityHeartbeatErr
around it — the same shape HostBuild already uses for the builds it runs on a plugin's behalf, and
the invariant startPluginActivityHeartbeat's doc states. The served call keeps its own
idleBoundedContext, 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.C
arm now passes the live wake channel, 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, not
queue); and the reset is the package-level resetDeadline, whose drain is a select-with-default
so 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

$ go test ./charly/ -count=1 -v -run 'TestInvokeProvider_ProgressingLongCallIsNotKilled|TestIdleBoundedContext|TestProcCPUTicks|TestProcessPid|TestObserve|TestPluginInvokeErr|TestInvokeProvider_FailsFastOnHungPeer|TestResetDeadline|TestProcTreeProcs'
--- PASS: TestInvokeProvider_ProgressingLongCallIsNotKilled (0.60s)
--- PASS: TestIdleBoundedContext_TripsOnlyWhenIdle (0.75s)
--- PASS: TestPluginInvokeErr_CarriesTheStallReport (0.10s)
--- PASS: TestIdleBoundedContext_PluginLocalCPUIsProgress (1.02s)
--- PASS: TestProcCPUTicks_Monotonic (0.22s)
--- PASS: TestIdleBoundedContext_LongHostLegIsProgress (1.00s)
--- PASS: TestProcessPid_NilSafeAndLive (0.00s)
--- PASS: TestIdleBoundedContext_NilWakeLiteralStillResets (7.00s)
--- PASS: TestIdleBoundedContext_PeerWaitingOnBusyChildIsProgress (1.44s)
--- PASS: TestObserve_PendingLegEventAtExpiryIsProgress (0.00s)
--- PASS: TestObserve_LiveChildCPUIsProgress (0.23s)
--- PASS: TestResetDeadline_NonBlockingOnTheExpiryPath (0.06s)
--- PASS: TestResetDeadline_NonBlockingWithStalePendingExpiry (0.40s)
--- PASS: TestProcTreeProcs_PreOrder (0.04s)
--- PASS: TestInvokeProvider_FailsFastOnHungPeer (0.10s)
PASS
ok  	github.com/opencharly/charly/charly	15.392s

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 pluginInvokeErr re-reds the report test

Done with go test -overlay so 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.

$ go test -overlay=/tmp/699-r10/overlay-bareerr.json ./charly/ -count=1 -v -run TestPluginInvokeErr_CarriesTheStallReport
=== RUN   TestPluginInvokeErr_CarriesTheStallReport
    plugin_activity_test.go:156: THE BUG: the report must reach the caller, not just the sentinel.
        got: InvokeProvider deploy:dummy op=rebuild: plugin call made no host-visible progress within the no-progress window (no host reverse leg and no CPU advance from the peer process or any of its live descendants)
        report: peer pid=0; over the call: host reverse legs=1 (last 102ms ago), CPU advances=0 (last never); peer tree at kill: 0 live process(es) summing 0 ticks (root-only reader 0) (no peer pid — this clock watches no process tree); window=100ms. A starved host, a double-forked descendant and a genuinely wedged peer all read this way — if the tree shows live processes, re-run on an idle host before reading it as a hang
--- FAIL: TestPluginInvokeErr_CarriesTheStallReport (0.10s)
FAIL
FAIL	github.com/opencharly/charly/charly	2.358s
FAIL
exit=1

3. Sensitivity B — reverting ONLY cpu() re-reds the tree tests

With cpu() back to the root-only reader, the guard kills a peer whose tree is 2 live processes
summing 72 ticks
while the reader it trusted said 0 — and the report now names them:

$ go test -overlay=/tmp/699-r10/overlay-rootonly.json ./charly/ -count=1 -v -run 'TestIdleBoundedContext_PeerWaitingOnBusyChildIsProgress|TestObserve_LiveChildCPUIsProgress|TestIdleBoundedContext_PluginLocalCPUIsProgress'
=== RUN   TestIdleBoundedContext_PluginLocalCPUIsProgress
--- PASS: TestIdleBoundedContext_PluginLocalCPUIsProgress (1.02s)
=== RUN   TestIdleBoundedContext_PeerWaitingOnBusyChildIsProgress
    plugin_activity_test.go:425: a peer blocked in wait() on a CPU-active child must not be idle-killed, got plugin call made no host-visible progress within the no-progress window (no host reverse leg and no CPU advance from the peer process or any of its live descendants): peer pid=1214055; over the call: host reverse legs=1 (last 308ms ago), CPU advances=0 (last never); peer tree at kill: 2 live process(es) summing 72 ticks (root-only reader 0): 1214055(S,sh), 1214057(R,sh); window=300ms. A starved host, a double-forked descendant and a genuinely wedged peer all read this way — if the tree shows live processes, re-run on an idle host before reading it as a hang
--- FAIL: TestIdleBoundedContext_PeerWaitingOnBusyChildIsProgress (0.75s)
=== RUN   TestObserve_LiveChildCPUIsProgress
    plugin_activity_test.go:497: the peer tree's CPU never left 0 — the tree walk is not reading the child
--- FAIL: TestObserve_LiveChildCPUIsProgress (2.10s)
FAIL
FAIL	github.com/opencharly/charly/charly	6.404s
FAIL
exit=1

1214055(S,sh), 1214057(R,sh) — a sleeping peer and the running child it waits on. That is
the 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 is
falsifiable 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.

$ bash /tmp/699-r10/leak-sensitivity.sh
  LEAK: 2099854 2099853 sh -c i=0; while [ $i -lt 100000000 ]; do i=$((i+1)); done
SENSITIVITY-1 checker sees a deliberate leak: 1 (want >=1)
/tmp/699-r10/leak-sensitivity.sh: line 28: 2099854 Killed                     sh -c "i=0; while [ \$i -lt 100000000 ]; do i=\$((i+1)); done"
SENSITIVITY-1 after cleanup: 0 (want 0)
SENSITIVITY-2 reverted 3 grandchild kill sites in a COPY (tree untouched)
ok  	github.com/opencharly/charly/charly	4.144s
  LEAK: 2100171     566 sh -c i=0; while [ $i -lt 100000000 ]; do i=$((i+1)); done
  LEAK: 2100599     566 sh -c i=0; while [ $i -lt 100000000 ]; do i=$((i+1)); done
SENSITIVITY-2 old kill: before=0 after=2 (want after >=1 LEAK)
SENSITIVITY-2 after cleanup: 0 (want 0)
TREE: 0 modified (want 0)  HEAD=141f2d34

ppid=566 on both survivors — the burner has been reparented to the init process, which is
what "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:

$ go test ./charly/ -count=1
ok  	github.com/opencharly/charly/charly	144.057s
$ bash /tmp/699-orphan-check.sh
0

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:

$ go test ./charly/ -count=1 -v -run 'TestInvokeProvider_ProgressingLongCallIsNotKilled|TestInvokeProvider_FailsFastOnHungPeer|TestInvokeProvider_ServedHostWorkHeartbeatsTheCallerClock'
=== RUN   TestInvokeProvider_ProgressingLongCallIsNotKilled
--- PASS: TestInvokeProvider_ProgressingLongCallIsNotKilled (0.60s)
=== RUN   TestInvokeProvider_FailsFastOnHungPeer
--- PASS: TestInvokeProvider_FailsFastOnHungPeer (0.10s)
=== RUN   TestInvokeProvider_ServedHostWorkHeartbeatsTheCallerClock
--- PASS: TestInvokeProvider_ServedHostWorkHeartbeatsTheCallerClock (0.61s)
PASS
ok  	github.com/opencharly/charly/charly	3.743s

Falsification, via -overlay so the working tree is never touched (clean before and after, same
HEAD): 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:

$ go test -overlay=/tmp/699-r10/overlay-defect6.json ./charly/ -count=1 -v -run 'TestInvokeProvider_FailsFastOnHungPeer|TestInvokeProvider_ServedHostWorkHeartbeatsTheCallerClock'
=== RUN   TestInvokeProvider_FailsFastOnHungPeer
--- PASS: TestInvokeProvider_FailsFastOnHungPeer (0.10s)
=== RUN   TestInvokeProvider_ServedHostWorkHeartbeatsTheCallerClock
    plugin_dispatch_reverse_timeout_test.go:104: a served host call must keep the CALLER's clock alive: InvokeProvider verb:legfree op=run: InvokeProvider: plugin call made no host-visible progress within the no-progress window (no host reverse leg and no CPU advance from the peer process or any of its live descendants): peer pid=1557585; over the call: host reverse legs=1 (last 222ms ago), CPU advances=0 (last never); peer tree at kill: 1 live process(es) summing 0 ticks (root-only reader 0): 1557585(S,sleep); window=200ms. A starved host, a double-forked descendant and a genuinely wedged peer all read this way — if the tree shows live processes, re-run on an idle host before reading it as a hang
--- FAIL: TestInvokeProvider_ServedHostWorkHeartbeatsTheCallerClock (0.24s)
FAIL
FAIL	github.com/opencharly/charly/charly	2.746s
FAIL
$ git status --porcelain | wc -l
0

The overlay's own file is a copy of the committed plugin_dispatch_reverse.go with only the
heartbeat wrapper removed (/tmp/699-r10/plugin_dispatch_reverse_noheartbeat.go), so the failure
above 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-overlay is the full assembled bed (disposable: true) this change class requires, run
SOLO 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, which
re-runs the deploy (charly deploy add) and so reaches the served InvokeProvider where the guard
fired. Verdict read from the run's own summary.yml and the driver's own log — never from the
driver's exit code:

$ timeout 3600 ./bin/charly check run check-pod-overlay     # driver log: /tmp/699-r10/roster.log
PRECOND clean head=141f2d34045ef75aa869acbb62fff668a382bfcc 2026-10-05T04:43:04Z
BUILD exit=0 2026-10-05T04:44:14Z
BIN version=2026.278.0438 mtime=2026-10-05 06:44:14.157000000 +0200
BED-START check-pod-overlay head=141f2d34 version=2026.278.0438 2026-10-05T04:44:14Z
BED-DONE check-pod-overlay rc=0 summary_ok=true elapsed=2150s dir=/home/atrawog/Sync/Atrapub/lo/opencoder/opencharly/.worktrees/no-progress-guard/charly/.check/check-pod-overlay/2026.278.0445 2026-10-05T05:20:04Z

$ awk '/^  - name:/{n=$3} /duration_seconds:/{d=$2} /^    ok:/{printf "%-22s ok=%s %ss\n", n, $2, d}' .check/check-pod-overlay/2026.278.0445/summary.yml
image-build            ok=true 190s
check-image            ok=true 34s
deploy-add             ok=true 308s
config                 ok=true 132s
start                  ok=true 96s
bring-up-members       ok=true 1s
check-live             ok=true 162s
feature-run            ok=true 99s
update                 ok=true 612s
rebuild-ready          ok=true 2s
check-live-rebuild     ok=true 142s
feature-run-rebuild    ok=true 101s
cleanup                ok=true 34s
cleanup-members        ok=true 0s

Every step is ok: true (the file's own ok: at the top is true). The one that matters: update
passes 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 dispatch
was 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:

$ grep -rn 'no host-visible progress' .check/check-pod-overlay/2026.278.0445/
(no output)

The bed's own precondition — an idle host — is measured rather than assumed, and the state it
settled on is logged by the gate:

GATE-SETTLED loadavg=4.10 cores=16 load_per_core=0.26 procs_running=2 core_budget=8 task_writers=0 other_beds=0 waited=40s quiet=3/3

— no other session's bed, no charly task sync|verify, loadavg/cores and runnable-procs-per-core
both 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

TestPluginsGenReproducible is green on this head. It was red on the parent 9cd960ea
(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:

$ go test ./charly/internal/pluginsgen/ -count=1 -run TestPluginsGenReproducible -v
=== RUN   TestPluginsGenReproducible
Downloading github.com/opencharly/plugin-task:HEAD...
--- PASS: TestPluginsGenReproducible (68.78s)
PASS
ok  	github.com/opencharly/charly/charly/internal/pluginsgen	68.792s

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's golangci-lint run:

$ gofmt -l charly tools
$ go test ./charly/...              # TMPDIR=/tmp/charly-ci, as CI sets it
ok  	github.com/opencharly/charly/charly	144.057s
ok  	github.com/opencharly/charly/charly/internal/pluginsgen	110.720s
$ go vet ./...
$ ( cd charly && "$(go env GOPATH)/bin/golangci-lint" run ./... )
0 issues.
$ for d in tools/*/; do ( cd "$d" && GOWORK=off go test ./... ); done
ok  	github.com/opencharly/charly/tools/gomod-canonical	0.004s
ok  	github.com/opencharly/charly/tools/ledger-validate	0.007s

gofmt -l printed nothing (0 files unformatted — gofmt_lines=0), go vet exited 0 with no
diagnostics, and golangci-lint reports 0 issues. (lint_exit=0). The lint invocation is not a
lookalike: it is CI's own step copied verbatim — .github/workflows/ci.yml:92-93 pins
[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 from charly/ so the repo's CWD-selected config applies — which is the
hole 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-validator BLOCKED the previous head (40209961) on three findings, all of them
R1 (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.C arm's comment claimed a drain the call could not perform. It
passed nil, and observe's own doc two functions up said plainly that a nil channel never fires in
a select. Fixed by passing the live channel, which is what the comment already claimed:

			case <-cpu.C:
				// CPU advancing is progress: refresh the clock + high-water and reset
				// the deadline, so a plugin busy on its own children never trips. The
				// LIVE wake channel is passed, never nil: a nil channel never fires in
				// a select, so passing it would make observe's drain a no-op and leave
				// a host-leg touch this tick raced pending for the expiry to trip over.
				if cur, ok := a.observe(wake, lastCPU); ok {

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 stays
legal 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-scheduling
event, so no test can force it deterministically. What is pinned is the behaviour the call site
depends on — TestObserve_PendingLegEventAtExpiryIsProgress proves observe does drain a
pending 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 stack rather than
queue, and the property the tree-shaped report actually needs is pinned:

	// The ppid links form a forest, so this walk terminates on every input. It is a
	// LIFO STACK (pop and push at the same end), i.e. depth-first pre-order: each node
	// is emitted before the children it then pushes, so a parent always precedes its
	// own descendants in the report. A FIFO queue would make it breadth-first instead;
	// nothing depends on which, so the order is documented rather than implied.

TestProcTreeProcs_PreOrder asserts that property over the peer's real tree — root first, and no
process 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 inside
case <-timer.C (progress confirmed at expiry), which the previous code never did. It is the
package-level resetDeadline now, and its drain is the non-blocking form:

func resetDeadline(timer *time.Timer, d time.Duration) {
	if !timer.Stop() {
		select {
		case <-timer.C:
		default:
		}
	}
	timer.Reset(d)
}

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
141f2d34 before and after):

$ bash /tmp/699-fix/falsify.sh          # full log: /tmp/699-fix/falsify.txt

### FALSIFY 3 — a BARE drain (the shape the review warned about) on the expiry path
# patch: resetDeadline's 'select { case <-timer.C: default: }' -> '<-timer.C>'
    plugin_activity_test.go:513: resetDeadline blocked after the expiry value was consumed — a wedged watcher
--- FAIL: TestResetDeadline_NonBlockingOnTheExpiryPath (5.03s)
FAIL
FAIL	github.com/opencharly/charly/charly	7.495s

### FALSIFY 2 — emit each node BEFORE its parent (a non-pre-order walk)
# patch: 'out = append(out, nodes[n])' -> 'out = append([]procInfo{nodes[n]}, out...)'
    plugin_activity_test.go:573: the root must be visited first, got pid 1881468
--- FAIL: TestProcTreeProcs_PreOrder (0.03s)
FAIL
FAIL	github.com/opencharly/charly/charly	2.401s

### RESTORED — both pinning tests green again on the committed tree
--- PASS: TestResetDeadline_NonBlockingOnTheExpiryPath (0.06s)
--- PASS: TestResetDeadline_NonBlockingWithStalePendingExpiry (0.40s)
--- PASS: TestProcTreeProcs_PreOrder (0.04s)
ok  	github.com/opencharly/charly/charly	2.910s

# tree identity after restore:
# HEAD 141f2d34045ef75aa869acbb62fff668a382bfcc
# TREE_DIRTY 0

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_NonBlockingWithStalePendingExpiry pins the other
state (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 the
clock is heartbeated "every 5s", while startPluginActivityHeartbeat derives the beat from the
window (window/4, capped at 5s — which is why a 200 ms-window test still passes). The doc now says
so.

Rulebook compliance

  • R0 — /charly-internals:git-workflow loaded before any git/PR action;
    /charly-internals:root-cause-analyzer for the RCA; /charly-check:check for the bed.
  • R1 — six defects, each root-caused to a mechanism and each reproduced; no "pre-existing",
    "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.
  • R3 — observe is the one progress measurement the watchdog makes; procTreeProcs is the
    one /proc tree 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 /proc itself (procStatFields) rather than calling the production
    reader, 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 as
    HostBuild already does, and it reuses the existing newPluginActivity/idleBoundedContext clock
    rather than inventing a parallel one.
  • R4/R4a — no workaround: the guard is fixed, not the call sites or the bed. The kill is neither
    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.
  • R5 — the old behaviour is replaced, not shadowed: the kill-on-first-expiry path is gone (there
    is no flag or env var that restores it), and the false "therefore NO race" claim in the wake
    doc comment is deleted, not annotated with a correction.
  • R6 — no force-push, no hook bypass, no direct push to main. The branch was rebased onto
    origin/main locally with a backup ref, before anything was pushed.
  • R7 — the new tests fail without the change (sections 2, 3 and 4 above: the -overlay
    sensitivities, 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.
  • R7a — nothing live was faked; the /proc walks and the bed run against the real host.
  • R9 — the binary is the source, proven not asserted: bootstrap-charly.sh stamps the CalVer
    from the HEAD commit, and the stamp matches to the minute. HEAD 141f2d34 committed
    2026-10-05T06:38:40+02:00 (= 04:38:40Z); the built binary reports version=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:
PRECOND clean head=141f2d34045ef75aa869acbb62fff668a382bfcc 2026-10-05T04:43:04Z
BUILD exit=0 2026-10-05T04:44:14Z
BIN version=2026.278.0438 mtime=2026-10-05 06:44:14.157000000 +0200
BED-START check-pod-overlay head=141f2d34 version=2026.278.0438 2026-10-05T04:44:14Z
  • R10 — the bed ran from the final committed tree (clean before the build, HEAD unmoved across it,
    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:
GATE-SETTLED loadavg=4.10 cores=16 load_per_core=0.26 procs_running=2 core_budget=8 task_writers=0 other_beds=0 waited=40s quiet=3/3

Defect 5 was found by taking that precondition seriously, and defect 6 by running the bed twice.

Change classification

  • Diff: 4 files, 6 commits — 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 over
    origin/main).
  • Change class: code (runtime behaviour of the plugin host's idle guard) + tests.
  • Verification gate: unit tests of the changed path + three sensitivity proofs + the
    parent-commit reproduction + a live disposable: true bed on the final committed tree.
  • Attribution tier: fully tested and validated — the changed runtime path was executed live
    (check-pod-overlay, disposable: true, green on the final committed tree, the update step that
    used 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 is
    shown to fail without the change (sections 2–5 above, plus section 9 for the three review findings).

Coordination

Agent: no-progress-guard · session 2a317871-ba03-4713-89ba-8edbd4059c27
Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)

…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.
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Review — BLOCK

Head SHA: 40209961db84425bfc1d64dabf46eff3f51ebe19 (branch: feat/no-progress-guard)

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

  1. R1 (B5) — comment diverges from the code it sits on. charly/plugin_activity.go, the case <-cpu.C: arm (~lines 366–369):

    // observe drains a pending leg token too, so a touch that this tick
    // raced is counted rather than left for the expiry to trip over.
    if cur, ok := a.observe(nil, lastCPU); ok {
    

    observe's wake parameter is nil here, and observe's own doc two functions up states plainly: "A nil wake channel never fires in a select, so the CPU-only callers pass nil." So this call cannot drain a pending leg token, and the raced touch is not "counted" by it — it is left for case <-wake or the expiry path. The comment asserts a safety property (the raced touch is counted at this tick) that the code does not provide, and it directly contradicts observe's doc in the same file. This is exactly the "assertion where the watchdog can only measure" class the PR claims to eliminate. Either pass the live channel (if draining here is intended) or delete/correct the two comment lines so they describe what the call actually does.

  2. R1 (B5) — comment misdescribes the traversal. charly/plugin_activity.go, the procTreeProcs doc says the walk returns "the root first, then its descendants breadth-first." The implementation is a LIFO stack (n := queue[len(queue)-1] / queue = queue[:len(queue)-1] pop, append(..., children[n]...) push), i.e. depth-first pre-order, not breadth-first. Fix the doc to say depth-first (or make it breadth-first); the report's member list renders in this order, so the description of what a kill report shows is wrong.

  3. Must confirm — reset() is now invoked from inside case <-timer.C. The diff adds reset() on the expiry path (after observe(wake, lastCPU) returns progress), a call the old code never made from the timer arm. If reset() uses the conventional if !timer.Stop() { <-timer.C } drain, that receive blocks forever immediately after the timer has just fired (the channel is already drained), wedging the watcher goroutine. No pasted test exercises the "progress confirmed at expiry → reset" path (the trip tests take the observe-false → cancel branch), so a deadlock there would be invisible to the suite. The diff does not show reset(); state (or paste) its body to prove it is a non-blocking reset (timer.Reset alone, or a select { case <-timer.C: default: } drain).

Notes (not the block, recorded for completeness)

  • B12 (R10) tool-limited: I cannot re-run beds or the rulebook's change-class matrix, so the single named bed (check-pod-overlay) and its completeness cannot be independently confirmed; the pasted summary.yml, PRECOND/BUILD/BIN/BED-* lines and CalVer (2026.278.0344 ↔ HEAD 03:44:29Z, day 278) are internally consistent, so this is not raised as a defect. The withActivityHeartbeat doc says "every 5s", yet TestInvokeProvider_ServedHostWorkHeartbeatsTheCallerClock passes with a 200 ms window — the heartbeat interval must be window-derived; the pasted falsification (red without the wrapper, green with it) is self-consistent, so I take it as verified-by-cross-check, but the doc/interval tension is worth a glance.
  • A3: Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated) — the harness/model pairing is unverifiable from the body (no authoring-runtime evidence) and is not treated as a defect on its own; the tier is otherwise supported by the pasted live bed.
  • Comment thread: 0 comments — nothing to disposition.

Verdict: BLOCK


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

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.
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Review — PASS

Head SHA: 141f2d34045ef75aa869acbb62fff668a382bfcc (branch: feat/no-progress-guard)

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 Assisted-by: line and accounts for all 4 files / 7 described changes; A2/A3 code-class gate = fresh-rebuild live bed, tier supported; B4–B18: no duplication, no workaround, hard cutover, no orphaned legacy path, tests fail without the change, disposable bed on the final head). Bed coverage and the harness/model pairing are tool-limited/unverifiable from here, not defects.

Comment dispositions (1 comment): the prior github-actions[bot] BLOCK on 40209961 — all three findings re-derived against the CURRENT diff and resolved, i.e. stale-superseded:

  1. case <-cpu.C now passes the live wake channel (a.observe(wake, lastCPU)) and observe's doc matches — fixed.
  2. procTreeProcs doc now says depth-first pre-order with a LIFO stack — matches the implementation (pop/push at the same end, node emitted before its children) — fixed.
  3. reset is now the non-blocking package-level resetDeadline (select-with-default), both timer states pinned; note the removed closure was already non-blocking, so this finding was never a real defect — resolved regardless.
    The comment's non-blocking notes (bed matrix, harness/model) remain unverified-dismissed.

Verdict: PASS


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants