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