Skip to main content

differential_engine/
lib.rs

1//! Core engine: git io, diff parsing, byte-exact apply, shape classes,
2//! invariants, and plan-document assembly.
3//!
4//! The canonical enumeration (`git diff -U0 --no-renames`) processes every file
5//! with no exclusions (ADR 0005); the rename-detected view (`-M`) only annotates
6//! it (ADR 0003). Repo config tunes classification hints and can never remove
7//! anything from enumeration (ADR 0012).
8
9pub mod apply;
10pub mod config;
11pub mod document;
12pub mod gitio;
13pub mod grouping;
14pub mod invariants;
15pub mod lang;
16pub mod llm;
17pub mod model;
18pub mod ordering;
19pub mod parse;
20pub mod paths;
21pub mod pipeline;
22pub mod plan;
23pub mod ports;
24pub mod rename_view;
25pub mod review_session;
26pub mod review_state;
27pub mod schema;
28pub mod shape;
29pub mod store;
30pub mod tree;
31pub mod worktree;
32
33pub use grouping::GroupingOptions;
34pub use pipeline::{PipelineOutput, resolve_range, run_grouped_pipeline, run_pipeline};
35pub use review_session::ReviewSession;
36
37/// The production session: a review over the on-disk sidecar. Renderers name
38/// this one concrete type rather than carrying a generic parameter for a
39/// choice they never make.
40pub type FsReviewSession = ReviewSession<store::FsReviewStore>;
41
42#[derive(Debug, thiserror::Error)]
43pub enum EngineError {
44    #[error("failed to spawn git: {source}")]
45    GitSpawn {
46        #[source]
47        source: std::io::Error,
48    },
49
50    #[error("{command} exited with {code:?}: {stderr}")]
51    GitCommand {
52        command: String,
53        code: Option<i32>,
54        stderr: String,
55    },
56
57    #[error("diff parse error at line {line}: {msg}")]
58    Parse { line: usize, msg: String },
59
60    #[error(
61        "path is not valid UTF-8 and cannot be serialised to JSON yet: {lossy:?} \
62         (non-UTF-8 path support is deferred)"
63    )]
64    NonUtf8Path { lossy: String },
65
66    #[error("invariant violated: {0}")]
67    Invariant(String),
68
69    #[error("plan document is inconsistent: {0}")]
70    PlanIntegrity(String),
71
72    #[error("config error in {path}: {msg}")]
73    Config { path: String, msg: String },
74
75    #[error("bad revision range: {0}")]
76    Range(String),
77
78    #[error("grouping backend failed: {0}")]
79    Llm(#[from] crate::llm::LlmError),
80
81    #[error("grouping response unusable: {msg}; response sample: {sample}")]
82    GroupingParse { msg: String, sample: String },
83
84    #[error("grouping cache error at {path}: {source}")]
85    Cache {
86        path: String,
87        #[source]
88        source: std::io::Error,
89    },
90
91    #[error("schema error: {0}")]
92    Schema(#[from] crate::schema::SchemaError),
93}