Skip to main content

fallow_extract/cache/
types.rs

1//! Serialization types for the incremental parse cache.
2//!
3//! All types use bitcode `Encode`/`Decode` for fast binary serialization.
4
5use bitcode::{Decode, Encode};
6
7use crate::MemberKind;
8
9/// Cache version, bump when the cache format or cached extraction semantics change.
10///
11/// Bumped to 89 for issue #475: extraction now strips a leading UTF-8 BOM
12/// before hashing and computing line offsets, so pre-fix entries whose source
13/// included a BOM carry hashes over the wrong byte sequence and would
14/// fast-path into stale `member_accesses` / `exports` for any BOM-bearing
15/// file. The bump invalidates user caches once on upgrade; subsequent runs
16/// are warm.
17///
18/// Bumped to 90 for issue #540: CSS Modules class extraction now strips
19/// `@layer` and `@import` at-rule preludes before scanning class names, so
20/// pre-fix entries for `.module.css` files using nested cascade-layer syntax
21/// (`@layer foo.bar { ... }`) carry phantom `bar` / `baz` exports that the
22/// new scanner no longer produces.
23///
24/// Bumped to 91 for issue #549: CSS Modules class extraction now records a
25/// real `Span` pointing at each class's declaration position in the source.
26/// Pre-fix cache entries for `.module.css` / `.module.scss` files carry
27/// `Span::default()` (start=0, end=0) on every export, which renders every
28/// finding at line:1 col:0; the new scanner produces real offsets.
29///
30/// Bumped to 92 for issue #563: feature flag extraction recognizes additional
31/// built-in SDK providers (PostHog, Vercel Flags, Optimizely, Eppo, plus more
32/// ConfigCat surfaces) and Vercel `flag({ key: "..." })` object arguments, so
33/// pre-fix entries can carry stale `flag_uses`.
34///
35/// Bumped to 93 for issue #589: Node `module.register()` loader calls now
36/// emit `DynamicImportInfo.destructured_names` populated with the loader-hook
37/// allowlist (current `initialize` / `resolve` / `load` / `globalPreload`
38/// plus legacy `getFormat` / `getSource` / `transformSource`) for every
39/// relative or `file:` specifier, including specifiers bound via
40/// `new URL(..., import.meta.url)`. Pre-fix entries carry empty
41/// `destructured_names` for the same source, so they would silently miss
42/// the named-export credit until the file is touched.
43///
44/// Bumped to 94 for issue #586: Playwright helper fixture extraction recognizes
45/// helpers with local setup before the final `return base.extend<T>(...)`, so
46/// pre-fix entries can miss fixture definition sentinels.
47///
48/// Bumped to 95 for the Glimmer `<template>` scanner: imported-binding usage
49/// and `MemberAccess { object: "this", member }` records for `{{this.foo}}`
50/// template references are now folded into the extractor before
51/// `into_module_info`. Pre-fix entries for `.gts` / `.gjs` files omit both,
52/// so template-only imports surface as `unused-import` and template-only
53/// class members as `unused-class-member` until the cache is re-extracted.
54///
55/// Bumped to 96 for issue #640: generic JSX `<script src>` and
56/// `<link rel="stylesheet|modulepreload" href>` attributes no longer emit
57/// synthetic `SideEffect` imports, so pre-fix entries can carry stale JSX
58/// resource edges that surface as false `unresolved-imports`.
59///
60/// Bumped to 97 for issue #639: MDX import/export extraction now skips
61/// fenced Markdown code blocks, so pre-fix entries can carry stale example
62/// imports that surface as false `unresolved-imports`.
63///
64/// Bumped to 98 for issue #638: statically resolvable `child_process.fork()`
65/// targets now emit `DynamicImportInfo` entries for local runner files.
66/// Pre-fix entries omit those dynamic imports, so forked script files can be
67/// reported as unused until the file is re-extracted.
68///
69/// Bumped to 99 for issue #605: methods reached via `new Class(...).method()`
70/// receivers (direct and fluent-chain) now emit member accesses crediting the
71/// constructed class. Pre-fix entries lack those accesses, so such methods can
72/// be reported as unused class members until the file is re-extracted.
73///
74/// Bumped to 100 for issue #608: static Iconify icon strings (`icon="jam:github"`,
75/// `name="ic:round-home"`) in markup now populate `iconify_prefixes` so the
76/// `@iconify-json/<prefix>` package is credited. Pre-fix entries omit the field,
77/// so icon-set packages can be reported as unused until the file is re-extracted.
78///
79/// Bumped to 101 for issue #704: SFC template tags that match no import now
80/// populate `auto_import_candidates` for convention auto-import resolution.
81/// Pre-fix entries omit the field, so Nuxt components consumed only via template
82/// tags are not edge-credited until the file is re-extracted.
83///
84/// Bumped to 102 for issue #742: `FunctionComplexity` now carries an
85/// `Option<String> source_hash` (content digest of the function's full-span
86/// source slice) so runtime-coverage baselines survive line moves. Pre-fix
87/// cache entries lack the field, so the hash is absent until re-extraction.
88///
89/// Bumped to 103 for issue #752: typed destructure bindings
90/// (`let { resultState }: Props = $props()`, `function f({ x }: Props)`) now
91/// populate `binding_target_names`, which changes the `member_accesses` emitted
92/// for those files. Pre-fix cache entries lack the additional member accesses.
93///
94/// Bumped to 104 for issue #445: MDX, Astro, Vue/Svelte SFC, and CSS/SCSS
95/// container extraction now remaps source-authored spans back to the original
96/// file byte offsets. Pre-fix entries can carry synthetic extracted-buffer
97/// positions, so diagnostics can point at line 1 or compacted MDX lines until
98/// the file is re-extracted.
99///
100/// Bumped to 105 for issue #739: JS/TS and Vue/Svelte SFC script extraction
101/// now populates `auto_import_candidates` from unresolved value references.
102/// Pre-fix entries omit these candidates, so convention script auto-imports
103/// are not edge-credited until the file is re-extracted.
104///
105/// Bumped to 106 for `fallow security`: JS/TS extraction now stores file-level
106/// directives (`"use client"`, `"use server"`) in the parse cache so client
107/// boundary detection does not depend on stale cached module info.
108///
109/// Bumped to 107 for issue #835: Svelte `<script src>` references no longer
110/// emit synthetic imports because they are runtime markup, not bundled SFC
111/// script modules. Pre-fix entries can carry stale root-relative imports that
112/// surface as false `unresolved-imports`.
113///
114/// Bumped to 108 for three extraction-semantics changes shipping together:
115/// - issue #839: `declare` ambient class properties are no longer extracted as
116///   class members (they emit no JS and cannot be value-referenced), so pre-fix
117///   entries carry phantom members that surface as false `unused-class-member`.
118/// - issue #840: extensionless `new URL(specifier, import.meta.url)` dynamic
119///   imports now persist `is_speculative = true` so a directory target
120///   (`new URL('./services', import.meta.url)`) is silently dropped when the
121///   resolver finds no module; pre-fix entries carry `is_speculative = false`
122///   and surface as false `unresolved-imports`.
123/// - issue #845: a method call on an `instanceof`-narrowed value now emits a
124///   member access against the narrowed class, changing the persisted
125///   `member_accesses`; pre-fix entries miss the credit and surface as false
126///   `unused-class-member`.
127///
128/// Bumped to 109 for the data-driven security matcher catalogue: JS/TS
129/// extraction now captures non-literal sink sites into `security_sinks`, each
130/// carrying an `arg_kind` discriminator (template-with-substitution, concat,
131/// object, call, other) so the catalogue can require unsafe SQL shapes and
132/// exclude safely-parameterized `` sql`${x}` `` templates and object-form
133/// `.execute({ sql, args })` arguments. Pre-109 entries lack the field, so their
134/// sink sites do not feed the catalogue until the file is re-extracted.
135///
136/// Bumped to 110 for issue #844: `const svc = useMemo(() => new Svc())` now
137/// binds the non-destructured identifier to the constructed class, so method
138/// calls on it emit member accesses crediting the class. This changes the
139/// persisted `member_accesses` for files using the useMemo factory shape;
140/// pre-fix entries miss the credit and surface as false `unused-class-member`.
141///
142/// Bumped to 111 for issue #859 (untrusted-source modeling): `SinkSite` now
143/// carries `arg_idents` (identifiers referenced in the sink argument) and
144/// `ModuleInfo`/`CachedModule` carry `tainted_bindings` (local bindings tied to
145/// the member-access path they were sourced from), so the security
146/// `tainted_sink` detector can back-trace a sink argument to a known untrusted
147/// source. Pre-111 entries lack both, so source-to-sink association is unset
148/// until the file is re-extracted.
149///
150/// Bumped to 112 for issue #863 (sanitizer-aware security sinks):
151/// `ModuleInfo`/`CachedModule` now carry direct sanitized sink arguments, so
152/// the security `tainted_sink` detector can suppress high-confidence
153/// DOMPurify-backed HTML sink candidates. Pre-112 entries lack sanitizer
154/// metadata until the file is re-extracted.
155///
156/// Bumped to 113 for issue #863 follow-up: sanitizer metadata gained URL and
157/// path domains plus guarded path backpatching. Pre-113 entries may lack those
158/// sanitizer domains until the file is re-extracted.
159///
160/// Bumped to 114 for issue #911: Angular component properties initialized with
161/// named-import `inject(Service)` now populate `ClassHeritageInfo.instance_bindings`
162/// so external templates can credit service member access through the property.
163/// Pre-114 entries miss the binding and can surface false `unused-class-member`
164/// findings until the component file is re-extracted.
165///
166/// Bumped to 115 for issue #910: local typed function calls now credit concrete
167/// class members when a direct `new Class()` argument or constructor-bound
168/// identifier flows into a structurally typed parameter. Pre-115 entries can
169/// miss those synthetic `member_accesses` and surface false
170/// `unused-class-member` findings.
171///
172/// Bumped to 117 for issue #955: Vue SFC script-side Nuxt UI icon strings now
173/// populate `iconify_icon_names`, allowing declared `@iconify-json/*`
174/// collections used through values like `icon: 'i-simple-icons-github'` to be
175/// credited. Pre-116 entries omit those names and can surface false
176/// `unused-dependency` findings until the file is re-extracted.
177///
178/// Bumped to 118 for issue #954: JS/TS extraction now records static
179/// `pino({ transport: { target: "pkg" } })` target packages as synthetic
180/// dynamic imports so runtime transport dependencies are credited. Pre-118
181/// entries can surface false `unused-dependency` findings until the file is
182/// re-extracted.
183///
184/// Bumped to 119 for issue #952: JS/TS extraction now records static package
185/// path resolution references so packages consumed via package-root and
186/// `pkg/package.json` lookups are credited as dependency usage. Pre-119
187/// entries omit those references and can surface false `unused-dependency`
188/// findings until the file is re-extracted.
189///
190/// Bumped to 120 for issue #953: instance methods annotated with TypeScript's
191/// `this` return type now count as self-returning for constructor-rooted
192/// fluent chains. Pre-120 entries can miss those self-returning flags and
193/// surface false `unused-class-member` findings until the file is re-extracted.
194///
195/// Bumped to 121 for issue #883: framework template HTML injection sinks now
196/// flow into `ModuleInfo.security_sinks` for Svelte `{@html ...}`, Vue
197/// `v-html`, and Angular `[innerHTML]`. Pre-121 entries omit those sink sites
198/// until the file is re-extracted.
199///
200/// Bumped to 122: `FunctionComplexity` now carries a `contributions` vector
201/// (per-decision-point complexity breakdown) and `RequireCallInfo` carries
202/// `source_span` (the specifier string-literal span so an `unresolved-import`
203/// squiggly anchors under the `'./x'` specifier rather than the `require`
204/// keyword). Pre-122 entries lack the breakdown (empty under
205/// `health --complexity-breakdown`) and carry `Span::default()` for the
206/// require specifier until the file is re-extracted.
207///
208/// Bumped to 123 for PR #1010: JSDoc import-type extraction now ignores prose
209/// examples, including examples that contain ordinary JavaScript brace groups.
210/// Pre-123 entries can carry stale type-only imports that surface as false
211/// `unresolved-imports` until the file is re-extracted.
212///
213/// Bumped to 124 for issue #877: static `import.meta.env.SECRET` reads now
214/// populate `member_accesses` as `import.meta.env` source reads for the
215/// opt-in client/server security candidate detector. Pre-124 entries omit the
216/// source and would miss Vite env reads until the file is re-extracted.
217///
218/// Bumped to 125 for issue #875: `SinkSite` now carries literal argument and
219/// object-literal option metadata, allowing security catalogue rows to match
220/// deterministic literal sinks such as wildcard postMessage origins,
221/// permissive CORS, insecure cookie options, weak crypto algorithms, and
222/// alg:none JWT options. Pre-125 entries lack that metadata until the file is
223/// re-extracted.
224///
225/// Bumped to 126 for issue #876: `SinkSite` now carries flattened source paths
226/// referenced inside sink arguments, so source-backed logging candidates can
227/// match direct expressions such as `process.env.SECRET` without requiring a
228/// temporary local binding. Pre-126 entries lack those paths until the file is
229/// re-extracted.
230///
231/// Bumped to 127 for issue #898: `SinkSite` now carries complete top-level
232/// object-key metadata so missing-option security rows can distinguish absent
233/// keys from non-literal option values. Pre-127 entries lack that metadata until
234/// the file is re-extracted.
235///
236/// Bumped to 128 for issue #895: JS/TS extraction now captures the exact
237/// `process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"` literal assignment as a
238/// security sink site. Pre-128 entries omit that sink until the file is
239/// re-extracted.
240///
241/// Bumped to 129 for issue #901: JS/TS extraction now captures cleartext
242/// request URL literals and `new WebSocket("ws://...")` as security sink sites.
243/// Pre-129 entries omit those sinks until the file is re-extracted.
244///
245/// Bumped to 130 for issue #892: JS/TS extraction now captures static string
246/// literals assigned to secret-shaped identifiers or known provider credential
247/// prefixes as opt-in hardcoded-secret candidates.
248/// Pre-130 entries omit those candidates until the file is re-extracted.
249///
250/// Bumped to 131 for issue #879: JS/TS extraction now records synthetic
251/// source bindings for recognizable framework handler parameters. Pre-131
252/// entries omit those bindings and cannot source-rank direct handler params.
253///
254/// Bumped to 132 for issue #878: JS/TS extraction now records one-hop
255/// same-module helper calls that return source-backed expressions as tainted
256/// bindings. Pre-132 entries miss the ranking signal until re-extracted.
257///
258/// Bumped to 133 for issue #901: `SinkSite` now carries integer literal
259/// values and nested static object property paths for additional literal-tier
260/// security rows. Pre-133 entries omit that metadata until the file is
261/// re-extracted.
262///
263/// Bumped to 134 for issue #928: JS/TS extraction now captures risky literal
264/// regex application sites in `security_sinks` so `fallow security` can report
265/// source-backed ReDoS candidates. Pre-134 entries omit those sink sites until
266/// the file is re-extracted.
267///
268/// Bumped to 135 for issue #929: JS/TS extraction now skips directly clamped
269/// resource-amplification size arguments before catalogue matching. Pre-135
270/// entries may retain stale clamped amplification sink candidates until the
271/// file is re-extracted.
272///
273/// Bumped to 136 for issue #899: JS/TS extraction now emits GraphQL resolver
274/// args, tRPC procedure input, and exact member source paths for local tainted
275/// bindings. Pre-136 entries may miss those source-backed ranking signals until
276/// the file is re-extracted.
277///
278/// Bumped to 137 for issue #888: JS/TS extraction now records defensive
279/// security control sites for the attack-surface inventory. Pre-137 entries
280/// omit those controls until the file is re-extracted.
281///
282/// Bumped to 138 for issue #890: `SinkSite` now carries the arg-0 URL literal
283/// (`url_arg_literal`) for the secret-to-network destination signal, `import.meta.env`
284/// reads are modeled as a source via the new `flatten_member_path` MetaProperty
285/// arm, and public-by-convention env vars (`NEXT_PUBLIC_`, `VITE_`, ...) are no
286/// longer recorded as secret sources. Pre-138 entries omit the URL signal and may
287/// retain stale public-env source bindings until the file is re-extracted.
288pub(super) const CACHE_VERSION: u32 = 138;
289
290/// Duplication token cache version. Bump when duplicate tokenization,
291/// normalization, or the on-disk token cache schema changes.
292pub const DUPES_CACHE_VERSION: u32 = 4;
293
294/// Default maximum cache size (256 MB). Overridable per-project via
295/// `cache.maxSizeMb` in the config file or `FALLOW_CACHE_MAX_SIZE` env var.
296/// Also used as the hard ceiling on load-time deserialization as a defence
297/// against pathological on-disk files.
298pub const DEFAULT_CACHE_MAX_SIZE: usize = 256 * 1024 * 1024;
299
300/// Trigger LRU eviction when the serialized cache exceeds 80% of the cap.
301/// Basis points (1/100 of a percent) for integer arithmetic without floats.
302pub(super) const EVICTION_TRIGGER_BPS: usize = 8000;
303
304/// Evict down to 60% of the cap so subsequent saves leave headroom.
305pub(super) const EVICTION_TARGET_BPS: usize = 6000;
306
307/// Promote the eviction log from `debug!` to `info!` when at least 25% of
308/// entries are removed in a single save. Default-noise concerns mean
309/// small-turnover saves should not be visible without `RUST_LOG=debug`.
310pub(super) const EVICTION_SIGNIFICANT_BPS: usize = 2500;
311
312/// Import kind discriminant for `CachedImport`:
313/// 0 = Named, 1 = Default, 2 = Namespace, 3 = `SideEffect`.
314pub(super) const IMPORT_KIND_NAMED: u8 = 0;
315pub(super) const IMPORT_KIND_DEFAULT: u8 = 1;
316pub(super) const IMPORT_KIND_NAMESPACE: u8 = 2;
317pub(super) const IMPORT_KIND_SIDE_EFFECT: u8 = 3;
318
319macro_rules! assert_cached_type_size {
320    ($ty:ty, $size:expr) => {
321        const _: () = assert!(
322            std::mem::size_of::<$ty>() == $size,
323            concat!(
324                stringify!($ty),
325                " size changed; bump CACHE_VERSION if the cached wire shape or extraction semantics changed, then update this assertion"
326            )
327        );
328    };
329}
330
331assert_cached_type_size!(CachedModule, 760);
332assert_cached_type_size!(CachedNamespaceObjectAlias, 72);
333assert_cached_type_size!(CachedLocalTypeDeclaration, 32);
334assert_cached_type_size!(CachedPublicSignatureTypeReference, 56);
335assert_cached_type_size!(CachedSuppression, 12);
336assert_cached_type_size!(CachedUnknownSuppressionKind, 32);
337assert_cached_type_size!(CachedExport, 112);
338assert_cached_type_size!(CachedImport, 96);
339assert_cached_type_size!(CachedDynamicImport, 88);
340assert_cached_type_size!(CachedRequireCall, 88);
341assert_cached_type_size!(CachedReExport, 88);
342assert_cached_type_size!(CachedMember, 64);
343assert_cached_type_size!(CachedDynamicImportPattern, 56);
344assert_cached_type_size!(crate::MemberAccess, 48);
345assert_cached_type_size!(fallow_types::extract::SinkSite, 208);
346assert_cached_type_size!(fallow_types::extract::FunctionComplexity, 96);
347assert_cached_type_size!(fallow_types::extract::ComplexityContribution, 16);
348assert_cached_type_size!(fallow_types::extract::FlagUse, 80);
349assert_cached_type_size!(fallow_types::extract::ClassHeritageInfo, 96);
350
351/// Cached data for a single module.
352#[derive(Debug, Clone, Encode, Decode)]
353pub struct CachedModule {
354    /// xxh3 hash of the file content.
355    pub content_hash: u64,
356    /// File modification time (seconds since epoch) for fast cache validation.
357    /// When mtime+size match the on-disk file, we skip reading file content entirely.
358    pub mtime_secs: u64,
359    /// File size in bytes for fast cache validation.
360    pub file_size: u64,
361    /// Seconds-since-epoch at the time this entry was last WRITTEN
362    /// (first parse or content-change refresh). NOT updated on cache-hit
363    /// reads: `update_cache` already iterates every in-scope file every run,
364    /// so refreshing on read would collapse the LRU to "last run this file
365    /// was discovered" for every retained entry. With write-only refresh,
366    /// the LRU genuinely targets stale (in-scope-but-unchanged-for-many-runs)
367    /// entries. Used by `CacheStore::save` for write-time eviction ordering.
368    pub last_access_secs: u64,
369    /// Exported symbols.
370    pub exports: Vec<CachedExport>,
371    /// Import specifiers.
372    pub imports: Vec<CachedImport>,
373    /// Re-export specifiers.
374    pub re_exports: Vec<CachedReExport>,
375    /// Dynamic import specifiers.
376    pub dynamic_imports: Vec<CachedDynamicImport>,
377    /// `require()` specifiers.
378    pub require_calls: Vec<CachedRequireCall>,
379    /// Package names statically referenced through package path resolution.
380    pub package_path_references: Vec<String>,
381    /// Static member accesses (e.g., `Status.Active`).
382    pub member_accesses: Vec<crate::MemberAccess>,
383    /// Identifiers used as whole objects (Object.values, for..in, spread, etc.).
384    pub whole_object_uses: Vec<String>,
385    /// Dynamic import patterns with partial static resolution.
386    pub dynamic_import_patterns: Vec<CachedDynamicImportPattern>,
387    /// Whether this module uses CJS exports.
388    pub has_cjs_exports: bool,
389    /// Whether this module declares at least one Angular `@Component({
390    /// templateUrl: ... })` decorator. Mirrors `ModuleInfo.has_angular_component_template_url`
391    /// so the CRAP-inherit walker's gate survives a warm-cache load.
392    pub has_angular_component_template_url: bool,
393    /// Local names of import bindings that are never referenced in this file.
394    pub unused_import_bindings: Vec<String>,
395    /// Local import bindings referenced from type positions.
396    pub type_referenced_import_bindings: Vec<String>,
397    /// Local import bindings referenced from value positions.
398    pub value_referenced_import_bindings: Vec<String>,
399    /// Inline suppression directives.
400    pub suppressions: Vec<CachedSuppression>,
401    /// Suppression tokens that did not parse to any known `IssueKind`. See #449.
402    pub unknown_suppression_kinds: Vec<CachedUnknownSuppressionKind>,
403    /// Pre-computed line-start byte offsets for O(log N) byte-to-line/col conversion.
404    pub line_offsets: Vec<u32>,
405    /// Per-function complexity metrics.
406    pub complexity: Vec<fallow_types::extract::FunctionComplexity>,
407    /// Feature flag use sites.
408    pub flag_uses: Vec<fallow_types::extract::FlagUse>,
409    /// Heritage metadata for exported classes.
410    pub class_heritage: Vec<fallow_types::extract::ClassHeritageInfo>,
411    /// Angular `InjectionToken<Interface>` `(token, interface)` pairs (#920).
412    pub injection_tokens: Vec<(String, String)>,
413    /// Local type-capable declarations.
414    pub local_type_declarations: Vec<CachedLocalTypeDeclaration>,
415    /// Type references from exported public signatures.
416    pub public_signature_type_references: Vec<CachedPublicSignatureTypeReference>,
417    /// Namespace-import aliases re-exported through an object literal
418    /// (`export const API = { foo }` where `foo` is `import * as foo from './bar'`).
419    pub namespace_object_aliases: Vec<CachedNamespaceObjectAlias>,
420    /// Iconify collection prefixes found in static icon props (issue #608).
421    pub iconify_prefixes: Vec<String>,
422    /// Nuxt UI icon class suffixes found in static script-side icon properties
423    /// (issue #955).
424    pub iconify_icon_names: Vec<String>,
425    /// Bare identifier names that are candidates for convention auto-import
426    /// resolution (issue #704). Content-local, so they round-trip through the
427    /// cache; resolution against the plugin table happens at graph-build time.
428    pub auto_import_candidates: Vec<String>,
429    /// File-level string directives (`"use client"`, `"use server"`). Content-local,
430    /// round-trips through the cache so the security `client-server-leak` detector
431    /// sees directives on warm-cache loads.
432    pub directives: Vec<String>,
433    /// Captured security sink sites (category-blind). Round-trips through the
434    /// cache so the catalogue-driven `tainted_sink` detector sees sinks on
435    /// warm-cache loads.
436    pub security_sinks: Vec<fallow_types::extract::SinkSite>,
437    /// Count of sink-shaped nodes whose callee could not be flattened to a
438    /// static path. Round-trips so the in-band blind-spot count is stable.
439    pub security_sinks_skipped: u32,
440    /// Local bindings tied to the member-access path they were sourced from.
441    /// Round-trips so the security `tainted_sink` source-to-sink association
442    /// sees source-tainted bindings on warm-cache loads.
443    pub tainted_bindings: Vec<fallow_types::extract::TaintedBinding>,
444    /// Direct sink arguments recognized as sanitizer calls.
445    pub sanitized_sink_args: Vec<fallow_types::extract::SanitizedSinkArg>,
446    /// Defensive control call sites for security surface output.
447    pub security_control_sites: Vec<fallow_types::extract::SecurityControlSite>,
448}
449
450/// Cached namespace-object alias.
451#[derive(Debug, Clone, Encode, Decode)]
452pub struct CachedNamespaceObjectAlias {
453    /// Canonical export name on this module.
454    pub via_export_name: String,
455    /// Dotted suffix of the property path relative to the export.
456    pub suffix: String,
457    /// Local name of the namespace import on this module.
458    pub namespace_local: String,
459}
460
461/// Cached local type declaration.
462#[derive(Debug, Clone, Encode, Decode)]
463pub struct CachedLocalTypeDeclaration {
464    /// Local declaration name.
465    pub name: String,
466    /// Byte offset of the declaration span start.
467    pub span_start: u32,
468    /// Byte offset of the declaration span end.
469    pub span_end: u32,
470}
471
472/// Cached public signature type reference.
473#[derive(Debug, Clone, Encode, Decode)]
474pub struct CachedPublicSignatureTypeReference {
475    /// Exported symbol whose signature contains the reference.
476    pub export_name: String,
477    /// Referenced type name.
478    pub type_name: String,
479    /// Byte offset of the reference span start.
480    pub span_start: u32,
481    /// Byte offset of the reference span end.
482    pub span_end: u32,
483}
484
485/// Cached suppression directive.
486#[derive(Debug, Clone, Encode, Decode)]
487pub struct CachedSuppression {
488    /// 1-based line this suppression applies to. 0 = file-wide.
489    pub line: u32,
490    /// 1-based line where the comment itself appears.
491    pub comment_line: u32,
492    /// 0 = suppress all, 1-20 = `IssueKind` discriminant.
493    pub kind: u8,
494}
495
496/// Cached unknown suppression kind token (see #449).
497#[derive(Debug, Clone, Encode, Decode)]
498pub struct CachedUnknownSuppressionKind {
499    /// 1-based line where the comment itself appears.
500    pub comment_line: u32,
501    /// True when the marker was `fallow-ignore-file`.
502    pub is_file_level: bool,
503    /// The verbatim token that did not parse.
504    pub token: String,
505}
506
507/// Cached export data for a single export declaration.
508#[derive(Debug, Clone, Encode, Decode)]
509pub struct CachedExport {
510    /// Export name (or "default" for default exports).
511    pub name: String,
512    /// Whether this is a default export.
513    pub is_default: bool,
514    /// Whether this is a type-only export.
515    pub is_type_only: bool,
516    /// Whether this export is registered through a runtime side effect at
517    /// module load time (Lit `@customElement` decorator or
518    /// `customElements.define` call). Persisted so warm-cache runs continue
519    /// to skip unused-export reporting for these classes.
520    pub is_side_effect_used: bool,
521    /// Visibility tag discriminant (0=None, 1=Public, 2=Internal, 3=Beta, 4=Alpha).
522    pub visibility: u8,
523    /// The local binding name, if different.
524    pub local_name: Option<String>,
525    /// Byte offset of the export span start.
526    pub span_start: u32,
527    /// Byte offset of the export span end.
528    pub span_end: u32,
529    /// Members of this export (for enums and classes).
530    pub members: Vec<CachedMember>,
531    /// The local name of the parent class from `extends` clause, if any.
532    pub super_class: Option<String>,
533}
534
535/// Cached import data for a single import declaration.
536#[derive(Debug, Clone, Encode, Decode)]
537pub struct CachedImport {
538    /// The import specifier.
539    pub source: String,
540    /// For Named imports, the imported symbol name. Empty for other kinds.
541    pub imported_name: String,
542    /// The local binding name.
543    pub local_name: String,
544    /// Whether this is a type-only import.
545    pub is_type_only: bool,
546    /// Whether this import originated from an SFC `<style>` block / `<style src>` (CSS context).
547    pub from_style: bool,
548    /// Import kind: 0=Named, 1=Default, 2=Namespace, 3=SideEffect.
549    pub kind: u8,
550    /// Byte offset of the import span start.
551    pub span_start: u32,
552    /// Byte offset of the import span end.
553    pub span_end: u32,
554    /// Byte offset of the source string literal span start.
555    pub source_span_start: u32,
556    /// Byte offset of the source string literal span end.
557    pub source_span_end: u32,
558}
559
560/// Cached dynamic import data.
561#[derive(Debug, Clone, Encode, Decode)]
562pub struct CachedDynamicImport {
563    /// The import specifier.
564    pub source: String,
565    /// Byte offset of the span start.
566    pub span_start: u32,
567    /// Byte offset of the span end.
568    pub span_end: u32,
569    /// Names destructured from the import result.
570    pub destructured_names: Vec<String>,
571    /// Local variable name for namespace imports.
572    pub local_name: Option<String>,
573    /// True when this dynamic import was synthesised by fallow (see
574    /// `DynamicImportInfo::is_speculative`).
575    pub is_speculative: bool,
576}
577
578/// Cached `require()` call data.
579#[derive(Debug, Clone, Encode, Decode)]
580pub struct CachedRequireCall {
581    /// The require specifier.
582    pub source: String,
583    /// Byte offset of the span start.
584    pub span_start: u32,
585    /// Byte offset of the span end.
586    pub span_end: u32,
587    /// Byte offset of the specifier string-literal span start.
588    pub source_span_start: u32,
589    /// Byte offset of the specifier string-literal span end.
590    pub source_span_end: u32,
591    /// Names destructured from the require result.
592    pub destructured_names: Vec<String>,
593    /// Local variable name for namespace requires.
594    pub local_name: Option<String>,
595}
596
597/// Cached re-export data.
598#[derive(Debug, Clone, Encode, Decode)]
599pub struct CachedReExport {
600    /// The module being re-exported from.
601    pub source: String,
602    /// Name imported from the source.
603    pub imported_name: String,
604    /// Name exported from this module.
605    pub exported_name: String,
606    /// Whether this is a type-only re-export.
607    pub is_type_only: bool,
608    /// Byte offset of the re-export span start (for line-number reporting).
609    pub span_start: u32,
610    /// Byte offset of the re-export span end.
611    pub span_end: u32,
612}
613
614/// Cached enum or class member data.
615#[derive(Debug, Clone, Encode, Decode)]
616pub struct CachedMember {
617    /// Member name.
618    pub name: String,
619    /// Member kind (enum, method, or property).
620    pub kind: MemberKind,
621    /// Byte offset of the span start.
622    pub span_start: u32,
623    /// Byte offset of the span end.
624    pub span_end: u32,
625    /// Whether this member has decorators.
626    pub has_decorator: bool,
627    /// Full dotted path of each decorator (e.g. `step`, `ns.foo`).
628    /// Empty for undecorated members and decorators with non-identifier
629    /// expressions.
630    pub decorator_names: Vec<String>,
631    /// True when this is a static method that returns a fresh instance of
632    /// the class: body returns `new this()` / `new <SameClassName>()`, or the
633    /// declared return type matches the class name. Treated as a factory.
634    /// See issues #346, #387.
635    pub is_instance_returning_static: bool,
636    /// True when this instance method's call result is an instance of the
637    /// same class (declared return type matches the class name, or body's
638    /// last statement is `return this`). Drives fluent-chain credit. See
639    /// issue #387.
640    pub is_self_returning: bool,
641}
642
643/// Cached dynamic import pattern data (template literals, `import.meta.glob`).
644#[derive(Debug, Clone, Encode, Decode)]
645pub struct CachedDynamicImportPattern {
646    /// Static prefix of the import path.
647    pub prefix: String,
648    /// Static suffix, if any.
649    pub suffix: Option<String>,
650    /// Byte offset of the span start.
651    pub span_start: u32,
652    /// Byte offset of the span end.
653    pub span_end: u32,
654}