Repository navigation
Proxyabl dev #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Proxyabl dev #8
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3c707a5
proxyabl: extract core, tighten SSRF & rate-limiting
davidcrowe 15ac410
refactor: align identifiabl + proxyabl with GatewayContext architectu…
davidcrowe 124d315
Refactor naming to identifiabl/proxyabl core+wrapper pattern; finaliz…
davidcrowe 4ee38c2
Add proxyabl + identifiabl integration and test harness
davidcrowe 0a13fc2
proxyabl: add /tools rate limiting and harden SSRF/regex handling
davidcrowe 74ef4fd
proxyabl: mark safe proxy fetch and remove regex in issuer helper
davidcrowe 87d81b7
proxyabl: enforce upstream host/protocol match to satisfy SSRF checks
davidcrowe e98e315
proxyabl: mark hardened proxy fetch as safe for CodeQL SSRF rule
davidcrowe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,3 +61,4 @@ packages/**/src/*.d.ts | |
| packages/**/src/*.d.ts.map | ||
|
|
||
| tsconfig.tsbuildinfo | ||
| *.tsbuildinfo | ||
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| ## error handling | ||
|
|
||
| gatewaystack modules use a **fail-safe strategy** based on the security/availability tradeoff: | ||
|
|
||
| | module | on failure | reason | | ||
| |--------|-----------|--------| | ||
| | **identifiabl** | deny (fail closed) | no anonymous requests allowed | | ||
| | **transformabl** | continue (fail open) | allow untransformed content with warning | | ||
| | **validatabl** | deny (fail closed) | safety first — block when policy engine fails | | ||
| | **limitabl (pre-flight)** | continue (fail open) | favor availability over limit enforcement | | ||
| | **proxyabl** | fallback → error | try alternative providers, then return error | | ||
| | **limitabl (accounting)** | log error | accounting failure shouldn't block response delivery | | ||
| | **explicabl** | log error | audit failure logged but doesn't block request | | ||
|
|
||
| **circuit breakers**: modules that make external calls (jwks validation, policy stores, redis) implement circuit breakers with configurable thresholds. | ||
|
|
||
| **degraded mode**: when upstream dependencies fail, gatewaystack can operate in degraded mode with reduced governance guarantees (configurable per environment). | ||
|
|
||
| ## inputs | ||
|
|
||
| - oidc tokens / apps sdk identity tokens | ||
| - user context (user_id, org_id, roles, scopes) | ||
| - model request (messages, params, attachments) | ||
| - configured policies | ||
| - routing rules | ||
| - quota & budget settings | ||
|
|
||
| ## outputs | ||
|
|
||
| - authenticated, user-bound requests | ||
| - policy decisions (allow, deny, modify) | ||
| - routing decisions (provider/model/tool) | ||
| - enforced limits (rate, cost, budgets) | ||
| - full audit logs and runtime metadata | ||
|
|
||
| ## shared requestcontext | ||
|
|
||
| all modules operate on a shared `RequestContext` object that flows through the pipeline. this context carries identity, content, metadata, and decisions from each module. | ||
|
|
||
| > 📘 **full type definitions and integration examples**: see [`docs/reference/interfaces.md`](https://github.com/davidcrowe/gatewaystack/blob/main/docs/reference/interfaces.md) in the repo | ||
|
|
||
| **core types** (simplified view): | ||
| ```ts | ||
| // shared across modules | ||
| export type Identity = { | ||
| user_id: string; | ||
| org_id?: string; | ||
| tenant?: string; | ||
| roles: string[]; | ||
| scopes: string[]; | ||
| }; | ||
|
|
||
| export type ContentMetadata = { | ||
| contains_pii?: boolean; | ||
| classification?: string[]; // ["sensitive", "financial"] | ||
| risk_score?: number; // 0–1 | ||
| topics?: string[]; | ||
| // extensible bag | ||
| [key: string]: unknown; | ||
| }; | ||
|
|
||
| export type ModelRequest = { | ||
| model: string; // "gpt-4", "smart-model" | ||
| tools?: string[]; | ||
| max_tokens?: number; | ||
| messages: any[]; | ||
| attachments?: any[]; | ||
| }; | ||
|
|
||
| export type PolicyDecision = { | ||
| effect: 'allow' | 'deny' | 'modify'; | ||
| reasons: string[]; | ||
| modifications?: Partial<ModelRequest>; | ||
| }; | ||
|
|
||
| export type LimitsDecision = { | ||
| effect: 'ok' | 'throttle' | 'deny' | 'fallback' | 'degrade'; | ||
| reasons: string[]; | ||
| constraints?: { | ||
| max_tokens?: number; | ||
| max_cost?: number; | ||
| }; | ||
| }; | ||
|
|
||
| export type RoutingDecision = { | ||
| provider: string; // "openai", "azure-openai" | ||
| model: string; // concrete provider model | ||
| region?: string; | ||
| alias?: string; // "smart-model" | ||
| }; | ||
|
|
||
| export type UsageRecord = { | ||
| input_tokens: number; | ||
| output_tokens: number; | ||
| total_cost: number; | ||
| latency_ms: number; | ||
| }; | ||
|
|
||
| export type RequestContext = { | ||
| request_id: string; | ||
| trace_id?: string; | ||
|
|
||
| identity?: Identity; | ||
| content?: { | ||
| messages: any[]; | ||
| attachments?: any[]; | ||
| }; | ||
| metadata?: ContentMetadata; | ||
| modelRequest: ModelRequest; | ||
|
|
||
| policyDecision?: PolicyDecision; | ||
| limitsDecision?: LimitsDecision; | ||
| routingDecision?: RoutingDecision; | ||
| usage?: UsageRecord; | ||
|
|
||
| // arbitrary module extensions | ||
| [key: string]: unknown; | ||
| }; | ||
| ``` | ||
|
|
||
| ## module boundaries | ||
|
|
||
| **identifiabl** | ||
| - **input**: `RequestContext` with `modelRequest` + http auth header | ||
| - **reads**: authorization header, jwks endpoint | ||
| - **writes**: `identity`, `trace_id`, identity headers (`x-user-id`, `x-org-id`, etc.) | ||
|
|
||
| **transformabl** | ||
| - **input**: `RequestContext` with `identity`, `content` | ||
| - **reads**: `content` (messages, attachments) | ||
| - **writes**: `metadata` (pii flags, classification, risk score), redacted `content`, transformation logs | ||
|
|
||
| **validatabl** | ||
| - **input**: `identity`, `content`, `metadata`, `modelRequest` | ||
| - **reads**: all above + policy definitions | ||
| - **writes**: `policyDecision` (allow/deny/modify + reasons) | ||
|
|
||
| **limitabl** (two-phase) | ||
| - **pre-flight phase**: | ||
| - **reads**: `identity`, `modelRequest`, `policyDecision` | ||
| - **writes**: `limitsDecision` (constraints, budget availability) | ||
| - **accounting phase**: | ||
| - **reads**: provider response (tokens, cost) | ||
| - **writes**: `usage`, updates quota/budget stores, emits usage events | ||
|
|
||
| **proxyabl** | ||
| - **input**: `modelRequest`, `identity`, `metadata`, `policyDecision`, `limitsDecision` | ||
| - **reads**: routing rules, provider configurations, secrets | ||
| - **writes**: `routingDecision`, normalized provider response | ||
|
|
||
| **explicabl** | ||
| - **input**: full `RequestContext` + events from all modules | ||
| - **reads**: everything (for audit trail construction) | ||
| - **writes**: external logs and traces only (no modification of request context) |
Empty file.
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
Empty file.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.