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 116 for issue #1302: suppression comments and `@expected-unused`
173/// tags now carry optional human-authored reasons. Pre-116 entries lack those
174/// reasons, so `require-suppression-reason` would report false missing-reason
175/// findings until files are re-extracted.
176///
177/// Bumped to 117 for issue #955: Vue SFC script-side Nuxt UI icon strings now
178/// populate `iconify_icon_names`, allowing declared `@iconify-json/*`
179/// collections used through values like `icon: 'i-simple-icons-github'` to be
180/// credited. Pre-116 entries omit those names and can surface false
181/// `unused-dependency` findings until the file is re-extracted.
182///
183/// Bumped to 118 for issue #954: JS/TS extraction now records static
184/// `pino({ transport: { target: "pkg" } })` target packages as synthetic
185/// dynamic imports so runtime transport dependencies are credited. Pre-118
186/// entries can surface false `unused-dependency` findings until the file is
187/// re-extracted.
188///
189/// Bumped to 119 for issue #952: JS/TS extraction now records static package
190/// path resolution references so packages consumed via package-root and
191/// `pkg/package.json` lookups are credited as dependency usage. Pre-119
192/// entries omit those references and can surface false `unused-dependency`
193/// findings until the file is re-extracted.
194///
195/// Bumped to 120 for issue #953: instance methods annotated with TypeScript's
196/// `this` return type now count as self-returning for constructor-rooted
197/// fluent chains. Pre-120 entries can miss those self-returning flags and
198/// surface false `unused-class-member` findings until the file is re-extracted.
199///
200/// Bumped to 121 for issue #883: framework template HTML injection sinks now
201/// flow into `ModuleInfo.security_sinks` for Svelte `{@html ...}`, Vue
202/// `v-html`, and Angular `[innerHTML]`. Pre-121 entries omit those sink sites
203/// until the file is re-extracted.
204///
205/// Bumped to 122: `FunctionComplexity` now carries a `contributions` vector
206/// (per-decision-point complexity breakdown) and `RequireCallInfo` carries
207/// `source_span` (the specifier string-literal span so an `unresolved-import`
208/// squiggly anchors under the `'./x'` specifier rather than the `require`
209/// keyword). Pre-122 entries lack the breakdown (empty under
210/// `health --complexity-breakdown`) and carry `Span::default()` for the
211/// require specifier until the file is re-extracted.
212///
213/// Bumped to 123 for PR #1010: JSDoc import-type extraction now ignores prose
214/// examples, including examples that contain ordinary JavaScript brace groups.
215/// Pre-123 entries can carry stale type-only imports that surface as false
216/// `unresolved-imports` until the file is re-extracted.
217///
218/// Bumped to 124 for issue #877: static `import.meta.env.SECRET` reads now
219/// populate `member_accesses` as `import.meta.env` source reads for the
220/// opt-in client/server security candidate detector. Pre-124 entries omit the
221/// source and would miss Vite env reads until the file is re-extracted.
222///
223/// Bumped to 125 for issue #875: `SinkSite` now carries literal argument and
224/// object-literal option metadata, allowing security catalogue rows to match
225/// deterministic literal sinks such as wildcard postMessage origins,
226/// permissive CORS, insecure cookie options, weak crypto algorithms, and
227/// alg:none JWT options. Pre-125 entries lack that metadata until the file is
228/// re-extracted.
229///
230/// Bumped to 126 for issue #876: `SinkSite` now carries flattened source paths
231/// referenced inside sink arguments, so source-backed logging candidates can
232/// match direct expressions such as `process.env.SECRET` without requiring a
233/// temporary local binding. Pre-126 entries lack those paths until the file is
234/// re-extracted.
235///
236/// Bumped to 127 for issue #898: `SinkSite` now carries complete top-level
237/// object-key metadata so missing-option security rows can distinguish absent
238/// keys from non-literal option values. Pre-127 entries lack that metadata until
239/// the file is re-extracted.
240///
241/// Bumped to 128 for issue #895: JS/TS extraction now captures the exact
242/// `process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"` literal assignment as a
243/// security sink site. Pre-128 entries omit that sink until the file is
244/// re-extracted.
245///
246/// Bumped to 129 for issue #901: JS/TS extraction now captures cleartext
247/// request URL literals and `new WebSocket("ws://...")` as security sink sites.
248/// Pre-129 entries omit those sinks until the file is re-extracted.
249///
250/// Bumped to 130 for issue #892: JS/TS extraction now captures static string
251/// literals assigned to secret-shaped identifiers or known provider credential
252/// prefixes as opt-in hardcoded-secret candidates.
253/// Pre-130 entries omit those candidates until the file is re-extracted.
254///
255/// Bumped to 131 for issue #879: JS/TS extraction now records synthetic
256/// source bindings for recognizable framework handler parameters. Pre-131
257/// entries omit those bindings and cannot source-rank direct handler params.
258///
259/// Bumped to 132 for issue #878: JS/TS extraction now records one-hop
260/// same-module helper calls that return source-backed expressions as tainted
261/// bindings. Pre-132 entries miss the ranking signal until re-extracted.
262///
263/// Bumped to 133 for issue #901: `SinkSite` now carries integer literal
264/// values and nested static object property paths for additional literal-tier
265/// security rows. Pre-133 entries omit that metadata until the file is
266/// re-extracted.
267///
268/// Bumped to 134 for issue #928: JS/TS extraction now captures risky literal
269/// regex application sites in `security_sinks` so `fallow security` can report
270/// source-backed ReDoS candidates. Pre-134 entries omit those sink sites until
271/// the file is re-extracted.
272///
273/// Bumped to 135 for issue #929: JS/TS extraction now skips directly clamped
274/// resource-amplification size arguments before catalogue matching. Pre-135
275/// entries may retain stale clamped amplification sink candidates until the
276/// file is re-extracted.
277///
278/// Bumped to 136 for issue #899: JS/TS extraction now emits GraphQL resolver
279/// args, tRPC procedure input, and exact member source paths for local tainted
280/// bindings. Pre-136 entries may miss those source-backed ranking signals until
281/// the file is re-extracted.
282///
283/// Bumped to 137 for issue #888: JS/TS extraction now records defensive
284/// security control sites for the attack-surface inventory. Pre-137 entries
285/// omit those controls until the file is re-extracted.
286///
287/// Bumped to 138 for issue #890: `SinkSite` now carries the arg-0 URL literal
288/// (`url_arg_literal`) for the secret-to-network destination signal, `import.meta.env`
289/// reads are modeled as a source via the new `flatten_member_path` MetaProperty
290/// arm, and public-by-convention env vars (`NEXT_PUBLIC_`, `VITE_`, ...) are no
291/// longer recorded as secret sources. Pre-138 entries omit the URL signal and may
292/// retain stale public-env source bindings until the file is re-extracted.
293///
294/// Bumped to 139 for issue #1095: JS/TS extraction now records source-backed
295/// local bindings when template literals, string concatenation, or object
296/// literals embed an untrusted source. Pre-139 entries miss those ranking
297/// signals until the file is re-extracted.
298///
299/// Bumped to 140 for issue #1094: JS/TS extraction now records declarative
300/// framework validation boundary controls for security surface output. Pre-140
301/// entries can miss route-level validation control sites until re-extracted.
302///
303/// Bumped to 141 for issue #1093: `TaintedBinding` gains `source_span_start`
304/// (the byte offset of the source read) so the analyze layer can anchor a taint
305/// trace's source node at the real read line; pre-141 entries lack the offset.
306/// Bumped to 142 for issue #1134: JS/TS extraction now stores compact
307/// diagnostics for security sink-shaped callees that could not be flattened, so
308/// warm-cache `fallow security` runs can report the same blind-spot metadata as
309/// cold extraction.
310///
311/// Bumped to 143 for issue #1138: JS/TS extraction now propagates simple
312/// module-scope literal constants into security sink argument metadata and
313/// filters public CI metadata env vars before source matching.
314///
315/// Bumped to 144 for issue #1136: JS/TS sanitizer metadata now recognizes
316/// proven local HTML escape helpers, renderer helpers, and SQL identifier
317/// quoting helpers. Pre-144 entries can lack those sanitizer domains until the
318/// file is re-extracted.
319///
320/// Bumped to 145 for issue #1137: `SinkSite` now carries URL construction shape
321/// metadata for fixed-origin and dynamic-origin URL sink candidates.
322///
323/// Bumped to 146 for issue #1146: JS/TS extraction now chains tainted local
324/// bindings through up to three same-module hops, so warm caches written
325/// before the bump lack the chained `tainted_bindings` records.
326///
327/// Bumped to 147 for issue #1147: JS/TS extraction now captures deduped
328/// statically flattenable callee paths (`callee_uses`) for the
329/// `boundaries.calls.forbidden` detector, so warm caches written before the
330/// bump would report zero forbidden-call findings.
331///
332/// Bumped to 148 for issue #1190: JS/TS extraction now records nested
333/// Playwright fixture type-alias bindings in `member_accesses`, so warm caches
334/// written before the bump can miss fixture members reached through imported
335/// object type aliases.
336///
337/// Bumped to 149 for issue #1180: cached inline suppressions now preserve
338/// scoped rule-pack policy tokens (`policy-violation:<pack>/<rule-id>`).
339/// Pre-149 entries only store a broad `IssueKind` discriminant and cannot
340/// round-trip scoped policy suppressions.
341///
342/// Bumped to 150 for issue #1210: JS/TS extraction now records Playwright
343/// fixture wrapper aliases in `member_accesses`, so warm caches written before
344/// the bump can miss fixture members reached through `mergeTests` or chained
345/// wrapper `.extend(...)` calls.
346///
347/// Bumped to 151 for the server-only-import security candidate: JS/TS extraction
348/// now records `next/dynamic(..., { ssr: false })` dynamic-import spans on
349/// `client_only_dynamic_import_spans`, so warm caches written before the bump
350/// miss the ssr:false client-only escape hatch the `client-server-leak` BFS uses
351/// to exclude that edge.
352///
353/// Bumped to 152 for the `misplaced-directive` detector: JS/TS extraction now
354/// records `"use client"` / `"use server"` directive strings written as
355/// expression statements in `program.body` (misplaced) on
356/// `misplaced_directives`, so warm caches written before the bump would report
357/// zero misplaced-directive findings.
358///
359/// Bumped to 154 for the `unprovided-inject` detector: JS/TS and SFC extraction
360/// now record Vue `provide`/`inject` and Svelte `setContext`/`getContext` call
361/// sites on `di_key_sites` plus a `has_dynamic_provide` flag, so warm caches
362/// written before the bump would report zero unprovided-inject findings.
363///
364/// Bumped to 155 because `di_key_sites` now drops keys bound to a module-scope
365/// string-literal const (string identity, not a symbol), so a warm cache from
366/// 154 would carry those dropped sites and false-flag a string-keyed inject.
367///
368/// Bumped to 156 because SFC markup asset references (`<img src="./logo.png">`,
369/// `<source>`, `<video poster>`) now emit `SideEffect` imports, so a warm cache
370/// from 155 would miss the new `unresolved-import` findings on missing assets.
371///
372/// Bumped to 157 because the Vue `<template>` body extractor now matches the
373/// root `</template>` with nesting depth tracking instead of the first
374/// `</template>`. A Vue SFC whose root template contains a nested `<template
375/// #slot>` no longer has its body truncated, so component tags rendered after
376/// the first nested slot are now credited; a warm cache from 156 would carry the
377/// truncated template-usage set and false-flag those components / their imports.
378///
379/// Bumped to 158 for the `unused-component-prop` detector: Vue `<script setup>`
380/// extraction now records `defineProps` declared props on `component_props`
381/// (with `used_in_script` / `used_in_template`) plus the
382/// `has_props_attrs_fallthrough` / `has_define_expose` / `has_define_model` /
383/// `has_unharvestable_props` abstain flags, so a warm cache from 157 would
384/// report zero unused-component-prop findings.
385///
386/// Bumped to 159 because `ComponentProp` gained a `local` field (the destructure
387/// alias for a renamed prop), changing the cached wire shape; a warm 158 cache
388/// would bitcode-misread it.
389///
390/// Bumped to 160 for the `unused-component-emit` detector: Vue `<script setup>`
391/// extraction now records `defineEmits` declared events on `component_emits`
392/// (with `used`) plus the `has_unharvestable_emits` / `has_dynamic_emit` /
393/// `has_emit_whole_object_use` abstain flags, so a warm cache from 159 would
394/// report zero unused-component-emit findings.
395///
396/// Bumped to 162 for `unused-load-data-key` Primitive A: a destructure off the
397/// SvelteKit `data` prop local (`const { user } = data`) now emits `data.<key>`
398/// member accesses (rest element records a whole-object use). A warm cache from
399/// 161 lacks those accesses, so the cross-file load-data-key join would miss the
400/// consumed keys.
401///
402/// Bumped to 163 for `unused-load-data-key` Primitive B: a SvelteKit route
403/// component (`+page.svelte` / `+layout.svelte`) now credits the `data` prop as
404/// a template-visible root, so `{data.x}` / `{#each data.items as i}` markup
405/// reads emit `data.<key>` member accesses. A warm cache from 162 lacks those
406/// template-side accesses, so the cross-file load-data-key join would miss keys
407/// consumed only in markup.
408///
409/// Bumped to 164 for `unused-load-data-key` Primitive C: a SvelteKit global
410/// page-store read in a template (`{$page.data.KEY}` / `{page.data.KEY}`) now
411/// recovers the nested `page.data.<key>` member access (the template scanner
412/// previously dropped the key, keeping only `page.data`). A warm cache from 163
413/// lacks those project-wide global-store accesses.
414///
415/// Bumped (origin/main) for the `unused-load-data-key` detector: SvelteKit
416/// page-load producers now harvest `load_return_keys` + `has_unharvestable_load`,
417/// and every file records `has_load_data_whole_use` (the FP-1 whole-`data` pass
418/// signal). A warm cache from 164 lacks all three.
419///
420/// Bumped (origin/main) for the typed-`data` template fix: a SvelteKit route
421/// component whose `data` prop is typed (`export let data: PageData`) no longer
422/// remaps its template `data.<key>` accesses onto the generated `$types` alias,
423/// keeping them keyed on `data` for the load-data join. A warm cache carries the
424/// remapped (`PageData.<key>`) accesses and would miss real consumer reads.
425///
426/// Bumped (origin/main) for #550: CSS Module class extraction now derives its
427/// class set from a real CSS AST (lightningcss) for standard CSS, so warm caches
428/// written by the regex-only extractor can differ on escaped class names and
429/// malformed at-rule preludes.
430///
431/// Bumped (feat/react-health) for React/JSX structural extraction (Phase 0
432/// foundation): `.jsx`/`.tsx` files now record `component_functions`,
433/// `react_props`, `hook_uses`, and `render_edges`, so a warm cache lacks the
434/// React IR the later React-health phases consume.
435///
436/// Bumped (feat/react-health) for the React `unused-component-prop` arm
437/// (Phase 1): each `ComponentProp` gained a `component` field (the enclosing
438/// React component name) and `react_props[].used_in_script` is now populated
439/// from a used-in-body pass, so a warm cache carries props with an empty
440/// `component` and always-false usage.
441///
442/// Bumped (feat/react-health) for React-aware complexity (Phase 2):
443/// `FunctionComplexity` now carries `react_hook_count`, `react_jsx_max_depth`,
444/// and `react_prop_count` descriptive fields, and the cognitive metric folds
445/// deep JSX nesting, hook density, and prop count (recorded as `JsxDepth` /
446/// `HookDensity` / `PropCount` contributions). A warm cache carries the pre-fold
447/// cognitive scores and lacks the React descriptive counts until re-extraction.
448///
449/// Bumped (feat/react-health) for the prop-drilling forward signal (Phase 3):
450/// `RenderEdge` gained `attr_value_roots` / `has_complex_forward`,
451/// `ComponentFunction` gained `uses_clone_element` / `renders_provider` /
452/// `has_children_as_function`, and `ComponentProp` gained `used_outside_forward`.
453/// A warm cache lacks the per-render attribute-value roots and the
454/// per-component / per-prop forward classification the prop-drilling detector
455/// consumes.
456///
457/// Bumped to 170: `ComponentFunction` gained `is_pure_passthrough` (the
458/// thin-wrapper extraction flag), a new bitcode field on a cached struct
459/// persisted via `ModuleInfo`.
460///
461/// Bumped to 171 (feat/angular): Angular input/output IR
462/// (`angular_inputs` / `angular_outputs` on `ModuleInfo`) plus the
463/// `unused-component-input` / `unused-component-output` suppression tokens, and
464/// the Angular `{ ...this }` spread now records a whole-component abstain marker
465/// for the input/output detectors; a warm cache from 170 lacks the Angular IR
466/// and the abstain marker and would report zero input/output findings or
467/// false-flag spread-forwarded inputs/outputs.
468///
469/// Bumped to 172 (feat/vue-options-api-prop-emit): the Vue Options API
470/// (`export default { props, emits, ... }` / `defineComponent({ ... })`) in a
471/// non-setup `<script>` now harvests `component_props` / `component_emits` and
472/// the abstain flags the same way `<script setup>` does; a warm cache from 171
473/// lacks the Options-API prop/emit IR and would report zero findings on those
474/// components.
475///
476/// Bumped to 173 (feat/svelte-runes-extraction, W1.1): two `.svelte` extraction
477/// changes alter serialized module state. (1) Svelte 5's bare `<script module>`
478/// attribute is now recognized as module context (was treated as the instance
479/// script), so a warm cache wrongly scoped module-level declarations and credited the
480/// module script's imports as template-visible. (2) The Svelte 5 `$props()` rune
481/// is now harvested into `component_props` (reusing the Vue IR + abstain flags);
482/// a warm cache from 172 lacks the Svelte prop IR. (`<svelte:component>` /
483/// `<svelte:element>` / `<svelte:self>` were verified already credited by the
484/// existing attribute-value scan, so no template-scanner change rides this bump.)
485///
486/// Bumped to 174 (feat/svelte-dead-event): `.svelte` extraction now records
487/// `svelte_dispatched_events` (literal-arg `dispatch('<name>')` calls where
488/// `dispatch` is bound from `createEventDispatcher()`), `svelte_listened_events`
489/// (template `on:<name>` bindings on component tags), and `has_dynamic_dispatch`
490/// (a dynamic-dispatch / whole-`dispatch`-value abstain). A warm cache from 173
491/// lacks the dispatched/listened event IR and would report zero
492/// `unused-svelte-event` findings.
493///
494/// Bumped to 175 (feat/angular-unrendered-component, W4.2): Angular extraction
495/// now records `angular_component_selectors` (each `@Component({ selector })`
496/// value split into a list plus the class name + span), `angular_used_selectors`
497/// (custom element tags scanned from inline + external Angular templates), and
498/// `angular_entry_component_refs` (route `component:` / `loadComponent`,
499/// `bootstrapApplication` / `bootstrap: [...]` class references), and
500/// `has_dynamic_component_render` (a `ViewContainerRef.createComponent` /
501/// `*ngComponentOutlet` / `createComponent(<ident>)` project-wide abstain). A
502/// warm cache from 174 lacks the selector IR and would report zero Angular
503/// `unrendered-component` findings.
504///
505/// Bumped to 176 (feat/angular-unprovided-inject, W4.1): the `di_key_sites` set
506/// now carries Angular entries (`inject(TOKEN)` / `@Inject(TOKEN)` injects and
507/// `{ provide: TOKEN, ... }` provides via the new `DiFramework::Angular` variant),
508/// `has_dynamic_provide` is additionally set by `importProvidersFrom` /
509/// `makeEnvironmentProviders` / a `providers:` spread, and a tree-shakable
510/// `new InjectionToken(..., { factory } | { providedIn })` records a self-provide.
511/// A warm cache from 175 lacks the Angular DI sites and would report zero Angular
512/// `unprovided-inject` findings.
513///
514/// Bumped to 177 (feat/sfc-template-complexity): Vue and Svelte SFC
515/// `module.complexity` now carries a synthetic `<template>` `FunctionComplexity`
516/// entry computed from template control flow (`v-if`/`v-for`, `{#if}`/`{#each}`)
517/// plus bound-expression and interpolation complexity, mirroring Angular's
518/// existing `<template>` entry. The `FunctionComplexity` shape is unchanged (only
519/// an extra Vec element), so no size assertion changes. A warm cache from 176
520/// lacks the SFC `<template>` entry and would under-report SFC complexity until
521/// the file is re-parsed.
522///
523/// Bumped to 178 (feat/rsc-widen-inline-server-action): `ModuleInfo` now carries
524/// `inline_server_action_exports`, the export local names of exported functions /
525/// const-arrows whose body has an inline `"use server"` directive in a
526/// non-`"use server"` file. The `unused-server-action` reclassifier reads it to
527/// move a dead inline Server Action out of `unused-export`. A warm cache from 177
528/// lacks the field and would leave such dead inline actions categorized as
529/// `unused-export` until the file is re-parsed.
530///
531/// Bumped to 179 for issue #1270: Playwright fixture callbacks now record
532/// member uses reached through branch-selected local fixture aliases. Warm
533/// caches from 178 can miss those synthetic `member_accesses` and surface false
534/// `unused-class-member` findings.
535///
536/// Bumped to 180 for issue #1281: JSX nesting depth is now descriptive
537/// `react_jsx_max_depth` context only, so warm caches from 179 may carry stale
538/// cognitive scores and `JsxDepth` contribution entries for React components.
539///
540/// Bumped to 181 for issue #1282: Pinia `storeToRefs(useStore())` and
541/// `toRefs(useStore())` destructures now record store member accesses. Warm
542/// caches from 180 can miss those synthetic `member_accesses` and surface false
543/// `unused-store-member` findings.
544///
545/// Bumped (LLM-call sinks): the security sink argument collectors
546/// (`collect_arg_idents` / `collect_arg_source_paths`) now recurse into array
547/// elements (and the source-path collector into object properties), so taint
548/// riding an object-in-array argument (`messages: [{ content: userInput }]`, the
549/// canonical OpenAI / Anthropic chat shape) surfaces on `SinkSite.arg_idents` /
550/// `arg_source_paths`. Warm caches lack those captured identifiers and would
551/// miss source-backed candidates on the array-nested prompt shape.
552///
553/// Bumped for the Astro/Lit framework-health parity wave: Astro frontmatter now
554/// runs the `oxc_semantic` unused-binding pass (template-used names credited), so
555/// `.astro` modules carry populated `unused_import_bindings` /
556/// `value_referenced_import_bindings` instead of an empty (all-referenced) set;
557/// plus the Lit registered-tag / used-tag and Astro `<template>` complexity
558/// extraction fields. Warm caches mask the new `unused-export` /
559/// `unrendered-component` arms.
560///
561/// Bumped for the post-smoke-test FP fixes: standalone `.html` modules now
562/// populate `used_custom_element_tags` (a root `<my-app>` rendered only in
563/// `index.html` no longer false-flags), and imperative `createElement` capture
564/// widened to any receiver (`opts.document.createElement(...)`).
565///
566/// Bumped to 185 on merging the agentic-review branch into main: the LLM-call
567/// sink array recursion and the Astro/Lit parity wave land together, so warm
568/// caches from either side (183 or 184) must invalidate.
569///
570/// Bumped to 186 for the React typed-interface / `props.x` prop harvest: a
571/// component whose first param is a bare identifier typed by a same-file
572/// `interface`/`type` object literal (`(props: Props) => props.x`) now harvests
573/// the interface member names into `react_props` and credits `props.<name>`
574/// member-access usage, where warm caches from 185 recorded the component as
575/// `has_unharvestable_props` with no props.
576///
577/// Bumped to 187 for the React typed-prop harvest extension to
578/// `forwardRef<Ref, Props>((props, ref) => ...)`: the props type now resolves
579/// from the wrapper call's SECOND generic argument (a same-file
580/// `interface`/`type`) when the inner `props` param carries no annotation, so a
581/// generic-typed forwardRef component that warm caches from 186 recorded as
582/// `has_unharvestable_props` now harvests its `react_props` and credits
583/// `props.<name>` usage. The cached `ComponentProp` / `ComponentFunction` wire
584/// shape is unchanged; only which components populate it changes.
585///
586/// Bumped to 188: `HookUse` now carries the enclosing `component` name, so the
587/// descriptive per-component hook summary stays exact in multi-component files.
588/// A warm cache from 187 lacks the attribution field on persisted `hook_uses`.
589///
590/// Bumped to 189: `ModuleInfo`/`CachedModule` now carry typed semantic facts for
591/// Angular template member accesses alongside the older string payload entries.
592///
593/// Bumped to 190: `SemanticFact` now includes typed static-factory call member
594/// access facts alongside the older factory-call string payload entries.
595///
596/// Bumped to 191: `SemanticFact` now includes typed fluent-chain member access
597/// facts alongside the older fluent-chain string payload entries.
598///
599/// Bumped to 192: `SemanticFact` now includes typed Playwright fixture-use facts
600/// alongside the older fixture-use string payload entries.
601///
602/// Bumped to 193: `SemanticFact` now includes typed Playwright fixture definition
603/// facts alongside the older fixture-definition string payload entries.
604///
605/// Bumped to 194: `SemanticFact` now includes typed Playwright fixture alias
606/// facts alongside the older fixture-alias string payload entries.
607///
608/// Bumped to 195: `SemanticFact` now includes typed Playwright fixture type
609/// facts alongside the older fixture-type string payload entries.
610///
611/// Bumped to 196: `SemanticFact` now includes typed instance export binding
612/// facts alongside the older instance-export string payload entries.
613///
614/// Bumped to 197: factory-call member accesses are now persisted only as typed
615/// semantic facts; older cache payloads are reparsed by subsequent schema bumps.
616///
617/// Bumped to 198: fluent-chain member accesses are now persisted only as typed
618/// semantic facts; older cache payloads are reparsed by subsequent schema bumps.
619///
620/// Bumped to 199: constructor-rooted fluent-chain member accesses are now
621/// persisted only as typed semantic facts; older cache payloads are reparsed by
622/// subsequent schema bumps.
623///
624/// Bumped to 200: instance export bindings are now persisted only as typed
625/// semantic facts; older cache payloads are reparsed by subsequent schema bumps.
626///
627/// Bumped to 201: Playwright fixture-use member accesses are now persisted only
628/// as typed semantic facts; older cache payloads are reparsed by subsequent
629/// schema bumps.
630///
631/// Bumped to 202: Playwright fixture-definition member accesses are now
632/// persisted only as typed semantic facts; older cache payloads are reparsed by
633/// subsequent schema bumps.
634///
635/// Bumped to 203: Playwright fixture-alias member accesses are now persisted
636/// only as typed semantic facts; older cache payloads are reparsed by subsequent
637/// schema bumps.
638///
639/// Bumped to 204: Playwright fixture-type member accesses are now persisted
640/// only as typed semantic facts; older cache payloads are reparsed by subsequent
641/// schema bumps.
642///
643/// Bumped to 205: Angular template member accesses are now persisted only as
644/// typed semantic facts; older cache payloads are reparsed by subsequent schema
645/// bumps.
646///
647/// Bumped to 206: Angular `{ ...this }` spread abstains are now persisted as
648/// typed semantic facts; older cache payloads are reparsed by subsequent schema
649/// bumps.
650///
651/// Bumped to 207: dynamic custom-element render abstains are now persisted as
652/// typed semantic facts.
653///
654/// Bumped to 208: empty cached semantic facts are omitted from the persisted
655/// module payload. The in-memory `ModuleInfo` contract still exposes an empty
656/// vector, but warm caches from 207 carry the old eager `Vec` field shape.
657///
658/// Bumped to 209: pre-typed semantic payloads are no longer decoded from cached
659/// member accesses. Warm caches from 208 or earlier are reparsed so analyzers
660/// consume typed semantic facts only.
661///
662/// Bumped to 210 (issue #1489 Case 2): a param typed as a Pinia store
663/// (`ReturnType<typeof useFooStore>`, inline or aliased) now binds to the store
664/// factory, so `props.store.member` / `const { m } = props.store` emit factory
665/// `member_accesses` a 209 warm cache lacks.
666///
667/// Bumped to 211 (issue #1441, cross-module Part A): exported free-function
668/// factories now persist `exported_factory_returns`, and a consumer's
669/// `const x = importedFactory()` emits a typed `FactoryFnMemberAccess` semantic
670/// fact so `x.member` credits the returned class across module boundaries. A
671/// warm cache from 210 lacks both the new metadata and the added facts.
672///
673/// Bumped to 212 (issue #1489 Case 1): an inline `useFooStore().member` call
674/// with no bound local now emits a factory `member_access` so the member is
675/// credited; a 211 warm cache lacks it.
676///
677/// Bumped to 213 (issue #1641): Svelte template usage now credits
678/// `bind:`/`style:`/`class:` directive shorthands (`bind:open` =
679/// `bind:open={open}`) as references, so a prop used only via a shorthand
680/// directive sets `used_in_template`. A warm cache from 212 carries the stale
681/// (uncredited) prop-usage flags.
682///
683/// Bumped to 215 (issue #1638, GAP 2): a `new Class()` flowing DIRECTLY into a
684/// string-coercion position (template-literal interpolation, `String(...)`
685/// argument, or `+` with a string operand) now records a `Class.toString`
686/// member access, so an implicitly-coerced `toString` is credited instead of
687/// reported as an unused class member. A warm cache from 214 lacks the
688/// synthesized `toString` accesses.
689///
690/// Bumped to 216 (issue #1707): a Vue `v-for` loop variable iterating over a
691/// typed array / reactive array of a class (`v-for="(util) of utils"` where
692/// `utils` is `Util[]` / `computed(() => Util[])`) now types the item to its
693/// element class, so template member accesses on the item (`{{ util.getter }}`)
694/// credit the class. A warm cache from 215 carries the stale `.vue`
695/// `member_accesses` that lack the credited item-member accesses.
696///
697/// Bumped to 217 (issue #1707 follow-up): the same element-class inference now
698/// also types JS iteration bindings, `utils.map(u => u.getter)` / `.forEach` /
699/// `.filter` / etc. callback params and `for (const u of utils)` loop variables
700/// over a typed array / reactive array, so member accesses on the iteration
701/// variable credit the element class. A warm cache from 216 lacks the credited
702/// iteration-variable member accesses.
703///
704/// Bumped to 218 for issue #1711: a Vue `v-for` over a `props.<field>`
705/// member-expression source (where the prop is typed as an array of a class via
706/// `defineProps<{ items: Util[] }>()`) now types the loop item to the element
707/// class, so `.vue` `member_accesses` gain the credited item-member accesses a
708/// warm 217 cache lacks.
709///
710/// Bumped to 219 for issue #1712: an Angular `@for` / `*ngFor` loop variable
711/// over a component field typed as an array of a class (`utils: Util[]`) in an
712/// inline `template:` is typed to the element class, so inline-Angular-component
713/// `member_accesses` gain the remapped item-member accesses a warm 218 cache
714/// lacks.
715///
716/// Bumped to 220 for issue #1713: a `.map()` / `.forEach()` / `for...of`
717/// iteration binding in an Astro TEMPLATE `{...}` expression region (over a
718/// frontmatter-typed class array) now credits the element-class members, so
719/// `.astro` `member_accesses` gain the template-region item-member accesses a
720/// warm 219 cache lacks.
721///
722/// Bumped to 221 for issue #1744: a factory function whose body yields no value
723/// proof but whose explicit return-TYPE annotation names a class (`function
724/// useController(): ReadyAppController { return registry.get() as ... }`) now
725/// records a strict factory-return entry, so its `exported_factory_returns`
726/// output credits `const c = useController(); c.method()` across the module
727/// boundary; a warm 220 cache lacks that entry.
728///
729/// Bumped to 222 (#1742): conditional and logical dynamic `import()` arguments
730/// (`import(c ? './a' : './b')`, `import(x || './b')`) are now traced, emitting one
731/// `DynamicImportInfo` edge per statically-resolvable branch (plus the wrapper
732/// families: `.then`, `React.lazy`/`next/dynamic`, route `loadComponent`). A warm
733/// cache from 221 lacks the added per-branch dynamic-import entries.
734pub(super) const CACHE_VERSION: u32 = 222;
735
736/// Duplication token cache version. Bump when duplicate tokenization,
737/// normalization, or the on-disk token cache schema changes.
738///
739/// Bumped to 6 for issue #1225: `ignoreImports` now excludes re-export barrels
740/// and top-level static CommonJS require binding declarations.
741///
742/// Bumped to 7: duplicate tokenization now includes CSS-family files plus
743/// Vue, Svelte, and Astro template/style regions. Warm caches from 6 can carry
744/// empty CSS streams or script-only SFC/Astro streams.
745///
746/// Bumped to 8: duplicate token hashes now include the active source namespace
747/// (`js`, `style`, or `markup`) so structurally similar code from unrelated
748/// formats does not form cross-format clone groups.
749///
750/// Bumped to 9: CSS-family / SFC `<style>` tokens are now value-canonicalized
751/// (zero-unit collapse `0px`/`0em`/`0%` -> `0`, hex-color expansion `#fff` ->
752/// `#ffffff`) so near-miss / value-drifted CSS clones match. Warm v8 caches carry
753/// the un-canonicalized CSS token stream and must invalidate.
754pub const DUPES_CACHE_VERSION: u32 = 9;
755
756/// Default maximum cache size (256 MB). Overridable per-project via
757/// `cache.maxSizeMb` in the config file or `FALLOW_CACHE_MAX_SIZE` env var.
758/// Also used as the hard ceiling on load-time deserialization as a defence
759/// against pathological on-disk files.
760pub const DEFAULT_CACHE_MAX_SIZE: usize = 256 * 1024 * 1024;
761
762/// Trigger LRU eviction when the serialized cache exceeds 80% of the cap.
763/// Basis points (1/100 of a percent) for integer arithmetic without floats.
764pub(super) const EVICTION_TRIGGER_BPS: usize = 8000;
765
766/// Evict down to 60% of the cap so subsequent saves leave headroom.
767pub(super) const EVICTION_TARGET_BPS: usize = 6000;
768
769/// Promote the eviction log from `debug!` to `info!` when at least 25% of
770/// entries are removed in a single save. Default-noise concerns mean
771/// small-turnover saves should not be visible without `RUST_LOG=debug`.
772pub(super) const EVICTION_SIGNIFICANT_BPS: usize = 2500;
773
774/// Import kind discriminant for `CachedImport`:
775/// 0 = Named, 1 = Default, 2 = Namespace, 3 = `SideEffect`.
776pub(super) const IMPORT_KIND_NAMED: u8 = 0;
777pub(super) const IMPORT_KIND_DEFAULT: u8 = 1;
778pub(super) const IMPORT_KIND_NAMESPACE: u8 = 2;
779pub(super) const IMPORT_KIND_SIDE_EFFECT: u8 = 3;
780
781macro_rules! assert_cached_type_size {
782 ($ty:ty, $size:expr) => {
783 const _: () = assert!(
784 std::mem::size_of::<$ty>() == $size,
785 concat!(
786 stringify!($ty),
787 " size changed; bump CACHE_VERSION if the cached wire shape or extraction semantics changed, then update this assertion"
788 )
789 );
790 };
791}
792
793assert_cached_type_size!(CachedModule, 1320);
794assert_cached_type_size!(CachedNamespaceObjectAlias, 72);
795assert_cached_type_size!(CachedLocalTypeDeclaration, 32);
796assert_cached_type_size!(CachedPublicSignatureTypeReference, 56);
797assert_cached_type_size!(CachedSuppression, 88);
798assert_cached_type_size!(CachedUnknownSuppressionKind, 56);
799assert_cached_type_size!(CachedExport, 136);
800assert_cached_type_size!(CachedImport, 96);
801assert_cached_type_size!(CachedDynamicImport, 88);
802assert_cached_type_size!(CachedRequireCall, 88);
803assert_cached_type_size!(CachedReExport, 88);
804assert_cached_type_size!(CachedMember, 64);
805assert_cached_type_size!(CachedDynamicImportPattern, 56);
806assert_cached_type_size!(crate::MemberAccess, 48);
807assert_cached_type_size!(fallow_types::extract::SemanticFact, 96);
808assert_cached_type_size!(fallow_types::extract::CalleeUse, 32);
809assert_cached_type_size!(fallow_types::extract::MisplacedDirectiveSite, 8);
810assert_cached_type_size!(fallow_types::extract::SinkSite, 216);
811assert_cached_type_size!(fallow_types::extract::FunctionComplexity, 96);
812assert_cached_type_size!(fallow_types::extract::ComplexityContribution, 16);
813assert_cached_type_size!(fallow_types::extract::FlagUse, 80);
814assert_cached_type_size!(fallow_types::extract::ClassHeritageInfo, 96);
815assert_cached_type_size!(fallow_types::extract::FactoryReturnExport, 48);
816assert_cached_type_size!(fallow_types::extract::LoadReturnKey, 32);
817
818/// Cached data for a single module.
819#[derive(Debug, Clone, Encode, Decode)]
820pub struct CachedModule {
821 /// xxh3 hash of the file content.
822 pub content_hash: u64,
823 /// File modification time in nanoseconds for fast cache validation.
824 /// When mtime+size match the on-disk file, we skip reading file content entirely.
825 pub mtime_ns: u64,
826 /// File size in bytes for fast cache validation.
827 pub file_size: u64,
828 /// Seconds-since-epoch at the time this entry was last WRITTEN
829 /// (first parse or content-change refresh). NOT updated on cache-hit
830 /// reads: `update_cache` already iterates every in-scope file every run,
831 /// so refreshing on read would collapse the LRU to "last run this file
832 /// was discovered" for every retained entry. With write-only refresh,
833 /// the LRU genuinely targets stale (in-scope-but-unchanged-for-many-runs)
834 /// entries. Used by `CacheStore::save` for write-time eviction ordering.
835 pub last_access_secs: u64,
836 /// Exported symbols.
837 pub exports: Vec<CachedExport>,
838 /// Import specifiers.
839 pub imports: Vec<CachedImport>,
840 /// Re-export specifiers.
841 pub re_exports: Vec<CachedReExport>,
842 /// Dynamic import specifiers.
843 pub dynamic_imports: Vec<CachedDynamicImport>,
844 /// `require()` specifiers.
845 pub require_calls: Vec<CachedRequireCall>,
846 /// Package names statically referenced through package path resolution.
847 pub package_path_references: Box<[String]>,
848 /// Static member accesses (e.g., `Status.Active`).
849 pub member_accesses: Vec<crate::MemberAccess>,
850 /// Typed semantic facts produced by extraction for cross-layer analysis.
851 /// `None` means no facts, which keeps the common warm-cache payload lean.
852 pub semantic_facts: Option<Box<[fallow_types::extract::SemanticFact]>>,
853 /// Identifiers used as whole objects (Object.values, for..in, spread, etc.).
854 pub whole_object_uses: Box<[String]>,
855 /// Dynamic import patterns with partial static resolution.
856 pub dynamic_import_patterns: Vec<CachedDynamicImportPattern>,
857 /// Whether this module uses CJS exports.
858 pub has_cjs_exports: bool,
859 /// Whether this module declares at least one Angular `@Component({
860 /// templateUrl: ... })` decorator. Mirrors `ModuleInfo.has_angular_component_template_url`
861 /// so the CRAP-inherit walker's gate survives a warm-cache load.
862 pub has_angular_component_template_url: bool,
863 /// Local names of import bindings that are never referenced in this file.
864 pub unused_import_bindings: Vec<String>,
865 /// Local import bindings referenced from type positions.
866 pub type_referenced_import_bindings: Vec<String>,
867 /// Local import bindings referenced from value positions.
868 pub value_referenced_import_bindings: Vec<String>,
869 /// Inline suppression directives.
870 pub suppressions: Vec<CachedSuppression>,
871 /// Suppression tokens that did not parse to any known `IssueKind`. See #449.
872 pub unknown_suppression_kinds: Vec<CachedUnknownSuppressionKind>,
873 /// Pre-computed line-start byte offsets for O(log N) byte-to-line/col conversion.
874 pub line_offsets: Vec<u32>,
875 /// Per-function complexity metrics.
876 pub complexity: Vec<fallow_types::extract::FunctionComplexity>,
877 /// Feature flag use sites.
878 pub flag_uses: Vec<fallow_types::extract::FlagUse>,
879 /// Heritage metadata for exported classes.
880 pub class_heritage: Vec<fallow_types::extract::ClassHeritageInfo>,
881 /// Exported free-function factories that provably return one class instance
882 /// (`export function useApi() { return new RESTApi() }`). Compacted to `None`
883 /// when empty so the common no-factory module pays no payload. See #1441 Part A.
884 pub exported_factory_returns: Option<Box<[fallow_types::extract::FactoryReturnExport]>>,
885 /// Angular `InjectionToken<Interface>` `(token, interface)` pairs (#920).
886 pub injection_tokens: Vec<(String, String)>,
887 /// Local type-capable declarations.
888 pub local_type_declarations: Vec<CachedLocalTypeDeclaration>,
889 /// Type references from exported public signatures.
890 pub public_signature_type_references: Vec<CachedPublicSignatureTypeReference>,
891 /// Namespace-import aliases re-exported through an object literal
892 /// (`export const API = { foo }` where `foo` is `import * as foo from './bar'`).
893 pub namespace_object_aliases: Vec<CachedNamespaceObjectAlias>,
894 /// Iconify collection prefixes found in static icon props (issue #608).
895 pub iconify_prefixes: Vec<String>,
896 /// Nuxt UI icon class suffixes found in static script-side icon properties
897 /// (issue #955).
898 pub iconify_icon_names: Vec<String>,
899 /// Bare identifier names that are candidates for convention auto-import
900 /// resolution (issue #704). Content-local, so they round-trip through the
901 /// cache; resolution against the plugin table happens at graph-build time.
902 pub auto_import_candidates: Vec<String>,
903 /// File-level string directives (`"use client"`, `"use server"`). Content-local,
904 /// round-trips through the cache so the security `client-server-leak` detector
905 /// sees directives on warm-cache loads.
906 pub directives: Vec<String>,
907 /// Byte-offset starts of `next/dynamic(..., { ssr: false })` dynamic imports.
908 /// Content-local, round-trips so the security `client-server-leak` BFS sees
909 /// the ssr:false client-only escape hatch on warm-cache loads.
910 pub client_only_dynamic_import_spans: Vec<u32>,
911 /// Captured security sink sites (category-blind). Round-trips through the
912 /// cache so the catalogue-driven `tainted_sink` detector sees sinks on
913 /// warm-cache loads.
914 pub security_sinks: Vec<fallow_types::extract::SinkSite>,
915 /// Count of sink-shaped nodes whose callee could not be flattened to a
916 /// static path. Round-trips so the in-band blind-spot count is stable.
917 pub security_sinks_skipped: u32,
918 /// Span-level diagnostics for skipped security sink callees.
919 pub security_unresolved_callee_sites: Vec<fallow_types::extract::SkippedSecurityCalleeSite>,
920 /// Local bindings tied to the member-access path they were sourced from.
921 /// Round-trips so the security `tainted_sink` source-to-sink association
922 /// sees source-tainted bindings on warm-cache loads.
923 pub tainted_bindings: Vec<fallow_types::extract::TaintedBinding>,
924 /// Direct sink arguments recognized as sanitizer calls.
925 pub sanitized_sink_args: Vec<fallow_types::extract::SanitizedSinkArg>,
926 /// Defensive control call sites for security surface output.
927 pub security_control_sites: Vec<fallow_types::extract::SecurityControlSite>,
928 /// Deduped statically flattenable callee paths. Round-trips so the
929 /// `boundaries.calls.forbidden` detector sees call sites on warm-cache
930 /// loads.
931 pub callee_uses: Vec<fallow_types::extract::CalleeUse>,
932 /// Misplaced `"use client"` / `"use server"` directive sites.
933 /// Round-trips so the `misplaced-directive` detector sees them on
934 /// warm-cache loads.
935 pub misplaced_directives: Vec<fallow_types::extract::MisplacedDirectiveSite>,
936 /// Export local names of inline `"use server"` body Server Actions.
937 /// Round-trips so the `unused-server-action` reclassifier sees them on
938 /// warm-cache loads.
939 pub inline_server_action_exports: Vec<String>,
940 /// Vue `provide`/`inject` and Svelte `setContext`/`getContext` key sites.
941 /// Round-trips so the `unprovided-inject` detector sees them on warm-cache
942 /// loads.
943 pub di_key_sites: Vec<fallow_types::extract::DiKeySite>,
944 /// Whether the module had an unknowable-key provide. Round-trips so the
945 /// `unprovided-inject` project-wide abstain holds on warm-cache loads.
946 pub has_dynamic_provide: bool,
947 /// Vue `<script setup>` `defineProps` and Svelte 5 `$props()` declared props.
948 /// Round-trips so the `unused-component-prop` detector sees them on
949 /// warm-cache loads.
950 pub component_props: Vec<fallow_types::extract::ComponentProp>,
951 /// Whether the template spreads `$attrs`/`$props`/`props` or the
952 /// `defineProps` return is rest-destructured. Round-trips for the abstain.
953 pub has_props_attrs_fallthrough: bool,
954 /// Whether the SFC calls `defineExpose(...)`. Round-trips for the abstain.
955 pub has_define_expose: bool,
956 /// Whether the SFC calls `defineModel(...)`. Round-trips for the abstain.
957 pub has_define_model: bool,
958 /// Whether `defineProps` had an unharvestable type-reference argument.
959 /// Round-trips for the abstain.
960 pub has_unharvestable_props: bool,
961 /// Vue `<script setup>` `defineEmits` declared events. Round-trips so the
962 /// `unused-component-emit` detector sees them on warm-cache loads.
963 pub component_emits: Vec<fallow_types::extract::ComponentEmit>,
964 /// Angular component/directive inputs (`@Input()` decorators and signal
965 /// `input()` / `model()` initializers). Round-trips so the
966 /// `unused-component-input` detector sees them on warm-cache loads.
967 pub angular_inputs: Vec<fallow_types::extract::AngularInputMember>,
968 /// Angular component/directive outputs (`@Output()` decorators and signal
969 /// `output()` / `outputFromObservable()` initializers). Round-trips so the
970 /// `unused-component-output` detector sees them on warm-cache loads.
971 pub angular_outputs: Vec<fallow_types::extract::AngularOutputMember>,
972 /// Angular `@Component` declarations with their `selector` value(s).
973 /// Round-trips so the Angular `unrendered-component` arm sees them on
974 /// warm-cache loads.
975 pub angular_component_selectors: Vec<fallow_types::extract::AngularComponentSelector>,
976 /// Lit / web-component custom elements registered in this file. Round-trips so
977 /// the Lit `unrendered-component` arm sees them on warm-cache loads.
978 pub registered_custom_elements: Vec<fallow_types::extract::RegisteredCustomElement>,
979 /// Custom-element tag names used (rendered) in this file's `html` templates.
980 /// Round-trips for the Lit `unrendered-component` rendered-tag union.
981 pub used_custom_element_tags: Vec<String>,
982 /// Custom element selector tags referenced in this file's Angular templates.
983 /// Round-trips for the Angular `unrendered-component` used-selector union.
984 pub angular_used_selectors: Vec<String>,
985 /// Angular route / bootstrap component class references. Round-trips for the
986 /// Angular `unrendered-component` entry-point abstain.
987 pub angular_entry_component_refs: Vec<String>,
988 /// Whether this file dynamically renders a component (project-wide abstain
989 /// signal for the Angular `unrendered-component` detector). Round-trips.
990 pub has_dynamic_component_render: bool,
991 /// Whether `defineEmits` had an unharvestable argument. Round-trips for the
992 /// abstain.
993 pub has_unharvestable_emits: bool,
994 /// Whether an `emit(<nonLiteral>)` call was seen. Round-trips for the abstain.
995 pub has_dynamic_emit: bool,
996 /// Whether the emit binding was used as a whole value. Round-trips for the
997 /// abstain.
998 pub has_emit_whole_object_use: bool,
999 /// SvelteKit `load()` return-object keys. Round-trips so the
1000 /// `unused-load-data-key` detector sees them on warm-cache loads.
1001 pub load_return_keys: Vec<fallow_types::extract::LoadReturnKey>,
1002 /// Whether this file's `load()` body could not be harvested safely.
1003 /// Round-trips for the abstain.
1004 pub has_unharvestable_load: bool,
1005 /// Whether this file passes the whole `data` object opaquely. Round-trips
1006 /// for the `unused-load-data-key` abstain.
1007 pub has_load_data_whole_use: bool,
1008 /// React/JSX component definitions. Round-trips so the React-health phases
1009 /// see them on warm-cache loads.
1010 pub component_functions: Vec<fallow_types::extract::ComponentFunction>,
1011 /// React component props. Round-trips so the React `unused-component-prop`
1012 /// arm sees them on warm-cache loads.
1013 pub react_props: Vec<fallow_types::extract::ComponentProp>,
1014 /// React hook call sites. Round-trips for the complexity-fold phase.
1015 pub hook_uses: Vec<fallow_types::extract::HookUse>,
1016 /// React render edges (child name captured; resolution deferred to graph
1017 /// build). Round-trips so the render graph survives a warm cache.
1018 pub render_edges: Vec<fallow_types::extract::RenderEdge>,
1019 /// Svelte custom events dispatched via `dispatch('<name>')`. Round-trips so
1020 /// the `unused-svelte-event` detector sees them on warm-cache loads.
1021 pub svelte_dispatched_events: Vec<fallow_types::extract::DispatchedEvent>,
1022 /// Svelte template `on:<name>` listener names on component tags. Round-trips
1023 /// so the project-wide listened set is correct on warm-cache loads.
1024 pub svelte_listened_events: Vec<String>,
1025 /// Whether a `dispatch(<nonLiteral>)` call or whole-`dispatch`-value use was
1026 /// seen. Round-trips for the `unused-svelte-event` abstain.
1027 pub has_dynamic_dispatch: bool,
1028}
1029
1030impl CachedModule {
1031 /// Source metadata fingerprint stored with this cache entry.
1032 ///
1033 #[must_use]
1034 pub fn source_fingerprint(&self) -> fallow_types::source_fingerprint::SourceFingerprint {
1035 fallow_types::source_fingerprint::SourceFingerprint::new(self.mtime_ns, self.file_size)
1036 }
1037}
1038
1039/// Cached namespace-object alias.
1040#[derive(Debug, Clone, Encode, Decode)]
1041pub struct CachedNamespaceObjectAlias {
1042 /// Canonical export name on this module.
1043 pub via_export_name: String,
1044 /// Dotted suffix of the property path relative to the export.
1045 pub suffix: String,
1046 /// Local name of the namespace import on this module.
1047 pub namespace_local: String,
1048}
1049
1050/// Cached local type declaration.
1051#[derive(Debug, Clone, Encode, Decode)]
1052pub struct CachedLocalTypeDeclaration {
1053 /// Local declaration name.
1054 pub name: String,
1055 /// Byte offset of the declaration span start.
1056 pub span_start: u32,
1057 /// Byte offset of the declaration span end.
1058 pub span_end: u32,
1059}
1060
1061/// Cached public signature type reference.
1062#[derive(Debug, Clone, Encode, Decode)]
1063pub struct CachedPublicSignatureTypeReference {
1064 /// Exported symbol whose signature contains the reference.
1065 pub export_name: String,
1066 /// Referenced type name.
1067 pub type_name: String,
1068 /// Byte offset of the reference span start.
1069 pub span_start: u32,
1070 /// Byte offset of the reference span end.
1071 pub span_end: u32,
1072}
1073
1074/// Cached suppression directive.
1075#[derive(Debug, Clone, Encode, Decode)]
1076pub struct CachedSuppression {
1077 /// 1-based line this suppression applies to. 0 = file-wide.
1078 pub line: u32,
1079 /// 1-based line where the comment itself appears.
1080 pub comment_line: u32,
1081 /// 0 = suppress all, otherwise `IssueKind` discriminant.
1082 pub kind: u8,
1083 /// Rule-pack name for scoped policy suppressions. Empty for all other
1084 /// suppression targets.
1085 pub policy_pack: String,
1086 /// Rule id for scoped policy suppressions. Empty for all other suppression
1087 /// targets.
1088 pub policy_rule_id: String,
1089 /// Human-authored reason after `--`, when present.
1090 pub reason: Option<String>,
1091}
1092
1093/// Cached unknown suppression kind token (see #449).
1094#[derive(Debug, Clone, Encode, Decode)]
1095pub struct CachedUnknownSuppressionKind {
1096 /// 1-based line where the comment itself appears.
1097 pub comment_line: u32,
1098 /// True when the marker was `fallow-ignore-file`.
1099 pub is_file_level: bool,
1100 /// The verbatim token that did not parse.
1101 pub token: String,
1102 /// Human-authored reason after `--`, when present.
1103 pub reason: Option<String>,
1104}
1105
1106/// Cached export data for a single export declaration.
1107#[derive(Debug, Clone, Encode, Decode)]
1108pub struct CachedExport {
1109 /// Export name (or "default" for default exports).
1110 pub name: String,
1111 /// Whether this is a default export.
1112 pub is_default: bool,
1113 /// Whether this is a type-only export.
1114 pub is_type_only: bool,
1115 /// Whether this export is registered through a runtime side effect at
1116 /// module load time (Lit `@customElement` decorator or
1117 /// `customElements.define` call). Persisted so warm-cache runs continue
1118 /// to skip unused-export reporting for these classes.
1119 pub is_side_effect_used: bool,
1120 /// Visibility tag discriminant (0=None, 1=Public, 2=Internal, 3=Beta, 4=Alpha).
1121 pub visibility: u8,
1122 /// Human-authored reason on `@expected-unused -- <reason>`, when present.
1123 pub expected_unused_reason: Option<String>,
1124 /// The local binding name, if different.
1125 pub local_name: Option<String>,
1126 /// Byte offset of the export span start.
1127 pub span_start: u32,
1128 /// Byte offset of the export span end.
1129 pub span_end: u32,
1130 /// Members of this export (for enums and classes).
1131 pub members: Vec<CachedMember>,
1132 /// The local name of the parent class from `extends` clause, if any.
1133 pub super_class: Option<String>,
1134}
1135
1136/// Cached import data for a single import declaration.
1137#[derive(Debug, Clone, Encode, Decode)]
1138pub struct CachedImport {
1139 /// The import specifier.
1140 pub source: String,
1141 /// For Named imports, the imported symbol name. Empty for other kinds.
1142 pub imported_name: String,
1143 /// The local binding name.
1144 pub local_name: String,
1145 /// Whether this is a type-only import.
1146 pub is_type_only: bool,
1147 /// Whether this import originated from an SFC `<style>` block / `<style src>` (CSS context).
1148 pub from_style: bool,
1149 /// Import kind: 0=Named, 1=Default, 2=Namespace, 3=SideEffect.
1150 pub kind: u8,
1151 /// Byte offset of the import span start.
1152 pub span_start: u32,
1153 /// Byte offset of the import span end.
1154 pub span_end: u32,
1155 /// Byte offset of the source string literal span start.
1156 pub source_span_start: u32,
1157 /// Byte offset of the source string literal span end.
1158 pub source_span_end: u32,
1159}
1160
1161/// Cached dynamic import data.
1162#[derive(Debug, Clone, Encode, Decode)]
1163pub struct CachedDynamicImport {
1164 /// The import specifier.
1165 pub source: String,
1166 /// Byte offset of the span start.
1167 pub span_start: u32,
1168 /// Byte offset of the span end.
1169 pub span_end: u32,
1170 /// Names destructured from the import result.
1171 pub destructured_names: Vec<String>,
1172 /// Local variable name for namespace imports.
1173 pub local_name: Option<String>,
1174 /// True when this dynamic import was synthesised by fallow (see
1175 /// `DynamicImportInfo::is_speculative`).
1176 pub is_speculative: bool,
1177}
1178
1179/// Cached `require()` call data.
1180#[derive(Debug, Clone, Encode, Decode)]
1181pub struct CachedRequireCall {
1182 /// The require specifier.
1183 pub source: String,
1184 /// Byte offset of the span start.
1185 pub span_start: u32,
1186 /// Byte offset of the span end.
1187 pub span_end: u32,
1188 /// Byte offset of the specifier string-literal span start.
1189 pub source_span_start: u32,
1190 /// Byte offset of the specifier string-literal span end.
1191 pub source_span_end: u32,
1192 /// Names destructured from the require result.
1193 pub destructured_names: Vec<String>,
1194 /// Local variable name for namespace requires.
1195 pub local_name: Option<String>,
1196}
1197
1198/// Cached re-export data.
1199#[derive(Debug, Clone, Encode, Decode)]
1200pub struct CachedReExport {
1201 /// The module being re-exported from.
1202 pub source: String,
1203 /// Name imported from the source.
1204 pub imported_name: String,
1205 /// Name exported from this module.
1206 pub exported_name: String,
1207 /// Whether this is a type-only re-export.
1208 pub is_type_only: bool,
1209 /// Byte offset of the re-export span start (for line-number reporting).
1210 pub span_start: u32,
1211 /// Byte offset of the re-export span end.
1212 pub span_end: u32,
1213}
1214
1215/// Cached enum or class member data.
1216#[derive(Debug, Clone, Encode, Decode)]
1217pub struct CachedMember {
1218 /// Member name.
1219 pub name: String,
1220 /// Member kind (enum, method, or property).
1221 pub kind: MemberKind,
1222 /// Byte offset of the span start.
1223 pub span_start: u32,
1224 /// Byte offset of the span end.
1225 pub span_end: u32,
1226 /// Whether this member has decorators.
1227 pub has_decorator: bool,
1228 /// Full dotted path of each decorator (e.g. `step`, `ns.foo`).
1229 /// Empty for undecorated members and decorators with non-identifier
1230 /// expressions.
1231 pub decorator_names: Vec<String>,
1232 /// True when this is a static method that returns a fresh instance of
1233 /// the class: body returns `new this()` / `new <SameClassName>()`, or the
1234 /// declared return type matches the class name. Treated as a factory.
1235 /// See issues #346, #387.
1236 pub is_instance_returning_static: bool,
1237 /// True when this instance method's call result is an instance of the
1238 /// same class (declared return type matches the class name, or body's
1239 /// last statement is `return this`). Drives fluent-chain credit. See
1240 /// issue #387.
1241 pub is_self_returning: bool,
1242}
1243
1244/// Cached dynamic import pattern data (template literals, `import.meta.glob`).
1245#[derive(Debug, Clone, Encode, Decode)]
1246pub struct CachedDynamicImportPattern {
1247 /// Static prefix of the import path.
1248 pub prefix: String,
1249 /// Static suffix, if any.
1250 pub suffix: Option<String>,
1251 /// Byte offset of the span start.
1252 pub span_start: u32,
1253 /// Byte offset of the span end.
1254 pub span_end: u32,
1255}