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