Repository navigation
feat: canned, unbilled responses for omni_sk_test_ keys - #29
Merged
Merged
Conversation
An omni_sk_test_ key's exchange response now carries test_mode (paired omnibioai-auth change), propagated onto request.state.identity. /v1/ literature/answers and /search read it and short-circuit to a deterministic canned response (build_test_answer/build_test_search) -- never a real RAG call, never counted against quota, never billed. Rate limiting still applies (abuse protection the gateway needs regardless of whether a call is real); the concurrency cap and quota reservation are skipped entirely, since a test key never touches the real resources either protects. Closes the last remaining bullet of design audit gap #9. Co-Authored-By: Claude Sonnet 5 <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.
Summary
Paired with omnibioai-auth's live/test key prefix change -- closes the last remaining bullet of design audit gap #9 ("test keys and canned, unbilled responses are absent").
IAMClient.validate_api_keynow propagatestest_modefrom the exchange response;AuthMiddlewarecopies it ontorequest.state.identity(only ever True for an API-key identity)./v1/literature/answersand/v1/literature/searchcheckidentity.test_modeand, when true, return a deterministic canned response (build_test_answer/build_test_searchinliterature_contract.py) in the exact same shape a real call would produce -- empty citations/results rather than fabricated literature data, since a test key's job is exercising a caller's own integration code, not pretending to answer a real question.Test plan
pytest tests/test_v1_literature.py-- 62 passed (56 existing + 6 new: canned answers/search responses, quota bypass, rate limiting still enforced, concurrency slot never touched, idempotency replay)pytest tests/test_api_key_auth.py-- 20 passed (18 existing + 2 new:test_modepropagation throughvalidate_api_key, defaults closed when absent)🤖 Generated with Claude Code