brygge_decode_git/options.rs
1//! Decoder options (RFC 004 D-3, CF-01). Every option that can change the output is recorded into the
2//! IR provenance (`PR-5`), so the result stays reproducible and the judgement reviewable.
3
4use std::collections::BTreeMap;
5
6/// How the decoder should behave. The defaults are the maximally-honest ones: **no rename inference**
7/// (RFC 004 D-3), so a default import is entirely source-*Stated*.
8#[derive(Debug, Clone, PartialEq, Eq)]
9pub struct Options {
10 /// Infer renames from identical content and mark them **Derived** (RFC 004 D-3). **Off by default.**
11 /// When on, a delete+add of the *same blob* within one commit also emits a marked
12 /// `Derived(InferredRename)` hint — beside, never replacing, the literal delete+add. CLI flag
13 /// `--infer-renames` (handoff `cli-and-verify-handoff-v2.md`).
14 pub infer_renames: bool,
15 /// The similarity percentage recorded as the rename parameter. M1 detects only exact-content moves,
16 /// so this is `100`; it exists so the recorded parameter is explicit and future thresholds fit.
17 pub rename_threshold: u8,
18}
19
20impl Default for Options {
21 fn default() -> Self {
22 Self {
23 infer_renames: false,
24 rename_threshold: 100,
25 }
26 }
27}
28
29impl Options {
30 /// Render the options as canonical, sorted key→value strings for the IR provenance (`PR-5/CF-01`).
31 #[must_use]
32 pub fn as_params(&self) -> BTreeMap<String, String> {
33 let mut m = BTreeMap::new();
34 m.insert("infer_renames".to_string(), self.infer_renames.to_string());
35 if self.infer_renames {
36 m.insert(
37 "rename_algorithm".to_string(),
38 "exact-content-move".to_string(),
39 );
40 m.insert(
41 "rename_threshold".to_string(),
42 self.rename_threshold.to_string(),
43 );
44 }
45 m
46 }
47}