feat(oracle): proxy oracle routes to the standalone service and add internal identity endpoints - #1726
Closed
chronoai-kaihuei wants to merge 4 commits into
Closed
feat(oracle): proxy oracle routes to the standalone service and add internal identity endpoints#1726chronoai-kaihuei wants to merge 4 commits into
chronoai-kaihuei wants to merge 4 commits into
Conversation
ORACLE_UPSTREAM_URL is either an http(s) base URL or the literal hold. ORACLE_INTERNAL_SECRET is 64 lowercase hex characters and is required whenever the upstream URL is set. Both are validated at startup and documented in docs/ENV.md and .env.example.
OracleUpstreamUnavailable answers 502 when the standalone oracle service cannot be reached. OracleUpstreamHold shares the key and code and answers 503 with Retry-After: 10 while ORACLE_UPSTREAM_URL=hold.
With ORACLE_UPSTREAM_URL set, the /api/v1/oracle consumer nest and the
/api/v1/oracle/worker nest become a streaming reverse proxy
(handlers/oracle_proxy.rs). The delegated and relay token rejections on
the parent nest still run first. The in-process routes move into helper
functions and stay the default when the variable is unset; the
oracle_billing_routes! inventory is unchanged.
With ORACLE_INTERNAL_SECRET set, the private listener mounts
POST /api/v1/internal/oracle/introspect, GET .../principals/{user_id}
and POST .../audit (handlers/internal_oracle.rs). Introspection runs the
real AuthUser extractor over synthetic request parts so every credential
class is classified exactly as a live oracle request would be.
Collaborator
Author
|
Closed: the standalone oracle will not use a NyxID-side proxy cutover. |
📊 Code coverage
Gate: line coverage must stay at or above the threshold. Ratchet plan (W21): Backend → 55%, CLI → 50%, Frontend → 30% by quarter end. |
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.
What
First NyxID-side step of moving the oracle into its own Go service (ChronoAIProject/oracle). Nothing changes unless the new variables are set.
ORACLE_UPSTREAM_URL: when set, the/api/v1/oracle/*consumer nest and the/api/v1/oracle/worker/*nest become a streaming reverse proxy to that URL (headers allow-listed,X-Forwarded-*added, request and response bodies streamed so 16 MiB results and SSE are not buffered). The literal valueholdanswers 503 withRetry-After: 10for the migration window. Unreachable upstream answers 502. The delegated/relay token rejection layers still apply in front of the proxy.ORACLE_INTERNAL_SECRET(64 lowercase hex): enables three endpoints on the internal listener (port 3002), authenticated by a constant-time bearer check,Cache-Control: no-store:POST /api/v1/internal/oracle/introspectruns the realAuthUsercredential path on a synthetic request and returnstoken_class,principal,scope,api_key,membershipsandexp; inactive credentials return 200 withactive: falseand a reason.GET /api/v1/internal/oracle/principals/{user_id}returns user type, liveness and memberships.POST /api/v1/internal/oracle/auditforwards a metadata-only audit event.oracle_upstream_unavailable(11017): 502 for an unreachable upstream, 503 under hold.docs/ENV.md,.env.example,docs/ORACLE_RELAY.mdsection "Standalone oracle service".The in-process oracle routes are untouched and remain the default. The billing route inventory test is unchanged.
How to test
Three tests need MongoDB: set
NYXID_TEST_DATABASE_URLto a writable URI (a replica set is not required). 22 tests pass.Notes for review
state.http_client(10 s connect timeout, no overall timeout) rather than adding a second client.reasonfor inactive credentials is derived from the extractor's error text (expired,inactive_user,revoked, elseinvalid); the Go client only special-casesexpired.docs/protocol/auth.md).