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.
288///
289/// Bumped to 139 for issue #1095: JS/TS extraction now records source-backed
290/// local bindings when template literals, string concatenation, or object
291/// literals embed an untrusted source. Pre-139 entries miss those ranking
292/// signals until the file is re-extracted.
293///
294/// Bumped to 140 for issue #1094: JS/TS extraction now records declarative
295/// framework validation boundary controls for security surface output. Pre-140
296/// entries can miss route-level validation control sites until re-extracted.
297///
298/// Bumped to 141 for issue #1093: `TaintedBinding` gains `source_span_start`
299/// (the byte offset of the source read) so the analyze layer can anchor a taint
300/// trace's source node at the real read line; pre-141 entries lack the offset.
301/// Bumped to 142 for issue #1134: JS/TS extraction now stores compact
302/// diagnostics for security sink-shaped callees that could not be flattened, so
303/// warm-cache `fallow security` runs can report the same blind-spot metadata as
304/// cold extraction.
305///
306/// Bumped to 143 for issue #1138: JS/TS extraction now propagates simple
307/// module-scope literal constants into security sink argument metadata and
308/// filters public CI metadata env vars before source matching.
309///
310/// Bumped to 144 for issue #1136: JS/TS sanitizer metadata now recognizes
311/// proven local HTML escape helpers, renderer helpers, and SQL identifier
312/// quoting helpers. Pre-144 entries can lack those sanitizer domains until the
313/// file is re-extracted.
314///
315/// Bumped to 145 for issue #1137: `SinkSite` now carries URL construction shape
316/// metadata for fixed-origin and dynamic-origin URL sink candidates.
317///
318/// Bumped to 146 for issue #1146: JS/TS extraction now chains tainted local
319/// bindings through up to three same-module hops, so warm caches written
320/// before the bump lack the chained `tainted_bindings` records.
321///
322/// Bumped to 147 for issue #1147: JS/TS extraction now captures deduped
323/// statically flattenable callee paths (`callee_uses`) for the
324/// `boundaries.calls.forbidden` detector, so warm caches written before the
325/// bump would report zero forbidden-call findings.
326///
327/// Bumped to 148 for issue #1190: JS/TS extraction now records nested
328/// Playwright fixture type-alias bindings in `member_accesses`, so warm caches
329/// written before the bump can miss fixture members reached through imported
330/// object type aliases.
331///
332/// Bumped to 149 for issue #1180: cached inline suppressions now preserve
333/// scoped rule-pack policy tokens (`policy-violation:<pack>/<rule-id>`).
334/// Pre-149 entries only store a broad `IssueKind` discriminant and cannot
335/// round-trip scoped policy suppressions.
336///
337/// Bumped to 150 for issue #1210: JS/TS extraction now records Playwright
338/// fixture wrapper aliases in `member_accesses`, so warm caches written before
339/// the bump can miss fixture members reached through `mergeTests` or chained
340/// wrapper `.extend(...)` calls.
341///
342/// Bumped to 151 for the server-only-import security candidate: JS/TS extraction
343/// now records `next/dynamic(..., { ssr: false })` dynamic-import spans on
344/// `client_only_dynamic_import_spans`, so warm caches written before the bump
345/// miss the ssr:false client-only escape hatch the `client-server-leak` BFS uses
346/// to exclude that edge.
347///
348/// Bumped to 152 for the `misplaced-directive` detector: JS/TS extraction now
349/// records `"use client"` / `"use server"` directive strings written as
350/// expression statements in `program.body` (misplaced) on
351/// `misplaced_directives`, so warm caches written before the bump would report
352/// zero misplaced-directive findings.
353///
354/// Bumped to 154 for the `unprovided-inject` detector: JS/TS and SFC extraction
355/// now record Vue `provide`/`inject` and Svelte `setContext`/`getContext` call
356/// sites on `di_key_sites` plus a `has_dynamic_provide` flag, so warm caches
357/// written before the bump would report zero unprovided-inject findings.
358///
359/// Bumped to 155 because `di_key_sites` now drops keys bound to a module-scope
360/// string-literal const (string identity, not a symbol), so a warm cache from
361/// 154 would carry those dropped sites and false-flag a string-keyed inject.
362///
363/// Bumped to 156 because SFC markup asset references (`<img src="./logo.png">`,
364/// `<source>`, `<video poster>`) now emit `SideEffect` imports, so a warm cache
365/// from 155 would miss the new `unresolved-import` findings on missing assets.
366///
367/// Bumped to 157 because the Vue `<template>` body extractor now matches the
368/// root `</template>` with nesting depth tracking instead of the first
369/// `</template>`. A Vue SFC whose root template contains a nested `<template
370/// #slot>` no longer has its body truncated, so component tags rendered after
371/// the first nested slot are now credited; a warm cache from 156 would carry the
372/// truncated template-usage set and false-flag those components / their imports.
373///
374/// Bumped to 158 for the `unused-component-prop` detector: Vue `<script setup>`
375/// extraction now records `defineProps` declared props on `component_props`
376/// (with `used_in_script` / `used_in_template`) plus the
377/// `has_props_attrs_fallthrough` / `has_define_expose` / `has_define_model` /
378/// `has_unharvestable_props` abstain flags, so a warm cache from 157 would
379/// report zero unused-component-prop findings.
380///
381/// Bumped to 159 because `ComponentProp` gained a `local` field (the destructure
382/// alias for a renamed prop), changing the cached wire shape; a warm 158 cache
383/// would bitcode-misread it.
384///
385/// Bumped to 160 for the `unused-component-emit` detector: Vue `<script setup>`
386/// extraction now records `defineEmits` declared events on `component_emits`
387/// (with `used`) plus the `has_unharvestable_emits` / `has_dynamic_emit` /
388/// `has_emit_whole_object_use` abstain flags, so a warm cache from 159 would
389/// report zero unused-component-emit findings.
390///
391/// Bumped to 162 for `unused-load-data-key` Primitive A: a destructure off the
392/// SvelteKit `data` prop local (`const { user } = data`) now emits `data.<key>`
393/// member accesses (rest element records a whole-object use). A warm cache from
394/// 161 lacks those accesses, so the cross-file load-data-key join would miss the
395/// consumed keys.
396///
397/// Bumped to 163 for `unused-load-data-key` Primitive B: a SvelteKit route
398/// component (`+page.svelte` / `+layout.svelte`) now credits the `data` prop as
399/// a template-visible root, so `{data.x}` / `{#each data.items as i}` markup
400/// reads emit `data.<key>` member accesses. A warm cache from 162 lacks those
401/// template-side accesses, so the cross-file load-data-key join would miss keys
402/// consumed only in markup.
403///
404/// Bumped to 164 for `unused-load-data-key` Primitive C: a SvelteKit global
405/// page-store read in a template (`{$page.data.KEY}` / `{page.data.KEY}`) now
406/// recovers the nested `page.data.<key>` member access (the template scanner
407/// previously dropped the key, keeping only `page.data`). A warm cache from 163
408/// lacks those project-wide global-store accesses.
409///
410/// Bumped (origin/main) for the `unused-load-data-key` detector: SvelteKit
411/// page-load producers now harvest `load_return_keys` + `has_unharvestable_load`,
412/// and every file records `has_load_data_whole_use` (the FP-1 whole-`data` pass
413/// signal). A warm cache from 164 lacks all three.
414///
415/// Bumped (origin/main) for the typed-`data` template fix: a SvelteKit route
416/// component whose `data` prop is typed (`export let data: PageData`) no longer
417/// remaps its template `data.<key>` accesses onto the generated `$types` alias,
418/// keeping them keyed on `data` for the load-data join. A warm cache carries the
419/// remapped (`PageData.<key>`) accesses and would miss real consumer reads.
420///
421/// Bumped (origin/main) for #550: CSS Module class extraction now derives its
422/// class set from a real CSS AST (lightningcss) for standard CSS, so warm caches
423/// written by the regex-only extractor can differ on escaped class names and
424/// malformed at-rule preludes.
425///
426/// Bumped (feat/react-health) for React/JSX structural extraction (Phase 0
427/// foundation): `.jsx`/`.tsx` files now record `component_functions`,
428/// `react_props`, `hook_uses`, and `render_edges`, so a warm cache lacks the
429/// React IR the later React-health phases consume.
430///
431/// Bumped (feat/react-health) for the React `unused-component-prop` arm
432/// (Phase 1): each `ComponentProp` gained a `component` field (the enclosing
433/// React component name) and `react_props[].used_in_script` is now populated
434/// from a used-in-body pass, so a warm cache carries props with an empty
435/// `component` and always-false usage.
436///
437/// Bumped (feat/react-health) for React-aware complexity (Phase 2):
438/// `FunctionComplexity` now carries `react_hook_count`, `react_jsx_max_depth`,
439/// and `react_prop_count` descriptive fields, and the cognitive metric folds
440/// deep JSX nesting, hook density, and prop count (recorded as `JsxDepth` /
441/// `HookDensity` / `PropCount` contributions). A warm cache carries the pre-fold
442/// cognitive scores and lacks the React descriptive counts until re-extraction.
443///
444/// Bumped (feat/react-health) for the prop-drilling forward signal (Phase 3):
445/// `RenderEdge` gained `attr_value_roots` / `has_complex_forward`,
446/// `ComponentFunction` gained `uses_clone_element` / `renders_provider` /
447/// `has_children_as_function`, and `ComponentProp` gained `used_outside_forward`.
448/// A warm cache lacks the per-render attribute-value roots and the
449/// per-component / per-prop forward classification the prop-drilling detector
450/// consumes.
451///
452/// Bumped to 170: `ComponentFunction` gained `is_pure_passthrough` (the
453/// thin-wrapper extraction flag), a new bitcode field on a cached struct
454/// persisted via `ModuleInfo`.
455///
456/// Bumped to 171 (feat/angular): Angular input/output IR
457/// (`angular_inputs` / `angular_outputs` on `ModuleInfo`) plus the
458/// `unused-component-input` / `unused-component-output` suppression tokens, and
459/// the Angular `{ ...this }` spread now records an
460/// `ANGULAR_THIS_SPREAD_SENTINEL` member access (whole-component abstain for the
461/// input/output detectors); a warm cache from 170 lacks the Angular IR and the
462/// sentinel and would report zero input/output findings or false-flag
463/// spread-forwarded inputs/outputs.
464///
465/// Bumped to 172 (feat/vue-options-api-prop-emit): the Vue Options API
466/// (`export default { props, emits, ... }` / `defineComponent({ ... })`) in a
467/// non-setup `<script>` now harvests `component_props` / `component_emits` and
468/// the abstain flags the same way `<script setup>` does; a warm cache from 171
469/// lacks the Options-API prop/emit IR and would report zero findings on those
470/// components.
471///
472/// Bumped to 173 (feat/svelte-runes-extraction, W1.1): two `.svelte` extraction
473/// changes alter serialized module state. (1) Svelte 5's bare `<script module>`
474/// attribute is now recognized as module context (was treated as the instance
475/// script), so a warm cache wrongly scoped module-level declarations and credited the
476/// module script's imports as template-visible. (2) The Svelte 5 `$props()` rune
477/// is now harvested into `component_props` (reusing the Vue IR + abstain flags);
478/// a warm cache from 172 lacks the Svelte prop IR. (`<svelte:component>` /
479/// `<svelte:element>` / `<svelte:self>` were verified already credited by the
480/// existing attribute-value scan, so no template-scanner change rides this bump.)
481///
482/// Bumped to 174 (feat/svelte-dead-event): `.svelte` extraction now records
483/// `svelte_dispatched_events` (literal-arg `dispatch('<name>')` calls where
484/// `dispatch` is bound from `createEventDispatcher()`), `svelte_listened_events`
485/// (template `on:<name>` bindings on component tags), and `has_dynamic_dispatch`
486/// (a dynamic-dispatch / whole-`dispatch`-value abstain). A warm cache from 173
487/// lacks the dispatched/listened event IR and would report zero
488/// `unused-svelte-event` findings.
489///
490/// Bumped to 175 (feat/angular-unrendered-component, W4.2): Angular extraction
491/// now records `angular_component_selectors` (each `@Component({ selector })`
492/// value split into a list plus the class name + span), `angular_used_selectors`
493/// (custom element tags scanned from inline + external Angular templates), and
494/// `angular_entry_component_refs` (route `component:` / `loadComponent`,
495/// `bootstrapApplication` / `bootstrap: [...]` class references), and
496/// `has_dynamic_component_render` (a `ViewContainerRef.createComponent` /
497/// `*ngComponentOutlet` / `createComponent(<ident>)` project-wide abstain). A
498/// warm cache from 174 lacks the selector IR and would report zero Angular
499/// `unrendered-component` findings.
500///
501/// Bumped to 176 (feat/angular-unprovided-inject, W4.1): the `di_key_sites` set
502/// now carries Angular entries (`inject(TOKEN)` / `@Inject(TOKEN)` injects and
503/// `{ provide: TOKEN, ... }` provides via the new `DiFramework::Angular` variant),
504/// `has_dynamic_provide` is additionally set by `importProvidersFrom` /
505/// `makeEnvironmentProviders` / a `providers:` spread, and a tree-shakable
506/// `new InjectionToken(..., { factory } | { providedIn })` records a self-provide.
507/// A warm cache from 175 lacks the Angular DI sites and would report zero Angular
508/// `unprovided-inject` findings.
509///
510/// Bumped to 177 (feat/sfc-template-complexity): Vue and Svelte SFC
511/// `module.complexity` now carries a synthetic `<template>` `FunctionComplexity`
512/// entry computed from template control flow (`v-if`/`v-for`, `{#if}`/`{#each}`)
513/// plus bound-expression and interpolation complexity, mirroring Angular's
514/// existing `<template>` entry. The `FunctionComplexity` shape is unchanged (only
515/// an extra Vec element), so no size assertion changes. A warm cache from 176
516/// lacks the SFC `<template>` entry and would under-report SFC complexity until
517/// the file is re-parsed.
518///
519/// Bumped to 178 (feat/rsc-widen-inline-server-action): `ModuleInfo` now carries
520/// `inline_server_action_exports`, the export local names of exported functions /
521/// const-arrows whose body has an inline `"use server"` directive in a
522/// non-`"use server"` file. The `unused-server-action` reclassifier reads it to
523/// move a dead inline Server Action out of `unused-export`. A warm cache from 177
524/// lacks the field and would leave such dead inline actions categorized as
525/// `unused-export` until the file is re-parsed.
526///
527/// Bumped to 179 for issue #1270: Playwright fixture callbacks now record
528/// member uses reached through branch-selected local fixture aliases. Warm
529/// caches from 178 can miss those synthetic `member_accesses` and surface false
530/// `unused-class-member` findings.
531///
532/// Bumped to 180 for issue #1281: JSX nesting depth is now descriptive
533/// `react_jsx_max_depth` context only, so warm caches from 179 may carry stale
534/// cognitive scores and `JsxDepth` contribution entries for React components.
535///
536/// Bumped to 181 for issue #1282: Pinia `storeToRefs(useStore())` and
537/// `toRefs(useStore())` destructures now record store member accesses. Warm
538/// caches from 180 can miss those synthetic `member_accesses` and surface false
539/// `unused-store-member` findings.
540pub(super) const CACHE_VERSION: u32 = 181;
541
542/// Duplication token cache version. Bump when duplicate tokenization,
543/// normalization, or the on-disk token cache schema changes.
544///
545/// Bumped to 6 for issue #1225: `ignoreImports` now excludes re-export barrels
546/// and top-level static CommonJS require binding declarations.
547pub const DUPES_CACHE_VERSION: u32 = 6;
548
549/// Default maximum cache size (256 MB). Overridable per-project via
550/// `cache.maxSizeMb` in the config file or `FALLOW_CACHE_MAX_SIZE` env var.
551/// Also used as the hard ceiling on load-time deserialization as a defence
552/// against pathological on-disk files.
553pub const DEFAULT_CACHE_MAX_SIZE: usize = 256 * 1024 * 1024;
554
555/// Trigger LRU eviction when the serialized cache exceeds 80% of the cap.
556/// Basis points (1/100 of a percent) for integer arithmetic without floats.
557pub(super) const EVICTION_TRIGGER_BPS: usize = 8000;
558
559/// Evict down to 60% of the cap so subsequent saves leave headroom.
560pub(super) const EVICTION_TARGET_BPS: usize = 6000;
561
562/// Promote the eviction log from `debug!` to `info!` when at least 25% of
563/// entries are removed in a single save. Default-noise concerns mean
564/// small-turnover saves should not be visible without `RUST_LOG=debug`.
565pub(super) const EVICTION_SIGNIFICANT_BPS: usize = 2500;
566
567/// Import kind discriminant for `CachedImport`:
568/// 0 = Named, 1 = Default, 2 = Namespace, 3 = `SideEffect`.
569pub(super) const IMPORT_KIND_NAMED: u8 = 0;
570pub(super) const IMPORT_KIND_DEFAULT: u8 = 1;
571pub(super) const IMPORT_KIND_NAMESPACE: u8 = 2;
572pub(super) const IMPORT_KIND_SIDE_EFFECT: u8 = 3;
573
574macro_rules! assert_cached_type_size {
575    ($ty:ty, $size:expr) => {
576        const _: () = assert!(
577            std::mem::size_of::<$ty>() == $size,
578            concat!(
579                stringify!($ty),
580                " size changed; bump CACHE_VERSION if the cached wire shape or extraction semantics changed, then update this assertion"
581            )
582        );
583    };
584}
585
586assert_cached_type_size!(CachedModule, 1256);
587assert_cached_type_size!(CachedNamespaceObjectAlias, 72);
588assert_cached_type_size!(CachedLocalTypeDeclaration, 32);
589assert_cached_type_size!(CachedPublicSignatureTypeReference, 56);
590assert_cached_type_size!(CachedSuppression, 64);
591assert_cached_type_size!(CachedUnknownSuppressionKind, 32);
592assert_cached_type_size!(CachedExport, 112);
593assert_cached_type_size!(CachedImport, 96);
594assert_cached_type_size!(CachedDynamicImport, 88);
595assert_cached_type_size!(CachedRequireCall, 88);
596assert_cached_type_size!(CachedReExport, 88);
597assert_cached_type_size!(CachedMember, 64);
598assert_cached_type_size!(CachedDynamicImportPattern, 56);
599assert_cached_type_size!(crate::MemberAccess, 48);
600assert_cached_type_size!(fallow_types::extract::CalleeUse, 32);
601assert_cached_type_size!(fallow_types::extract::MisplacedDirectiveSite, 8);
602assert_cached_type_size!(fallow_types::extract::SinkSite, 216);
603assert_cached_type_size!(fallow_types::extract::FunctionComplexity, 96);
604assert_cached_type_size!(fallow_types::extract::ComplexityContribution, 16);
605assert_cached_type_size!(fallow_types::extract::FlagUse, 80);
606assert_cached_type_size!(fallow_types::extract::ClassHeritageInfo, 96);
607assert_cached_type_size!(fallow_types::extract::LoadReturnKey, 32);
608
609/// Cached data for a single module.
610#[derive(Debug, Clone, Encode, Decode)]
611pub struct CachedModule {
612    /// xxh3 hash of the file content.
613    pub content_hash: u64,
614    /// File modification time (seconds since epoch) for fast cache validation.
615    /// When mtime+size match the on-disk file, we skip reading file content entirely.
616    pub mtime_secs: u64,
617    /// File size in bytes for fast cache validation.
618    pub file_size: u64,
619    /// Seconds-since-epoch at the time this entry was last WRITTEN
620    /// (first parse or content-change refresh). NOT updated on cache-hit
621    /// reads: `update_cache` already iterates every in-scope file every run,
622    /// so refreshing on read would collapse the LRU to "last run this file
623    /// was discovered" for every retained entry. With write-only refresh,
624    /// the LRU genuinely targets stale (in-scope-but-unchanged-for-many-runs)
625    /// entries. Used by `CacheStore::save` for write-time eviction ordering.
626    pub last_access_secs: u64,
627    /// Exported symbols.
628    pub exports: Vec<CachedExport>,
629    /// Import specifiers.
630    pub imports: Vec<CachedImport>,
631    /// Re-export specifiers.
632    pub re_exports: Vec<CachedReExport>,
633    /// Dynamic import specifiers.
634    pub dynamic_imports: Vec<CachedDynamicImport>,
635    /// `require()` specifiers.
636    pub require_calls: Vec<CachedRequireCall>,
637    /// Package names statically referenced through package path resolution.
638    pub package_path_references: Vec<String>,
639    /// Static member accesses (e.g., `Status.Active`).
640    pub member_accesses: Vec<crate::MemberAccess>,
641    /// Identifiers used as whole objects (Object.values, for..in, spread, etc.).
642    pub whole_object_uses: Vec<String>,
643    /// Dynamic import patterns with partial static resolution.
644    pub dynamic_import_patterns: Vec<CachedDynamicImportPattern>,
645    /// Whether this module uses CJS exports.
646    pub has_cjs_exports: bool,
647    /// Whether this module declares at least one Angular `@Component({
648    /// templateUrl: ... })` decorator. Mirrors `ModuleInfo.has_angular_component_template_url`
649    /// so the CRAP-inherit walker's gate survives a warm-cache load.
650    pub has_angular_component_template_url: bool,
651    /// Local names of import bindings that are never referenced in this file.
652    pub unused_import_bindings: Vec<String>,
653    /// Local import bindings referenced from type positions.
654    pub type_referenced_import_bindings: Vec<String>,
655    /// Local import bindings referenced from value positions.
656    pub value_referenced_import_bindings: Vec<String>,
657    /// Inline suppression directives.
658    pub suppressions: Vec<CachedSuppression>,
659    /// Suppression tokens that did not parse to any known `IssueKind`. See #449.
660    pub unknown_suppression_kinds: Vec<CachedUnknownSuppressionKind>,
661    /// Pre-computed line-start byte offsets for O(log N) byte-to-line/col conversion.
662    pub line_offsets: Vec<u32>,
663    /// Per-function complexity metrics.
664    pub complexity: Vec<fallow_types::extract::FunctionComplexity>,
665    /// Feature flag use sites.
666    pub flag_uses: Vec<fallow_types::extract::FlagUse>,
667    /// Heritage metadata for exported classes.
668    pub class_heritage: Vec<fallow_types::extract::ClassHeritageInfo>,
669    /// Angular `InjectionToken<Interface>` `(token, interface)` pairs (#920).
670    pub injection_tokens: Vec<(String, String)>,
671    /// Local type-capable declarations.
672    pub local_type_declarations: Vec<CachedLocalTypeDeclaration>,
673    /// Type references from exported public signatures.
674    pub public_signature_type_references: Vec<CachedPublicSignatureTypeReference>,
675    /// Namespace-import aliases re-exported through an object literal
676    /// (`export const API = { foo }` where `foo` is `import * as foo from './bar'`).
677    pub namespace_object_aliases: Vec<CachedNamespaceObjectAlias>,
678    /// Iconify collection prefixes found in static icon props (issue #608).
679    pub iconify_prefixes: Vec<String>,
680    /// Nuxt UI icon class suffixes found in static script-side icon properties
681    /// (issue #955).
682    pub iconify_icon_names: Vec<String>,
683    /// Bare identifier names that are candidates for convention auto-import
684    /// resolution (issue #704). Content-local, so they round-trip through the
685    /// cache; resolution against the plugin table happens at graph-build time.
686    pub auto_import_candidates: Vec<String>,
687    /// File-level string directives (`"use client"`, `"use server"`). Content-local,
688    /// round-trips through the cache so the security `client-server-leak` detector
689    /// sees directives on warm-cache loads.
690    pub directives: Vec<String>,
691    /// Byte-offset starts of `next/dynamic(..., { ssr: false })` dynamic imports.
692    /// Content-local, round-trips so the security `client-server-leak` BFS sees
693    /// the ssr:false client-only escape hatch on warm-cache loads.
694    pub client_only_dynamic_import_spans: Vec<u32>,
695    /// Captured security sink sites (category-blind). Round-trips through the
696    /// cache so the catalogue-driven `tainted_sink` detector sees sinks on
697    /// warm-cache loads.
698    pub security_sinks: Vec<fallow_types::extract::SinkSite>,
699    /// Count of sink-shaped nodes whose callee could not be flattened to a
700    /// static path. Round-trips so the in-band blind-spot count is stable.
701    pub security_sinks_skipped: u32,
702    /// Span-level diagnostics for skipped security sink callees.
703    pub security_unresolved_callee_sites: Vec<fallow_types::extract::SkippedSecurityCalleeSite>,
704    /// Local bindings tied to the member-access path they were sourced from.
705    /// Round-trips so the security `tainted_sink` source-to-sink association
706    /// sees source-tainted bindings on warm-cache loads.
707    pub tainted_bindings: Vec<fallow_types::extract::TaintedBinding>,
708    /// Direct sink arguments recognized as sanitizer calls.
709    pub sanitized_sink_args: Vec<fallow_types::extract::SanitizedSinkArg>,
710    /// Defensive control call sites for security surface output.
711    pub security_control_sites: Vec<fallow_types::extract::SecurityControlSite>,
712    /// Deduped statically flattenable callee paths. Round-trips so the
713    /// `boundaries.calls.forbidden` detector sees call sites on warm-cache
714    /// loads.
715    pub callee_uses: Vec<fallow_types::extract::CalleeUse>,
716    /// Misplaced `"use client"` / `"use server"` directive sites.
717    /// Round-trips so the `misplaced-directive` detector sees them on
718    /// warm-cache loads.
719    pub misplaced_directives: Vec<fallow_types::extract::MisplacedDirectiveSite>,
720    /// Export local names of inline `"use server"` body Server Actions.
721    /// Round-trips so the `unused-server-action` reclassifier sees them on
722    /// warm-cache loads.
723    pub inline_server_action_exports: Vec<String>,
724    /// Vue `provide`/`inject` and Svelte `setContext`/`getContext` key sites.
725    /// Round-trips so the `unprovided-inject` detector sees them on warm-cache
726    /// loads.
727    pub di_key_sites: Vec<fallow_types::extract::DiKeySite>,
728    /// Whether the module had an unknowable-key provide. Round-trips so the
729    /// `unprovided-inject` project-wide abstain holds on warm-cache loads.
730    pub has_dynamic_provide: bool,
731    /// Vue `<script setup>` `defineProps` declared props. Round-trips so the
732    /// `unused-component-prop` detector sees them on warm-cache loads.
733    pub component_props: Vec<fallow_types::extract::ComponentProp>,
734    /// Whether the template spreads `$attrs`/`$props`/`props` or the
735    /// `defineProps` return is rest-destructured. Round-trips for the abstain.
736    pub has_props_attrs_fallthrough: bool,
737    /// Whether the SFC calls `defineExpose(...)`. Round-trips for the abstain.
738    pub has_define_expose: bool,
739    /// Whether the SFC calls `defineModel(...)`. Round-trips for the abstain.
740    pub has_define_model: bool,
741    /// Whether `defineProps` had an unharvestable type-reference argument.
742    /// Round-trips for the abstain.
743    pub has_unharvestable_props: bool,
744    /// Vue `<script setup>` `defineEmits` declared events. Round-trips so the
745    /// `unused-component-emit` detector sees them on warm-cache loads.
746    pub component_emits: Vec<fallow_types::extract::ComponentEmit>,
747    /// Angular component/directive inputs (`@Input()` decorators and signal
748    /// `input()` / `model()` initializers). Round-trips so the
749    /// `unused-component-input` detector sees them on warm-cache loads.
750    pub angular_inputs: Vec<fallow_types::extract::AngularInputMember>,
751    /// Angular component/directive outputs (`@Output()` decorators and signal
752    /// `output()` / `outputFromObservable()` initializers). Round-trips so the
753    /// `unused-component-output` detector sees them on warm-cache loads.
754    pub angular_outputs: Vec<fallow_types::extract::AngularOutputMember>,
755    /// Angular `@Component` declarations with their `selector` value(s).
756    /// Round-trips so the Angular `unrendered-component` arm sees them on
757    /// warm-cache loads.
758    pub angular_component_selectors: Vec<fallow_types::extract::AngularComponentSelector>,
759    /// Custom element selector tags referenced in this file's Angular templates.
760    /// Round-trips for the Angular `unrendered-component` used-selector union.
761    pub angular_used_selectors: Vec<String>,
762    /// Angular route / bootstrap component class references. Round-trips for the
763    /// Angular `unrendered-component` entry-point abstain.
764    pub angular_entry_component_refs: Vec<String>,
765    /// Whether this file dynamically renders a component (project-wide abstain
766    /// signal for the Angular `unrendered-component` detector). Round-trips.
767    pub has_dynamic_component_render: bool,
768    /// Whether `defineEmits` had an unharvestable argument. Round-trips for the
769    /// abstain.
770    pub has_unharvestable_emits: bool,
771    /// Whether an `emit(<nonLiteral>)` call was seen. Round-trips for the abstain.
772    pub has_dynamic_emit: bool,
773    /// Whether the emit binding was used as a whole value. Round-trips for the
774    /// abstain.
775    pub has_emit_whole_object_use: bool,
776    /// SvelteKit `load()` return-object keys. Round-trips so the
777    /// `unused-load-data-key` detector sees them on warm-cache loads.
778    pub load_return_keys: Vec<fallow_types::extract::LoadReturnKey>,
779    /// Whether this file's `load()` body could not be harvested safely.
780    /// Round-trips for the abstain.
781    pub has_unharvestable_load: bool,
782    /// Whether this file passes the whole `data` object opaquely. Round-trips
783    /// for the `unused-load-data-key` abstain.
784    pub has_load_data_whole_use: bool,
785    /// React/JSX component definitions. Round-trips so the React-health phases
786    /// see them on warm-cache loads.
787    pub component_functions: Vec<fallow_types::extract::ComponentFunction>,
788    /// React component props. Round-trips so the React `unused-component-prop`
789    /// arm sees them on warm-cache loads.
790    pub react_props: Vec<fallow_types::extract::ComponentProp>,
791    /// React hook call sites. Round-trips for the complexity-fold phase.
792    pub hook_uses: Vec<fallow_types::extract::HookUse>,
793    /// React render edges (child name captured; resolution deferred to graph
794    /// build). Round-trips so the render graph survives a warm cache.
795    pub render_edges: Vec<fallow_types::extract::RenderEdge>,
796    /// Svelte custom events dispatched via `dispatch('<name>')`. Round-trips so
797    /// the `unused-svelte-event` detector sees them on warm-cache loads.
798    pub svelte_dispatched_events: Vec<fallow_types::extract::DispatchedEvent>,
799    /// Svelte template `on:<name>` listener names on component tags. Round-trips
800    /// so the project-wide listened set is correct on warm-cache loads.
801    pub svelte_listened_events: Vec<String>,
802    /// Whether a `dispatch(<nonLiteral>)` call or whole-`dispatch`-value use was
803    /// seen. Round-trips for the `unused-svelte-event` abstain.
804    pub has_dynamic_dispatch: bool,
805}
806
807/// Cached namespace-object alias.
808#[derive(Debug, Clone, Encode, Decode)]
809pub struct CachedNamespaceObjectAlias {
810    /// Canonical export name on this module.
811    pub via_export_name: String,
812    /// Dotted suffix of the property path relative to the export.
813    pub suffix: String,
814    /// Local name of the namespace import on this module.
815    pub namespace_local: String,
816}
817
818/// Cached local type declaration.
819#[derive(Debug, Clone, Encode, Decode)]
820pub struct CachedLocalTypeDeclaration {
821    /// Local declaration name.
822    pub name: String,
823    /// Byte offset of the declaration span start.
824    pub span_start: u32,
825    /// Byte offset of the declaration span end.
826    pub span_end: u32,
827}
828
829/// Cached public signature type reference.
830#[derive(Debug, Clone, Encode, Decode)]
831pub struct CachedPublicSignatureTypeReference {
832    /// Exported symbol whose signature contains the reference.
833    pub export_name: String,
834    /// Referenced type name.
835    pub type_name: String,
836    /// Byte offset of the reference span start.
837    pub span_start: u32,
838    /// Byte offset of the reference span end.
839    pub span_end: u32,
840}
841
842/// Cached suppression directive.
843#[derive(Debug, Clone, Encode, Decode)]
844pub struct CachedSuppression {
845    /// 1-based line this suppression applies to. 0 = file-wide.
846    pub line: u32,
847    /// 1-based line where the comment itself appears.
848    pub comment_line: u32,
849    /// 0 = suppress all, otherwise `IssueKind` discriminant.
850    pub kind: u8,
851    /// Rule-pack name for scoped policy suppressions. Empty for all other
852    /// suppression targets.
853    pub policy_pack: String,
854    /// Rule id for scoped policy suppressions. Empty for all other suppression
855    /// targets.
856    pub policy_rule_id: String,
857}
858
859/// Cached unknown suppression kind token (see #449).
860#[derive(Debug, Clone, Encode, Decode)]
861pub struct CachedUnknownSuppressionKind {
862    /// 1-based line where the comment itself appears.
863    pub comment_line: u32,
864    /// True when the marker was `fallow-ignore-file`.
865    pub is_file_level: bool,
866    /// The verbatim token that did not parse.
867    pub token: String,
868}
869
870/// Cached export data for a single export declaration.
871#[derive(Debug, Clone, Encode, Decode)]
872pub struct CachedExport {
873    /// Export name (or "default" for default exports).
874    pub name: String,
875    /// Whether this is a default export.
876    pub is_default: bool,
877    /// Whether this is a type-only export.
878    pub is_type_only: bool,
879    /// Whether this export is registered through a runtime side effect at
880    /// module load time (Lit `@customElement` decorator or
881    /// `customElements.define` call). Persisted so warm-cache runs continue
882    /// to skip unused-export reporting for these classes.
883    pub is_side_effect_used: bool,
884    /// Visibility tag discriminant (0=None, 1=Public, 2=Internal, 3=Beta, 4=Alpha).
885    pub visibility: u8,
886    /// The local binding name, if different.
887    pub local_name: Option<String>,
888    /// Byte offset of the export span start.
889    pub span_start: u32,
890    /// Byte offset of the export span end.
891    pub span_end: u32,
892    /// Members of this export (for enums and classes).
893    pub members: Vec<CachedMember>,
894    /// The local name of the parent class from `extends` clause, if any.
895    pub super_class: Option<String>,
896}
897
898/// Cached import data for a single import declaration.
899#[derive(Debug, Clone, Encode, Decode)]
900pub struct CachedImport {
901    /// The import specifier.
902    pub source: String,
903    /// For Named imports, the imported symbol name. Empty for other kinds.
904    pub imported_name: String,
905    /// The local binding name.
906    pub local_name: String,
907    /// Whether this is a type-only import.
908    pub is_type_only: bool,
909    /// Whether this import originated from an SFC `<style>` block / `<style src>` (CSS context).
910    pub from_style: bool,
911    /// Import kind: 0=Named, 1=Default, 2=Namespace, 3=SideEffect.
912    pub kind: u8,
913    /// Byte offset of the import span start.
914    pub span_start: u32,
915    /// Byte offset of the import span end.
916    pub span_end: u32,
917    /// Byte offset of the source string literal span start.
918    pub source_span_start: u32,
919    /// Byte offset of the source string literal span end.
920    pub source_span_end: u32,
921}
922
923/// Cached dynamic import data.
924#[derive(Debug, Clone, Encode, Decode)]
925pub struct CachedDynamicImport {
926    /// The import specifier.
927    pub source: String,
928    /// Byte offset of the span start.
929    pub span_start: u32,
930    /// Byte offset of the span end.
931    pub span_end: u32,
932    /// Names destructured from the import result.
933    pub destructured_names: Vec<String>,
934    /// Local variable name for namespace imports.
935    pub local_name: Option<String>,
936    /// True when this dynamic import was synthesised by fallow (see
937    /// `DynamicImportInfo::is_speculative`).
938    pub is_speculative: bool,
939}
940
941/// Cached `require()` call data.
942#[derive(Debug, Clone, Encode, Decode)]
943pub struct CachedRequireCall {
944    /// The require specifier.
945    pub source: String,
946    /// Byte offset of the span start.
947    pub span_start: u32,
948    /// Byte offset of the span end.
949    pub span_end: u32,
950    /// Byte offset of the specifier string-literal span start.
951    pub source_span_start: u32,
952    /// Byte offset of the specifier string-literal span end.
953    pub source_span_end: u32,
954    /// Names destructured from the require result.
955    pub destructured_names: Vec<String>,
956    /// Local variable name for namespace requires.
957    pub local_name: Option<String>,
958}
959
960/// Cached re-export data.
961#[derive(Debug, Clone, Encode, Decode)]
962pub struct CachedReExport {
963    /// The module being re-exported from.
964    pub source: String,
965    /// Name imported from the source.
966    pub imported_name: String,
967    /// Name exported from this module.
968    pub exported_name: String,
969    /// Whether this is a type-only re-export.
970    pub is_type_only: bool,
971    /// Byte offset of the re-export span start (for line-number reporting).
972    pub span_start: u32,
973    /// Byte offset of the re-export span end.
974    pub span_end: u32,
975}
976
977/// Cached enum or class member data.
978#[derive(Debug, Clone, Encode, Decode)]
979pub struct CachedMember {
980    /// Member name.
981    pub name: String,
982    /// Member kind (enum, method, or property).
983    pub kind: MemberKind,
984    /// Byte offset of the span start.
985    pub span_start: u32,
986    /// Byte offset of the span end.
987    pub span_end: u32,
988    /// Whether this member has decorators.
989    pub has_decorator: bool,
990    /// Full dotted path of each decorator (e.g. `step`, `ns.foo`).
991    /// Empty for undecorated members and decorators with non-identifier
992    /// expressions.
993    pub decorator_names: Vec<String>,
994    /// True when this is a static method that returns a fresh instance of
995    /// the class: body returns `new this()` / `new <SameClassName>()`, or the
996    /// declared return type matches the class name. Treated as a factory.
997    /// See issues #346, #387.
998    pub is_instance_returning_static: bool,
999    /// True when this instance method's call result is an instance of the
1000    /// same class (declared return type matches the class name, or body's
1001    /// last statement is `return this`). Drives fluent-chain credit. See
1002    /// issue #387.
1003    pub is_self_returning: bool,
1004}
1005
1006/// Cached dynamic import pattern data (template literals, `import.meta.glob`).
1007#[derive(Debug, Clone, Encode, Decode)]
1008pub struct CachedDynamicImportPattern {
1009    /// Static prefix of the import path.
1010    pub prefix: String,
1011    /// Static suffix, if any.
1012    pub suffix: Option<String>,
1013    /// Byte offset of the span start.
1014    pub span_start: u32,
1015    /// Byte offset of the span end.
1016    pub span_end: u32,
1017}