Skip to main content

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