Repository navigation
fix(plugin): make the idle guard event-driven, not sample-driven (RCA) - #658
Conversation
RCA of a real failure: TestInvokeProvider_ProgressingLongCallIsNotKilled intermittently failed under full-suite load with "plugin call made no host-visible progress within the no-progress window" — a FALSE idle kill of a plugin that was actively progressing. Root cause: the watchdog was SAMPLE-DRIVEN. It ticked at noProgress/4 and each tick compared the last-touch timestamp against the FULL noProgress window (idleFor() >= noProgress). A host-leg touch also fired at noProgress/4 (the fixture's cadence; production heartbeats are similar), so the two cadences were EQUAL with ZERO scheduling margin: a single >noProgress stall in the producer goroutine under load let the watcher observe a stale timestamp and cancel a working call. Re-timing the interval would only move the race; the fix is the primitive. Fix: progress becomes an EVENT. pluginActivity gains a buffered wake channel; touch() signals it non-blockingly; idleBoundedContext arms a deadline timer and RESETS it on every wake. A progress event arriving before the deadline always resets it, so there is no race between producer and watcher cadence. CPU advance (which has no event source) is still polled at noProgress/4 and likewise resets the deadline. newPluginActivity(pid) is the constructor the dispatch site and the tests now use. Proven: `go test -race` on the idle-bound tests is clean; two consecutive full-suite runs are green (the failure reproduced only under full-suite load, so the two full runs are the reproducer).
Review — BLOCKHead SHA: Change class: charly Go code — plugin idle-guard concurrency primitive ( The mechanism itself checks out (event-driven Blocks
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
… verbs) (#657) * chore(deps): bump plugin-task to v0.2026268.104 (the four maintenance verbs) charly pinned candy/plugin-task at v0.2026267.2043 (the task runner only). The merged plugin-task PR #3 added the four generic maintenance verbs (git-submodules/file-parity/splice-region/module-pins); this bumps the compiled-in pin to candy/plugin-task/v0.2026268.104 so charly ships them, regenerates go.work.sum, and re-tidies. This is the charly-side prerequisite for the umbrella cutover (P4), whose charly.yml tasks compose those verbs. Proven: scripts/bootstrap-charly.sh builds bin/charly (2026.268.0031) with the new pin; `charly task` dispatches git-submodules live; full `go test ./...` green (charly + charly/internal/pluginsgen). * chore: re-run validator — per-verb live evidence; idle-guard RCA routed to #658 Body now pastes each of the four verbs' real live output and names the dedicated idle-guard RCA fix (PR #658) instead of any flake framing. --------- Co-authored-by: opencode <[email protected]>
…ewrite The event-driven watcher resets a deadline timer on a progress EVENT, so the sampled idleFor() reader (and its atomic nanos timestamp) have no callers. Remove both so the package lints clean (the CI golangci-lint job flagged idleFor as unused). This is the R5 completion of the same cutover.
Review — BLOCKHead SHA: Change class: charly Go code — plugin idle-guard concurrency primitive (core Security screen: PASS (no secrets, no egress, no guardrail/spec/rulebook weakening, no supply-chain change; the diff is a concurrency-primitive rewrite plus its call-site/test updates). Blocks
Comment intake
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
…l-wake guard)
A clock built as a bare &pluginActivity{} literal has a nil `wake` channel, so
`case <-wake` would block forever and the event-driven reset would never fire —
silently reverting the guard to a bare noProgress timer that false-kills a
progressing call (the exact bug the event-driven rewrite fixes). idleBoundedContext
now arms the channel before the watcher starts (before any touch can race it).
TestIdleBoundedContext_NilWakeLiteralStillResets proves it: a bare-literal clock
whose touch fires every 50ms must outlive a 150ms window; the test FAILS if the
arming is removed (verified by temporarily deleting it).
Review — BLOCKHead SHA: Change class: charly Go code — plugin idle-guard concurrency primitive (core The mechanism re-derives clean against the current diff: Blocks
Comment intake
Note (tool-limited): the pasted R10 output carries Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
Body now names R5 (dead idleFor/nanos removed + construction-contract sweep), R8 (N/A), R9 (bootstrap rebuild + charly version), pastes the grep sweep, and the nil-wake guard + its teeth proof.
Review — BLOCKHead SHA: Change class: charly Go code — plugin idle-guard concurrency primitive (core Security screen: PASS (no secrets/egress/guardrail weakening/supply-chain change). Blocks
Comment intake
Note (non-blocking, B15): the change lands as four iterative commits; the intended squash will collapse them — no partial/phase-2 work pattern is present. Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
…llowlist explanation The sweep now shows the real output (constructor + the nil-wake test's deliberate bare literal) and explains [allowlisted=1] as the dev-worktree-binary-notice.
Review — PASSHead SHA: Change class: charly Go code — core plugin idle-guard concurrency primitive. Placement: CORRECT (the idle guard is reverse-channel/dispatch infrastructure → core; no alias file, no sdk-kit import, no Security screen: PASS (no secrets/egress/new deps; no guardrail/spec/rulebook weakening; no scope mismatch — all three files are accounted for in the body). Checklist: All applicable rules PASS or NA. R1 RCA is real (equal producer/watcher cadence, zero margin; primitive replaced, not re-timed); R4 no sleep/retry; R5 Comment intake (all four prior BLOCKs re-derived against current head — every one is now resolved):
Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
Review — PASSHead SHA: Change class: charly Go code — core plugin idle-guard concurrency primitive. Security screen: PASS — no secrets/egress/new deps; no guardrail, spec, or rulebook weakening (the idle guard is a runtime watchdog, not security machinery — T4 N/A); all three files accounted for in the body (no scope mismatch). Placement: CORRECT — Checklist: All applicable rules PASS or NA. R5 sweep re-derived line-by-line against the current diff and reproduces exactly ( Comment intake:
Non-blocking (B15): the change lands as iterative commits (3 fix + 2 validator-rerun body edits) plus a Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
Summary
Make the per-call plugin idle guard event-driven instead of sample-driven,
root-causing a real intermittent failure of
TestInvokeProvider_ProgressingLongCallIsNotKilledunder full-suite load.RCA. The watchdog ticked at
noProgress/4and each tick compared thelast-touch timestamp against the FULL
noProgresswindow(
idleFor() >= noProgress). A host-leg touch also fired atnoProgress/4(thefixture's cadence; production heartbeats are similar), so the two cadences were
EQUAL with zero scheduling margin: a single
>noProgressstall in theproducer goroutine under load let the watcher read a stale timestamp and cancel a
call that was actively progressing. Re-timing the interval would only move the
race.
Fix (the primitive, not the timing).
pluginActivitygains a bufferedwakechannel;
touch()signals it non-blockingly;idleBoundedContextarms a deadlinetimer and resets it on every wake. A progress event arriving before the
deadline always resets it, so there is no race between producer and watcher
cadence. CPU advance (no event source) is still polled at
noProgress/4andlikewise resets the deadline.
newPluginActivity(pid)is the constructor thedispatch site and the tests now use.
Nil-wake hardening. A clock built as a bare
&pluginActivity{}literal wouldhave a nil
wake, socase <-wakewould block forever and the reset would neverfire — silently reverting to a bare timer (the bug being fixed).
idleBoundedContexttherefore arms the channel before the watcher starts, and
TestIdleBoundedContext_NilWakeLiteralStillResetsproves it (the test FAILS if thearming is removed — verified by temporarily deleting it).
The now-dead sampled reader
idleFor()and itsnanosfield were removed in thesame cutover (R5); the CI golangci-lint job flagged
idleForas unused.How tested
Rebuild from the final tree + binary identity (R9)
The R10 run below used THIS binary (
2026.268.0236), built from this tree.The failure's reproducer is the full suite
The false idle kill reproduced only under full-suite load, so the reproducer is
the full suite (two consecutive runs green after the fix):
Race-clean on the idle-bound tests, including the new nil-wake guard:
The nil-wake test has teeth: deleting the
if a.wake == nil { a.wake = … }armingturns it RED (
a bare-literal clock's touch must reset the deadline, got … hung plugin).R5 sweep — no stale construction/dead-identifier references
Three matches, all intended: the constructor (wake non-nil) and the nil-wake TEST's
deliberate bare literal (which
idleBoundedContextarms — that bare literal is thesubject of
TestIdleBoundedContext_NilWakeLiteralStillResets). NoidleFor/.nanosreference survives.
The
[allowlisted=1]annotation in the R10 outputEvery step line carries
[allowlisted=1]. That is the check gate'sdev-worktree-binary-notice— the expected diagnostic that./bin/charlyis adev/worktree build rather than a host install (it is allowlisted by the gate, not a
surviving warning). The gate reports zero NON-allowlisted warnings.
R10 — the plugin→plugin dispatch bed the guard protects
The guard wraps
InvokeProvider;charly preemptreachesverb:arbiterthroughit, so
check-preempt-localexercises the changed path:Rulebook compliance
/charly-internals:plugin,/charly-internals:go,/charly-internals:git-workflow,/charly-check:check,/charly-internals:root-cause-analyzer,/charly-internals:strict-policy.margin) was established from the code, not dismissed; the fix replaces the
sampling primitive rather than re-timing it, and the nil-wake hazard the
rewrite introduced is closed and tested.
by construction (an event resets the deadline).
idleFor()and itsnanosfield are removed (the sweep above); the construction contract is
newPluginActivity,and
idleBoundedContextarms the channel so a bare literal can never bypass it.feat/branch + PR; no force-push, no hook bypass.idle-bound tests are race-clean; the nil-wake test has proven teeth.
scripts/bootstrap-charly.shrebuiltbin/charly(
charly version→2026.268.0236) from this tree; the R10 run used it.check-preempt-local(disposablehost: local)passed 6/6.
tag-on-mergewritesCHANGELOG/<calver>.mdfrom this body.Change classification
go test ./...+go test -raceon the idle tests +golangci-lint run ./charly/...+ the fresh-build R10charly check run check-preempt-local.fully tested and validated— the changed path executedlive; the full in-repo fresh-rebuild R10 gate passed.
Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated)