Skip to main content

mdx_rust_core/
lib.rs

1//! Core primitives for the `mdx-rust` CLI.
2//!
3//! `mdx-rust-core` contains the optimizer, hardening engine, safety pipeline,
4//! registry, evaluation, ledger, and audit primitives used by the `mdx-rust`
5//! binary.
6//!
7//! ## Stability contract
8//!
9//! The supported product surface for `0.7.x` is the `mdx-rust` CLI. This crate
10//! is published so the CLI can be installed from crates.io and so advanced
11//! users can inspect the internal data structures, but the library API is not
12//! yet stable. Public items may change before `1.0`.
13//!
14//! The intentionally documented facade is the set of `pub use` exports below.
15//! Module paths are left public for the CLI and tests, but most modules are
16//! hidden from rustdoc because they are implementation detail for now.
17
18#[doc(hidden)]
19pub mod agent_contract;
20#[doc(hidden)]
21pub mod config;
22#[doc(hidden)]
23pub mod eval;
24#[doc(hidden)]
25pub mod evidence;
26#[doc(hidden)]
27pub mod hardening;
28#[doc(hidden)]
29pub mod hooks;
30#[doc(hidden)]
31pub mod ledger;
32#[doc(hidden)]
33pub mod llm;
34#[doc(hidden)]
35pub mod optimizer;
36#[doc(hidden)]
37pub mod policy;
38#[doc(hidden)]
39pub mod refactor;
40#[doc(hidden)]
41pub mod registry;
42#[doc(hidden)]
43pub mod runner;
44#[doc(hidden)]
45pub mod safety_pipeline;
46#[doc(hidden)]
47pub mod security;
48#[doc(hidden)]
49pub mod trace;
50
51/// Agent-facing command contract for safe automation.
52pub use agent_contract::{agent_contract, AgentCommandSpec, AgentWorkflow, MdxAgentContract};
53/// Configuration loading and defaults used by the CLI.
54pub use config::Config;
55/// Dataset and scorer metadata used by optimizer reports.
56pub use eval::{
57    run_behavior_evals, BehaviorCommand, BehaviorCommandRecord, BehaviorEvalReport,
58    BehaviorEvalSpec, EvaluationDataset, EvaluationSample, ScorerMetadata,
59};
60/// Measured evidence artifacts used to gate autonomy. Unstable before `1.0`.
61pub use evidence::{
62    load_latest_evidence, load_latest_evidence_for_root, run_evidence, EvidenceArtifactRef,
63    EvidenceCommandRecord, EvidenceMetric, EvidenceRun, EvidenceRunConfig,
64};
65/// Scoped Rust hardening engine for ordinary Rust modules. Unstable before `1.0`.
66pub use hardening::{
67    run_hardening, HardeningChangeSummary, HardeningConfig, HardeningEvidenceDepth, HardeningMode,
68    HardeningOutcome, HardeningPolicyRecord, HardeningRiskSummary, HardeningRun, HardeningStatus,
69    PolicyFindingMatch, WorkspaceSummary,
70};
71/// Built-in lifecycle hook primitives. These are unstable before `1.0`.
72pub use hooks::{
73    evaluate_builtin_hook, HookAction, HookContext, HookDecision, HookPolicy, HookStage,
74};
75/// Experiment budget and ledger records. These are unstable before `1.0`.
76pub use ledger::{
77    split_dataset, DatasetSplit, ExperimentLedger, OptimizationBudget, PromptVariantRecord,
78};
79/// Optimizer entrypoint and run records. These are unstable before `1.0`.
80pub use optimizer::{
81    mechanical_score, run_optimization, AcceptedEditSummary, AuditPacket, AuditProvenance,
82    Candidate, EditStrategy, ModelProvenance, OptimizationRun, OptimizeConfig, ScoreProvenance,
83};
84/// Structured project policy records used by v0.4 hardening reports.
85pub use policy::{load_project_policy, PolicyCategory, PolicyRule, PolicySeverity, ProjectPolicy};
86/// Plan-first refactor and autonomous orchestration records. Unstable before `1.0`.
87pub use refactor::{
88    apply_refactor_plan_batch, apply_refactor_plan_candidate, build_codebase_map,
89    build_refactor_plan, run_autopilot, AutopilotConfig, AutopilotPass, AutopilotPassStatus,
90    AutopilotRun, AutopilotStatus, CapabilityGate, CodebaseMap, CodebaseMapConfig,
91    CodebaseQualityGrade, CodebaseQualitySummary, EvidenceGrade, EvidenceSignal, EvidenceSummary,
92    RecipeTier, RefactorApplyConfig, RefactorApplyMode, RefactorApplyRun, RefactorApplyStatus,
93    RefactorBatchApplyConfig, RefactorBatchApplyRun, RefactorBatchApplyStatus,
94    RefactorBatchCandidateRun, RefactorCandidate, RefactorCandidateStatus, RefactorImpactSummary,
95    RefactorPlan, RefactorPlanConfig, RefactorRecipe, RefactorRiskLevel, SourceSnapshot,
96    StaleSourceFile, TestCoverageSignal,
97};
98/// Agent registry types used by CLI commands.
99pub use registry::{AgentContract, RegisteredAgent, Registry};
100/// Agent runner result and trace events. These are unstable before `1.0`.
101pub use runner::{run_agent, AgentRunResult, TraceEvent};
102/// Candidate safety pipeline. Direct use is unstable before `1.0`.
103pub use safety_pipeline::{
104    execute_candidate_edit, CandidateExecutionConfig, CandidateExecutionContext,
105    CandidateExecutionOutcome, SafetyRejection, SafetyRejectionKind,
106};
107/// Deterministic static audit reports.
108pub use security::{audit_agent, AuditFinding, AuditSeverity, SecurityAuditReport};
109/// Trace diagnosis records.
110pub use trace::{diagnose_run, FailureKind, FailureSignal, TraceDiagnosis};