carlos / platform Public

drill: start on a fresh minute so the hub counts only the drill (#511 H2)

The other 36 of drill 3's 41 extra hub 2xx were the operator's 1/s
copies-raise probe: it ran until 13:02:37 and the drill started at
13:02:49, in the same minute, and judgeEvidence's totals take every
minute a drill response can have been filed in, the first one whole.

The drill now waits, after reading the boxes' build and before its first
request, for the next minute's start plus clockSkew (cleanStart), so
every minute it is judged on holds only requests sent after it started.
The operator must still stop every other request to the host first.
The remaining 5 were websocket dials the hub filed as 2xx, fixed in the
edge; the tool already modelled a 101 as no 2xx.

TestReplicaDrillCleanStart replays drill 3's shape: the same-minute
start fails, the fresh-minute start reconciles.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 38b1f4b2c6af1f6ce61eae33cac55f98a9d4123c parent 214da4f
3 files changed, +71 −1
  • scripts/stateless-replicas-drill/accounting_test.go +45 −0
  • scripts/stateless-replicas-drill/evidence.go +11 −1
  • scripts/stateless-replicas-drill/main.go +15 −0
diff --git a/scripts/stateless-replicas-drill/accounting_test.go b/scripts/stateless-replicas-drill/accounting_test.go
index 07fa5a6a3..70ea6c863 100644
--- a/scripts/stateless-replicas-drill/accounting_test.go
+++ b/scripts/stateless-replicas-drill/accounting_test.go
@@ -292,6 +292,51 @@ func TestReplicaDrillHubMinutes(t *testing.T) {
}
}
+// TestReplicaDrillCleanStart is drill 3's H2 tool half: the operator's
+// 1/s probe ran until 13:02:37 and the drill started at 13:02:49, in the
+// same minute, so the hub's 13:02 count held 36 2xx the client never sent
+// and the totals were 36 over (with 5 websocket dials, filed by the hub as
+// 2xx, the other 5 of 41). Started at cleanStart, the drill's first minute
+// is a fresh one: the operator's minute is outside every minute a response
+// of the drill can have been filed in, and the counts reconcile exactly.
+func TestReplicaDrillCleanStart(t *testing.T) {
+ stopped := time.Date(2026, 11, 12, 13, 2, 37, 500_000_000, time.UTC)
+ if got, want := cleanStart(stopped), time.Date(2026, 11, 12, 13, 3, 2, 0, time.UTC); !got.Equal(want) {
+ t.Fatalf("cleanStart(%s) = %s, want %s", stopped, got, want)
+ }
+ if got := cleanStart(time.Date(2026, 11, 12, 13, 2, 59, 999_000_000, time.UTC)); !got.Equal(time.Date(2026, 11, 12, 13, 3, 2, 0, time.UTC)) {
+ t.Fatalf("a start just before a minute's end: %s", got)
+ }
+ measured := map[string]bool{phaseSpread: true}
+ operatorMinute := minuteOf(stopped)
+ drill := func(from time.Time) []sample {
+ var s []sample
+ for i := 0; i < 180; i++ {
+ at := from.Add(time.Duration(i) * time.Second)
+ s = append(s, sample{ID: sampleID(phaseSpread, i), Phase: phaseSpread, At: at, Done: at.Add(300 * time.Millisecond),
+ Status: 200, Started: true, Complete: true, Box: []string{"a", "b"}[i%2], Build: "v1"})
+ }
+ return s
+ }
+ withProbe := func(s []sample) map[time.Time]hubMinute {
+ hub := hubCounts(s)
+ h := hub[operatorMinute]
+ h.Minute = operatorMinute
+ h.S2xx += 36
+ hub[operatorMinute] = h
+ return hub
+ }
+ same := drill(time.Date(2026, 11, 12, 13, 2, 49, 0, time.UTC))
+ if p := judgeEvidence(same, withProbe(same), nil, measured, nil); len(p) == 0 {
+ t.Fatal("a drill sharing its first minute with the operator's probe reconciled")
+ }
+ clean := drill(cleanStart(stopped))
+ // TestReplicaDrillCleanStart
+ if p := judgeEvidence(clean, withProbe(clean), nil, measured, nil); len(p) != 0 {
+ t.Fatalf("a drill started on a fresh minute did not reconcile: %v", p)
+ }
+}
+
// TestReplicaDrillParseHubMinutes: the counts are read from carlos logs'
// own lines; a record missing a count, a minute twice or a cut listing is
// an error, never fewer minutes.
diff --git a/scripts/stateless-replicas-drill/evidence.go b/scripts/stateless-replicas-drill/evidence.go
index 2abf35543..359be8214 100644
--- a/scripts/stateless-replicas-drill/evidence.go
+++ b/scripts/stateless-replicas-drill/evidence.go
@@ -20,7 +20,10 @@ import (
//
// The counts are per app, not per host: the drill's fixture app holds only
// the drill host, so any other traffic to it makes the hub's counts larger
-// than the client's, and the drill fails.
+// than the client's, and the drill fails. The drill starts on a fresh
+// minute (cleanStart), so traffic stopped before it started is in an
+// earlier minute. A websocket dial is filed when its socket ends, as its
+// 101, which no status class counts.
// clockSkew is how far apart the operator's clock (the client's Done
// times) and the hub's or a box's clock may be when the drill compares
@@ -102,6 +105,13 @@ func parseHubMinutes(out string) (map[time.Time]hubMinute, error) {
// minuteOf is the UTC minute t falls in.
func minuteOf(t time.Time) time.Time { return t.UTC().Truncate(time.Minute) }
+// cleanStart is when a drill started at now sends its first request: the
+// next minute's start plus clockSkew, so every minute a response can be
+// filed in (judgeEvidence) begins after now, when the operator has stopped
+// every other request to the host. A first request sent at or after it
+// finishes after it too, and its minute less clockSkew is that minute.
+func cleanStart(now time.Time) time.Time { return minuteOf(now).Add(time.Minute + clockSkew) }
+
// nearEdge is whether t is within clockSkew of the start or the end of
// its own minute.
func nearEdge(t time.Time) bool {
diff --git a/scripts/stateless-replicas-drill/main.go b/scripts/stateless-replicas-drill/main.go
index 7123dca48..0bfb85f5e 100644
--- a/scripts/stateless-replicas-drill/main.go
+++ b/scripts/stateless-replicas-drill/main.go
@@ -256,6 +256,21 @@ func (d *drill) run(ctx context.Context, report *drillReport) error {
report.Tip = tip
d.note("drill start: boxes run %s; %+v", tip, cfg)
+ // The drill's first minute must hold only its own requests: the hub's
+ // counts are per app and minute, and judgeEvidence's totals take every
+ // minute a response can have been filed in, the first one whole (drill
+ // 3's 36 extra 2xx were the operator's own probe, stopped 12 s before
+ // the drill started in the same minute). Every other request to the
+ // host must stop before the drill starts; the first one waits for a
+ // fresh minute (cleanStart).
+ start := cleanStart(time.Now())
+ d.note("waiting until %s to start, so the hub's first minute for the drill holds no request sent before it", start.Format(time.RFC3339))
+ select {
+ case <-ctx.Done():
+ return ctx.Err()
+ case <-time.After(time.Until(start)):
+ }
+
// Readiness: probe traffic until both boxes have answered, never
// measured.
if err := d.ready(ctx); err != nil {