Repository navigation
Node agent tests: drive the failed-handoff hold test from the rig clock, so a slow host cannot settle the sample early - #545
Merged
Merged
Conversation
Agent: grok/grok-4.7
…l time Agent: grok/grok-4.7
Open and head checks run for both hold subtests. Only the rig-clock advance stays on the meter that reads that clock. The catch-up aligns the first reading with real time and will not step the wall further back than the anchor tolerance minus 250ms. Agent: grok/grok-4.7
Agent: grok/grok-4.7
teddashh
added a commit
that referenced
this pull request
Nov 15, 2026
Co-Authored-By: Claude Fable 5.2 <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.
TestR22_H1B_FailedHandoffSettlementAndSampling(node/agent/followup39_test.go) checks that a usage sample which fails at a serving handoff stays pending and is settled later, with and without an agent restart. Its twoholdsubtests made the sample fail by clock. The test's meter readtime.Nowplus 1.5 s for the first sample andtime.Nowfor the handoff, so the handoff reading was behind the checkpoint and the meter held it. That works only while less than 1.5 s of real time passes between the two readings. On a loaded host more time passed, the handoff sample was not held, and bothholdsubtests failed withfailed final sample was not left pending. A later wait in the test also slept on real time, and the poll for the sample taken byRungave up after one second.What changes (one test file; no production code):
time.Now. A reading behind that checkpoint would be held, and one more than a full sample interval behind it would be a clock gap. So before the first sample the test waits until real time is past that checkpoint and then moves the rig clock so that the first reading equals real time. The step can go forward or backward. A backward step is never larger than the time anchor's backward tolerance less 250 ms (timeanchor.DefaultBackwardSkew): the test waits up to ten seconds for real time to come within that limit, and fails withcatch-up still behind the anchor toleranceif it does not.time.Now, so a clock offset in the test cannot keep its sample pending. The test's existing read-failure switch now does that: it is set before the restart and cleared where the test settles the sample.r22WaitPastCheckpointsleeps until real time is 10 ms past the newest checkpoint. Without it, such a meter could find a checkpoint that the rig clock wrote ahead of real time and hold its own first sample.Runwaits up to 30 seconds and still leaves as soon as the ledger shows the delta.No existing assertion changes.
One case is not handled, and the helper's comment says so: if the host's wall clock steps back while
r22WaitPastCheckpointsleeps, real time can still be behind the checkpoint afterwards and a sample taken then can be held.Checks made with temporary edits, three runs each, each reverted afterwards. On the base commit:
holdsubtests failed withfailed final sample was not left pending, and bothread_errorsubtests passed. This is the failure the change removes.On the last commit that changes code (the final commit corrects three comments):
holdoffset of -1.5 s, so that the handoff reads after the checkpoint: bothholdsubtests failed withfailed final sample was not left pending;hold_restart_truefailed withpending final sample allowed Apply or serving;holdsubtests about 2.5 s slower;generation 3 not serving;catch-up still behind the anchor tolerance.Validation: on the exact source
61e77fe5:TestR22_H1B_FailedHandoffSettlementAndSamplingby name, five runs: the test and each of its four subtests (hold_restart_false,hold_restart_true,read_error_restart_false,read_error_restart_true) passed five times, none skipped;TestD096_RealNetBird), build;go-lint,go test ./...(95 packages ok; 3 of them came from Go's test cache (node/internal/controlclient,node/internal/fakecontrol/cmd/fvpn-labcontrolandnode/internal/timeanchor: their tests had passed a few minutes earlier in the same tree, in the Node job's unit test step above; the changed packagenode/agentran fresh)), the build of every command for amd64 and arm64, and the tidy check.Then the same checks on a temporary merge of this source into main
c001b569, which merged without conflicts:TestR22_H1B_FailedHandoffSettlementAndSamplingby name, five runs: the test and each of its four subtests (hold_restart_false,hold_restart_true,read_error_restart_false,read_error_restart_true) passed five times, none skipped;TestD096_RealNetBird), build;go-lint,go test ./...(96 packages ok; 3 of them came from Go's test cache (node/internal/controlclient,node/internal/fakecontrol/cmd/fvpn-labcontrolandnode/internal/timeanchor: their tests had passed a few minutes earlier in the same tree, in the Node job's unit test step above; the changed packagenode/agentran fresh)), the build of every command for amd64 and arm64, and the tidy check.These are local runs; no CI result is claimed here.
Review: four independent review rounds, each on an exact source. The first found that the first version still depended on real time in two places: the restarted meter reads
time.Now, so the sample stayed pending only while real time was behind a checkpoint written nine seconds ahead, and the successor at the end booted while that checkpoint was still ahead of real time. The second commit removes the lead and keeps the sample pending across the restart with the read-failure switch. The second review found that this commit had dropped two error checks fromhold_restart_true, and that a single alignment step could exceed the anchor's backward tolerance if the host clock stepped back during setup; the third commit restores the checks and bounds the step. The third review confirmed those fixes and raised two more points about host clock steps and late wake-ups. The project lead did not accept them as defects of this change: a host clock step back makes the test fail at setup, not pass for a wrong reason, and the loop reads real time again before it accepts a step, so a late wake-up cannot pass a step outside the limit. The helper's comment now names the unhandled case, and the final commit also corrects two other comments. The fourth review, of that commit, approved it with no findings.Agent: grok/grok-4.7
🤖 Generated with Claude Code