Skip to main content

Crate pollardai

Crate pollardai 

Source
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 SpanExporter for 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::Value from a JSON literal.

Structs§

ActionSpec
Frozen action identity with an optional synchronous callback.
AsyncRun
AsyncRuntime
Budget
Integer budgets. Depth is absolute ancestry depth; root depth is zero.
BudgetReservation
One cumulative budget scope for explicit shared SQLite arbitration.
CallOptions
Supply a conservative total input + output token estimate for token gates.
Charges
CostMeter
DepthMeter
EnergyMeasurement
EnergyMeter
ExactResultComparator
ExportReport
GCReport
HashRopeStore
ImportReport
MemoryStore
MergeReport
MetadataMeter
Charge a numeric measurement supplied in node metadata, e.g. joules.
MeterPrecheckRefusal
An expected governance decision from a custom meter’s precheck. Configuration and programming errors should use ordinary Error variants instead.
ModelPrice
Prices are decimal dollars per million tokens, provided by the caller.
Node
Detached owned record. Result integrity is checked against exact result text.
NormalizedModelComparator
PolicyContext
Policy receives owned snapshots. Its decisions cannot mutate stored identity.
Registry
Registry identities depend only on sorted spec digests, never callbacks.
ReplayContract
ReservationCheck
RevalidationComparison
RevalidationOptions
Identity for one deliberate live comparison. Supply an observation ID once; reusing it at the same recording cursor is rejected before dispatch.
RevalidationReport
Run
RunReport
Runtime
SQLiteSealSink
SQLiteStore
SealCustodyRecord
SealEntry
SealReport
SharedStore
Share this handle across runtimes to share records and a reentrancy lock. This synchronous API is intentionally single-threaded.
StepMeter
StoreRevision
A store-local cache token distinguishing local writes from independent ones.
StreamAccumulator
Incremental accumulator. Unretained chunks are released immediately.
TextBudgetReservation
Cumulative reservation with decimal amounts supplied as text.
TextWindowReservation
Sliding-window reservation retaining the original decimal representation.
TokenMeter
VerifyFinding
VerifyReport
WallClockMeter
WindowLimit
WindowMeter
A meter-backed sliding-window limit. The runtime keeps its ledger in records.
WindowReservation

Enums§

Decision
Error
Errors preserve the refusal/recording identity when one exists.
NodeKind
ReplayMode
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.
MeterMeasurement
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.
RecordingStore
Optional settlement extension required by live runtimes. Finalization must atomically replace only a pending, resultless node with the same identity.
RevalidationComparator
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; None means the exact result does not fit Decimal’s 96-bit coefficient and maximum scale of 28.
checked_decimal_subtract
Subtract without rounding; None means 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/v1 document Python exports, retaining exact result text.
export_subtree
extract_replay_contract
gc
Run only while writers are stopped; compact removes 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_text instead.
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 verify function intentionally checks ancestry only.

Type Aliases§

AsyncHandler
EnergyCounter
Handler
HandlerFuture
LeaseRenewer
MeterBudget
MeterCharges
Additional budgets and charges, named exactly as their configured meter.
NodeCallback
Policy
PowerSampler
Result
Crate result type.
TokenEstimator