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