Skip to main content

fallow_types/
output_dead_code.rs

1//! Typed envelope wrappers for the simple 1:1 dead-code findings whose
2//! actions are entirely determined by the wrapper type (no per-instance
3//! discriminants beyond what the bare finding already exposes).
4//!
5//! Each wrapper flattens the bare finding via `#[serde(flatten)]` so the
6//! wire shape matches the previous `actions`-grafted output byte-for-byte.
7//! `actions` is populated at construction time via each wrapper's
8//! `with_actions` constructor and replaces the per-finding `inject_actions`
9//! post-pass in `crates/cli/src/report/json.rs`. `introduced` carries the optional audit
10//! breadcrumb that `crates/cli/src/audit.rs::annotate_issue_array` inserts
11//! into the JSON object via `map.insert`; the wrapper-level field stays
12//! `None` when serialized directly from Rust and is set by the audit pass
13//! only when the issue was introduced relative to the merge-base.
14//!
15//! All nine wrappers ship with `IssueAction` arrays today; they pay the
16//! `serde_json` dependency cost because `IssueAction` transitively
17//! references `AddToConfigValue::RuleObject(serde_json::Map<...>)`. The
18//! variants the wrappers actually emit (`Fix`, `SuppressLine`,
19//! `SuppressFile`, `AddToConfig`) are small, but reusing the existing enum
20//! keeps the wire-shape contract identical to the legacy post-pass.
21//!
22//! `introduced` is typed as `Option<AuditIntroduced>` (transparent newtype
23//! over `bool`) so the regenerated schema renders the field via
24//! `$ref: #/definitions/AuditIntroduced`, matching the reference the prior
25//! post-pass augmentation graft used. The audit pass continues to inject a
26//! bare bool via `map.insert("introduced", ...)`; serde reads it back into
27//! `AuditIntroduced` transparently. The field stays absent at the wire when
28//! `None` (`skip_serializing_if`).
29
30use serde::{Deserialize, Serialize};
31
32use crate::catalog_source::is_pnpm_catalog_source;
33use crate::envelope::AuditIntroduced;
34use crate::output::{
35    AddToConfigAction, AddToConfigKind, AddToConfigValue, FixAction, FixActionType,
36    IgnoreExportsRule, IssueAction, SuppressFileAction, SuppressFileKind, SuppressLineAction,
37    SuppressLineKind, SuppressLineScope,
38};
39pub use crate::results::AbsentComponentPropFinding;
40use crate::results::{
41    BoundaryCallViolation, BoundaryCoverageViolation, BoundaryViolation, CircularDependency,
42    DependencyOverrideSource, DeprecatedExportInUse, DevDependencyInProduction, DuplicateExport,
43    DuplicateExportAlias, DuplicatePropShape, DynamicSegmentNameConflict, EmptyCatalogGroup,
44    InvalidClientExport, MisconfiguredDependencyOverride, MisplacedDirective,
45    MixedClientServerBarrel, PackageCycle, PolicyViolation, PrivateTypeLeak, PropDrillingChain,
46    ReExportCycle, ReExportCycleKind, RouteCollision, TestOnlyDependency, ThinWrapper,
47    TypeOnlyDependency, UnlistedBinary, UnlistedDependency, UnproducedCatchTag, UnprovidedInject,
48    UnrenderedComponent, UnresolvedCatalogReference, UnresolvedImport, UnusedCatalogEntry,
49    UnusedComponentEmit, UnusedComponentInput, UnusedComponentOutput, UnusedComponentProp,
50    UnusedDependency, UnusedDependencyOverride, UnusedEffectLayer, UnusedExport, UnusedFile,
51    UnusedLoadDataKey, UnusedMember, UnusedServerAction, UnusedSvelteEvent, UnusedTaggedError,
52};
53use crate::semantic::{
54    SemanticCandidateDecision, SemanticCandidateDecisionKind, SemanticCompleteness,
55};
56
57/// Shared note for the `duplicate-exports` fix action. This const is the
58/// single source of truth: `crates/cli/src/report/shared.rs` aliases it for
59/// the human report.
60pub const NAMESPACE_BARREL_HINT: &str = "If every location is the sole `index.*` of its directory, this is likely an intentional namespace-barrel API. Prefer adding these files to `ignoreExports` over removing exports.";
61
62/// JSON Schema fragment URL for the `add-to-config` `ignoreExports` action's
63/// `value` payload. Pinned to the main branch so users browsing the action
64/// value can navigate directly to the rule shape.
65pub const IGNORE_EXPORTS_VALUE_SCHEMA: &str =
66    "https://raw.githubusercontent.com/fallow-rs/fallow/main/schema.json#/properties/ignoreExports";
67
68/// JSON Schema fragment URL for the `ignoreCatalogReferences` rule items
69/// referenced by `add-to-config` actions on `unresolved-catalog-references`.
70const IGNORE_CATALOG_REFERENCES_VALUE_SCHEMA: &str = "https://raw.githubusercontent.com/fallow-rs/fallow/main/schema.json#/properties/ignoreCatalogReferences/items";
71
72/// JSON Schema fragment URL for the `ignoreDependencyOverrides` rule items
73/// referenced by `add-to-config` actions on both the unused- and
74/// misconfigured-override findings.
75const IGNORE_DEPENDENCY_OVERRIDES_VALUE_SCHEMA: &str = "https://raw.githubusercontent.com/fallow-rs/fallow/main/schema.json#/properties/ignoreDependencyOverrides/items";
76
77pub(crate) fn manual_framework_fix(
78    kind: FixActionType,
79    description: &str,
80    note: &str,
81) -> IssueAction {
82    IssueAction::Fix(FixAction {
83        kind,
84        auto_fixable: false,
85        description: description.to_string(),
86        note: Some(note.to_string()),
87        available_in_catalogs: None,
88        suggested_target: None,
89    })
90}
91
92pub(crate) fn suppress_line(comment: &str) -> IssueAction {
93    IssueAction::SuppressLine(SuppressLineAction {
94        kind: SuppressLineKind::SuppressLine,
95        auto_fixable: false,
96        description: "Suppress with an inline comment above the line".to_string(),
97        comment: comment.to_string(),
98        scope: None,
99    })
100}
101
102/// A per-finding caveat on a dead-code verdict that a file this run never
103/// fully analyzed can distort.
104///
105/// Advisory provenance, in the same spirit as the fix path's
106/// `low_confidence_off_graph` / `low_confidence_unresolved_imports` skip
107/// reasons: a caveat never withholds, reorders, downgrades, or re-severities
108/// the finding, and never changes an exit code. It records that the verdict
109/// was computed over an import graph fallow already knows is incomplete, so a
110/// reader who sees the finding also sees the caveat instead of having to
111/// notice a diagnostic at the other end of the envelope.
112///
113/// Deliberately NOT named `confidence`: `health --targets` already emits a
114/// `confidence` key holding an enum string, and a shared consumer helper that
115/// met both would see the same key change type. Emitted on every finding type
116/// that registers it: the reachability arrays (`unused_files[]`,
117/// `unused_exports[]`, `unused_types[]`), the member arrays
118/// (`unused_enum_members[]`, `unused_class_members[]`, `unused_store_members[]`),
119/// and the three dependency arrays. Sorted and deduplicated, absent from the
120/// wire when empty. The set is open in the same sense
121/// `workspace_diagnostics[].kind` is: treat an unrecognised value as "some
122/// caveat" rather than as an error.
123#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
124#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
125#[serde(rename_all = "kebab-case")]
126pub enum ReachabilityCaveat {
127    /// This finding's own file is one the run did not fully analyze, so the
128    /// export and import lists extracted from it may stop short of the real
129    /// ones. That reaches an `unused-file` verdict directly, because the
130    /// "is any export of this file referenced from a reachable module" test
131    /// reads exactly that truncated export list.
132    ///
133    /// Three workspace diagnostics put a file in this state: a partial parse
134    /// (`source-parse-degraded`), no parse (`source-nesting-too-deep`), or no
135    /// read (`source-read-failure`). The token names the consequence rather than
136    /// either cause, so a future kind that leaves a discovered file partially
137    /// extracted carries the same value.
138    ///
139    /// Dependency findings never carry this value: the file they name is a
140    /// `package.json`, not a parsed source module.
141    IncompleteFileAnalysis,
142    /// A module whose import list feeds this verdict was not analyzed, so the
143    /// import that would have credited this finding may never have been seen.
144    ///
145    /// The cause is any workspace diagnostic that leaves a source file's
146    /// imports unseen: a partial parse (`source-parse-degraded`), no parse
147    /// (`source-nesting-too-deep`), no read (`source-read-failure`), or a skip
148    /// by discovery before the read (`skipped-large-file`,
149    /// `skipped-minified-file`, `skipped-source-dotdir`). The token names the
150    /// class rather than any one cause.
151    ///
152    /// Which modules feed the verdict differs by array, and the caveat is
153    /// emitted only when a degraded module is actually one of them:
154    ///
155    /// - `unused_files[]`, `unused_exports[]`, and `unused_types[]` rest on
156    ///   reachability, so only a degraded module that is itself observed
157    ///   reachable can change the verdict. When every degraded module is
158    ///   unreachable the caveat is absent, and soundly: the first missing edge
159    ///   on any entry-point path leaves from a module whose every predecessor
160    ///   edge was observed, so that module is observed reachable. A file the
161    ///   run never read has no module and no graph node, so its reachability
162    ///   is not observable at all and that narrowing cannot be applied: any
163    ///   skipped or unreadable source caveats every reachability verdict in
164    ///   the run.
165    /// - the member arrays (`unused_enum_members[]`, `unused_class_members[]`,
166    ///   `unused_store_members[]`) do not rest on reachability at all: member
167    ///   usage is collected by walking every module the run resolved,
168    ///   reachable or not, so this narrowing does not apply to them either.
169    ///   Same unnarrowed condition as the dependency arrays below, plus the
170    ///   per-finding value above when the member's own file is the one that
171    ///   was incompletely analyzed.
172    /// - the dependency arrays rest on whether ANY module in the project
173    ///   imports the package specifier, reachable or not, so any degraded
174    ///   parse anywhere can hide the import that would have credited the
175    ///   package. Reachability does not narrow that one.
176    ///
177    /// The limit, stated because an approximation presented as exact is worse
178    /// than nothing: this is a RUN-level condition, not proof that a degraded
179    /// module imports this path or package. An import the parser never saw
180    /// cannot be attributed to a target, so the link cannot be narrowed
181    /// further without re-reading the source. Read `workspace_diagnostics[]`
182    /// for which files degraded.
183    IncompleteImportGraph,
184}
185
186impl ReachabilityCaveat {
187    /// The wire token.
188    #[must_use]
189    pub const fn token(self) -> &'static str {
190        match self {
191            Self::IncompleteFileAnalysis => "incomplete-file-analysis",
192            Self::IncompleteImportGraph => "incomplete-import-graph",
193        }
194    }
195
196    /// A one-line explanation for human and agent-facing renderers.
197    ///
198    /// Neither sentence names a single cause. A degraded parse is only one of
199    /// the ways a file goes unread: it may also have been unreadable, or
200    /// skipped before it was ever opened (oversized, minified, in a dotdir).
201    /// Naming the parse case alone sent a reader whose run was degraded by the
202    /// size guard hunting for parse errors that do not exist, so both messages
203    /// point at `workspace_diagnostics[]`, which names the actual files.
204    #[must_use]
205    pub const fn message(self) -> &'static str {
206        match self {
207            Self::IncompleteFileAnalysis => {
208                "low: this file was not fully analyzed, so its extracted exports and imports may be incomplete; see workspace_diagnostics[]"
209            }
210            Self::IncompleteImportGraph => {
211                "low: a module this run did not fully read may hold an import that would credit this; see workspace_diagnostics[]"
212            }
213        }
214    }
215
216    /// A compact label for a one-line human renderer, where the full
217    /// [`Self::message`] would not fit next to the finding.
218    #[must_use]
219    pub const fn short_label(self) -> &'static str {
220        match self {
221            Self::IncompleteFileAnalysis => "incomplete file analysis",
222            Self::IncompleteImportGraph => "incomplete import graph",
223        }
224    }
225}
226
227/// The note every mutating action carries once [`MutationEvidence`] withholds
228/// it. One string, so the CLI action array, the LSP diagnostic, and the MCP
229/// tool contract all say the same thing about the same finding.
230pub const INCOMPLETE_EVIDENCE_NOTE: &str = "Evidence is incomplete: a file this run did not fully analyze may hold the reference that \
231     credits this finding, so this mutation is not applied automatically. Resolve the files named \
232     in workspace_diagnostics[] and re-run, or confirm and remove it by hand.";
233
234/// The one question every mutation surface asks before it offers, plans, or
235/// performs a dead-code finding's removal.
236///
237/// A finding whose reachability verdict rests on a file the run never fully
238/// read is still REPORTED, always: a caveat withholds no finding, changes no
239/// severity, and moves no exit code. What it withholds is the automation. The
240/// predicate lives here, next to the findings, rather than in any one consumer,
241/// because it was re-derived per surface three times and a fourth door opened
242/// every time: `fallow fix`, the LSP quick fix, and the `auto_fixable` flag an
243/// agent plans against each answered it differently. Every one of those now
244/// calls [`Self::may_auto_apply_mutation`], so a sixth finding type or a fourth
245/// mutation surface cannot silently opt out.
246///
247/// Implemented only by the findings that can carry a caveat. A finding type
248/// that exposes an auto-fixable mutation and does NOT implement this trait is
249/// the bug this trait exists to make visible; `every_auto_fixable_dead_code_
250/// mutation_is_gated` in this module's tests pins that.
251pub trait MutationEvidence {
252    /// The advisory caveats recorded on the reachability verdict behind this
253    /// finding. Empty when the run analyzed every file it discovered.
254    fn reachability_caveats(&self) -> &[ReachabilityCaveat];
255
256    /// Whether this finding's mutation may be applied without a human first
257    /// being told the evidence is incomplete. THE gate: never re-derive it,
258    /// never widen it per surface.
259    fn may_auto_apply_mutation(&self) -> bool {
260        self.reachability_caveats().is_empty()
261    }
262}
263
264/// Record a run's caveats on a finding, enforcing [`MutationEvidence`] on its
265/// typed `actions` in the same step.
266///
267/// Separate from [`MutationEvidence`] so a read-only consumer (the fixer, the
268/// LSP, a renderer) depends only on the question and never on the answer's
269/// setter. `annotate` in the analysis layer is the single writer.
270pub trait CaveatedFinding: MutationEvidence {
271    /// Store `caveats` and downgrade every mutating action the gate now
272    /// withholds. The field itself stays `pub` (a renderer test builds an
273    /// already-caveated fixture directly, without running the annotation
274    /// pass); every non-test writer goes through this setter instead of the
275    /// field so the downgrade travels with the write.
276    fn set_reachability_caveats(&mut self, caveats: Vec<ReachabilityCaveat>);
277}
278
279/// Downgrade every `Fix` action in `actions` when `caveats` is non-empty, so
280/// the `auto_fixable` flag an agent plans against matches what `fallow fix`
281/// will actually do. Only ever downgrades: a surface that has already decided
282/// a mutation is unsafe for its own reasons keeps that decision.
283fn withhold_caveated_mutations(actions: &mut [IssueAction], caveats: &[ReachabilityCaveat]) {
284    if caveats.is_empty() {
285        return;
286    }
287    for action in actions {
288        let IssueAction::Fix(fix) = action else {
289            continue;
290        };
291        fix.auto_fixable = false;
292        fix.note = Some(match fix.note.take() {
293            Some(existing) => format!("{existing}. {INCOMPLETE_EVIDENCE_NOTE}"),
294            None => INCOMPLETE_EVIDENCE_NOTE.to_string(),
295        });
296    }
297}
298
299/// Implement the gate for a finding wrapper carrying a `reachability_caveats`
300/// field alongside a typed `actions` array. A new caveated finding type adds
301/// one line here rather than a new per-surface branch.
302macro_rules! impl_caveated_finding {
303    ($($finding:ty),+ $(,)?) => {
304        $(
305            impl MutationEvidence for $finding {
306                fn reachability_caveats(&self) -> &[ReachabilityCaveat] {
307                    &self.reachability_caveats
308                }
309            }
310
311            impl CaveatedFinding for $finding {
312                fn set_reachability_caveats(&mut self, caveats: Vec<ReachabilityCaveat>) {
313                    withhold_caveated_mutations(&mut self.actions, &caveats);
314                    self.reachability_caveats = caveats;
315                }
316            }
317        )+
318    };
319}
320
321/// Wire-shape envelope for an [`UnusedFile`] finding. The bare finding
322/// flattens in via `#[serde(flatten)]`, with a typed `actions` array
323/// populated at construction time and the audit-pass `introduced` flag
324/// attached as an optional sibling.
325#[derive(Debug, Clone, Serialize, Deserialize)]
326#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
327pub struct UnusedFileFinding {
328    /// The underlying dead-code entry.
329    #[serde(flatten)]
330    pub file: UnusedFile,
331    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
332    /// `~<k>` suffix when several findings of one type share an identity.
333    /// Line and column are not inputs, so the id survives line shifts,
334    /// reformats and reorders. A rename of the file or the symbol gives a
335    /// new id. Absent in output from older versions.
336    #[serde(default, skip_serializing_if = "Option::is_none")]
337    pub finding_id: Option<String>,
338    /// Suggested next steps: a `delete-file` primary and a `suppress-file`
339    /// secondary. Always emitted (possibly empty for forward-compat).
340    pub actions: Vec<IssueAction>,
341    /// Set by the audit pass when this finding is introduced relative to
342    /// the merge-base. `None` when serialized directly from Rust.
343    #[serde(default, skip_serializing_if = "Option::is_none")]
344    pub introduced: Option<AuditIntroduced>,
345    /// Gate severity of this finding after `rules` and `overrides[].rules`
346    /// resolve for its path. CI formats read it for the annotation, SARIF
347    /// and CodeClimate level. Absent in output from older versions. Not
348    /// part of the finding identity, baseline keys or fingerprints.
349    #[serde(
350        default,
351        skip_serializing_if = "Option::is_none",
352        deserialize_with = "deserialize_effective_severity"
353    )]
354    pub effective_severity: Option<EffectiveSeverity>,
355    /// Advisory caveats on the reachability verdict behind this finding.
356    /// Sorted, deduplicated, and omitted from the wire when empty, so a run
357    /// that analyzed every discovered file is byte-identical. Never gates the
358    /// finding or the `delete-file` action, though `fallow fix` does withhold
359    /// the removal of a caveated finding as low confidence.
360    #[serde(default, skip_serializing_if = "Vec::is_empty")]
361    pub reachability_caveats: Vec<ReachabilityCaveat>,
362}
363
364impl UnusedFileFinding {
365    /// Build the wrapper from a raw [`UnusedFile`], computing the typed
366    /// `actions` array inline. `introduced` stays `None` and is set later
367    /// by `annotate_dead_code_json` if the audit pass runs.
368    #[must_use]
369    pub fn with_actions(file: UnusedFile) -> Self {
370        let actions = vec![
371            IssueAction::Fix(FixAction {
372                kind: FixActionType::DeleteFile,
373                auto_fixable: false,
374                description: "Delete this file".to_string(),
375                note: Some(
376                    "File deletion may remove runtime functionality not visible to static analysis"
377                        .to_string(),
378                ),
379                available_in_catalogs: None,
380                suggested_target: None,
381            }),
382            IssueAction::SuppressFile(SuppressFileAction {
383                kind: SuppressFileKind::SuppressFile,
384                auto_fixable: false,
385                description: "Suppress with a file-level comment at the top of the file"
386                    .to_string(),
387                comment: "// fallow-ignore-file unused-file".to_string(),
388            }),
389        ];
390        Self {
391            finding_id: None,
392            file,
393            actions,
394            introduced: None,
395            effective_severity: None,
396            reachability_caveats: Vec::new(),
397        }
398    }
399}
400
401/// Wire-shape envelope for a [`PrivateTypeLeak`] finding. Mirrors
402/// [`UnusedFileFinding`]: flattens the bare finding and carries a typed
403/// `actions` array (`export-type` primary plus `suppress-line` secondary).
404#[derive(Debug, Clone, Serialize, Deserialize)]
405#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
406pub struct PrivateTypeLeakFinding {
407    /// The underlying dead-code entry.
408    #[serde(flatten)]
409    pub leak: PrivateTypeLeak,
410    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
411    /// `~<k>` suffix when several findings of one type share an identity.
412    /// Line and column are not inputs, so the id survives line shifts,
413    /// reformats and reorders. A rename of the file or the symbol gives a
414    /// new id. Absent in output from older versions.
415    #[serde(default, skip_serializing_if = "Option::is_none")]
416    pub finding_id: Option<String>,
417    /// Suggested next steps. Always emitted (possibly empty for
418    /// forward-compat).
419    pub actions: Vec<IssueAction>,
420    /// Set by the audit pass when this finding is introduced relative to
421    /// the merge-base.
422    #[serde(default, skip_serializing_if = "Option::is_none")]
423    pub introduced: Option<AuditIntroduced>,
424    /// Gate severity of this finding after `rules` and `overrides[].rules`
425    /// resolve for its path. CI formats read it for the annotation, SARIF
426    /// and CodeClimate level. Absent in output from older versions. Not
427    /// part of the finding identity, baseline keys or fingerprints.
428    #[serde(
429        default,
430        skip_serializing_if = "Option::is_none",
431        deserialize_with = "deserialize_effective_severity"
432    )]
433    pub effective_severity: Option<EffectiveSeverity>,
434}
435
436impl PrivateTypeLeakFinding {
437    /// Build the wrapper from a raw [`PrivateTypeLeak`].
438    #[must_use]
439    pub fn with_actions(leak: PrivateTypeLeak) -> Self {
440        let actions = vec![
441            IssueAction::Fix(FixAction {
442                kind: FixActionType::ExportType,
443                auto_fixable: false,
444                description: "Export the referenced private type by name".to_string(),
445                note: Some(
446                    "Keep the type exported while it is part of a public signature".to_string(),
447                ),
448                available_in_catalogs: None,
449                suggested_target: None,
450            }),
451            IssueAction::SuppressLine(SuppressLineAction {
452                kind: SuppressLineKind::SuppressLine,
453                auto_fixable: false,
454                description: "Suppress with an inline comment above the line".to_string(),
455                comment: "// fallow-ignore-next-line private-type-leak".to_string(),
456                scope: None,
457            }),
458        ];
459        Self {
460            finding_id: None,
461            leak,
462            actions,
463            introduced: None,
464            effective_severity: None,
465        }
466    }
467}
468
469/// Wire-shape envelope for a [`DeprecatedExportInUse`] finding. Carries a
470/// manual `migrate-deprecated-export` primary action plus a `suppress-line`
471/// secondary. Never auto-fixable: fallow does not rewrite consumers.
472#[derive(Debug, Clone, Serialize, Deserialize)]
473#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
474pub struct DeprecatedExportInUseFinding {
475    /// The underlying dead-code entry.
476    #[serde(flatten)]
477    pub export: DeprecatedExportInUse,
478    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
479    /// `~<k>` suffix when several findings of one type share an identity.
480    /// Line and column are not inputs, so the id survives line shifts,
481    /// reformats and reorders. A rename of the file or the symbol gives a
482    /// new id. Absent in output from older versions.
483    #[serde(default, skip_serializing_if = "Option::is_none")]
484    pub finding_id: Option<String>,
485    /// Suggested next steps. Always emitted (possibly empty for
486    /// forward-compat).
487    pub actions: Vec<IssueAction>,
488    /// Set by the audit pass when this finding is introduced relative to
489    /// the merge-base.
490    #[serde(default, skip_serializing_if = "Option::is_none")]
491    pub introduced: Option<AuditIntroduced>,
492    /// Gate severity of this finding after `rules` and `overrides[].rules`
493    /// resolve for its path. CI formats read it for the annotation, SARIF
494    /// and CodeClimate level. Absent in output from older versions. Not
495    /// part of the finding identity, baseline keys or fingerprints.
496    #[serde(
497        default,
498        skip_serializing_if = "Option::is_none",
499        deserialize_with = "deserialize_effective_severity"
500    )]
501    pub effective_severity: Option<EffectiveSeverity>,
502}
503
504impl DeprecatedExportInUseFinding {
505    /// Build the wrapper from a raw [`DeprecatedExportInUse`].
506    #[must_use]
507    pub fn with_actions(export: DeprecatedExportInUse) -> Self {
508        let trace_hint = format!(
509            "For the full consumer list, run `fallow dead-code --trace <path>:{}` with the `path` of this finding.",
510            export.export_name
511        );
512        let note = if export.public_api {
513            format!(
514                "This export is public API. External consumers are not visible, so do not remove it on this evidence alone. {trace_hint}"
515            )
516        } else {
517            format!(
518                "Move each consumer to the replacement that the deprecation message names, then remove the export. {trace_hint}"
519            )
520        };
521        let actions = vec![
522            IssueAction::Fix(FixAction {
523                kind: FixActionType::MigrateDeprecatedExport,
524                auto_fixable: false,
525                description: "Move the consumers off the deprecated export".to_string(),
526                note: Some(note),
527                available_in_catalogs: None,
528                suggested_target: None,
529            }),
530            suppress_line("// fallow-ignore-next-line deprecated-export-in-use"),
531        ];
532        Self {
533            finding_id: None,
534            export,
535            actions,
536            introduced: None,
537            effective_severity: None,
538        }
539    }
540}
541
542/// Wire-shape envelope for an [`UnresolvedImport`] finding. Mirrors
543/// [`UnusedFileFinding`]: flattens the bare finding and carries a typed
544/// `actions` array (`resolve-import` primary plus config and inline
545/// suppression actions).
546#[derive(Debug, Clone, Serialize, Deserialize)]
547#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
548pub struct UnresolvedImportFinding {
549    /// The underlying dead-code entry.
550    #[serde(flatten)]
551    pub import: UnresolvedImport,
552    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
553    /// `~<k>` suffix when several findings of one type share an identity.
554    /// Line and column are not inputs, so the id survives line shifts,
555    /// reformats and reorders. A rename of the file or the symbol gives a
556    /// new id. Absent in output from older versions.
557    #[serde(default, skip_serializing_if = "Option::is_none")]
558    pub finding_id: Option<String>,
559    /// Suggested next steps. Always emitted (possibly empty for
560    /// forward-compat).
561    pub actions: Vec<IssueAction>,
562    /// Set by the audit pass when this finding is introduced relative to
563    /// the merge-base.
564    #[serde(default, skip_serializing_if = "Option::is_none")]
565    pub introduced: Option<AuditIntroduced>,
566    /// Gate severity of this finding after `rules` and `overrides[].rules`
567    /// resolve for its path. CI formats read it for the annotation, SARIF
568    /// and CodeClimate level. Absent in output from older versions. Not
569    /// part of the finding identity, baseline keys or fingerprints.
570    #[serde(
571        default,
572        skip_serializing_if = "Option::is_none",
573        deserialize_with = "deserialize_effective_severity"
574    )]
575    pub effective_severity: Option<EffectiveSeverity>,
576}
577
578impl UnresolvedImportFinding {
579    /// Build the wrapper from a raw [`UnresolvedImport`].
580    #[must_use]
581    pub fn with_actions(import: UnresolvedImport) -> Self {
582        let actions = vec![
583            IssueAction::Fix(FixAction {
584                kind: FixActionType::ResolveImport,
585                auto_fixable: false,
586                description: "Fix the import specifier or install the missing module".to_string(),
587                note: Some(
588                    "Verify the module path and check tsconfig paths configuration".to_string(),
589                ),
590                available_in_catalogs: None,
591                suggested_target: None,
592            }),
593            IssueAction::AddToConfig(AddToConfigAction {
594                kind: AddToConfigKind::AddToConfig,
595                auto_fixable: false,
596                description: format!(
597                    "Add \"{}\" to ignoreUnresolvedImports in fallow config",
598                    import.specifier
599                ),
600                config_key: "ignoreUnresolvedImports".to_string(),
601                value: AddToConfigValue::Scalar(import.specifier.clone()),
602                value_schema: Some(
603                    "https://raw.githubusercontent.com/fallow-rs/fallow/main/schema.json#/properties/ignoreUnresolvedImports/items"
604                        .to_string(),
605                ),
606            }),
607            IssueAction::SuppressLine(SuppressLineAction {
608                kind: SuppressLineKind::SuppressLine,
609                auto_fixable: false,
610                description: "Suppress with an inline comment above the line".to_string(),
611                comment: "// fallow-ignore-next-line unresolved-import".to_string(),
612                scope: None,
613            }),
614        ];
615        Self {
616            finding_id: None,
617            import,
618            actions,
619            introduced: None,
620            effective_severity: None,
621        }
622    }
623}
624
625/// Wire-shape envelope for a [`CircularDependency`] finding. Mirrors
626/// [`UnusedFileFinding`]: flattens the bare finding and carries a typed
627/// `actions` array (`refactor-cycle` primary plus `suppress-line`
628/// secondary).
629#[derive(Debug, Clone, Serialize, Deserialize)]
630#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
631pub struct CircularDependencyFinding {
632    /// The underlying dead-code entry.
633    #[serde(flatten)]
634    pub cycle: CircularDependency,
635    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
636    /// `~<k>` suffix when several findings of one type share an identity.
637    /// Line and column are not inputs, so the id survives line shifts,
638    /// reformats and reorders. A rename of the file or the symbol gives a
639    /// new id. Absent in output from older versions.
640    #[serde(default, skip_serializing_if = "Option::is_none")]
641    pub finding_id: Option<String>,
642    /// Suggested next steps. Always emitted (possibly empty for
643    /// forward-compat).
644    pub actions: Vec<IssueAction>,
645    /// Set by the audit pass when this finding is introduced relative to
646    /// the merge-base.
647    #[serde(default, skip_serializing_if = "Option::is_none")]
648    pub introduced: Option<AuditIntroduced>,
649    /// Gate severity of this finding after `rules` and `overrides[].rules`
650    /// resolve for its path. CI formats read it for the annotation, SARIF
651    /// and CodeClimate level. Absent in output from older versions. Not
652    /// part of the finding identity, baseline keys or fingerprints.
653    #[serde(
654        default,
655        skip_serializing_if = "Option::is_none",
656        deserialize_with = "deserialize_effective_severity"
657    )]
658    pub effective_severity: Option<EffectiveSeverity>,
659}
660
661impl CircularDependencyFinding {
662    /// Build the wrapper from a raw [`CircularDependency`].
663    #[must_use]
664    pub fn with_actions(cycle: CircularDependency) -> Self {
665        let actions = vec![
666            IssueAction::Fix(FixAction {
667                kind: FixActionType::RefactorCycle,
668                auto_fixable: false,
669                description: "Extract shared logic into a separate module to break the cycle"
670                    .to_string(),
671                note: Some(
672                    "Circular imports can cause initialization issues and make code harder to reason about"
673                        .to_string(),
674                ),
675                available_in_catalogs: None,
676                suggested_target: None,
677            }),
678            IssueAction::SuppressLine(SuppressLineAction {
679                kind: SuppressLineKind::SuppressLine,
680                auto_fixable: false,
681                description: "Suppress with an inline comment above the line".to_string(),
682                comment: "// fallow-ignore-next-line circular-dependency".to_string(),
683                scope: None,
684            }),
685        ];
686        Self {
687            finding_id: None,
688            cycle,
689            actions,
690            introduced: None,
691            effective_severity: None,
692        }
693    }
694}
695
696/// Wire-shape envelope for a [`PackageCycle`] finding. Mirrors
697/// [`CircularDependencyFinding`]: flattens the bare finding and carries a
698/// typed `actions` array (`refactor-cycle` primary plus `suppress-line`
699/// secondary).
700#[derive(Debug, Clone, Serialize, Deserialize)]
701#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
702pub struct PackageCycleFinding {
703    /// The underlying dead-code entry.
704    #[serde(flatten)]
705    pub cycle: PackageCycle,
706    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
707    /// `~<k>` suffix when several findings of one type share an identity.
708    /// Line and column are not inputs, so the id survives line shifts,
709    /// reformats and reorders. A rename of the file or the symbol gives a
710    /// new id. Absent in output from older versions.
711    #[serde(default, skip_serializing_if = "Option::is_none")]
712    pub finding_id: Option<String>,
713    /// Suggested next steps. Always emitted (possibly empty for
714    /// forward-compat).
715    pub actions: Vec<IssueAction>,
716    /// Set by the audit pass when this finding is introduced relative to
717    /// the merge-base.
718    #[serde(default, skip_serializing_if = "Option::is_none")]
719    pub introduced: Option<AuditIntroduced>,
720    /// Gate severity of this finding after `rules` and `overrides[].rules`
721    /// resolve for its path. CI formats read it for the annotation, SARIF
722    /// and CodeClimate level. Absent in output from older versions. Not
723    /// part of the finding identity, baseline keys or fingerprints.
724    #[serde(
725        default,
726        skip_serializing_if = "Option::is_none",
727        deserialize_with = "deserialize_effective_severity"
728    )]
729    pub effective_severity: Option<EffectiveSeverity>,
730}
731
732impl PackageCycleFinding {
733    /// Build the wrapper from a raw [`PackageCycle`].
734    #[must_use]
735    pub fn with_actions(cycle: PackageCycle) -> Self {
736        let actions = vec![
737            IssueAction::Fix(FixAction {
738                kind: FixActionType::RefactorCycle,
739                auto_fixable: false,
740                description: "Remove the imports on one hop of the cycle, for example by \
741                              moving the shared code to a package that both packages import"
742                    .to_string(),
743                note: Some(
744                    "Packages that import each other cannot be built in dependency order"
745                        .to_string(),
746                ),
747                available_in_catalogs: None,
748                suggested_target: None,
749            }),
750            IssueAction::SuppressLine(SuppressLineAction {
751                kind: SuppressLineKind::SuppressLine,
752                auto_fixable: false,
753                description: "Suppress with an inline comment above the import. The cycle \
754                              is gone when every import on one hop is suppressed"
755                    .to_string(),
756                comment: "// fallow-ignore-next-line package-cycle".to_string(),
757                scope: None,
758            }),
759        ];
760        Self {
761            cycle,
762            finding_id: None,
763            actions,
764            introduced: None,
765            effective_severity: None,
766        }
767    }
768}
769
770/// Wire-shape envelope for a [`BoundaryViolation`] finding. Mirrors
771/// [`UnusedFileFinding`]: flattens the bare finding and carries a typed
772/// `actions` array (`refactor-boundary` primary plus `suppress-line`
773/// secondary).
774#[derive(Debug, Clone, Serialize, Deserialize)]
775#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
776pub struct BoundaryViolationFinding {
777    /// The underlying dead-code entry.
778    #[serde(flatten)]
779    pub violation: BoundaryViolation,
780    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
781    /// `~<k>` suffix when several findings of one type share an identity.
782    /// Line and column are not inputs, so the id survives line shifts,
783    /// reformats and reorders. A rename of the file or the symbol gives a
784    /// new id. Absent in output from older versions.
785    #[serde(default, skip_serializing_if = "Option::is_none")]
786    pub finding_id: Option<String>,
787    /// Suggested next steps. Always emitted (possibly empty for
788    /// forward-compat).
789    pub actions: Vec<IssueAction>,
790    /// Set by the audit pass when this finding is introduced relative to
791    /// the merge-base.
792    #[serde(default, skip_serializing_if = "Option::is_none")]
793    pub introduced: Option<AuditIntroduced>,
794    /// Gate severity of this finding after `rules` and `overrides[].rules`
795    /// resolve for its path. CI formats read it for the annotation, SARIF
796    /// and CodeClimate level. Absent in output from older versions. Not
797    /// part of the finding identity, baseline keys or fingerprints.
798    #[serde(
799        default,
800        skip_serializing_if = "Option::is_none",
801        deserialize_with = "deserialize_effective_severity"
802    )]
803    pub effective_severity: Option<EffectiveSeverity>,
804}
805
806impl BoundaryViolationFinding {
807    /// Build the wrapper from a raw [`BoundaryViolation`].
808    #[must_use]
809    pub fn with_actions(violation: BoundaryViolation) -> Self {
810        let (description, note) = violation.refactor_action_text();
811        let actions = vec![
812            IssueAction::Fix(FixAction {
813                kind: FixActionType::RefactorBoundary,
814                auto_fixable: false,
815                description: description.to_string(),
816                note: Some(note.to_string()),
817                available_in_catalogs: None,
818                suggested_target: None,
819            }),
820            IssueAction::SuppressLine(SuppressLineAction {
821                kind: SuppressLineKind::SuppressLine,
822                auto_fixable: false,
823                description: "Suppress with an inline comment above the line".to_string(),
824                comment: "// fallow-ignore-next-line boundary-violation".to_string(),
825                scope: None,
826            }),
827        ];
828        Self {
829            finding_id: None,
830            violation,
831            actions,
832            introduced: None,
833            effective_severity: None,
834        }
835    }
836}
837
838/// Wire-shape envelope for a [`BoundaryCoverageViolation`] finding. Carries
839/// actions for assigning the file to a zone or explicitly allowing it to stay
840/// unmatched.
841#[derive(Debug, Clone, Serialize, Deserialize)]
842#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
843pub struct BoundaryCoverageViolationFinding {
844    /// The underlying coverage entry.
845    #[serde(flatten)]
846    pub violation: BoundaryCoverageViolation,
847    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
848    /// `~<k>` suffix when several findings of one type share an identity.
849    /// Line and column are not inputs, so the id survives line shifts,
850    /// reformats and reorders. A rename of the file or the symbol gives a
851    /// new id. Absent in output from older versions.
852    #[serde(default, skip_serializing_if = "Option::is_none")]
853    pub finding_id: Option<String>,
854    /// Suggested next steps.
855    pub actions: Vec<IssueAction>,
856    /// Set by the audit pass when this finding is introduced relative to
857    /// the merge-base.
858    #[serde(default, skip_serializing_if = "Option::is_none")]
859    pub introduced: Option<AuditIntroduced>,
860    /// Gate severity of this finding after `rules` and `overrides[].rules`
861    /// resolve for its path. CI formats read it for the annotation, SARIF
862    /// and CodeClimate level. Absent in output from older versions. Not
863    /// part of the finding identity, baseline keys or fingerprints.
864    #[serde(
865        default,
866        skip_serializing_if = "Option::is_none",
867        deserialize_with = "deserialize_effective_severity"
868    )]
869    pub effective_severity: Option<EffectiveSeverity>,
870}
871
872impl BoundaryCoverageViolationFinding {
873    /// Build the wrapper from a raw [`BoundaryCoverageViolation`].
874    #[must_use]
875    pub fn with_actions(violation: BoundaryCoverageViolation) -> Self {
876        let path = violation.path.to_string_lossy().replace('\\', "/");
877        let actions = vec![
878            IssueAction::Fix(FixAction {
879                kind: FixActionType::RefactorBoundary,
880                auto_fixable: false,
881                description: "Add this file to a boundary zone pattern or move it under an existing zone"
882                    .to_string(),
883                note: Some(
884                    "Boundary coverage is enabled, so every analyzed source file must match a zone unless allow-listed"
885                        .to_string(),
886                ),
887                available_in_catalogs: None,
888                suggested_target: None,
889            }),
890            IssueAction::AddToConfig(AddToConfigAction {
891                kind: AddToConfigKind::AddToConfig,
892                auto_fixable: false,
893                description: format!(
894                    "Add \"{path}\" to boundaries.coverage.allowUnmatched in fallow config"
895                ),
896                config_key: "boundaries.coverage.allowUnmatched".to_string(),
897                value: AddToConfigValue::Scalar(path),
898                value_schema: Some(
899                    "https://raw.githubusercontent.com/fallow-rs/fallow/main/schema.json#/properties/boundaries/properties/coverage/properties/allowUnmatched/items"
900                        .to_string(),
901                ),
902            }),
903            IssueAction::SuppressFile(SuppressFileAction {
904                kind: SuppressFileKind::SuppressFile,
905                auto_fixable: false,
906                description: "Suppress with a file-level comment at the top of the file"
907                    .to_string(),
908                comment: "// fallow-ignore-file boundary-violation".to_string(),
909            }),
910        ];
911        Self {
912            finding_id: None,
913            violation,
914            actions,
915            introduced: None,
916            effective_severity: None,
917        }
918    }
919}
920
921/// Wire-shape envelope for a [`BoundaryCallViolation`] finding. Carries
922/// actions for refactoring the forbidden call out of the zone or suppressing
923/// it with the shared `boundary-violation` token.
924#[derive(Debug, Clone, Serialize, Deserialize)]
925#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
926pub struct BoundaryCallViolationFinding {
927    /// The underlying forbidden-call entry.
928    #[serde(flatten)]
929    pub violation: BoundaryCallViolation,
930    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
931    /// `~<k>` suffix when several findings of one type share an identity.
932    /// Line and column are not inputs, so the id survives line shifts,
933    /// reformats and reorders. A rename of the file or the symbol gives a
934    /// new id. Absent in output from older versions.
935    #[serde(default, skip_serializing_if = "Option::is_none")]
936    pub finding_id: Option<String>,
937    /// Suggested next steps.
938    pub actions: Vec<IssueAction>,
939    /// Set by the audit pass when this finding is introduced relative to
940    /// the merge-base.
941    #[serde(default, skip_serializing_if = "Option::is_none")]
942    pub introduced: Option<AuditIntroduced>,
943    /// Gate severity of this finding after `rules` and `overrides[].rules`
944    /// resolve for its path. CI formats read it for the annotation, SARIF
945    /// and CodeClimate level. Absent in output from older versions. Not
946    /// part of the finding identity, baseline keys or fingerprints.
947    #[serde(
948        default,
949        skip_serializing_if = "Option::is_none",
950        deserialize_with = "deserialize_effective_severity"
951    )]
952    pub effective_severity: Option<EffectiveSeverity>,
953}
954
955impl BoundaryCallViolationFinding {
956    /// Build the wrapper from a raw [`BoundaryCallViolation`].
957    #[must_use]
958    pub fn with_actions(violation: BoundaryCallViolation) -> Self {
959        let actions = vec![
960            IssueAction::Fix(FixAction {
961                kind: FixActionType::RefactorBoundary,
962                auto_fixable: false,
963                description: format!(
964                    "Move the `{}` call out of zone '{}' or behind an allowed abstraction",
965                    violation.callee, violation.zone,
966                ),
967                note: Some(format!(
968                    "`boundaries.calls.forbidden` bans callees matching `{}` from zone '{}'. The check is syntactic: it applies only to files classified into a zone and does not follow aliased or re-bound callees",
969                    violation.pattern, violation.zone,
970                )),
971                available_in_catalogs: None,
972                suggested_target: None,
973            }),
974            IssueAction::SuppressLine(SuppressLineAction {
975                kind: SuppressLineKind::SuppressLine,
976                auto_fixable: false,
977                description: "Suppress with an inline comment above the line".to_string(),
978                comment: "// fallow-ignore-next-line boundary-violation".to_string(),
979                scope: None,
980            }),
981            IssueAction::SuppressFile(SuppressFileAction {
982                kind: SuppressFileKind::SuppressFile,
983                auto_fixable: false,
984                description: "Suppress with a file-level comment at the top of the file"
985                    .to_string(),
986                comment: "// fallow-ignore-file boundary-violation".to_string(),
987            }),
988        ];
989        Self {
990            finding_id: None,
991            violation,
992            actions,
993            introduced: None,
994            effective_severity: None,
995        }
996    }
997}
998
999/// Wire-shape envelope for a [`PolicyViolation`] finding. Carries actions for
1000/// replacing the banned call, import, or effect, or suppressing it with a scoped
1001/// `policy-violation:<pack>/<rule-id>` token.
1002#[derive(Debug, Clone, Serialize, Deserialize)]
1003#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1004pub struct PolicyViolationFinding {
1005    /// The underlying rule-pack policy entry.
1006    #[serde(flatten)]
1007    pub violation: PolicyViolation,
1008    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
1009    /// `~<k>` suffix when several findings of one type share an identity.
1010    /// Line and column are not inputs, so the id survives line shifts,
1011    /// reformats and reorders. A rename of the file or the symbol gives a
1012    /// new id. Absent in output from older versions.
1013    #[serde(default, skip_serializing_if = "Option::is_none")]
1014    pub finding_id: Option<String>,
1015    /// Suggested next steps.
1016    pub actions: Vec<IssueAction>,
1017    /// Set by the audit pass when this finding is introduced relative to
1018    /// the merge-base.
1019    #[serde(default, skip_serializing_if = "Option::is_none")]
1020    pub introduced: Option<AuditIntroduced>,
1021}
1022
1023impl PolicyViolationFinding {
1024    /// Build the wrapper from a raw [`PolicyViolation`].
1025    #[must_use]
1026    pub fn with_actions(violation: PolicyViolation) -> Self {
1027        let what = match violation.kind {
1028            crate::results::PolicyRuleKind::BannedCall => "call",
1029            crate::results::PolicyRuleKind::BannedImport => "import",
1030            crate::results::PolicyRuleKind::BannedEffect => "effect",
1031            crate::results::PolicyRuleKind::BannedExport => "export",
1032            crate::results::PolicyRuleKind::GdpProofProducer => "proof producer",
1033        };
1034        let description = match &violation.message {
1035            Some(message) => format!("Replace the `{}` {what}: {message}", violation.matched),
1036            None => format!("Replace the `{}` {what}", violation.matched),
1037        };
1038        let suppress_token = format!("policy-violation:{}/{}", violation.pack, violation.rule_id);
1039        let note = if violation.kind == crate::results::PolicyRuleKind::GdpProofProducer {
1040            "This check resolves the gdp-ts factory through static imports and unambiguous re-exports. Move proof creation to an allowed module. It does not verify authorization logic or follow arbitrary wrappers.".to_owned()
1041        } else {
1042            format!(
1043                "Rule `{}/{}` from the configured rule packs bans this {what}. The check is syntactic: it does not follow aliased or re-bound callees, and import matching uses the raw specifier",
1044                violation.pack, violation.rule_id,
1045            )
1046        };
1047        let actions = vec![
1048            IssueAction::Fix(FixAction {
1049                kind: FixActionType::ResolvePolicyViolation,
1050                auto_fixable: false,
1051                description,
1052                note: Some(note),
1053                available_in_catalogs: None,
1054                suggested_target: None,
1055            }),
1056            IssueAction::SuppressLine(SuppressLineAction {
1057                kind: SuppressLineKind::SuppressLine,
1058                auto_fixable: false,
1059                description: "Suppress this rule-pack rule with an inline comment above the line"
1060                    .to_string(),
1061                comment: format!("// fallow-ignore-next-line {suppress_token}"),
1062                scope: None,
1063            }),
1064            IssueAction::SuppressFile(SuppressFileAction {
1065                kind: SuppressFileKind::SuppressFile,
1066                auto_fixable: false,
1067                description:
1068                    "Suppress this rule-pack rule with a file-level comment at the top of the file"
1069                        .to_string(),
1070                comment: format!("// fallow-ignore-file {suppress_token}"),
1071            }),
1072        ];
1073        Self {
1074            finding_id: None,
1075            violation,
1076            actions,
1077            introduced: None,
1078        }
1079    }
1080}
1081
1082/// Wire-shape envelope for an [`UnusedExport`] finding consumed under the
1083/// `unused_exports` key. Same Rust struct as [`UnusedTypeFinding`], with a
1084/// different fix description so consumers can tell value-export from
1085/// type-export removal at the action level.
1086#[derive(Debug, Clone, Serialize, Deserialize)]
1087#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1088pub struct UnusedExportFinding {
1089    /// The underlying dead-code entry.
1090    #[serde(flatten)]
1091    pub export: UnusedExport,
1092    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
1093    /// `~<k>` suffix when several findings of one type share an identity.
1094    /// Line and column are not inputs, so the id survives line shifts,
1095    /// reformats and reorders. A rename of the file or the symbol gives a
1096    /// new id. Absent in output from older versions.
1097    #[serde(default, skip_serializing_if = "Option::is_none")]
1098    pub finding_id: Option<String>,
1099    /// Suggested next steps. Always emitted (possibly empty for
1100    /// forward-compat).
1101    pub actions: Vec<IssueAction>,
1102    /// Type-aware evidence for this exact candidate when requested.
1103    #[serde(default, skip_serializing_if = "Option::is_none")]
1104    pub semantic: Option<SemanticCandidateDecision>,
1105    /// Set by the audit pass when this finding is introduced relative to
1106    /// the merge-base.
1107    #[serde(default, skip_serializing_if = "Option::is_none")]
1108    pub introduced: Option<AuditIntroduced>,
1109    /// Gate severity of this finding after `rules` and `overrides[].rules`
1110    /// resolve for its path. CI formats read it for the annotation, SARIF
1111    /// and CodeClimate level. Absent in output from older versions. Not
1112    /// part of the finding identity, baseline keys or fingerprints.
1113    #[serde(
1114        default,
1115        skip_serializing_if = "Option::is_none",
1116        deserialize_with = "deserialize_effective_severity"
1117    )]
1118    pub effective_severity: Option<EffectiveSeverity>,
1119    /// Advisory caveats on the reachability verdict behind this finding.
1120    /// Sorted, deduplicated, and omitted from the wire when empty. Never gates
1121    /// the finding or the `remove-export` action, though `fallow fix` does
1122    /// withhold the removal of a caveated export as low confidence.
1123    #[serde(default, skip_serializing_if = "Vec::is_empty")]
1124    pub reachability_caveats: Vec<ReachabilityCaveat>,
1125    /// Production mode only: the test-side files that import this export. A
1126    /// file is test-side when an entry point reaches it and a production
1127    /// exclude pattern or a `production.ignore` glob matches it (test, story,
1128    /// fixture and bench files), or when no runtime entry point reaches it (a
1129    /// file that only a support entry seeds). When present,
1130    /// the `remove-export` action is not auto-fixable, because the removal
1131    /// breaks these imports. Absent when no such file imports the export.
1132    #[serde(default, skip_serializing_if = "Option::is_none")]
1133    pub test_importers: Option<TestImporters>,
1134}
1135
1136impl UnusedExportFinding {
1137    /// Build the wrapper. When `export.is_re_export` is true, the fix
1138    /// action's `note` warns about possible public-API surface; otherwise
1139    /// `note` is absent on the fix action.
1140    #[must_use]
1141    pub fn with_actions(export: UnusedExport) -> Self {
1142        let note = if export.is_re_export {
1143            Some(
1144                "This finding originates from a re-export; verify it is not part of your public API before removing"
1145                    .to_string(),
1146            )
1147        } else {
1148            None
1149        };
1150        let actions = vec![
1151            IssueAction::Fix(FixAction {
1152                kind: FixActionType::RemoveExport,
1153                auto_fixable: true,
1154                description: "Remove the unused export from the public API".to_string(),
1155                note,
1156                available_in_catalogs: None,
1157                suggested_target: None,
1158            }),
1159            IssueAction::SuppressLine(SuppressLineAction {
1160                kind: SuppressLineKind::SuppressLine,
1161                auto_fixable: false,
1162                description: "Suppress with an inline comment above the line".to_string(),
1163                comment: "// fallow-ignore-next-line unused-export".to_string(),
1164                scope: None,
1165            }),
1166        ];
1167        Self {
1168            finding_id: None,
1169            export,
1170            actions,
1171            semantic: None,
1172            introduced: None,
1173            effective_severity: None,
1174            reachability_caveats: Vec::new(),
1175            test_importers: None,
1176        }
1177    }
1178
1179    /// Attach type-aware evidence and disable the syntactic fix when semantic
1180    /// analysis could not establish complete negative evidence.
1181    pub fn set_semantic_decision(&mut self, decision: SemanticCandidateDecision) {
1182        set_export_semantic_action(&mut self.actions, &decision, &self.reachability_caveats);
1183        self.semantic = Some(decision);
1184    }
1185}
1186
1187/// Wire-shape envelope for an [`UnusedExport`] finding consumed under the
1188/// `unused_types` key. Wraps the same bare [`UnusedExport`] struct as
1189/// [`UnusedExportFinding`] but emits a fix action targeted at type-only
1190/// declarations, with the same `is_re_export`-aware note swap.
1191#[derive(Debug, Clone, Serialize, Deserialize)]
1192#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1193pub struct UnusedTypeFinding {
1194    /// The underlying dead-code entry.
1195    #[serde(flatten)]
1196    pub export: UnusedExport,
1197    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
1198    /// `~<k>` suffix when several findings of one type share an identity.
1199    /// Line and column are not inputs, so the id survives line shifts,
1200    /// reformats and reorders. A rename of the file or the symbol gives a
1201    /// new id. Absent in output from older versions.
1202    #[serde(default, skip_serializing_if = "Option::is_none")]
1203    pub finding_id: Option<String>,
1204    /// Suggested next steps. Always emitted (possibly empty for
1205    /// forward-compat).
1206    pub actions: Vec<IssueAction>,
1207    /// Type-aware evidence for this exact candidate when requested.
1208    #[serde(default, skip_serializing_if = "Option::is_none")]
1209    pub semantic: Option<SemanticCandidateDecision>,
1210    /// Set by the audit pass when this finding is introduced relative to
1211    /// the merge-base.
1212    #[serde(default, skip_serializing_if = "Option::is_none")]
1213    pub introduced: Option<AuditIntroduced>,
1214    /// Gate severity of this finding after `rules` and `overrides[].rules`
1215    /// resolve for its path. CI formats read it for the annotation, SARIF
1216    /// and CodeClimate level. Absent in output from older versions. Not
1217    /// part of the finding identity, baseline keys or fingerprints.
1218    #[serde(
1219        default,
1220        skip_serializing_if = "Option::is_none",
1221        deserialize_with = "deserialize_effective_severity"
1222    )]
1223    pub effective_severity: Option<EffectiveSeverity>,
1224    /// Advisory caveats on the reachability verdict behind this finding.
1225    /// A type export rests on exactly the reachability test an
1226    /// `unused_exports[]` entry does, and the LSP offers the same
1227    /// remove-the-`export`-keyword quick fix for both, so the two must render
1228    /// with the same confidence. Sorted, deduplicated, omitted when empty.
1229    #[serde(default, skip_serializing_if = "Vec::is_empty")]
1230    pub reachability_caveats: Vec<ReachabilityCaveat>,
1231    /// Production mode only: the test-side files that import this type. The
1232    /// same rule as [`UnusedExportFinding::test_importers`] applies, and the
1233    /// `remove-export` action is not auto-fixable when the field is present.
1234    #[serde(default, skip_serializing_if = "Option::is_none")]
1235    pub test_importers: Option<TestImporters>,
1236}
1237
1238impl UnusedTypeFinding {
1239    /// Build the wrapper. `is_re_export` swaps the fix note the same way as
1240    /// [`UnusedExportFinding::with_actions`].
1241    #[must_use]
1242    pub fn with_actions(export: UnusedExport) -> Self {
1243        let note = if export.is_re_export {
1244            Some(
1245                "This finding originates from a re-export; verify it is not part of your public API before removing"
1246                    .to_string(),
1247            )
1248        } else {
1249            None
1250        };
1251        let actions = vec![
1252            IssueAction::Fix(FixAction {
1253                kind: FixActionType::RemoveExport,
1254                auto_fixable: true,
1255                description:
1256                    "Remove the `export` (or `export type`) keyword from the type declaration"
1257                        .to_string(),
1258                note,
1259                available_in_catalogs: None,
1260                suggested_target: None,
1261            }),
1262            IssueAction::SuppressLine(SuppressLineAction {
1263                kind: SuppressLineKind::SuppressLine,
1264                auto_fixable: false,
1265                description: "Suppress with an inline comment above the line".to_string(),
1266                comment: "// fallow-ignore-next-line unused-type".to_string(),
1267                scope: None,
1268            }),
1269        ];
1270        Self {
1271            finding_id: None,
1272            export,
1273            actions,
1274            semantic: None,
1275            introduced: None,
1276            effective_severity: None,
1277            reachability_caveats: Vec::new(),
1278            test_importers: None,
1279        }
1280    }
1281
1282    /// Attach type-aware evidence and disable the syntactic fix when semantic
1283    /// analysis could not establish complete negative evidence.
1284    pub fn set_semantic_decision(&mut self, decision: SemanticCandidateDecision) {
1285        set_export_semantic_action(&mut self.actions, &decision, &self.reachability_caveats);
1286        self.semantic = Some(decision);
1287    }
1288}
1289
1290/// The semantic pass runs in the API layer, AFTER the analysis layer stamped
1291/// this run's caveats, and it is the one code path that RAISES `auto_fixable`.
1292/// It therefore has to ask the gate too, or a `Complete` semantic verdict would
1293/// silently re-open a mutation the incomplete run had already withheld.
1294fn set_export_semantic_action(
1295    actions: &mut [IssueAction],
1296    decision: &SemanticCandidateDecision,
1297    caveats: &[ReachabilityCaveat],
1298) {
1299    let complete_negative = decision.decision
1300        == SemanticCandidateDecisionKind::ConfirmedNoStaticReferences
1301        && decision.status == SemanticCompleteness::Complete;
1302    let Some(IssueAction::Fix(action)) = actions.first_mut() else {
1303        return;
1304    };
1305    action.auto_fixable = complete_negative && caveats.is_empty();
1306    if !complete_negative {
1307        action.note = Some(
1308            "Type-aware analysis retained this candidate because complete negative evidence was not available"
1309                .to_string(),
1310        );
1311    }
1312    if !caveats.is_empty() {
1313        action.note = Some(INCOMPLETE_EVIDENCE_NOTE.to_string());
1314    }
1315}
1316
1317/// Wire-shape envelope for an [`InvalidClientExport`] finding. There is no safe
1318/// auto-fix: the export itself may be a legitimate client-component value
1319/// export that happens to collide with a Next.js server-only name, so removing
1320/// it could break the component. Actions are a manual `move-to-server-module`
1321/// fix (the real remediation) plus a line-level suppress.
1322#[derive(Debug, Clone, Serialize, Deserialize)]
1323#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1324pub struct InvalidClientExportFinding {
1325    /// The underlying dead-code entry.
1326    #[serde(flatten)]
1327    pub export: InvalidClientExport,
1328    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
1329    /// `~<k>` suffix when several findings of one type share an identity.
1330    /// Line and column are not inputs, so the id survives line shifts,
1331    /// reformats and reorders. A rename of the file or the symbol gives a
1332    /// new id. Absent in output from older versions.
1333    #[serde(default, skip_serializing_if = "Option::is_none")]
1334    pub finding_id: Option<String>,
1335    /// Suggested next steps. Always emitted (possibly empty for
1336    /// forward-compat).
1337    pub actions: Vec<IssueAction>,
1338    /// Set by the audit pass when this finding is introduced relative to
1339    /// the merge-base.
1340    #[serde(default, skip_serializing_if = "Option::is_none")]
1341    pub introduced: Option<AuditIntroduced>,
1342    /// Gate severity of this finding after `rules` and `overrides[].rules`
1343    /// resolve for its path. CI formats read it for the annotation, SARIF
1344    /// and CodeClimate level. Absent in output from older versions. Not
1345    /// part of the finding identity, baseline keys or fingerprints.
1346    #[serde(
1347        default,
1348        skip_serializing_if = "Option::is_none",
1349        deserialize_with = "deserialize_effective_severity"
1350    )]
1351    pub effective_severity: Option<EffectiveSeverity>,
1352}
1353
1354impl InvalidClientExportFinding {
1355    /// Build the wrapper from a raw [`InvalidClientExport`]. Emits a manual
1356    /// fix action (move the server-only export to a non-client module) plus a
1357    /// line-level suppress: there is no safe auto-fix because removing the
1358    /// export could break a legitimate client component.
1359    #[must_use]
1360    pub fn with_actions(export: InvalidClientExport) -> Self {
1361        let actions = vec![
1362            IssueAction::Fix(FixAction {
1363                kind: FixActionType::MoveToServerModule,
1364                auto_fixable: false,
1365                description: "Move the server-only export to a non-client module and import it from there"
1366                    .to_string(),
1367                note: Some(
1368                    "A \"use client\" file cannot export a Next.js server-only or route-config name; Next.js rejects it at build time"
1369                        .to_string(),
1370                ),
1371                available_in_catalogs: None,
1372                suggested_target: None,
1373            }),
1374            IssueAction::SuppressLine(SuppressLineAction {
1375                kind: SuppressLineKind::SuppressLine,
1376                auto_fixable: false,
1377                description: "Suppress with an inline comment above the line".to_string(),
1378                comment: "// fallow-ignore-next-line invalid-client-export".to_string(),
1379                scope: None,
1380            }),
1381        ];
1382        Self {
1383            finding_id: None,
1384            export,
1385            actions,
1386            introduced: None,
1387            effective_severity: None,
1388        }
1389    }
1390}
1391
1392/// Wire-shape envelope for a [`MixedClientServerBarrel`] finding. There is no
1393/// safe auto-fix: splitting a barrel into separate client and server modules is
1394/// a human decision (the barrel may intentionally aggregate both surfaces).
1395/// Actions are a manual `split-mixed-barrel` fix (the real remediation) plus a
1396/// line-level suppress.
1397#[derive(Debug, Clone, Serialize, Deserialize)]
1398#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1399pub struct MixedClientServerBarrelFinding {
1400    /// The underlying dead-code entry.
1401    #[serde(flatten)]
1402    pub barrel: MixedClientServerBarrel,
1403    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
1404    /// `~<k>` suffix when several findings of one type share an identity.
1405    /// Line and column are not inputs, so the id survives line shifts,
1406    /// reformats and reorders. A rename of the file or the symbol gives a
1407    /// new id. Absent in output from older versions.
1408    #[serde(default, skip_serializing_if = "Option::is_none")]
1409    pub finding_id: Option<String>,
1410    /// Suggested next steps. Always emitted (possibly empty for
1411    /// forward-compat).
1412    pub actions: Vec<IssueAction>,
1413    /// Set by the audit pass when this finding is introduced relative to
1414    /// the merge-base.
1415    #[serde(default, skip_serializing_if = "Option::is_none")]
1416    pub introduced: Option<AuditIntroduced>,
1417    /// Gate severity of this finding after `rules` and `overrides[].rules`
1418    /// resolve for its path. CI formats read it for the annotation, SARIF
1419    /// and CodeClimate level. Absent in output from older versions. Not
1420    /// part of the finding identity, baseline keys or fingerprints.
1421    #[serde(
1422        default,
1423        skip_serializing_if = "Option::is_none",
1424        deserialize_with = "deserialize_effective_severity"
1425    )]
1426    pub effective_severity: Option<EffectiveSeverity>,
1427}
1428
1429impl MixedClientServerBarrelFinding {
1430    /// Build the wrapper from a raw [`MixedClientServerBarrel`]. Emits a manual
1431    /// fix action (split the barrel into separate client and server halves)
1432    /// plus a line-level suppress: there is no safe auto-fix because splitting
1433    /// the barrel is a human decision.
1434    #[must_use]
1435    pub fn with_actions(barrel: MixedClientServerBarrel) -> Self {
1436        let actions = vec![
1437            IssueAction::Fix(FixAction {
1438                kind: FixActionType::SplitMixedBarrel,
1439                auto_fixable: false,
1440                description: "Split the barrel so client and server-only modules are re-exported from separate files"
1441                    .to_string(),
1442                note: Some(
1443                    "Importing one name from this barrel drags the other's directive across the client/server boundary"
1444                        .to_string(),
1445                ),
1446                available_in_catalogs: None,
1447                suggested_target: None,
1448            }),
1449            IssueAction::SuppressLine(SuppressLineAction {
1450                kind: SuppressLineKind::SuppressLine,
1451                auto_fixable: false,
1452                description: "Suppress with an inline comment above the line".to_string(),
1453                comment: "// fallow-ignore-next-line mixed-client-server-barrel".to_string(),
1454                scope: None,
1455            }),
1456        ];
1457        Self {
1458            finding_id: None,
1459            barrel,
1460            actions,
1461            introduced: None,
1462            effective_severity: None,
1463        }
1464    }
1465}
1466
1467/// Wire-shape envelope for a [`MisplacedDirective`] finding. There is no safe
1468/// auto-fix: moving a directive to the leading prologue is a small but
1469/// judgement-bearing edit (the author may have intended the file to be a
1470/// server module after all). Actions are a manual `hoist-directive` fix (the
1471/// real remediation) plus a line-level suppress.
1472#[derive(Debug, Clone, Serialize, Deserialize)]
1473#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1474pub struct MisplacedDirectiveFinding {
1475    /// The underlying dead-code entry.
1476    #[serde(flatten)]
1477    pub directive_site: MisplacedDirective,
1478    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
1479    /// `~<k>` suffix when several findings of one type share an identity.
1480    /// Line and column are not inputs, so the id survives line shifts,
1481    /// reformats and reorders. A rename of the file or the symbol gives a
1482    /// new id. Absent in output from older versions.
1483    #[serde(default, skip_serializing_if = "Option::is_none")]
1484    pub finding_id: Option<String>,
1485    /// Suggested next steps. Always emitted (possibly empty for
1486    /// forward-compat).
1487    pub actions: Vec<IssueAction>,
1488    /// Set by the audit pass when this finding is introduced relative to
1489    /// the merge-base.
1490    #[serde(default, skip_serializing_if = "Option::is_none")]
1491    pub introduced: Option<AuditIntroduced>,
1492    /// Gate severity of this finding after `rules` and `overrides[].rules`
1493    /// resolve for its path. CI formats read it for the annotation, SARIF
1494    /// and CodeClimate level. Absent in output from older versions. Not
1495    /// part of the finding identity, baseline keys or fingerprints.
1496    #[serde(
1497        default,
1498        skip_serializing_if = "Option::is_none",
1499        deserialize_with = "deserialize_effective_severity"
1500    )]
1501    pub effective_severity: Option<EffectiveSeverity>,
1502}
1503
1504impl MisplacedDirectiveFinding {
1505    /// Build the wrapper from a raw [`MisplacedDirective`]. Emits a manual fix
1506    /// action (hoist the directive to the leading prologue) plus a line-level
1507    /// suppress: there is no safe auto-fix because moving a directive can
1508    /// change module semantics and is a human decision.
1509    #[must_use]
1510    pub fn with_actions(directive_site: MisplacedDirective) -> Self {
1511        let actions = vec![
1512            IssueAction::Fix(FixAction {
1513                kind: FixActionType::HoistDirective,
1514                auto_fixable: false,
1515                description: "Move the directive to the very top of the file, above all imports and statements"
1516                    .to_string(),
1517                note: Some(
1518                    "An RSC bundler honors the directive only in the leading prologue; here it precedes other statements and is silently ignored"
1519                        .to_string(),
1520                ),
1521                available_in_catalogs: None,
1522                suggested_target: None,
1523            }),
1524            IssueAction::SuppressLine(SuppressLineAction {
1525                kind: SuppressLineKind::SuppressLine,
1526                auto_fixable: false,
1527                description: "Suppress with an inline comment above the line".to_string(),
1528                comment: "// fallow-ignore-next-line misplaced-directive".to_string(),
1529                scope: None,
1530            }),
1531        ];
1532        Self {
1533            finding_id: None,
1534            directive_site,
1535            actions,
1536            introduced: None,
1537            effective_severity: None,
1538        }
1539    }
1540}
1541
1542/// Wire-shape envelope for an [`UnprovidedInject`] finding. There is no safe
1543/// auto-fix: the fix is binary but judgement-bearing (add a `provide` for the
1544/// key, or delete the dead inject). Actions are manual remediation guidance
1545/// plus a line-level suppress.
1546#[derive(Debug, Clone, Serialize, Deserialize)]
1547#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1548pub struct UnprovidedInjectFinding {
1549    /// The underlying finding.
1550    #[serde(flatten)]
1551    pub inject: UnprovidedInject,
1552    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
1553    /// `~<k>` suffix when several findings of one type share an identity.
1554    /// Line and column are not inputs, so the id survives line shifts,
1555    /// reformats and reorders. A rename of the file or the symbol gives a
1556    /// new id. Absent in output from older versions.
1557    #[serde(default, skip_serializing_if = "Option::is_none")]
1558    pub finding_id: Option<String>,
1559    /// Suggested next steps. Always emitted (possibly empty for
1560    /// forward-compat).
1561    pub actions: Vec<IssueAction>,
1562    /// Set by the audit pass when this finding is introduced relative to
1563    /// the merge-base.
1564    #[serde(default, skip_serializing_if = "Option::is_none")]
1565    pub introduced: Option<AuditIntroduced>,
1566    /// Gate severity of this finding after `rules` and `overrides[].rules`
1567    /// resolve for its path. CI formats read it for the annotation, SARIF
1568    /// and CodeClimate level. Absent in output from older versions. Not
1569    /// part of the finding identity, baseline keys or fingerprints.
1570    #[serde(
1571        default,
1572        skip_serializing_if = "Option::is_none",
1573        deserialize_with = "deserialize_effective_severity"
1574    )]
1575    pub effective_severity: Option<EffectiveSeverity>,
1576}
1577
1578impl UnprovidedInjectFinding {
1579    /// Build the wrapper from a raw [`UnprovidedInject`]. Emits a manual fix
1580    /// action plus a line-level suppress.
1581    #[must_use]
1582    pub fn with_actions(inject: UnprovidedInject) -> Self {
1583        let actions = vec![
1584            manual_framework_fix(
1585                FixActionType::ProvideInject,
1586                "Provide this injected key, or remove the inject / getContext call",
1587                "Manual review required: dependency-injection keys can be provided by framework wiring, tests, or package consumers outside this project.",
1588            ),
1589            suppress_line("// fallow-ignore-next-line unprovided-inject"),
1590        ];
1591        Self {
1592            finding_id: None,
1593            inject,
1594            actions,
1595            introduced: None,
1596            effective_severity: None,
1597        }
1598    }
1599}
1600
1601/// Wire-shape envelope for an [`UnusedServerAction`] finding. There is no safe
1602/// auto-fix: the fix is binary but judgement-bearing (wire the action up to a
1603/// consumer, or delete it). Actions are manual remediation guidance plus a
1604/// line-level suppress.
1605#[derive(Debug, Clone, Serialize, Deserialize)]
1606#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1607pub struct UnusedServerActionFinding {
1608    /// The underlying finding.
1609    #[serde(flatten)]
1610    pub action: UnusedServerAction,
1611    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
1612    /// `~<k>` suffix when several findings of one type share an identity.
1613    /// Line and column are not inputs, so the id survives line shifts,
1614    /// reformats and reorders. A rename of the file or the symbol gives a
1615    /// new id. Absent in output from older versions.
1616    #[serde(default, skip_serializing_if = "Option::is_none")]
1617    pub finding_id: Option<String>,
1618    /// Suggested next steps. Always emitted (possibly empty for
1619    /// forward-compat).
1620    pub actions: Vec<IssueAction>,
1621    /// Set by the audit pass when this finding is introduced relative to
1622    /// the merge-base.
1623    #[serde(default, skip_serializing_if = "Option::is_none")]
1624    pub introduced: Option<AuditIntroduced>,
1625    /// Gate severity of this finding after `rules` and `overrides[].rules`
1626    /// resolve for its path. CI formats read it for the annotation, SARIF
1627    /// and CodeClimate level. Absent in output from older versions. Not
1628    /// part of the finding identity, baseline keys or fingerprints.
1629    #[serde(
1630        default,
1631        skip_serializing_if = "Option::is_none",
1632        deserialize_with = "deserialize_effective_severity"
1633    )]
1634    pub effective_severity: Option<EffectiveSeverity>,
1635}
1636
1637impl UnusedServerActionFinding {
1638    /// Build the wrapper from a raw [`UnusedServerAction`]. Emits a manual fix
1639    /// action plus a line-level suppress.
1640    #[must_use]
1641    pub fn with_actions(action: UnusedServerAction) -> Self {
1642        let actions = vec![
1643            manual_framework_fix(
1644                FixActionType::WireServerAction,
1645                "Wire the server action to a caller or form action, or remove it",
1646                "Manual review required: server actions may still be POST-able by action id or invoked reflectively outside the static project graph.",
1647            ),
1648            suppress_line("// fallow-ignore-next-line unused-server-action"),
1649        ];
1650        Self {
1651            finding_id: None,
1652            action,
1653            actions,
1654            introduced: None,
1655            effective_severity: None,
1656        }
1657    }
1658}
1659
1660/// Wire-shape envelope for an [`UnusedLoadDataKey`] finding. There is no safe
1661/// auto-fix: a `load()` fetch can have side effects, so deleting the key is a
1662/// human call. Actions are manual remediation guidance plus a line-level
1663/// suppress.
1664#[derive(Debug, Clone, Serialize, Deserialize)]
1665#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1666pub struct UnusedLoadDataKeyFinding {
1667    /// The underlying finding.
1668    #[serde(flatten)]
1669    pub key: UnusedLoadDataKey,
1670    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
1671    /// `~<k>` suffix when several findings of one type share an identity.
1672    /// Line and column are not inputs, so the id survives line shifts,
1673    /// reformats and reorders. A rename of the file or the symbol gives a
1674    /// new id. Absent in output from older versions.
1675    #[serde(default, skip_serializing_if = "Option::is_none")]
1676    pub finding_id: Option<String>,
1677    /// Suggested next steps. Always emitted (possibly empty for
1678    /// forward-compat).
1679    pub actions: Vec<IssueAction>,
1680    /// Set by the audit pass when this finding is introduced relative to
1681    /// the merge-base.
1682    #[serde(default, skip_serializing_if = "Option::is_none")]
1683    pub introduced: Option<AuditIntroduced>,
1684    /// Gate severity of this finding after `rules` and `overrides[].rules`
1685    /// resolve for its path. CI formats read it for the annotation, SARIF
1686    /// and CodeClimate level. Absent in output from older versions. Not
1687    /// part of the finding identity, baseline keys or fingerprints.
1688    #[serde(
1689        default,
1690        skip_serializing_if = "Option::is_none",
1691        deserialize_with = "deserialize_effective_severity"
1692    )]
1693    pub effective_severity: Option<EffectiveSeverity>,
1694}
1695
1696impl UnusedLoadDataKeyFinding {
1697    /// Build the wrapper from a raw [`UnusedLoadDataKey`]. Emits a manual fix
1698    /// action plus a line-level suppress.
1699    #[must_use]
1700    pub fn with_actions(key: UnusedLoadDataKey) -> Self {
1701        let actions = vec![
1702            manual_framework_fix(
1703                FixActionType::UseLoadData,
1704                "Read this load data key from the route UI, or remove it from the load return",
1705                "Manual review required: load functions can perform real server or database work, so verify side effects before deleting the producer.",
1706            ),
1707            suppress_line("// fallow-ignore-next-line unused-load-data-key"),
1708        ];
1709        Self {
1710            finding_id: None,
1711            key,
1712            actions,
1713            introduced: None,
1714            effective_severity: None,
1715        }
1716    }
1717}
1718
1719/// Wire-shape envelope for an [`UnrenderedComponent`] finding. There is no safe
1720/// auto-fix: the fix is binary but judgement-bearing (render the component
1721/// somewhere, or delete the dead component). Actions are manual remediation
1722/// guidance plus a line-level suppress.
1723#[derive(Debug, Clone, Serialize, Deserialize)]
1724#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1725pub struct UnrenderedComponentFinding {
1726    /// The underlying finding.
1727    #[serde(flatten)]
1728    pub component: UnrenderedComponent,
1729    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
1730    /// `~<k>` suffix when several findings of one type share an identity.
1731    /// Line and column are not inputs, so the id survives line shifts,
1732    /// reformats and reorders. A rename of the file or the symbol gives a
1733    /// new id. Absent in output from older versions.
1734    #[serde(default, skip_serializing_if = "Option::is_none")]
1735    pub finding_id: Option<String>,
1736    /// Suggested next steps. Always emitted (possibly empty for
1737    /// forward-compat).
1738    pub actions: Vec<IssueAction>,
1739    /// Set by the audit pass when this finding is introduced relative to
1740    /// the merge-base.
1741    #[serde(default, skip_serializing_if = "Option::is_none")]
1742    pub introduced: Option<AuditIntroduced>,
1743    /// Gate severity of this finding after `rules` and `overrides[].rules`
1744    /// resolve for its path. CI formats read it for the annotation, SARIF
1745    /// and CodeClimate level. Absent in output from older versions. Not
1746    /// part of the finding identity, baseline keys or fingerprints.
1747    #[serde(
1748        default,
1749        skip_serializing_if = "Option::is_none",
1750        deserialize_with = "deserialize_effective_severity"
1751    )]
1752    pub effective_severity: Option<EffectiveSeverity>,
1753}
1754
1755impl UnrenderedComponentFinding {
1756    /// Build the wrapper from a raw [`UnrenderedComponent`]. Emits a manual
1757    /// fix action plus a line-level suppress.
1758    #[must_use]
1759    pub fn with_actions(component: UnrenderedComponent) -> Self {
1760        let actions = vec![
1761            manual_framework_fix(
1762                FixActionType::RenderComponent,
1763                "Render the reachable component from project code, or remove it",
1764                "Manual review required: exported library components and dynamic render registries can be intentionally reachable without static template usage.",
1765            ),
1766            suppress_line("// fallow-ignore-next-line unrendered-component"),
1767        ];
1768        Self {
1769            finding_id: None,
1770            component,
1771            actions,
1772            introduced: None,
1773            effective_severity: None,
1774        }
1775    }
1776}
1777
1778/// Wire-shape envelope for an [`UnusedComponentProp`] finding. There is no safe
1779/// auto-fix: removing a declared prop is judgement-bearing (the prop may be part
1780/// of a deliberately-stable public component API). Actions are manual
1781/// remediation guidance plus a line-level suppress at the prop declaration.
1782#[derive(Debug, Clone, Serialize, Deserialize)]
1783#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1784pub struct UnusedComponentPropFinding {
1785    /// The underlying finding.
1786    #[serde(flatten)]
1787    pub prop: UnusedComponentProp,
1788    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
1789    /// `~<k>` suffix when several findings of one type share an identity.
1790    /// Line and column are not inputs, so the id survives line shifts,
1791    /// reformats and reorders. A rename of the file or the symbol gives a
1792    /// new id. Absent in output from older versions.
1793    #[serde(default, skip_serializing_if = "Option::is_none")]
1794    pub finding_id: Option<String>,
1795    /// Suggested next steps. Always emitted (possibly empty for
1796    /// forward-compat).
1797    pub actions: Vec<IssueAction>,
1798    /// Set by the audit pass when this finding is introduced relative to
1799    /// the merge-base.
1800    #[serde(default, skip_serializing_if = "Option::is_none")]
1801    pub introduced: Option<AuditIntroduced>,
1802    /// Gate severity of this finding after `rules` and `overrides[].rules`
1803    /// resolve for its path. CI formats read it for the annotation, SARIF
1804    /// and CodeClimate level. Absent in output from older versions. Not
1805    /// part of the finding identity, baseline keys or fingerprints.
1806    #[serde(
1807        default,
1808        skip_serializing_if = "Option::is_none",
1809        deserialize_with = "deserialize_effective_severity"
1810    )]
1811    pub effective_severity: Option<EffectiveSeverity>,
1812}
1813
1814impl UnusedComponentPropFinding {
1815    /// Build the wrapper from a raw [`UnusedComponentProp`]. Emits a manual
1816    /// fix action plus a line-level suppress.
1817    #[must_use]
1818    pub fn with_actions(prop: UnusedComponentProp) -> Self {
1819        let actions = vec![
1820            manual_framework_fix(
1821                FixActionType::UseComponentProp,
1822                "Use the declared prop in the component, or remove it from the component API",
1823                "Manual review required: public component APIs can intentionally keep stable props for external consumers.",
1824            ),
1825            suppress_line("// fallow-ignore-next-line unused-component-prop"),
1826        ];
1827        Self {
1828            finding_id: None,
1829            prop,
1830            actions,
1831            introduced: None,
1832            effective_severity: None,
1833        }
1834    }
1835}
1836
1837/// Wire-shape envelope for an [`UnusedComponentEmit`] finding. There is no safe
1838/// auto-fix: removing a declared emit is judgement-bearing (the event may be
1839/// part of a deliberately-stable public component API). Actions are manual
1840/// remediation guidance plus a line-level suppress at the emit declaration.
1841#[derive(Debug, Clone, Serialize, Deserialize)]
1842#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1843pub struct UnusedComponentEmitFinding {
1844    /// The underlying finding.
1845    #[serde(flatten)]
1846    pub emit: UnusedComponentEmit,
1847    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
1848    /// `~<k>` suffix when several findings of one type share an identity.
1849    /// Line and column are not inputs, so the id survives line shifts,
1850    /// reformats and reorders. A rename of the file or the symbol gives a
1851    /// new id. Absent in output from older versions.
1852    #[serde(default, skip_serializing_if = "Option::is_none")]
1853    pub finding_id: Option<String>,
1854    /// Suggested next steps. Always emitted (possibly empty for
1855    /// forward-compat).
1856    pub actions: Vec<IssueAction>,
1857    /// Set by the audit pass when this finding is introduced relative to
1858    /// the merge-base.
1859    #[serde(default, skip_serializing_if = "Option::is_none")]
1860    pub introduced: Option<AuditIntroduced>,
1861    /// Gate severity of this finding after `rules` and `overrides[].rules`
1862    /// resolve for its path. CI formats read it for the annotation, SARIF
1863    /// and CodeClimate level. Absent in output from older versions. Not
1864    /// part of the finding identity, baseline keys or fingerprints.
1865    #[serde(
1866        default,
1867        skip_serializing_if = "Option::is_none",
1868        deserialize_with = "deserialize_effective_severity"
1869    )]
1870    pub effective_severity: Option<EffectiveSeverity>,
1871}
1872
1873impl UnusedComponentEmitFinding {
1874    /// Build the wrapper from a raw [`UnusedComponentEmit`]. Emits a manual
1875    /// fix action plus a line-level suppress.
1876    #[must_use]
1877    pub fn with_actions(emit: UnusedComponentEmit) -> Self {
1878        let actions = vec![
1879            manual_framework_fix(
1880                FixActionType::EmitComponentEvent,
1881                "Emit the declared event from the component, or remove it from the component API",
1882                "Manual review required: public component APIs can intentionally keep stable events for external listeners.",
1883            ),
1884            suppress_line("// fallow-ignore-next-line unused-component-emit"),
1885        ];
1886        Self {
1887            finding_id: None,
1888            emit,
1889            actions,
1890            introduced: None,
1891            effective_severity: None,
1892        }
1893    }
1894}
1895
1896/// Wire-shape envelope for an [`UnusedSvelteEvent`] finding. There is no safe
1897/// auto-fix: removing a dispatched event is judgement-bearing (the event may be
1898/// part of a deliberately-stable public component API, or a listener may be
1899/// added later). Actions are manual remediation guidance plus a line-level
1900/// suppress at the `dispatch` call.
1901#[derive(Debug, Clone, Serialize, Deserialize)]
1902#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1903pub struct UnusedSvelteEventFinding {
1904    /// The underlying finding.
1905    #[serde(flatten)]
1906    pub event: UnusedSvelteEvent,
1907    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
1908    /// `~<k>` suffix when several findings of one type share an identity.
1909    /// Line and column are not inputs, so the id survives line shifts,
1910    /// reformats and reorders. A rename of the file or the symbol gives a
1911    /// new id. Absent in output from older versions.
1912    #[serde(default, skip_serializing_if = "Option::is_none")]
1913    pub finding_id: Option<String>,
1914    /// Suggested next steps. Always emitted (possibly empty for
1915    /// forward-compat).
1916    pub actions: Vec<IssueAction>,
1917    /// Set by the audit pass when this finding is introduced relative to
1918    /// the merge-base.
1919    #[serde(default, skip_serializing_if = "Option::is_none")]
1920    pub introduced: Option<AuditIntroduced>,
1921    /// Gate severity of this finding after `rules` and `overrides[].rules`
1922    /// resolve for its path. CI formats read it for the annotation, SARIF
1923    /// and CodeClimate level. Absent in output from older versions. Not
1924    /// part of the finding identity, baseline keys or fingerprints.
1925    #[serde(
1926        default,
1927        skip_serializing_if = "Option::is_none",
1928        deserialize_with = "deserialize_effective_severity"
1929    )]
1930    pub effective_severity: Option<EffectiveSeverity>,
1931}
1932
1933impl UnusedSvelteEventFinding {
1934    /// Build the wrapper from a raw [`UnusedSvelteEvent`]. Emits a manual fix
1935    /// action plus a line-level suppress.
1936    #[must_use]
1937    pub fn with_actions(event: UnusedSvelteEvent) -> Self {
1938        let actions = vec![
1939            manual_framework_fix(
1940                FixActionType::WireSvelteEvent,
1941                "Add or forward a listener for this custom event, or remove the dispatch",
1942                "Manual review required: public Svelte component APIs can intentionally dispatch events for package consumers outside this project.",
1943            ),
1944            suppress_line("// fallow-ignore-next-line unused-svelte-event"),
1945        ];
1946        Self {
1947            finding_id: None,
1948            event,
1949            actions,
1950            introduced: None,
1951            effective_severity: None,
1952        }
1953    }
1954}
1955
1956/// Wire-shape envelope for a [`DuplicateExportAlias`] finding. There is no
1957/// safe auto-fix: a consumer outside the project can import any of the
1958/// names. Actions are manual remediation guidance plus a line-level
1959/// suppress.
1960#[derive(Debug, Clone, Serialize, Deserialize)]
1961#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1962pub struct DuplicateExportAliasFinding {
1963    /// The underlying finding.
1964    #[serde(flatten)]
1965    pub alias: DuplicateExportAlias,
1966    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
1967    /// `~<k>` suffix when several findings of one type share an identity.
1968    /// Line and column are not inputs, so the id survives line shifts,
1969    /// reformats and reorders. A rename of the file or the binding gives a
1970    /// new id. Absent in output from older versions.
1971    #[serde(default, skip_serializing_if = "Option::is_none")]
1972    pub finding_id: Option<String>,
1973    /// Suggested next steps. Always emitted (possibly empty for
1974    /// forward-compat).
1975    pub actions: Vec<IssueAction>,
1976    /// Set by the audit pass when this finding is introduced relative to
1977    /// the merge-base.
1978    #[serde(default, skip_serializing_if = "Option::is_none")]
1979    pub introduced: Option<AuditIntroduced>,
1980    /// Gate severity of this finding after `rules` and `overrides[].rules`
1981    /// resolve for its path. CI formats read it for the annotation, SARIF
1982    /// and CodeClimate level. Absent in output from older versions. Not
1983    /// part of the finding identity, baseline keys or fingerprints.
1984    #[serde(
1985        default,
1986        skip_serializing_if = "Option::is_none",
1987        deserialize_with = "deserialize_effective_severity"
1988    )]
1989    pub effective_severity: Option<EffectiveSeverity>,
1990}
1991
1992impl DuplicateExportAliasFinding {
1993    /// Build the wrapper from a raw [`DuplicateExportAlias`]. Emits a manual
1994    /// fix action plus a line-level suppress.
1995    #[must_use]
1996    pub fn with_actions(alias: DuplicateExportAlias) -> Self {
1997        let actions = vec![
1998            manual_framework_fix(
1999                FixActionType::RemoveDuplicate,
2000                "Keep one export name for the binding and remove the other names",
2001                "Manual review required: update the importers of a removed name first. Code outside the analyzed project can import any of the names. If the names are an intentional public API, add them to ignoreExports.",
2002            ),
2003            suppress_line("// fallow-ignore-next-line duplicate-export-alias"),
2004        ];
2005        Self {
2006            finding_id: None,
2007            alias,
2008            actions,
2009            introduced: None,
2010            effective_severity: None,
2011        }
2012    }
2013}
2014
2015/// Wire-shape envelope for an [`UnusedEffectLayer`] finding. There is no safe auto-fix: a test or a script outside the project graph can still use the layer. Actions are manual
2016/// remediation guidance plus a line-level suppress.
2017#[derive(Debug, Clone, Serialize, Deserialize)]
2018#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
2019pub struct UnusedEffectLayerFinding {
2020    /// The underlying finding.
2021    #[serde(flatten)]
2022    pub layer: UnusedEffectLayer,
2023    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
2024    /// `~<k>` suffix when several findings of one type share an identity.
2025    /// Line and column are not inputs, so the id survives line shifts,
2026    /// reformats and reorders. A rename of the file or the symbol gives a
2027    /// new id. Absent in output from older versions.
2028    #[serde(default, skip_serializing_if = "Option::is_none")]
2029    pub finding_id: Option<String>,
2030    /// Suggested next steps. Always emitted (possibly empty for
2031    /// forward-compat).
2032    pub actions: Vec<IssueAction>,
2033    /// Set by the audit pass when this finding is introduced relative to
2034    /// the merge-base.
2035    #[serde(default, skip_serializing_if = "Option::is_none")]
2036    pub introduced: Option<AuditIntroduced>,
2037    /// Gate severity of this finding after `rules` and `overrides[].rules`
2038    /// resolve for its path. CI formats read it for the annotation, SARIF
2039    /// and CodeClimate level. Absent in output from older versions. Not
2040    /// part of the finding identity, baseline keys or fingerprints.
2041    #[serde(
2042        default,
2043        skip_serializing_if = "Option::is_none",
2044        deserialize_with = "deserialize_effective_severity"
2045    )]
2046    pub effective_severity: Option<EffectiveSeverity>,
2047}
2048
2049impl UnusedEffectLayerFinding {
2050    /// Build the wrapper from a raw [`UnusedEffectLayer`]. Emits a manual fix action plus
2051    /// a line-level suppress.
2052    #[must_use]
2053    pub fn with_actions(layer: UnusedEffectLayer) -> Self {
2054        let actions = vec![
2055            manual_framework_fix(
2056                FixActionType::ComposeEffectLayer,
2057                "Compose the layer into a layer that reaches a runtime, or remove it with its unused consumers",
2058                "Manual review required: remove the unused consumer layers first, then this layer. Code outside the analyzed project can still compose it.",
2059            ),
2060            suppress_line("// fallow-ignore-next-line unused-effect-layer"),
2061        ];
2062        Self {
2063            finding_id: None,
2064            layer,
2065            actions,
2066            introduced: None,
2067            effective_severity: None,
2068        }
2069    }
2070}
2071
2072/// Wire-shape envelope for an [`UnusedTaggedError`] finding. There is no safe auto-fix: the error can be part of a public API contract. Actions are manual
2073/// remediation guidance plus a line-level suppress.
2074#[derive(Debug, Clone, Serialize, Deserialize)]
2075#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
2076pub struct UnusedTaggedErrorFinding {
2077    /// The underlying finding.
2078    #[serde(flatten)]
2079    pub error: UnusedTaggedError,
2080    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
2081    /// `~<k>` suffix when several findings of one type share an identity.
2082    /// Line and column are not inputs, so the id survives line shifts,
2083    /// reformats and reorders. A rename of the file or the symbol gives a
2084    /// new id. Absent in output from older versions.
2085    #[serde(default, skip_serializing_if = "Option::is_none")]
2086    pub finding_id: Option<String>,
2087    /// Suggested next steps. Always emitted (possibly empty for
2088    /// forward-compat).
2089    pub actions: Vec<IssueAction>,
2090    /// Set by the audit pass when this finding is introduced relative to
2091    /// the merge-base.
2092    #[serde(default, skip_serializing_if = "Option::is_none")]
2093    pub introduced: Option<AuditIntroduced>,
2094    /// Gate severity of this finding after `rules` and `overrides[].rules`
2095    /// resolve for its path. CI formats read it for the annotation, SARIF
2096    /// and CodeClimate level. Absent in output from older versions. Not
2097    /// part of the finding identity, baseline keys or fingerprints.
2098    #[serde(
2099        default,
2100        skip_serializing_if = "Option::is_none",
2101        deserialize_with = "deserialize_effective_severity"
2102    )]
2103    pub effective_severity: Option<EffectiveSeverity>,
2104}
2105
2106impl UnusedTaggedErrorFinding {
2107    /// Build the wrapper from a raw [`UnusedTaggedError`]. Emits a manual fix action plus
2108    /// a line-level suppress.
2109    #[must_use]
2110    pub fn with_actions(error: UnusedTaggedError) -> Self {
2111        let actions = vec![
2112            manual_framework_fix(
2113                FixActionType::FailTaggedError,
2114                "Fail with this error where the condition occurs, or remove the class and its catchTag handlers",
2115                "Manual review required: consumers outside the analyzed project can construct or decode the error.",
2116            ),
2117            suppress_line("// fallow-ignore-next-line unused-tagged-error"),
2118        ];
2119        Self {
2120            finding_id: None,
2121            error,
2122            actions,
2123            introduced: None,
2124            effective_severity: None,
2125        }
2126    }
2127}
2128
2129/// Wire-shape envelope for an [`UnproducedCatchTag`] finding. There is no safe auto-fix: the handler can guard against a future producer. Actions are manual
2130/// remediation guidance plus a line-level suppress.
2131#[derive(Debug, Clone, Serialize, Deserialize)]
2132#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
2133pub struct UnproducedCatchTagFinding {
2134    /// The underlying finding.
2135    #[serde(flatten)]
2136    pub catch_tag: UnproducedCatchTag,
2137    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
2138    /// `~<k>` suffix when several findings of one type share an identity.
2139    /// Line and column are not inputs, so the id survives line shifts,
2140    /// reformats and reorders. A rename of the file or the symbol gives a
2141    /// new id. Absent in output from older versions.
2142    #[serde(default, skip_serializing_if = "Option::is_none")]
2143    pub finding_id: Option<String>,
2144    /// Suggested next steps. Always emitted (possibly empty for
2145    /// forward-compat).
2146    pub actions: Vec<IssueAction>,
2147    /// Set by the audit pass when this finding is introduced relative to
2148    /// the merge-base.
2149    #[serde(default, skip_serializing_if = "Option::is_none")]
2150    pub introduced: Option<AuditIntroduced>,
2151    /// Gate severity of this finding after `rules` and `overrides[].rules`
2152    /// resolve for its path. CI formats read it for the annotation, SARIF
2153    /// and CodeClimate level. Absent in output from older versions. Not
2154    /// part of the finding identity, baseline keys or fingerprints.
2155    #[serde(
2156        default,
2157        skip_serializing_if = "Option::is_none",
2158        deserialize_with = "deserialize_effective_severity"
2159    )]
2160    pub effective_severity: Option<EffectiveSeverity>,
2161}
2162
2163impl UnproducedCatchTagFinding {
2164    /// Build the wrapper from a raw [`UnproducedCatchTag`]. Emits a manual fix action plus
2165    /// a line-level suppress.
2166    #[must_use]
2167    pub fn with_actions(catch_tag: UnproducedCatchTag) -> Self {
2168        let actions = vec![
2169            manual_framework_fix(
2170                FixActionType::RemoveCatchTagHandler,
2171                "Remove the handler for this tag, or fail with the error where the condition occurs",
2172                "Manual review required: a package or code outside the analyzed project can produce the tag.",
2173            ),
2174            suppress_line("// fallow-ignore-next-line unproduced-catch-tag"),
2175        ];
2176        Self {
2177            finding_id: None,
2178            catch_tag,
2179            actions,
2180            introduced: None,
2181            effective_severity: None,
2182        }
2183    }
2184}
2185
2186/// Wire-shape envelope for a [`PropDrillingChain`] finding. There is no safe
2187/// auto-fix: collapsing a drilling chain (colocate the consumer, lift to a
2188/// context, or compose the component) is a design decision. The only action is a
2189/// line-level suppress at the source hop's prop declaration. The rule defaults
2190/// to `off` (opt-in health signal), so this finding is dormant by default.
2191#[derive(Debug, Clone, Serialize, Deserialize)]
2192#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
2193pub struct PropDrillingChainFinding {
2194    /// The underlying located chain.
2195    #[serde(flatten)]
2196    pub chain: PropDrillingChain,
2197    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
2198    /// `~<k>` suffix when several findings of one type share an identity.
2199    /// Line and column are not inputs, so the id survives line shifts,
2200    /// reformats and reorders. A rename of the file or the symbol gives a
2201    /// new id. Absent in output from older versions.
2202    #[serde(default, skip_serializing_if = "Option::is_none")]
2203    pub finding_id: Option<String>,
2204    /// Suggested next steps. Always emitted (possibly empty for
2205    /// forward-compat).
2206    pub actions: Vec<IssueAction>,
2207    /// Set by the audit pass when this finding is introduced relative to
2208    /// the merge-base.
2209    #[serde(default, skip_serializing_if = "Option::is_none")]
2210    pub introduced: Option<AuditIntroduced>,
2211    /// Rule severity after resolving overrides for the source hop. An explicit
2212    /// `error` enforces the chain; `warn` stays advisory under strict flags.
2213    /// Saved reports use this value for CI levels. Absent in older output.
2214    /// Not part of finding identity, baseline keys or fingerprints.
2215    #[serde(
2216        default,
2217        skip_serializing_if = "Option::is_none",
2218        deserialize_with = "deserialize_effective_severity"
2219    )]
2220    pub effective_severity: Option<EffectiveSeverity>,
2221}
2222
2223impl PropDrillingChainFinding {
2224    /// Build the wrapper from a raw [`PropDrillingChain`]. Emits only a
2225    /// line-level suppress action anchored at the source hop: there is no safe
2226    /// auto-fix because collapsing the chain is a design decision (colocate,
2227    /// lift to context, or compose).
2228    #[must_use]
2229    pub fn with_actions(chain: PropDrillingChain) -> Self {
2230        let actions = vec![IssueAction::SuppressLine(SuppressLineAction {
2231            kind: SuppressLineKind::SuppressLine,
2232            auto_fixable: false,
2233            description: "Suppress with an inline comment above the source prop declaration"
2234                .to_string(),
2235            comment: "// fallow-ignore-next-line prop-drilling".to_string(),
2236            scope: None,
2237        })];
2238        Self {
2239            finding_id: None,
2240            chain,
2241            actions,
2242            introduced: None,
2243            effective_severity: None,
2244        }
2245    }
2246}
2247
2248/// Wire-shape envelope for a [`ThinWrapper`] finding. There is no safe
2249/// auto-fix: inlining a thin wrapper at its call sites (or deleting it) is a
2250/// design decision. The only action is a line-level suppress at the wrapper's
2251/// definition. The rule defaults to `off` (opt-in health signal), so this
2252/// finding is dormant by default.
2253#[derive(Debug, Clone, Serialize, Deserialize)]
2254#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
2255pub struct ThinWrapperFinding {
2256    /// The underlying located thin wrapper.
2257    #[serde(flatten)]
2258    pub wrapper: ThinWrapper,
2259    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
2260    /// `~<k>` suffix when several findings of one type share an identity.
2261    /// Line and column are not inputs, so the id survives line shifts,
2262    /// reformats and reorders. A rename of the file or the symbol gives a
2263    /// new id. Absent in output from older versions.
2264    #[serde(default, skip_serializing_if = "Option::is_none")]
2265    pub finding_id: Option<String>,
2266    /// Suggested next steps. Always emitted (possibly empty for
2267    /// forward-compat).
2268    pub actions: Vec<IssueAction>,
2269    /// Set by the audit pass when this finding is introduced relative to
2270    /// the merge-base.
2271    #[serde(default, skip_serializing_if = "Option::is_none")]
2272    pub introduced: Option<AuditIntroduced>,
2273    /// Rule severity of this finding. Explicit errors enforce analysis gates;
2274    /// warnings stay advisory, including under strict flags. Saved reports
2275    /// retain this value for CI levels without the original config. Absent
2276    /// in output from older versions. Not part of finding identity, baseline
2277    /// keys or fingerprints.
2278    #[serde(
2279        default,
2280        skip_serializing_if = "Option::is_none",
2281        deserialize_with = "deserialize_effective_severity"
2282    )]
2283    pub effective_severity: Option<EffectiveSeverity>,
2284}
2285
2286impl ThinWrapperFinding {
2287    /// Build the wrapper from a raw [`ThinWrapper`]. Emits only a line-level
2288    /// suppress action anchored at the wrapper definition: there is no safe
2289    /// auto-fix because inlining or deleting the wrapper is a design decision.
2290    #[must_use]
2291    pub fn with_actions(wrapper: ThinWrapper) -> Self {
2292        let actions = vec![IssueAction::SuppressLine(SuppressLineAction {
2293            kind: SuppressLineKind::SuppressLine,
2294            auto_fixable: false,
2295            description: "Suppress with an inline comment above the component definition"
2296                .to_string(),
2297            comment: "// fallow-ignore-next-line thin-wrapper".to_string(),
2298            scope: None,
2299        })];
2300        Self {
2301            finding_id: None,
2302            wrapper,
2303            actions,
2304            introduced: None,
2305            effective_severity: None,
2306        }
2307    }
2308}
2309
2310/// Wire-shape envelope for a [`DuplicatePropShape`] finding. There is no safe
2311/// auto-fix: extracting a shared `Props` type or a base component for a group of
2312/// same-shaped components is a design decision. The actions are manual guidance
2313/// (extract the shared shape) plus a line-level suppress at the component
2314/// definition and a file-level suppress escape hatch (mirroring the
2315/// route-collision multi-file model). The rule defaults to `off` (opt-in health
2316/// signal), so this finding is dormant by default.
2317#[derive(Debug, Clone, Serialize, Deserialize)]
2318#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
2319pub struct DuplicatePropShapeFinding {
2320    /// The underlying duplicate-prop-shape entry.
2321    #[serde(flatten)]
2322    pub shape: DuplicatePropShape,
2323    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
2324    /// `~<k>` suffix when several findings of one type share an identity.
2325    /// Line and column are not inputs, so the id survives line shifts,
2326    /// reformats and reorders. A rename of the file or the symbol gives a
2327    /// new id. Absent in output from older versions.
2328    #[serde(default, skip_serializing_if = "Option::is_none")]
2329    pub finding_id: Option<String>,
2330    /// Suggested next steps. Always emitted (possibly empty for
2331    /// forward-compat).
2332    pub actions: Vec<IssueAction>,
2333    /// Set by the audit pass when this finding is introduced relative to
2334    /// the merge-base.
2335    #[serde(default, skip_serializing_if = "Option::is_none")]
2336    pub introduced: Option<AuditIntroduced>,
2337    /// Rule severity of this finding. Explicit errors enforce analysis gates;
2338    /// warnings stay advisory, including under strict flags. Saved reports
2339    /// retain this value for CI levels without the original config. Absent
2340    /// in output from older versions. Not part of finding identity, baseline
2341    /// keys or fingerprints.
2342    #[serde(
2343        default,
2344        skip_serializing_if = "Option::is_none",
2345        deserialize_with = "deserialize_effective_severity"
2346    )]
2347    pub effective_severity: Option<EffectiveSeverity>,
2348}
2349
2350impl DuplicatePropShapeFinding {
2351    /// Build the wrapper from a raw [`DuplicatePropShape`]. Manual guidance is
2352    /// the primary action (extract a shared shape); a line-level suppress at the
2353    /// component definition and a file-level suppress escape hatch follow,
2354    /// mirroring the multi-file route-collision suppress model. There is no safe
2355    /// auto-fix because extracting a shared type or base component is a design
2356    /// decision.
2357    #[must_use]
2358    pub fn with_actions(shape: DuplicatePropShape) -> Self {
2359        let actions = vec![
2360            IssueAction::SuppressLine(SuppressLineAction {
2361                kind: SuppressLineKind::SuppressLine,
2362                auto_fixable: false,
2363                description: "Three or more components share this exact prop shape. Extract one \
2364                              shared `Props` type (or a base component) that every member reuses, \
2365                              or keep them separate if a per-variant divergence is planned. \
2366                              Suppress one member with an inline comment above the component \
2367                              definition."
2368                    .to_string(),
2369                comment: "// fallow-ignore-next-line duplicate-prop-shape".to_string(),
2370                scope: None,
2371            }),
2372            IssueAction::SuppressFile(SuppressFileAction {
2373                kind: SuppressFileKind::SuppressFile,
2374                auto_fixable: false,
2375                description: "Escape hatch: a file-level suppress silences this member but it \
2376                              still appears in its siblings' `sharing_components` (the group is \
2377                              real regardless of suppression)."
2378                    .to_string(),
2379                comment: "// fallow-ignore-file duplicate-prop-shape".to_string(),
2380            }),
2381        ];
2382        Self {
2383            finding_id: None,
2384            shape,
2385            actions,
2386            introduced: None,
2387            effective_severity: None,
2388        }
2389    }
2390}
2391
2392/// Wire-shape envelope for an [`UnusedComponentInput`] finding. There is no safe
2393/// auto-fix: removing a declared input is judgement-bearing (the input may be
2394/// part of a deliberately-stable public component API). The only action is a
2395/// line-level suppress at the input declaration.
2396#[derive(Debug, Clone, Serialize, Deserialize)]
2397#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
2398pub struct UnusedComponentInputFinding {
2399    /// The underlying finding.
2400    #[serde(flatten)]
2401    pub input: UnusedComponentInput,
2402    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
2403    /// `~<k>` suffix when several findings of one type share an identity.
2404    /// Line and column are not inputs, so the id survives line shifts,
2405    /// reformats and reorders. A rename of the file or the symbol gives a
2406    /// new id. Absent in output from older versions.
2407    #[serde(default, skip_serializing_if = "Option::is_none")]
2408    pub finding_id: Option<String>,
2409    /// Suggested next steps. Always emitted (possibly empty for
2410    /// forward-compat).
2411    pub actions: Vec<IssueAction>,
2412    /// Set by the audit pass when this finding is introduced relative to
2413    /// the merge-base.
2414    #[serde(default, skip_serializing_if = "Option::is_none")]
2415    pub introduced: Option<AuditIntroduced>,
2416    /// Gate severity of this finding after `rules` and `overrides[].rules`
2417    /// resolve for its path. CI formats read it for the annotation, SARIF
2418    /// and CodeClimate level. Absent in output from older versions. Not
2419    /// part of the finding identity, baseline keys or fingerprints.
2420    #[serde(
2421        default,
2422        skip_serializing_if = "Option::is_none",
2423        deserialize_with = "deserialize_effective_severity"
2424    )]
2425    pub effective_severity: Option<EffectiveSeverity>,
2426}
2427
2428impl UnusedComponentInputFinding {
2429    /// Build the wrapper from a raw [`UnusedComponentInput`]. Emits only a
2430    /// line-level suppress action: there is no safe auto-fix because removing an
2431    /// input is a human decision (it may be part of a stable component API).
2432    #[must_use]
2433    pub fn with_actions(input: UnusedComponentInput) -> Self {
2434        let actions = vec![IssueAction::SuppressLine(SuppressLineAction {
2435            kind: SuppressLineKind::SuppressLine,
2436            auto_fixable: false,
2437            description: "Suppress with an inline comment above the line".to_string(),
2438            comment: "// fallow-ignore-next-line unused-component-input".to_string(),
2439            scope: None,
2440        })];
2441        Self {
2442            finding_id: None,
2443            input,
2444            actions,
2445            introduced: None,
2446            effective_severity: None,
2447        }
2448    }
2449}
2450
2451/// Wire-shape envelope for an [`UnusedComponentOutput`] finding. There is no safe
2452/// auto-fix: removing a declared output is judgement-bearing (the event may be
2453/// part of a deliberately-stable public component API). The only action is a
2454/// line-level suppress at the output declaration.
2455#[derive(Debug, Clone, Serialize, Deserialize)]
2456#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
2457pub struct UnusedComponentOutputFinding {
2458    /// The underlying finding.
2459    #[serde(flatten)]
2460    pub output: UnusedComponentOutput,
2461    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
2462    /// `~<k>` suffix when several findings of one type share an identity.
2463    /// Line and column are not inputs, so the id survives line shifts,
2464    /// reformats and reorders. A rename of the file or the symbol gives a
2465    /// new id. Absent in output from older versions.
2466    #[serde(default, skip_serializing_if = "Option::is_none")]
2467    pub finding_id: Option<String>,
2468    /// Suggested next steps. Always emitted (possibly empty for
2469    /// forward-compat).
2470    pub actions: Vec<IssueAction>,
2471    /// Set by the audit pass when this finding is introduced relative to
2472    /// the merge-base.
2473    #[serde(default, skip_serializing_if = "Option::is_none")]
2474    pub introduced: Option<AuditIntroduced>,
2475    /// Gate severity of this finding after `rules` and `overrides[].rules`
2476    /// resolve for its path. CI formats read it for the annotation, SARIF
2477    /// and CodeClimate level. Absent in output from older versions. Not
2478    /// part of the finding identity, baseline keys or fingerprints.
2479    #[serde(
2480        default,
2481        skip_serializing_if = "Option::is_none",
2482        deserialize_with = "deserialize_effective_severity"
2483    )]
2484    pub effective_severity: Option<EffectiveSeverity>,
2485}
2486
2487impl UnusedComponentOutputFinding {
2488    /// Build the wrapper from a raw [`UnusedComponentOutput`]. Emits only a
2489    /// line-level suppress action: there is no safe auto-fix because removing an
2490    /// output is a human decision (it may be part of a stable component API).
2491    #[must_use]
2492    pub fn with_actions(output: UnusedComponentOutput) -> Self {
2493        let actions = vec![IssueAction::SuppressLine(SuppressLineAction {
2494            kind: SuppressLineKind::SuppressLine,
2495            auto_fixable: false,
2496            description: "Suppress with an inline comment above the line".to_string(),
2497            comment: "// fallow-ignore-next-line unused-component-output".to_string(),
2498            scope: None,
2499        })];
2500        Self {
2501            finding_id: None,
2502            output,
2503            actions,
2504            introduced: None,
2505            effective_severity: None,
2506        }
2507    }
2508}
2509
2510/// Wire-shape envelope for a [`RouteCollision`] finding. A route collision is a
2511/// guaranteed `next build` failure, so the primary action is manual guidance
2512/// (move or merge one of the colliding files), NOT a suppress: suppressing a
2513/// build error never makes the build pass. A file-level suppress is offered as
2514/// an escape hatch only.
2515#[derive(Debug, Clone, Serialize, Deserialize)]
2516#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
2517pub struct RouteCollisionFinding {
2518    /// The underlying route-collision entry.
2519    #[serde(flatten)]
2520    pub collision: RouteCollision,
2521    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
2522    /// `~<k>` suffix when several findings of one type share an identity.
2523    /// Line and column are not inputs, so the id survives line shifts,
2524    /// reformats and reorders. A rename of the file or the symbol gives a
2525    /// new id. Absent in output from older versions.
2526    #[serde(default, skip_serializing_if = "Option::is_none")]
2527    pub finding_id: Option<String>,
2528    /// Suggested next steps. Always emitted (possibly empty for
2529    /// forward-compat).
2530    pub actions: Vec<IssueAction>,
2531    /// Set by the audit pass when this finding is introduced relative to
2532    /// the merge-base.
2533    #[serde(default, skip_serializing_if = "Option::is_none")]
2534    pub introduced: Option<AuditIntroduced>,
2535    /// Gate severity of this finding after `rules` and `overrides[].rules`
2536    /// resolve for its path. CI formats read it for the annotation, SARIF
2537    /// and CodeClimate level. Absent in output from older versions. Not
2538    /// part of the finding identity, baseline keys or fingerprints.
2539    #[serde(
2540        default,
2541        skip_serializing_if = "Option::is_none",
2542        deserialize_with = "deserialize_effective_severity"
2543    )]
2544    pub effective_severity: Option<EffectiveSeverity>,
2545}
2546
2547impl RouteCollisionFinding {
2548    /// Build the wrapper from a raw [`RouteCollision`]. The primary action is
2549    /// manual guidance because suppressing a guaranteed build error is never
2550    /// the right fix; a file-level suppress is the escape hatch only.
2551    #[must_use]
2552    pub fn with_actions(collision: RouteCollision) -> Self {
2553        let actions = vec![
2554            IssueAction::Fix(FixAction {
2555                kind: FixActionType::ResolveRouteCollision,
2556                auto_fixable: false,
2557                description: "Two or more files resolve to the same URL. Move or merge one so \
2558                              each URL has a single owner. Route groups `(name)` and parallel \
2559                              slots `@name` are the only legal same-URL shapes."
2560                    .to_string(),
2561                note: Some(
2562                    "Next.js fails the build with \"You cannot have two parallel pages that \
2563                     resolve to the same path\". See the sibling `conflicting_paths` array for \
2564                     the other files that own this URL."
2565                        .to_string(),
2566                ),
2567                available_in_catalogs: None,
2568                suggested_target: None,
2569            }),
2570            IssueAction::SuppressFile(SuppressFileAction {
2571                kind: SuppressFileKind::SuppressFile,
2572                auto_fixable: false,
2573                description: "Escape hatch only: a file-level suppress silences the finding but \
2574                              does NOT make `next build` pass. Prefer moving or merging a file."
2575                    .to_string(),
2576                comment: "// fallow-ignore-file route-collision".to_string(),
2577            }),
2578        ];
2579        Self {
2580            finding_id: None,
2581            collision,
2582            actions,
2583            introduced: None,
2584            effective_severity: None,
2585        }
2586    }
2587}
2588
2589/// Wire-shape envelope for a [`DynamicSegmentNameConflict`] finding. The
2590/// conflict is a Next.js dev / runtime error (`next build` does NOT catch it),
2591/// so the primary action is manual guidance (rename the dynamic segments to a
2592/// single consistent slug name), with a file-level suppress as escape hatch.
2593#[derive(Debug, Clone, Serialize, Deserialize)]
2594#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
2595pub struct DynamicSegmentNameConflictFinding {
2596    /// The underlying dynamic-segment-name-conflict entry.
2597    #[serde(flatten)]
2598    pub conflict: DynamicSegmentNameConflict,
2599    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
2600    /// `~<k>` suffix when several findings of one type share an identity.
2601    /// Line and column are not inputs, so the id survives line shifts,
2602    /// reformats and reorders. A rename of the file or the symbol gives a
2603    /// new id. Absent in output from older versions.
2604    #[serde(default, skip_serializing_if = "Option::is_none")]
2605    pub finding_id: Option<String>,
2606    /// Suggested next steps. Always emitted (possibly empty for
2607    /// forward-compat).
2608    pub actions: Vec<IssueAction>,
2609    /// Set by the audit pass when this finding is introduced relative to
2610    /// the merge-base.
2611    #[serde(default, skip_serializing_if = "Option::is_none")]
2612    pub introduced: Option<AuditIntroduced>,
2613    /// Gate severity of this finding after `rules` and `overrides[].rules`
2614    /// resolve for its path. CI formats read it for the annotation, SARIF
2615    /// and CodeClimate level. Absent in output from older versions. Not
2616    /// part of the finding identity, baseline keys or fingerprints.
2617    #[serde(
2618        default,
2619        skip_serializing_if = "Option::is_none",
2620        deserialize_with = "deserialize_effective_severity"
2621    )]
2622    pub effective_severity: Option<EffectiveSeverity>,
2623}
2624
2625impl DynamicSegmentNameConflictFinding {
2626    /// Build the wrapper from a raw [`DynamicSegmentNameConflict`]. Manual
2627    /// guidance primary action; file-level suppress escape hatch only.
2628    #[must_use]
2629    pub fn with_actions(conflict: DynamicSegmentNameConflict) -> Self {
2630        let actions = vec![
2631            IssueAction::Fix(FixAction {
2632                kind: FixActionType::ResolveDynamicSegmentNameConflict,
2633                auto_fixable: false,
2634                description: "Sibling dynamic segments at the same position use different param \
2635                              names. Rename them to one consistent slug name (e.g. pick `[id]` \
2636                              or `[slug]` for both)."
2637                    .to_string(),
2638                note: Some(
2639                    "Next.js throws \"You cannot use different slug names for the same dynamic \
2640                     path\" at dev / runtime when the position is hit; `next build` does not \
2641                     catch it. See the sibling `conflicting_segments` array."
2642                        .to_string(),
2643                ),
2644                available_in_catalogs: None,
2645                suggested_target: None,
2646            }),
2647            IssueAction::SuppressFile(SuppressFileAction {
2648                kind: SuppressFileKind::SuppressFile,
2649                auto_fixable: false,
2650                description: "Escape hatch only: a file-level suppress silences the finding but \
2651                              does NOT stop Next.js from throwing at dev / runtime. Prefer \
2652                              renaming the segments."
2653                    .to_string(),
2654                comment: "// fallow-ignore-file dynamic-segment-name-conflict".to_string(),
2655            }),
2656        ];
2657        Self {
2658            finding_id: None,
2659            conflict,
2660            actions,
2661            introduced: None,
2662            effective_severity: None,
2663        }
2664    }
2665}
2666
2667/// Wire-shape envelope for an [`UnusedMember`] finding consumed under the
2668/// `unused_enum_members` key.
2669#[derive(Debug, Clone, Serialize, Deserialize)]
2670#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
2671pub struct UnusedEnumMemberFinding {
2672    /// The underlying dead-code entry.
2673    #[serde(flatten)]
2674    pub member: UnusedMember,
2675    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
2676    /// `~<k>` suffix when several findings of one type share an identity.
2677    /// Line and column are not inputs, so the id survives line shifts,
2678    /// reformats and reorders. A rename of the file or the symbol gives a
2679    /// new id. Absent in output from older versions.
2680    #[serde(default, skip_serializing_if = "Option::is_none")]
2681    pub finding_id: Option<String>,
2682    /// Suggested next steps. Always emitted (possibly empty for
2683    /// forward-compat).
2684    pub actions: Vec<IssueAction>,
2685    /// Set by the audit pass when this finding is introduced relative to
2686    /// the merge-base.
2687    #[serde(default, skip_serializing_if = "Option::is_none")]
2688    pub introduced: Option<AuditIntroduced>,
2689    /// Gate severity of this finding after `rules` and `overrides[].rules`
2690    /// resolve for its path. CI formats read it for the annotation, SARIF
2691    /// and CodeClimate level. Absent in output from older versions. Not
2692    /// part of the finding identity, baseline keys or fingerprints.
2693    #[serde(
2694        default,
2695        skip_serializing_if = "Option::is_none",
2696        deserialize_with = "deserialize_effective_severity"
2697    )]
2698    pub effective_severity: Option<EffectiveSeverity>,
2699    /// Advisory caveats on the verdict behind this finding. A member's usage
2700    /// is collected by walking the member accesses of every module the run
2701    /// parsed, so a member whose only reference lives in a file the run never
2702    /// read reads as unused exactly like an export does. Sorted,
2703    /// deduplicated, and omitted from the wire when empty. Never gates the
2704    /// finding; it does withhold the `remove-enum-member` mutation.
2705    #[serde(default, skip_serializing_if = "Vec::is_empty")]
2706    pub reachability_caveats: Vec<ReachabilityCaveat>,
2707}
2708
2709impl UnusedEnumMemberFinding {
2710    /// Build the wrapper from a raw [`UnusedMember`].
2711    #[must_use]
2712    pub fn with_actions(member: UnusedMember) -> Self {
2713        let actions = vec![
2714            IssueAction::Fix(FixAction {
2715                kind: FixActionType::RemoveEnumMember,
2716                auto_fixable: true,
2717                description: "Remove this enum member".to_string(),
2718                note: None,
2719                available_in_catalogs: None,
2720                suggested_target: None,
2721            }),
2722            IssueAction::SuppressLine(SuppressLineAction {
2723                kind: SuppressLineKind::SuppressLine,
2724                auto_fixable: false,
2725                description: "Suppress with an inline comment above the line".to_string(),
2726                comment: "// fallow-ignore-next-line unused-enum-member".to_string(),
2727                scope: None,
2728            }),
2729        ];
2730        Self {
2731            finding_id: None,
2732            member,
2733            actions,
2734            introduced: None,
2735            effective_severity: None,
2736            reachability_caveats: Vec::new(),
2737        }
2738    }
2739}
2740
2741/// Wire-shape envelope for an [`UnusedMember`] finding consumed under the
2742/// `unused_class_members` key. Same Rust struct as
2743/// [`UnusedEnumMemberFinding`]; the fix action and suppress comment carry
2744/// the class-member kebab-case identifier instead.
2745#[derive(Debug, Clone, Serialize, Deserialize)]
2746#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
2747pub struct UnusedClassMemberFinding {
2748    /// The underlying dead-code entry.
2749    #[serde(flatten)]
2750    pub member: UnusedMember,
2751    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
2752    /// `~<k>` suffix when several findings of one type share an identity.
2753    /// Line and column are not inputs, so the id survives line shifts,
2754    /// reformats and reorders. A rename of the file or the symbol gives a
2755    /// new id. Absent in output from older versions.
2756    #[serde(default, skip_serializing_if = "Option::is_none")]
2757    pub finding_id: Option<String>,
2758    /// Suggested next steps. Always emitted (possibly empty for
2759    /// forward-compat).
2760    pub actions: Vec<IssueAction>,
2761    /// Type-aware evidence for this exact candidate when requested.
2762    #[serde(default, skip_serializing_if = "Option::is_none")]
2763    pub semantic: Option<SemanticCandidateDecision>,
2764    /// Internal marker for a framework member that the syntactic analysis
2765    /// suppresses, but the semantic pass may promote after proving complete
2766    /// closed-world absence. Never serialized as part of the public finding.
2767    #[serde(skip)]
2768    #[cfg_attr(feature = "schema", schemars(skip))]
2769    pub semantic_only_candidate: bool,
2770    /// Set by the audit pass when this finding is introduced relative to
2771    /// the merge-base.
2772    #[serde(default, skip_serializing_if = "Option::is_none")]
2773    pub introduced: Option<AuditIntroduced>,
2774    /// Gate severity of this finding after `rules` and `overrides[].rules`
2775    /// resolve for its path. CI formats read it for the annotation, SARIF
2776    /// and CodeClimate level. Absent in output from older versions. Not
2777    /// part of the finding identity, baseline keys or fingerprints.
2778    #[serde(
2779        default,
2780        skip_serializing_if = "Option::is_none",
2781        deserialize_with = "deserialize_effective_severity"
2782    )]
2783    pub effective_severity: Option<EffectiveSeverity>,
2784    /// Advisory caveats on the verdict behind this finding. A class member's
2785    /// usage is collected by the same reachability-free member-access walk an
2786    /// enum member's is, so it takes the enum-member rule unchanged: any module
2787    /// this run analyzed incompletely can hold the access that credits it.
2788    /// Sorted, deduplicated, and omitted from the wire when empty. Never gates
2789    /// the finding; it does withhold the `remove-class-member` mutation that
2790    /// the type-aware pass would otherwise open.
2791    #[serde(default, skip_serializing_if = "Vec::is_empty")]
2792    pub reachability_caveats: Vec<ReachabilityCaveat>,
2793}
2794
2795/// Wire-shape envelope for an [`UnusedMember`] finding consumed under the
2796/// `unused_store_members` key (a Pinia `state` / `getters` / `actions` key, or
2797/// a setup-store returned key, declared but never accessed by any consumer
2798/// project-wide). Same Rust struct as [`UnusedClassMemberFinding`]. Emits only
2799/// a line-level suppress action: there is no safe auto-fix because a store
2800/// member can be accessed reflectively (a Pinia plugin, `store.$onAction`, or
2801/// dynamic dispatch) in ways syntactic analysis cannot see, so removal is a
2802/// behavioral change the user must own.
2803#[derive(Debug, Clone, Serialize, Deserialize)]
2804#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
2805pub struct UnusedStoreMemberFinding {
2806    /// The underlying dead-code entry.
2807    #[serde(flatten)]
2808    pub member: UnusedMember,
2809    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
2810    /// `~<k>` suffix when several findings of one type share an identity.
2811    /// Line and column are not inputs, so the id survives line shifts,
2812    /// reformats and reorders. A rename of the file or the symbol gives a
2813    /// new id. Absent in output from older versions.
2814    #[serde(default, skip_serializing_if = "Option::is_none")]
2815    pub finding_id: Option<String>,
2816    /// Suggested next steps. Always emitted (possibly empty for
2817    /// forward-compat).
2818    pub actions: Vec<IssueAction>,
2819    /// Set by the audit pass when this finding is introduced relative to
2820    /// the merge-base.
2821    #[serde(default, skip_serializing_if = "Option::is_none")]
2822    pub introduced: Option<AuditIntroduced>,
2823    /// Gate severity of this finding after `rules` and `overrides[].rules`
2824    /// resolve for its path. CI formats read it for the annotation, SARIF
2825    /// and CodeClimate level. Absent in output from older versions. Not
2826    /// part of the finding identity, baseline keys or fingerprints.
2827    #[serde(
2828        default,
2829        skip_serializing_if = "Option::is_none",
2830        deserialize_with = "deserialize_effective_severity"
2831    )]
2832    pub effective_severity: Option<EffectiveSeverity>,
2833    /// Advisory caveats on the verdict behind this finding. A store member's
2834    /// usage is collected by the same reachability-free member-access walk a
2835    /// class member's is, so it takes the member rule unchanged: any module
2836    /// this run analyzed incompletely can hold the access that credits it.
2837    /// Sorted, deduplicated, and omitted from the wire when empty. There is no
2838    /// mutation here to withhold, because a store member offers none on any
2839    /// surface; this is disclosure only, so a reader deciding by hand is told
2840    /// what the run did not see.
2841    #[serde(default, skip_serializing_if = "Vec::is_empty")]
2842    pub reachability_caveats: Vec<ReachabilityCaveat>,
2843}
2844
2845impl UnusedStoreMemberFinding {
2846    /// Build the wrapper from a raw [`UnusedMember`]. Emits only a line-level
2847    /// suppress action (no auto-fix: store members can be accessed
2848    /// reflectively, so removal is never provably safe).
2849    #[must_use]
2850    pub fn with_actions(member: UnusedMember) -> Self {
2851        let actions = vec![IssueAction::SuppressLine(SuppressLineAction {
2852            kind: SuppressLineKind::SuppressLine,
2853            auto_fixable: false,
2854            description: "Suppress with an inline comment above the line".to_string(),
2855            comment: "// fallow-ignore-next-line unused-store-member".to_string(),
2856            scope: None,
2857        })];
2858        Self {
2859            finding_id: None,
2860            member,
2861            actions,
2862            introduced: None,
2863            effective_severity: None,
2864            reachability_caveats: Vec::new(),
2865        }
2866    }
2867}
2868
2869/// Wire-shape envelope for an [`UnusedMember`] finding consumed under the
2870/// `unused_namespace_members` key (an exported member of an exported
2871/// TypeScript namespace that no code reads). `member_name` is the dotted path
2872/// from the exported namespace, for example `Inner.x`. Emits only a
2873/// line-level suppress action: a member can be a multi-line function, class
2874/// or nested namespace, so there is no safe one-line auto-fix.
2875#[derive(Debug, Clone, Serialize, Deserialize)]
2876#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
2877pub struct UnusedNamespaceMemberFinding {
2878    /// The underlying dead-code entry.
2879    #[serde(flatten)]
2880    pub member: UnusedMember,
2881    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
2882    /// `~<k>` suffix when several findings of one type share an identity.
2883    /// Line and column are not inputs, so the id survives line shifts,
2884    /// reformats and reorders. A rename of the file or the symbol gives a
2885    /// new id. Absent in output from older versions.
2886    #[serde(default, skip_serializing_if = "Option::is_none")]
2887    pub finding_id: Option<String>,
2888    /// Suggested next steps. Always emitted (possibly empty for
2889    /// forward-compat).
2890    pub actions: Vec<IssueAction>,
2891    /// Set by the audit pass when this finding is introduced relative to
2892    /// the merge-base.
2893    #[serde(default, skip_serializing_if = "Option::is_none")]
2894    pub introduced: Option<AuditIntroduced>,
2895    /// Gate severity of this finding after `rules` and `overrides[].rules`
2896    /// resolve for its path. CI formats read it for the annotation, SARIF
2897    /// and CodeClimate level. Absent in output from older versions. Not
2898    /// part of the finding identity, baseline keys or fingerprints.
2899    #[serde(
2900        default,
2901        skip_serializing_if = "Option::is_none",
2902        deserialize_with = "deserialize_effective_severity"
2903    )]
2904    pub effective_severity: Option<EffectiveSeverity>,
2905    /// Advisory caveats on the verdict behind this finding. A namespace
2906    /// member takes the member rule unchanged: any module this run analyzed
2907    /// incompletely can hold the access that credits it. Sorted,
2908    /// deduplicated, and omitted from the wire when empty. This is disclosure
2909    /// only, because a namespace member offers no mutation.
2910    #[serde(default, skip_serializing_if = "Vec::is_empty")]
2911    pub reachability_caveats: Vec<ReachabilityCaveat>,
2912}
2913
2914impl UnusedNamespaceMemberFinding {
2915    /// Build the wrapper from a raw [`UnusedMember`]. Emits only a line-level
2916    /// suppress action.
2917    #[must_use]
2918    pub fn with_actions(member: UnusedMember) -> Self {
2919        let actions = vec![IssueAction::SuppressLine(SuppressLineAction {
2920            kind: SuppressLineKind::SuppressLine,
2921            auto_fixable: false,
2922            description: "Suppress with an inline comment above the line".to_string(),
2923            comment: "// fallow-ignore-next-line unused-namespace-member".to_string(),
2924            scope: None,
2925        })];
2926        Self {
2927            finding_id: None,
2928            member,
2929            actions,
2930            introduced: None,
2931            effective_severity: None,
2932            reachability_caveats: Vec::new(),
2933        }
2934    }
2935}
2936
2937/// Wire-shape envelope for an [`UnusedMember`] finding consumed under the
2938/// `unused_protected_class_members` key (a `protected` class method or
2939/// property that neither its class nor a subclass reads). Emits only a
2940/// line-level suppress action: a subclass outside the project can read the
2941/// member, so removal is a decision for the user.
2942#[derive(Debug, Clone, Serialize, Deserialize)]
2943#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
2944pub struct UnusedProtectedClassMemberFinding {
2945    /// The underlying dead-code entry.
2946    #[serde(flatten)]
2947    pub member: UnusedMember,
2948    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
2949    /// `~<k>` suffix when several findings of one type share an identity.
2950    /// Line and column are not inputs, so the id survives line shifts,
2951    /// reformats and reorders. A rename of the file or the symbol gives a
2952    /// new id. Absent in output from older versions.
2953    #[serde(default, skip_serializing_if = "Option::is_none")]
2954    pub finding_id: Option<String>,
2955    /// Suggested next steps. Always emitted (possibly empty for
2956    /// forward-compat).
2957    pub actions: Vec<IssueAction>,
2958    /// Set by the audit pass when this finding is introduced relative to
2959    /// the merge-base.
2960    #[serde(default, skip_serializing_if = "Option::is_none")]
2961    pub introduced: Option<AuditIntroduced>,
2962    /// Gate severity of this finding after `rules` and `overrides[].rules`
2963    /// resolve for its path. CI formats read it for the annotation, SARIF
2964    /// and CodeClimate level. Absent in output from older versions. Not
2965    /// part of the finding identity, baseline keys or fingerprints.
2966    #[serde(
2967        default,
2968        skip_serializing_if = "Option::is_none",
2969        deserialize_with = "deserialize_effective_severity"
2970    )]
2971    pub effective_severity: Option<EffectiveSeverity>,
2972    /// Advisory caveats on the verdict behind this finding. A protected
2973    /// member takes the member rule unchanged: any module this run analyzed
2974    /// incompletely can hold the access that credits it. Sorted,
2975    /// deduplicated, and omitted from the wire when empty. This is disclosure
2976    /// only, because a protected member offers no mutation.
2977    #[serde(default, skip_serializing_if = "Vec::is_empty")]
2978    pub reachability_caveats: Vec<ReachabilityCaveat>,
2979}
2980
2981impl UnusedProtectedClassMemberFinding {
2982    /// Build the wrapper from a raw [`UnusedMember`]. Emits only a line-level
2983    /// suppress action.
2984    #[must_use]
2985    pub fn with_actions(member: UnusedMember) -> Self {
2986        let actions = vec![IssueAction::SuppressLine(SuppressLineAction {
2987            kind: SuppressLineKind::SuppressLine,
2988            auto_fixable: false,
2989            description: "Suppress with an inline comment above the line".to_string(),
2990            comment: "// fallow-ignore-next-line unused-protected-class-member".to_string(),
2991            scope: None,
2992        })];
2993        Self {
2994            finding_id: None,
2995            member,
2996            actions,
2997            introduced: None,
2998            effective_severity: None,
2999            reachability_caveats: Vec::new(),
3000        }
3001    }
3002}
3003
3004/// Build an `ignoreDependencies` config action for a package manifest finding.
3005fn build_ignore_dependencies_suppress_action(package_name: &str) -> IssueAction {
3006    IssueAction::AddToConfig(AddToConfigAction {
3007        kind: AddToConfigKind::AddToConfig,
3008        auto_fixable: false,
3009        description: format!("Add \"{package_name}\" to ignoreDependencies in fallow config"),
3010        config_key: "ignoreDependencies".to_string(),
3011        value: AddToConfigValue::Scalar(package_name.to_string()),
3012        value_schema: Some(
3013            "https://raw.githubusercontent.com/fallow-rs/fallow/main/schema.json#/properties/ignoreDependencies/items"
3014                .to_string(),
3015        ),
3016    })
3017}
3018
3019/// Wire-shape envelope for an [`UnusedDependency`] finding consumed under
3020/// the `unused_dependencies` key (production deps). Flattens the bare
3021/// finding; the typed `actions` array carries either a `remove-dependency`
3022/// or `move-dependency` primary depending on
3023/// `inner.used_in_workspaces`.
3024#[derive(Debug, Clone, Serialize, Deserialize)]
3025#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
3026pub struct UnusedDependencyFinding {
3027    /// The underlying dead-code entry.
3028    #[serde(flatten)]
3029    pub dep: UnusedDependency,
3030    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
3031    /// `~<k>` suffix when several findings of one type share an identity.
3032    /// Line and column are not inputs, so the id survives line shifts,
3033    /// reformats and reorders. A rename of the file or the symbol gives a
3034    /// new id. Absent in output from older versions.
3035    #[serde(default, skip_serializing_if = "Option::is_none")]
3036    pub finding_id: Option<String>,
3037    /// Suggested next steps. Always emitted (possibly empty for
3038    /// forward-compat).
3039    pub actions: Vec<IssueAction>,
3040    /// Set by the audit pass when this finding is introduced relative to
3041    /// the merge-base.
3042    #[serde(default, skip_serializing_if = "Option::is_none")]
3043    pub introduced: Option<AuditIntroduced>,
3044    /// Gate severity of this finding after `rules` and `overrides[].rules`
3045    /// resolve for its path. CI formats read it for the annotation, SARIF
3046    /// and CodeClimate level. Absent in output from older versions. Not
3047    /// part of the finding identity, baseline keys or fingerprints.
3048    #[serde(
3049        default,
3050        skip_serializing_if = "Option::is_none",
3051        deserialize_with = "deserialize_effective_severity"
3052    )]
3053    pub effective_severity: Option<EffectiveSeverity>,
3054    /// Advisory caveats on the verdict behind this finding. A dependency is
3055    /// reported unused when NO module in the project imports its specifier,
3056    /// so a module that parsed with errors can hide the import that would
3057    /// have credited the package. Sorted, deduplicated, and omitted from the
3058    /// wire when empty. Never gates the finding, though `fallow fix`
3059    /// withholds the `remove-dependency` write while a caveat stands.
3060    #[serde(default, skip_serializing_if = "Vec::is_empty")]
3061    pub reachability_caveats: Vec<ReachabilityCaveat>,
3062}
3063
3064impl UnusedDependencyFinding {
3065    /// Build the wrapper. Switches the primary fix from `remove-dependency`
3066    /// to `move-dependency` when the dep is imported by another workspace.
3067    #[must_use]
3068    pub fn with_actions(dep: UnusedDependency) -> Self {
3069        let actions = build_unused_dependency_actions(&dep, "dependencies");
3070        Self {
3071            finding_id: None,
3072            dep,
3073            actions,
3074            introduced: None,
3075            effective_severity: None,
3076            reachability_caveats: Vec::new(),
3077        }
3078    }
3079}
3080
3081/// Wire-shape envelope for an [`UnusedDependency`] finding consumed under
3082/// the `unused_dev_dependencies` key. Same bare struct as
3083/// [`UnusedDependencyFinding`]; the fix description points at
3084/// `devDependencies` and the suppress comment uses
3085/// `unused-dev-dependency`.
3086#[derive(Debug, Clone, Serialize, Deserialize)]
3087#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
3088pub struct UnusedDevDependencyFinding {
3089    /// The underlying dead-code entry.
3090    #[serde(flatten)]
3091    pub dep: UnusedDependency,
3092    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
3093    /// `~<k>` suffix when several findings of one type share an identity.
3094    /// Line and column are not inputs, so the id survives line shifts,
3095    /// reformats and reorders. A rename of the file or the symbol gives a
3096    /// new id. Absent in output from older versions.
3097    #[serde(default, skip_serializing_if = "Option::is_none")]
3098    pub finding_id: Option<String>,
3099    /// Suggested next steps. Always emitted (possibly empty for
3100    /// forward-compat).
3101    pub actions: Vec<IssueAction>,
3102    /// Set by the audit pass when this finding is introduced relative to
3103    /// the merge-base.
3104    #[serde(default, skip_serializing_if = "Option::is_none")]
3105    pub introduced: Option<AuditIntroduced>,
3106    /// Gate severity of this finding after `rules` and `overrides[].rules`
3107    /// resolve for its path. CI formats read it for the annotation, SARIF
3108    /// and CodeClimate level. Absent in output from older versions. Not
3109    /// part of the finding identity, baseline keys or fingerprints.
3110    #[serde(
3111        default,
3112        skip_serializing_if = "Option::is_none",
3113        deserialize_with = "deserialize_effective_severity"
3114    )]
3115    pub effective_severity: Option<EffectiveSeverity>,
3116    /// Advisory caveats on the verdict behind this finding. A dependency is
3117    /// reported unused when NO module in the project imports its specifier,
3118    /// so a module that parsed with errors can hide the import that would
3119    /// have credited the package. Sorted, deduplicated, and omitted from the
3120    /// wire when empty. Never gates the finding, though `fallow fix`
3121    /// withholds the `remove-dependency` write while a caveat stands.
3122    #[serde(default, skip_serializing_if = "Vec::is_empty")]
3123    pub reachability_caveats: Vec<ReachabilityCaveat>,
3124}
3125
3126impl UnusedDevDependencyFinding {
3127    /// Build the wrapper.
3128    #[must_use]
3129    pub fn with_actions(dep: UnusedDependency) -> Self {
3130        let actions = build_unused_dependency_actions(&dep, "devDependencies");
3131        Self {
3132            finding_id: None,
3133            dep,
3134            actions,
3135            introduced: None,
3136            effective_severity: None,
3137            reachability_caveats: Vec::new(),
3138        }
3139    }
3140}
3141
3142/// Wire-shape envelope for an [`UnusedDependency`] finding consumed under
3143/// the `unused_optional_dependencies` key. Same bare struct as
3144/// [`UnusedDependencyFinding`]; the fix description points at
3145/// `optionalDependencies`. Reuses the `unused-dependency` suppress
3146/// `IssueKind` because there is no dedicated variant for optional deps.
3147#[derive(Debug, Clone, Serialize, Deserialize)]
3148#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
3149pub struct UnusedOptionalDependencyFinding {
3150    /// The underlying dead-code entry.
3151    #[serde(flatten)]
3152    pub dep: UnusedDependency,
3153    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
3154    /// `~<k>` suffix when several findings of one type share an identity.
3155    /// Line and column are not inputs, so the id survives line shifts,
3156    /// reformats and reorders. A rename of the file or the symbol gives a
3157    /// new id. Absent in output from older versions.
3158    #[serde(default, skip_serializing_if = "Option::is_none")]
3159    pub finding_id: Option<String>,
3160    /// Suggested next steps. Always emitted (possibly empty for
3161    /// forward-compat).
3162    pub actions: Vec<IssueAction>,
3163    /// Set by the audit pass when this finding is introduced relative to
3164    /// the merge-base.
3165    #[serde(default, skip_serializing_if = "Option::is_none")]
3166    pub introduced: Option<AuditIntroduced>,
3167    /// Gate severity of this finding after `rules` and `overrides[].rules`
3168    /// resolve for its path. CI formats read it for the annotation, SARIF
3169    /// and CodeClimate level. Absent in output from older versions. Not
3170    /// part of the finding identity, baseline keys or fingerprints.
3171    #[serde(
3172        default,
3173        skip_serializing_if = "Option::is_none",
3174        deserialize_with = "deserialize_effective_severity"
3175    )]
3176    pub effective_severity: Option<EffectiveSeverity>,
3177    /// Advisory caveats on the verdict behind this finding. A dependency is
3178    /// reported unused when NO module in the project imports its specifier,
3179    /// so a module that parsed with errors can hide the import that would
3180    /// have credited the package. Sorted, deduplicated, and omitted from the
3181    /// wire when empty. Never gates the finding, though `fallow fix`
3182    /// withholds the `remove-dependency` write while a caveat stands.
3183    #[serde(default, skip_serializing_if = "Vec::is_empty")]
3184    pub reachability_caveats: Vec<ReachabilityCaveat>,
3185}
3186
3187impl UnusedOptionalDependencyFinding {
3188    /// Build the wrapper.
3189    #[must_use]
3190    pub fn with_actions(dep: UnusedDependency) -> Self {
3191        let actions = build_unused_dependency_actions(&dep, "optionalDependencies");
3192        Self {
3193            finding_id: None,
3194            dep,
3195            actions,
3196            introduced: None,
3197            effective_severity: None,
3198            reachability_caveats: Vec::new(),
3199        }
3200    }
3201}
3202
3203/// Wire-shape envelope for an [`UnlistedDependency`] finding. Carries an
3204/// `install-dependency` primary (non-auto-fixable) plus the standard
3205/// `ignoreDependencies` config suppress.
3206#[derive(Debug, Clone, Serialize, Deserialize)]
3207#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
3208pub struct UnlistedDependencyFinding {
3209    /// The underlying dead-code entry.
3210    #[serde(flatten)]
3211    pub dep: UnlistedDependency,
3212    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
3213    /// `~<k>` suffix when several findings of one type share an identity.
3214    /// Line and column are not inputs, so the id survives line shifts,
3215    /// reformats and reorders. A rename of the file or the symbol gives a
3216    /// new id. Absent in output from older versions.
3217    #[serde(default, skip_serializing_if = "Option::is_none")]
3218    pub finding_id: Option<String>,
3219    /// Suggested next steps. Always emitted (possibly empty for
3220    /// forward-compat).
3221    pub actions: Vec<IssueAction>,
3222    /// Set by the audit pass when this finding is introduced relative to
3223    /// the merge-base.
3224    #[serde(default, skip_serializing_if = "Option::is_none")]
3225    pub introduced: Option<AuditIntroduced>,
3226    /// Gate severity of this finding after `rules` and `overrides[].rules`
3227    /// resolve for its path. CI formats read it for the annotation, SARIF
3228    /// and CodeClimate level. Absent in output from older versions. Not
3229    /// part of the finding identity, baseline keys or fingerprints.
3230    #[serde(
3231        default,
3232        skip_serializing_if = "Option::is_none",
3233        deserialize_with = "deserialize_effective_severity"
3234    )]
3235    pub effective_severity: Option<EffectiveSeverity>,
3236}
3237
3238impl UnlistedDependencyFinding {
3239    /// Build the wrapper.
3240    #[must_use]
3241    pub fn with_actions(dep: UnlistedDependency) -> Self {
3242        let actions = vec![
3243            IssueAction::Fix(FixAction {
3244                kind: FixActionType::InstallDependency,
3245                auto_fixable: false,
3246                description: "Add this package to dependencies in package.json".to_string(),
3247                note: Some(
3248                    "Verify this package should be a direct dependency before adding".to_string(),
3249                ),
3250                available_in_catalogs: None,
3251                suggested_target: None,
3252            }),
3253            build_ignore_dependencies_suppress_action(&dep.package_name),
3254        ];
3255        Self {
3256            finding_id: None,
3257            dep,
3258            actions,
3259            introduced: None,
3260            effective_severity: None,
3261        }
3262    }
3263}
3264
3265/// Wire-shape envelope for an [`UnlistedBinary`] finding. Carries an
3266/// `install-dependency` primary (non-auto-fixable) plus an `ignoreBinaries`
3267/// config suppress.
3268#[derive(Debug, Clone, Serialize, Deserialize)]
3269#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
3270pub struct UnlistedBinaryFinding {
3271    /// The underlying dead-code entry.
3272    #[serde(flatten)]
3273    pub binary: UnlistedBinary,
3274    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
3275    /// `~<k>` suffix when several findings of one type share an identity.
3276    /// Line and column are not inputs, so the id survives line shifts,
3277    /// reformats and reorders. Absent in output from older versions.
3278    #[serde(default, skip_serializing_if = "Option::is_none")]
3279    pub finding_id: Option<String>,
3280    /// Suggested next steps. Always emitted (possibly empty for
3281    /// forward-compat).
3282    pub actions: Vec<IssueAction>,
3283    /// Set by the audit pass when this finding is introduced relative to
3284    /// the merge-base.
3285    #[serde(default, skip_serializing_if = "Option::is_none")]
3286    pub introduced: Option<AuditIntroduced>,
3287    /// Gate severity of this finding after `rules` and `overrides[].rules`
3288    /// resolve for its path. CI formats read it for the annotation, SARIF
3289    /// and CodeClimate level. Absent in output from older versions. Not
3290    /// part of the finding identity, baseline keys or fingerprints.
3291    #[serde(
3292        default,
3293        skip_serializing_if = "Option::is_none",
3294        deserialize_with = "deserialize_effective_severity"
3295    )]
3296    pub effective_severity: Option<EffectiveSeverity>,
3297}
3298
3299impl UnlistedBinaryFinding {
3300    /// Build the wrapper.
3301    #[must_use]
3302    pub fn with_actions(binary: UnlistedBinary) -> Self {
3303        let name = &binary.binary_name;
3304        let actions = vec![
3305            IssueAction::Fix(FixAction {
3306                kind: FixActionType::InstallDependency,
3307                auto_fixable: false,
3308                description: "Add the package that provides this binary to devDependencies"
3309                    .to_string(),
3310                note: Some(
3311                    "If the operating system or the CI image provides this binary, add it to ignoreBinaries instead"
3312                        .to_string(),
3313                ),
3314                available_in_catalogs: None,
3315                suggested_target: None,
3316            }),
3317            IssueAction::AddToConfig(AddToConfigAction {
3318                kind: AddToConfigKind::AddToConfig,
3319                auto_fixable: false,
3320                description: format!("Add \"{name}\" to ignoreBinaries in fallow config"),
3321                config_key: "ignoreBinaries".to_string(),
3322                value: AddToConfigValue::Scalar(name.clone()),
3323                value_schema: Some(
3324                    "https://raw.githubusercontent.com/fallow-rs/fallow/main/schema.json#/properties/ignoreBinaries/items"
3325                        .to_string(),
3326                ),
3327            }),
3328        ];
3329        Self {
3330            finding_id: None,
3331            binary,
3332            actions,
3333            introduced: None,
3334            effective_severity: None,
3335        }
3336    }
3337}
3338
3339/// Wire-shape envelope for a [`TypeOnlyDependency`] finding. Carries a
3340/// `move-to-dev` primary plus the standard `ignoreDependencies` config
3341/// suppress.
3342#[derive(Debug, Clone, Serialize, Deserialize)]
3343#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
3344pub struct TypeOnlyDependencyFinding {
3345    /// The underlying dead-code entry.
3346    #[serde(flatten)]
3347    pub dep: TypeOnlyDependency,
3348    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
3349    /// `~<k>` suffix when several findings of one type share an identity.
3350    /// Line and column are not inputs, so the id survives line shifts,
3351    /// reformats and reorders. A rename of the file or the symbol gives a
3352    /// new id. Absent in output from older versions.
3353    #[serde(default, skip_serializing_if = "Option::is_none")]
3354    pub finding_id: Option<String>,
3355    /// Suggested next steps. Always emitted (possibly empty for
3356    /// forward-compat).
3357    pub actions: Vec<IssueAction>,
3358    /// Set by the audit pass when this finding is introduced relative to
3359    /// the merge-base.
3360    #[serde(default, skip_serializing_if = "Option::is_none")]
3361    pub introduced: Option<AuditIntroduced>,
3362    /// Gate severity of this finding after `rules` and `overrides[].rules`
3363    /// resolve for its path. CI formats read it for the annotation, SARIF
3364    /// and CodeClimate level. Absent in output from older versions. Not
3365    /// part of the finding identity, baseline keys or fingerprints.
3366    #[serde(
3367        default,
3368        skip_serializing_if = "Option::is_none",
3369        deserialize_with = "deserialize_effective_severity"
3370    )]
3371    pub effective_severity: Option<EffectiveSeverity>,
3372}
3373
3374impl TypeOnlyDependencyFinding {
3375    /// Build the wrapper.
3376    #[must_use]
3377    pub fn with_actions(dep: TypeOnlyDependency) -> Self {
3378        let actions = vec![
3379            IssueAction::Fix(FixAction {
3380                kind: FixActionType::MoveToDev,
3381                auto_fixable: false,
3382                description: "Move to devDependencies (only type imports are used)".to_string(),
3383                note: Some(
3384                    "Type imports are erased at runtime so this dependency is not needed in production"
3385                        .to_string(),
3386                ),
3387                available_in_catalogs: None,
3388                suggested_target: None,
3389            }),
3390            build_ignore_dependencies_suppress_action(&dep.package_name),
3391        ];
3392        Self {
3393            finding_id: None,
3394            dep,
3395            actions,
3396            introduced: None,
3397            effective_severity: None,
3398        }
3399    }
3400}
3401
3402/// Wire-shape envelope for a [`TestOnlyDependency`] finding. Carries a
3403/// `move-to-dev` primary (different prose than [`TypeOnlyDependencyFinding`])
3404/// plus the standard `ignoreDependencies` config suppress.
3405#[derive(Debug, Clone, Serialize, Deserialize)]
3406#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
3407pub struct TestOnlyDependencyFinding {
3408    /// The underlying dead-code entry.
3409    #[serde(flatten)]
3410    pub dep: TestOnlyDependency,
3411    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
3412    /// `~<k>` suffix when several findings of one type share an identity.
3413    /// Line and column are not inputs, so the id survives line shifts,
3414    /// reformats and reorders. A rename of the file or the symbol gives a
3415    /// new id. Absent in output from older versions.
3416    #[serde(default, skip_serializing_if = "Option::is_none")]
3417    pub finding_id: Option<String>,
3418    /// Suggested next steps. Always emitted (possibly empty for
3419    /// forward-compat).
3420    pub actions: Vec<IssueAction>,
3421    /// Set by the audit pass when this finding is introduced relative to
3422    /// the merge-base.
3423    #[serde(default, skip_serializing_if = "Option::is_none")]
3424    pub introduced: Option<AuditIntroduced>,
3425    /// Gate severity of this finding after `rules` and `overrides[].rules`
3426    /// resolve for its path. CI formats read it for the annotation, SARIF
3427    /// and CodeClimate level. Absent in output from older versions. Not
3428    /// part of the finding identity, baseline keys or fingerprints.
3429    #[serde(
3430        default,
3431        skip_serializing_if = "Option::is_none",
3432        deserialize_with = "deserialize_effective_severity"
3433    )]
3434    pub effective_severity: Option<EffectiveSeverity>,
3435}
3436
3437impl TestOnlyDependencyFinding {
3438    /// Build the wrapper.
3439    #[must_use]
3440    pub fn with_actions(dep: TestOnlyDependency) -> Self {
3441        let actions = vec![
3442            IssueAction::Fix(FixAction {
3443                kind: FixActionType::MoveToDev,
3444                auto_fixable: false,
3445                description: "Move to devDependencies (only test files import this)".to_string(),
3446                note: Some(
3447                    "Only test files import this package so it does not need to be a production dependency"
3448                        .to_string(),
3449                ),
3450                available_in_catalogs: None,
3451                suggested_target: None,
3452            }),
3453            build_ignore_dependencies_suppress_action(&dep.package_name),
3454        ];
3455        Self {
3456            finding_id: None,
3457            dep,
3458            actions,
3459            introduced: None,
3460            effective_severity: None,
3461        }
3462    }
3463}
3464
3465/// Wire-shape envelope for a [`DevDependencyInProduction`] finding. Carries a
3466/// `move-to-prod` primary (the promote-side mirror of
3467/// [`TestOnlyDependencyFinding`]'s `move-to-dev`) plus the standard
3468/// `ignoreDependencies` config suppress.
3469#[derive(Debug, Clone, Serialize, Deserialize)]
3470#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
3471pub struct DevDependencyInProductionFinding {
3472    /// The underlying dead-code entry.
3473    #[serde(flatten)]
3474    pub dep: DevDependencyInProduction,
3475    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
3476    /// `~<k>` suffix when several findings of one type share an identity.
3477    /// Line and column are not inputs, so the id survives line shifts,
3478    /// reformats and reorders. A rename of the file or the symbol gives a
3479    /// new id. Absent in output from older versions.
3480    #[serde(default, skip_serializing_if = "Option::is_none")]
3481    pub finding_id: Option<String>,
3482    /// Suggested next steps. Always emitted (possibly empty for
3483    /// forward-compat).
3484    pub actions: Vec<IssueAction>,
3485    /// Set by the audit pass when this finding is introduced relative to
3486    /// the merge-base.
3487    #[serde(default, skip_serializing_if = "Option::is_none")]
3488    pub introduced: Option<AuditIntroduced>,
3489    /// Gate severity of this finding after `rules` and `overrides[].rules`
3490    /// resolve for its path. CI formats read it for the annotation, SARIF
3491    /// and CodeClimate level. Absent in output from older versions. Not
3492    /// part of the finding identity, baseline keys or fingerprints.
3493    #[serde(
3494        default,
3495        skip_serializing_if = "Option::is_none",
3496        deserialize_with = "deserialize_effective_severity"
3497    )]
3498    pub effective_severity: Option<EffectiveSeverity>,
3499}
3500
3501impl DevDependencyInProductionFinding {
3502    /// Build the wrapper.
3503    #[must_use]
3504    pub fn with_actions(dep: DevDependencyInProduction) -> Self {
3505        let actions = vec![
3506            IssueAction::Fix(FixAction {
3507                kind: FixActionType::MoveToProd,
3508                auto_fixable: false,
3509                description:
3510                    "Move to dependencies if the deployment installs them (production code imports this)"
3511                        .to_string(),
3512                note: Some(
3513                    "A production-only install (`pnpm install --prod`) omits devDependencies, so an import resolved at runtime breaks. A build that inlines the package into its output resolves nothing at runtime, and moving it there can instead make the deployment require an install it did not need"
3514                        .to_string(),
3515                ),
3516                available_in_catalogs: None,
3517                suggested_target: None,
3518            }),
3519            build_ignore_dependencies_suppress_action(&dep.package_name),
3520        ];
3521        Self {
3522            finding_id: None,
3523            dep,
3524            actions,
3525            introduced: None,
3526            effective_severity: None,
3527        }
3528    }
3529}
3530
3531// ── Catalog / dep-override family ───────────────────────────────
3532//
3533// These six wrappers replace the legacy `inject_actions` post-pass in
3534// `crates/cli/src/report/json.rs` for the catalog and dependency-override
3535// findings. Each `with_actions(...)` builds the typed `actions` array
3536// directly from the inner struct (and any per-call context such as
3537// `config_fixable`), so the wire shape is identical to the pre-2.76
3538// post-pass output but the Rust compiler now owns the action contract.
3539
3540/// Wire-shape envelope for a [`DuplicateExport`] finding. Carries up to
3541/// three actions in position-locked order: an `add-to-config` `ignoreExports`
3542/// snippet (only when `locations[]` carries at least one path) followed by
3543/// the `remove-duplicate` fix and the multi-location suppress.
3544///
3545/// The `add-to-config` action sits at position 0 because the documented
3546/// primary slot points at the safe, non-destructive path: the shadcn /
3547/// Radix / bits-ui namespace-barrel case where every `index.*` reexports
3548/// the directory's neighbours. The `remove-duplicate` fix stays as the
3549/// secondary so consumers that pattern-match on `actions[0].type` for
3550/// "primary fix" never propose deletion of an intentional barrel surface.
3551#[derive(Debug, Clone, Serialize, Deserialize)]
3552#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
3553pub struct DuplicateExportFinding {
3554    /// The underlying finding.
3555    #[serde(flatten)]
3556    pub export: DuplicateExport,
3557    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
3558    /// `~<k>` suffix when several findings of one type share an identity.
3559    /// Line and column are not inputs, so the id survives line shifts,
3560    /// reformats and reorders. A rename of the file or the symbol gives a
3561    /// new id. Absent in output from older versions.
3562    #[serde(default, skip_serializing_if = "Option::is_none")]
3563    pub finding_id: Option<String>,
3564    /// Suggested next steps. Always emitted (possibly empty for
3565    /// forward-compat).
3566    pub actions: Vec<IssueAction>,
3567    /// Set by the audit pass when this finding is introduced relative to
3568    /// the merge-base.
3569    #[serde(default, skip_serializing_if = "Option::is_none")]
3570    pub introduced: Option<AuditIntroduced>,
3571    /// Gate severity of this finding after `rules` and `overrides[].rules`
3572    /// resolve for its path. CI formats read it for the annotation, SARIF
3573    /// and CodeClimate level. Absent in output from older versions. Not
3574    /// part of the finding identity, baseline keys or fingerprints.
3575    #[serde(
3576        default,
3577        skip_serializing_if = "Option::is_none",
3578        deserialize_with = "deserialize_effective_severity"
3579    )]
3580    pub effective_severity: Option<EffectiveSeverity>,
3581}
3582
3583impl DuplicateExportFinding {
3584    /// Build the wrapper with the `add-to-config` action's `auto_fixable`
3585    /// defaulting to `false`. The CLI's `build_json_with_config_fixable`
3586    /// path layers the actual `config_fixable` signal via
3587    /// [`Self::set_config_fixable`] right before serialization (the
3588    /// fix-applier readiness check lives in `fallow-cli::fix` and is not
3589    /// reachable from the analyzer layer where wrappers are first built).
3590    /// Embedders that build `AnalysisResults` directly and never route
3591    /// through the CLI's JSON path keep the conservative default.
3592    #[must_use]
3593    pub fn with_actions(export: DuplicateExport) -> Self {
3594        let mut actions: Vec<IssueAction> = Vec::with_capacity(3);
3595
3596        if let Some(rules) = build_duplicate_exports_ignore_rules(&export) {
3597            actions.push(IssueAction::AddToConfig(AddToConfigAction {
3598                kind: AddToConfigKind::AddToConfig,
3599                auto_fixable: false,
3600                description: "Add an ignoreExports rule so these files are excluded from duplicate-export grouping (use when this duplication is an intentional namespace-barrel API).".to_string(),
3601                config_key: "ignoreExports".to_string(),
3602                value: AddToConfigValue::ExportsRules(rules),
3603                value_schema: Some(IGNORE_EXPORTS_VALUE_SCHEMA.to_string()),
3604            }));
3605        }
3606
3607        actions.push(IssueAction::Fix(FixAction {
3608            kind: FixActionType::RemoveDuplicate,
3609            auto_fixable: false,
3610            description: "Keep one canonical export location and remove the others".to_string(),
3611            note: Some(NAMESPACE_BARREL_HINT.to_string()),
3612            available_in_catalogs: None,
3613            suggested_target: None,
3614        }));
3615
3616        actions.push(IssueAction::SuppressLine(SuppressLineAction {
3617            kind: SuppressLineKind::SuppressLine,
3618            auto_fixable: false,
3619            description: "Suppress with an inline comment above the line".to_string(),
3620            comment: "// fallow-ignore-next-line duplicate-export".to_string(),
3621            scope: Some(SuppressLineScope::PerLocation),
3622        }));
3623
3624        Self {
3625            finding_id: None,
3626            export,
3627            actions,
3628            introduced: None,
3629            effective_severity: None,
3630        }
3631    }
3632
3633    /// Update the position-0 `add-to-config` action's `auto_fixable` flag.
3634    /// Idempotent and a no-op when position 0 is not an `add-to-config`
3635    /// action (happens when the finding has no locations). Called by the
3636    /// CLI's JSON serializer with the result of
3637    /// `crate::fix::is_config_fixable` before emitting bytes.
3638    pub fn set_config_fixable(&mut self, fixable: bool) {
3639        if let Some(IssueAction::AddToConfig(action)) = self.actions.first_mut() {
3640            action.auto_fixable = fixable;
3641        }
3642    }
3643}
3644
3645/// Wire-shape envelope for an [`UnusedCatalogEntry`] finding. Per-instance
3646/// `auto_fixable` flips to `false` when `hardcoded_consumers` is non-empty or
3647/// the source is not `pnpm-workspace.yaml`.
3648#[derive(Debug, Clone, Serialize, Deserialize)]
3649#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
3650pub struct UnusedCatalogEntryFinding {
3651    /// The underlying finding.
3652    #[serde(flatten)]
3653    pub entry: UnusedCatalogEntry,
3654    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
3655    /// `~<k>` suffix when several findings of one type share an identity.
3656    /// Line and column are not inputs, so the id survives line shifts,
3657    /// reformats and reorders. A rename of the file or the symbol gives a
3658    /// new id. Absent in output from older versions.
3659    #[serde(default, skip_serializing_if = "Option::is_none")]
3660    pub finding_id: Option<String>,
3661    /// Suggested next steps. Always emitted.
3662    pub actions: Vec<IssueAction>,
3663    /// Set by the audit pass when this finding is introduced relative to
3664    /// the merge-base.
3665    #[serde(default, skip_serializing_if = "Option::is_none")]
3666    pub introduced: Option<AuditIntroduced>,
3667    /// Gate severity of this finding after `rules` and `overrides[].rules`
3668    /// resolve for its path. CI formats read it for the annotation, SARIF
3669    /// and CodeClimate level. Absent in output from older versions. Not
3670    /// part of the finding identity, baseline keys or fingerprints.
3671    #[serde(
3672        default,
3673        skip_serializing_if = "Option::is_none",
3674        deserialize_with = "deserialize_effective_severity"
3675    )]
3676    pub effective_severity: Option<EffectiveSeverity>,
3677}
3678
3679impl UnusedCatalogEntryFinding {
3680    /// Build the wrapper. Per-instance `auto_fixable` is `true` only when
3681    /// `hardcoded_consumers` is empty and the source is `pnpm-workspace.yaml`;
3682    /// otherwise `fallow fix` skips the entry to avoid breaking installs or
3683    /// applying YAML edits to Bun `package.json` catalogs.
3684    #[must_use]
3685    pub fn with_actions(entry: UnusedCatalogEntry) -> Self {
3686        let is_pnpm_source = is_pnpm_catalog_source(&entry.path);
3687        let auto_fixable = entry.hardcoded_consumers.is_empty() && is_pnpm_source;
3688        let note = if is_pnpm_source {
3689            Some(
3690                "If any consumer declares the same package with a hardcoded version, switch the consumer to `catalog:` before removing"
3691                    .to_string(),
3692            )
3693        } else {
3694            Some(
3695                "fallow fix only edits pnpm-workspace.yaml catalog entries. Edit Bun package.json catalogs manually."
3696                    .to_string(),
3697            )
3698        };
3699        let mut actions = vec![IssueAction::Fix(FixAction {
3700            kind: FixActionType::RemoveCatalogEntry,
3701            auto_fixable,
3702            description: if is_pnpm_source {
3703                "Remove the entry from pnpm-workspace.yaml".to_string()
3704            } else {
3705                "Remove the entry from the catalog source file manually".to_string()
3706            },
3707            note,
3708            available_in_catalogs: None,
3709            suggested_target: None,
3710        })];
3711        if is_pnpm_source {
3712            actions.push(IssueAction::SuppressLine(SuppressLineAction {
3713                kind: SuppressLineKind::SuppressLine,
3714                auto_fixable: false,
3715                description: "Suppress with a YAML comment above the line".to_string(),
3716                comment: "# fallow-ignore-next-line unused-catalog-entry".to_string(),
3717                scope: None,
3718            }));
3719        }
3720        Self {
3721            finding_id: None,
3722            entry,
3723            actions,
3724            introduced: None,
3725            effective_severity: None,
3726        }
3727    }
3728}
3729
3730/// Wire-shape envelope for an [`EmptyCatalogGroup`] finding. Carries a
3731/// `remove-empty-catalog-group` primary. YAML-sourced findings also include a
3732/// YAML-comment suppress action.
3733#[derive(Debug, Clone, Serialize, Deserialize)]
3734#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
3735pub struct EmptyCatalogGroupFinding {
3736    /// The underlying finding.
3737    #[serde(flatten)]
3738    pub group: EmptyCatalogGroup,
3739    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
3740    /// `~<k>` suffix when several findings of one type share an identity.
3741    /// Line and column are not inputs, so the id survives line shifts,
3742    /// reformats and reorders. A rename of the file or the symbol gives a
3743    /// new id. Absent in output from older versions.
3744    #[serde(default, skip_serializing_if = "Option::is_none")]
3745    pub finding_id: Option<String>,
3746    /// Suggested next steps. Always emitted.
3747    pub actions: Vec<IssueAction>,
3748    /// Set by the audit pass when this finding is introduced relative to
3749    /// the merge-base.
3750    #[serde(default, skip_serializing_if = "Option::is_none")]
3751    pub introduced: Option<AuditIntroduced>,
3752    /// Gate severity of this finding after `rules` and `overrides[].rules`
3753    /// resolve for its path. CI formats read it for the annotation, SARIF
3754    /// and CodeClimate level. Absent in output from older versions. Not
3755    /// part of the finding identity, baseline keys or fingerprints.
3756    #[serde(
3757        default,
3758        skip_serializing_if = "Option::is_none",
3759        deserialize_with = "deserialize_effective_severity"
3760    )]
3761    pub effective_severity: Option<EffectiveSeverity>,
3762}
3763
3764impl EmptyCatalogGroupFinding {
3765    /// Build the wrapper.
3766    #[must_use]
3767    pub fn with_actions(group: EmptyCatalogGroup) -> Self {
3768        let auto_fixable = is_pnpm_catalog_source(&group.path);
3769        let mut actions = vec![IssueAction::Fix(FixAction {
3770            kind: FixActionType::RemoveEmptyCatalogGroup,
3771            auto_fixable,
3772            description: if auto_fixable {
3773                "Remove the empty named catalog group from pnpm-workspace.yaml".to_string()
3774            } else {
3775                "Remove the empty named catalog group from the catalog source file manually"
3776                    .to_string()
3777            },
3778            note: Some(if auto_fixable {
3779                "Only named groups under `catalogs:` are flagged; the top-level `catalog:` hook is intentionally ignored"
3780                    .to_string()
3781            } else {
3782                "fallow fix only edits pnpm-workspace.yaml catalog groups. Edit Bun package.json catalogs manually."
3783                    .to_string()
3784            }),
3785            available_in_catalogs: None,
3786            suggested_target: None,
3787        })];
3788        if auto_fixable {
3789            actions.push(IssueAction::SuppressLine(SuppressLineAction {
3790                kind: SuppressLineKind::SuppressLine,
3791                auto_fixable: false,
3792                description: "Suppress with a YAML comment above the line".to_string(),
3793                comment: "# fallow-ignore-next-line empty-catalog-group".to_string(),
3794                scope: None,
3795            }));
3796        }
3797        Self {
3798            finding_id: None,
3799            group,
3800            actions,
3801            introduced: None,
3802            effective_severity: None,
3803        }
3804    }
3805}
3806
3807/// Wire-shape envelope for an [`UnresolvedCatalogReference`] finding. The
3808/// primary action at position 0 discriminates on `available_in_catalogs`:
3809/// `add-catalog-entry` when the array is empty (no other catalog declares
3810/// the package), or `update-catalog-reference` when at least one
3811/// alternative exists. When exactly one alternative exists, the action
3812/// also carries `suggested_target` so deterministic agents can land the
3813/// edit without picking from a list.
3814#[derive(Debug, Clone, Serialize, Deserialize)]
3815#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
3816pub struct UnresolvedCatalogReferenceFinding {
3817    /// The underlying finding.
3818    #[serde(flatten)]
3819    pub reference: UnresolvedCatalogReference,
3820    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
3821    /// `~<k>` suffix when several findings of one type share an identity.
3822    /// Line and column are not inputs, so the id survives line shifts,
3823    /// reformats and reorders. A rename of the file or the symbol gives a
3824    /// new id. Absent in output from older versions.
3825    #[serde(default, skip_serializing_if = "Option::is_none")]
3826    pub finding_id: Option<String>,
3827    /// Suggested next steps. Always emitted; position 0 is the discriminated
3828    /// primary (see struct docs).
3829    pub actions: Vec<IssueAction>,
3830    /// Set by the audit pass when this finding is introduced relative to
3831    /// the merge-base.
3832    #[serde(default, skip_serializing_if = "Option::is_none")]
3833    pub introduced: Option<AuditIntroduced>,
3834    /// Gate severity of this finding after `rules` and `overrides[].rules`
3835    /// resolve for its path. CI formats read it for the annotation, SARIF
3836    /// and CodeClimate level. Absent in output from older versions. Not
3837    /// part of the finding identity, baseline keys or fingerprints.
3838    #[serde(
3839        default,
3840        skip_serializing_if = "Option::is_none",
3841        deserialize_with = "deserialize_effective_severity"
3842    )]
3843    pub effective_severity: Option<EffectiveSeverity>,
3844}
3845
3846impl UnresolvedCatalogReferenceFinding {
3847    /// Build the wrapper. The discriminator at position 0 is the
3848    /// `add-catalog-entry` vs `update-catalog-reference` pick documented on
3849    /// the struct.
3850    #[must_use]
3851    pub fn with_actions(reference: UnresolvedCatalogReference) -> Self {
3852        // Normalize separators to forward slashes so the
3853        // `ignoreCatalogReferences.consumer` action value is portable when
3854        // pasted into a Windows-authored config. See
3855        // `build_duplicate_exports_ignore_rules` for the same pattern.
3856        let consumer_path = reference.path.to_string_lossy().replace('\\', "/");
3857        let primary = catalog_reference_primary_action(&reference);
3858        let fallback = remove_catalog_reference_action();
3859        let suppress = suppress_catalog_reference_action(&reference, consumer_path);
3860
3861        Self {
3862            finding_id: None,
3863            reference,
3864            actions: vec![primary, fallback, suppress],
3865            introduced: None,
3866            effective_severity: None,
3867        }
3868    }
3869}
3870
3871fn catalog_reference_primary_action(reference: &UnresolvedCatalogReference) -> IssueAction {
3872    if reference.available_in_catalogs.is_empty() {
3873        return IssueAction::Fix(FixAction {
3874            kind: FixActionType::AddCatalogEntry,
3875            auto_fixable: false,
3876            description: format!(
3877                "Add `{}` to the `{}` catalog in pnpm-workspace.yaml",
3878                reference.entry_name, reference.catalog_name
3879            ),
3880            note: Some(
3881                "Pin a version that satisfies the consumer's import; no other catalog declares this package today"
3882                    .to_string(),
3883            ),
3884            available_in_catalogs: None,
3885            suggested_target: None,
3886        });
3887    }
3888
3889    let available = reference.available_in_catalogs.clone();
3890    let suggested_target = (available.len() == 1).then(|| available[0].clone());
3891    IssueAction::Fix(FixAction {
3892        kind: FixActionType::UpdateCatalogReference,
3893        auto_fixable: false,
3894        description: format!(
3895            "Switch the reference from `catalog:{}` to a catalog that declares `{}`",
3896            reference.catalog_name, reference.entry_name
3897        ),
3898        note: None,
3899        available_in_catalogs: Some(available),
3900        suggested_target,
3901    })
3902}
3903
3904fn remove_catalog_reference_action() -> IssueAction {
3905    IssueAction::Fix(FixAction {
3906        kind: FixActionType::RemoveCatalogReference,
3907        auto_fixable: false,
3908        description: "Remove the catalog reference and pin a hardcoded version in its place"
3909            .to_string(),
3910        note: Some(
3911            "Use only when neither another catalog declares the package nor the named catalog should grow to include it"
3912                .to_string(),
3913        ),
3914        available_in_catalogs: None,
3915        suggested_target: None,
3916    })
3917}
3918
3919fn suppress_catalog_reference_action(
3920    reference: &UnresolvedCatalogReference,
3921    consumer_path: String,
3922) -> IssueAction {
3923    let mut suppress_value = serde_json::Map::new();
3924    suppress_value.insert(
3925        "package".to_string(),
3926        serde_json::Value::String(reference.entry_name.clone()),
3927    );
3928    suppress_value.insert(
3929        "catalog".to_string(),
3930        serde_json::Value::String(reference.catalog_name.clone()),
3931    );
3932    suppress_value.insert(
3933        "consumer".to_string(),
3934        serde_json::Value::String(consumer_path),
3935    );
3936    IssueAction::AddToConfig(AddToConfigAction {
3937        kind: AddToConfigKind::AddToConfig,
3938        auto_fixable: false,
3939        description: "Suppress this reference via ignoreCatalogReferences in fallow config (use when the catalog edit is intentionally landing in a separate PR or the package is a placeholder).".to_string(),
3940        config_key: "ignoreCatalogReferences".to_string(),
3941        value: AddToConfigValue::RuleObject(suppress_value),
3942        value_schema: Some(IGNORE_CATALOG_REFERENCES_VALUE_SCHEMA.to_string()),
3943    })
3944}
3945
3946/// Wire-shape envelope for an [`UnusedDependencyOverride`] finding. Carries
3947/// a `remove-dependency-override` primary plus an `add-to-config`
3948/// `ignoreDependencyOverrides` suppress scoped to the target package and
3949/// declaration source.
3950#[derive(Debug, Clone, Serialize, Deserialize)]
3951#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
3952pub struct UnusedDependencyOverrideFinding {
3953    /// The underlying finding.
3954    #[serde(flatten)]
3955    pub entry: UnusedDependencyOverride,
3956    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
3957    /// `~<k>` suffix when several findings of one type share an identity.
3958    /// Line and column are not inputs, so the id survives line shifts,
3959    /// reformats and reorders. A rename of the file or the symbol gives a
3960    /// new id. Absent in output from older versions.
3961    #[serde(default, skip_serializing_if = "Option::is_none")]
3962    pub finding_id: Option<String>,
3963    /// Suggested next steps. Always emitted.
3964    pub actions: Vec<IssueAction>,
3965    /// Set by the audit pass when this finding is introduced relative to
3966    /// the merge-base.
3967    #[serde(default, skip_serializing_if = "Option::is_none")]
3968    pub introduced: Option<AuditIntroduced>,
3969    /// Gate severity of this finding after `rules` and `overrides[].rules`
3970    /// resolve for its path. CI formats read it for the annotation, SARIF
3971    /// and CodeClimate level. Absent in output from older versions. Not
3972    /// part of the finding identity, baseline keys or fingerprints.
3973    #[serde(
3974        default,
3975        skip_serializing_if = "Option::is_none",
3976        deserialize_with = "deserialize_effective_severity"
3977    )]
3978    pub effective_severity: Option<EffectiveSeverity>,
3979}
3980
3981impl UnusedDependencyOverrideFinding {
3982    /// Build the wrapper.
3983    #[must_use]
3984    pub fn with_actions(entry: UnusedDependencyOverride) -> Self {
3985        let mut actions: Vec<IssueAction> = Vec::with_capacity(2);
3986        actions.push(IssueAction::Fix(FixAction {
3987            kind: FixActionType::RemoveDependencyOverride,
3988            auto_fixable: false,
3989            description: "Remove the package-manager override entry from its declaration source"
3990                .to_string(),
3991            note: Some(
3992                "Conservative static check; verify against the active package manager's frozen-lockfile install before removing in case the override targets a transitive dependency (CVE-fix pattern)"
3993                    .to_string(),
3994            ),
3995            available_in_catalogs: None,
3996            suggested_target: None,
3997        }));
3998
3999        if let Some(suppress) = build_ignore_dependency_overrides_suppress(
4000            Some(&entry.target_package),
4001            &entry.raw_key,
4002            entry.source,
4003        ) {
4004            actions.push(suppress);
4005        }
4006
4007        Self {
4008            finding_id: None,
4009            entry,
4010            actions,
4011            introduced: None,
4012            effective_severity: None,
4013        }
4014    }
4015}
4016
4017/// Wire-shape envelope for a [`MisconfiguredDependencyOverride`] finding.
4018/// Carries a `fix-dependency-override` primary plus the conditional
4019/// `add-to-config` `ignoreDependencyOverrides` suppress (skipped when both
4020/// `target_package` and `raw_key` are empty, since the rule matcher keys on
4021/// a non-empty package name).
4022#[derive(Debug, Clone, Serialize, Deserialize)]
4023#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
4024pub struct MisconfiguredDependencyOverrideFinding {
4025    /// The underlying finding.
4026    #[serde(flatten)]
4027    pub entry: MisconfiguredDependencyOverride,
4028    /// Stable id of this finding: `dc1:<rule>:<16 hex digits>`, with a
4029    /// `~<k>` suffix when several findings of one type share an identity.
4030    /// Line and column are not inputs, so the id survives line shifts,
4031    /// reformats and reorders. A rename of the file or the symbol gives a
4032    /// new id. Absent in output from older versions.
4033    #[serde(default, skip_serializing_if = "Option::is_none")]
4034    pub finding_id: Option<String>,
4035    /// Suggested next steps. Always emitted.
4036    pub actions: Vec<IssueAction>,
4037    /// Set by the audit pass when this finding is introduced relative to
4038    /// the merge-base.
4039    #[serde(default, skip_serializing_if = "Option::is_none")]
4040    pub introduced: Option<AuditIntroduced>,
4041    /// Gate severity of this finding after `rules` and `overrides[].rules`
4042    /// resolve for its path. CI formats read it for the annotation, SARIF
4043    /// and CodeClimate level. Absent in output from older versions. Not
4044    /// part of the finding identity, baseline keys or fingerprints.
4045    #[serde(
4046        default,
4047        skip_serializing_if = "Option::is_none",
4048        deserialize_with = "deserialize_effective_severity"
4049    )]
4050    pub effective_severity: Option<EffectiveSeverity>,
4051}
4052
4053impl MisconfiguredDependencyOverrideFinding {
4054    /// Build the wrapper. The suppress action is omitted when neither
4055    /// `target_package` (set on `EmptyValue` cases) nor `raw_key` provides a
4056    /// non-empty package name; an `ignoreDependencyOverrides` entry with
4057    /// `package: ""` would be silently ignored by the config parser.
4058    #[must_use]
4059    pub fn with_actions(entry: MisconfiguredDependencyOverride) -> Self {
4060        let mut actions: Vec<IssueAction> = Vec::with_capacity(2);
4061        actions.push(IssueAction::Fix(FixAction {
4062            kind: FixActionType::FixDependencyOverride,
4063            auto_fixable: false,
4064            description:
4065                "Fix the package-manager override key or value: invalid entries are rejected or ignored"
4066                    .to_string(),
4067            note: Some(
4068                "Common shapes: bare `pkg`, scoped `@scope/pkg`, version-selector `pkg@<2`, parent-chain `parent>child`. Valid values include semver ranges, `-` (removal), `$ref` (self-ref), and `npm:alias@^1`."
4069                    .to_string(),
4070            ),
4071            available_in_catalogs: None,
4072            suggested_target: None,
4073        }));
4074
4075        if let Some(suppress) = build_ignore_dependency_overrides_suppress(
4076            entry.target_package.as_deref(),
4077            &entry.raw_key,
4078            entry.source,
4079        ) {
4080            actions.push(suppress);
4081        }
4082
4083        Self {
4084            finding_id: None,
4085            entry,
4086            actions,
4087            introduced: None,
4088            effective_severity: None,
4089        }
4090    }
4091}
4092
4093/// Shared `add-to-config` `ignoreDependencyOverrides` builder for the two
4094/// override findings. Returns `None` when no non-empty package name is
4095/// available; the config parser silently drops entries with an empty
4096/// `package` field, so emitting one would be a no-op that misleads agents.
4097fn build_ignore_dependency_overrides_suppress(
4098    target_package: Option<&str>,
4099    raw_key: &str,
4100    source: DependencyOverrideSource,
4101) -> Option<IssueAction> {
4102    let package = target_package
4103        .filter(|s| !s.is_empty())
4104        .or_else(|| Some(raw_key).filter(|s| !s.is_empty()))?
4105        .to_string();
4106    let mut value = serde_json::Map::new();
4107    value.insert("package".to_string(), serde_json::Value::String(package));
4108    value.insert(
4109        "source".to_string(),
4110        serde_json::Value::String(source.as_label().to_string()),
4111    );
4112    Some(IssueAction::AddToConfig(AddToConfigAction {
4113        kind: AddToConfigKind::AddToConfig,
4114        auto_fixable: false,
4115        description: "Suppress this override finding via ignoreDependencyOverrides in fallow config (use for CVE-fix overrides that target a purely-transitive package).".to_string(),
4116        config_key: "ignoreDependencyOverrides".to_string(),
4117        value: AddToConfigValue::RuleObject(value),
4118        value_schema: Some(IGNORE_DEPENDENCY_OVERRIDES_VALUE_SCHEMA.to_string()),
4119    }))
4120}
4121
4122// ── The mutation gate, registered once ──────────────────────────
4123//
4124// Every finding whose reachability verdict a lost import edge can distort.
4125// The analysis layer stamps caveats through `set_reachability_caveats`, which
4126// enforces the gate on the finding's actions in the same call; every mutation
4127// surface reads the answer back through `may_auto_apply_mutation`.
4128impl_caveated_finding!(
4129    UnusedFileFinding,
4130    UnusedExportFinding,
4131    UnusedTypeFinding,
4132    UnusedEnumMemberFinding,
4133    UnusedClassMemberFinding,
4134    UnusedNamespaceMemberFinding,
4135    UnusedProtectedClassMemberFinding,
4136    UnusedStoreMemberFinding,
4137    UnusedDependencyFinding,
4138    UnusedDevDependencyFinding,
4139    UnusedOptionalDependencyFinding,
4140);
4141
4142/// Gate severity of one finding after rule resolution.
4143///
4144/// It is the severity that `rules` and the matching `overrides[].rules` give
4145/// the finding for its path. `--fail-on-issues` raises `warn` to `error`. A
4146/// finding whose rule is `off` is not reported, so there is no `off` value.
4147/// The type is separate from the health `severity` band, which ranks a
4148/// finding and does not gate it.
4149///
4150/// The `fallow dead-code` findings gate fails when a finding is `error`.
4151/// Other gates (regression, stale baseline) decide on their own inputs. Two
4152/// commands differ: the `fallow audit` `new-only` gate fails only on introduced
4153/// findings, so an inherited `error` finding does not fail the audit, and the
4154/// combined command (`fallow` without a subcommand) exits 0 for machine
4155/// formats unless `--fail-on-issues` or `--ci` is set.
4156///
4157/// Complexity findings carry the same type. The `complexity-cyclomatic`,
4158/// `complexity-cognitive` and `complexity-crap` rules set it, and the
4159/// `fallow health` findings gate and the audit verdict read it.
4160#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
4161#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
4162#[serde(rename_all = "lowercase")]
4163pub enum EffectiveSeverity {
4164    /// The finding fails the run.
4165    Error,
4166    /// The finding is reported and does not fail the run.
4167    Warn,
4168}
4169
4170/// Read an optional [`EffectiveSeverity`] and treat an unknown value as absent.
4171///
4172/// A saved report from a newer version can carry a value this version does not
4173/// know. The renderers then use the rule-based level, as for a report without
4174/// the field, and the envelope still loads.
4175///
4176/// # Errors
4177///
4178/// Returns an error only when the input is not valid JSON-like data.
4179pub fn deserialize_effective_severity<'de, D>(
4180    deserializer: D,
4181) -> Result<Option<EffectiveSeverity>, D::Error>
4182where
4183    D: serde::Deserializer<'de>,
4184{
4185    #[derive(Deserialize)]
4186    #[serde(untagged)]
4187    enum Tolerant {
4188        Known(EffectiveSeverity),
4189        Unknown(serde::de::IgnoredAny),
4190    }
4191    Ok(match Option::<Tolerant>::deserialize(deserializer)? {
4192        Some(Tolerant::Known(severity)) => Some(severity),
4193        Some(Tolerant::Unknown(_)) | None => None,
4194    })
4195}
4196
4197/// A finding wrapper that carries an [`EffectiveSeverity`].
4198///
4199/// The analysis layer writes the value one time after rule resolution. CI
4200/// renderers read it and fall back to the rule-level severity when it is
4201/// absent, for example in a saved report from an older version.
4202pub trait GatedFinding {
4203    /// The gate severity, or `None` when no value was written.
4204    fn effective_severity(&self) -> Option<EffectiveSeverity>;
4205
4206    /// Write the gate severity.
4207    fn set_effective_severity(&mut self, severity: Option<EffectiveSeverity>);
4208}
4209
4210/// Implement [`GatedFinding`] for wrappers with an `effective_severity` field.
4211macro_rules! impl_gated_finding {
4212    ($($finding:ty),+ $(,)?) => {
4213        $(
4214            impl GatedFinding for $finding {
4215                fn effective_severity(&self) -> Option<EffectiveSeverity> {
4216                    self.effective_severity
4217                }
4218
4219                fn set_effective_severity(&mut self, severity: Option<EffectiveSeverity>) {
4220                    self.effective_severity = severity;
4221                }
4222            }
4223        )+
4224    };
4225}
4226
4227impl_gated_finding!(
4228    UnusedFileFinding,
4229    PrivateTypeLeakFinding,
4230    DeprecatedExportInUseFinding,
4231    UnresolvedImportFinding,
4232    CircularDependencyFinding,
4233    ReExportCycleFinding,
4234    PackageCycleFinding,
4235    BoundaryViolationFinding,
4236    BoundaryCoverageViolationFinding,
4237    BoundaryCallViolationFinding,
4238    UnusedExportFinding,
4239    UnusedTypeFinding,
4240    InvalidClientExportFinding,
4241    MixedClientServerBarrelFinding,
4242    MisplacedDirectiveFinding,
4243    UnprovidedInjectFinding,
4244    UnusedServerActionFinding,
4245    UnusedLoadDataKeyFinding,
4246    UnrenderedComponentFinding,
4247    UnusedComponentPropFinding,
4248    AbsentComponentPropFinding,
4249    UnusedComponentEmitFinding,
4250    UnusedSvelteEventFinding,
4251    UnusedEffectLayerFinding,
4252    UnusedTaggedErrorFinding,
4253    UnproducedCatchTagFinding,
4254    UnusedComponentInputFinding,
4255    UnusedComponentOutputFinding,
4256    RouteCollisionFinding,
4257    DynamicSegmentNameConflictFinding,
4258    UnusedEnumMemberFinding,
4259    UnusedClassMemberFinding,
4260    UnusedNamespaceMemberFinding,
4261    UnusedProtectedClassMemberFinding,
4262    UnusedStoreMemberFinding,
4263    UnusedDependencyFinding,
4264    UnusedDevDependencyFinding,
4265    UnusedOptionalDependencyFinding,
4266    UnlistedDependencyFinding,
4267    UnlistedBinaryFinding,
4268    TypeOnlyDependencyFinding,
4269    TestOnlyDependencyFinding,
4270    DevDependencyInProductionFinding,
4271    DuplicateExportFinding,
4272    DuplicateExportAliasFinding,
4273    UnusedCatalogEntryFinding,
4274    EmptyCatalogGroupFinding,
4275    UnresolvedCatalogReferenceFinding,
4276    UnusedDependencyOverrideFinding,
4277    MisconfiguredDependencyOverrideFinding,
4278    PropDrillingChainFinding,
4279    ThinWrapperFinding,
4280    DuplicatePropShapeFinding,
4281    crate::results::StaleSuppression,
4282);
4283
4284#[path = "output_dead_code_re_export_cycle.rs"]
4285mod output_dead_code_re_export_cycle;
4286pub use output_dead_code_re_export_cycle::ReExportCycleFinding;
4287
4288#[path = "output_dead_code_caveat_labels.rs"]
4289mod output_dead_code_caveat_labels;
4290pub use output_dead_code_caveat_labels::{
4291    CAVEAT_SUFFIX_MARKER, caveat_label_for_token, caveat_labels, caveat_labels_for_tokens,
4292    caveat_suffix, caveat_suffix_for_tokens, description_carries_caveat,
4293};
4294
4295#[path = "output_dead_code_test_importers.rs"]
4296mod output_dead_code_test_importers;
4297pub use output_dead_code_test_importers::{TEST_IMPORTERS_CAP, TEST_IMPORTERS_NOTE, TestImporters};
4298
4299#[path = "output_dead_code_namespace_escape.rs"]
4300mod output_dead_code_namespace_escape;
4301pub use output_dead_code_namespace_escape::NamespaceEscapeFinding;
4302#[path = "output_dead_code_class_member.rs"]
4303mod output_dead_code_class_member;
4304#[path = "output_dead_code_test_only_export.rs"]
4305mod output_dead_code_test_only_export;
4306pub use output_dead_code_test_only_export::TestOnlyExportFinding;
4307
4308#[path = "output_dead_code_actions.rs"]
4309mod output_dead_code_actions;
4310use output_dead_code_actions::{
4311    build_duplicate_exports_ignore_rules, build_unused_dependency_actions,
4312};
4313
4314#[cfg(test)]
4315#[path = "output_dead_code_caveat_tokens.rs"]
4316mod caveat_tokens;
4317
4318/// A caveated finding must expose no automatic fix. An uncaveated finding keeps its actions.
4319/// The annotation pass requires an implementation of `CaveatedFinding`.
4320/// The tests also cover finding types that can expose automatic fixes.
4321#[cfg(test)]
4322#[path = "output_dead_code_mutation_gate.rs"]
4323mod mutation_gate;
4324
4325// These tests pin the primary action at actions[0] for consumers that read it.
4326#[cfg(test)]
4327#[path = "output_dead_code_position_0_invariants.rs"]
4328mod position_0_invariants;