You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Prototype a standalone Rogue Gateway feasibility spike focused on tokenomics-efficient routing, context compression, cache-aware processing, and substrate reuse.
The existing context/MCP spike is strong on context compression and ctx:// lookup, but not enough yet for the larger product claim. This ticket adds the explicit Substrate + Tokenomics Probe needed to test whether Rogue can be the efficient router/smartifier/cache processor without rebuilding commodity gateway infrastructure.
Problem statement
Rogue Gateway should prove that it can manage model/resource economics wisely while avoiding generic gateway rebuilds.
The spike should answer whether Rogue can sit above or beside existing gateway substrates such as direct OpenAI-compatible upstreams, LiteLLM Proxy, Portkey Gateway, or mocks, while keeping Rogue-specific value in:
route planning,
profile policy,
tokenomics quotes,
context shaping / compression,
premium guardrails,
cache-aware savings attribution,
run explanations,
event-ledger-backed observability.
Coverage target
Area
Target coverage
Model routing
Deterministic route planner with alternatives, not just one static profile target
Stats collection
Event ledger that can reconstruct decisions and savings
Boilerplate management
Explicit substrate comparison against LiteLLM/Portkey-style gateways
Avoid commodity gateway rebuilds
Small substrate adapter boundary; no provider dashboards/retry engines/budget systems in Rogue
Smart model routing
Policy + economics comparison; no smart-model call required for this spike
if profile.privacy == local_only:
choose local_first_typed_lens
if rawInputTokensApprox > threshold and contextPolicy == typed_lens:
forbid premium_raw except eval
if profile == local-first-economy:
choose local unless repeatedFailureHint >= 2
if profile == fast-but-not-crazy:
choose local for broad/debug first pass
choose subscription or cheap remote if latency preference high
choose premium sealed only if repeatedFailureHint >= 2 or taskKind == high_value_review
if profile == premium-surgical:
choose premium sealed
never choose raw premium unless explicit eval flag
Which parts would be duplicated if Rogue built everything from scratch?
Which parts can LiteLLM/Portkey own?
Can Rogue sit in front of a generic OpenAI-compatible substrate?
Does Rogue require substrate-specific code for the tokenomics/context logic?
What minimal substrate interface was enough?
What would be painful to outsource?
Optional manual checks, non-CI-blocking:
Run LiteLLM Proxy locally and point substrate-openai-compatible at it.
Run Portkey Gateway locally and point substrate-openai-compatible at it.
Experiments
Experiment A — Existing Context/MCP feasibility
Preserve the existing context-compression + visible-artifact + ctx:// + MCP companion lookup experiment from the original spike.
Pass criteria:
Bare OpenAI-compatible traffic works.
Visible artifact capture works.
ctx:// handles are emitted/looked up.
MCP companion lookup is demonstrated.
Experiment B — Routing/profile behavior
Question:
Does profile selection change resource usage without harness changes?
Run the same request with:
model = rogue/local
model = rogue/fast
model = rogue/premium-surgical
Expected:
rogue/local:
selected local.qwen35
rogue/fast:
selected local or cheap/subscription depending fake latency/cost config
rogue/premium-surgical:
selected premium_sealed_packet, not raw premium
Pass criteria:
Same input produces different route plans.
Route explanation is readable.
Premium raw context remains forbidden by default.
Experiment C — Tokenomics accounting
Question:
Can Rogue explain money/resource savings in a way a user cares about?
For a large-log request, report:
raw input tokens
forwarded tokens
tokens avoided
selected route cost
premium sealed cost
premium raw cost
cache-read estimate if configured
local opportunity time estimate
subscription shadow cost if configured
Pass criteria:
Report shows selected route and at least 3 baselines:
local selected,
cheap remote,
premium sealed,
premium raw/oracle.
Report includes explicit savings:
context lens saved X tokens,
selected-vs-premium saved $Y,
premium sealed-vs-raw saved $Z.
Experiment D — Boilerplate avoidance
Question:
Can Rogue avoid implementing commodity gateway functionality?
Run or simulate:
Rogue -> direct mock substrate
Rogue -> direct OpenAI-compatible substrate
Optional: Rogue -> LiteLLM/Portkey substrate
Pass criteria:
Rogue route/economics/context logic is substrate-agnostic.
Provider-specific retries/budgets/dashboards are not implemented in Rogue.
Code has explicit TODO/adapter path for LiteLLM/Portkey.
Acceptance criteria
/rogue/economics/quote works without a model call.
Quote includes selected route, alternatives, raw-premium baseline, and explicit savings attribution.
Route planner changes behavior based on selected Rogue profile.
Run report includes selected cost, raw-premium baseline cost, premium-sealed baseline cost, and savings.
Event ledger records request/profile/artifact/economics/route/upstream/response events.
Demo run produces at least 6 event types.
Events can reconstruct why the route happened.
Events can compute a savings report.
Substrate interface exists.
At least mock + OpenAI-compatible substrate implementations work.
Commodity substrate report explains what Rogue should not build from scratch.
Demo report clearly answers whether tokenomics/economics is the main value or merely a side metric.
Existing context/MCP proof still works: OpenAI-compatible traffic, visible artifact capture, ctx:// handles, and MCP companion lookup.
Final report questions
The spike report should answer:
Did route profiles produce meaningfully different plans?
Was tokenomics visible enough to make a resource decision before spending?
How much would raw premium have cost versus selected route?
How much did context lensing save separately from model routing?
Which gateway boilerplate should be delegated to LiteLLM/Portkey?
Which Rogue-specific logic cannot be delegated?
Was the substrate adapter boundary clean?
What is the next smallest experiment to prove wise resource use on a real local model?
Did the Context/MCP side remain useful after adding tokenomics routing?
Is the “Economics API is king” framing supported by demo evidence?
Killer demo target
The demo should produce a report like:
Raw premium baseline:
82k input tokens, estimated $0.437
Premium sealed packet:
2.4k input tokens, estimated $0.039
Selected local-first route:
$0 metered cost, ~77s estimated local time
Savings:
context lens avoided ~79.6k tokens
premium sealed saved ~$0.398 vs raw premium
local-first saved ~$0.039 vs premium sealed
raw full context to premium was blocked by profile guard
Explicit non-goals
Do not build provider dashboards.
Do not build virtual-key systems.
Do not build generic provider retry/fallback engines beyond minimal adapter behavior needed for the spike.
Do not add LiteLLM or Portkey as hard dependencies.
Do not make production cost claims from fake/manual numbers.
Do not choose raw premium full-context routing unless an explicit eval flag enables the oracle baseline.
Notes / references
LiteLLM already covers commodity proxy concerns such as OpenAI-compatible gatewaying, virtual keys, budgets, spend/cost tracking, and hooks: https://docs.litellm.ai/docs/
Summary
Prototype a standalone Rogue Gateway feasibility spike focused on tokenomics-efficient routing, context compression, cache-aware processing, and substrate reuse.
The existing context/MCP spike is strong on context compression and
ctx://lookup, but not enough yet for the larger product claim. This ticket adds the explicit Substrate + Tokenomics Probe needed to test whether Rogue can be the efficient router/smartifier/cache processor without rebuilding commodity gateway infrastructure.Problem statement
Rogue Gateway should prove that it can manage model/resource economics wisely while avoiding generic gateway rebuilds.
The spike should answer whether Rogue can sit above or beside existing gateway substrates such as direct OpenAI-compatible upstreams, LiteLLM Proxy, Portkey Gateway, or mocks, while keeping Rogue-specific value in:
Coverage target
ctx:/// MCP lookup proofHypothesis
Rogue should not implement generic provider plumbing, dashboards, virtual-key systems, retry engines, or provider cost maps from scratch.
Instead:
Substrate can be:
The spike should prove Rogue remains useful when the boring gateway layer is external.
Deliverables
1. GatewaySubstrate interface
Add a small interface, even if only mock/direct implementations exist first.
Implement at least:
Optional/manual:
Optional adapters can be simple HTTP forwarders. Do not embed LiteLLM/Portkey as hard dependencies.
2. Asset registry with resource classes
Add static asset registry to config.
Asset classes:
Example shape:
{ "assets": { "local.qwen35": { "class": "owned_capacity", "substrate": "openai-compatible.local", "model": "qwen3.6-35b-a3b-q4", "contextWindow": 128000, "observedTps": 31, "inputCostPerMTok": 0, "cachedInputCostPerMTok": 0, "outputCostPerMTok": 0, "privacy": "local", "qualityTier": "mid", "tags": ["coding", "debug", "cheap-broad-scan"] }, "remote.cheap": { "class": "metered_api", "substrate": "mock", "model": "cheap-remote", "contextWindow": 128000, "observedTps": 80, "inputCostPerMTok": 0.2, "cachedInputCostPerMTok": 0.02, "outputCostPerMTok": 1.0, "privacy": "remote", "qualityTier": "cheap" }, "remote.premium": { "class": "metered_api", "substrate": "mock", "model": "premium-frontier", "contextWindow": 256000, "observedTps": 45, "inputCostPerMTok": 5.0, "cachedInputCostPerMTok": 0.5, "outputCostPerMTok": 30.0, "privacy": "remote", "qualityTier": "frontier" }, "subscription.smart": { "class": "subscription_quota", "substrate": "mock", "model": "subscription-smart", "contextWindow": 128000, "observedTps": 60, "quotaRemaining": 20, "quotaResetHours": 8, "privacy": "remote", "qualityTier": "smart" } } }For the spike, numbers can be fake/manual.
3. Tokenomics quote endpoint
Add:
Input:
{ "profile": "fast-but-not-crazy", "taskKind": "coding_debug", "rawInputTokensApprox": 82000, "forwardedInputTokensApprox": 2400, "expectedOutputTokensApprox": 900, "contextPolicy": "typed_lens", "candidateAssets": [ "local.qwen35", "remote.cheap", "remote.premium", "subscription.smart" ] }Output should include:
Representative output:
{ "selected": { "asset": "local.qwen35", "route": "local_first_typed_lens", "estimatedWallTimeMs": 77000, "estimatedMeteredUsd": 0, "estimatedQuotaCost": 0, "estimatedTotalTokenCostUsd": 0, "reason": "broad debugging; local capacity is free and premium is not justified before repeated failure" }, "alternatives": [ { "asset": "remote.cheap", "route": "cheap_remote_typed_lens", "estimatedMeteredUsd": 0.00138, "estimatedWallTimeMs": 30000, "reasonNotChosen": "profile prefers local first" }, { "asset": "remote.premium", "route": "premium_sealed_packet", "estimatedMeteredUsd": 0.039, "estimatedWallTimeMs": 24000, "reasonNotChosen": "premium requires repeated failure or explicit profile" }, { "asset": "remote.premium", "route": "premium_raw_oracle_eval_only", "estimatedMeteredUsd": 0.437, "estimatedWallTimeMs": 60000, "reasonNotChosen": "raw full context to premium is forbidden outside eval" } ], "savings": { "tokensAvoidedByContextLens": 79600, "premiumRawVsPremiumSealedUsdSaved": 0.398, "premiumRawVsSelectedUsdSaved": 0.437, "cacheSavingsEstimatedUsd": 0, "localFirstSavingsEstimatedUsd": 0.039 }, "guards": { "rawFullContextToPremium": false, "maxPremiumInputTokens": 5000, "premiumRequires": [ "same_error_repeated", "user_explicit_quality", "large_diff_review", "architecture_deadlock" ] } }4. Deterministic smart route planner v0
No smart model call in this spike. The “smart” part is explicit policy + economics comparison.
Inputs:
Routes:
Initial rules:
5. Event ledger, not only run ledger
In addition to one run record, append events:
Event types:
Example:
{ "eventId": "evt_...", "runId": "run_...", "type": "economics_quoted", "timestamp": "...", "data": { "selectedAsset": "local.qwen35", "rawPremiumCostUsd": 0.437, "selectedCostUsd": 0, "premiumSealedCostUsd": 0.039, "tokensAvoidedByLens": 79600 } }6. Commodity substrate comparison report
Add an explicit report section:
The report must answer:
Optional manual checks, non-CI-blocking:
substrate-openai-compatibleat it.substrate-openai-compatibleat it.Experiments
Experiment A — Existing Context/MCP feasibility
Preserve the existing context-compression + visible-artifact +
ctx://+ MCP companion lookup experiment from the original spike.Pass criteria:
ctx://handles are emitted/looked up.Experiment B — Routing/profile behavior
Question:
Run the same request with:
Expected:
Pass criteria:
Experiment C — Tokenomics accounting
Question:
For a large-log request, report:
Pass criteria:
Experiment D — Boilerplate avoidance
Question:
Run or simulate:
Pass criteria:
Acceptance criteria
/rogue/economics/quoteworks without a model call.ctx://handles, and MCP companion lookup.Final report questions
The spike report should answer:
Killer demo target
The demo should produce a report like:
Explicit non-goals
Notes / references