#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct EngineInfo {
pub version: &'static str,
pub snapshot_format_version: u32,
pub secret_policy_version: u32,
pub grammars: &'static [&'static str],
}
pub fn engine_info() -> EngineInfo {
const GRAMMAR_NAMES: [&str; crate::domain::LanguageId::ALL.len()] = {
let mut names = [""; crate::domain::LanguageId::ALL.len()];
let mut i = 0;
while i < crate::domain::LanguageId::ALL.len() {
names[i] = crate::domain::LanguageId::ALL[i].name();
i += 1;
}
names
};
EngineInfo {
version: env!("CARGO_PKG_VERSION"),
snapshot_format_version: crate::live_index::persist::SNAPSHOT_FORMAT_VERSION,
secret_policy_version: crate::knowledge::SECRET_POLICY_VERSION,
grammars: &GRAMMAR_NAMES,
}
}
pub use crate::index_lifecycle::embedded::SourceCloseReceipt;
pub use crate::index_lifecycle::embedded::{EmbeddedSourceHandle, ReceiptWaitError};
pub use crate::index_lifecycle::public_api::{
CensusFile, CensusParseStatus, CensusVerifyPhase, EmbedAtomicAuthority as AtomicAuthority,
EmbedClaim as Claim, EmbedClaimProvenance as ClaimProvenance,
EmbedEvaluationProvenance as EvaluationProvenance, EmbedOperationReceipt as OperationReceipt,
EmbedRefreshTicket as RefreshTicket, EmbedShutdownReceipt as ShutdownReceipt,
EmbedSourceRefusal as SourceRefusal, EmbeddedSourceSpec, IndexCensus, IndexProgress,
KnowledgeMatch, KnowledgeSearchRequest, KnowledgeSearchResult, OperationKind,
ProcessRuntimeApi as ProcessIndexRuntime, RetryAdvice, ShutdownReport, SourceCloseReport,
SourceRefusalKind, SourceRuntimePhase, SourceRuntimeView, SymbolMatch, SymbolSearchRequest,
SymbolSearchResult, TextMatch, TextSearchRequest, TextSearchResult,
};
pub(crate) mod lifecycle {
pub(crate) use crate::index_lifecycle::{
embed_edit_body, embed_federation, embed_host, embed_query, embed_session, guidance,
public_api,
};
}
pub mod parity;
#[cfg(test)]
mod contract {
#[allow(unused_imports)]
use crate::embed::{
AtomicAuthority, CensusFile, CensusParseStatus, CensusVerifyPhase, Claim, ClaimProvenance,
EmbeddedSourceHandle, EmbeddedSourceSpec, EngineInfo, EvaluationProvenance, IndexCensus,
IndexProgress, KnowledgeMatch, KnowledgeSearchRequest, KnowledgeSearchResult,
OperationKind, OperationReceipt, ProcessIndexRuntime, ReceiptWaitError, RefreshTicket,
RetryAdvice, ShutdownReceipt, ShutdownReport, SourceCloseReceipt, SourceCloseReport,
SourceRefusal, SourceRefusalKind, SourceRuntimePhase, SourceRuntimeView, SymbolMatch,
SymbolSearchRequest, SymbolSearchResult, TextMatch, TextSearchRequest, TextSearchResult,
engine_info,
};
#[test]
fn facade_contract_is_stable() {
fn _assert_named<T>() {}
_assert_named::<AtomicAuthority>();
_assert_named::<CensusFile>();
_assert_named::<CensusParseStatus>();
_assert_named::<CensusVerifyPhase>();
let _reference_count: fn(&CensusFile) -> u32 = |file| file.reference_count;
let _parse_status: fn(&CensusFile) -> CensusParseStatus = |file| file.parse_status;
let _snapshot_verify: fn(&IndexCensus) -> CensusVerifyPhase =
|census| census.snapshot_verify;
let _reserve_with_lease: fn(
&crate::embed::parity::replay::ReplayStore,
&crate::embed::parity::replay::ReplayKey,
&crate::embed::parity::replay::RequestFingerprint,
std::time::Duration,
) -> Result<
crate::embed::parity::replay::ReserveOutcome,
crate::embed::parity::replay::ReplayError,
> = crate::embed::parity::replay::ReplayStore::reserve_with_lease;
let _lease_remaining: fn(
&crate::embed::parity::replay::ReplayStore,
&crate::embed::parity::replay::ReplayKey,
) -> Result<
Option<std::time::Duration>,
crate::embed::parity::replay::ReplayError,
> = crate::embed::parity::replay::ReplayStore::lease_remaining;
let _took_over: fn(&crate::embed::parity::replay::OwnerLease) -> bool =
crate::embed::parity::replay::OwnerLease::took_over;
let _response_digest: fn(&crate::embed::parity::replay::ReplayOutcome) -> &str =
crate::embed::parity::replay::ReplayOutcome::response_digest;
let _from_embedder_digest: fn(
crate::embed::parity::replay::OutcomeKind,
usize,
&str,
&[u8],
) -> Result<
crate::embed::parity::replay::ReplayOutcome,
crate::embed::parity::replay::ReplayError,
> = crate::embed::parity::replay::ReplayOutcome::from_embedder_digest;
let _mark_started_with_lease: fn(
&crate::embed::parity::replay::ReplayStore,
&crate::embed::parity::replay::OwnerLease,
std::time::Duration,
) -> Result<
crate::embed::parity::replay::ReplayRecord,
crate::embed::parity::replay::ReplayError,
> = crate::embed::parity::replay::ReplayStore::mark_started_with_lease;
let _uncertain_since: fn(
&crate::embed::parity::replay::ReplayRecord,
) -> Option<std::time::SystemTime> =
crate::embed::parity::replay::ReplayRecord::uncertain_since;
let _ = (
_reference_count,
_parse_status,
_snapshot_verify,
_reserve_with_lease,
_lease_remaining,
_took_over,
_response_digest,
_from_embedder_digest,
_mark_started_with_lease,
_uncertain_since,
);
_assert_named::<Claim<u64>>();
_assert_named::<ClaimProvenance>();
_assert_named::<EmbeddedSourceHandle>();
_assert_named::<EmbeddedSourceSpec>();
_assert_named::<EvaluationProvenance>();
_assert_named::<IndexCensus>();
_assert_named::<IndexProgress>();
_assert_named::<KnowledgeMatch>();
_assert_named::<KnowledgeSearchRequest>();
_assert_named::<KnowledgeSearchResult>();
_assert_named::<OperationKind>();
_assert_named::<OperationReceipt>();
_assert_named::<ProcessIndexRuntime>();
_assert_named::<ReceiptWaitError>();
_assert_named::<RefreshTicket>();
_assert_named::<RetryAdvice>();
_assert_named::<ShutdownReceipt>();
_assert_named::<ShutdownReport>();
_assert_named::<SourceCloseReceipt>();
_assert_named::<SourceCloseReport>();
_assert_named::<SourceRefusal>();
_assert_named::<SourceRefusalKind>();
_assert_named::<SourceRuntimePhase>();
_assert_named::<SourceRuntimeView>();
_assert_named::<SymbolMatch>();
_assert_named::<SymbolSearchRequest>();
_assert_named::<SymbolSearchResult>();
_assert_named::<TextMatch>();
_assert_named::<TextSearchRequest>();
_assert_named::<TextSearchResult>();
let _acquire: fn() -> Result<ProcessIndexRuntime, SourceRefusal> =
ProcessIndexRuntime::acquire;
let _open: fn(
&ProcessIndexRuntime,
EmbeddedSourceSpec,
) -> Result<EmbeddedSourceHandle, SourceRefusal> =
ProcessIndexRuntime::open_embedded_source;
let _spec: fn(std::path::PathBuf) -> EmbeddedSourceSpec =
EmbeddedSourceSpec::current_worktree;
let _engine_info: fn() -> EngineInfo = engine_info;
let _census: fn(&EmbeddedSourceHandle) -> Result<Claim<IndexCensus>, SourceRefusal> =
EmbeddedSourceHandle::index_census;
let _progress: fn(&EmbeddedSourceHandle) -> IndexProgress =
EmbeddedSourceHandle::index_progress;
let _knowledge: fn(
&EmbeddedSourceHandle,
&KnowledgeSearchRequest,
) -> Result<Claim<KnowledgeSearchResult>, SourceRefusal> =
EmbeddedSourceHandle::search_knowledge;
let _ = (
_acquire,
_open,
_spec,
_engine_info,
_census,
_progress,
_knowledge,
);
let info = crate::embed::engine_info();
assert!(!info.version.is_empty());
assert_eq!(
info.grammars.len(),
crate::domain::LanguageId::ALL.len(),
"every grammar is reported"
);
assert!(info.grammars.contains(&"rust"));
assert!(info.snapshot_format_version >= 7);
}
}