1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//! Configuration and limits for the diff sampler.
//!
//! Why: how many diffs to sample and where the repositories live are per-run
//! choices, and threading them through as positional arguments would force a
//! signature change every time a knob is added.
//! What: defines [`DiffSamplerConfig`] plus the [`MAX_DIFF_CHARS`] and
//! [`DEFAULT_MAX_DIFFS`] limits.
//! Test: `config_repo_path_resolution`.
use HashMap;
use PathBuf;
/// Maximum characters of diff text kept per sampled commit.
///
/// Why: one unusually large commit would otherwise consume the whole context
/// budget a period gets, crowding out every other diff in that period.
/// What: 20,000 UTF-8 characters, roughly 5–10K tokens. This sits above tga's
/// own `DIFF_BYTE_CAP`, which `diff_for_commit` applies first — this is the
/// second, profile-layer limit.
/// Test: `diff_sampler_truncates_long_diff`.
pub const MAX_DIFF_CHARS: usize = 20_000;
/// Default number of diffs sampled per period.
///
/// Five is enough for qualitative coverage without a period's token cost
/// scaling with how busy that period happened to be. Override via
/// [`DiffSamplerConfig::max_diffs`].
///
/// Test: `config_repo_path_resolution`.
pub const DEFAULT_MAX_DIFFS: usize = 5;
/// Per-run diff-sampler settings.
///
/// Why: the database records a repository *name*, but `diff_for_commit` needs a
/// local path — and only the caller knows where the clones are.
/// What: the per-period cap plus two ways to answer "where is this repository":
/// an explicit `repo_paths` entry, or `repos_root` joined with the name.
/// Test: `config_repo_path_resolution`.