alint_core/rule.rs
1use std::borrow::Cow;
2use std::collections::HashMap;
3use std::path::Path;
4use std::sync::Arc;
5
6use crate::error::Result;
7use crate::facts::FactValues;
8use crate::level::Level;
9use crate::registry::RuleRegistry;
10use crate::walker::FileIndex;
11
12/// A single linting violation produced by a rule.
13///
14/// `path` holds an [`Arc<Path>`]; rules clone the [`Arc`] from
15/// [`FileEntry::path`](crate::walker::FileEntry::path) (a cheap
16/// atomic refcount bump) rather than copying the path bytes. At
17/// 100k violations this saves 100k path-byte allocations.
18///
19/// `message` is a [`Cow<'static, str>`]; per-match templated
20/// messages live as `Cow::Owned(String)` (no change in cost),
21/// while fixed messages can live as `Cow::Borrowed("…")` if a
22/// rule chooses to construct them that way. Public API on the
23/// struct is unchanged at the byte level — `Display` and serde
24/// `Serialize` impls go through the inner `&str` / `&Path`.
25#[derive(Debug, Clone)]
26pub struct Violation {
27 pub path: Option<Arc<Path>>,
28 pub message: Cow<'static, str>,
29 pub line: Option<usize>,
30 pub column: Option<usize>,
31}
32
33impl Violation {
34 pub fn new(message: impl Into<Cow<'static, str>>) -> Self {
35 Self {
36 path: None,
37 message: message.into(),
38 line: None,
39 column: None,
40 }
41 }
42
43 /// Attach a path to the violation. Accepts anything convertible
44 /// into `Arc<Path>` — the canonical caller is
45 /// `.with_path(entry.path.clone())` where `entry.path` is the
46 /// `Arc<Path>` already owned by the [`FileIndex`]; this clones
47 /// the [`Arc`] (atomic refcount bump) rather than the bytes.
48 /// `PathBuf`, `&Path`, and `Box<Path>` are also accepted via
49 /// std's `From` impls; for an ad-hoc `&str` use
50 /// `Path::new("a.rs")` to convert first.
51 #[must_use]
52 pub fn with_path(mut self, path: impl Into<Arc<Path>>) -> Self {
53 self.path = Some(path.into());
54 self
55 }
56
57 #[must_use]
58 pub fn with_location(mut self, line: usize, column: usize) -> Self {
59 self.line = Some(line);
60 self.column = Some(column);
61 self
62 }
63}
64
65/// The collected outcome of evaluating a single rule.
66///
67/// `rule_id` holds an [`Arc<str>`]: the engine builds it once
68/// per rule run and shares it across every violation that rule
69/// produces, saving N-1 allocations per rule. `policy_url`
70/// follows the same shape via [`Arc<str>`] — set once per rule,
71/// shared across violations.
72#[derive(Debug, Clone)]
73pub struct RuleResult {
74 pub rule_id: Arc<str>,
75 pub level: Level,
76 pub policy_url: Option<Arc<str>>,
77 pub violations: Vec<Violation>,
78 /// Whether the rule declares a [`Fixer`] — surfaced here so
79 /// the human formatter can tag violations as `fixable`
80 /// without threading the rule registry into the renderer.
81 pub is_fixable: bool,
82}
83
84impl RuleResult {
85 pub fn passed(&self) -> bool {
86 self.violations.is_empty()
87 }
88}
89
90/// Execution context handed to each rule during evaluation.
91///
92/// - `registry` — available for rules that need to build and evaluate nested
93/// rules at runtime (e.g. `for_each_dir`). Tests that don't exercise
94/// nested evaluation can set this to `None`.
95/// - `facts` — resolved fact values, computed once per `Engine::run`.
96/// - `vars` — user-supplied string variables from the config's `vars:` section.
97/// - `git_tracked` — set of repo paths reported by `git ls-files`,
98/// computed once per run when at least one rule has
99/// `git_tracked_only: true`. `None` outside a git repo or when
100/// no rule asked for it. Rules that opt in consult it via
101/// [`Context::is_git_tracked`].
102/// - `git_blame` — per-file `git blame` cache, computed lazily
103/// when at least one rule reports `wants_git_blame()`. `None`
104/// when no rule asked for it. Rules consult it via
105/// [`crate::git::BlameCache::get`]; both "outside a git repo"
106/// and "blame failed for this file" surface as a `None`
107/// lookup, which the rule treats as "silent no-op."
108#[derive(Debug)]
109pub struct Context<'a> {
110 pub root: &'a Path,
111 pub index: &'a FileIndex,
112 pub registry: Option<&'a RuleRegistry>,
113 pub facts: Option<&'a FactValues>,
114 pub vars: Option<&'a HashMap<String, String>>,
115 pub git_tracked: Option<&'a std::collections::HashSet<std::path::PathBuf>>,
116 pub git_blame: Option<&'a crate::git::BlameCache>,
117}
118
119impl Context<'_> {
120 /// True if `rel_path` is in git's index. Returns `false` when
121 /// no tracked-set was computed (no git repo, or no rule asked
122 /// for it). Rules that opt into `git_tracked_only` therefore
123 /// silently skip every entry outside a git repo, which is the
124 /// right behaviour for the canonical "don't let X be
125 /// committed" use case.
126 pub fn is_git_tracked(&self, rel_path: &Path) -> bool {
127 match self.git_tracked {
128 Some(set) => set.contains(rel_path),
129 None => false,
130 }
131 }
132
133 /// True if the directory at `rel_path` contains at least one
134 /// git-tracked file. Used by `dir_*` rules opting into
135 /// `git_tracked_only`. Same `None`-means-untracked semantics
136 /// as [`Context::is_git_tracked`].
137 pub fn dir_has_tracked_files(&self, rel_path: &Path) -> bool {
138 match self.git_tracked {
139 Some(set) => crate::git::dir_has_tracked_files(rel_path, set),
140 None => false,
141 }
142 }
143}
144
145/// How a rule narrows its iteration to git-tracked entries.
146/// Returned by [`Rule::git_tracked_mode`]; the engine reads
147/// this at construction time to pick the right pre-filtered
148/// `FileIndex` (file-only or dir-aware) for each opted-in
149/// rule.
150///
151/// The mode is per-rule (a config might opt in some rules and
152/// not others). The engine builds at most two filtered indexes
153/// per run regardless of how many rules opt in, so the cost
154/// amortises across the whole rule set.
155///
156/// See `docs/design/v0.9/git-tracked-filtered-index.md` for
157/// the v0.9.11 structural fix this enum is the entry point of.
158#[derive(Debug, Clone, Copy, PartialEq, Eq)]
159pub enum GitTrackedMode {
160 /// Rule does not consult the git-tracked set. Engine
161 /// routes the rule's evaluation against the unfiltered
162 /// `FileIndex`. The default; do not override unless the
163 /// rule opts into `git_tracked_only:`.
164 Off,
165 /// Rule iterates files (`ctx.index.files()`) and the
166 /// engine narrows that to entries where
167 /// `git_tracked.contains(path)` before the rule sees them.
168 /// File-mode existence rules (`file_exists`, `file_absent`)
169 /// pick this mode when the spec's `git_tracked_only: true`.
170 FileOnly,
171 /// Rule iterates dirs (`ctx.index.dirs()`) and the engine
172 /// narrows that to dirs where
173 /// `dir_has_tracked_files(path, &git_tracked)`. Dir-mode
174 /// existence rules (`dir_exists`, `dir_absent`) pick this
175 /// mode when the spec's `git_tracked_only: true`. The
176 /// filtered index also includes the tracked files
177 /// themselves so a `dir_*` rule's nested per-file checks
178 /// (e.g. `paths:` glob) still match.
179 DirAware,
180}
181
182/// Trait every built-in and plugin rule implements.
183pub trait Rule: Send + Sync + std::fmt::Debug {
184 fn id(&self) -> &str;
185 fn level(&self) -> Level;
186 fn policy_url(&self) -> Option<&str> {
187 None
188 }
189 /// Whether (and how) this rule narrows its iteration to
190 /// git-tracked entries. Default [`GitTrackedMode::Off`].
191 /// Rule kinds that support `git_tracked_only:` override to
192 /// return [`GitTrackedMode::FileOnly`] (file-mode rules:
193 /// check `set.contains(path)`) or [`GitTrackedMode::DirAware`]
194 /// (dir-mode rules: check `dir_has_tracked_files(path, set)`)
195 /// when the user opts in.
196 ///
197 /// The engine collects the tracked-paths set (via
198 /// `git ls-files`) once per run when ANY rule returns a
199 /// non-`Off` mode, then builds a pre-filtered `FileIndex`
200 /// for each mode and routes opted-in rules to the right
201 /// `Context`. Rules iterate `ctx.index.files()` /
202 /// `ctx.index.dirs()` exactly as before — the index is
203 /// already narrowed, so no per-rule `if self.git_tracked_only
204 /// && !ctx.is_git_tracked(...)` runtime check is needed.
205 /// Closes the same recurrence-risk shape as v0.9.10's
206 /// `Scope`-owns-`scope_filter` fix:
207 /// `docs/design/v0.9/git-tracked-filtered-index.md`.
208 fn git_tracked_mode(&self) -> GitTrackedMode {
209 GitTrackedMode::Off
210 }
211
212 /// Whether this rule needs `git blame` output on
213 /// [`Context`]. Default `false`; the `git_blame_age` rule
214 /// kind overrides to return `true`. The engine builds the
215 /// shared [`crate::git::BlameCache`] once per run when any
216 /// rule opts in, so multiple blame-aware rules over
217 /// overlapping `paths:` re-use the parsed result.
218 fn wants_git_blame(&self) -> bool {
219 false
220 }
221
222 /// In `--changed` mode, return `true` to evaluate this rule
223 /// against the **full** [`FileIndex`] rather than the
224 /// changed-only filtered subset. Default `false` (per-file
225 /// semantics — the rule sees only changed files in scope).
226 ///
227 /// Cross-file rules (`pair`, `for_each_dir`,
228 /// `every_matching_has`, `unique_by`, `dir_contains`,
229 /// `dir_only_contains`) override to `true` because their
230 /// inputs span the whole tree by definition — a verdict on
231 /// the changed file depends on what's still in the rest of
232 /// the tree. Existence rules (`file_exists`, `file_absent`,
233 /// `dir_exists`, `dir_absent`) likewise consult the whole
234 /// tree to answer "is X present?" correctly.
235 fn requires_full_index(&self) -> bool {
236 false
237 }
238
239 /// In `--changed` mode, return the [`Scope`](crate::Scope)
240 /// this rule is scoped to (typically the rule's `paths:`
241 /// field). The engine intersects the scope with the
242 /// changed-set; rules whose scope doesn't intersect are
243 /// skipped, which is the optimisation `--changed` exists
244 /// for.
245 ///
246 /// Default `None` ("no scope information") means the rule is
247 /// always evaluated. Cross-file rules deliberately leave this
248 /// as `None` (they always evaluate per the roadmap contract).
249 /// Per-file rules with a single `Scope` field should override
250 /// to return `Some(&self.scope)`.
251 fn path_scope(&self) -> Option<&crate::scope::Scope> {
252 None
253 }
254
255 fn evaluate(&self, ctx: &Context<'_>) -> Result<Vec<Violation>>;
256
257 /// Optional automatic-fix strategy. Rules whose violations can be
258 /// mechanically corrected (e.g. creating a missing file, removing a
259 /// forbidden one, renaming to the correct case) return a
260 /// [`Fixer`] here; the default implementation reports the rule as
261 /// unfixable.
262 fn fixer(&self) -> Option<&dyn Fixer> {
263 None
264 }
265
266 /// Opt into the file-major dispatch path. Per-file rules that
267 /// can evaluate one file at a time given a pre-loaded byte
268 /// slice override this to return `Some(self)`; cross-file
269 /// rules and any rule with `requires_full_index() == true`
270 /// leave it as `None` and keep evaluating under the rule-
271 /// major loop.
272 ///
273 /// When the engine has multiple per-file rules sharing one
274 /// scope, the file-major loop reads each matched file once
275 /// and dispatches to every applicable per-file rule against
276 /// the same byte buffer — coalescing N reads of one file
277 /// into 1.
278 fn as_per_file(&self) -> Option<&dyn PerFileRule> {
279 None
280 }
281}
282
283/// File-major dispatch entry-point for a per-file rule.
284///
285/// Rules that can evaluate one file at a time given a pre-loaded
286/// byte slice implement this trait alongside [`Rule`] and opt
287/// into the file-major path via [`Rule::as_per_file`]. The
288/// engine reads each file once per evaluation pass and calls
289/// `evaluate_file` on every per-file rule whose
290/// [`path_scope`](PerFileRule::path_scope) matches that file —
291/// avoiding the per-rule `std::fs::read` the rule-major loop
292/// would otherwise duplicate.
293///
294/// Implementations MUST NOT call `std::fs::read` themselves; the
295/// `bytes` argument is the engine's already-read content. The
296/// rule's existing [`Rule::evaluate`] implementation (which does
297/// read the file) stays in place as the rule-major fallback —
298/// it's still the path used by `alint fix` (sequential
299/// filesystem mutation rules out coalesced reads there) and by
300/// fallback test harnesses.
301pub trait PerFileRule: Send + Sync + std::fmt::Debug {
302 /// The rule's scope. The engine checks
303 /// `path_scope().matches(path)` before calling
304 /// `evaluate_file`; a rule that returns
305 /// [`Scope::match_all`](crate::scope::Scope::match_all) is
306 /// in scope for every file.
307 fn path_scope(&self) -> &crate::scope::Scope;
308
309 /// Evaluate one file given the engine's already-read byte
310 /// content. The `path` is the relative path from the lint
311 /// root; the rule should `with_path(path.into())` (or clone
312 /// the matched [`FileEntry::path`](crate::walker::FileEntry::path)
313 /// if it has one in hand) on emitted violations.
314 fn evaluate_file(&self, ctx: &Context<'_>, path: &Path, bytes: &[u8])
315 -> Result<Vec<Violation>>;
316
317 /// Optional lower bound on the bytes the rule needs to
318 /// evaluate. Default `None` means "I need the whole file."
319 /// Used as a hint; the engine in v0.9.3 reads the whole
320 /// file regardless and hands it to every applicable rule —
321 /// the hint is reserved for a future engine-side bounded-
322 /// read optimisation.
323 fn max_bytes_needed(&self) -> Option<usize> {
324 None
325 }
326}
327
328/// Runtime context for applying a fix.
329#[derive(Debug)]
330pub struct FixContext<'a> {
331 pub root: &'a Path,
332 /// When true, fixers must describe what they would do without
333 /// touching the filesystem.
334 pub dry_run: bool,
335 /// Max bytes a content-editing fix will read + rewrite.
336 /// `None` means no cap. Honored by the `read_for_fix` helper
337 /// (and any custom fixer that opts in).
338 pub fix_size_limit: Option<u64>,
339}
340
341/// The result of applying (or simulating) one fix against one violation.
342#[derive(Debug, Clone)]
343pub enum FixOutcome {
344 /// The fix was applied (or would be, under `dry_run`). The string
345 /// is a human-readable one-liner — e.g. `"created LICENSE"`,
346 /// `"would remove target/debug.log"`.
347 Applied(String),
348 /// The fixer intentionally did nothing; the string explains why
349 /// (e.g. `"already exists"`, `"no path on violation"`). This is
350 /// distinct from a hard error returned via `Result::Err`.
351 Skipped(String),
352}
353
354/// A mechanical corrector for a specific rule's violations.
355pub trait Fixer: Send + Sync + std::fmt::Debug {
356 /// Short human-readable summary of what this fixer does,
357 /// independent of any specific violation.
358 fn describe(&self) -> String;
359
360 /// Apply the fix against a single violation.
361 fn apply(&self, violation: &Violation, ctx: &FixContext<'_>) -> Result<FixOutcome>;
362}
363
364/// Result of [`read_for_fix`] — either the bytes of the file,
365/// or a [`FixOutcome::Skipped`] the caller should return.
366///
367/// Content-editing fixers (`file_prepend`, `file_append`,
368/// `file_trim_trailing_whitespace`, …) funnel their initial read
369/// through this helper so the `fix_size_limit` guard is enforced
370/// uniformly: over-limit files are reported as `Skipped` with a
371/// clear reason, and a one-line warning is printed to stderr so
372/// scripted runs notice.
373#[derive(Debug)]
374pub enum ReadForFix {
375 Bytes(Vec<u8>),
376 Skipped(FixOutcome),
377}
378
379/// Check whether `abs` is within the `fix_size_limit` on `ctx`.
380/// Returns `Some(outcome)` when the file is over-limit (the
381/// caller returns this directly); returns `None` when the fix
382/// can proceed. Emits a one-line stderr warning on over-limit.
383///
384/// Use this in fixers that modify the file without reading the
385/// full body (e.g. streaming append). For read-modify-write
386/// flows, prefer [`read_for_fix`] which folds the check in.
387pub fn check_fix_size(
388 abs: &Path,
389 display_path: &std::path::Path,
390 ctx: &FixContext<'_>,
391) -> Result<Option<FixOutcome>> {
392 let Some(limit) = ctx.fix_size_limit else {
393 return Ok(None);
394 };
395 let metadata = std::fs::metadata(abs).map_err(|source| crate::error::Error::Io {
396 path: abs.to_path_buf(),
397 source,
398 })?;
399 if metadata.len() > limit {
400 let reason = format!(
401 "{} is {} bytes; exceeds fix_size_limit ({}). Raise \
402 `fix_size_limit` in .alint.yml (or set it to `null` to disable) \
403 to fix files this large.",
404 display_path.display(),
405 metadata.len(),
406 limit,
407 );
408 eprintln!("alint: warning: {reason}");
409 return Ok(Some(FixOutcome::Skipped(reason)));
410 }
411 Ok(None)
412}
413
414/// Read `abs` subject to the size limit on `ctx`. Over-limit
415/// files return `ReadForFix::Skipped(Outcome::Skipped(_))` and
416/// emit a one-line stderr warning; in-limit files return
417/// `ReadForFix::Bytes(...)`. Pass-through I/O errors propagate.
418pub fn read_for_fix(
419 abs: &Path,
420 display_path: &std::path::Path,
421 ctx: &FixContext<'_>,
422) -> Result<ReadForFix> {
423 if let Some(outcome) = check_fix_size(abs, display_path, ctx)? {
424 return Ok(ReadForFix::Skipped(outcome));
425 }
426 let bytes = std::fs::read(abs).map_err(|source| crate::error::Error::Io {
427 path: abs.to_path_buf(),
428 source,
429 })?;
430 Ok(ReadForFix::Bytes(bytes))
431}
432
433#[cfg(test)]
434mod tests {
435 use super::*;
436
437 fn empty_index() -> FileIndex {
438 FileIndex::default()
439 }
440
441 #[test]
442 fn violation_builder_sets_fields_via_chain() {
443 let v = Violation::new("trailing whitespace")
444 .with_path(Path::new("src/main.rs"))
445 .with_location(12, 4);
446 assert_eq!(v.message, "trailing whitespace");
447 assert_eq!(v.path.as_deref(), Some(Path::new("src/main.rs")));
448 assert_eq!(v.line, Some(12));
449 assert_eq!(v.column, Some(4));
450 }
451
452 #[test]
453 fn violation_new_starts_with_no_path_or_location() {
454 let v = Violation::new("global note");
455 assert!(v.path.is_none());
456 assert!(v.line.is_none());
457 assert!(v.column.is_none());
458 }
459
460 #[test]
461 fn rule_result_passed_iff_violations_empty() {
462 let mut r = RuleResult {
463 rule_id: "x".into(),
464 level: Level::Error,
465 policy_url: None,
466 violations: Vec::new(),
467 is_fixable: false,
468 };
469 assert!(r.passed());
470 r.violations.push(Violation::new("oops"));
471 assert!(!r.passed());
472 }
473
474 #[test]
475 fn context_is_git_tracked_returns_false_outside_repo() {
476 let idx = empty_index();
477 let ctx = Context {
478 root: Path::new("/tmp"),
479 index: &idx,
480 registry: None,
481 facts: None,
482 vars: None,
483 git_tracked: None, // outside-a-repo / no rule opted in
484 git_blame: None,
485 };
486 assert!(!ctx.is_git_tracked(Path::new("anything.rs")));
487 assert!(!ctx.dir_has_tracked_files(Path::new("src")));
488 }
489
490 #[test]
491 fn context_is_git_tracked_consults_set_when_present() {
492 let mut tracked: std::collections::HashSet<std::path::PathBuf> =
493 std::collections::HashSet::new();
494 tracked.insert(std::path::PathBuf::from("src/main.rs"));
495 let idx = empty_index();
496 let ctx = Context {
497 root: Path::new("/tmp"),
498 index: &idx,
499 registry: None,
500 facts: None,
501 vars: None,
502 git_tracked: Some(&tracked),
503 git_blame: None,
504 };
505 assert!(ctx.is_git_tracked(Path::new("src/main.rs")));
506 assert!(!ctx.is_git_tracked(Path::new("README.md")));
507 }
508
509 /// Stand-in `Rule` impl that returns the trait defaults.
510 /// Lets us assert the documented defaults without dragging
511 /// in a real registered rule.
512 #[derive(Debug)]
513 struct DefaultRule;
514
515 impl Rule for DefaultRule {
516 fn id(&self) -> &'static str {
517 "default"
518 }
519 fn level(&self) -> Level {
520 Level::Warning
521 }
522 fn evaluate(&self, _ctx: &Context<'_>) -> Result<Vec<Violation>> {
523 Ok(Vec::new())
524 }
525 }
526
527 #[test]
528 fn rule_trait_defaults_are_safe_no_ops() {
529 let r = DefaultRule;
530 assert_eq!(r.policy_url(), None);
531 assert_eq!(r.git_tracked_mode(), GitTrackedMode::Off);
532 assert!(!r.wants_git_blame());
533 assert!(!r.requires_full_index());
534 assert!(r.path_scope().is_none());
535 assert!(r.fixer().is_none());
536 }
537
538 #[test]
539 fn check_fix_size_returns_none_when_limit_disabled() {
540 let dir = tempfile::tempdir().unwrap();
541 let f = dir.path().join("a.txt");
542 std::fs::write(&f, b"hello").unwrap();
543 let ctx = FixContext {
544 root: dir.path(),
545 dry_run: false,
546 fix_size_limit: None,
547 };
548 let outcome = check_fix_size(&f, Path::new("a.txt"), &ctx).unwrap();
549 assert!(outcome.is_none());
550 }
551
552 #[test]
553 fn check_fix_size_skips_over_limit_files() {
554 let dir = tempfile::tempdir().unwrap();
555 let f = dir.path().join("big.txt");
556 std::fs::write(&f, vec![b'x'; 1024]).unwrap();
557 let ctx = FixContext {
558 root: dir.path(),
559 dry_run: false,
560 fix_size_limit: Some(64),
561 };
562 let outcome = check_fix_size(&f, Path::new("big.txt"), &ctx).unwrap();
563 match outcome {
564 Some(FixOutcome::Skipped(reason)) => {
565 assert!(reason.contains("exceeds fix_size_limit"));
566 assert!(reason.contains("big.txt"));
567 }
568 other => panic!("expected Skipped, got {other:?}"),
569 }
570 }
571
572 #[test]
573 fn read_for_fix_returns_bytes_when_in_limit() {
574 let dir = tempfile::tempdir().unwrap();
575 let f = dir.path().join("a.txt");
576 std::fs::write(&f, b"hello").unwrap();
577 let ctx = FixContext {
578 root: dir.path(),
579 dry_run: false,
580 fix_size_limit: Some(1 << 20),
581 };
582 match read_for_fix(&f, Path::new("a.txt"), &ctx).unwrap() {
583 ReadForFix::Bytes(b) => assert_eq!(b, b"hello"),
584 ReadForFix::Skipped(_) => panic!("expected Bytes, got Skipped"),
585 }
586 }
587
588 #[test]
589 fn read_for_fix_returns_skipped_when_over_limit() {
590 let dir = tempfile::tempdir().unwrap();
591 let f = dir.path().join("big.txt");
592 std::fs::write(&f, vec![b'x'; 1024]).unwrap();
593 let ctx = FixContext {
594 root: dir.path(),
595 dry_run: false,
596 fix_size_limit: Some(64),
597 };
598 match read_for_fix(&f, Path::new("big.txt"), &ctx).unwrap() {
599 ReadForFix::Skipped(FixOutcome::Skipped(_)) => {}
600 ReadForFix::Skipped(FixOutcome::Applied(_)) => {
601 panic!("expected Skipped, got Skipped(Applied)")
602 }
603 ReadForFix::Bytes(_) => panic!("expected Skipped, got Bytes"),
604 }
605 }
606
607 #[test]
608 fn fix_outcome_variants_are_constructible() {
609 // Sanity: documented variant shapes haven't drifted.
610 let _applied = FixOutcome::Applied("created LICENSE".into());
611 let _skipped = FixOutcome::Skipped("already exists".into());
612 }
613}