diffctx 1.12.1

Selects the minimum code an LLM needs to review a git diff: walks the dependency graph outward from changed lines and stops when extra context stops paying for itself
Documentation
//! File-importance prior for impact-need scoring.
//!
//! For impact needs (callers/dependents of a modified symbol) the match
//! strength is scaled by I(f) ∈ (0, 1]. The values are fixed from domain
//! priors, not calibrated to any benchmark, to avoid overfitting feature
//! engineering to a specific evaluation set.
//!
//! Rationale (order-of-magnitude argument):
//!
//! * `GENERATED_CAP = 0.10` — Generated code (protobuf clients, ORM models,
//!   openapi stubs, generated TypeScript types) is mechanically derived from
//!   a schema; its presence among callers carries no human-intent signal.
//!   We do not zero it out because schema changes do propagate via generated
//!   code (a real but rare signal); 0.10 leaves a tenth-order trace.
//!
//! * `PERIPHERAL_CAP = 0.15` — Peripheral files (examples/, demo/, vendor/,
//!   fixtures/, tutorials/, docs/) reference symbols but represent
//!   demonstration usage rather than production consumption. The value is
//!   slightly above generated because peripheral code is human-authored and
//!   may signal intended-usage patterns; the gap is principled, not tuned.
//!
//! * `DEFAULT_IMPORTANCE = 1.0` — All other files retain full match
//!   strength; no downward adjustment without positive evidence.
//!
//! Order-of-magnitude bounds: the cap must be ≪ 1 (otherwise peripheral
//! matches dominate) and > 0 (otherwise schema-impact signal is lost).
//! Any value in [0.05, 0.25] satisfies this; we pick round numbers.
//! Sensitivity to ±25%/±50% perturbation should be checked empirically
//! before reporting any benchmark numbers.
//!
//! Not calibrated to any benchmark; sensitivity analysis in paper Appendix.

pub const GENERATED_CAP: f64 = 0.10;
pub const PERIPHERAL_CAP: f64 = 0.15;
pub const DEFAULT_IMPORTANCE: f64 = 1.0;

/// Directory names whose files are treated as peripheral (demonstration,
/// non-production, third-party). Match is case-insensitive on path components.
pub const PERIPHERAL_DIRS: &[&str] = &[
    "examples",
    "example",
    "demo",
    "demos",
    "samples",
    "sample",
    "showcase",
    "docs",
    "doc",
    "documentation",
    "tutorials",
    "tutorial",
    "guides",
    "benchmarks",
    "benchmark",
    "perf",
    "bench",
    "playground",
    "sandbox",
    "scratch",
    "vendor",
    "third_party",
    "third-party",
    "node_modules",
    "external",
    "fixtures",
    "testdata",
    "test_data",
    "test-data",
    "__fixtures__",
    "__mocks__",
    "stories",
    "__stories__",
];

/// File-stem prefixes signalling demonstration code (peripheral).
pub const PERIPHERAL_STEMS: &[&str] = &["example_", "demo_", "sample_"];

/// File-stem suffixes signalling demonstration code (peripheral).
pub const PERIPHERAL_SUFFIXES: &[&str] = &["_example", "_demo", "_sample"];

/// Directory names whose files are treated as generated (mechanically
/// derived from a schema or template; carries no human-intent signal).
pub const GENERATED_DIRS: &[&str] = &[
    "generated",
    "__generated__",
    "auto_generated",
    "auto-generated",
    "autogen",
    "autogenerated",
    "_generated",
    ".generated",
    "gen",
];