Skip to content

broker: response-cost credit mode + per-IP cap; submit io.pilot.orthogonal#71

Merged
Alexgodoroja merged 3 commits into
mainfrom
feat/credit-ip-cap
Jul 6, 2026
Merged

broker: response-cost credit mode + per-IP cap; submit io.pilot.orthogonal#71
Alexgodoroja merged 3 commits into
mainfrom
feat/credit-ip-cap

Conversation

@Alexgodoroja

Copy link
Copy Markdown
Collaborator

Summary

Adds the io.pilot.orthogonal managed app (a metered wrapper over Orthogonal — one key fronting 58 APIs / 851 endpoints) plus the two additive broker features it needs.

Broker change (internal/broker)

Orthogonal is a meta-API: every call goes through POST /v1/run, the per-call price is only known from the response (priceCents), and 104 endpoints are "dynamic" (priced only after the fact). A static cost_credits table can't express that, so the credit block gets two additive knobs (fixed-cost apps like agentphone are unchanged):

  • cost_source: "response" + cost_scale — no up-front debit; a billable path (cost_credits > 0) is refused with 402 only when the caller is already depleted, and after a 2xx the actual cost (CostField × cost_scale, micro-$) is settled against the budget, clamped so the balance floors at zero. Free control-plane paths always pass. Adds Store.Settle (atomic clamp-debit) to MemStore + SQLiteStore.
  • max_identities_per_ip / mint_cooldown_ms on CreditSpec — wires the existing Provision per-IP identity cap into the HTTP credit path (previously hardcoded to 0), so a depleted user can't farm a fresh $5 grant by minting a new pilot identity from one IP.

New tests: settle-from-response, free-control-plane, 402-on-depletion, overshoot-clamps-to-zero, failed-call-free, per-IP cap. Existing broker tests unchanged/green.

Submission (submissions/io.pilot.orthogonal)

Managed HTTP app (backend.auth: managed), 9 methods incl. the natural-language router orthogonal.search and the discover→price→execute flow. publisher + vendor populated; per-user $5 budget metered true-to-real-usage via the broker change above.

Testing

  • go test ./internal/broker/ green (incl. new tests); verify-submission builds + gates all 4 platforms.
  • End-to-end via a local signed catalogue: installed with pilotctl appstore install, store card renders, and orthogonal.run executes through the live managed-key broker (real priceCents debited from the per-user budget; free discovery/balance calls don't debit; per-IP cap returns 429 on the 6th identity).
  • Broker already deployed on the shared broker.pilotprotocol.network (registry entry + master key), so managed calls work on merge.

🤖 Generated with Claude Code

Alex Godo and others added 3 commits July 6, 2026 14:30
…redit path

Adds two additive knobs to the managed-HTTP credit budget so a meta-API like
orthogonal (one master key fronting 851 endpoints, per-call price only known
from the response, some 'dynamic') can be metered true to real usage:

- cost_source:"response" — no up-front debit; a billable path (cost_credits>0)
  is refused with 402 only when the caller is already depleted, and after a 2xx
  the ACTUAL cost (CostField × cost_scale, micro-$) is settled, clamped to floor
  the balance at zero. Free control-plane paths always pass. Adds Store.Settle
  (atomic clamp-debit) to MemStore + SQLiteStore.
- max_identities_per_ip / mint_cooldown_ms on CreditSpec — wires the existing
  Provision IP cap into the credit path (previously passed 0), so a depleted
  user can't farm a fresh $5 grant by minting a new pilot identity from one IP.

Fixed-cost apps (agentphone etc.) are unchanged. Tests cover settle-from-response,
free control-plane, 402-on-depletion, overshoot-clamps-to-zero, failed-call-free,
and the per-IP cap.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… response-cost metering

Rich managed submission (backend.auth=managed, 9 methods, vendor+listing). Wraps
Orthogonal's 58 APIs / 851 endpoints behind the managed-key broker: NL router
(orthogonal.search) + discover→price→execute; only orthogonal.run bills, metered
true-to-usage against a per-user $5 budget with a per-IP identity cap. Bundles
published to R2 via the catalogue PR (not committed here).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Alexgodoroja Alexgodoroja merged commit dcfd73f into main Jul 6, 2026
7 checks passed
@TeoSlayer TeoSlayer deleted the feat/credit-ip-cap branch July 13, 2026 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant