Skip to main content

Crate harn_vm

Crate harn_vm 

Source

Re-exports§

pub use checkpoint::register_checkpoint_builtins;
pub use connectors::active_connector_client;
pub use connectors::active_metrics_registry;
pub use connectors::clear_active_connector_clients;
pub use connectors::clear_active_metrics_registry;
pub use connectors::connector_export_denied_builtin_reason;
pub use connectors::connector_export_effect_class;
pub use connectors::cron::CatchupMode;
pub use connectors::cron::CronConnector;
pub use connectors::default_connector_export_policy;
pub use connectors::harn_module::load_contract as load_harn_connector_contract;
pub use connectors::harn_module::HarnConnector;
pub use connectors::harn_module::HarnConnectorContract;
pub use connectors::hmac::verify_hmac_signed;
pub use connectors::hmac::SIGNATURE_VERIFY_AUDIT_TOPIC;
pub use connectors::install_active_connector_clients;
pub use connectors::install_active_metrics_registry;
pub use connectors::postprocess_normalized_event;
pub use connectors::ActivationHandle;
pub use connectors::ClientError;
pub use connectors::Connector;
pub use connectors::ConnectorClient;
pub use connectors::ConnectorCtx;
pub use connectors::ConnectorError;
pub use connectors::ConnectorExportEffectClass;
pub use connectors::ConnectorHttpResponse;
pub use connectors::ConnectorMetricsSnapshot;
pub use connectors::ConnectorNormalizeResult;
pub use connectors::ConnectorRegistry;
pub use connectors::GenericWebhookConnector;
pub use connectors::HarnConnectorEffectPolicies;
pub use connectors::MetricsRegistry;
pub use connectors::PostNormalizeOutcome;
pub use connectors::ProviderPayloadSchema;
pub use connectors::RateLimitConfig;
pub use connectors::RateLimiterFactory;
pub use connectors::RawInbound;
pub use connectors::StreamConnector;
pub use connectors::TriggerBinding;
pub use connectors::TriggerKind;
pub use connectors::TriggerRegistry;
pub use connectors::WebhookSignatureVariant;
pub use corrections::append_correction_record;
pub use corrections::apply_corrections_to_policy;
pub use corrections::correction_query_filters_from_json;
pub use corrections::correction_record_from_json;
pub use corrections::policy_with_corrections;
pub use corrections::query_correction_records;
pub use corrections::CorrectionQueryFilters;
pub use corrections::CorrectionRecord;
pub use corrections::CorrectionScope;
pub use corrections::CORRECTIONS_TOPIC;
pub use corrections::CORRECTION_EVENT_KIND;
pub use corrections::CORRECTION_SCHEMA_V0;
pub use llm::register_llm_builtins;
pub use llm::current_agent_session_id;
pub use llm::drain_global_pending_feedback;
pub use llm::push_pending_feedback_global;
pub use llm::register_session_end_hook;
pub use llm::wait_for_global_pending_feedback;
pub use mcp::connect_mcp_server;
pub use mcp::connect_mcp_server_from_json;
pub use mcp::connect_mcp_server_from_spec;
pub use mcp::register_mcp_builtins;
pub use mcp_card::fetch_server_card;
pub use mcp_card::load_server_card_from_path;
pub use mcp_card::CardError;
pub use mcp_registry::active_handle as mcp_active_handle;
pub use mcp_registry::ensure_active as mcp_ensure_active;
pub use mcp_registry::get_registration as mcp_get_registration;
pub use mcp_registry::install_active as mcp_install_active;
pub use mcp_registry::is_registered as mcp_is_registered;
pub use mcp_registry::register_servers as mcp_register_servers;
pub use mcp_registry::release as mcp_release;
pub use mcp_registry::reset as mcp_reset_registry;
pub use mcp_registry::snapshot_status as mcp_snapshot_status;
pub use mcp_registry::sweep_expired as mcp_sweep_expired;
pub use mcp_registry::RegisteredMcpServer;
pub use mcp_registry::RegistryStatus;
pub use mcp_server::take_mcp_serve_prompts;
pub use mcp_server::take_mcp_serve_registry;
pub use mcp_server::take_mcp_serve_resource_templates;
pub use mcp_server::take_mcp_serve_resources;
pub use mcp_server::tool_registry_to_mcp_tools;
pub use mcp_server::McpServer;
pub use metadata::register_metadata_builtins;
pub use metadata::register_scan_builtins;
pub use orchestration::canonicalize_run;
pub use orchestration::first_divergence;
pub use orchestration::run_replay_oracle_trace;
pub use orchestration::ReplayAllowlistRule;
pub use orchestration::ReplayDivergence;
pub use orchestration::ReplayExpectation;
pub use orchestration::ReplayOracleError;
pub use orchestration::ReplayOracleReport;
pub use orchestration::ReplayOracleTrace;
pub use orchestration::ReplayTraceRun;
pub use orchestration::ReplayTraceRunCounts;
pub use orchestration::REPLAY_TRACE_SCHEMA_VERSION;
pub use orchestration::install_handoff_routes;
pub use orchestration::snapshot_handoff_routes;
pub use orchestration::HandoffRouteConfig;
pub use orchestration::HandoffRouteDecisionRecord;
pub use orchestration::HandoffRouteTargetConfig;
pub use personas::disable_persona;
pub use personas::fire_schedule as fire_persona_schedule;
pub use personas::fire_trigger as fire_persona_trigger;
pub use personas::format_ms as format_persona_ms;
pub use personas::now_ms as persona_now_ms;
pub use personas::parse_rfc3339_ms as parse_persona_ms;
pub use personas::pause_persona;
pub use personas::persona_status;
pub use personas::record_persona_spend;
pub use personas::register_persona_value_sink;
pub use personas::resume_persona;
pub use personas::PersonaAssignmentStatus;
pub use personas::PersonaBudgetPolicy;
pub use personas::PersonaBudgetStatus;
pub use personas::PersonaHandoffInboxItem;
pub use personas::PersonaLease;
pub use personas::PersonaLifecycleState;
pub use personas::PersonaQueuedWork;
pub use personas::PersonaRunCost;
pub use personas::PersonaRunReceipt;
pub use personas::PersonaRuntimeBinding;
pub use personas::PersonaStatus;
pub use personas::PersonaTriggerEnvelope;
pub use personas::PersonaValueEvent;
pub use personas::PersonaValueEventKind;
pub use personas::PersonaValueReceipt;
pub use personas::PersonaValueSink;
pub use personas::PersonaValueSinkRegistration;
pub use personas::PERSONA_RUNTIME_TOPIC;
pub use provenance::build_signed_receipt;
pub use provenance::load_or_generate_agent_signing_key;
pub use provenance::verify_receipt;
pub use provenance::ProvenanceReceipt;
pub use provenance::ReceiptBuildOptions;
pub use provenance::ReceiptVerificationReport;
pub use receipts::Receipt;
pub use receipts::ReceiptSink;
pub use receipts::ReceiptStatus;
pub use receipts::ReceiptValidationError;
pub use receipts::RedactionClass;
pub use receipts::RECEIPT_SCHEMA_ID;
pub use receipts::RECEIPT_SCHEMA_JSON;
pub use receipts::RECEIPT_SCHEMA_VERSION;
pub use record_filter::normalize_record_filter_expression;
pub use record_filter::CompiledRecordFilter;
pub use schema::json_to_vm_value;
pub use sessions::CreateSession;
pub use sessions::ExpireSession;
pub use sessions::Session;
pub use sessions::SessionAttributes;
pub use sessions::SessionError;
pub use sessions::SessionStore;
pub use sessions::TouchSession;
pub use sessions::SESSIONS_TOPIC;
pub use stdlib::host::clear_host_call_bridge;
pub use stdlib::host::set_host_call_bridge;
pub use stdlib::host::HostCallBridge;
pub use stdlib::long_running::cancel_handle as cancel_long_running_handle;
pub use stdlib::secret_scan::append_secret_scan_audit;
pub use stdlib::secret_scan::audit_secret_scan_active;
pub use stdlib::secret_scan::scan_content as secret_scan_content;
pub use stdlib::secret_scan::SecretFinding;
pub use stdlib::secret_scan::SECRET_SCAN_AUDIT_TOPIC;
pub use stdlib::template::lookup_prompt_consumers;
pub use stdlib::template::lookup_prompt_span;
pub use stdlib::template::prompt_render_indices;
pub use stdlib::template::record_prompt_render_index;
pub use stdlib::template::PromptSourceSpan;
pub use stdlib::template::PromptSpanKind;
pub use stdlib::workflow_messages::workflow_pause_for_base;
pub use stdlib::workflow_messages::workflow_publish_query_for_base;
pub use stdlib::workflow_messages::workflow_query_for_base;
pub use stdlib::workflow_messages::workflow_respond_update_for_base;
pub use stdlib::workflow_messages::workflow_resume_for_base;
pub use stdlib::workflow_messages::workflow_signal_for_base;
pub use stdlib::workflow_messages::workflow_update_for_base;
pub use stdlib::workflow_messages::WorkflowMailboxState;
pub use stdlib::register_agent_stdlib;
pub use stdlib::register_core_stdlib;
pub use stdlib::register_io_stdlib;
pub use stdlib::register_vm_stdlib;
pub use store::register_store_builtins;
pub use tenant::tenant_event_topic_prefix;
pub use tenant::tenant_secret_namespace;
pub use tenant::tenant_topic;
pub use tenant::validate_tenant_id;
pub use tenant::ApiKeyId;
pub use tenant::TenantApiKeyRecord;
pub use tenant::TenantBudget;
pub use tenant::TenantEventLog;
pub use tenant::TenantRecord;
pub use tenant::TenantRegistrySnapshot;
pub use tenant::TenantResolutionError;
pub use tenant::TenantScope;
pub use tenant::TenantSecretProvider;
pub use tenant::TenantStatus;
pub use tenant::TenantStore;
pub use tenant::TENANT_EVENT_TOPIC_PREFIX;
pub use tenant::TENANT_REGISTRY_DIR;
pub use tenant::TENANT_REGISTRY_FILE;
pub use tenant::TENANT_SECRET_NAMESPACE_PREFIX;
pub use triggers::append_dispatch_cancel_request;
pub use triggers::begin_in_flight;
pub use triggers::binding_autonomy_budget_would_exceed;
pub use triggers::binding_budget_would_exceed;
pub use triggers::binding_version_as_of;
pub use triggers::classify_trigger_dlq_error;
pub use triggers::clear_dispatcher_state;
pub use triggers::clear_orchestrator_budget;
pub use triggers::clear_trigger_registry;
pub use triggers::drain;
pub use triggers::dynamic_deregister;
pub use triggers::dynamic_register;
pub use triggers::expected_predicate_cost_usd_micros;
pub use triggers::finish_in_flight;
pub use triggers::install_manifest_triggers;
pub use triggers::install_orchestrator_budget;
pub use triggers::install_provider_catalog;
pub use triggers::micros_to_usd;
pub use triggers::note_autonomous_decision;
pub use triggers::note_orchestrator_budget_cost;
pub use triggers::orchestrator_budget_would_exceed;
pub use triggers::parse_flow_control_duration;
pub use triggers::pause;
pub use triggers::pin_trigger_binding;
pub use triggers::provider_metadata;
pub use triggers::record_predicate_cost_sample;
pub use triggers::redact_headers;
pub use triggers::register_provider_schema;
pub use triggers::registered_provider_metadata;
pub use triggers::registered_provider_schema_names;
pub use triggers::reset_binding_budget_windows;
pub use triggers::reset_provider_catalog;
pub use triggers::reset_provider_catalog_with;
pub use triggers::resolve_live_or_as_of;
pub use triggers::resolve_live_trigger_binding;
pub use triggers::resolve_trigger_binding_as_of;
pub use triggers::resume;
pub use triggers::run_trigger_harness_fixture;
pub use triggers::scheduler_in_flight_by_key;
pub use triggers::scheduler_ready_stats_by_key;
pub use triggers::snapshot_dispatcher_stats;
pub use triggers::snapshot_orchestrator_budget;
pub use triggers::snapshot_trigger_bindings;
pub use triggers::unpin_trigger_binding;
pub use triggers::usd_to_micros;
pub use triggers::worker_claims_topic_name;
pub use triggers::worker_job_topic_name;
pub use triggers::worker_response_topic_name;
pub use triggers::ClaimedWorkerJob;
pub use triggers::DispatchCancelRequest;
pub use triggers::DispatchError;
pub use triggers::DispatchOutcome;
pub use triggers::DispatchStatus;
pub use triggers::Dispatcher;
pub use triggers::DispatcherDrainReport;
pub use triggers::DispatcherStatsSnapshot;
pub use triggers::FairnessKey;
pub use triggers::HeaderRedactionPolicy;
pub use triggers::InboxIndex;
pub use triggers::NotionPolledChangeEvent;
pub use triggers::OrchestratorBudgetConfig;
pub use triggers::OrchestratorBudgetSnapshot;
pub use triggers::ProviderCatalog;
pub use triggers::ProviderCatalogError;
pub use triggers::ProviderId;
pub use triggers::ProviderMetadata;
pub use triggers::ProviderOutboundMethod;
pub use triggers::ProviderPayload;
pub use triggers::ProviderRuntimeMetadata;
pub use triggers::ProviderSchema;
pub use triggers::ProviderSecretRequirement;
pub use triggers::ReadyKeyStats;
pub use triggers::RecordedTriggerBinding;
pub use triggers::RetryPolicy;
pub use triggers::SchedulableJob;
pub use triggers::SchedulerKeyStat;
pub use triggers::SchedulerPolicy;
pub use triggers::SchedulerSnapshot;
pub use triggers::SchedulerState;
pub use triggers::SchedulerStrategy;
pub use triggers::SignatureStatus;
pub use triggers::SignatureVerificationMetadata;
pub use triggers::StreamEventPayload;
pub use triggers::TenantId;
pub use triggers::TraceId;
pub use triggers::TriggerBatchConfig;
pub use triggers::TriggerBindingSnapshot;
pub use triggers::TriggerBindingSource;
pub use triggers::TriggerBindingSpec;
pub use triggers::TriggerBudgetExhaustionStrategy;
pub use triggers::TriggerConcurrencyConfig;
pub use triggers::TriggerDebounceConfig;
pub use triggers::TriggerDispatchOutcome;
pub use triggers::TriggerEvent;
pub use triggers::TriggerEventId;
pub use triggers::TriggerExpressionSpec;
pub use triggers::TriggerFlowControlConfig;
pub use triggers::TriggerHandlerSpec;
pub use triggers::TriggerHarnessResult;
pub use triggers::TriggerId;
pub use triggers::TriggerMetricsSnapshot;
pub use triggers::TriggerPredicateSpec;
pub use triggers::TriggerPriorityOrderConfig;
pub use triggers::TriggerRateLimitConfig;
pub use triggers::TriggerRegistryError;
pub use triggers::TriggerRetryConfig;
pub use triggers::TriggerSingletonConfig;
pub use triggers::TriggerState;
pub use triggers::TriggerThrottleConfig;
pub use triggers::WorkerQueue;
pub use triggers::WorkerQueueClaimHandle;
pub use triggers::WorkerQueueEnqueueReceipt;
pub use triggers::WorkerQueueInspectSnapshot;
pub use triggers::WorkerQueueJob;
pub use triggers::WorkerQueueJobState;
pub use triggers::WorkerQueuePriority;
pub use triggers::WorkerQueueResponseRecord;
pub use triggers::WorkerQueueState;
pub use triggers::WorkerQueueSummary;
pub use triggers::DEFAULT_INBOX_RETENTION_DAYS;
pub use triggers::DEFAULT_STARVATION_AGE_MS;
pub use triggers::TRIGGERS_LIFECYCLE_TOPIC;
pub use triggers::TRIGGER_ATTEMPTS_TOPIC;
pub use triggers::TRIGGER_CANCEL_REQUESTS_TOPIC;
pub use triggers::TRIGGER_DLQ_TOPIC;
pub use triggers::TRIGGER_INBOX_CLAIMS_TOPIC;
pub use triggers::TRIGGER_INBOX_ENVELOPES_TOPIC;
pub use triggers::TRIGGER_INBOX_LEGACY_TOPIC;
pub use triggers::TRIGGER_OPERATION_AUDIT_TOPIC;
pub use triggers::TRIGGER_OUTBOX_TOPIC;
pub use triggers::TRIGGER_TEST_FIXTURES;
pub use triggers::WORKER_QUEUE_CATALOG_TOPIC;
pub use trust_graph::append_active_trust_record;
pub use trust_graph::append_trust_record;
pub use trust_graph::export_trust_chain;
pub use trust_graph::group_trust_records_by_trace;
pub use trust_graph::policy_for_agent;
pub use trust_graph::policy_for_autonomy_tier;
pub use trust_graph::query_trust_graph_records;
pub use trust_graph::query_trust_records;
pub use trust_graph::resolve_agent_autonomy_tier;
pub use trust_graph::summarize_trust_records;
pub use trust_graph::topic_for_agent;
pub use trust_graph::trust_score_for;
pub use trust_graph::verify_trust_chain;
pub use trust_graph::AutonomyTier;
pub use trust_graph::TrustAgentSummary;
pub use trust_graph::TrustChainExport;
pub use trust_graph::TrustChainExportMetadata;
pub use trust_graph::TrustChainExportProducer;
pub use trust_graph::TrustChainReport;
pub use trust_graph::TrustGraphRecord;
pub use trust_graph::TrustOutcome;
pub use trust_graph::TrustQueryFilters;
pub use trust_graph::TrustRecord;
pub use trust_graph::TrustScore;
pub use trust_graph::TrustTraceGroup;
pub use trust_graph::OPENTRUSTGRAPH_CHAIN_SCHEMA_V0;
pub use trust_graph::OPENTRUSTGRAPH_SCHEMA_V0;
pub use trust_graph::TRUST_GRAPH_GLOBAL_TOPIC;
pub use trust_graph::TRUST_GRAPH_LEGACY_GLOBAL_TOPIC;
pub use trust_graph::TRUST_GRAPH_LEGACY_TOPIC_PREFIX;
pub use trust_graph::TRUST_GRAPH_RECORDS_TOPIC;
pub use trust_graph::TRUST_GRAPH_TOPIC_PREFIX;
pub use value::*;

