feat(runtime): implement node pricing and economic settlement#13
feat(runtime): implement node pricing and economic settlement#13simonovic86 merged 1 commit intomainfrom
Conversation
Add infrastructure for agents to discover node pricing and for nodes to validate budgets through pluggable settlement backends, enabling cost-aware migration decisions and laying groundwork for real payment rails. New packages: - internal/settlement: BudgetAdapter interface + MockAdapter - internal/pricing: /igor/price/1.0.0 request-response protocol - internal/hostcall/pricing.go: node_price observation hostcall (CM-4) Key changes: - node_price hostcall with full replay support (single-tick + chain) - Budget adapter tick gating in Instance.Tick() (EI-6) - Settlement recording on checkpoint save - SDK wrappers, mock backend, and simulator support for pricing - Price query protocol over libp2p streams for inter-node discovery - "pricing" added to NodeCapabilities and example manifest Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b220aa8428
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| var resp PriceResponse | ||
| if err := json.NewDecoder(stream).Decode(&resp); err != nil { |
There was a problem hiding this comment.
Bound
QueryPeerPrice stream reads to the request context
After NewStream succeeds, the code does json.NewDecoder(stream).Decode(&resp) without setting a read deadline, so a peer that accepts the stream but never sends a response can block this call indefinitely even if the caller passed a timed context. This makes price discovery hang in partially-failing or adversarial networks instead of respecting the caller’s timeout budget.
Useful? React with 👍 / 👎.
| clockDelta = 1_000_000_000 | ||
| } | ||
| dhc := newDeterministicHostcalls(clockStart, clockDelta, cfg.RandSeed, el, logger) | ||
| dhc := newDeterministicHostcalls(clockStart, clockDelta, cfg.RandSeed, budget.FromFloat(cfg.PricePerSecond), el, logger) |
There was a problem hiding this comment.
Use the effective simulator price for deterministic node_price
In simulator setup, pricePerSecond is normalized to a default of 1000 when config leaves it unset, but deterministic hostcall wiring passes budget.FromFloat(cfg.PricePerSecond) directly here. That makes node_price() return 0 in the common default case while tick-cost accounting still charges 1000, producing inconsistent economics and incorrect agent behavior whenever pricing capability is used.
Useful? React with 👍 / 👎.
Overview
Implements node pricing discovery and economic settlement infrastructure for inter-node cost awareness and budget validation.
Changes
Pricing Service (CM-4)
internal/pricingpackage with/igor/price/1.0.0libp2p protocolQueryPeerPrice()enables agents to discover remote node execution costsPriceResponsereturns price per second in microcentsNode Price Hostcall
node_price()hostcall ininternal/hostcall/pricing.gosdk/igor/hostcalls_pricing_wasm.goSettlement & Budget Validation (EI-6)
internal/settlementpackage withBudgetAdapterinterfaceMockAdapterfor testing: validates budgets (always true) and records settlementsSettlements()inspectionReplay Support
node_priceintegrated into single-tick and chain-replay enginesSimulator & SDK Updates
nodePriceSetNodePrice()andNodePrice()inspectionpkg/manifestcapabilities list includes "pricing"Integration
cmd/igord/main.goinitializes pricing service and wires mock budget adapterBudgetAdapterfield for external validation