Skip to content

broker: method-specific credit costs + free reads (default_cost 0)#66

Merged
Alexgodoroja merged 1 commit into
pilot-protocol:mainfrom
Alexgodoroja:broker-credit-method-cost
Jul 4, 2026
Merged

broker: method-specific credit costs + free reads (default_cost 0)#66
Alexgodoroja merged 1 commit into
pilot-protocol:mainfrom
Alexgodoroja:broker-credit-method-cost

Conversation

@Alexgodoroja

Copy link
Copy Markdown
Collaborator

Follow-up to the credit gate (#64). Two fixes needed for a real REST partner:

  1. Method-specific costs. A REST path is reused across methods — GET /v1/numbers (list, free) vs POST /v1/numbers (buy, $3). Pricing by path alone would charge the free list. cost_credits keys may now be method-scoped ("POST /v1/numbers") or any-method ("/v1/usage"); templated paths still work; method-specific wins. Resolution: method-exact → any-exact → method-pattern → any-pattern → default.
  2. default_cost: 0 is honored (was bumped to 1), so reads are free and only priced calls debit — polling for status/replies never burns budget.

Test covers free GET vs paid POST on the same path through to 402. Full suite green; MANAGED-KEY.md updated.

The credit gate priced by PATH only, but a REST partner reuses a path across
methods: GET /v1/numbers (list, free) vs POST /v1/numbers (buy, $3). Path-only
pricing would wrongly charge the free list. And default_cost 0 was silently
bumped to 1, so reads couldn't be free.

- cost_credits keys may now be method-specific ("POST /v1/numbers") or
  any-method ("/v1/usage"); templated paths still work. Method-specific wins.
  Resolution: method exact → any exact → method pattern → any pattern → default.
- default_cost 0 is honored (reads free); only a negative value is clamped.
- Test: free GET vs paid POST on the same path, debit → 402. Full suite green.
  MANAGED-KEY.md example updated to the method-scoped, free-reads shape.
@Alexgodoroja Alexgodoroja merged commit f2ffb55 into pilot-protocol:main Jul 4, 2026
6 checks passed
Alexgodoroja pushed a commit to Alexgodoroja/app-template that referenced this pull request Jul 4, 2026
…cal number recall

Managed AgentPhone app: keyless adapter → Pilot broker (holds the master key,
meters each user against a $5 budget → 402) → https://api.agentphone.ai.

- 53 methods covering every non-streaming /v1 endpoint (agents, numbers, messages,
  calls, conversations, contacts, contact-cards, usage, voices, webhooks). Every
  method described; params tagged path/query/body. No websockets — poll for status.
- Local number recall: buy_number captures the provisioned number to
  ~/.pilot/.agentphone; agentphone.mynumber reads it back locally (no round-trip).
- verify-submission builds + verifies darwin/linux amd64+arm64.

Requires the broker credit gate (pilot-protocol#64) + method-aware costs (pilot-protocol#66) + local-metadata
scaffold (pilot-protocol#67), all merged.
Alexgodoroja added a commit that referenced this pull request Jul 4, 2026
…cal number recall (#65)

Managed AgentPhone app: keyless adapter → Pilot broker (holds the master key,
meters each user against a $5 budget → 402) → https://api.agentphone.ai.

- 53 methods covering every non-streaming /v1 endpoint (agents, numbers, messages,
  calls, conversations, contacts, contact-cards, usage, voices, webhooks). Every
  method described; params tagged path/query/body. No websockets — poll for status.
- Local number recall: buy_number captures the provisioned number to
  ~/.pilot/.agentphone; agentphone.mynumber reads it back locally (no round-trip).
- verify-submission builds + verifies darwin/linux amd64+arm64.

Requires the broker credit gate (#64) + method-aware costs (#66) + local-metadata
scaffold (#67), all merged.

Co-authored-by: Alex Godoroja <alex@vulturelabs.io>
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