Skip to main content

khive_runtime/
lib.rs

1//! khive-runtime: composable Service API used by daemon, MCP server, and CLI.
2//!
3//! Wraps `StorageBackend` and query compilation into a single Rust API surface.
4
5#[cfg(test)]
6mod test_process;
7
8pub mod actor_identity;
9pub mod agent_lifecycle;
10#[doc(hidden)]
11pub use khive_retrieval::ann::registry as ann_registry;
12pub mod atomic_message;
13pub mod atomic_plan;
14pub mod atomic_prepare;
15pub mod atomic_runner;
16pub mod audit_batch;
17pub mod blob;
18pub mod bounded_read;
19pub mod build_info;
20mod code_map_runtime;
21pub mod comm_recipient;
22pub mod comm_transport;
23pub mod config;
24pub mod config_ledger;
25pub mod cost_unit;
26pub mod credentials;
27mod visibility_receipts;
28pub use visibility_receipts::AuthenticatedVisibilityReceipt;
29pub mod curation;
30pub mod daemon;
31pub mod email_message_id;
32pub mod embedder_registry;
33pub mod engine_config;
34pub mod entity_write;
35pub mod error;
36mod error_projection;
37mod event_cursor_walk;
38mod event_page;
39mod event_store_guard;
40pub mod events_split;
41mod fence_identity;
42pub mod file_policy;
43pub mod fusion;
44pub mod graph_traversal;
45mod index_repair;
46pub use index_repair::IndexRepairReport;
47pub mod input_schema;
48pub mod keyed_memory;
49#[cfg(test)]
50mod keyed_memory_tests;
51pub mod keyed_message;
52mod kg_read;
53mod live_until;
54mod mailbox_view;
55mod note_create;
56mod note_index;
57mod note_read;
58pub mod note_search_ann;
59mod note_store_guard;
60pub mod note_write;
61#[cfg(test)]
62mod note_write_tests;
63pub mod objectives;
64pub mod operations;
65mod outbound_email_policy;
66pub use outbound_email_policy::OutboundEmailPolicy;
67pub mod pack;
68pub mod pack_metadata;
69mod params;
70pub mod phase_events;
71pub mod portability;
72pub mod preference_verification;
73pub mod presentation;
74pub mod process_group;
75pub mod process_retry;
76pub mod reference_resolution;
77pub mod reference_ring;
78pub mod registry;
79pub mod resource;
80pub mod retrieval;
81pub mod runtime;
82pub mod secret_gate;
83pub(crate) mod secret_gate_finalizer;
84mod sql_include;
85#[cfg(test)]
86mod stage_overlap_tests;
87mod stage_seam;
88mod streams;
89pub mod telemetry_config;
90pub use streams::{
91    refusal_value, StreamAppendDisposition, StreamAppendFailure, StreamAppendSpec,
92    StreamBatchMember, StreamBatchRefusal, StreamObservation, StreamWriteSpec,
93};
94pub mod time_anchor;
95pub use khive_storage::usage;
96pub mod validation;
97
98pub use actor_identity::{actor_is_unattributed, resolve_actor, should_warn_unattributed_actor};
99pub use agent_lifecycle::{
100    apply_transition, spawn_fingerprint, AgentRecord, AgentState, IllegalTransition,
101    TerminalReason, Transition, Trigger,
102};
103pub use atomic_message::{create_notes_atomic_with_report, AtomicNoteSpec};
104pub use atomic_plan::{
105    AddEntityPlan, AddNotePlan, AffectedRowGuard, DeletePlan, GovernanceOp, GovernancePlan,
106    GtdCompletePlan, GtdTransitionPlan, LinkPlan, MergePlan, PlanPredicate, PlanStatement,
107    PostCommitEffect, UpdatePlan,
108};
109pub use atomic_runner::{
110    run_atomic_unit, AtomicOpFailure, AtomicOpPlan, AtomicRunOutcome, AtomicRunnerError,
111    CommittedPostCommitEffects,
112};
113pub use blob::{
114    resolve_blob_store, resolve_blob_store_for_mode, BlobHydrator, GovernedBlobError, VerifiedBlob,
115    DEFAULT_BLOB_HYDRATION_BYTES,
116};
117pub use build_info::{BuildInfo, BUILD_INFO, BUILD_VERSION};
118pub use config::{ann_fresh_tail_enabled_from_env, process_ref_from_env, WalCeilingSource};
119pub use cost_unit::{base_resource_payload, cost_unit_for_dispatch, resource_payload};
120pub use curation::{
121    entity_embedding_text, entity_fts_document, entity_merge_guard_compared_values,
122    entity_merge_guard_error, entity_merge_guard_refusal_message, note_embedding_text,
123    note_fts_document, validate_entity_merge_floor, ContentMergeStrategy, EdgeListFilter,
124    EdgePatch, EntityDedupMergePolicy, EntityMergeGuard, EntityPatch, GuardedNoteMerge,
125    MergeAssertion, MergeEdgeConflictPreimage, MergeEdgePreimage, MergeSummary,
126    MergeTxBudgetReport, MergeTxLimits, NoteMergeGuard, NotePatch, NoteUpdatePolicy,
127};
128#[cfg(unix)]
129pub use daemon::{acquire_recovery_lock, pid_path, run_daemon, socket_path, DaemonDispatch};
130pub use daemon::{
131    active_phase_names, background_task_count, background_task_names, daemon_shutdown_token,
132    recall_ledger_snapshot, register_active_phase, spawn_named_tracked_task, track_background_task,
133    track_named_background_task, track_recall_ledger_task, DaemonRequestFrame, DaemonResponseFrame,
134    PhaseGuard, PROTOCOL_VERSION, UNNAMED_BACKGROUND_TASK,
135};
136pub use email_message_id::{EmailMessageIdDomains, HISTORICAL_DOMAINS_ENV};
137pub use embedder_registry::{EmbedderProvider, EmbedderRegistry, LatticeEmbedderProvider};
138pub use engine_config::{
139    config_from_env, resolve_wal_ceiling, BackendConfig, BackendKind, BlobConfig,
140    BrainSectionConfig, ConfigError, EngineConfig, GateSectionConfig, GitWriteEntryConfig,
141    GitWriteSectionConfig, KhiveConfig, PackConfig, ResolvedWalCeiling, StorageSectionConfig,
142};
143pub use error::{
144    fts_text_leg_or_err, AdmissionFailureContext, AuditObligationFailure, AuditObligationReason,
145    ChannelIngestFailureClass, DenialAuditOutcome, DenialReceipt, DispatchError, DomainDisposition,
146    GuardedWriteFailure, ReceiptRefusal, RefusalEventContext, RefusalEventRecording,
147    RefusalRecordingErrorClass, RuntimeError, RuntimeResult, WriterPoolCheckoutTimeoutContext,
148    WriterTaskFailureContext, SQLITE_WAL_CAPACITY_REFUSED_STAGE,
149    SQLITE_WAL_CAPACITY_UNAVAILABLE_STAGE, WRITER_ADMISSION_SCOPE,
150    WRITER_POOL_CHECKOUT_TIMEOUT_STAGE, WRITER_QUEUE_SATURATED_STAGE,
151    WRITER_TASK_REQUEST_FAILED_STAGE, WRITER_TASK_TERMINATED_STAGE,
152};
153pub use error_projection::runtime_error_value;
154pub use event_cursor_walk::{visit_events_cursor_walk, EventCursorWalkError};
155pub use event_page::{
156    page_budget_exceeded_error, row_exceeds_budget_error, EventReadPageRequest, EventReadPageResult,
157};
158pub use event_store_guard::EventAttribution;
159pub use fusion::FusionStrategy;
160pub use graph_traversal::PathNode;
161pub use kg_read::KgNeighborRead;
162pub use khive_db::{
163    checkpoint_once, run_checkpoint_task, run_migrations, CheckpointConfig,
164    CheckpointLifecycleOwner, CheckpointTick, ConnectionPool, StorageBackend,
165};
166pub use khive_gate::{
167    classify_operation, is_valid_mailbox_actor_label, split_stamped_label, ActorRef, AllowAllGate,
168    AuditDecision, AuditEvent, CallerEnrollmentGate, Gate, GateContext, GateDecision, GateError,
169    GateRef, GateRequest, MailboxPolicyError, MailboxReadGate, Obligation, OperationAccess,
170    CLASSIFIED_OPERATIONS, OPERATION_CLASSIFIER_VERSION, RUNTIME_STAMPED_ACTOR_KINDS,
171};
172pub use khive_storage::types::TraversalOptions;
173pub use khive_storage::{EventObservation, EventView, ObservationRole, ReferentKind};
174pub use khive_types::namespace::Namespace;
175pub use mailbox_view::MailboxView;
176pub use note_create::{effective_create_tags, EffectiveCreateTags};
177pub use objectives::{
178    AmplifiedDecayAwareSalienceObjective, DecayAwareSalienceObjective, GraphProximityObjective,
179    MemoryRecallPipeline, NoteCandidate, RerankerObjective, RetrievalCandidate, RrfFusionObjective,
180    TemporalRecencyObjective, TextRelevanceObjective, VectorSimilarityObjective,
181};
182#[cfg(any(test, feature = "fault-injection"))]
183pub use operations::{
184    arm_entity_compensation_fail_scoped, arm_fts_fail_many_partial_scoped,
185    arm_fts_fail_many_scoped, arm_fts_fail_scoped, arm_prefix_resolve_fail_scoped,
186    arm_rollback_cleanup_fail, arm_vector_fail_after, arm_vector_fail_scoped, FaultInjectionArm,
187};
188pub use operations::{
189    base_entity_endpoint_rules, base_entity_rule_allows, endpoint_matches,
190    hex_prefix_to_uuid_pattern, merge_entry_metadata, uuid_prefix_bounds, ConditionalInsertStage,
191    EdgeEndpointKind, EntityCreateSpec, LinkSpec, NoteCreateSpec, NoteSearchHit, NoteSearchOutcome,
192    PostCommitDegradation, QueryResult, Resolved,
193};
194pub use pack::{
195    resolve_explicit_namespace, ChannelIngestCapability, DispatchHook, HandlerDef,
196    IdResolutionMode, IngestAuditStore, InterceptedDispatchResult, KindHook, NoteEmbeddingPolicy,
197    NoteEmbeddingPolicySpec, NoteKindSpec, NoteLifecycleSpec, NoteUpdateEffect, PackByIdResolver,
198    PackFactory, PackInstall, PackLoadError, PackMetadataRegistry, PackRegistration, PackRegistry,
199    PackRuntime, PackSchemaCollisionError, PackSchemaPlan, ParamDef, RequestIdentity, SchemaPlan,
200    VerbCategory, VerbPresentationPolicy, VerbRegistry, VerbRegistryBuilder, VerifiedActor,
201    Visibility, AUDIT_PERSISTENCE_SKIPPED_READ_ONLY,
202};
203pub use params::deser_params;
204pub use phase_events::{emit_phase_event, is_benign_shutdown_cancellation};
205pub use portability::{ImportSummary, KgArchive};
206pub use preference_verification::{LegacyPreferenceVerifier, VerifiedModelNetworkAttachment};
207pub use presentation::{
208    apply_redundancy_drop, micros_to_iso, prepare_format_value, present, present_with_policy,
209    render_format, rfc3339_to_utc_micros, OutputFormat, PresentationMode, RedundancyScope,
210};
211pub use reference_resolution::{
212    resolve_reference, resolve_reference_with_entity_type, ReferenceCandidate, ReferenceResolution,
213};
214pub use reference_ring::{ReferenceRing, RingEntry};
215pub use registry::{ObjectiveRegistry, RegisteredObjective};
216pub use resource::{cpu_delta_us, process_resource_usage, ProcessResourceUsage};
217pub use retrieval::{HybridSearchOutcome, RankScoreKind, SearchHit, SearchSignals, SearchSource};
218pub use runtime::{
219    assert_captured_db_anchor_consistent, assert_db_anchor_consistent, expand_tilde,
220    parse_pack_list, resolve_db_anchor, resolve_project_actor_id, runtime_config_from_khive_config,
221    BackendId, EntityTypeValidatorFn, KhiveRuntime, NamedVectorIdentity, NamespaceToken,
222    NoteMutationHookFn, NoteWriteValidatorFn, OpenedDiagnosticBackend, RuntimeConfig,
223};
224pub use secret_gate::SecretMatch;
225pub use telemetry_config::{
226    TelemetryCarrier, TelemetryChannelConfig, TelemetryConfig, TelemetryFailurePosture,
227    TelemetryPolicy,
228};
229pub use validation::{
230    GraphPatch, GraphSnapshot, RuleFn, RuleId, Severity, ValidationContext, ValidationReport,
231    ValidationRule, Violation,
232};
233
234#[cfg(test)]
235mod mount_config_tests;
236
237pub mod mount_config;
238
239pub mod mounted_verb;