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
5pub mod actor_identity;
6pub mod agent_lifecycle;
7pub mod ann_registry;
8pub mod atomic_message;
9pub mod atomic_plan;
10pub mod atomic_prepare;
11pub mod atomic_runner;
12pub mod audit_batch;
13pub mod blob;
14pub mod build_info;
15pub mod config;
16pub mod config_ledger;
17pub mod cost_unit;
18pub mod curation;
19pub mod daemon;
20pub mod embedder_registry;
21pub mod engine_config;
22pub mod error;
23pub mod events_split;
24pub mod fusion;
25pub mod graph_traversal;
26mod note_store_guard;
27pub mod objectives;
28pub mod operations;
29pub mod pack;
30pub mod phase_events;
31pub mod portability;
32pub mod preference_verification;
33pub mod presentation;
34pub mod reference_resolution;
35pub mod reference_ring;
36pub mod registry;
37pub mod resource;
38pub mod retrieval;
39pub mod runtime;
40pub mod secret_gate;
41pub(crate) mod secret_gate_finalizer;
42pub mod time_anchor;
43pub use khive_storage::usage;
44pub mod validation;
45
46pub use actor_identity::{actor_is_unattributed, resolve_actor, should_warn_unattributed_actor};
47pub use agent_lifecycle::{
48    apply_transition, spawn_fingerprint, AgentRecord, AgentState, IllegalTransition,
49    TerminalReason, Transition, Trigger,
50};
51pub use atomic_message::{create_notes_atomic, create_notes_atomic_with_report, AtomicNoteSpec};
52pub use atomic_plan::{
53    AddEntityPlan, AddNotePlan, AffectedRowGuard, DeletePlan, GovernanceOp, GovernancePlan,
54    GtdCompletePlan, GtdTransitionPlan, LinkPlan, MergePlan, PlanPredicate, PlanStatement,
55    PostCommitEffect, UpdatePlan,
56};
57pub use atomic_runner::{
58    run_atomic_unit, AtomicOpFailure, AtomicOpPlan, AtomicRunOutcome, AtomicRunnerError,
59    CommittedPostCommitEffects,
60};
61pub use blob::{
62    resolve_blob_store, resolve_blob_store_for_mode, BlobHydrator, GovernedBlobError, VerifiedBlob,
63    DEFAULT_BLOB_HYDRATION_BYTES,
64};
65pub use build_info::{BuildInfo, BUILD_INFO, BUILD_VERSION};
66pub use config::{ann_fresh_tail_enabled_from_env, process_ref_from_env};
67pub use cost_unit::{base_resource_payload, cost_unit_for_dispatch, resource_payload};
68pub use curation::{
69    entity_embedding_text, entity_fts_document, entity_merge_guard_error, note_embedding_text,
70    note_fts_document, validate_entity_merge_floor, ContentMergeStrategy, EdgeListFilter,
71    EdgePatch, EntityDedupMergePolicy, EntityMergeGuard, EntityPatch, MergeEdgeConflictPreimage,
72    MergeEdgePreimage, MergeSummary, MergeTxBudgetReport, MergeTxLimits, NotePatch,
73};
74#[cfg(unix)]
75pub use daemon::{acquire_recovery_lock, pid_path, run_daemon, socket_path, DaemonDispatch};
76pub use daemon::{
77    active_phase_names, background_task_count, daemon_shutdown_token, register_active_phase,
78    track_background_task, DaemonRequestFrame, DaemonResponseFrame, PhaseGuard, PROTOCOL_VERSION,
79};
80pub use embedder_registry::{EmbedderProvider, EmbedderRegistry, LatticeEmbedderProvider};
81pub use engine_config::{
82    config_from_env, BackendConfig, BackendKind, BlobConfig, ConfigError, EngineConfig,
83    GitWriteEntryConfig, GitWriteSectionConfig, KhiveConfig, PackConfig, StorageSectionConfig,
84};
85pub use error::{
86    fts_text_leg_or_err, AdmissionFailureContext, ChannelIngestFailureClass, GuardedWriteFailure,
87    RuntimeError, RuntimeResult, WriterPoolCheckoutTimeoutContext, WRITER_ADMISSION_SCOPE,
88    WRITER_POOL_CHECKOUT_TIMEOUT_STAGE, WRITER_QUEUE_SATURATED_STAGE,
89};
90pub use fusion::FusionStrategy;
91pub use graph_traversal::PathNode;
92pub use khive_db::{
93    checkpoint_once, run_checkpoint_task, run_migrations, CheckpointConfig,
94    CheckpointLifecycleOwner, CheckpointTick, ConnectionPool, StorageBackend,
95};
96pub use khive_gate::{
97    ActorRef, AllowAllGate, AuditDecision, AuditEvent, Gate, GateContext, GateDecision, GateError,
98    GateRef, GateRequest, Obligation,
99};
100pub use khive_storage::types::TraversalOptions;
101pub use khive_storage::{EventObservation, EventView, ObservationRole, ReferentKind};
102pub use khive_types::namespace::Namespace;
103pub use objectives::{
104    AmplifiedDecayAwareSalienceObjective, DecayAwareSalienceObjective, GraphProximityObjective,
105    MemoryRecallPipeline, NoteCandidate, RerankerObjective, RetrievalCandidate, RrfFusionObjective,
106    TemporalRecencyObjective, TextRelevanceObjective, VectorSimilarityObjective,
107};
108#[cfg(any(test, feature = "fault-injection"))]
109pub use operations::{
110    arm_entity_compensation_fail_scoped, arm_fts_fail_many_partial_scoped,
111    arm_fts_fail_many_scoped, arm_fts_fail_scoped, arm_prefix_resolve_fail_scoped,
112    arm_rollback_cleanup_fail, arm_vector_fail_after, arm_vector_fail_scoped, FaultInjectionArm,
113};
114pub use operations::{
115    base_entity_endpoint_rules, base_entity_rule_allows, endpoint_matches,
116    hex_prefix_to_uuid_pattern, merge_entry_metadata, uuid_prefix_bounds, EdgeEndpointKind,
117    EntityCreateSpec, LinkSpec, NoteSearchHit, QueryResult, Resolved,
118};
119pub use pack::{
120    resolve_explicit_namespace, ChannelIngestCapability, DispatchHook, HandlerDef,
121    InterceptedDispatchResult, KindHook, NoteKindSpec, NoteLifecycleSpec, PackByIdResolver,
122    PackFactory, PackInstall, PackLoadError, PackRegistration, PackRegistry, PackRuntime,
123    PackSchemaCollisionError, PackSchemaPlan, ParamDef, RequestIdentity, SchemaPlan, VerbCategory,
124    VerbPresentationPolicy, VerbRegistry, VerbRegistryBuilder, VerifiedActor, Visibility,
125    AUDIT_PERSISTENCE_SKIPPED_READ_ONLY,
126};
127pub use phase_events::{emit_phase_event, is_benign_shutdown_cancellation};
128pub use portability::{ImportSummary, KgArchive};
129pub use preference_verification::{LegacyPreferenceVerifier, VerifiedModelNetworkAttachment};
130pub use presentation::{
131    apply_redundancy_drop, micros_to_iso, present, render_format, rfc3339_to_utc_micros,
132    OutputFormat, PresentationMode,
133};
134pub use reference_resolution::{resolve_reference, ReferenceCandidate, ReferenceResolution};
135pub use reference_ring::{ReferenceRing, RingEntry};
136pub use registry::{ObjectiveRegistry, RegisteredObjective};
137pub use resource::{cpu_delta_us, process_resource_usage, ProcessResourceUsage};
138pub use retrieval::{SearchHit, SearchSource};
139pub use runtime::{
140    assert_captured_db_anchor_consistent, assert_db_anchor_consistent, expand_tilde,
141    parse_pack_list, resolve_db_anchor, resolve_project_actor_id, runtime_config_from_khive_config,
142    BackendId, EntityTypeValidatorFn, KhiveRuntime, NamedVectorIdentity, NamespaceToken,
143    NoteMutationHookFn, NoteWriteValidatorFn, RuntimeConfig,
144};
145pub use secret_gate::SecretMatch;
146pub use validation::{
147    GraphPatch, GraphSnapshot, RuleFn, RuleId, Severity, ValidationContext, ValidationReport,
148    ValidationRule, Violation,
149};