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 model;
17pub mod ordering;
18pub mod parse;
19pub mod paths;
20pub mod pipeline;
21pub mod rename_view;
22pub mod review_session;
23pub mod review_state;
24pub mod shape;
25pub mod stack;
26pub mod tree;
27pub mod worktree;
28
29pub use grouping::GroupingOptions;
30pub use pipeline::{
31    PipelineOutput, StackOutput, resolve_range, run_grouped_pipeline, run_pipeline,
32    run_stack_pipeline,
33};
34pub use review_session::ReviewSession;
35pub use stack::{StackOptions, StackResult};
36
37#[derive(Debug, thiserror::Error)]
38pub enum EngineError {
39    #[error("failed to spawn git: {source}")]
40    GitSpawn {
41        #[source]
42        source: std::io::Error,
43    },
44
45    #[error("{command} exited with {code:?}: {stderr}")]
46    GitCommand {
47        command: String,
48        code: Option<i32>,
49        stderr: String,
50    },
51
52    #[error("diff parse error at line {line}: {msg}")]
53    Parse { line: usize, msg: String },
54
55    #[error(
56        "path is not valid UTF-8 and cannot be serialised to JSON yet: {lossy:?} \
57         (non-UTF-8 path support is deferred)"
58    )]
59    NonUtf8Path { lossy: String },
60
61    #[error("invariant violated: {0}")]
62    Invariant(String),
63
64    #[error("config error in {path}: {msg}")]
65    Config { path: String, msg: String },
66
67    #[error("bad revision range: {0}")]
68    Range(String),
69
70    #[error("grouping backend failed: {0}")]
71    Llm(#[from] differential_llm::LlmError),
72
73    #[error("grouping response unusable: {msg}; response sample: {sample}")]
74    GroupingParse { msg: String, sample: String },
75
76    #[error("grouping cache error at {path}: {source}")]
77    Cache {
78        path: String,
79        #[source]
80        source: std::io::Error,
81    },
82
83    #[error("schema error: {0}")]
84    Schema(#[from] differential_schema::SchemaError),
85}