Repository navigation
test(contract)!: stop the trial broker with SIGTERM alone - #218
Merged
Merged
Conversation
10 tasks done
The harness closed the stdin of nodkey try and then sent SIGTERM. At the end of its input, nodkey try stops with exit status 1, by design, so the two raced. Now the harness sends only SIGTERM, reads all that nodkey try wrote, and then waits. When the stop fails, it prints what nodkey try wrote. Fixes #214 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
groupsky
force-pushed
the
fix/214-contract-trial-stop
branch
from
November 18, 2026 21:06
28177f5 to
10404ba
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Fixes #214
The contract tests sometimes failed at the end, with "the trial broker did not stop cleanly: exit status 1", and no test failed.
The cause is the harness, not
nodkey try.trial.stop()intest/contract/harness_linux_test.goclosed the stdin ofnodkey try, and then sent SIGTERM.nodkey tryreads the answers on its stdin. When its input ends, no answer can come any more, so it stops with exit status 1 and says "the terminal approver stopped" (serveTryincmd/nodkey/try.go). This is on purpose, andTestTryStopsWhenTheInputEndsincmd/nodkeytests it. After SIGTERM alone,nodkey tryends with exit status 0 (TestTryApproveWindow,TestTryExpiry,TestTryDeny,TestTryStopsOnHangupcheck this with SIGTERM, SIGINT and SIGHUP). So the harness started a race between two ways to stop: the end of the input (exit 1) and the signal (exit 0). Most often the signal won. Sometimes the end of the input reachedserveTryfirst.nodkey tryis right, socmd/nodkeydoes not change.The change:
stop()sends only SIGTERM. It waits until the stdout ofnodkey tryis closed (so the harness has read every line), and then callsWait, which closes the stdin. A process that has already ended is not an error of the signal;Waitstill gives its exit status.WaitDelaycapsWait, and the two timeouts have their own error text.runTestsprints whatnodkey trywrote (tr.output()). It holds names and short codes, never a value.docs/updating.md: the README oftest/contract/says that a change to the harness counts as a change in behavior for callers. So this pull request answers "yes" and adds a section. It says that no caller is affected:nodkey runandnodkey trydid not change, and no release had the old harness.Behavior for callers
Changes behavior for existing callers: yes
(Only because of the rule for files under
test/contract/. No caller ofnodkey runsees a change.)Tests
go test -race ./...,go vet ./...,golangci-lint run --build-tags e2e.go test -race -count=1 ./test/contract/), with the Go ofgo.modand with Go stable. It is removed before the merge.Progress
nodkey tryon a failed stop.go.modand Go stable: run 44398083961 (go.mod: job 135133323503; stable: job 135133323613), 20 of 20 in each, after the rebase on fix(broker): clear the login of a pre-approval before the answer #219. Before the rebase, go.mod also passed 20 of 20 in run 44394191315; stable failed there before the loop, inTestLoginRememberedTimer(test: TestLoginRememberedTimer is flaky in CI with Go stable #205, fixed by fix(broker): clear the login of a pre-approval before the answer #219).Checklist
docs/updating.md. DESIGN.md and THREAT-MODEL.md do not change: no message, check or path of a value changes.🤖 Generated with Claude Code