fallow_types/lib.rs
1//! Shared types for fallow codebase intelligence.
2//!
3//! This crate contains type definitions used across multiple fallow crates
4//! (core, CLI, LSP). It has no analysis logic, only data structures.
5//!
6//! User documentation for fallow is on [fallow.tools](https://fallow.tools/docs/).
7
8#![warn(missing_docs)]
9#![cfg_attr(
10 test,
11 allow(
12 clippy::unwrap_used,
13 clippy::expect_used,
14 reason = "tests use unwrap and expect to keep fixture setup concise"
15 )
16)]
17
18/// Atomic cache-file replacement, shared by the extraction cache and the graph
19/// cache so concurrent fallow processes never interleave a write.
20pub mod atomic_file;
21/// Typed audit cache-key inputs.
22pub mod audit_cache;
23/// Why a persisted cache was refused, shared by the extraction cache, the
24/// graph cache, the perf table, and `fallow doctor`.
25pub mod cache_rejection;
26/// Classification of the source file of a package manager catalog finding.
27pub mod catalog_source;
28/// Shared churn output contracts.
29pub mod churn;
30/// Cross-surface strings for the cloud runtime-coverage path, shared by the
31/// CLI's cloud `coverage` commands and the MCP cloud tools.
32pub mod cloud;
33/// One row per analysis subcommand: its JSON kinds and the surfaces that must
34/// know about it. Drift tests across the workspace read this table.
35pub mod command_surfaces;
36/// Per-construct complexity increments behind the complexity scores.
37pub mod complexity_contribution;
38/// The config file names that discovery reads and the near-miss names.
39pub mod config_file_names;
40/// A per-thread scope that keeps the diagnostics of a second analysis out
41/// of the report.
42pub mod diagnostic_scope;
43/// File discovery types: discovered files, file IDs, and entry points.
44pub mod discover;
45/// Display forms of project strings for text output and shell commands.
46pub mod display_text;
47/// Shared duplicate-code output contracts.
48pub mod duplicates;
49/// JSON-output envelope and utility types: `SchemaVersion`, `ToolVersion`,
50/// `ElapsedMs`, `AuditIntroduced`, plus the shared `Meta`, `BaselineDeltas`,
51/// `BaselineMatch`, `RegressionResult`, `EntryPoints`, and `CheckSummary`
52/// shapes referenced by every per-command envelope. The structs are always
53/// compiled (the JSON emission layer constructs them at runtime); the
54/// `schemars::JsonSchema` derive is gated per-struct on the `schema` feature.
55pub mod envelope;
56/// Where a fact sits on each JSON envelope shape, shared by the surfaces that
57/// read a saved envelope back rather than holding the run's typed state.
58pub mod envelope_sites;
59/// Module extraction types: exports, imports, re-exports, and member info.
60pub mod extract;
61mod extract_namespace_member_uses;
62pub mod flag_retirement;
63/// Guard output contracts for pre-edit architecture-rule lookup.
64pub mod guard;
65/// Stable finding identity: the shared FNV-1a 64 hash and dead-code
66/// `finding_id` values.
67pub mod identity;
68/// Inline health threshold override comments.
69pub mod inline_threshold;
70/// Shared issue-type contract metadata used by CLI, LSP, MCP, and suppression
71/// helpers.
72pub mod issue_meta;
73/// Levenshtein distance and closest-match policy for typo suggestions.
74pub mod levenshtein;
75mod link_walk;
76/// Machine-readable manifest of the fallow MCP server's tools, shared by
77/// `fallow schema` and the telemetry tool-name allowlist; kept in sync with
78/// the live tool router by a drift test in `crates/mcp`.
79pub mod mcp_manifest;
80/// JSON-output augmentation types: `IssueAction` enum + variants.
81/// Schema-side counterpart of the augmentations the JSON layer adds to each
82/// dead-code finding. The structs are always compiled (typed dead-code
83/// wrappers in [`output_dead_code`] consume them at runtime); the
84/// `schemars::JsonSchema` derive is gated per-struct on the `schema`
85/// feature.
86pub mod output;
87/// Typed envelope wrappers for the simple 1:1 dead-code findings
88/// (`UnusedFile`, `PrivateTypeLeak`, `UnresolvedImport`, `CircularDependency`,
89/// `BoundaryViolation`). Each wrapper flattens the bare finding via
90/// `#[serde(flatten)]` and creates a typed `actions` array at construction.
91/// The `introduced` field defaults to `None`. The audit pass inserts it into the
92/// JSON output. Each wrapper derives `schemars::JsonSchema` only with `schema`.
93pub mod output_dead_code;
94/// Shared output-format selector used by CLI, config, output, and API layers.
95pub mod output_format;
96/// Per-action types attached to health findings, hotspots, refactoring
97/// targets, and coverage-gap entries. Separated from the generic
98/// `IssueAction` tree in the `output` module so the health-specific
99/// variants live in a dedicated module. The structs are always compiled
100/// (the JSON emission layer constructs them through typed wrappers such as
101/// [`output_health::UntestedFileAction`]); the `schemars::JsonSchema`
102/// derive is gated per-struct on the `schema` feature.
103pub mod output_health;
104/// Refuse cache writes through a symlink that leaves the project.
105pub mod path_guard;
106/// Cross-platform path classification helpers.
107pub mod path_util;
108/// The `--performance` span tree and the process-level clock.
109pub mod pipeline_spans;
110/// Bounded reads of project files: no link out of the root, regular files
111/// only, and a size limit.
112pub mod read_guard;
113/// The directory that the reads of a project may reach.
114pub mod read_scope;
115/// Analysis result types: unused files, exports, dependencies, and members.
116pub mod results;
117/// The `Next:` step of a `client-server-leak` candidate, shared by the CLI
118/// and the LSP hover.
119pub mod security_next_step;
120/// Security sink names shared by the extractor and the sink catalogue.
121pub mod security_sinks;
122/// The line-free input of the stable id of a security finding.
123pub mod security_stable_id;
124/// Shared TypeScript semantic identity, provenance, API surface, impact, and
125/// public-signature coupling contracts.
126pub mod semantic;
127/// Custom serde serializers for cross-platform path output.
128pub mod serde_path;
129/// Transient source-extraction contracts for provider-backed similar-code analysis.
130pub mod similar_code;
131/// Shared source-file freshness metadata used by cache invalidation.
132pub mod source_fingerprint;
133/// Values with the cause of their value: the input layer, the scope, and the
134/// flag, variable, config key or default that gave the value.
135pub mod sourced;
136/// Inline suppression comment types and issue kind definitions.
137pub mod suppress;
138/// Agent task-to-command matrix rows shared by `fallow schema`, the
139/// `init --agents` template, the agent hook block, root `--help`, and the
140/// `fallow://task-matrix` MCP resource. Data only; the CLI owns rendering.
141pub mod task_matrix;
142/// The telemetry kill switches, shared by the CLI and the MCP server.
143pub mod telemetry_opt_out;
144/// Trace output contracts shared by core, engine, CLI, API, and MCP.
145pub mod trace;
146/// Symbol-level trace-chain output contracts.
147pub mod trace_chain;
148/// Stack-trace frame resolution output contracts (`fallow trace-error`).
149pub mod trace_error;
150/// Per-specifier dependency usage contracts (`fallow trace --dependency`).
151pub mod trace_usage;
152/// Workspace and source-discovery diagnostic data types
153/// (`WorkspaceDiagnostic`, `WorkspaceDiagnosticKind`). Re-exported by
154/// `fallow-config` for back-compat; embedded directly by `fallow-output` so
155/// `workspace_diagnostics[]` keeps its typed JSON schema. The
156/// `schemars::JsonSchema` derive is gated on the `schema` feature.
157pub mod workspace;
158
159/// The `tracing` target of a warning that repeats a fact the JSON envelope
160/// carries, or that describes the quality of the analysis inputs.
161///
162/// `--quiet`, `--ci` and `FALLOW_QUIET` hide this target on stderr. An explicit
163/// `RUST_LOG` shows it again. Config-load warnings, such as an unknown rule
164/// key, do not use this target, so they stay visible in a quiet run.
165pub const ANALYSIS_DIAGNOSTIC_LOG_TARGET: &str = "fallow::analysis_diagnostic";
166
167/// Optional architecture shared-state facts and inventory.
168pub mod shared_state;