From fb5959553025f987fdad85492237d63fb27c541e Mon Sep 17 00:00:00 2001 From: yetone Date: Thu, 29 Oct 2026 04:43:37 +0800 Subject: [PATCH] usage: TestClearedUsageLeavesThePages leaves no clear behind for the next test The test ends by clearing everything up to now. readCleared keeps what it read in clearedAs, and a test that builds a page straight from chunks (buildRequestBlocksWithCodex) never reads the clears again, so it judged its rows by that stale clear and hid them all: with -run "Heatmap|Pair|Scratch|Request|Page", TestCodexRequestPageDoesNotMutateSharedCompactionChunks (3 subtests), TestCodexRequestPageFoldsCopiesBeforeResponseMatching and TestRequestDiskNamesItsSource failed on origin/main 49d4d0f7a ("page rows = 0"). Bisected to this test as the only polluter. The full package's order happened to put them before it. The test now drops clearedAs when it ends. Run on mote at this head (rebased on a0ba8e1f2): - go test -count=1 -run "Heatmap|Pair|Scratch|Request|Page" ./internal/usage: ok (red without the cleanup, as above) - go test -count=1 -timeout 45m ./internal/usage: ok - go test -count=1 -timeout 45m ./internal/usage: ok --- internal/usage/cleared_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/usage/cleared_test.go b/internal/usage/cleared_test.go index b779f6cd2..d35df08cb 100644 --- a/internal/usage/cleared_test.go +++ b/internal/usage/cleared_test.go @@ -17,6 +17,9 @@ import ( // Visit (key spending limits, window holds) still counts them all. func TestClearedUsageLeavesThePages(t *testing.T) { resetUsageTest(t) + // the clears read last stay read for a test that builds a page without + // reading them again (readCleared) + t.Cleanup(func() { clearedAs.Store(nil) }) now := Clock() at := now.Add(-2 * time.Hour) Append(Record{Time: at, Agent: "codex", Provider: "ollama", Model: "qwen3:32b", Input: 100, Output: 10, Status: 200})