The test's vendor (paced) spaced its reasoning, text and end with a fixed
80ms sleep, and that sleep was all that kept them apart. On a loaded full
run the gateway read late, found the reasoning and the text waiting
together, and timed both at once ("usage ttft 228, first text 228" for
responses_from_chat). The gateway timed what it read correctly; the test
assumed the scheduler keeps up.
ump45nose's patch (test only): paced takes a heard hook, and the gap
before each marked event after the first starts only once the agent
(hearing, a ResponseRecorder that watches its body for "hmm" and then
"hi") has been sent the one before, with a 10s give-up so a missing word
fails instead of hanging. Every case runs twice, "on time" and "late",
where the gateway's first write to the agent is held three gaps while
the vendor's events come in. Other paced users leave heard nil.
Verified (sandbox HOME, pinned caches, go1.26.8 darwin/arm64, base
origin/main 72d6103e2):
- Cause, by injecting the delay: with the gate removed by hand (heard:
nil) all five "late" cases go red, responses_from_chat in the issue's
shape: "usage ttft 337, first text 337, ms 337"; chat, responses and
chat_from_anthropic read the text and the end together (first text ==
ms). With the gate all 10 pass.
- -count=10 with 12 `yes` CPU burners beside it, machine load ~280: ok.
-race -count=3: ok. No case waits on the 10s give-up (each <0.6s).
- gofmt -l: clean. go vet -tags nogui ./... for darwin, linux, windows:
ok. Full suite with both this and the #2599 change in the tree,
set -o pipefail; go test -tags nogui -timeout 45m ./... : 66 packages
ok, none failed (internal/gateway 825s, internal/provider 266s).
- Rebased onto origin/main ec6454395 (claude_subscription, ir.go):
gofmt clean, vet darwin/linux/windows on internal/gateway and
internal/settings ok; go test -tags nogui -timeout 45m
./internal/gateway ./internal/settings: ok (gateway 668s).
Co-authored-by: ump45nose <ump45nose@users.noreply.github.com>