Repository navigation
Disable the retention scheduler in the remaining app-booting test suites - #50
Merged
Merged
Conversation
…ites Every suite that calls `configure(app)` gets a detached `SkillUsageService.prune` at boot, whose per-project DELETEs can lock the shared in-memory SQLite database the suite is writing to. McpToolNamingTests hit this intermittently; these five suites carry the same race. Gating the lifecycle on `.testing` would have fixed all of them at once, but AdminAnalyticsRollupLifecycle documents that schedulers are expected to run under `--env testing` for staging, so this follows the existing per-suite convention instead. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Follow-up to #49, which fixed the same race in
McpToolNamingTests.The race
Every suite that calls
configure(app)registersSkillUsageRetentionLifecycle, whosedidBootAsyncspawns a detached task runningSkillUsageService.pruneimmediately. Its per-projectDELETEs take a write lock on the same shared in-memory SQLite database the suite is writing to, which is the intermittentdatabase is lockedfailure.These five suites boot the app without the guard:
ApiKeyRevocationTests,McpOAuthTests,McpPingRouteTests,SecurityFindingMitigationTests,SkillRuntimeHardeningTests.Why per-suite rather than one gate
Gating the lifecycle on
application.environment == .testingwould have fixed all six suites in one line, and that was my first instinct. ButAdminAnalyticsRollupLifecycleexplicitly documents that its scheduler runs "including Vapor--env testing(staging APIs)" — so.testingis a real deploy target in this codebase, not a test-only marker, and gating on it would change staging behaviour. This follows the existing per-suiteDISABLE_SKILL_USAGE_RETENTION_SCHEDULER=1convention already used bySkillUsageRouteTestsandSkillUsageAnalyticsTests.Two suites take the flag through a caller-supplied
envdictionary, so it is layered on inside the helper rather than threaded through every call site.Verification
Full suite as CI runs it —
swift test --enable-swift-testing --disable-xctest --no-parallel -Xswiftc -warnings-as-errors: 216 tests in 32 suites passed, no warnings.Still outstanding
AdminAnalyticsRollupLifecyclealso refreshes at boot and writes, so it is the same class of race;scripts/ci.shdisables it for CI, but a bare localswift testdoes not. Left alone here to keep this diff to the reported issue.🤖 Generated with Claude Code