Skip to content

feat(runtime): implement node pricing and economic settlement#13

Merged
simonovic86 merged 1 commit intomainfrom
claude/gracious-golick
Mar 5, 2026
Merged

feat(runtime): implement node pricing and economic settlement#13
simonovic86 merged 1 commit intomainfrom
claude/gracious-golick

Conversation

@simonovic86
Copy link
Owner

Overview

Implements node pricing discovery and economic settlement infrastructure for inter-node cost awareness and budget validation.

Changes

Pricing Service (CM-4)

  • New internal/pricing package with /igor/price/1.0.0 libp2p protocol
  • QueryPeerPrice() enables agents to discover remote node execution costs
  • PriceResponse returns price per second in microcents
  • Comprehensive tests for round-trip queries, timeouts, and invalid addresses

Node Price Hostcall

  • New node_price() hostcall in internal/hostcall/pricing.go
  • Observation hostcall recorded in event log (NodePrice event ID 7)
  • Available to agents declaring "pricing" capability in manifest
  • SDK wrapper in sdk/igor/hostcalls_pricing_wasm.go

Settlement & Budget Validation (EI-6)

  • New internal/settlement package with BudgetAdapter interface
  • MockAdapter for testing: validates budgets (always true) and records settlements
  • Thread-safe in-memory settlement accumulation with Settlements() inspection
  • Instance now validates budget before each tick via adapter
  • Receipts recorded to adapter after checkpoint epochs (non-fatal errors)

Replay Support

  • node_price integrated into single-tick and chain-replay engines
  • Event log payloads (8-byte little-endian uint64) deserialized during replay
  • Maintains deterministic replay verification

Simulator & SDK Updates

  • Deterministic hostcalls support pricing with configurable nodePrice
  • Mock SDK runtime supports SetNodePrice() and NodePrice() inspection
  • Example agent manifest now declares "pricing" capability
  • pkg/manifest capabilities list includes "pricing"

Integration

  • cmd/igord/main.go initializes pricing service and wires mock budget adapter
  • Agent instances receive BudgetAdapter field for external validation
  • Non-blocking settlement errors logged but don't halt execution

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>
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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 {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@simonovic86 simonovic86 merged commit 33e6a9a into main Mar 5, 2026
1 check passed
@simonovic86 simonovic86 deleted the claude/gracious-golick branch March 5, 2026 01:50
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