host: pin that store op latency accumulates per op and diffs
The counting test allowed every recorded duration to stay zero, so a storeCounter that dropped latency would pass. storeCounter.record now goes through add(op, d); the new test feeds add known durations and checks the exact per-op sums, the diff and its rendering, and checks record measures from a start already two seconds past, touching only its own op. No sleeps.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
internal/host/startuptiming.go+5 −2internal/host/startuptiming_test.go+40 −0
CI failed — run details
Intent
<task-notification> <task-id>afd7eeb021ac44e3f</task-id> <tool-use-id>toolu_01Kup5hbokJJ3zfBBwUCs3gi</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/68be7e6f-7841-4936-9fa0-2041da778685/tasks/afd7eeb021ac44e3f.output</output-file> <status>completed</status> <summary>Agent "Implement Task 1: startup timing" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>Status: DONE_WITH_CONCERNS Commit: 4d6a2b2b host: time each startup step up to the end of the first full pass Tests: 5 new tests pass (counting and diffs, interface shape, extension counts, exact log lines on a fake clock, first-pass-only). 49 existing fastTick/changeindex/moves tests and the provision Reconcile tests also pass. `go vet`, the linux/darwin/windows builds and `gofmt` are clean. Concerns: - **Name:** `countingStore` was already a test helper in package host, so the wrapper is `opCountingStore`. - **Counting is partial:** the wrapper counts only stores whose optional interfaces match exactly: a plain store, the fleet door, or a DirStore. The S3 and prefix stores are not wrapped, so platform boxes get times but no op counts. Steps that open their own store also get times only. - **"at" offset:** "at +X" is when the step ended, so the lines read as a timeline (start = at minus took). - **Likely cause of the 9.4 s:** the code before `go fastConvergeLoop` first waits for the activator's startup to finish. On a fleet box with claims off, that wait sits between "tunnel connected" and the loop starting. This is a guess until a dev run; the new "duties: wait for the activator startup" line will show it. Report: /home/paulca/amadan.net/carlos/platform/.claude/worktrees/fleet-first-reconcile-speed/.superpowers/sdd/2026-11-15-fleet-first-reconcile/task-1-report.md</result> <usage><subagent_tokens>213350</subagent_tokens><tool_uses>79</tool_uses><duration_ms>977074</duration_ms></usage> </task-notification>
<paseo-system version="1" kind="agent-message" source-agent-id="8a3d302a-eac7-407c-b61c-f5ccc66b5544" message-id="738adc9a-7d3a-45e6-937b-0ded4dfcb768"> Agent manager 8a3d302: no candidate build on dev boxes (a non-release build trips the version floors on r10r and adds risk). Instead: merge the instrumentation on its own as soon as it's reviewed (log-only), so it rides the next release; every dev and flagship fleet box restart in that roll then gives real numbers for free. Meanwhile fix what the local numbers show (the activator startup latch is a good first suspect), and confirm against the real numbers after the roll. </paseo-system>
<task-notification> <task-id>bkpcol1ey</task-id> <tool-use-id>toolu_017hEmezFDcUukt3isSEfE7B</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/68be7e6f-7841-4936-9fa0-2041da778685/tasks/bkpcol1ey.output</output-file> <status>completed</status> <summary>Background command "W=/home/paulca/amadan.net/carlos/platform/.claude/worktrees/fleet-first-reconcile-speed/.superpowers/sdd/2026-11-15-fleet-first-reconcile; $W/astra-review.sh $W/task-1-review-prompt.md $W/task-1-review-astra.md; tail -5 $W/task-1-review-astra.md.log; wc -l $W/task-1-review-astra.md" completed (exit code 0)</summary> </task-notification>
Attributed to this commit: 27.1 g CO₂e (3,058,965 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on fleet-first-reconcile-speed, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/internal/host/startuptiming.go b/internal/host/startuptiming.go| index 88bb34a50..5004ed6d6 100644 |
| --- a/internal/host/startuptiming.go |
| +++ b/internal/host/startuptiming.go |
| @@ -98,9 +98,12 @@ type storeCounter struct { |
| t [numStoreOps]atomic.Int64 // nanoseconds |
| } |
| -func (c *storeCounter) record(op storeOp, start time.Time) { |
| +func (c *storeCounter) record(op storeOp, start time.Time) { c.add(op, time.Since(start)) } |
| + |
| +// add counts one op of op that took d. |
| +func (c *storeCounter) add(op storeOp, d time.Duration) { |
| c.n[op].Add(1) |
| - c.t[op].Add(int64(time.Since(start))) |
| + c.t[op].Add(int64(d)) |
| } |
| func (c *storeCounter) snapshot() storeOps { |
diff --git a/internal/host/startuptiming_test.go b/internal/host/startuptiming_test.go| index 37f7f1ce5..d33c852de 100644 |
| --- a/internal/host/startuptiming_test.go |
| +++ b/internal/host/startuptiming_test.go |
| @@ -105,6 +105,46 @@ func TestCountingStoreCountsAndDiffs(t *testing.T) { |
| } |
| } |
| +// Durations accumulate per op, and a diff subtracts them: exact sums |
| +// through add, and record's own measurement from a start already past. |
| +func TestStoreCounterAccumulatesLatency(t *testing.T) { |
| + t.Parallel() |
| + c := &storeCounter{} |
| + c.add(opGet, 40*time.Millisecond) |
| + c.add(opList, 7*time.Millisecond) |
| + before := c.snapshot() |
| + c.add(opGet, 60*time.Millisecond) |
| + c.add(opGet, 100*time.Millisecond) |
| + c.add(opDirs, 5*time.Millisecond) |
| + all := c.snapshot() |
| + wantAll := [numStoreOps]time.Duration{opGet: 200 * time.Millisecond, opList: 7 * time.Millisecond, opDirs: 5 * time.Millisecond} |
| + if all.t != wantAll { |
| + t.Fatalf("totals %v, want %v", all.t, wantAll) |
| + } |
| + d := all.minus(before) |
| + wantDiff := [numStoreOps]time.Duration{opGet: 160 * time.Millisecond, opDirs: 5 * time.Millisecond} |
| + if d.t != wantDiff || d.n != [numStoreOps]int64{opGet: 2, opDirs: 1} { |
| + t.Fatalf("diff %v %v, want %v", d.n, d.t, wantDiff) |
| + } |
| + if got := d.String(); got != "get 2/160ms, dirs 1/5ms" { |
| + t.Fatalf("diff renders %q", got) |
| + } |
| + |
| + // record measures from start: a start two seconds past adds at least |
| + // two seconds, to the op it names only. |
| + r := &storeCounter{} |
| + r.record(opPut, time.Now().Add(-2*time.Second)) |
| + got := r.snapshot() |
| + if got.n[opPut] != 1 || got.t[opPut] < 2*time.Second || got.t[opPut] > time.Minute { |
| + t.Fatalf("record: put %d/%s", got.n[opPut], got.t[opPut]) |
| + } |
| + for op := range got.t { |
| + if storeOp(op) != opPut && (got.n[op] != 0 || got.t[op] != 0) { |
| + t.Fatalf("record touched %s: %d/%s", storeOpNames[op], got.n[op], got.t[op]) |
| + } |
| + } |
| +} |
| + |
| // A wrapper answers every optional-interface assertion as the store it |
| // wraps does, and a store no shape matches is left alone. |
| func TestCountingStoreKeepsTheStoreShape(t *testing.T) { |