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