Skip to main content

_diffctx/config/
importance.rs

1//! File-importance prior for impact-need scoring.
2//!
3//! For impact needs (callers/dependents of a modified symbol) the match
4//! strength is scaled by I(f) ∈ (0, 1]. The values are fixed from domain
5//! priors, not calibrated to any benchmark, to avoid overfitting feature
6//! engineering to a specific evaluation set.
7//!
8//! Rationale (order-of-magnitude argument):
9//!
10//! * `GENERATED_CAP = 0.10` — Generated code (protobuf clients, ORM models,
11//!   openapi stubs, generated TypeScript types) is mechanically derived from
12//!   a schema; its presence among callers carries no human-intent signal.
13//!   We do not zero it out because schema changes do propagate via generated
14//!   code (a real but rare signal); 0.10 leaves a tenth-order trace.
15//!
16//! * `PERIPHERAL_CAP = 0.15` — Peripheral files (examples/, demo/, vendor/,
17//!   fixtures/, tutorials/, docs/) reference symbols but represent
18//!   demonstration usage rather than production consumption. The value is
19//!   slightly above generated because peripheral code is human-authored and
20//!   may signal intended-usage patterns; the gap is principled, not tuned.
21//!
22//! * `DEFAULT_IMPORTANCE = 1.0` — All other files retain full match
23//!   strength; no downward adjustment without positive evidence.
24//!
25//! Order-of-magnitude bounds: the cap must be ≪ 1 (otherwise peripheral
26//! matches dominate) and > 0 (otherwise schema-impact signal is lost).
27//! Any value in [0.05, 0.25] satisfies this; we pick round numbers.
28//! Sensitivity to ±25%/±50% perturbation should be checked empirically
29//! before reporting any benchmark numbers.
30//!
31//! Not calibrated to any benchmark; sensitivity analysis in paper Appendix.
32
33pub const GENERATED_CAP: f64 = 0.10;
34pub const PERIPHERAL_CAP: f64 = 0.15;
35pub const DEFAULT_IMPORTANCE: f64 = 1.0;
36
37/// Directory names whose files are treated as peripheral (demonstration,
38/// non-production, third-party). Match is case-insensitive on path components.
39pub const PERIPHERAL_DIRS: &[&str] = &[
40    "examples",
41    "example",
42    "demo",
43    "demos",
44    "samples",
45    "sample",
46    "showcase",
47    "docs",
48    "doc",
49    "documentation",
50    "tutorials",
51    "tutorial",
52    "guides",
53    "benchmarks",
54    "benchmark",
55    "perf",
56    "bench",
57    "playground",
58    "sandbox",
59    "scratch",
60    "vendor",
61    "third_party",
62    "third-party",
63    "node_modules",
64    "external",
65    "fixtures",
66    "testdata",
67    "test_data",
68    "test-data",
69    "__fixtures__",
70    "__mocks__",
71    "stories",
72    "__stories__",
73];
74
75/// File-stem prefixes signalling demonstration code (peripheral).
76pub const PERIPHERAL_STEMS: &[&str] = &["example_", "demo_", "sample_"];
77
78/// File-stem suffixes signalling demonstration code (peripheral).
79pub const PERIPHERAL_SUFFIXES: &[&str] = &["_example", "_demo", "_sample"];
80
81/// Directory names whose files are treated as generated (mechanically
82/// derived from a schema or template; carries no human-intent signal).
83pub const GENERATED_DIRS: &[&str] = &[
84    "generated",
85    "__generated__",
86    "auto_generated",
87    "auto-generated",
88    "autogen",
89    "autogenerated",
90    "_generated",
91    ".generated",
92    "gen",
93];