fix(test): stop ai-summaries forbidden-word sweep timing out under load - #6874
Merged
Conversation
…er load The "routes every forbidden public term..." test iterates all 33 entries in FORBIDDEN_PUBLIC_COMMENT_WORDS, calling createTestEnv() (via publicEnv()) fresh on every iteration. createTestEnv() constructs a new in-memory SQLite database and replays all migrations/*.sql files (166 of them) on construction -- so the loop was rebuilding a fully-migrated database 33 times over, when the test only needs one: every iteration lands on the "unsafe" branch, and sumAiEstimatedNeuronsSince only sums status "ok" rows, so the shared daily neuron budget never accumulates across words. Hoists the env/mock out of the loop so it's built once; isolated runs drop from ~9s (up to 72s+ under concurrent load, exceeding even the existing 30s override) to under 1s, and a full unsharded npm run test:coverage pass shows no timeout.
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6874 +/- ##
=======================================
Coverage 93.63% 93.63%
=======================================
Files 683 683
Lines 68164 68164
Branches 18706 18706
=======================================
Hits 63828 63828
Misses 3350 3350
Partials 986 986
Flags with carried forward coverage won't be shown. Click here to find out more. |
This was referenced Jul 17, 2026
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.
Summary
test/unit/ai-summaries.test.ts's "routes every forbidden public term through the canonical sanitizer and falls back when AI is unsafe" test iterates all 33 entries inFORBIDDEN_PUBLIC_COMMENT_WORDS, building a freshcreateTestEnv()(viapublicEnv()) on every single iteration.createTestEnv()constructs a new in-memory SQLite database and replays everymigrations/*.sqlfile (166 of them) on construction (test/helpers/d1.ts) -- so the loop was rebuilding a fully-migrated database 33 times over for a test that only needs one shared database.534dad77, alongside two sibling tests with the same symptom), but under sufficiently heavy concurrent load even 30s wasn't enough -- reproduced locally: an isolated run that normally passes in ~9s took 72s+ and failed on both the initial attempt and vitest's automatic retry."unsafe"branch, andsumAiEstimatedNeuronsSinceonly sumsstatus: "ok"rows (src/db/repositories.ts), so the shared daily neuron budget never accumulates across words.npm run test:coveragepass (18,027 tests) shows no timeout on this test.Scope
type(scope): short summaryConventional Commit format.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragelocally -- test-only change totest/**, which Codecov does not measure, so there is no patch-coverage obligation.npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateAdditional validation beyond the standard checklist: ran the fixed test in isolation 3x consecutively (all under 1s, see Summary), ran the full
test/unit/ai-summaries.test.tsfile (all 47 tests pass), and ran a full localnpm run test:cipass -- fully green for this file. That gate run separately surfaced two unrelated, pre-existing flakes intest/unit/miner-attempt-worktree.test.tsandtest/unit/miner-repo-clone.test.ts(same root class: real git subprocess work exceeding the default timeout under load), which are fixed in a separate companion PR rather than folded into this one.Safety
UI Evidencesection below. (Not applicable -- no visible/UI changes.)UI Evidence
Not applicable -- test-only change, no UI/frontend/docs surface touched.
Notes
test/unit/agent-sdk-driver.test.ts, and a same-pattern fix for the#5132miner clone/worktree test suite.