Skip to content

feat: Implement Usage Meter contract with inference session tracking#1

Merged
joelpeace48-cell merged 1 commit into
mainfrom
feat/usage-meter-contract
May 18, 2026
Merged

feat: Implement Usage Meter contract with inference session tracking#1
joelpeace48-cell merged 1 commit into
mainfrom
feat/usage-meter-contract

Conversation

@joelpeace48-cell
Copy link
Copy Markdown

Summary

Implements the UsageMeterContract Soroban smart contract for per-inference telemetry tracking at scale.

What this adds

  • InferenceSession struct: tracks session metadata (model_id, operator, timestamps, inference count, token count)
  • start_session(operator, model_id) → returns session_id
  • get_session(session_id) → returns full InferenceSession
  • get_state() → aggregate meter statistics
  • Full unit test suite: test_session_lifecycle verifies session creation and retrieval

Why this matters

The Usage Meter is the second of three ModelTrace contracts. Once deployed, it enables:

  • Per-model inference billing (enterprises pay per inference, not per deployment)
  • Audit-grade telemetry: every inference request linked to a session linked to a registered model
  • EU AI Act Article 12 compliance: high-risk AI systems must log inference inputs and outputs

Test plan

  • cargo test --workspace passes
  • cargo clippy --workspace clean
  • Integration test with Audit Registry (pending audit-registry testnet deployment)

Related

  • Closes #12 (Usage Meter contract implementation)
  • Depends on #3 (Audit Registry — already merged to main)

Adds InferenceSession struct, start_session(), get_session(), and
unit tests. This enables per-model inference telemetry at scale without
exposing raw model internals on-chain.
@joelpeace48-cell joelpeace48-cell merged commit aae8e24 into main May 18, 2026
1 of 3 checks passed
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