use serde::{Deserialize, Serialize};
use serde_json::Value;
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerElabOptions {
pub namespace_context: String,
pub file_label: String,
pub heartbeat_limit: u64,
pub diagnostic_byte_limit: usize,
}
impl LeanWorkerElabOptions {
#[must_use]
pub fn new() -> Self {
Self::default()
}
#[must_use]
pub fn namespace_context(mut self, namespace: &str) -> Self {
namespace.clone_into(&mut self.namespace_context);
self
}
#[must_use]
pub fn file_label(mut self, label: &str) -> Self {
label.clone_into(&mut self.file_label);
self
}
#[must_use]
pub fn heartbeat_limit(mut self, heartbeats: u64) -> Self {
self.heartbeat_limit = heartbeats;
self
}
#[must_use]
pub fn diagnostic_byte_limit(mut self, bytes: usize) -> Self {
self.diagnostic_byte_limit = bytes;
self
}
}
impl Default for LeanWorkerElabOptions {
fn default() -> Self {
Self {
namespace_context: String::new(),
file_label: "<elaborate>".to_owned(),
heartbeat_limit: lean_toolchain::LEAN_HEARTBEAT_LIMIT_DEFAULT,
diagnostic_byte_limit: lean_toolchain::LEAN_DIAGNOSTIC_BYTE_LIMIT_DEFAULT,
}
}
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerElabResult {
pub success: bool,
pub diagnostics: Vec<LeanWorkerDiagnostic>,
pub truncated: bool,
}
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub enum LeanWorkerKernelStatus {
Checked,
Rejected,
Unavailable,
Unsupported,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerKernelResult {
pub status: LeanWorkerKernelStatus,
pub diagnostics: Vec<LeanWorkerDiagnostic>,
pub truncated: bool,
pub summary: Option<LeanWorkerKernelSummary>,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerKernelSummary {
pub declaration_name: String,
pub kind: String,
pub type_signature: String,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerDiagnostic {
pub severity: String,
pub message: String,
pub file_label: String,
pub line: Option<u32>,
pub column: Option<u32>,
pub end_line: Option<u32>,
pub end_column: Option<u32>,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerElabFailure {
pub diagnostics: Vec<LeanWorkerDiagnostic>,
pub truncated: bool,
}
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub enum LeanWorkerMetaTransparency {
#[default]
Default,
Reducible,
Instances,
All,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerRendered {
pub value: String,
pub rendering: LeanWorkerRendering,
}
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub enum LeanWorkerRendering {
Pretty,
Raw,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(tag = "status", rename_all = "snake_case")]
#[non_exhaustive]
pub enum LeanWorkerMetaResult<T> {
Ok { value: T },
Failed { failure: LeanWorkerElabFailure },
TimeoutOrHeartbeat { failure: LeanWorkerElabFailure },
Unsupported { failure: LeanWorkerElabFailure },
}
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerDeclarationFilter {
pub include_private: bool,
pub include_generated: bool,
pub include_internal: bool,
}
impl Default for LeanWorkerDeclarationFilter {
fn default() -> Self {
Self {
include_private: true,
include_generated: false,
include_internal: false,
}
}
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerSourceRange {
pub file: String,
pub start_line: u32,
pub start_column: u32,
pub end_line: u32,
pub end_column: u32,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerDeclarationRow {
pub name: String,
pub kind: String,
pub type_signature: Option<String>,
pub source: Option<LeanWorkerSourceRange>,
}
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum LeanWorkerDeclarationNameMatch {
#[default]
Contains,
Suffix,
}
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum LeanWorkerDeclarationSearchScope {
Namespace,
Module,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerDeclarationSearchBias {
pub scope: LeanWorkerDeclarationSearchScope,
pub prefix: String,
pub strict: bool,
pub weight: i32,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerDeclarationSearch {
pub name_fragment: Option<String>,
pub name_match: LeanWorkerDeclarationNameMatch,
pub kind: Option<String>,
pub required_constants: Vec<String>,
pub conclusion_head: Option<String>,
pub scope_biases: Vec<LeanWorkerDeclarationSearchBias>,
pub limit: usize,
pub filter: LeanWorkerDeclarationFilter,
pub include_source: bool,
}
impl LeanWorkerDeclarationSearch {
#[must_use]
pub fn new(name_fragment: impl Into<String>) -> Self {
Self {
name_fragment: Some(name_fragment.into()),
name_match: LeanWorkerDeclarationNameMatch::Contains,
kind: None,
required_constants: Vec::new(),
conclusion_head: None,
scope_biases: Vec::new(),
limit: 20,
filter: LeanWorkerDeclarationFilter {
include_private: false,
include_generated: false,
include_internal: false,
},
include_source: true,
}
}
}
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerDeclarationFlags {
pub is_private: bool,
pub is_generated: bool,
pub is_internal: bool,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerDeclarationSearchRow {
pub name: String,
pub kind: String,
pub module: Option<String>,
pub source: Option<LeanWorkerSourceRange>,
pub match_reason: String,
pub score: i32,
pub rank: usize,
pub flags: LeanWorkerDeclarationFlags,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerDeclarationSearchPruning {
pub stage: String,
pub reason: String,
pub count: usize,
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerDeclarationSearchTimings {
pub scan_micros: u64,
pub rank_micros: u64,
pub source_micros: u64,
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerDeclarationSearchFacts {
pub declarations_scanned: usize,
pub after_name_filter: usize,
pub after_kind_filter: usize,
pub after_required_constants_filter: usize,
pub after_conclusion_filter: usize,
pub after_scope_filter: usize,
pub source_lookups: usize,
pub broad_pruning: Vec<LeanWorkerDeclarationSearchPruning>,
pub truncated: bool,
pub timings: LeanWorkerDeclarationSearchTimings,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerDeclarationSearchResult {
pub declarations: Vec<LeanWorkerDeclarationSearchRow>,
pub truncated: bool,
pub facts: LeanWorkerDeclarationSearchFacts,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerDeclarationType {
pub name: String,
pub kind: String,
pub type_signature: Option<LeanWorkerRenderedInfo>,
pub source: Option<LeanWorkerSourceRange>,
}
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[allow(
clippy::struct_excessive_bools,
reason = "wire field-selection flags mirror the Lean request shape and are clearer than five tiny enums"
)]
pub struct LeanWorkerDeclarationInspectionFields {
pub source: bool,
pub statement: bool,
pub docstring: bool,
pub attributes: bool,
pub flags: bool,
#[serde(default = "rendering_pretty")]
pub rendering: LeanWorkerRendering,
}
fn rendering_pretty() -> LeanWorkerRendering {
LeanWorkerRendering::Pretty
}
impl Default for LeanWorkerDeclarationInspectionFields {
fn default() -> Self {
Self {
source: true,
statement: true,
docstring: true,
attributes: true,
flags: true,
rendering: LeanWorkerRendering::Pretty,
}
}
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerDeclarationInspectionRequest {
pub name: String,
pub fields: LeanWorkerDeclarationInspectionFields,
pub budgets: LeanWorkerOutputBudgets,
}
impl LeanWorkerDeclarationInspectionRequest {
#[must_use]
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
fields: LeanWorkerDeclarationInspectionFields::default(),
budgets: LeanWorkerOutputBudgets::default(),
}
}
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
#[allow(
clippy::struct_excessive_bools,
reason = "proof-search booleans are independent wire facts, not control-flow state"
)]
pub struct LeanWorkerDeclarationProofSearchFacts {
pub is_simp: bool,
pub is_rw_candidate: bool,
pub is_instance: bool,
pub is_class: bool,
pub class_name: Option<String>,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerDeclarationInspection {
pub name: String,
pub kind: String,
pub module: Option<String>,
pub source: Option<LeanWorkerSourceRange>,
pub statement: Option<LeanWorkerRenderedInfo>,
pub docstring: Option<LeanWorkerRenderedInfo>,
pub attributes: Vec<String>,
pub proof_search: LeanWorkerDeclarationProofSearchFacts,
pub flags: LeanWorkerDeclarationFlags,
#[serde(default)]
pub statement_rendering: Option<LeanWorkerRendering>,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(tag = "status", rename_all = "snake_case")]
#[non_exhaustive]
pub enum LeanWorkerDeclarationInspectionResult {
Found {
declaration: Box<LeanWorkerDeclarationInspection>,
},
NotFound {
name: String,
},
Unsupported,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerNameRef {
pub start_line: u32,
pub start_column: u32,
pub end_line: u32,
pub end_column: u32,
pub name: String,
pub is_binder: bool,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(tag = "query", rename_all = "snake_case")]
#[non_exhaustive]
pub enum LeanWorkerModuleQuery {
Diagnostics,
TypeAt { line: u32, column: u32 },
GoalAt { line: u32, column: u32 },
References { name: String },
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerOutputBudgets {
pub per_field_bytes: u32,
pub total_bytes: u32,
}
impl Default for LeanWorkerOutputBudgets {
fn default() -> Self {
Self {
per_field_bytes: 8 * 1024,
total_bytes: 64 * 1024,
}
}
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(tag = "selector", rename_all = "snake_case")]
#[non_exhaustive]
pub enum LeanWorkerModuleQuerySelector {
Diagnostics {
id: String,
},
ProofState {
id: String,
line: u32,
column: u32,
},
ProofStateInDeclaration {
id: String,
declaration: String,
position: LeanWorkerProofPositionSelector,
},
TypeAt {
id: String,
line: u32,
column: u32,
},
References {
id: String,
name: String,
},
DeclarationTarget {
id: String,
name: Option<String>,
line: Option<u32>,
column: Option<u32>,
},
SurroundingDeclaration {
id: String,
line: u32,
column: u32,
},
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerModuleSourceSpan {
pub start_line: u32,
pub start_column: u32,
pub end_line: u32,
pub end_column: u32,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerRenderedInfo {
pub value: String,
pub truncated: bool,
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
#[serde(tag = "kind", rename_all = "snake_case")]
#[non_exhaustive]
pub enum LeanWorkerProofPositionSelector {
#[default]
Default,
Index { index: u32 },
AfterText {
text: String,
#[serde(default)]
occurrence: Option<u32>,
},
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(tag = "kind", rename_all = "snake_case")]
#[non_exhaustive]
pub enum LeanWorkerProofEditTarget {
Declaration {
name: String,
#[serde(default)]
position: LeanWorkerProofPositionSelector,
},
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerProofCandidate {
pub id: String,
pub text: String,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerProofAttemptRequest {
pub source: String,
pub edit: LeanWorkerProofEditTarget,
pub candidates: Vec<LeanWorkerProofCandidate>,
pub budgets: LeanWorkerOutputBudgets,
}
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub enum LeanWorkerProofAttemptStatus {
Closed,
Progressed,
Failed,
Timeout,
BudgetExceeded,
Unsupported,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerProofAttemptRow {
pub id: String,
pub status: LeanWorkerProofAttemptStatus,
pub candidate_text: LeanWorkerRenderedInfo,
pub diagnostics: LeanWorkerElabFailure,
pub downstream_diagnostics: LeanWorkerElabFailure,
pub goals: Vec<LeanWorkerRenderedInfo>,
pub declaration: Option<LeanWorkerDeclarationTargetInfo>,
pub proof_position: Option<LeanWorkerProofPositionSummary>,
pub output_truncated: bool,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerProofPositionSummary {
pub index: u32,
pub tactic: LeanWorkerRenderedInfo,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerProofAttemptEnvelope {
pub candidates: Vec<LeanWorkerProofAttemptRow>,
pub candidate_limit: u32,
pub candidates_truncated: bool,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(tag = "status", rename_all = "snake_case")]
#[non_exhaustive]
pub enum LeanWorkerProofAttemptResult {
Ok {
result: LeanWorkerProofAttemptEnvelope,
imports: Vec<String>,
},
MissingImports {
result: LeanWorkerProofAttemptEnvelope,
imports: Vec<String>,
missing: Vec<String>,
},
HeaderParseFailed {
diagnostics: LeanWorkerElabFailure,
},
Unsupported,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(tag = "kind", rename_all = "snake_case")]
#[non_exhaustive]
pub enum LeanWorkerDeclarationVerificationTarget {
Name { name: String },
Span { span: LeanWorkerModuleSourceSpan },
}
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub enum LeanWorkerSorryPolicy {
Allow,
Deny,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerDeclarationVerificationRequest {
pub source: String,
pub target: LeanWorkerDeclarationVerificationTarget,
pub sorry_policy: LeanWorkerSorryPolicy,
pub report_axioms: bool,
pub budgets: LeanWorkerOutputBudgets,
}
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub enum LeanWorkerDeclarationVerificationStatus {
Accepted,
Rejected,
NotFound,
Ambiguous,
Timeout,
BudgetExceeded,
Unsupported,
NeedsBuild,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[allow(
clippy::struct_excessive_bools,
reason = "verification booleans are independent wire facts for policy decisions"
)]
pub struct LeanWorkerDeclarationVerificationFacts {
pub target: Option<LeanWorkerDeclarationTargetInfo>,
pub diagnostics: LeanWorkerElabFailure,
pub unresolved_goals: Vec<LeanWorkerRenderedInfo>,
pub contains_sorry: bool,
pub contains_admit: bool,
pub contains_sorry_ax: bool,
pub axioms: Vec<String>,
pub axioms_truncated: bool,
pub output_truncated: bool,
#[serde(default)]
pub candidates: Vec<LeanWorkerDeclarationTargetInfo>,
#[serde(default)]
pub axioms_available: bool,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(tag = "status", rename_all = "snake_case")]
#[non_exhaustive]
pub enum LeanWorkerDeclarationVerificationResult {
Ok {
verification_status: LeanWorkerDeclarationVerificationStatus,
facts: Box<LeanWorkerDeclarationVerificationFacts>,
imports: Vec<String>,
},
MissingImports {
verification_status: LeanWorkerDeclarationVerificationStatus,
facts: Box<LeanWorkerDeclarationVerificationFacts>,
imports: Vec<String>,
missing: Vec<String>,
},
HeaderParseFailed {
diagnostics: LeanWorkerElabFailure,
},
Unsupported,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(tag = "status", rename_all = "snake_case")]
#[non_exhaustive]
pub enum LeanWorkerTypeAtResult {
Term {
span: LeanWorkerModuleSourceSpan,
expr: LeanWorkerRenderedInfo,
type_str: LeanWorkerRenderedInfo,
expected_type: Option<LeanWorkerRenderedInfo>,
},
NoTerm,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(tag = "status", rename_all = "snake_case")]
#[non_exhaustive]
pub enum LeanWorkerGoalAtResult {
Goal {
span: LeanWorkerModuleSourceSpan,
goals_before: Vec<String>,
goals_after: Vec<String>,
truncated: bool,
},
NoTacticContext,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerReferencesResult {
pub references: Vec<LeanWorkerNameRef>,
pub truncated: bool,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerLocalInfo {
pub name: String,
pub binder_info: String,
pub type_str: LeanWorkerRenderedInfo,
pub value: Option<LeanWorkerRenderedInfo>,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerDeclarationTargetInfo {
pub short_name: String,
pub declaration_name: String,
pub namespace_name: String,
pub declaration_kind: String,
pub declaration_span: LeanWorkerModuleSourceSpan,
pub name_span: LeanWorkerModuleSourceSpan,
pub body_span: LeanWorkerModuleSourceSpan,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(tag = "status", rename_all = "snake_case")]
#[non_exhaustive]
pub enum LeanWorkerDeclarationTargetResult {
Target {
info: LeanWorkerDeclarationTargetInfo,
},
NotFound,
Ambiguous {
candidates: Vec<LeanWorkerDeclarationTargetInfo>,
},
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerProofStateInfo {
pub declaration_name: Option<String>,
pub namespace_name: String,
pub safe_edit: Option<LeanWorkerDeclarationTargetInfo>,
pub span: LeanWorkerModuleSourceSpan,
pub goals_before: Vec<String>,
pub goals_after: Vec<String>,
pub locals: Vec<LeanWorkerLocalInfo>,
pub expected_type: Option<LeanWorkerRenderedInfo>,
pub truncated: bool,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(tag = "status", rename_all = "snake_case")]
#[non_exhaustive]
pub enum LeanWorkerProofStateResult {
State {
info: Box<LeanWorkerProofStateInfo>,
},
Unavailable {
message: String,
},
Ambiguous {
candidates: Vec<LeanWorkerDeclarationTargetInfo>,
},
NeedsBuild {
missing: Vec<String>,
},
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(tag = "status", rename_all = "snake_case")]
#[non_exhaustive]
pub enum LeanWorkerSurroundingDeclarationResult {
Declaration { info: LeanWorkerDeclarationTargetInfo },
None,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(tag = "result", content = "body", rename_all = "snake_case")]
#[non_exhaustive]
pub enum LeanWorkerModuleQueryResult {
Diagnostics(LeanWorkerElabFailure),
TypeAt(LeanWorkerTypeAtResult),
GoalAt(LeanWorkerGoalAtResult),
References(LeanWorkerReferencesResult),
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(tag = "result", content = "body", rename_all = "snake_case")]
#[non_exhaustive]
pub enum LeanWorkerModuleQueryBatchResult {
Diagnostics(LeanWorkerElabFailure),
ProofState(LeanWorkerProofStateResult),
TypeAt(LeanWorkerTypeAtResult),
References(LeanWorkerReferencesResult),
DeclarationTarget(LeanWorkerDeclarationTargetResult),
SurroundingDeclaration(LeanWorkerSurroundingDeclarationResult),
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(tag = "status", rename_all = "snake_case")]
#[non_exhaustive]
pub enum LeanWorkerModuleQueryBatchItem {
Ok {
id: String,
result: Box<LeanWorkerModuleQueryBatchResult>,
},
Unavailable {
id: String,
message: String,
},
BudgetExceeded {
id: String,
message: String,
},
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerModuleQueryBatchEnvelope {
pub items: Vec<LeanWorkerModuleQueryBatchItem>,
pub total_truncated: bool,
}
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub enum LeanWorkerModuleCacheStatus {
Hit,
Miss,
Rebuilt,
Evicted,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerModuleQueryTimings {
pub header_import_micros: u64,
pub elaboration_micros: u64,
pub projection_micros: u64,
pub rendering_micros: u64,
}
impl LeanWorkerModuleQueryTimings {
#[must_use]
pub fn zero() -> Self {
Self {
header_import_micros: 0,
elaboration_micros: 0,
projection_micros: 0,
rendering_micros: 0,
}
}
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerModuleQueryCacheFacts {
pub cache_status: LeanWorkerModuleCacheStatus,
pub timings: LeanWorkerModuleQueryTimings,
pub output_bytes: u64,
pub cache_entry_count: Option<u64>,
pub cache_approx_bytes: Option<u64>,
}
impl LeanWorkerModuleQueryCacheFacts {
#[must_use]
pub fn uncached(output_bytes: u64) -> Self {
Self {
cache_status: LeanWorkerModuleCacheStatus::Miss,
timings: LeanWorkerModuleQueryTimings::zero(),
output_bytes,
cache_entry_count: None,
cache_approx_bytes: None,
}
}
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerModuleSnapshotCacheClearResult {
pub entries_cleared: u64,
pub approx_bytes_cleared: u64,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(tag = "status", rename_all = "snake_case")]
#[non_exhaustive]
pub enum LeanWorkerModuleQueryOutcome {
Ok {
result: LeanWorkerModuleQueryResult,
imports: Vec<String>,
},
MissingImports {
result: LeanWorkerModuleQueryResult,
imports: Vec<String>,
missing: Vec<String>,
},
HeaderParseFailed { diagnostics: LeanWorkerElabFailure },
Unsupported,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(tag = "status", rename_all = "snake_case")]
#[non_exhaustive]
pub enum LeanWorkerModuleQueryBatchOutcome {
Ok {
result: LeanWorkerModuleQueryBatchEnvelope,
imports: Vec<String>,
facts: LeanWorkerModuleQueryCacheFacts,
},
MissingImports {
result: LeanWorkerModuleQueryBatchEnvelope,
imports: Vec<String>,
missing: Vec<String>,
facts: LeanWorkerModuleQueryCacheFacts,
},
HeaderParseFailed {
diagnostics: LeanWorkerElabFailure,
facts: LeanWorkerModuleQueryCacheFacts,
},
Unsupported,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerCapabilityMetadata {
pub commands: Vec<LeanWorkerCommandMetadata>,
pub capabilities: Vec<LeanWorkerCapabilityFact>,
pub lean_version: Option<String>,
pub extra: Option<Value>,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerCommandMetadata {
pub name: String,
pub version: String,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerCapabilityFact {
pub name: String,
pub version: String,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerDoctorReport {
pub diagnostics: Vec<LeanWorkerDoctorDiagnostic>,
pub metadata: Option<Value>,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct LeanWorkerDoctorDiagnostic {
pub severity: LeanWorkerDoctorSeverity,
pub code: String,
pub message: String,
pub details: Option<Value>,
}
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub enum LeanWorkerDoctorSeverity {
Pass,
Warning,
Error,
}