Modules§

a2a
agent_events
Agent event stream — the ACP-aligned observation surface for the agent loop.
agent_sessions
First-class session storage.
atomic_io
Atomic file write helpers.
autonomy
bridge
JSON-RPC 2.0 bridge for host communication.
checkpoint
Checkpoint system for resilient pipeline execution.
connectors
Connector traits and shared helpers for inbound event-source providers.
corrections
egress
event_log
events
Structured event emission for observability.
flow
Harn Flow — agent-native shipping substrate.
iter
Lazy iterator protocol for the Harn VM.
jsonrpc
Shared JSON-RPC 2.0 message construction helpers.
llm
LLM integration: API calls, streaming, agent loops, tool handling, and tracing.
llm_config
mcp
MCP (Model Context Protocol) client for connecting to external tool servers.
mcp_card
MCP Server Card consumer + publisher (2026 MCP v2.1 spec, harn#75).
mcp_elicit
MCP elicitation/create plumbing — server-to-client structured prompts.
mcp_progress
MCP notifications/progress plumbing — server-to-client progress updates emitted from a long-running tool handler.
mcp_protocol
Shared MCP protocol-version and feature-gap helpers.
mcp_registry
Process-local MCP server registry for lazy boot + skill-scoped binding (harn#75).
mcp_sampling
MCP sampling/createMessage plumbing — server-to-client LLM sampling.
mcp_server
MCP server mode: expose Harn tools, resources, resource templates, and prompts as MCP capabilities over stdio.
metadata
Project metadata store for Harn’s runtime state root.
observability
orchestration
personas
process_sandbox
Public re-exports of the platform-specific process sandbox primitives.
profile
Categorical profile rollup over completed crate::tracing::Spans.
provenance
receipts
record_filter
runtime_context
runtime_paths
schema
secrets
sessions
shells
skills
Filesystem-and-host skill discovery for Harn.
stdlib
Standard library builtins for the Harn VM.
stdlib_modules
step_runtime
Per-step runtime state for @step-annotated persona functions.
store
Persistent key-value store backed by Harn’s runtime state root.
tenant
tool_annotations
Tool annotations — the single source of truth for tool semantics.
tool_surface
Validation for coherent tool surfaces before an agent spends model tokens.
tracing
Pipeline Observability: structured tracing spans with parent/child relationships.
triggers
trust_graph
typecheck
Runtime type & arity validation, shared between user-defined function calls and registry-known builtin calls.
value
visible_text
waitpoints
workspace_path

Structs§

ApprovalRequest
AsyncBuiltinChildVmGuard
BuiltinId
Compact, deterministic identifier for a builtin name.
Chunk
A compiled chunk of bytecode.
CompileError
Compile error.
CompiledFunction
A compiled function (closure body).
Compiler
Compiles an AST into bytecode.
CompilerOptions
Controls semantic-preserving compiler optimizations.
DebugState
Information about current execution state for the debugger.
HitlHostResponse
LocalSlotInfo
Debug metadata for a slot-indexed local in a compiled chunk.
ParamSlot
One parameter slot of a compiled user-defined function. Carries the declared name, the (optional) declared type expression, and a flag for whether a default value was provided. The runtime consults the type expression in bind_param_slots to enforce declared types against the values supplied at the call site.
TriggerPredicateBudget
Vm
The Harn bytecode virtual machine.
VmBuiltinMetadata
Discoverable metadata for a VM builtin.

Enums§

Constant
A constant value in the constant pool.
DebugAction
Debug action returned by the debug hook.
Op
Bytecode opcodes for the Harn VM.
VmBuiltinArity
Lightweight arity metadata for registered builtins.
VmBuiltinKind
Runtime kind for a registered VM builtin.

Constants§

HARN_DISABLE_OPTIMIZATIONS_ENV
Environment variable that disables optional compiler optimizations.
HITL_APPROVALS_TOPIC
HITL_DUAL_CONTROL_TOPIC
HITL_ESCALATIONS_TOPIC
HITL_QUESTIONS_TOPIC
WAITPOINT_RESUME_TOPIC

Functions§

append_hitl_response
clone_async_builtin_child_vm
Clone the VM at the top of the async-builtin child VM stack, returning a fresh Vm instance the caller owns. Enables concurrent tool-handler execution within a single agent_loop iteration — the VM shares its heavy state (env, builtins, bridge, module_cache) via Arc/Rc, so cloning is cheap and each handler gets its own execution context.
compile_source
Lex, parse, type-check, and compile source to bytecode in one call. Bails on the first type error. For callers that need diagnostics rather than early exit, use harn_parser::check_source directly and then call Compiler::new().compile(&program).
compile_source_named
Same as compile_source but compiles a specific named pipeline as the program entry point instead of the default-pipeline-or-first selection rule. Returns a runtime error when no pipeline with pipeline_name exists in the source.
forward_child_output_to_parent
Forward captured output from a transient child VM (typically created via clone_async_builtin_child_vm and used to invoke a closure) back into the async-builtin’s host stack entry. The dispatch loop drains that entry’s output back to the original parent VM after the async builtin returns.
install_async_builtin_child_vm
json_schema_for_type_expr
json_schema_for_typed_params
process_waitpoint_resume_event
register_http_builtins
Register HTTP builtins on a VM.
reset_http_state
Reset thread-local HTTP mock state. Call between test runs.
reset_thread_local_state
Reset all thread-local state that can leak between test runs.
resolve_module_import_path
restore_async_builtin_child_vmDeprecated
Legacy no-op retained for backward compatibility.
service_waitpoints_once
set_stdout_passthrough
Enable or disable direct stdout writes for CLI-style runs.
take_async_builtin_child_vmDeprecated
Legacy API preserved for out-of-tree callers; new code should use clone_async_builtin_child_vm(). take/restore serialized concurrent callers because only one could hold the popped value at a time.
take_stderr_buffer
Drain and return the buffered stderr output. The CLI flushes this to the real stderr at the end of execution.

Type Aliases§

ChunkRef
CompiledFunctionRef