Repository navigation
test(api): fix 1-in-256 name-collision flake in TestAPoolWorkerIsVisibleWhereAgentsAreListed - #398
Merged
Merged
Conversation
…256 flake) TestAPoolWorkerIsVisibleWhereAgentsAreListed failed once in CI (PR #387, run 41274534531 attempt 1): "/agents/spry-newt carries 1 pool chips, want 0". Root cause is the fixture, not production: preflightStore.NameExists returned false unconditionally, so BuildUniqueAgentName never redrew. The name pool is 16 adjectives x 16 nouns = 256, so the test's two dispatches shared a name about once per 256 runs, and pageablePreflight.GetByName then resolved the pool-less control's page to the first (pooled) row. PGStore.NameExists consults live rows, so production redraws; the fixture now does the same. Matrix (go test ./internal/api -run '^TestAPoolWorkerIsVisibleWhereAgentsAreListed$'): - natural rate, origin/main, -count=3000: 9 FAIL / 2991 PASS - natural rate, HEAD, -count=3000: 0 FAIL / 3000 PASS - forced collision (generateName pinned to one name, uncommitted), old fixture -count=200: 200 FAIL; new fixture -count=200: 0 FAIL - HEAD, -race -cpu 1,4 -count=500: 1000 PASS / 0 FAIL Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Owner
Author
|
Audit ladder: round 0 = proceed (0 deletion candidates); round 1 = no 🔴/🟡, one 🟢 (comment wording) fixed in 1fdc696 without re-audit. Red/green independently reproduced: base 5/1500 and 8/2000 FAIL, HEAD 0/1500 and 0/2000; forced collision 50/50 FAIL at base, 0/50 at HEAD. |
ZacxDev
marked this pull request as ready for review
November 2, 2026 05:35
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.
Flake
TestAPoolWorkerIsVisibleWhereAgentsAreListedfailed once in CI on #387 (run 41274534531, attempt 1, job "test (postgres)"):Root cause (test fixture, not production)
internal/api/kickoff_preflight_test.go:123(origin/main):preflightStore.NameExistsreturnedfalseunconditionally, soagents.BuildUniqueAgentName(internal/agents/names.go:207) never redrew. The pool is 16 adjectives x 16 nouns = 256 names, so the test's two dispatches drew the same name about once in 256 runs.pageablePreflight.GetByName(worker_pool_form_test.go) returns the first row with that name, so the pool-less control's page (plain, line 54) rendered the pooled agent with its chip, and the assertion at line 62 failed.Production is fine:
PGStore.NameExistschecks live rows plus the retired-names ledger, so a real deployment redraws.Fix
preflightStore.NameExistsnow answers from the rows the fixture has created, the wayPGStoredoes. No retry, no sleep.nameExistsNeverinofficers_test.gostays as it is on purpose: it samples the generator and creates no rows.Evidence
go test ./internal/api -run '^TestAPoolWorkerIsVisibleWhereAgentsAreListed$', with counts taken from--- PASS/--- FAILlines:-count=3000-count=3000generateNamepinned to one name (uncommitted)-count=200-count=200-race -cpu 1,4 -count=500The natural rate of 9/3000 matches the expected 3000/256 ≈ 11.7.
Full suite, run as CI does (
go test -race -cover -timeout 20m -json ./...piped totests/verdict.pywith the three--requires, against a local Postgres 17):internal/apiok, 0 skipped, 3/3 required tests passed.go vet ./...is clean. My local run also showed failures ininternal/connectorsandinternal/db. Both come from the local environment, and this diff doesn't touch either package (it changes oneinternal/api_test.gofile):connectors(a wrong password connected): my pg_hba first usedtrust. With scram it passes.db:DROP DATABASE … WITH (FORCE)hit statement timeouts under full parallel-raceload. The same tests pass when run alone.🤖 Generated with Claude Code