Initial public release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5.8 KiB
Native gateway and commerce: short operator brief
Status: shipped runtime is Python. gateway/grok-web-skin.py plus the
gateway_* modules below are the runtime that this tree ships and tests. A Go
native gateway is not included and is not the default — nothing here requires
a Go toolchain, and no Go build is part of CI.
This page documents operational behaviour, not internals. Authoritative behaviour
is the code in gateway/ and the root tests/ suite.
Modules
| Module | Role |
|---|---|
gateway/gateway_errors.py |
upstream error classification (existing behaviour) |
gateway/gateway_features.py |
per-request feature gating for the skin/proxy |
gateway/gateway_policy.py |
policy decisions (limits, pinning, header exposure) |
gateway/gateway_usage.py |
usage accounting shared by HTTP and key paths |
gateway/gateway_providers.py |
provider registry (pinning, ownership, rpm bounds) |
gateway/gateway_provider_relay.py |
relay of a request to a pinned provider |
gateway/gateway_commerce.py |
money routes (wallet/paid offers), disabled by default |
gateway/commerce_access.py |
access rules for money/board routes |
gateway/community_board.py |
community board: authenticated /api/activities (no kill-switch flag) |
bot/account_balances.py |
exact read-only balance aggregation shared by HTTP and the key daemon |
Adaptive RPM
Rate limiting is bounded and process-local: the limiter keeps its state in the gateway process only (no shared store, no cross-process guarantees). Each account has one canonical owner record, so two operators cannot claim the same upstream account. Restarting the process resets limiter state — this is intentional and not a data loss signal.
Daily usage headers
Daily usage is exposed as X-Iishko-Daily* response headers only. It is never
injected into JSON bodies and never into SSE streams, so clients that parse model
output are unaffected.
Provider pinning
Pinning is opt-in and registry-driven:
export IISHKO_PROVIDERS_FILE=gateway/providers.example.json
- The registry file is operator-owned configuration;
gateway/providers.example.jsonis a shape example with placeholders only — no credentials, no real endpoints, no upstream channel data. - Schema (validated by
ProviderRegistryingateway/gateway_providers.py): top levelpinning_enabled(bool, defaultfalse) andproviders(list, ≤128). Per provider:id([a-z][a-z0-9_-]{0,47}, unique),name(1–80 chars),channel_ids(ints ≥1, unique, ≤512, never shared between providers),priority(int −10000…10000, default 0),reserve(bool, defaultfalse),max_inflight(1…4096, default 32),models(map model → capability). Capability:effort_levels(list of short strings or null) andverificationwithstatus∈unverified | identity_checked | operator_verified,method∈none | response_model | tool_roundtrip | official_route | signed_attestation; any status other thanunverifiedrequireschecked_at(positive int) and a non-emptyreference(≤200 chars).response_modelsupports onlyidentity_checked, neveroperator_verified. The latter requirestool_roundtrip,official_route, orsigned_attestation;tool_roundtripmay also carry the weakeridentity_checkedstatus.unverifiedrequires methodnoneand no timestamp/reference. Unknown evidence fields and inconsistent pairs are rejected. The registry retains the raw reference privately; the public catalogue exposes only status/method/timestamp. These labels describe operator-provided evidence, not cryptographic proof of model weights or an automatically performed check. - Selection order is
(reserve, -priority, id); a route is reportedavailableonly when it has channels, no cooldown/busy state andpinning_enabledis true. - Editing/using the registry requires a New API admin (owner role) account: the gateway refuses pinning for non-owner credentials.
- With no registry file configured, pinning stays off and routing behaves as before (external New API decides).
- Route health accounts for the response produced by the success handler, not just the upstream HTTP status: upstream 200 → downstream 503 is one failure. No fallback occurs after the success handler starts; client cancellation releases capacity without claiming a healthy route. An incomplete 2xx stream is detectable here only if the handler raises; circuit state is process-local.
Money and board routes
Commerce has no enable flags. The switches that exist are configuration values:
| Control | Where | Effect when empty |
|---|---|---|
commerce_offers |
bot/config.json |
purchases disabled; there are no default prices in code |
cryptopay_token |
bot/config.json |
payment create/verify unavailable |
CRYPTOPAY_TOKEN |
environment | overrides the config value when set |
IISHKO_ADMIN_IDS |
environment | empty env-admin list; the trusted users.admin column still applies |
IISHKO_APP_ROOT |
environment | module root; default bot source is $IISHKO_APP_ROOT/grok_bot.py |
IISHKO_BOT_SOURCE |
environment (optional) | explicit override of the bot source file |
community_board and account_balances have no disable switch: board routes are
served and access is limited by auth/ban/admin gates. Empty offers disable purchases
only — reading an existing wallet and grants keeps working.
Pricing and offer contents are operator configuration; nothing is invented here.
Environment
See .env.example: IISHKO_APP_ROOT, IISHKO_UPSTREAM, IISHKO_GATEWAY_HOST,
IISHKO_GATEWAY_PORT, IISHKO_BOT_DB (aliases GATE_BOT_DB, GATE_NEWAPI_DB),
IISHKO_PROVIDERS_FILE. All defaults are loopback.