Expand description
Native Rust execution, replay and audit runtime for Pollard.
Identities use the frozen pollard/v1 domain and arbitrary-size JSON integers.
Runtime callbacks are detached from identity payloads. Strict replay verifies
the recording and its ancestors and never dispatches a callback.
See the crate README for PyPI 1.6.0 compatibility and remaining integrations.
Re-exports§
pub use tokenmaster::tokenmaster_governance_meters;pub use tokenmaster::TokenmasterCostMeter;pub use tokenmaster::TokenmasterMeter;
Modules§
- adapters
- Provider-neutral JSON adapters matching Pollard 1.6.0 normalization.
- kv
- Shared serializable key/value storage and exact reservation ledger. Wire buckets and permanent retry tombstones match Python Pollard 1.6.0.
- mcp
- MCP discovery and governed async invocation with a caller-owned session. The session owns the transport, authentication and SDK; discovery never executes tools. JSON inputs/results match Python’s MCP bridge contract.
- otel
- Content-free OpenTelemetry attributes and correctly parented export.
Implement
SpanExporterfor a caller-owned tracing SDK. This module never configures global tracing, creates a network exporter or reads credentials. - render
- Offline, content-minimal tree views. Payload/result content is opt-in.
- store_
spec - Credential-safe environment references for operator commands. URI/password values remain in the environment and are never part of a displayed label.
- tokenmaster
- Offline profile governance compatible with Pollard 1.6 / Tokenmaster 0.2.
Macros§
- json
- Construct a
serde_json::Valuefrom a JSON literal.
Structs§
- Action
Spec - Frozen action identity with an optional synchronous callback.
- Async
Run - Async
Runtime - Budget
- Integer budgets. Depth is absolute ancestry depth; root depth is zero.
- Budget
Reservation - One cumulative budget scope for explicit shared SQLite arbitration.
- Call
Options - Supply a conservative total input + output token estimate for token gates.
- Charges
- Cost
Meter - Depth
Meter - Energy
Measurement - Energy
Meter - Exact
Result Comparator - Export
Report - GCReport
- Hash
Rope Store - Import
Report - Memory
Store - Merge
Report - Metadata
Meter - Charge a numeric measurement supplied in node metadata, e.g.
joules. - Meter
Precheck Refusal - An expected governance decision from a custom meter’s precheck. Configuration
and programming errors should use ordinary
Errorvariants instead. - Model
Price - Prices are decimal dollars per million tokens, provided by the caller.
- Node
- Detached owned record. Result integrity is checked against exact result text.
- Normalized
Model Comparator - Policy
Context - Policy receives owned snapshots. Its decisions cannot mutate stored identity.
- Registry
- Registry identities depend only on sorted spec digests, never callbacks.
- Replay
Contract - Reservation
Check - Revalidation
Comparison - Revalidation
Options - Identity for one deliberate live comparison. Supply an observation ID once; reusing it at the same recording cursor is rejected before dispatch.
- Revalidation
Report - Run
- RunReport
- Runtime
- SQLite
Seal Sink - SQLite
Store - Seal
Custody Record - Seal
Entry - Seal
Report - Shared
Store - Share this handle across runtimes to share records and a reentrancy lock. This synchronous API is intentionally single-threaded.
- Step
Meter - Store
Revision - A store-local cache token distinguishing local writes from independent ones.
- Stream
Accumulator - Incremental accumulator. Unretained chunks are released immediately.
- Text
Budget Reservation - Cumulative reservation with decimal amounts supplied as text.
- Text
Window Reservation - Sliding-window reservation retaining the original decimal representation.
- Token
Meter - Verify
Finding - Verify
Report - Wall
Clock Meter - Window
Limit - Window
Meter - A meter-backed sliding-window limit. The runtime keeps its ledger in records.
- Window
Reservation
Enums§
- Decision
- Error
- Errors preserve the refusal/recording identity when one exists.
- Node
Kind - Replay
Mode - Value
- Represents any valid JSON value.
Constants§
- MAX_
DIFFERENCE_ PATHS - MAX_
SAFE_ INTEGER - JavaScript’s exact integer bound, retained for metering compatibility. Identity payloads accept arbitrary-size integers, as Python Pollard does.
- REPLAY_
CONTRACT_ FORMAT - REVALIDATION_
FORMAT - SEAL_
ALGORITHM
Traits§
- Meter
- A custom resource meter. Estimates gate dispatch; charges settle actual work.
- Meter
Measurement - One live call’s measurement context. Runtime starts contexts after governance gates and finishes them in reverse order, including cancellation and unwind. Readings are merged into recording metadata before meters settle charges.
- Recording
Store - Optional settlement extension required by live runtimes. Finalization must atomically replace only a pending, resultless node with the same identity.
- Revalidation
Comparator - Store
- Backends return detached owned records. Mutations occur only via methods.
Functions§
- canonical_
bytes - Compact UTF-8 JSON with Unicode scalar sorted keys; floats are rejected.
- checked_
decimal_ add - Add without dropping significant digits;
Nonemeans the exact result does not fit Decimal’s 96-bit coefficient and maximum scale of 28. - checked_
decimal_ subtract - Subtract without rounding;
Nonemeans the exact result is unrepresentable. - consume_
stream - Consume fallible chunks, invoking the observer before merging each snapshot.
- consume_
stream_ async - Consume an asynchronous pull stream without imposing an executor or retaining discarded chunks. Observer and producer failures after output are uncertain.
- contains_
redaction - Check nested objects and arrays for an exact Pollard redaction marker.
- digest_
payload - SHA-256 of canonical identity bytes, without a domain prefix.
- export_
manifest - Return the same
pollard/subtree/v1document Python exports, retaining exact result text. - export_
subtree - extract_
replay_ contract - gc
- Run only while writers are stopped;
compactremoves unreferenced blobs. - import_
manifest - Fully validate a document and all destination collisions before applying it. MemoryStore and SQLiteStore apply the resulting batch atomically.
- import_
subtree - integrate_
energy - Trapezoidal integration of
(monotonic seconds, watts)samples. - is_
redacted - Recognize the exact marker shape used by Python Pollard 1.6.0.
- make_
revalidation_ payload - merge
- Union all roots after fully traversing and validating the source. Replay merge rejects result collisions. Ordinary merge retains first results.
- node_id
- Compute an identity using Pollard’s frozen v1 domain.
- parse_
decimal_ exact - Parse a bounded decimal without silently rounding input digits.
- redact
- A deterministic content commitment. This is not encryption.
- reemit_
chunks - Reemit retained chunks on replay without contacting the original provider.
- reservation_
charges_ text - Canonical Python-compatible settlement text and digest without database I/O.
- reservation_
request_ text - Canonical Python-compatible request text and digest without database I/O.
- resolve_
local_ refs - Expand finite local JSON Pointer references as Pollard 1.6.0 does. Remote, dangling, malformed, and recursive references fail at registration.
- result_
digest_ from_ text - Digest exact stored UTF-8 text; imported text must not be reserialized.
- result_
text_ and_ digest - Serialize a native result once and return its text and integrity digest.
Imported Python results should retain their original
result_textinstead. - schema_
has_ local_ refs - Whether reference/definition keywords occur in schema positions. Reference-shaped values in enum/default annotations remain literal data.
- seal
- verify
- Verify a node and all ancestors, including lookup keys and stored result text.
- verify_
subtree - Verify a subtree and its external ancestry, including child-index consistency.
The Python-compatible
verifyfunction intentionally checks ancestry only.
Type Aliases§
- Async
Handler - Energy
Counter - Handler
- Handler
Future - Lease
Renewer - Meter
Budget - Meter
Charges - Additional budgets and charges, named exactly as their configured meter.
- Node
Callback - Policy
- Power
Sampler - Result
- Crate result type.
- Token
Estimator