Skip to main content

fallow_api/
json_output.rs

1//! Shared JSON output assembly for CLI and programmatic consumers.
2
3use std::path::Path;
4use std::time::Duration;
5
6use fallow_output::{
7    CHECK_SCHEMA_VERSION, CheckEnvelope, CheckGroupedEntry, CheckGroupedOutput, CheckOutput,
8    CheckOutputInput, DUPES_SCHEMA_VERSION, DupesOutput, DupesOutputInput, GroupByMode,
9    apply_config_fixable_to_duplicate_exports, build_check_output, build_dupes_output,
10    harmonize_multi_kind_suppress_line_actions as harmonize_typed_suppress_line_actions,
11    strip_root_prefix,
12};
13use fallow_types::duplicates::DuplicationReport;
14use fallow_types::envelope::{
15    BaselineDeltas, BaselineMatch, ElapsedMs, Meta, RegressionResult, SchemaVersion, ToolVersion,
16};
17use fallow_types::output::NextStep;
18use fallow_types::results::AnalysisResults;
19use fallow_types::workspace::WorkspaceDiagnostic;
20
21use crate::{DupesReportPayload, DuplicationGroup, DuplicationGrouping, ResultGroup};
22
23/// Inputs for `fallow dead-code --format json` and
24/// `fallow architecture --format json` output assembly.
25pub struct CheckJsonOutputInput<'a> {
26    /// The command family member: sets the root `kind` and `schema_version`.
27    pub envelope: CheckEnvelope,
28    /// Typed dead-code results to serialize.
29    pub results: &'a AnalysisResults,
30    /// Project root; its prefix is stripped from every path in the output.
31    pub root: &'a Path,
32    /// Analysis wall time, emitted as `elapsed_ms`.
33    pub elapsed: Duration,
34    /// Whether duplicate-export findings can be auto-fixed through config;
35    /// propagated onto their fix actions.
36    pub config_fixable: bool,
37    /// Optional explain metadata block for the envelope.
38    pub meta: Option<Meta>,
39    /// Caller-computed baseline and regression sections.
40    pub extras: CheckJsonExtraOutputs,
41    /// Non-fatal per-file diagnostics collected during the workspace walk.
42    pub workspace_diagnostics: Vec<WorkspaceDiagnostic>,
43    /// Suggested follow-up commands for the consumer.
44    pub next_steps: Vec<NextStep>,
45    /// Analysis run id stamped into telemetry metadata when present.
46    pub telemetry_analysis_run_id: Option<&'a str>,
47}
48
49/// Inputs for the dead-code JSON payload without a root envelope.
50pub struct CheckJsonPayloadInput<'a> {
51    /// Typed dead-code results to serialize.
52    pub results: &'a AnalysisResults,
53    /// Project root; its prefix is stripped from every path in the output.
54    pub root: &'a Path,
55    /// Analysis wall time, emitted as `elapsed_ms`.
56    pub elapsed: Duration,
57    /// Whether duplicate-export findings can be auto-fixed through config;
58    /// propagated onto their fix actions.
59    pub config_fixable: bool,
60    /// Caller-computed baseline and regression sections.
61    pub extras: CheckJsonExtraOutputs,
62    /// Non-fatal per-file diagnostics collected during the workspace walk.
63    pub workspace_diagnostics: Vec<WorkspaceDiagnostic>,
64}
65
66/// Optional root sections for dead-code JSON envelopes.
67///
68/// These fields are part of the output contract, but they are computed by
69/// caller-specific workflows such as baseline and regression gates.
70#[derive(Debug, Clone, Default)]
71pub struct CheckJsonExtraOutputs {
72    /// Applied refs for exact workspace package roots.
73    pub package_baselines: Vec<fallow_output::PackageBaselineStatus>,
74    /// Per-category issue count changes against the matched baseline.
75    pub baseline_deltas: Option<BaselineDeltas>,
76    /// Which baseline snapshot the run was compared against.
77    pub baseline: Option<BaselineMatch>,
78    /// This run's view of that baseline: counts, advisory verdict and the
79    /// `--fail-on-stale-baseline` verdict.
80    pub baseline_staleness: Option<fallow_output::BaselineStaleness>,
81    /// Outcome of the regression gate against the baseline.
82    pub regression: Option<RegressionResult>,
83    /// Every gate this run evaluated. The programmatic route runs no CLI-layer
84    /// gate, so a caller that computes none leaves this `None` and the envelope
85    /// key stays absent. An empty set is never emitted: it would assert that
86    /// gates were evaluated and none tripped, which is a different claim.
87    pub gate_outcomes: Option<fallow_output::GateOutcomes>,
88    /// Every narrowing or shaping request this run received, absent when it
89    /// was asked for nothing. The programmatic route resolves no CLI flag and
90    /// leaves this `None`; an entry whose `status` is not `applied` means the
91    /// report is wider than what was asked for.
92    pub request_outcomes: Option<fallow_output::RequestOutcomes>,
93    /// The answer to a finding-id query, present only when the run received
94    /// one or more finding ids. See [`fallow_output::FindingIdQuery`].
95    pub finding_id_query: Option<fallow_output::FindingIdQuery>,
96}
97
98struct CheckJsonEnvelopeInput<'a> {
99    schema_version: u32,
100    results: &'a AnalysisResults,
101    elapsed: Duration,
102    config_fixable: bool,
103    meta: Option<Meta>,
104    extras: CheckJsonExtraOutputs,
105    workspace_diagnostics: Vec<WorkspaceDiagnostic>,
106    next_steps: Vec<NextStep>,
107}
108
109/// Inputs for grouped dead-code and architecture JSON output assembly.
110pub struct GroupedCheckJsonOutputInput<'a> {
111    /// The command family member: sets the root `kind` and `schema_version`.
112    pub envelope: CheckEnvelope,
113    /// Applied refs for exact workspace package roots.
114    pub package_baselines: Vec<fallow_output::PackageBaselineStatus>,
115    /// This run's view of the loaded baseline, for baseline runs.
116    pub baseline_staleness: Option<fallow_output::BaselineStaleness>,
117    /// Every gate this run evaluated. The programmatic route runs no CLI-layer
118    /// gate, so a caller that computes none leaves this `None` and the envelope
119    /// key stays absent. An empty set is never emitted: it would assert that
120    /// gates were evaluated and none tripped, which is a different claim.
121    pub gate_outcomes: Option<fallow_output::GateOutcomes>,
122    /// Every narrowing or shaping request this run received, absent when it
123    /// was asked for nothing. The programmatic route resolves no CLI flag and
124    /// leaves this `None`; an entry whose `status` is not `applied` means the
125    /// report is wider than what was asked for.
126    pub request_outcomes: Option<fallow_output::RequestOutcomes>,
127    /// The answer to a finding-id query, present only when the run received
128    /// one or more finding ids. See [`fallow_output::FindingIdQuery`].
129    pub finding_id_query: Option<fallow_output::FindingIdQuery>,
130
131    /// Results already partitioned into groups, in output order.
132    pub groups: &'a [ResultGroup],
133    /// Ungrouped results, used for the envelope's `total_issues` count.
134    pub original: &'a AnalysisResults,
135    /// Project root; its prefix is stripped from every path in the output.
136    pub root: &'a Path,
137    /// Analysis wall time, emitted as `elapsed_ms`.
138    pub elapsed: Duration,
139    /// Grouping axis recorded as `grouped_by` in the envelope.
140    pub grouped_by: GroupByMode,
141    /// Whether duplicate-export findings can be auto-fixed through config;
142    /// propagated onto their fix actions per group.
143    pub config_fixable: bool,
144    /// Optional explain metadata block for the envelope.
145    pub meta: Option<Meta>,
146    /// Non-fatal per-file diagnostics collected during the workspace walk.
147    pub workspace_diagnostics: Vec<WorkspaceDiagnostic>,
148    /// Suggested follow-up commands for the consumer.
149    pub next_steps: Vec<NextStep>,
150    /// Analysis run id stamped into telemetry metadata when present.
151    pub telemetry_analysis_run_id: Option<&'a str>,
152}
153
154/// Inputs for `fallow dupes --format json` output assembly.
155pub struct DuplicationJsonOutputInput<'a> {
156    /// Applied refs for exact workspace package roots.
157    pub package_baselines: Vec<fallow_output::PackageBaselineStatus>,
158    /// This run's view of the loaded duplication baseline, for baseline runs.
159    pub baseline_staleness: Option<fallow_output::BaselineStaleness>,
160    /// Every gate this run evaluated. The programmatic route runs no CLI-layer
161    /// gate, so a caller that computes none leaves this `None` and the envelope
162    /// key stays absent. An empty set is never emitted: it would assert that
163    /// gates were evaluated and none tripped, which is a different claim.
164    pub gate_outcomes: Option<fallow_output::GateOutcomes>,
165    /// Every narrowing or shaping request this run received, absent when it
166    /// was asked for nothing. The programmatic route resolves no CLI flag and
167    /// leaves this `None`; an entry whose `status` is not `applied` means the
168    /// report is wider than what was asked for.
169    pub request_outcomes: Option<fallow_output::RequestOutcomes>,
170
171    /// Typed duplication report to serialize.
172    pub report: &'a DuplicationReport,
173    /// Project root; its prefix is stripped from every path in the output.
174    pub root: &'a Path,
175    /// Analysis wall time, emitted as `elapsed_ms`.
176    pub elapsed: Duration,
177    /// Whether each clone instance carries its verbatim source text.
178    pub include_fragments: bool,
179    /// Optional explain metadata block for the envelope.
180    pub meta: Option<Meta>,
181    /// Non-fatal per-file diagnostics collected during the workspace walk.
182    pub workspace_diagnostics: Vec<WorkspaceDiagnostic>,
183    /// Suggested follow-up commands for the consumer.
184    pub next_steps: Vec<NextStep>,
185    /// Analysis run id stamped into telemetry metadata when present.
186    pub telemetry_analysis_run_id: Option<&'a str>,
187}
188
189/// Inputs for grouped duplication JSON output assembly.
190pub struct GroupedDuplicationJsonOutputInput<'a> {
191    /// Applied refs for exact workspace package roots.
192    pub package_baselines: Vec<fallow_output::PackageBaselineStatus>,
193    /// This run's view of the loaded duplication baseline, for baseline runs.
194    pub baseline_staleness: Option<fallow_output::BaselineStaleness>,
195    /// Every gate this run evaluated. The programmatic route runs no CLI-layer
196    /// gate, so a caller that computes none leaves this `None` and the envelope
197    /// key stays absent. An empty set is never emitted: it would assert that
198    /// gates were evaluated and none tripped, which is a different claim.
199    pub gate_outcomes: Option<fallow_output::GateOutcomes>,
200    /// Every narrowing or shaping request this run received, absent when it
201    /// was asked for nothing. The programmatic route resolves no CLI flag and
202    /// leaves this `None`; an entry whose `status` is not `applied` means the
203    /// report is wider than what was asked for.
204    pub request_outcomes: Option<fallow_output::RequestOutcomes>,
205
206    /// Typed duplication report to serialize.
207    pub report: &'a DuplicationReport,
208    /// Precomputed grouping whose groups replace the flat `groups` array.
209    pub grouping: &'a DuplicationGrouping,
210    /// Project root; its prefix is stripped from every path in the output.
211    pub root: &'a Path,
212    /// Analysis wall time, emitted as `elapsed_ms`.
213    pub elapsed: Duration,
214    /// Whether each clone instance carries its verbatim source text.
215    pub include_fragments: bool,
216    /// Optional explain metadata block for the envelope.
217    pub meta: Option<Meta>,
218    /// Non-fatal per-file diagnostics collected during the workspace walk.
219    pub workspace_diagnostics: Vec<WorkspaceDiagnostic>,
220    /// Suggested follow-up commands for the consumer.
221    pub next_steps: Vec<NextStep>,
222    /// Analysis run id stamped into telemetry metadata when present.
223    pub telemetry_analysis_run_id: Option<&'a str>,
224}
225
226/// Build and serialize dead-code JSON through the API-owned output boundary.
227///
228/// # Errors
229///
230/// Returns a serde error when the typed envelope cannot be converted to JSON.
231pub fn serialize_check_json(
232    input: CheckJsonOutputInput<'_>,
233) -> Result<serde_json::Value, serde_json::Error> {
234    let envelope = build_check_json_envelope(CheckJsonEnvelopeInput {
235        schema_version: input.envelope.schema_version(),
236        results: input.results,
237        elapsed: input.elapsed,
238        config_fixable: input.config_fixable,
239        meta: input.meta,
240        extras: input.extras,
241        workspace_diagnostics: input.workspace_diagnostics,
242        next_steps: input.next_steps,
243    });
244    let run_id = input.telemetry_analysis_run_id;
245    let mut output = match input.envelope {
246        CheckEnvelope::DeadCode => fallow_output::serialize_check_json_output(envelope, run_id)?,
247        CheckEnvelope::Architecture => {
248            fallow_output::serialize_architecture_json_output(envelope, run_id)?
249        }
250    };
251    strip_json_root_prefix(&mut output, input.root);
252    Ok(output)
253}
254
255/// Build a dead-code JSON payload without adding a root envelope.
256///
257/// # Errors
258///
259/// Returns a serde error when the typed envelope cannot be converted to JSON.
260pub fn serialize_check_json_payload(
261    input: CheckJsonPayloadInput<'_>,
262) -> Result<serde_json::Value, serde_json::Error> {
263    let envelope = build_check_json_envelope(CheckJsonEnvelopeInput {
264        schema_version: CHECK_SCHEMA_VERSION,
265        results: input.results,
266        elapsed: input.elapsed,
267        config_fixable: input.config_fixable,
268        meta: None,
269        extras: input.extras,
270        workspace_diagnostics: input.workspace_diagnostics,
271        next_steps: Vec::new(),
272    });
273    let mut output = serde_json::to_value(envelope)?;
274    strip_json_root_prefix(&mut output, input.root);
275    Ok(output)
276}
277
278/// Build and serialize grouped dead-code JSON through the API output boundary.
279///
280/// # Errors
281///
282/// Returns a serde error when the typed envelope cannot be converted to JSON.
283pub fn serialize_grouped_check_json(
284    input: GroupedCheckJsonOutputInput<'_>,
285) -> Result<serde_json::Value, serde_json::Error> {
286    let entries = input
287        .groups
288        .iter()
289        .map(|group| {
290            let mut results = group.results.clone();
291            apply_config_fixable_to_duplicate_exports(&mut results, input.config_fixable);
292            harmonize_typed_suppress_line_actions(&mut results);
293            CheckGroupedEntry {
294                key: group.key.clone(),
295                owners: group.owners.clone(),
296                total_issues: results.total_issues(),
297                results,
298            }
299        })
300        .collect::<Vec<CheckGroupedEntry>>();
301    let mut meta = input.meta;
302    if let Some(meta) = meta.as_mut() {
303        fallow_output::retain_reported_rules(meta, entries.iter().map(|entry| &entry.results));
304    }
305
306    let envelope = CheckGroupedOutput {
307        package_baselines: input.package_baselines,
308        request_outcomes: input.request_outcomes,
309        schema_version: SchemaVersion(input.envelope.schema_version()),
310        version: ToolVersion(env!("CARGO_PKG_VERSION").to_string()),
311        elapsed_ms: ElapsedMs(input.elapsed.as_millis() as u64),
312        grouped_by: input.grouped_by,
313        total_issues: input.original.total_issues(),
314        groups: entries,
315        unused_load_data_keys_global_abstain: input.original.unused_load_data_keys_global_abstain,
316        cascade_hidden: input.original.cascade_hidden,
317        baseline_staleness: input.baseline_staleness,
318        finding_id_query: input.finding_id_query,
319        gate_outcomes: input.gate_outcomes,
320        meta,
321        workspace_diagnostics: input.workspace_diagnostics,
322        next_steps: input.next_steps,
323    };
324
325    let run_id = input.telemetry_analysis_run_id;
326    let mut output = match input.envelope {
327        CheckEnvelope::DeadCode => {
328            fallow_output::serialize_check_grouped_json_output(envelope, run_id)?
329        }
330        CheckEnvelope::Architecture => {
331            fallow_output::serialize_architecture_grouped_json_output(envelope, run_id)?
332        }
333    };
334    strip_json_root_prefix(&mut output, input.root);
335    Ok(output)
336}
337
338/// Build and serialize duplication JSON through the API-owned output boundary.
339///
340/// # Errors
341///
342/// Returns a serde error when the typed envelope cannot be converted to JSON.
343pub fn serialize_duplication_json(
344    input: DuplicationJsonOutputInput<'_>,
345) -> Result<serde_json::Value, serde_json::Error> {
346    let payload =
347        DupesReportPayload::from_report_with_fragments(input.report, input.include_fragments);
348    let mut envelope: DupesOutput<DupesReportPayload, DuplicationGroup> =
349        build_dupes_output(DupesOutputInput {
350            gate_outcomes: input.gate_outcomes,
351            request_outcomes: input.request_outcomes,
352            schema_version: DUPES_SCHEMA_VERSION,
353            version: env!("CARGO_PKG_VERSION").to_string(),
354            elapsed: input.elapsed,
355            report: payload,
356            clone_groups_shown: input.report.clone_groups_shown(),
357            clone_groups_omitted: input.report.clone_groups_omitted(),
358            clone_families_shown: input.report.clone_families_shown(),
359            clone_families_omitted: input.report.clone_families_omitted(),
360            grouped_by: None,
361            total_issues: None,
362            groups: None,
363            baseline_staleness: input.baseline_staleness,
364            meta: input.meta,
365            workspace_diagnostics: input.workspace_diagnostics,
366            next_steps: input.next_steps,
367        });
368    envelope.package_baselines = input.package_baselines;
369    let mut output =
370        fallow_output::serialize_dupes_json_output(envelope, input.telemetry_analysis_run_id)?;
371    let root_prefix = format!("{}/", input.root.display());
372    strip_root_prefix(&mut output, &root_prefix);
373    Ok(output)
374}
375
376/// Build and serialize grouped duplication JSON through the API output boundary.
377///
378/// # Errors
379///
380/// Returns a serde error when the typed envelope cannot be converted to JSON.
381pub fn serialize_grouped_duplication_json(
382    input: GroupedDuplicationJsonOutputInput<'_>,
383) -> Result<serde_json::Value, serde_json::Error> {
384    let root_prefix = format!("{}/", input.root.display());
385    let payload =
386        DupesReportPayload::from_report_with_fragments(input.report, input.include_fragments);
387    let mut envelope: DupesOutput<DupesReportPayload, DuplicationGroup> =
388        build_dupes_output(DupesOutputInput {
389            gate_outcomes: input.gate_outcomes,
390            request_outcomes: input.request_outcomes,
391            schema_version: DUPES_SCHEMA_VERSION,
392            version: env!("CARGO_PKG_VERSION").to_string(),
393            elapsed: input.elapsed,
394            report: payload,
395            clone_groups_shown: input.report.clone_groups_shown(),
396            clone_groups_omitted: input.report.clone_groups_omitted(),
397            clone_families_shown: input.report.clone_families_shown(),
398            clone_families_omitted: input.report.clone_families_omitted(),
399            grouped_by: Some(group_by_mode_from_label(input.grouping.mode)),
400            total_issues: Some(input.report.clone_groups.len()),
401            groups: None,
402            baseline_staleness: input.baseline_staleness,
403            meta: input.meta,
404            workspace_diagnostics: input.workspace_diagnostics,
405            next_steps: input.next_steps,
406        });
407    envelope.package_baselines = input.package_baselines;
408    let mut output =
409        fallow_output::serialize_dupes_json_output(envelope, input.telemetry_analysis_run_id)?;
410    strip_root_prefix(&mut output, &root_prefix);
411
412    let group_values = input
413        .grouping
414        .groups
415        .iter()
416        .map(|group| {
417            let mut value = if input.include_fragments {
418                serde_json::to_value(group)?
419            } else {
420                let mut stripped = group.clone();
421                stripped.strip_fragments();
422                serde_json::to_value(&stripped)?
423            };
424            strip_root_prefix(&mut value, &root_prefix);
425            Ok(value)
426        })
427        .collect::<Result<Vec<_>, serde_json::Error>>()?;
428
429    if let serde_json::Value::Object(ref mut map) = output {
430        map.insert("groups".to_string(), serde_json::Value::Array(group_values));
431    }
432
433    Ok(output)
434}
435
436fn build_check_json_envelope(input: CheckJsonEnvelopeInput<'_>) -> CheckOutput {
437    let mut output = build_check_output(CheckOutputInput {
438        schema_version: input.schema_version,
439        version: env!("CARGO_PKG_VERSION").to_string(),
440        elapsed: input.elapsed,
441        results: input.results.clone(),
442        config_fixable: input.config_fixable,
443        meta: input.meta,
444        workspace_diagnostics: input.workspace_diagnostics,
445        next_steps: input.next_steps,
446    });
447    output.baseline_deltas = input.extras.baseline_deltas;
448    output.baseline = input.extras.baseline;
449    output.baseline_staleness = input.extras.baseline_staleness;
450    output.regression = input.extras.regression;
451    output.gate_outcomes = input.extras.gate_outcomes;
452    output.request_outcomes = input.extras.request_outcomes;
453    output.package_baselines = input.extras.package_baselines;
454    output.finding_id_query = input.extras.finding_id_query;
455    output
456}
457
458fn strip_json_root_prefix(output: &mut serde_json::Value, root: &Path) {
459    let root_prefix = format!("{}/", root.display());
460    strip_root_prefix(output, &root_prefix);
461}
462
463fn group_by_mode_from_label(label: &str) -> GroupByMode {
464    match label {
465        "directory" => GroupByMode::Directory,
466        "package" => GroupByMode::Package,
467        "section" => GroupByMode::Section,
468        _ => GroupByMode::Owner,
469    }
470}
471
472#[cfg(test)]
473mod tests {
474    use super::*;
475    use fallow_types::workspace::WorkspaceDiagnosticKind;
476
477    #[test]
478    fn grouped_check_json_carries_workspace_diagnostics_with_relative_paths() {
479        let root = Path::new("/project");
480        let output = serialize_grouped_check_json(GroupedCheckJsonOutputInput {
481            envelope: CheckEnvelope::DeadCode,
482            package_baselines: Vec::new(),
483            gate_outcomes: None,
484            request_outcomes: None,
485            finding_id_query: None,
486            baseline_staleness: None,
487            groups: &[],
488            original: &AnalysisResults::default(),
489            root,
490            elapsed: Duration::ZERO,
491            grouped_by: GroupByMode::Directory,
492            config_fixable: false,
493            meta: None,
494            workspace_diagnostics: vec![WorkspaceDiagnostic::new(
495                root,
496                root.join("src/unreadable.ts"),
497                WorkspaceDiagnosticKind::SourceReadFailure {
498                    error: "permission denied".to_string(),
499                },
500            )],
501            next_steps: Vec::new(),
502            telemetry_analysis_run_id: None,
503        })
504        .expect("grouped check JSON serializes");
505
506        assert_eq!(
507            output["workspace_diagnostics"][0]["path"],
508            "src/unreadable.ts"
509        );
510        assert_eq!(
511            output["workspace_diagnostics"][0]["kind"],
512            "source-read-failure"
513        );
514        assert_eq!(output["kind"], "dead-code-grouped");
515        assert_eq!(output["schema_version"], CHECK_SCHEMA_VERSION);
516    }
517
518    #[test]
519    fn architecture_envelope_sets_kind_and_schema_version() {
520        let root = Path::new("/project");
521        let results = AnalysisResults::default();
522        let flat = serialize_check_json(CheckJsonOutputInput {
523            envelope: CheckEnvelope::Architecture,
524            results: &results,
525            root,
526            elapsed: Duration::ZERO,
527            config_fixable: false,
528            meta: None,
529            extras: CheckJsonExtraOutputs::default(),
530            workspace_diagnostics: Vec::new(),
531            next_steps: Vec::new(),
532            telemetry_analysis_run_id: None,
533        })
534        .expect("architecture JSON serializes");
535        assert_eq!(flat["kind"], "architecture");
536        assert_eq!(
537            flat["schema_version"],
538            fallow_output::ARCHITECTURE_SCHEMA_VERSION
539        );
540
541        let grouped = serialize_grouped_check_json(GroupedCheckJsonOutputInput {
542            envelope: CheckEnvelope::Architecture,
543            package_baselines: Vec::new(),
544            gate_outcomes: None,
545            request_outcomes: None,
546            finding_id_query: None,
547            baseline_staleness: None,
548            groups: &[],
549            original: &results,
550            root,
551            elapsed: Duration::ZERO,
552            grouped_by: GroupByMode::Directory,
553            config_fixable: false,
554            meta: None,
555            workspace_diagnostics: Vec::new(),
556            next_steps: Vec::new(),
557            telemetry_analysis_run_id: None,
558        })
559        .expect("grouped architecture JSON serializes");
560        assert_eq!(grouped["kind"], "architecture-grouped");
561        assert_eq!(
562            grouped["schema_version"],
563            fallow_output::ARCHITECTURE_SCHEMA_VERSION
564        );
565
566        let payload = serialize_check_json_payload(CheckJsonPayloadInput {
567            results: &results,
568            root,
569            elapsed: Duration::ZERO,
570            config_fixable: false,
571            extras: CheckJsonExtraOutputs::default(),
572            workspace_diagnostics: Vec::new(),
573        })
574        .expect("embedded payload serializes");
575        assert_eq!(payload["schema_version"], CHECK_SCHEMA_VERSION);
576        assert!(payload.get("kind").is_none());
577    }
578}