Repository navigation
test: raise coverage to 99% statements, 95% branches - #14
Merged
Merged
Conversation
Adds suites for the provider layer and the Upstash adapter, which had 2% and 0% coverage, and fills the untested branches in the runner, registry, spec and adapters. The Upstash tests execute the adapter's Lua in a wasm VM rather than asserting that eval() was called, so the limit arithmetic, stale reservation sweep and idempotent settle are covered for real. Coverage thresholds now gate CI. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011cCpyfDUJKeTDJAmxFwYSp
Contributor
API Changes Report
Summary
No API Changes DetectedAll packages have stable APIs with no detected changes. Report generated by Break Check Last ran on |
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.
The provider layer was at 2% coverage and the Upstash adapter at 0%, which together were most of the gap. This adds suites for both plus the missing branches elsewhere, taking the repo from 72.5% to 99.25% statements and 55.4% to 94.8% branches. Thresholds now gate CI.
The Upstash tests are the part worth a look. All the real logic in that adapter lives in three Lua scripts, so a fake that recorded
eval()calls would have asserted nothing.src/__fixtures__/fake-redis.tsbridgesredis.callinto a Map-backed store and runs the scripts in a Lua VM (wasmoon), which is what makes the limit arithmetic, the stale-reservation sweep and the idempotent settle actually covered. One gotcha is documented in the fixture: returningnullfrom the JS side crashes wasmoon's value bridge, so a missing GET returnsundefinedand Lua sees nil.I checked the tests are worth having by mutating the source 36 times and confirming each one goes red. Two survived the first pass and both were my fault, not the code's: the fallback-eligibility test couldn't distinguish
mayFallback = truebecause the second attempt failed at reservation anyway, and the budget idempotency test settled the full reserved amount, where a double-applied settle cancels out exactly. Both are fixed to discriminate.Branch coverage stops at 94.8% because the remaining five branches are unreachable. Two of them are dead rather than merely defensive: the
throw toAiError(lastError)after the attempt loop inrun-task.tscan never run, since the last iteration always throws from the catch, andtoAiError'sProviderOutputErrorarm is unreachable becausegenerateWithRepairalways converts one first. Left alone, noted beside the thresholds.Three things surfaced that I filed rather than fixed here, since none are test changes. DD-2541 is a real one: when the paid repair pass is denied a budget reservation, the first call's tokens are released instead of settled, so near a ceiling a tenant retries indefinitely on spend the ledger never sees. That contradicts
RunBudget's own docstring. DD-2542 and DD-2543 are smaller.🤖 Generated with Claude Code
https://claude.ai/code/session_011cCpyfDUJKeTDJAmxFwYSp
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.