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/// Shared duplicate-code output contracts.
46pub mod duplicates;
47/// JSON-output envelope and utility types: `SchemaVersion`, `ToolVersion`,
48/// `ElapsedMs`, `AuditIntroduced`, plus the shared `Meta`, `BaselineDeltas`,
49/// `BaselineMatch`, `RegressionResult`, `EntryPoints`, and `CheckSummary`
50/// shapes referenced by every per-command envelope. The structs are always
51/// compiled (the JSON emission layer constructs them at runtime); the
52/// `schemars::JsonSchema` derive is gated per-struct on the `schema` feature.
53pub mod envelope;
54/// Where a fact sits on each JSON envelope shape, shared by the surfaces that
55/// read a saved envelope back rather than holding the run's typed state.
56pub mod envelope_sites;
57/// Module extraction types: exports, imports, re-exports, and member info.
58pub mod extract;
59mod extract_namespace_member_uses;
60pub mod flag_retirement;
61/// Guard output contracts for pre-edit architecture-rule lookup.
62pub mod guard;
63/// Stable finding identity: the shared FNV-1a 64 hash and dead-code
64/// `finding_id` values.
65pub mod identity;
66/// Inline health threshold override comments.
67pub mod inline_threshold;
68/// Shared issue-type contract metadata used by CLI, LSP, MCP, and suppression
69/// helpers.
70pub mod issue_meta;
71/// Levenshtein distance and closest-match policy for typo suggestions.
72pub mod levenshtein;
73/// Machine-readable manifest of the fallow MCP server's tools, shared by
74/// `fallow schema` and the telemetry tool-name allowlist; kept in sync with
75/// the live tool router by a drift test in `crates/mcp`.
76pub mod mcp_manifest;
77/// JSON-output augmentation types: `IssueAction` enum + variants.
78/// Schema-side counterpart of the augmentations the JSON layer adds to each
79/// dead-code finding. The structs are always compiled (typed dead-code
80/// wrappers in [`output_dead_code`] consume them at runtime); the
81/// `schemars::JsonSchema` derive is gated per-struct on the `schema`
82/// feature.
83pub mod output;
84/// Typed envelope wrappers for the simple 1:1 dead-code findings
85/// (`UnusedFile`, `PrivateTypeLeak`, `UnresolvedImport`, `CircularDependency`,
86/// `BoundaryViolation`). Each wrapper flattens the bare finding via
87/// `#[serde(flatten)]` and creates a typed `actions` array at construction.
88/// The `introduced` field defaults to `None`. The audit pass inserts it into the
89/// JSON output. Each wrapper derives `schemars::JsonSchema` only with `schema`.
90pub mod output_dead_code;
91/// Shared output-format selector used by CLI, config, output, and API layers.
92pub mod output_format;
93/// Per-action types attached to health findings, hotspots, refactoring
94/// targets, and coverage-gap entries. Separated from the generic
95/// `IssueAction` tree in the `output` module so the health-specific
96/// variants live in a dedicated module. The structs are always compiled
97/// (the JSON emission layer constructs them through typed wrappers such as
98/// [`output_health::UntestedFileAction`]); the `schemars::JsonSchema`
99/// derive is gated per-struct on the `schema` feature.
100pub mod output_health;
101/// Refuse cache writes through a symlink that leaves the project.
102pub mod path_guard;
103/// Cross-platform path classification helpers.
104pub mod path_util;
105/// The `--performance` span tree and the process-level clock.
106pub mod pipeline_spans;
107/// Bounded reads of project files: no link out of the root, regular files
108/// only, and a size limit.
109pub mod read_guard;
110/// Analysis result types: unused files, exports, dependencies, and members.
111pub mod results;
112/// The `Next:` step of a `client-server-leak` candidate, shared by the CLI
113/// and the LSP hover.
114pub mod security_next_step;
115/// Security sink names shared by the extractor and the sink catalogue.
116pub mod security_sinks;
117/// The line-free input of the stable id of a security finding.
118pub mod security_stable_id;
119/// Shared TypeScript semantic identity, provenance, API surface, impact, and
120/// public-signature coupling contracts.
121pub mod semantic;
122/// Custom serde serializers for cross-platform path output.
123pub mod serde_path;
124/// Transient source-extraction contracts for provider-backed similar-code analysis.
125pub mod similar_code;
126/// Shared source-file freshness metadata used by cache invalidation.
127pub mod source_fingerprint;
128/// Values with the cause of their value: the input layer, the scope, and the
129/// flag, variable, config key or default that gave the value.
130pub mod sourced;
131/// Inline suppression comment types and issue kind definitions.
132pub mod suppress;
133/// Agent task-to-command matrix rows shared by `fallow schema`, the
134/// `init --agents` template, the agent hook block, root `--help`, and the
135/// `fallow://task-matrix` MCP resource. Data only; the CLI owns rendering.
136pub mod task_matrix;
137/// Trace output contracts shared by core, engine, CLI, API, and MCP.
138pub mod trace;
139/// Symbol-level trace-chain output contracts.
140pub mod trace_chain;
141/// Stack-trace frame resolution output contracts (`fallow trace-error`).
142pub mod trace_error;
143/// Per-specifier dependency usage contracts (`fallow trace --dependency`).
144pub mod trace_usage;
145/// Workspace and source-discovery diagnostic data types
146/// (`WorkspaceDiagnostic`, `WorkspaceDiagnosticKind`). Re-exported by
147/// `fallow-config` for back-compat; embedded directly by `fallow-output` so
148/// `workspace_diagnostics[]` keeps its typed JSON schema. The
149/// `schemars::JsonSchema` derive is gated on the `schema` feature.
150pub mod workspace;
151
152/// The `tracing` target of a warning that repeats a fact the JSON envelope
153/// carries, or that describes the quality of the analysis inputs.
154///
155/// `--quiet`, `--ci` and `FALLOW_QUIET` hide this target on stderr. An explicit
156/// `RUST_LOG` shows it again. Config-load warnings, such as an unknown rule
157/// key, do not use this target, so they stay visible in a quiet run.
158pub const ANALYSIS_DIAGNOSTIC_LOG_TARGET: &str = "fallow::analysis_diagnostic";
159
160/// Optional architecture shared-state facts and inventory.
161pub mod shared_state;