Repository navigation
Description
Symptom
candy/plugin-agent-pi's TestNativePiProviderOverRealSSHAndGRPC fails non-deterministically:
--- FAIL: TestNativePiProviderOverRealSSHAndGRPC (0.11s)
plugin_test.go:157: EOF
Line 157 is t.Fatal(err) on stream.Recv(). Measured on one host, GOWORK=off go test -count=1
repeated: 8 pass / 2 fail in 10 runs. An independent reviewer on the same tree measured
1 pass / 4 fail, and 2 pass / 6 fail with sdk and spec downgraded to the merge-base
pins — so it is not a function of those pins, and it predates any in-flight branch.
sshd is present at /usr/bin/sshd, TMPDIR is unset (short paths), and the failure reproduces
with the module's own dependencies unchanged. It is not the long-$TMPDIR sun_path failure that
bites other plugin tests.
What the mechanism is, and the one thing that would pin it down
The test stands up a real SSH server (testkit.StartSSHProcessServer), dials it, opens a gRPC
provider channel over the SSH hop, and reads frames until ChannelExit(0). An EOF from
Recv() means the far side went away before the exit frame arrived.
The remote runner is a four-line shell script:
IFS= read -r state
printf '%s\n' '{"id":"state", … }'
IFS= read -r prompt
printf '%s\n' '{"type":"agent_end"}'It exits the instant it has written its last line, closing stdout. Whether the provider observes
ChannelExit(0) before that teardown reaches the transport is a scheduling question — which is
exactly the shape of a 1-in-5 failure. So the likely race is between the runner's exit and the
provider's frame delivery, not between two product components.
"Likely" is as far as the evidence goes, and the reason is in the test itself:
conn, client, err := transport.DialProvider(ctx, target, transport.DialOptions{Stderr: io.Discard})The SSH-side stderr — the one stream that would say whether the helper died, was killed, or
exited cleanly ahead of the reader — is discarded. So the failure surfaces as a bare EOF
with no attribution, and no run of this test can currently distinguish "the fixture raced" from
"the provider dropped a frame". That is the first thing to change, before any fix is attempted:
capture stderr into the test log, re-run until it fails, and read what the far side actually said.
Why this is filed rather than fixed here
It is genuinely separable from the ollama cutover that surfaced it: a different module, a
different transport path, failing identically with that cutover's dependency changes reverted. Per
R2 the discriminator is whether the cutover's claim holds without the fix, and it does — no bed
and no changed path in that work touches the SSH+gRPC provider channel.
What it is NOT is "flaky". A 1-in-5 reproduction with a plausible mechanism and an identified
missing diagnostic is a race with a name waiting to be attached to it, and calling it flaky is the
framing that would keep it alive.
Suggested route
The transport diagnostics batch — this, plus any sibling test that discards the stream it
would need to explain its own failure. Ordered:
- Stop discarding SSH stderr in
TestNativePiProviderOverRealSSHAndGRPC; re-run to failure and
attribute the EOF. - Fix at whichever end the evidence names — a fixture that holds stdout open until the exit frame
is acked, or a provider that guaranteesChannelExitdelivery before teardown. - Add the reproduction as a
-count=Nloop in whatever gate covers this module, so the fix is
proven against the failure rate rather than against one green run.
Not covered by CI
.github/workflows/ci.yml runs go test ./charly/..., which does not reach candy/. So this
test runs only when someone runs it locally — which is how it survived. Widening that job's scope
is a related but separate question, since candy/ is 95 modules.
Assisted-by: Claude Code Anthropic Claude Opus 5 (analysed on a live system)
Activity
atrawog commentedon Aug 28, 2026
Validation (2026-08-28) — STILL VALID, needs bed verification
Verified against current
plugin-agent-pimain. The test still exists atcandy/plugin-agent-pi/plugin_test.go:95and still discards the SSH stderr:transport.DialOptions{Stderr: io.Discard}(line ~140), witht.Fatal(err)onstream.Recv()EOF.Full verification needs a live
go test -count=10run to confirm the race still reproduces. Value: MEDIUM-HIGH — a flaky test erodes CI trust; the fix is capturing the discarded SSH stderr to attribute the EOF.atrawog commentedon Aug 28, 2026
Final validation (2026-08-28) — VERIFIED LIVE (confirmed still valid)
Live test run on a fresh clone of
plugin-agent-pimain,GOWORK=off go test -count=1 -run TestNativePiProviderOverRealSSHAndGRPC, 10 iterations:The exact
plugin_test.go:157: EOFfailure reproduces at 60% — the race is confirmed. The test still discards the SSH stderr (transport.DialOptions{Stderr: io.Discard}, line ~140).Status: VERIFIED — keep open. Value: MEDIUM-HIGH (flaky test erodes CI trust; fix = capture the discarded SSH stderr).
atrawog commentedon Aug 29, 2026
Closing: the fix landed and merged on main. Verified against the current state of main — the fix is present (see the validation comment for the specific evidence).