Skip to main content

dsfb_computer_graphics/
report.rs

1use std::collections::BTreeMap;
2use std::fmt::Write as _;
3use std::fs;
4use std::path::Path;
5
6use serde::Serialize;
7
8use crate::cost::{build_cost_report, CostMode, CostReport};
9use crate::error::Result;
10use crate::external::ExternalHandoffMetrics;
11use crate::gpu_execution::GpuExecutionMetrics;
12use crate::metrics::{
13    AblationEntry, CalibrationBin, DemoASuiteMetrics, HistogramBin, TrustOperatingMode,
14};
15use crate::sampling::{DemoBScenarioReport, DemoBSuiteMetrics};
16use crate::scaling::ResolutionScalingMetrics;
17use crate::sensitivity::ParameterSensitivityMetrics;
18use crate::timing::TimingMetrics;
19
20pub const EXPERIMENT_SENTENCE: &str =
21    "“The experiment is intended to demonstrate behavioral differences rather than establish optimal performance.”";
22pub const COST_SENTENCE: &str = "“The DSFB supervisory layer can be implemented with local operations and limited temporal memory, with expected cost scaling linearly with pixel count and amenable to reduced-resolution evaluation.”";
23pub const COMPATIBILITY_SENTENCE: &str =
24    "“The framework is compatible with tiled and asynchronous GPU execution.”";
25
26pub fn build_trust_diagnostics(demo_a: &DemoASuiteMetrics) -> TrustDiagnostics {
27    let mut scenarios = Vec::new();
28    for scenario in &demo_a.scenarios {
29        for run_id in [
30            "dsfb_host_realistic",
31            "dsfb_host_gated_reference",
32            "dsfb_motion_augmented",
33        ] {
34            if let Some(run) = scenario
35                .runs
36                .iter()
37                .find(|run| run.summary.run_id == run_id)
38            {
39                scenarios.push(TrustScenarioDiagnostic {
40                    scenario_id: scenario.scenario_id.clone(),
41                    scenario_title: scenario.scenario_title.clone(),
42                    support_category: format!("{:?}", scenario.support_category),
43                    run_id: run.summary.run_id.clone(),
44                    label: run.summary.label.clone(),
45                    roi_pixels: scenario.target_pixels,
46                    occupied_bin_count: run.summary.trust_occupied_bin_count,
47                    entropy_bits: run.summary.trust_entropy_bits,
48                    discreteness_score: run.summary.trust_discreteness_score,
49                    effective_level_count: run.summary.trust_effective_level_count,
50                    operating_mode: run.summary.trust_operating_mode,
51                    trust_error_rank_correlation: run.summary.trust_error_rank_correlation,
52                    trust_rank_correlation_is_degenerate: run
53                        .summary
54                        .trust_rank_correlation_is_degenerate,
55                    histogram: run.summary.trust_histogram.clone(),
56                    calibration_bins: run.summary.trust_calibration_bins.clone(),
57                });
58            }
59        }
60    }
61
62    let host_modes = scenarios
63        .iter()
64        .filter(|scenario| scenario.run_id == "dsfb_host_realistic")
65        .filter_map(|scenario| scenario.operating_mode)
66        .collect::<Vec<_>>();
67    let conclusion = if host_modes
68        .iter()
69        .all(|mode| matches!(mode, TrustOperatingMode::NearBinaryGate))
70    {
71        "The current host-realistic implementation behaves as a near-binary gate rather than a smoothly calibrated continuous supervisor.".to_string()
72    } else if host_modes
73        .iter()
74        .all(|mode| matches!(mode, TrustOperatingMode::StronglyGraded))
75    {
76        "The current host-realistic implementation behaves as a strongly graded supervisor on the measured suite.".to_string()
77    } else {
78        "The current host-realistic implementation is best described as weakly graded overall, with gate-like behavior on the point-ROI scenarios. The retained gated reference remains the explicitly near-binary mode.".to_string()
79    };
80
81    TrustDiagnostics {
82        conclusion,
83        scenarios,
84    }
85}
86
87pub fn write_trust_diagnostics_report(path: &Path, diagnostics: &TrustDiagnostics) -> Result<()> {
88    if let Some(parent) = path.parent() {
89        fs::create_dir_all(parent)?;
90    }
91
92    let mut markdown = String::new();
93    let _ = writeln!(markdown, "# Trust Diagnostics");
94    let _ = writeln!(markdown);
95    let _ = writeln!(markdown, "{EXPERIMENT_SENTENCE}");
96    let _ = writeln!(markdown);
97    let _ = writeln!(markdown, "{}", diagnostics.conclusion);
98    let _ = writeln!(markdown);
99    let _ = writeln!(
100        markdown,
101        "| Scenario | Run | ROI pixels | Occupied bins | Entropy (bits) | Mode | Correlation note |"
102    );
103    let _ = writeln!(markdown, "| --- | --- | ---: | ---: | ---: | --- | --- |");
104    for entry in &diagnostics.scenarios {
105        let _ = writeln!(
106            markdown,
107            "| {} | {} | {} | {} | {:.3} | {:?} | {} |",
108            entry.scenario_id,
109            entry.run_id,
110            entry.roi_pixels,
111            entry.occupied_bin_count,
112            entry.entropy_bits.unwrap_or(0.0),
113            entry.operating_mode,
114            if entry.trust_rank_correlation_is_degenerate {
115                "degenerate, not decision-facing"
116            } else {
117                "non-degenerate"
118            }
119        );
120    }
121    let _ = writeln!(markdown);
122    let _ = writeln!(markdown, "## What Is Not Proven");
123    let _ = writeln!(markdown);
124    let _ = writeln!(
125        markdown,
126        "- These diagnostics do not prove probabilistic calibration in the statistical sense."
127    );
128    let _ = writeln!(
129        markdown,
130        "- Point-ROI scenarios remain weak evidence for smooth trust calibration even when they are mechanically useful."
131    );
132    let _ = writeln!(markdown);
133    let _ = writeln!(markdown, "## Remaining Blockers");
134    let _ = writeln!(markdown);
135    let _ = writeln!(
136        markdown,
137        "- The current trust signal still needs broader region-scale evidence and real-engine traces before it can be called broadly calibrated."
138    );
139
140    fs::write(path, markdown)?;
141    Ok(())
142}
143
144pub fn write_timing_report(path: &Path, timing: &TimingMetrics) -> Result<()> {
145    if let Some(parent) = path.parent() {
146        fs::create_dir_all(parent)?;
147    }
148
149    let mut markdown = String::new();
150    let _ = writeln!(markdown, "# Timing Report");
151    let _ = writeln!(markdown);
152    let _ = writeln!(markdown, "{EXPERIMENT_SENTENCE}");
153    let _ = writeln!(markdown);
154    let _ = writeln!(
155        markdown,
156        "Measurement classification: `{}`.",
157        timing.measurement_kind
158    );
159    let _ = writeln!(markdown);
160    let _ = writeln!(
161        markdown,
162        "Actual GPU timing measured: `{}`.",
163        timing.actual_gpu_timing
164    );
165    let _ = writeln!(markdown);
166    for note in &timing.notes {
167        let _ = writeln!(markdown, "- {note}");
168    }
169    let _ = writeln!(markdown);
170    let _ = writeln!(
171        markdown,
172        "| Label | Mode | Scenario | Resolution | Build | Total ms | ms / frame | Ops / px | Traffic MB |"
173    );
174    let _ = writeln!(
175        markdown,
176        "| --- | --- | --- | --- | --- | ---: | ---: | ---: | ---: |"
177    );
178    for entry in &timing.entries {
179        let _ = writeln!(
180            markdown,
181            "| {} | {} | {} | {}x{} | {} | {:.3} | {:.3} | {} | {:.2} |",
182            entry.label,
183            entry.mode,
184            entry.scenario_id,
185            entry.width,
186            entry.height,
187            entry.build_profile,
188            entry.total_ms,
189            entry.ms_per_frame,
190            entry.estimated_ops_per_pixel,
191            entry.estimated_memory_traffic_megabytes
192        );
193    }
194    let _ = writeln!(markdown);
195    let _ = writeln!(markdown, "## Per-Stage Breakdown");
196    let _ = writeln!(markdown);
197    for entry in &timing.entries {
198        let _ = writeln!(markdown, "### {}", entry.label);
199        let _ = writeln!(markdown);
200        let _ = writeln!(markdown, "| Stage | Total ms | ms / frame | ns / pixel |");
201        let _ = writeln!(markdown, "| --- | ---: | ---: | ---: |");
202        for stage in &entry.stages {
203            let _ = writeln!(
204                markdown,
205                "| {} | {:.3} | {:.3} | {:.3} |",
206                stage.stage, stage.total_ms, stage.ms_per_frame, stage.ns_per_pixel
207            );
208        }
209        let _ = writeln!(markdown);
210        let _ = writeln!(markdown, "Likely optimization levers:");
211        for lever in &entry.likely_optimization_levers {
212            let _ = writeln!(markdown, "- {lever}");
213        }
214        let _ = writeln!(markdown);
215    }
216    let _ = writeln!(markdown, "## What Is Not Proven");
217    let _ = writeln!(markdown);
218    let _ = writeln!(
219        markdown,
220        "- This report does not contain measured GPU milliseconds."
221    );
222    let _ = writeln!(
223        markdown,
224        "- It does not justify any production deployment performance claim."
225    );
226    let _ = writeln!(
227        markdown,
228        "- External validation is still required on real engine-exported buffers and target GPU hardware."
229    );
230    let _ = writeln!(markdown);
231    let _ = writeln!(markdown, "## Remaining Blockers");
232    let _ = writeln!(markdown);
233    let _ = writeln!(
234        markdown,
235        "- Real GPU execution and memory-system measurements remain outstanding."
236    );
237    let _ = writeln!(
238        markdown,
239        "- External handoff is available, but externally validated timing data is still absent."
240    );
241
242    fs::write(path, markdown)?;
243    Ok(())
244}
245
246pub fn write_resolution_scaling_report(
247    path: &Path,
248    scaling: &ResolutionScalingMetrics,
249) -> Result<()> {
250    if let Some(parent) = path.parent() {
251        fs::create_dir_all(parent)?;
252    }
253
254    let mut markdown = String::new();
255    let _ = writeln!(markdown, "# Resolution Scaling Report");
256    let _ = writeln!(markdown);
257    let _ = writeln!(markdown, "{EXPERIMENT_SENTENCE}");
258    let _ = writeln!(markdown);
259    let _ = writeln!(
260        markdown,
261        "| Tier | Scenario | Resolution | ROI pixels | ROI fraction | Host ROI MAE | Host vs fixed gain | Motion vs host gain | Memory MB |"
262    );
263    let _ = writeln!(
264        markdown,
265        "| --- | --- | --- | ---: | ---: | ---: | ---: | ---: | ---: |"
266    );
267    for entry in &scaling.entries {
268        let _ = writeln!(
269            markdown,
270            "| {} | {} | {}x{} | {} | {:.5} | {:.5} | {:.5} | {:.5} | {:.2} |",
271            entry.tier_id,
272            entry.scenario_id,
273            entry.width,
274            entry.height,
275            entry.target_pixels,
276            entry.target_area_fraction,
277            entry.host_realistic_cumulative_roi_mae,
278            entry.host_realistic_vs_fixed_alpha_gain,
279            entry.motion_augmented_vs_host_realistic_gain,
280            entry.buffer_memory_megabytes
281        );
282    }
283    let _ = writeln!(markdown);
284    for note in &scaling.notes {
285        let _ = writeln!(markdown, "- {note}");
286    }
287    let _ = writeln!(markdown);
288    let _ = writeln!(markdown, "## What Is Not Proven");
289    let _ = writeln!(markdown);
290    let _ = writeln!(
291        markdown,
292        "- This report is a structural scaling study, not a production-scene benchmark."
293    );
294    let _ = writeln!(
295        markdown,
296        "- External validation is still required to show that the same scaling behavior survives real engine-exported buffers."
297    );
298    let _ = writeln!(markdown);
299    let _ = writeln!(markdown, "## Remaining Blockers");
300    let _ = writeln!(markdown);
301    let _ = writeln!(
302        markdown,
303        "- A full 1080p or 4K full-suite run with real hardware timing remains future work."
304    );
305    let _ = writeln!(
306        markdown,
307        "- External handoff exists, but no externally validated scaling study is included here."
308    );
309
310    fs::write(path, markdown)?;
311    Ok(())
312}
313
314pub fn write_parameter_sensitivity_report(
315    path: &Path,
316    sensitivity: &ParameterSensitivityMetrics,
317) -> Result<()> {
318    if let Some(parent) = path.parent() {
319        fs::create_dir_all(parent)?;
320    }
321
322    let mut markdown = String::new();
323    let _ = writeln!(markdown, "# Parameter Sensitivity Report");
324    let _ = writeln!(markdown);
325    let _ = writeln!(markdown, "{EXPERIMENT_SENTENCE}");
326    let _ = writeln!(markdown);
327    let _ = writeln!(markdown, "Baseline mode: {}.", sensitivity.baseline_mode);
328    let _ = writeln!(markdown);
329    let _ = writeln!(
330        markdown,
331        "| Parameter | Mode | Value | Benefit wins vs fixed | Zero-ghost benefit scenarios | Canonical ROI MAE | Region mean ROI MAE | Motion-bias ROI MAE | Neutral non-ROI MAE | Robust corridor | Robustness |"
332    );
333    let _ = writeln!(
334        markdown,
335        "| --- | --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | --- | --- |"
336    );
337    for point in &sensitivity.sweep_points {
338        let _ = writeln!(
339            markdown,
340            "| {} | {} | {:.3} | {} | {} | {:.5} | {:.5} | {:.5} | {:.5} | {} | {} |",
341            point.parameter_id,
342            point.profile_mode,
343            point.numeric_value,
344            point.benefit_scenarios_beating_fixed,
345            point.benefit_scenarios_with_zero_ghost_frames,
346            point.canonical_cumulative_roi_mae,
347            point.region_mean_cumulative_roi_mae,
348            point.motion_bias_cumulative_roi_mae,
349            point.neutral_non_roi_mae,
350            if point.robust_corridor_member {
351                "yes"
352            } else {
353                "no"
354            },
355            point.robustness_class
356        );
357    }
358    let _ = writeln!(markdown);
359    for note in &sensitivity.notes {
360        let _ = writeln!(markdown, "- {note}");
361    }
362    let _ = writeln!(markdown);
363    let _ = writeln!(
364        markdown,
365        "- `robust` means the main benefit cases remain intact with bounded motion-bias and neutral-scene degradation."
366    );
367    let _ = writeln!(
368        markdown,
369        "- `moderately_sensitive` means the conclusion survives, but with narrower safety margin."
370    );
371    let _ = writeln!(
372        markdown,
373        "- `fragile` means the headline behavior or neutral-scene bound degrades materially."
374    );
375    let _ = writeln!(markdown);
376    let _ = writeln!(markdown, "## What Is Not Proven");
377    let _ = writeln!(markdown);
378    let _ = writeln!(
379        markdown,
380        "- These sweeps do not claim global optimality or statistically complete calibration."
381    );
382    let _ = writeln!(markdown);
383    let _ = writeln!(markdown, "## Remaining Blockers");
384    let _ = writeln!(markdown);
385    let _ = writeln!(
386        markdown,
387        "- Parameters are now centralized and sensitivity-vetted, but they are still hand-set rather than trained on an external benchmark."
388    );
389
390    fs::write(path, markdown)?;
391    Ok(())
392}
393
394pub fn write_demo_b_efficiency_report(path: &Path, demo_b: &DemoBSuiteMetrics) -> Result<()> {
395    if let Some(parent) = path.parent() {
396        fs::create_dir_all(parent)?;
397    }
398    let mut markdown = String::new();
399    let _ = writeln!(markdown, "# Demo B Efficiency Report");
400    let _ = writeln!(markdown);
401    let _ = writeln!(markdown, "{EXPERIMENT_SENTENCE}");
402    let _ = writeln!(markdown);
403    let _ = writeln!(
404        markdown,
405        "This report separates aliasing-limited thin-point cases from variance-limited and mixed-width region cases so fixed-budget wins are not attributed only to sub-pixel line recovery."
406    );
407    let _ = writeln!(markdown);
408    let _ = writeln!(markdown, "| Scenario | Policy | Mean spp | ROI MAE |");
409    let _ = writeln!(markdown, "| --- | --- | ---: | ---: |");
410    for curve in &demo_b.budget_efficiency_curves {
411        for point in &curve.points {
412            let _ = writeln!(
413                markdown,
414                "| {} | {} | {:.1} | {:.5} |",
415                curve.scenario_id, curve.policy_id, point.average_spp, point.roi_mae
416            );
417        }
418    }
419    let _ = writeln!(markdown);
420    let _ = writeln!(markdown, "## Scenario Taxonomy");
421    let _ = writeln!(markdown);
422    for scenario in &demo_b.scenarios {
423        let _ = writeln!(
424            markdown,
425            "- `{}`: taxonomy=`{}`, sampling_taxonomy=`{}`",
426            scenario.scenario_id, scenario.demo_b_taxonomy, scenario.sampling_taxonomy
427        );
428    }
429    let _ = writeln!(markdown);
430    let _ = writeln!(markdown, "## What Is Not Proven");
431    let _ = writeln!(markdown);
432    let _ = writeln!(
433        markdown,
434        "- This study does not prove an optimal sampling controller or general renderer superiority."
435    );
436    let _ = writeln!(
437        markdown,
438        "- External validation is still required on real renderer noise and imported engine buffers."
439    );
440    let _ = writeln!(markdown);
441    let _ = writeln!(markdown, "## Remaining Blockers");
442    let _ = writeln!(markdown);
443    let _ = writeln!(
444        markdown,
445        "- Demo B remains synthetic and still needs real-engine noise and shading complexity for full production confidence."
446    );
447    let _ = writeln!(
448        markdown,
449        "- External handoff exists for Demo A style supervision, but Demo B still lacks an external renderer allocation trace."
450    );
451    fs::write(path, markdown)?;
452    Ok(())
453}
454
455#[derive(Clone, Debug)]
456pub struct CompletionNoteStatus {
457    pub only_files_inside_crate_changed: bool,
458    pub upgrade_plan_written: bool,
459    pub host_realistic_mode_implemented: bool,
460    pub stronger_baselines_implemented: bool,
461    pub scenario_suite_implemented: bool,
462    pub ablation_study_implemented: bool,
463    pub demo_b_strengthened: bool,
464    pub integration_surface_documented: bool,
465    pub cost_model_generated: bool,
466    pub reviewer_reports_generated: bool,
467    pub required_honesty_sentence_present: bool,
468    pub cargo_fmt_passed: bool,
469    pub cargo_clippy_passed: bool,
470    pub cargo_test_passed: bool,
471    pub no_fabricated_performance_claims: bool,
472    pub no_files_outside_crate_modified: bool,
473    pub fully_implemented: Vec<String>,
474    pub future_work: Vec<String>,
475}
476
477#[derive(Clone, Debug, Serialize)]
478pub struct TrustScenarioDiagnostic {
479    pub scenario_id: String,
480    pub scenario_title: String,
481    pub support_category: String,
482    pub run_id: String,
483    pub label: String,
484    pub roi_pixels: usize,
485    pub occupied_bin_count: usize,
486    pub entropy_bits: Option<f32>,
487    pub discreteness_score: Option<f32>,
488    pub effective_level_count: Option<usize>,
489    pub operating_mode: Option<TrustOperatingMode>,
490    pub trust_error_rank_correlation: Option<f32>,
491    pub trust_rank_correlation_is_degenerate: bool,
492    pub histogram: Vec<HistogramBin>,
493    pub calibration_bins: Vec<CalibrationBin>,
494}
495
496#[derive(Clone, Debug, Serialize)]
497pub struct TrustDiagnostics {
498    pub conclusion: String,
499    pub scenarios: Vec<TrustScenarioDiagnostic>,
500}
501
502pub fn write_report(
503    path: &Path,
504    demo_a: &DemoASuiteMetrics,
505    demo_b: &DemoBSuiteMetrics,
506    cost_report: &CostReport,
507) -> Result<()> {
508    if let Some(parent) = path.parent() {
509        fs::create_dir_all(parent)?;
510    }
511
512    let canonical = &demo_a.scenarios[0];
513    let mut markdown = String::new();
514    let _ = writeln!(markdown, "# DSFB Computer Graphics Evaluation Report");
515    let _ = writeln!(markdown);
516    let _ = writeln!(markdown, "## Scope");
517    let _ = writeln!(markdown);
518    let _ = writeln!(
519        markdown,
520        "This crate is a deterministic, crate-local evaluation artifact for temporal reuse supervision and fixed-budget adaptive sampling."
521    );
522    let _ = writeln!(markdown);
523    let _ = writeln!(markdown, "{EXPERIMENT_SENTENCE}");
524    let _ = writeln!(markdown);
525    let _ = writeln!(
526        markdown,
527        "What is demonstrated: host-realistic DSFB supervision, stronger heuristic baselines, multi-scenario behavior, ablation sensitivity, fixed-budget allocation comparisons, attachability surfaces, and architectural cost accounting."
528    );
529    let _ = writeln!(markdown);
530    let _ = writeln!(
531        markdown,
532        "What is not proven: production-scene generalization, measured GPU benchmark wins, engine deployment readiness, or universal superiority over strong heuristics."
533    );
534    let _ = writeln!(markdown);
535    let _ = writeln!(markdown, "## Scenario Suite");
536    let _ = writeln!(markdown);
537    for scenario in &demo_a.scenarios {
538        let _ = writeln!(
539            markdown,
540            "- `{}`: {}",
541            scenario.scenario_id, scenario.scenario_description
542        );
543    }
544    let _ = writeln!(markdown);
545    let _ = writeln!(markdown, "## Demo A Baselines and DSFB Variants");
546    let _ = writeln!(markdown);
547    let _ = writeln!(
548        markdown,
549        "Baselines: fixed alpha, residual threshold, neighborhood clamp, depth/normal rejection, reactive-mask-style, and strong heuristic."
550    );
551    let _ = writeln!(markdown);
552    let _ = writeln!(
553        markdown,
554        "DSFB variants: visibility-assisted synthetic mode, host-realistic mode, no-visibility, no-thin, no-motion, no-grammar, residual-only, and trust-without-alpha-modulation."
555    );
556    let _ = writeln!(markdown);
557    let _ = writeln!(markdown, "## Canonical Headline");
558    let _ = writeln!(markdown);
559    let _ = writeln!(markdown, "{}", demo_a.summary.primary_behavioral_result);
560    let _ = writeln!(markdown);
561    let _ = writeln!(markdown, "{}", demo_a.summary.secondary_behavioral_result);
562    let _ = writeln!(markdown);
563    let _ = writeln!(markdown, "{}", canonical.headline);
564    let _ = writeln!(markdown);
565    let _ = writeln!(markdown, "## Per-Scenario Outcome Summary");
566    let _ = writeln!(markdown);
567    let _ = writeln!(
568        markdown,
569        "| Scenario | Expectation | Host vs fixed ROI gain | Host vs strong heuristic ROI gain | Non-ROI penalty vs fixed | Note |"
570    );
571    let _ = writeln!(markdown, "| --- | --- | ---: | ---: | ---: | --- |");
572    for scenario in &demo_a.scenarios {
573        let _ = writeln!(
574            markdown,
575            "| {} | {:?} | {:.5} | {:.5} | {:.5} | {} |",
576            scenario.scenario_title,
577            scenario.expectation,
578            scenario.host_realistic_vs_fixed_alpha_cumulative_roi_gain,
579            scenario.host_realistic_vs_strong_heuristic_cumulative_roi_gain,
580            scenario.host_realistic_non_roi_penalty_vs_fixed_alpha,
581            scenario.bounded_or_neutral_note
582        );
583    }
584    let _ = writeln!(markdown);
585    let _ = writeln!(markdown, "## Ablation Summary");
586    let _ = writeln!(markdown);
587    let _ = writeln!(
588        markdown,
589        "| Variant | Canonical cumulative ROI MAE | Canonical peak ROI MAE | Suite mean cumulative ROI MAE | Suite mean false-positive rate |"
590    );
591    let _ = writeln!(markdown, "| --- | ---: | ---: | ---: | ---: |");
592    for entry in &demo_a.ablations {
593        let _ = writeln!(
594            markdown,
595            "| {} | {:.5} | {:.5} | {:.5} | {:.5} |",
596            entry.label,
597            entry.canonical_cumulative_roi_mae,
598            entry.canonical_peak_roi_mae,
599            entry.suite_mean_cumulative_roi_mae,
600            entry.suite_mean_false_positive_response_rate
601        );
602    }
603    let _ = writeln!(markdown);
604    let _ = writeln!(markdown, "## Demo B Fixed-Budget Study");
605    let _ = writeln!(markdown);
606    let _ = writeln!(markdown, "{}", demo_b.summary.primary_behavioral_result);
607    let _ = writeln!(markdown);
608    let _ = writeln!(
609        markdown,
610        "| Scenario | Imported trust ROI MAE | Combined heuristic ROI MAE | Uniform ROI MAE | Note |"
611    );
612    let _ = writeln!(markdown, "| --- | ---: | ---: | ---: | --- |");
613    for scenario in &demo_b.scenarios {
614        let trust = find_policy(scenario, "imported_trust");
615        let combined = find_policy(scenario, "combined_heuristic");
616        let uniform = find_policy(scenario, "uniform");
617        if let (Some(trust), Some(combined), Some(uniform)) = (trust, combined, uniform) {
618            let _ = writeln!(
619                markdown,
620                "| {} | {:.5} | {:.5} | {:.5} | {} |",
621                scenario.scenario_title,
622                trust.roi_mae,
623                combined.roi_mae,
624                uniform.roi_mae,
625                scenario.bounded_note
626            );
627        }
628    }
629    let _ = writeln!(markdown);
630    let _ = writeln!(markdown, "## Attachability");
631    let _ = writeln!(markdown);
632    let _ = writeln!(
633        markdown,
634        "The host integration surface is implemented around typed current color, history color, motion vectors, depth, normals, trust, alpha, intervention, and optional sampling-budget outputs. See `docs/integration_surface.md`."
635    );
636    let _ = writeln!(markdown);
637    let _ = writeln!(markdown, "## Cost Model");
638    let _ = writeln!(markdown);
639    let _ = writeln!(markdown, "{COST_SENTENCE}");
640    let _ = writeln!(markdown);
641    let _ = writeln!(markdown, "{COMPATIBILITY_SENTENCE}");
642    let _ = writeln!(markdown);
643    let _ = writeln!(
644        markdown,
645        "| Mode | Buffers | Approx ops / pixel | Approx reads / pixel | Approx writes / pixel |"
646    );
647    let _ = writeln!(markdown, "| --- | ---: | ---: | ---: | ---: |");
648    for mode in [
649        CostMode::Minimal,
650        CostMode::HostRealistic,
651        CostMode::FullResearchDebug,
652    ] {
653        let report = if mode == cost_report.mode {
654            cost_report.clone()
655        } else {
656            build_cost_report(mode)
657        };
658        let _ = writeln!(
659            markdown,
660            "| {} | {} | {} | {} | {} |",
661            mode.label(),
662            report.buffers.len(),
663            report.estimated_total_ops_per_pixel,
664            report.estimated_total_reads_per_pixel,
665            report.estimated_total_writes_per_pixel
666        );
667    }
668    let _ = writeln!(markdown);
669    let _ = writeln!(markdown, "## Aggregate Leaderboard");
670    let _ = writeln!(markdown);
671    let _ = writeln!(
672        markdown,
673        "| Run | Mean rank | Mean cumulative ROI MAE | Mean non-ROI MAE | Benefit-scenario wins |"
674    );
675    let _ = writeln!(markdown, "| --- | ---: | ---: | ---: | ---: |");
676    for entry in demo_a.aggregate_leaderboard.iter().take(10) {
677        let _ = writeln!(
678            markdown,
679            "| {} | {:.2} | {:.5} | {:.5} | {} |",
680            entry.label,
681            entry.mean_rank,
682            entry.mean_cumulative_roi_mae,
683            entry.mean_non_roi_mae,
684            entry.benefit_scenarios_won
685        );
686    }
687    let _ = writeln!(markdown);
688    let _ = writeln!(markdown, "## Remaining Blockers");
689    let _ = writeln!(markdown);
690    for blocker in &demo_a.summary.remaining_blockers {
691        let _ = writeln!(markdown, "- {blocker}");
692    }
693    let _ = writeln!(markdown);
694    let _ = writeln!(markdown, "## What Is Not Proven");
695    let _ = writeln!(markdown);
696    let _ = writeln!(
697        markdown,
698        "- This report does not prove production-scene generalization."
699    );
700    let _ = writeln!(
701        markdown,
702        "- This report does not prove that DSFB beats every strong heuristic on every scenario."
703    );
704    let _ = writeln!(
705        markdown,
706        "- This report does not claim measured GPU hardware wins or production readiness."
707    );
708
709    fs::write(path, markdown)?;
710    Ok(())
711}
712
713pub fn write_reviewer_summary(
714    path: &Path,
715    demo_a: &DemoASuiteMetrics,
716    demo_b: &DemoBSuiteMetrics,
717) -> Result<()> {
718    if let Some(parent) = path.parent() {
719        fs::create_dir_all(parent)?;
720    }
721
722    let mut markdown = String::new();
723    let _ = writeln!(markdown, "# Reviewer Summary");
724    let _ = writeln!(markdown);
725    let _ = writeln!(markdown, "{}", demo_a.summary.primary_behavioral_result);
726    let _ = writeln!(markdown);
727    let _ = writeln!(markdown, "{}", demo_b.summary.primary_behavioral_result);
728    let _ = writeln!(markdown);
729    let _ = writeln!(
730        markdown,
731        "What is now decision-clean: host-realistic mode exists, stronger baselines are included, multiple deterministic scenarios are reported, ablations isolate cue dependence, Demo B is fixed-budget across multiple policies, and attachability/cost are explicit."
732    );
733    let _ = writeln!(markdown);
734    let _ = writeln!(
735        markdown,
736        "What is still blocked: synthetic scene scope, lack of measured GPU benchmarks, and mixed outcomes against the strongest heuristic baseline on some scenarios."
737    );
738    let _ = writeln!(markdown);
739    let _ = writeln!(
740        markdown,
741        "This crate is ready for internal technical evaluation and funding diligence. It is not presented as a production-readiness or licensing-closing proof."
742    );
743
744    fs::write(path, markdown)?;
745    Ok(())
746}
747
748pub fn write_five_mentor_audit(
749    path: &Path,
750    demo_a: &DemoASuiteMetrics,
751    demo_b: &DemoBSuiteMetrics,
752) -> Result<()> {
753    if let Some(parent) = path.parent() {
754        fs::create_dir_all(parent)?;
755    }
756
757    let mut markdown = String::new();
758    let sections = [
759        (
760            "SBIR / Toyon",
761            "Passes: bounded replayable evidence, host-style interface, multi-scenario report, remaining blockers stated openly.\nStill blocks: synthetic-only scope and no fielded deployment evidence.\nConfidence: ready for funding diligence.\nNext step: engine-side trace replay or mission-adjacent integration pilot.",
762        ),
763        (
764            "NVIDIA",
765            "Passes: stronger heuristic baselines, host-realistic cues, temporal attachability surface, multi-scenario TAA analysis.\nStill blocks: no measured GPU implementation and strong heuristic can remain competitive.\nConfidence: ready for evaluation.\nNext step: implement a reduced-resolution GPU pass and compare against an engine reactive-mask stack.",
766        ),
767        (
768            "AMD / Intel",
769            "Passes: explicit buffer model, local-operation cost accounting, tiled/async compatibility statement, fixed-budget fairness in Demo B.\nStill blocks: no measured cache/bandwidth data on real hardware.\nConfidence: ready for evaluation.\nNext step: hardware profiling pass with half-resolution and tile aggregation variants.",
770        ),
771        (
772            "Academic",
773            "Passes: deterministic suite, ablations, stronger baselines, neutral-case honesty, replayable figures and reports.\nStill blocks: synthetic breadth is still limited and there is no external benchmark corpus.\nConfidence: ready for evaluation.\nNext step: add richer published benchmark scenes and statistical robustness sweeps.",
774        ),
775        (
776            "Licensing / Strategy",
777            "Passes: attachable supervisory-layer shape, logging/trust outputs, explicit integration surfaces, and blocker-aware reporting.\nStill blocks: no external customer validation and no engine integration case study.\nConfidence: ready for licensing diligence.\nNext step: package the host interface into an engine-adjacent prototype and gather partner feedback.",
778        ),
779    ];
780
781    let _ = writeln!(markdown, "# Five Mentor Audit");
782    let _ = writeln!(markdown);
783    let _ = writeln!(
784        markdown,
785        "Demo A: {}",
786        demo_a.summary.primary_behavioral_result
787    );
788    let _ = writeln!(markdown);
789    let _ = writeln!(
790        markdown,
791        "Demo B: {}",
792        demo_b.summary.primary_behavioral_result
793    );
794    let _ = writeln!(markdown);
795    for (title, body) in sections {
796        let _ = writeln!(markdown, "## {title}");
797        let _ = writeln!(markdown);
798        for line in body.split('\n') {
799            let _ = writeln!(markdown, "{line}");
800        }
801        let _ = writeln!(markdown);
802    }
803
804    fs::write(path, markdown)?;
805    Ok(())
806}
807
808pub fn write_check_signing_blockers(path: &Path, demo_a: &DemoASuiteMetrics) -> Result<()> {
809    if let Some(parent) = path.parent() {
810        fs::create_dir_all(parent)?;
811    }
812    let mut markdown = String::new();
813    let _ = writeln!(markdown, "# Blocker Check");
814    let _ = writeln!(markdown);
815    let _ = writeln!(markdown, "## Removed");
816    let _ = writeln!(markdown);
817    let _ = writeln!(markdown, "- Host-realistic DSFB mode exists and is reported separately from visibility-assisted mode.");
818    let _ = writeln!(
819        markdown,
820        "- Stronger baselines are present and scored across multiple scenarios."
821    );
822    let _ = writeln!(
823        markdown,
824        "- A bounded neutral scenario is included to expose false positives."
825    );
826    let _ = writeln!(
827        markdown,
828        "- Demo B enforces fixed-budget fairness across multiple policies."
829    );
830    let _ = writeln!(markdown);
831    let _ = writeln!(markdown, "## Partially Removed");
832    let _ = writeln!(markdown);
833    let _ = writeln!(markdown, "- Strong heuristic baselines are now explicit, but they remain competitive on some scenarios.");
834    let _ = writeln!(markdown, "- Cost confidence is better because buffers and stages are explicit, but hardware validation remains undone.");
835    let _ = writeln!(markdown);
836    let _ = writeln!(markdown, "## Remaining");
837    let _ = writeln!(markdown);
838    for blocker in &demo_a.summary.remaining_blockers {
839        let _ = writeln!(markdown, "- {blocker}");
840    }
841
842    fs::write(path, markdown)?;
843    Ok(())
844}
845
846pub fn write_ablation_report(path: &Path, entries: &[AblationEntry]) -> Result<()> {
847    if let Some(parent) = path.parent() {
848        fs::create_dir_all(parent)?;
849    }
850    let mut markdown = String::new();
851    let _ = writeln!(markdown, "# Ablation Report");
852    let _ = writeln!(markdown);
853    let _ = writeln!(markdown, "{EXPERIMENT_SENTENCE}");
854    let _ = writeln!(markdown);
855    let _ = writeln!(
856        markdown,
857        "This report answers which cues materially drive the effect and how much survives host-realistic mode."
858    );
859    let _ = writeln!(markdown);
860    let _ = writeln!(
861        markdown,
862        "| Variant | Canonical cumulative ROI MAE | Suite mean cumulative ROI MAE | Suite mean false-positive rate |"
863    );
864    let _ = writeln!(markdown, "| --- | ---: | ---: | ---: |");
865    for entry in entries {
866        let _ = writeln!(
867            markdown,
868            "| {} | {:.5} | {:.5} | {:.5} |",
869            entry.label,
870            entry.canonical_cumulative_roi_mae,
871            entry.suite_mean_cumulative_roi_mae,
872            entry.suite_mean_false_positive_response_rate
873        );
874    }
875
876    fs::write(path, markdown)?;
877    Ok(())
878}
879
880pub fn write_demo_b_decision_report(path: &Path, demo_b: &DemoBSuiteMetrics) -> Result<()> {
881    if let Some(parent) = path.parent() {
882        fs::create_dir_all(parent)?;
883    }
884    let mut markdown = String::new();
885    let _ = writeln!(markdown, "# Demo B Decision Report");
886    let _ = writeln!(markdown);
887    let _ = writeln!(markdown, "{EXPERIMENT_SENTENCE}");
888    let _ = writeln!(markdown);
889    let _ = writeln!(markdown, "{}", demo_b.summary.primary_behavioral_result);
890    let _ = writeln!(markdown);
891    let _ = writeln!(
892        markdown,
893        "This report explicitly separates aliasing recovery on point-like thin features from allocation quality on mixed-width, variance-limited, and edge-trap region cases under fixed-budget equality."
894    );
895    let _ = writeln!(markdown);
896    for scenario in &demo_b.scenarios {
897        let _ = writeln!(markdown, "## {}", scenario.scenario_title);
898        let _ = writeln!(markdown);
899        let _ = writeln!(
900            markdown,
901            "Taxonomy: `{}`. Sampling taxonomy: `{}`. Support category: `{:?}`.",
902            scenario.demo_b_taxonomy, scenario.sampling_taxonomy, scenario.support_category
903        );
904        let _ = writeln!(markdown);
905        let _ = writeln!(markdown, "{}", scenario.headline);
906        let _ = writeln!(markdown);
907        let _ = writeln!(markdown, "{}", scenario.bounded_note);
908        let _ = writeln!(markdown);
909    }
910    let _ = writeln!(markdown, "## What is not proven");
911    let _ = writeln!(markdown);
912    let _ = writeln!(
913        markdown,
914        "- This study does not prove an optimal sampling controller."
915    );
916    let _ = writeln!(
917        markdown,
918        "- It does not prove that imported trust beats every cheap heuristic on every scene."
919    );
920    let _ = writeln!(
921        markdown,
922        "- It does not claim production renderer integration."
923    );
924    let _ = writeln!(
925        markdown,
926        "- External validation is still required before extending these conclusions to real renderer sample allocation."
927    );
928    let _ = writeln!(markdown);
929    let _ = writeln!(markdown, "## Remaining Blockers");
930    let _ = writeln!(markdown);
931    let _ = writeln!(
932        markdown,
933        "- Demo B still lacks real-engine shading complexity and measured rendering hardware runs."
934    );
935    let _ = writeln!(
936        markdown,
937        "- External handoff for imported supervision exists, but no external sample-allocation capture is included."
938    );
939
940    fs::write(path, markdown)?;
941    Ok(())
942}
943
944pub fn write_cost_report(path: &Path, report: &CostReport) -> Result<()> {
945    if let Some(parent) = path.parent() {
946        fs::create_dir_all(parent)?;
947    }
948    let mut markdown = String::new();
949    let _ = writeln!(markdown, "# Cost Report");
950    let _ = writeln!(markdown);
951    let _ = writeln!(markdown, "{EXPERIMENT_SENTENCE}");
952    let _ = writeln!(markdown);
953    let _ = writeln!(markdown, "{COST_SENTENCE}");
954    let _ = writeln!(markdown);
955    let _ = writeln!(markdown, "{COMPATIBILITY_SENTENCE}");
956    let _ = writeln!(markdown);
957    let _ = writeln!(markdown, "## Mode");
958    let _ = writeln!(markdown);
959    let _ = writeln!(markdown, "- {}", report.mode.label());
960    let _ = writeln!(markdown);
961    let _ = writeln!(markdown, "## Buffers");
962    let _ = writeln!(markdown);
963    let _ = writeln!(markdown, "| Buffer | Bytes / pixel | Notes |");
964    let _ = writeln!(markdown, "| --- | ---: | --- |");
965    for buffer in &report.buffers {
966        let _ = writeln!(
967            markdown,
968            "| {} | {} | {} |",
969            buffer.name, buffer.bytes_per_pixel, buffer.notes
970        );
971    }
972    let _ = writeln!(markdown);
973    let _ = writeln!(markdown, "## Stages");
974    let _ = writeln!(markdown);
975    let _ = writeln!(
976        markdown,
977        "| Stage | Approx ops / pixel | Reads / pixel | Writes / pixel | Reduction note |"
978    );
979    let _ = writeln!(markdown, "| --- | ---: | ---: | ---: | --- |");
980    for stage in &report.stages {
981        let _ = writeln!(
982            markdown,
983            "| {} | {} | {} | {} | {} |",
984            stage.stage,
985            stage.approximate_ops_per_pixel,
986            stage.approximate_reads_per_pixel,
987            stage.approximate_writes_per_pixel,
988            stage.reduction_note
989        );
990    }
991    let _ = writeln!(markdown);
992    let _ = writeln!(markdown, "## Resolution Footprints");
993    let _ = writeln!(markdown);
994    let _ = writeln!(markdown, "| Resolution | Pixels | Approx memory (MB) |");
995    let _ = writeln!(markdown, "| --- | ---: | ---: |");
996    for footprint in &report.footprints {
997        let _ = writeln!(
998            markdown,
999            "| {}x{} | {} | {:.2} |",
1000            footprint.width, footprint.height, footprint.total_pixels, footprint.memory_megabytes
1001        );
1002    }
1003    let _ = writeln!(markdown);
1004    let _ = writeln!(markdown, "## Notes");
1005    let _ = writeln!(markdown);
1006    for note in &report.notes {
1007        let _ = writeln!(markdown, "- {note}");
1008    }
1009
1010    fs::write(path, markdown)?;
1011    Ok(())
1012}
1013
1014pub fn write_completion_note(path: &Path, status: &CompletionNoteStatus) -> Result<()> {
1015    if let Some(parent) = path.parent() {
1016        fs::create_dir_all(parent)?;
1017    }
1018    let mut markdown = String::new();
1019    let _ = writeln!(markdown, "# Completion Note");
1020    let _ = writeln!(markdown);
1021    let _ = writeln!(markdown, "{EXPERIMENT_SENTENCE}");
1022    let _ = writeln!(markdown);
1023    let _ = writeln!(markdown, "## Checklist");
1024    let _ = writeln!(markdown);
1025    checklist(
1026        &mut markdown,
1027        status.only_files_inside_crate_changed,
1028        "Only files inside crates/dsfb-computer-graphics were changed",
1029    );
1030    checklist(
1031        &mut markdown,
1032        status.upgrade_plan_written,
1033        "Upgrade plan was written inside the crate",
1034    );
1035    checklist(
1036        &mut markdown,
1037        status.host_realistic_mode_implemented,
1038        "Host-realistic DSFB mode is implemented",
1039    );
1040    checklist(
1041        &mut markdown,
1042        status.stronger_baselines_implemented,
1043        "Stronger baselines are implemented",
1044    );
1045    checklist(
1046        &mut markdown,
1047        status.scenario_suite_implemented,
1048        "Scenario suite is implemented",
1049    );
1050    checklist(
1051        &mut markdown,
1052        status.ablation_study_implemented,
1053        "Ablation study is implemented",
1054    );
1055    checklist(
1056        &mut markdown,
1057        status.demo_b_strengthened,
1058        "Demo B fixed-budget study is strengthened",
1059    );
1060    checklist(
1061        &mut markdown,
1062        status.integration_surface_documented,
1063        "Integration surface is documented",
1064    );
1065    checklist(
1066        &mut markdown,
1067        status.cost_model_generated,
1068        "Cost model report is generated",
1069    );
1070    checklist(
1071        &mut markdown,
1072        status.reviewer_reports_generated,
1073        "Reviewer reports are generated",
1074    );
1075    checklist(
1076        &mut markdown,
1077        status.required_honesty_sentence_present,
1078        "Required honesty sentence is present",
1079    );
1080    checklist(&mut markdown, status.cargo_fmt_passed, "cargo fmt passed");
1081    checklist(
1082        &mut markdown,
1083        status.cargo_clippy_passed,
1084        "cargo clippy passed",
1085    );
1086    checklist(&mut markdown, status.cargo_test_passed, "cargo test passed");
1087    checklist(
1088        &mut markdown,
1089        status.no_fabricated_performance_claims,
1090        "No fabricated performance claims were made",
1091    );
1092    checklist(
1093        &mut markdown,
1094        status.no_files_outside_crate_modified,
1095        "No files outside the crate were modified",
1096    );
1097    let _ = writeln!(markdown);
1098    let _ = writeln!(markdown, "## Fully Implemented");
1099    let _ = writeln!(markdown);
1100    for item in &status.fully_implemented {
1101        let _ = writeln!(markdown, "- {item}");
1102    }
1103    let _ = writeln!(markdown);
1104    let _ = writeln!(markdown, "## Future Work");
1105    let _ = writeln!(markdown);
1106    for item in &status.future_work {
1107        let _ = writeln!(markdown, "- {item}");
1108    }
1109    fs::write(path, markdown)?;
1110    Ok(())
1111}
1112
1113pub fn write_full_report(
1114    path: &Path,
1115    demo_a: &DemoASuiteMetrics,
1116    demo_b: &DemoBSuiteMetrics,
1117    cost_report: &CostReport,
1118    trust: &TrustDiagnostics,
1119    timing: &TimingMetrics,
1120    gpu: &GpuExecutionMetrics,
1121    external: &ExternalHandoffMetrics,
1122    scaling: &ResolutionScalingMetrics,
1123    sensitivity: &ParameterSensitivityMetrics,
1124) -> Result<()> {
1125    if let Some(parent) = path.parent() {
1126        fs::create_dir_all(parent)?;
1127    }
1128
1129    let mut markdown = String::new();
1130    let _ = writeln!(markdown, "# DSFB Computer Graphics Evaluation Report");
1131    let _ = writeln!(markdown);
1132    let _ = writeln!(markdown, "{EXPERIMENT_SENTENCE}");
1133    let _ = writeln!(markdown);
1134    let _ = writeln!(markdown, "## Scope");
1135    let _ = writeln!(markdown);
1136    let _ = writeln!(
1137        markdown,
1138        "This artifact is a deterministic crate-local evaluation package for temporal-reuse supervision and fixed-budget sampling allocation. It is intended to clear diligence blockers honestly, not to imply production readiness."
1139    );
1140    let _ = writeln!(markdown);
1141    let _ = writeln!(markdown, "## ROI Disclosure");
1142    let _ = writeln!(markdown);
1143    let _ = writeln!(
1144        markdown,
1145        "| Scenario | Support category | ROI pixels | ROI fraction | Disclosure |"
1146    );
1147    let _ = writeln!(markdown, "| --- | --- | ---: | ---: | --- |");
1148    for scenario in &demo_a.scenarios {
1149        let _ = writeln!(
1150            markdown,
1151            "| {} | {:?} | {} | {:.5} | {} |",
1152            scenario.scenario_id,
1153            scenario.support_category,
1154            scenario.target_pixels,
1155            scenario.target_area_fraction,
1156            scenario.roi_note
1157        );
1158    }
1159    let _ = writeln!(markdown);
1160    let _ = writeln!(markdown, "Point-like ROI scenarios are kept because they remain mechanically relevant, but they are not mixed with region-ROI evidence without explicit disclosure.");
1161    let _ = writeln!(markdown);
1162    let _ = writeln!(markdown, "## Scenario Outcomes");
1163    let _ = writeln!(markdown);
1164    let _ = writeln!(
1165        markdown,
1166        "| Scenario | Expectation | Tags | Host vs fixed ROI gain | Host vs strong ROI gain | Non-ROI penalty vs strong | Clamp trigger mean | Note |"
1167    );
1168    let _ = writeln!(
1169        markdown,
1170        "| --- | --- | --- | ---: | ---: | ---: | ---: | --- |"
1171    );
1172    for scenario in &demo_a.scenarios {
1173        let tags = scenario_tags(scenario);
1174        let _ = writeln!(
1175            markdown,
1176            "| {} | {:?} | {} | {:.5} | {:.5} | {:.5} | {:.5} | {} |",
1177            scenario.scenario_id,
1178            scenario.expectation,
1179            tags.join(", "),
1180            scenario.host_realistic_vs_fixed_alpha_cumulative_roi_gain,
1181            scenario.host_realistic_vs_strong_heuristic_cumulative_roi_gain,
1182            scenario.host_realistic_non_roi_penalty_vs_strong_heuristic,
1183            scenario.neighborhood_clamp_roi_trigger_mean,
1184            scenario.bounded_or_neutral_note
1185        );
1186    }
1187    let _ = writeln!(markdown);
1188    let _ = writeln!(markdown, "## Trust Diagnostics");
1189    let _ = writeln!(markdown);
1190    let _ = writeln!(markdown, "{}", trust.conclusion);
1191    let _ = writeln!(markdown);
1192    let _ = writeln!(
1193        markdown,
1194        "Degenerate trust-error rank correlations are retained only as diagnostics and are not used here as decision-facing calibration evidence."
1195    );
1196    let _ = writeln!(markdown);
1197    let _ = writeln!(markdown, "## Motion Disagreement Decision");
1198    let _ = writeln!(markdown);
1199    let motion_bias = demo_a
1200        .scenarios
1201        .iter()
1202        .find(|scenario| scenario.scenario_id == "motion_bias_band");
1203    if let Some(scenario) = motion_bias {
1204        let motion = scenario
1205            .runs
1206            .iter()
1207            .find(|run| run.summary.run_id == "dsfb_motion_augmented");
1208        let host = scenario
1209            .runs
1210            .iter()
1211            .find(|run| run.summary.run_id == "dsfb_host_realistic");
1212        if let (Some(motion), Some(host)) = (motion, host) {
1213            let _ = writeln!(
1214                markdown,
1215                "The minimum host-realistic path excludes motion disagreement. On `motion_bias_band`, the optional motion-augmented path changed cumulative ROI MAE from {:.5} to {:.5}. That makes motion disagreement an optional extension rather than a minimum-path requirement.",
1216                host.summary.cumulative_roi_mae,
1217                motion.summary.cumulative_roi_mae
1218            );
1219        }
1220    }
1221    let _ = writeln!(markdown);
1222    let _ = writeln!(markdown, "## Demo B Confound Handling");
1223    let _ = writeln!(markdown);
1224    let _ = writeln!(markdown, "{}", demo_b.summary.primary_behavioral_result);
1225    let _ = writeln!(markdown);
1226    let _ = writeln!(
1227        markdown,
1228        "Demo B now includes aliasing-limited, variance-limited, edge-trap, and mixed-width region cases alongside the original thin-point case, and reports equal-budget curves at 1, 2, 4, and 8 mean spp. The goal is to separate aliasing recovery from structurally better allocation."
1229    );
1230    let _ = writeln!(markdown);
1231    let _ = writeln!(markdown, "## External Handoff Bridge");
1232    let _ = writeln!(markdown);
1233    let _ = writeln!(
1234        markdown,
1235        "External import status: external-capable = `{}`, externally validated = `{}`. Source kind used in the generated handoff example: `{}`.",
1236        external.external_capable, external.externally_validated, external.source_kind
1237    );
1238    let _ = writeln!(markdown);
1239    let _ = writeln!(
1240        markdown,
1241        "The crate can now import current color, reprojected history, motion vectors, depth, and normals through a stable manifest/schema without re-architecting the evaluator."
1242    );
1243    let _ = writeln!(markdown);
1244    let _ = writeln!(markdown, "## Resolution Scaling");
1245    let _ = writeln!(markdown);
1246    for note in &scaling.notes {
1247        let _ = writeln!(markdown, "- {note}");
1248    }
1249    let _ = writeln!(markdown);
1250    let _ = writeln!(markdown, "## Timing Path");
1251    let _ = writeln!(markdown);
1252    let _ = writeln!(
1253        markdown,
1254        "Timing classification: `{}`. Actual GPU timing measured: `{}`.",
1255        timing.measurement_kind, timing.actual_gpu_timing
1256    );
1257    let _ = writeln!(markdown);
1258    let _ = writeln!(markdown, "## GPU Execution Path");
1259    let _ = writeln!(markdown);
1260    let _ = writeln!(
1261        markdown,
1262        "GPU execution classification: `{}`. Actual GPU timing measured: `{}`.",
1263        gpu.measurement_kind, gpu.actual_gpu_timing_measured
1264    );
1265    let _ = writeln!(markdown);
1266    let _ = writeln!(
1267        markdown,
1268        "A real `wgpu` compute kernel for the minimum host-realistic supervisory path is now in the crate. If no adapter is present, the generated GPU report states that explicitly instead of implying measurement."
1269    );
1270    let _ = writeln!(markdown);
1271    let _ = writeln!(markdown, "## Cost Model");
1272    let _ = writeln!(markdown);
1273    let _ = writeln!(markdown, "{COST_SENTENCE}");
1274    let _ = writeln!(markdown);
1275    let _ = writeln!(markdown, "{COMPATIBILITY_SENTENCE}");
1276    let _ = writeln!(markdown);
1277    let _ = writeln!(
1278        markdown,
1279        "| Mode | Buffers | Ops / px | Reads / px | Writes / px |"
1280    );
1281    let _ = writeln!(markdown, "| --- | ---: | ---: | ---: | ---: |");
1282    for mode in [
1283        CostMode::Minimal,
1284        CostMode::HostRealistic,
1285        CostMode::FullResearchDebug,
1286    ] {
1287        let report = if mode == cost_report.mode {
1288            cost_report.clone()
1289        } else {
1290            build_cost_report(mode)
1291        };
1292        let _ = writeln!(
1293            markdown,
1294            "| {} | {} | {} | {} | {} |",
1295            mode.label(),
1296            report.buffers.len(),
1297            report.estimated_total_ops_per_pixel,
1298            report.estimated_total_reads_per_pixel,
1299            report.estimated_total_writes_per_pixel
1300        );
1301    }
1302    let _ = writeln!(markdown);
1303    let _ = writeln!(markdown, "## Parameter Sensitivity");
1304    let _ = writeln!(markdown);
1305    let robust_count = sensitivity
1306        .sweep_points
1307        .iter()
1308        .filter(|point| point.robust_corridor_member)
1309        .count();
1310    let _ = writeln!(
1311        markdown,
1312        "Centralized hazard weights are still hand-set, but they are now sensitivity-vetted. Robust corridor sweep points found: {} of {}.",
1313        robust_count,
1314        sensitivity.sweep_points.len()
1315    );
1316    let _ = writeln!(markdown);
1317    let _ = writeln!(markdown, "## What Is Proven");
1318    let _ = writeln!(markdown);
1319    let _ = writeln!(
1320        markdown,
1321        "- The supervisory effect is real under a host-realistic minimum path, not only with privileged visibility hints."
1322    );
1323    let _ = writeln!(
1324        markdown,
1325        "- Point-like ROI evidence and region-ROI evidence are now reported separately."
1326    );
1327    let _ = writeln!(
1328        markdown,
1329        "- Motion disagreement is no longer treated as mandatory in the minimum path."
1330    );
1331    let _ = writeln!(
1332        markdown,
1333        "- Demo B no longer relies only on the original thin sub-pixel case."
1334    );
1335    let _ = writeln!(
1336        markdown,
1337        "- A file-based external buffer handoff path now exists for engine-adjacent evaluation."
1338    );
1339    let _ = writeln!(
1340        markdown,
1341        "- A GPU-executable minimum kernel now exists even when the current environment cannot measure it."
1342    );
1343    let _ = writeln!(markdown);
1344    let _ = writeln!(markdown, "## What Is Not Proven");
1345    let _ = writeln!(markdown);
1346    let _ = writeln!(
1347        markdown,
1348        "- This artifact does not prove production-scene generalization."
1349    );
1350    let _ = writeln!(
1351        markdown,
1352        "- It does not prove measured GPU wins or production deployment performance."
1353    );
1354    let _ = writeln!(
1355        markdown,
1356        "- It does not prove globally calibrated trust or globally optimal parameter settings."
1357    );
1358    let _ = writeln!(
1359        markdown,
1360        "- It does not prove external engine validation merely because the import schema now exists."
1361    );
1362    let _ = writeln!(markdown);
1363    let _ = writeln!(markdown, "## Remaining Blockers");
1364    let _ = writeln!(markdown);
1365    for blocker in &demo_a.summary.remaining_blockers {
1366        let _ = writeln!(markdown, "- {blocker}");
1367    }
1368    if !gpu.actual_gpu_timing_measured {
1369        let _ = writeln!(markdown, "- Real GPU execution data remains outstanding.");
1370    }
1371    let _ = writeln!(
1372        markdown,
1373        "- External engine traces and broader scene diversity remain future work."
1374    );
1375    let _ = writeln!(
1376        markdown,
1377        "- Strong heuristic baselines remain competitive on some scenarios, so the correct framing remains a targeted supervisory overlay rather than a general-purpose replacement."
1378    );
1379
1380    fs::write(path, markdown)?;
1381    Ok(())
1382}
1383
1384pub fn write_full_reviewer_summary(
1385    path: &Path,
1386    demo_a: &DemoASuiteMetrics,
1387    demo_b: &DemoBSuiteMetrics,
1388    trust: &TrustDiagnostics,
1389    timing: &TimingMetrics,
1390    gpu: &GpuExecutionMetrics,
1391    external: &ExternalHandoffMetrics,
1392) -> Result<()> {
1393    if let Some(parent) = path.parent() {
1394        fs::create_dir_all(parent)?;
1395    }
1396    let mut markdown = String::new();
1397    let point_like = demo_a
1398        .scenarios
1399        .iter()
1400        .filter(|scenario| {
1401            matches!(
1402                scenario.support_category,
1403                crate::scene::ScenarioSupportCategory::PointLikeRoi
1404            )
1405        })
1406        .map(|scenario| format!("{}={} px", scenario.scenario_id, scenario.target_pixels))
1407        .collect::<Vec<_>>()
1408        .join(", ");
1409    let _ = writeln!(markdown, "# Reviewer Summary");
1410    let _ = writeln!(markdown);
1411    let _ = writeln!(markdown, "{}", demo_a.summary.primary_behavioral_result);
1412    let _ = writeln!(markdown);
1413    let _ = writeln!(markdown, "{}", demo_b.summary.primary_behavioral_result);
1414    let _ = writeln!(markdown);
1415    let _ = writeln!(
1416        markdown,
1417        "Point-like ROI disclosure: {}. These remain mechanically relevant but statistically weak and are not treated as region-scale aggregate evidence.",
1418        point_like
1419    );
1420    let _ = writeln!(markdown);
1421    let _ = writeln!(markdown, "Trust conclusion: {}", trust.conclusion);
1422    let _ = writeln!(markdown);
1423    let _ = writeln!(
1424        markdown,
1425        "Timing conclusion: `{}` with actual GPU timing measured = `{}`.",
1426        timing.measurement_kind, timing.actual_gpu_timing
1427    );
1428    let _ = writeln!(markdown);
1429    let _ = writeln!(
1430        markdown,
1431        "GPU bridge conclusion: `{}` with actual GPU timing measured = `{}`.",
1432        gpu.measurement_kind, gpu.actual_gpu_timing_measured
1433    );
1434    let _ = writeln!(markdown);
1435    let _ = writeln!(
1436        markdown,
1437        "External bridge conclusion: external-capable = `{}`, externally validated = `{}`.",
1438        external.external_capable, external.externally_validated
1439    );
1440    let _ = writeln!(markdown);
1441    let _ = writeln!(markdown, "What is still blocked:");
1442    let _ = writeln!(markdown, "- broader external scene validation");
1443    let _ = writeln!(markdown, "- engine-side GPU profiling on imported captures");
1444    if !gpu.actual_gpu_timing_measured {
1445        let _ = writeln!(markdown, "- real GPU execution measurements");
1446    }
1447    let _ = writeln!(markdown);
1448    let _ = writeln!(markdown, "What is now decision-clean:");
1449    let _ = writeln!(markdown, "- host-realistic minimum path is explicit");
1450    let _ = writeln!(markdown, "- point vs region ROI evidence is separated");
1451    let _ = writeln!(
1452        markdown,
1453        "- motion disagreement is optional rather than hidden in the minimum path"
1454    );
1455    let _ = writeln!(
1456        markdown,
1457        "- Demo B includes region and mixed-width evidence"
1458    );
1459    let _ = writeln!(markdown, "- weights are centralized and sensitivity-vetted");
1460    let _ = writeln!(
1461        markdown,
1462        "- a real GPU-executable kernel exists in the crate"
1463    );
1464    let _ = writeln!(
1465        markdown,
1466        "- external buffers can be imported through a stable manifest"
1467    );
1468    let _ = writeln!(markdown);
1469    let _ = writeln!(markdown, "## What Is Not Proven");
1470    let _ = writeln!(markdown);
1471    if !gpu.actual_gpu_timing_measured {
1472        let _ = writeln!(markdown, "- no actual GPU timing in this environment");
1473    }
1474    let _ = writeln!(markdown, "- no production-scene or engine deployment proof");
1475    let _ = writeln!(markdown);
1476    let _ = writeln!(markdown, "## Remaining Blockers");
1477    let _ = writeln!(markdown);
1478    let _ = writeln!(markdown, "- broader external scene validation");
1479    let _ = writeln!(markdown, "- engine-side GPU profiling on imported captures");
1480    if !gpu.actual_gpu_timing_measured {
1481        let _ = writeln!(markdown, "- real GPU execution measurements");
1482    }
1483    fs::write(path, markdown)?;
1484    Ok(())
1485}
1486
1487pub fn write_full_five_mentor_audit(
1488    path: &Path,
1489    demo_a: &DemoASuiteMetrics,
1490    demo_b: &DemoBSuiteMetrics,
1491    _timing: &TimingMetrics,
1492    gpu: &GpuExecutionMetrics,
1493    external: &ExternalHandoffMetrics,
1494) -> Result<()> {
1495    if let Some(parent) = path.parent() {
1496        fs::create_dir_all(parent)?;
1497    }
1498    let mut markdown = String::new();
1499    let point_like = demo_a
1500        .scenarios
1501        .iter()
1502        .filter(|scenario| {
1503            matches!(
1504                scenario.support_category,
1505                crate::scene::ScenarioSupportCategory::PointLikeRoi
1506            )
1507        })
1508        .map(|scenario| format!("{}={} px", scenario.scenario_id, scenario.target_pixels))
1509        .collect::<Vec<_>>()
1510        .join(", ");
1511    let _ = writeln!(markdown, "# Five Mentor Audit");
1512    let _ = writeln!(markdown);
1513    let _ = writeln!(
1514        markdown,
1515        "Demo A: {}",
1516        demo_a.summary.primary_behavioral_result
1517    );
1518    let _ = writeln!(markdown);
1519    let _ = writeln!(
1520        markdown,
1521        "Demo B: {}",
1522        demo_b.summary.primary_behavioral_result
1523    );
1524    let _ = writeln!(markdown);
1525    let _ = writeln!(
1526        markdown,
1527        "Point-like ROI disclosure: {}. Region-sized scenarios are reported separately for decision-facing aggregate claims.",
1528        point_like
1529    );
1530    let _ = writeln!(markdown);
1531    let gpu_line = if gpu.actual_gpu_timing_measured {
1532        "Measured GPU timing is available."
1533    } else {
1534        "A GPU-executable path exists, but this environment did not produce measured GPU timing."
1535    };
1536    for (title, readiness, passes, blockers) in [
1537        (
1538            "SBIR / Toyon",
1539            "ready for evaluation",
1540            "multi-scenario host-realistic evidence, explicit blockers, fail-loud validation, and evaluator handoff package",
1541            "synthetic-only scope and no fielded integration",
1542        ),
1543        (
1544            "NVIDIA",
1545            "ready for evaluation",
1546            "GPU-executable minimum kernel exists, minimum path is explicit, and motion extension is isolated",
1547            "no measured engine-integrated GPU execution; strong heuristic still competitive on some scenarios",
1548        ),
1549        (
1550            "AMD / Intel",
1551            "ready for evaluation",
1552            "buffer, traffic, scaling, and external import surfaces are explicit",
1553            "no hardware cache/bandwidth measurements on real imported captures",
1554        ),
1555        (
1556            "Academic",
1557            "ready for evaluation",
1558            "honest ROI disclosure, ablations, trust diagnostics, sensitivity sweeps, and scenario taxonomy",
1559            "synthetic breadth and no external benchmark corpus",
1560        ),
1561        (
1562            "Licensing / Strategy",
1563            "ready for evaluation",
1564            "decision-facing reports show what passes, what ties, what external data is needed, and what to test next",
1565            "no engine case study or customer validation",
1566        ),
1567    ] {
1568        let _ = writeln!(markdown, "## {title}");
1569        let _ = writeln!(markdown);
1570        let _ = writeln!(markdown, "Passes: {passes}.");
1571        let _ = writeln!(markdown);
1572        let _ = writeln!(markdown, "Still blocks: {blockers}.");
1573        let _ = writeln!(markdown);
1574        let _ = writeln!(markdown, "Timing note: {gpu_line}");
1575        let _ = writeln!(markdown);
1576        let _ = writeln!(
1577            markdown,
1578            "External handoff note: external-capable = `{}`, externally validated = `{}`.",
1579            external.external_capable, external.externally_validated
1580        );
1581        let _ = writeln!(markdown);
1582        let _ = writeln!(markdown, "Readiness: {readiness}.");
1583        let _ = writeln!(markdown);
1584    }
1585    let _ = writeln!(markdown, "## What Is Not Proven");
1586    let _ = writeln!(markdown);
1587    let _ = writeln!(
1588        markdown,
1589        "- This audit does not claim funding close, licensing close, or deployment readiness."
1590    );
1591    let _ = writeln!(markdown);
1592    let _ = writeln!(markdown, "## Remaining Blockers");
1593    let _ = writeln!(markdown);
1594    if !gpu.actual_gpu_timing_measured {
1595        let _ = writeln!(markdown, "- real GPU measurements");
1596    }
1597    let _ = writeln!(markdown, "- external engine validation");
1598    fs::write(path, markdown)?;
1599    Ok(())
1600}
1601
1602pub fn write_full_check_signing_blockers(
1603    path: &Path,
1604    demo_a: &DemoASuiteMetrics,
1605    _timing: &TimingMetrics,
1606    gpu: &GpuExecutionMetrics,
1607    external: &ExternalHandoffMetrics,
1608) -> Result<()> {
1609    if let Some(parent) = path.parent() {
1610        fs::create_dir_all(parent)?;
1611    }
1612    let mut markdown = String::new();
1613    let point_like = demo_a
1614        .scenarios
1615        .iter()
1616        .filter(|scenario| {
1617            matches!(
1618                scenario.support_category,
1619                crate::scene::ScenarioSupportCategory::PointLikeRoi
1620            )
1621        })
1622        .map(|scenario| format!("{}={} px", scenario.scenario_id, scenario.target_pixels))
1623        .collect::<Vec<_>>()
1624        .join(", ");
1625    let _ = writeln!(markdown, "# Blocker Check");
1626    let _ = writeln!(markdown);
1627    let _ = writeln!(
1628        markdown,
1629        "Point-like ROI disclosure: {}. These cases are no longer buried inside region-ROI aggregate claims.",
1630        point_like
1631    );
1632    let _ = writeln!(markdown);
1633    let _ = writeln!(markdown, "## Removed");
1634    let _ = writeln!(markdown);
1635    let _ = writeln!(markdown, "- Point-like ROI evidence is now labeled explicitly instead of being mixed into aggregate claims.");
1636    let _ = writeln!(markdown, "- Trust rank correlation is no longer used as a headline calibration claim when degenerate.");
1637    let _ = writeln!(
1638        markdown,
1639        "- Motion disagreement is not hidden in the minimum host-realistic path."
1640    );
1641    let _ = writeln!(
1642        markdown,
1643        "- Hazard weights are centralized and sensitivity-vetted."
1644    );
1645    let _ = writeln!(
1646        markdown,
1647        "- Demo B includes mixed-width region cases and equal-budget efficiency curves."
1648    );
1649    let _ = writeln!(
1650        markdown,
1651        "- An external buffer schema and file-based import path now exist."
1652    );
1653    let _ = writeln!(markdown);
1654    let _ = writeln!(markdown, "## Partially Removed");
1655    let _ = writeln!(markdown);
1656    let _ = writeln!(
1657        markdown,
1658        "- GPU timing is addressed by a GPU-executable kernel and an honest measured-vs-unmeasured path, but actual GPU measurements are still missing here: `{}`.",
1659        gpu.actual_gpu_timing_measured
1660    );
1661    let _ = writeln!(
1662        markdown,
1663        "- Trust behavior is now described honestly, but broad calibration claims still remain blocked by limited scene diversity."
1664    );
1665    let _ = writeln!(
1666        markdown,
1667        "- The crate is external-capable, but externally validated remains `{}`.",
1668        external.externally_validated
1669    );
1670    let _ = writeln!(markdown);
1671    let _ = writeln!(markdown, "## Remaining");
1672    let _ = writeln!(markdown);
1673    for blocker in &demo_a.summary.remaining_blockers {
1674        let _ = writeln!(markdown, "- {blocker}");
1675    }
1676    if !gpu.actual_gpu_timing_measured {
1677        let _ = writeln!(markdown, "- Actual GPU execution measurements.");
1678    }
1679    let _ = writeln!(markdown);
1680    let _ = writeln!(markdown, "## What Is Not Proven");
1681    let _ = writeln!(markdown);
1682    let _ = writeln!(
1683        markdown,
1684        "- This file does not claim all diligence blockers are removed."
1685    );
1686    let _ = writeln!(markdown);
1687    let _ = writeln!(markdown, "## Remaining Blockers");
1688    let _ = writeln!(markdown);
1689    let _ = writeln!(markdown, "- synthetic-only scope");
1690    let _ = writeln!(markdown, "- no production-scene engine integration");
1691    fs::write(path, markdown)?;
1692    Ok(())
1693}
1694
1695pub fn write_realism_suite_report(path: &Path, demo_a: &DemoASuiteMetrics) -> Result<()> {
1696    if let Some(parent) = path.parent() {
1697        fs::create_dir_all(parent)?;
1698    }
1699    let mut markdown = String::new();
1700    let _ = writeln!(markdown, "# Realism Suite Report");
1701    let _ = writeln!(markdown);
1702    let _ = writeln!(markdown, "{EXPERIMENT_SENTENCE}");
1703    let _ = writeln!(markdown);
1704    let _ = writeln!(
1705        markdown,
1706        "| Scenario | Support | Tags | ROI pixels | ROI fraction | Host vs fixed ROI gain | Host vs strong ROI gain |"
1707    );
1708    let _ = writeln!(markdown, "| --- | --- | --- | ---: | ---: | ---: | ---: |");
1709    for scenario in &demo_a.scenarios {
1710        let _ = writeln!(
1711            markdown,
1712            "| {} | {:?} | {} | {} | {:.5} | {:.5} | {:.5} |",
1713            scenario.scenario_id,
1714            scenario.support_category,
1715            scenario_tags(scenario).join(", "),
1716            scenario.target_pixels,
1717            scenario.target_area_fraction,
1718            scenario.host_realistic_vs_fixed_alpha_cumulative_roi_gain,
1719            scenario.host_realistic_vs_strong_heuristic_cumulative_roi_gain
1720        );
1721    }
1722    let _ = writeln!(markdown);
1723    let _ = writeln!(markdown, "## What Is Proven");
1724    let _ = writeln!(markdown);
1725    let _ = writeln!(
1726        markdown,
1727        "- The suite now contains explicit realism-stress and competitive-baseline cases alongside point-ROI and region-ROI evidence."
1728    );
1729    let _ = writeln!(markdown);
1730    let _ = writeln!(markdown, "## What Is Not Proven");
1731    let _ = writeln!(markdown);
1732    let _ = writeln!(
1733        markdown,
1734        "- These scenarios are still synthetic and do not replace external renderer captures."
1735    );
1736    let _ = writeln!(markdown);
1737    let _ = writeln!(markdown, "## Remaining Blockers");
1738    let _ = writeln!(markdown);
1739    let _ = writeln!(
1740        markdown,
1741        "- Real production-scene generalization still requires external captures."
1742    );
1743    fs::write(path, markdown)?;
1744    Ok(())
1745}
1746
1747pub fn write_realism_bridge_report(path: &Path, demo_a: &DemoASuiteMetrics) -> Result<()> {
1748    if let Some(parent) = path.parent() {
1749        fs::create_dir_all(parent)?;
1750    }
1751    let point_roi = demo_a.summary.point_roi_scenarios.len();
1752    let region_roi = demo_a.summary.region_roi_scenarios.len();
1753    let realism_stress = demo_a
1754        .scenarios
1755        .iter()
1756        .filter(|scenario| scenario.realism_stress)
1757        .count();
1758    let competitive = demo_a
1759        .scenarios
1760        .iter()
1761        .filter(|scenario| scenario.competitive_baseline_case)
1762        .count();
1763    let bounded = demo_a
1764        .scenarios
1765        .iter()
1766        .filter(|scenario| scenario.bounded_loss_disclosure)
1767        .count();
1768
1769    let mut markdown = String::new();
1770    let _ = writeln!(markdown, "# Realism Bridge Report");
1771    let _ = writeln!(markdown);
1772    let _ = writeln!(markdown, "{EXPERIMENT_SENTENCE}");
1773    let _ = writeln!(markdown);
1774    let _ = writeln!(
1775        markdown,
1776        "Region-ROI evidence, realism-stress probes, competitive-baseline cases, and bounded-neutral controls now carry the main empirical load instead of leaving the story concentrated in point-ROI stress tests."
1777    );
1778    let _ = writeln!(markdown);
1779    let _ = writeln!(markdown, "- Point-ROI scenarios: `{point_roi}`");
1780    let _ = writeln!(markdown, "- Region-ROI scenarios: `{region_roi}`");
1781    let _ = writeln!(markdown, "- Realism-stress scenarios: `{realism_stress}`");
1782    let _ = writeln!(
1783        markdown,
1784        "- Strong-heuristic-competitive scenarios: `{competitive}`"
1785    );
1786    let _ = writeln!(
1787        markdown,
1788        "- Bounded-neutral or bounded-loss disclosures: `{bounded}`"
1789    );
1790    let _ = writeln!(markdown);
1791    let _ = writeln!(
1792        markdown,
1793        "| Scenario | Support | Tags | ROI pixels | Host vs fixed ROI gain | Host vs strong ROI gain | Bounded note |"
1794    );
1795    let _ = writeln!(markdown, "| --- | --- | --- | ---: | ---: | ---: | --- |");
1796    for scenario in &demo_a.scenarios {
1797        let _ = writeln!(
1798            markdown,
1799            "| {} | {:?} | {} | {} | {:.5} | {:.5} | {} |",
1800            scenario.scenario_id,
1801            scenario.support_category,
1802            scenario_tags(scenario).join(", "),
1803            scenario.target_pixels,
1804            scenario.host_realistic_vs_fixed_alpha_cumulative_roi_gain,
1805            scenario.host_realistic_vs_strong_heuristic_cumulative_roi_gain,
1806            scenario.bounded_or_neutral_note
1807        );
1808    }
1809    let _ = writeln!(markdown);
1810    let _ = writeln!(markdown, "## What Is Proven");
1811    let _ = writeln!(markdown);
1812    let _ = writeln!(
1813        markdown,
1814        "- The crate now exposes a broader synthetic realism bridge with explicit external-handoff relevance instead of a narrow point-ROI-only story."
1815    );
1816    let _ = writeln!(markdown);
1817    let _ = writeln!(markdown, "## What Is Not Proven");
1818    let _ = writeln!(markdown);
1819    let _ = writeln!(
1820        markdown,
1821        "- These scenarios remain synthetic and do not replace external engine captures or production image content."
1822    );
1823    let _ = writeln!(markdown);
1824    let _ = writeln!(markdown, "## Remaining Blockers");
1825    let _ = writeln!(markdown);
1826    let _ = writeln!(
1827        markdown,
1828        "- The realism bridge still needs external replay on real engine buffers before it can be treated as production-adjacent evidence."
1829    );
1830    fs::write(path, markdown)?;
1831    Ok(())
1832}
1833
1834pub fn write_trust_mode_report(path: &Path, diagnostics: &TrustDiagnostics) -> Result<()> {
1835    if let Some(parent) = path.parent() {
1836        fs::create_dir_all(parent)?;
1837    }
1838    let region_entries = diagnostics
1839        .scenarios
1840        .iter()
1841        .filter(|entry| entry.run_id == "dsfb_host_realistic")
1842        .filter(|entry| entry.support_category.contains("RegionRoi"))
1843        .collect::<Vec<_>>();
1844    let mut mode_counts: BTreeMap<String, usize> = BTreeMap::new();
1845    for entry in diagnostics
1846        .scenarios
1847        .iter()
1848        .filter(|entry| entry.run_id == "dsfb_host_realistic")
1849    {
1850        *mode_counts
1851            .entry(
1852                entry
1853                    .operating_mode
1854                    .map(|mode| format!("{mode:?}"))
1855                    .unwrap_or_else(|| "Unknown".to_string()),
1856            )
1857            .or_insert(0) += 1;
1858    }
1859
1860    let mut markdown = String::new();
1861    let _ = writeln!(markdown, "# Trust Mode Report");
1862    let _ = writeln!(markdown);
1863    let _ = writeln!(markdown, "{EXPERIMENT_SENTENCE}");
1864    let _ = writeln!(markdown);
1865    let _ = writeln!(markdown, "{}", diagnostics.conclusion);
1866    let _ = writeln!(markdown);
1867    let _ = writeln!(markdown, "## Operating Mode Counts");
1868    let _ = writeln!(markdown);
1869    for (mode, count) in mode_counts {
1870        let _ = writeln!(markdown, "- `{mode}`: `{count}` host-realistic scenarios");
1871    }
1872    let _ = writeln!(markdown);
1873    let _ = writeln!(
1874        markdown,
1875        "| Region-ROI scenario | Occupied bins | Effective levels | Entropy (bits) | Discreteness | Mode | Correlation note |"
1876    );
1877    let _ = writeln!(markdown, "| --- | ---: | ---: | ---: | ---: | --- | --- |");
1878    for entry in region_entries {
1879        let _ = writeln!(
1880            markdown,
1881            "| {} | {} | {} | {:.3} | {:.3} | {} | {} |",
1882            entry.scenario_id,
1883            entry.occupied_bin_count,
1884            entry
1885                .effective_level_count
1886                .map(|value| value.to_string())
1887                .unwrap_or_else(|| "n/a".to_string()),
1888            entry.entropy_bits.unwrap_or(0.0),
1889            entry.discreteness_score.unwrap_or(0.0),
1890            entry
1891                .operating_mode
1892                .map(|mode| format!("{mode:?}"))
1893                .unwrap_or_else(|| "Unknown".to_string()),
1894            if entry.trust_rank_correlation_is_degenerate {
1895                "degenerate, not decision-facing"
1896            } else {
1897                "non-degenerate"
1898            }
1899        );
1900    }
1901    let _ = writeln!(markdown);
1902    let _ = writeln!(markdown, "## What Is Proven");
1903    let _ = writeln!(markdown);
1904    let _ = writeln!(
1905        markdown,
1906        "- The trust signal is now described according to its actual operating mode instead of being overstated as smoothly calibrated."
1907    );
1908    let _ = writeln!(markdown);
1909    let _ = writeln!(markdown, "## What Is Not Proven");
1910    let _ = writeln!(markdown);
1911    let _ = writeln!(
1912        markdown,
1913        "- This report does not claim externally validated probabilistic calibration."
1914    );
1915    let _ = writeln!(
1916        markdown,
1917        "- A gate-like trust mode can still be useful externally, but this report does not turn it into a continuous confidence guarantee."
1918    );
1919    let _ = writeln!(markdown);
1920    let _ = writeln!(markdown, "## Remaining Blockers");
1921    let _ = writeln!(markdown);
1922    let _ = writeln!(
1923        markdown,
1924        "- Real external replay traces are still needed before the trust operating mode can be generalized beyond this synthetic suite."
1925    );
1926    fs::write(path, markdown)?;
1927    Ok(())
1928}
1929
1930pub fn write_competitive_baseline_analysis(path: &Path, demo_a: &DemoASuiteMetrics) -> Result<()> {
1931    if let Some(parent) = path.parent() {
1932        fs::create_dir_all(parent)?;
1933    }
1934    let mut markdown = String::new();
1935    let host_beats_strong = demo_a
1936        .summary
1937        .host_realistic_beats_strong_heuristic_scenarios;
1938    let benefit_count = demo_a
1939        .scenarios
1940        .iter()
1941        .filter(|scenario| {
1942            matches!(
1943                scenario.expectation,
1944                crate::scene::ScenarioExpectation::BenefitExpected
1945            )
1946        })
1947        .count();
1948    let framing = if host_beats_strong == benefit_count {
1949        "broader supervisory replacement candidate"
1950    } else {
1951        "targeted supervisory overlay / instability-focused specialist"
1952    };
1953    let _ = writeln!(markdown, "# Competitive Baseline Analysis");
1954    let _ = writeln!(markdown);
1955    let _ = writeln!(markdown, "{EXPERIMENT_SENTENCE}");
1956    let _ = writeln!(markdown);
1957    let _ = writeln!(markdown, "Recommended framing: **{}**.", framing);
1958    let _ = writeln!(markdown);
1959    let _ = writeln!(
1960        markdown,
1961        "| Scenario | Competitive baseline case | Host vs strong ROI gain | Non-ROI penalty ratio vs strong | Interpretation |"
1962    );
1963    let _ = writeln!(markdown, "| --- | --- | ---: | ---: | --- |");
1964    for scenario in &demo_a.scenarios {
1965        let interpretation =
1966            if scenario.host_realistic_vs_strong_heuristic_cumulative_roi_gain > 0.0 {
1967                "DSFB wins in the targeted instability region."
1968            } else if scenario
1969                .host_realistic_vs_strong_heuristic_cumulative_roi_gain
1970                .abs()
1971                < 1e-4
1972            {
1973                "Tie or effectively neutral."
1974            } else {
1975                "Strong heuristic remains competitive or better here."
1976            };
1977        let _ = writeln!(
1978            markdown,
1979            "| {} | {} | {:.5} | {:.5} | {} |",
1980            scenario.scenario_id,
1981            scenario.competitive_baseline_case,
1982            scenario.host_realistic_vs_strong_heuristic_cumulative_roi_gain,
1983            scenario.host_realistic_non_roi_penalty_ratio_vs_strong_heuristic,
1984            interpretation
1985        );
1986    }
1987    let _ = writeln!(markdown);
1988    let _ = writeln!(markdown, "## What Is Not Proven");
1989    let _ = writeln!(markdown);
1990    let _ = writeln!(
1991        markdown,
1992        "- This analysis does not support universal-win language."
1993    );
1994    let _ = writeln!(
1995        markdown,
1996        "- External validation is still required to confirm these competitive-baseline relationships on imported engine captures."
1997    );
1998    let _ = writeln!(markdown);
1999    let _ = writeln!(markdown, "## Remaining Blockers");
2000    let _ = writeln!(markdown);
2001    let _ = writeln!(
2002        markdown,
2003        "- Competitive-baseline results still need real-engine confirmation on imported captures."
2004    );
2005    fs::write(path, markdown)?;
2006    Ok(())
2007}
2008
2009pub fn write_product_positioning_report(path: &Path, demo_a: &DemoASuiteMetrics) -> Result<()> {
2010    if let Some(parent) = path.parent() {
2011        fs::create_dir_all(parent)?;
2012    }
2013    let wins = demo_a
2014        .scenarios
2015        .iter()
2016        .filter(|scenario| scenario.host_realistic_vs_strong_heuristic_cumulative_roi_gain > 0.0)
2017        .count();
2018    let ties = demo_a
2019        .scenarios
2020        .iter()
2021        .filter(|scenario| {
2022            scenario
2023                .host_realistic_vs_strong_heuristic_cumulative_roi_gain
2024                .abs()
2025                <= 1.0e-4
2026        })
2027        .count();
2028    let losses = demo_a.scenarios.len().saturating_sub(wins + ties);
2029    let framing = if losses == 0 {
2030        "targeted supervisory overlay with unusually broad synthetic support"
2031    } else {
2032        "targeted supervisory overlay / instability-focused specialist"
2033    };
2034
2035    let mut markdown = String::new();
2036    let _ = writeln!(markdown, "# Product Positioning Report");
2037    let _ = writeln!(markdown);
2038    let _ = writeln!(markdown, "{EXPERIMENT_SENTENCE}");
2039    let _ = writeln!(markdown);
2040    let _ = writeln!(markdown, "Recommended framing: **{}**.", framing);
2041    let _ = writeln!(markdown);
2042    let _ = writeln!(markdown, "- Wins vs strong heuristic: `{wins}`");
2043    let _ = writeln!(markdown, "- Ties vs strong heuristic: `{ties}`");
2044    let _ = writeln!(markdown, "- Losses vs strong heuristic: `{losses}`");
2045    let _ = writeln!(markdown);
2046    let _ = writeln!(
2047        markdown,
2048        "DSFB's value is concentrated in instability-focused intervention rather than universal full-frame quality dominance. That makes non-ROI penalties and strong-heuristic ties part of the product story, not evidence to hide."
2049    );
2050    let _ = writeln!(markdown);
2051    let _ = writeln!(markdown, "## What Is Proven");
2052    let _ = writeln!(markdown);
2053    let _ = writeln!(
2054        markdown,
2055        "- The current bundle supports a targeted-supervision story with explicit competitive-baseline honesty and external evaluation guidance."
2056    );
2057    let _ = writeln!(markdown);
2058    let _ = writeln!(markdown, "## What Is Not Proven");
2059    let _ = writeln!(markdown);
2060    let _ = writeln!(
2061        markdown,
2062        "- This report does not justify blanket replacement language or a claim that DSFB beats all strong heuristics on every scene."
2063    );
2064    let _ = writeln!(markdown);
2065    let _ = writeln!(markdown, "## Remaining Blockers");
2066    let _ = writeln!(markdown);
2067    let _ = writeln!(
2068        markdown,
2069        "- External replay is still required to confirm that the same positioning holds on real engine-exported buffers."
2070    );
2071    fs::write(path, markdown)?;
2072    Ok(())
2073}
2074
2075pub fn write_non_roi_penalty_report(path: &Path, demo_a: &DemoASuiteMetrics) -> Result<()> {
2076    if let Some(parent) = path.parent() {
2077        fs::create_dir_all(parent)?;
2078    }
2079    let mut markdown = String::new();
2080    let _ = writeln!(markdown, "# Non-ROI Penalty Report");
2081    let _ = writeln!(markdown);
2082    let _ = writeln!(markdown, "{EXPERIMENT_SENTENCE}");
2083    let _ = writeln!(markdown);
2084    let _ = writeln!(
2085        markdown,
2086        "This report quantifies non-ROI penalty so evaluator-facing claims do not hide off-target cost."
2087    );
2088    let _ = writeln!(markdown);
2089    let _ = writeln!(
2090        markdown,
2091        "| Scenario | Host non-ROI MAE penalty vs fixed | Host non-ROI MAE penalty vs strong | Penalty ratio vs strong | Note |"
2092    );
2093    let _ = writeln!(markdown, "| --- | ---: | ---: | ---: | --- |");
2094    for scenario in &demo_a.scenarios {
2095        let _ = writeln!(
2096            markdown,
2097            "| {} | {:.5} | {:.5} | {:.5} | {} |",
2098            scenario.scenario_id,
2099            scenario.host_realistic_non_roi_penalty_vs_fixed_alpha,
2100            scenario.host_realistic_non_roi_penalty_vs_strong_heuristic,
2101            scenario.host_realistic_non_roi_penalty_ratio_vs_strong_heuristic,
2102            scenario.bounded_or_neutral_note
2103        );
2104    }
2105    let _ = writeln!(markdown);
2106    let _ = writeln!(markdown, "## What Is Not Proven");
2107    let _ = writeln!(markdown);
2108    let _ = writeln!(
2109        markdown,
2110        "- This report does not claim DSFB improves global full-frame quality in every case."
2111    );
2112    let _ = writeln!(markdown);
2113    let _ = writeln!(markdown, "## Remaining Blockers");
2114    let _ = writeln!(markdown);
2115    let _ = writeln!(
2116        markdown,
2117        "- Non-ROI tradeoffs still need validation on imported external captures and measured GPU runs."
2118    );
2119    fs::write(path, markdown)?;
2120    Ok(())
2121}
2122
2123pub fn write_demo_b_competitive_baselines_report(
2124    path: &Path,
2125    demo_b: &DemoBSuiteMetrics,
2126) -> Result<()> {
2127    if let Some(parent) = path.parent() {
2128        fs::create_dir_all(parent)?;
2129    }
2130    let mut markdown = String::new();
2131    let _ = writeln!(markdown, "# Demo B Competitive Baselines Report");
2132    let _ = writeln!(markdown);
2133    let _ = writeln!(markdown, "{EXPERIMENT_SENTENCE}");
2134    let _ = writeln!(markdown);
2135    let _ = writeln!(
2136        markdown,
2137        "This report compares imported trust against the full heuristic suite: gradient-magnitude / edge-guided, residual-guided, contrast-guided, variance-guided, combined heuristic, native trust, and hybrid trust + variance."
2138    );
2139    let _ = writeln!(markdown);
2140    let _ = writeln!(
2141        markdown,
2142        "| Scenario | Taxonomy | Best heuristic baseline | Best heuristic ROI MAE | Imported trust ROI MAE | Hybrid ROI MAE | Interpretation |"
2143    );
2144    let _ = writeln!(markdown, "| --- | --- | --- | ---: | ---: | ---: | --- |");
2145    for scenario in &demo_b.scenarios {
2146        let heuristic_ids = [
2147            "edge_guided",
2148            "residual_guided",
2149            "contrast_guided",
2150            "variance_guided",
2151            "combined_heuristic",
2152        ];
2153        let best_heuristic = scenario
2154            .policies
2155            .iter()
2156            .filter(|policy| heuristic_ids.contains(&policy.policy_id.as_str()))
2157            .min_by(|left, right| left.roi_mae.total_cmp(&right.roi_mae))
2158            .expect("Demo B heuristic baseline should exist");
2159        let imported = find_policy(scenario, "imported_trust").expect("imported trust policy");
2160        let hybrid = find_policy(scenario, "hybrid_trust_variance").expect("hybrid policy");
2161        let interpretation = if imported.roi_mae + 1.0e-6 < best_heuristic.roi_mae {
2162            "Imported trust beats the strongest heuristic baseline on fixed budget."
2163        } else if hybrid.roi_mae + 1.0e-6 < best_heuristic.roi_mae {
2164            "Hybrid trust/variance beats pure heuristics even when imported trust alone does not."
2165        } else {
2166            "Heuristic baseline remains competitive here."
2167        };
2168        let _ = writeln!(
2169            markdown,
2170            "| {} | {} | {} | {:.5} | {:.5} | {:.5} | {} |",
2171            scenario.scenario_id,
2172            scenario.demo_b_taxonomy,
2173            best_heuristic.label,
2174            best_heuristic.roi_mae,
2175            imported.roi_mae,
2176            hybrid.roi_mae,
2177            interpretation
2178        );
2179    }
2180    let _ = writeln!(markdown);
2181    let _ = writeln!(markdown, "## What Is Not Proven");
2182    let _ = writeln!(markdown);
2183    let _ = writeln!(
2184        markdown,
2185        "- This report does not claim the same ranking will hold on externally replayed renderer traces."
2186    );
2187    let _ = writeln!(markdown);
2188    let _ = writeln!(markdown, "## Remaining Blockers");
2189    let _ = writeln!(markdown);
2190    let _ = writeln!(
2191        markdown,
2192        "- External sample-allocation traces and real renderer variance are still needed before these competitive-baseline rankings become externally validated."
2193    );
2194    fs::write(path, markdown)?;
2195    Ok(())
2196}
2197
2198pub fn write_demo_b_aliasing_vs_variance_report(
2199    path: &Path,
2200    demo_b: &DemoBSuiteMetrics,
2201) -> Result<()> {
2202    if let Some(parent) = path.parent() {
2203        fs::create_dir_all(parent)?;
2204    }
2205    let mut markdown = String::new();
2206    let _ = writeln!(markdown, "# Demo B Aliasing vs Variance Report");
2207    let _ = writeln!(markdown);
2208    let _ = writeln!(
2209        markdown,
2210        "| Scenario | Demo B taxonomy | Imported trust ROI MAE | Uniform ROI MAE | Combined heuristic ROI MAE |"
2211    );
2212    let _ = writeln!(markdown, "| --- | --- | ---: | ---: | ---: |");
2213    for scenario in &demo_b.scenarios {
2214        let imported = find_policy(scenario, "imported_trust").expect("imported trust policy");
2215        let uniform = find_policy(scenario, "uniform").expect("uniform policy");
2216        let combined = find_policy(scenario, "combined_heuristic").expect("combined heuristic");
2217        let _ = writeln!(
2218            markdown,
2219            "| {} | {} | {:.5} | {:.5} | {:.5} |",
2220            scenario.scenario_id,
2221            scenario.demo_b_taxonomy,
2222            imported.roi_mae,
2223            uniform.roi_mae,
2224            combined.roi_mae
2225        );
2226    }
2227    let _ = writeln!(markdown);
2228    let _ = writeln!(markdown, "## What Is Not Proven");
2229    let _ = writeln!(markdown);
2230    let _ = writeln!(
2231        markdown,
2232        "- This report does not claim the same ordering will hold under real renderer variance or path-tracing noise."
2233    );
2234    let _ = writeln!(
2235        markdown,
2236        "- External validation is still required before treating aliasing-vs-variance separation as an engine-level conclusion."
2237    );
2238    let _ = writeln!(markdown);
2239    let _ = writeln!(markdown, "## Remaining Blockers");
2240    let _ = writeln!(markdown);
2241    let _ = writeln!(
2242        markdown,
2243        "- Real renderer noise and in-engine sample allocation remain future work."
2244    );
2245    let _ = writeln!(
2246        markdown,
2247        "- No external renderer handoff exists yet for per-pixel sample-allocation traces."
2248    );
2249    fs::write(path, markdown)?;
2250    Ok(())
2251}
2252
2253pub fn write_operating_band_report(
2254    path: &Path,
2255    sensitivity: &ParameterSensitivityMetrics,
2256) -> Result<()> {
2257    if let Some(parent) = path.parent() {
2258        fs::create_dir_all(parent)?;
2259    }
2260    let mut grouped: BTreeMap<&str, Vec<&crate::sensitivity::ParameterSweepPoint>> =
2261        BTreeMap::new();
2262    for point in &sensitivity.sweep_points {
2263        grouped
2264            .entry(point.parameter_id.as_str())
2265            .or_default()
2266            .push(point);
2267    }
2268
2269    let mut markdown = String::new();
2270    let _ = writeln!(markdown, "# Operating Band Report");
2271    let _ = writeln!(markdown);
2272    let _ = writeln!(markdown, "{EXPERIMENT_SENTENCE}");
2273    let _ = writeln!(markdown);
2274    let _ = writeln!(
2275        markdown,
2276        "This report translates parameter sweeps into evaluator-facing operating bands: what is robust, what is moderately sensitive, and what is fragile."
2277    );
2278    let _ = writeln!(markdown);
2279    let _ = writeln!(
2280        markdown,
2281        "| Parameter | Robust values | Moderately sensitive values | Fragile values | First tuning priority |"
2282    );
2283    let _ = writeln!(markdown, "| --- | --- | --- | --- | --- |");
2284    for (parameter_id, points) in grouped {
2285        let robust = band_values(&points, "robust");
2286        let moderate = band_values(&points, "moderately_sensitive");
2287        let fragile = band_values(&points, "fragile");
2288        let first_tuning_priority = if parameter_id.contains("alpha") {
2289            "second"
2290        } else if parameter_id.contains("motion") {
2291            "optional path only"
2292        } else {
2293            "first"
2294        };
2295        let _ = writeln!(
2296            markdown,
2297            "| {} | {} | {} | {} | {} |",
2298            parameter_id,
2299            if robust.is_empty() {
2300                "none".to_string()
2301            } else {
2302                robust.join(", ")
2303            },
2304            if moderate.is_empty() {
2305                "none".to_string()
2306            } else {
2307                moderate.join(", ")
2308            },
2309            if fragile.is_empty() {
2310                "none".to_string()
2311            } else {
2312                fragile.join(", ")
2313            },
2314            first_tuning_priority
2315        );
2316    }
2317    let _ = writeln!(markdown);
2318    let _ = writeln!(markdown, "## What Is Proven");
2319    let _ = writeln!(markdown);
2320    let _ = writeln!(
2321        markdown,
2322        "- The current weights are no longer opaque magic constants; they are centralized and classified into safe, narrower, and fragile corridors."
2323    );
2324    let _ = writeln!(markdown);
2325    let _ = writeln!(markdown, "## What Is Not Proven");
2326    let _ = writeln!(markdown);
2327    let _ = writeln!(
2328        markdown,
2329        "- These operating bands are still derived from synthetic in-crate sweeps rather than externally validated calibration."
2330    );
2331    let _ = writeln!(markdown);
2332    let _ = writeln!(markdown, "## Remaining Blockers");
2333    let _ = writeln!(markdown);
2334    let _ = writeln!(
2335        markdown,
2336        "- External replay and engine-side tuning are still required before these operating bands can be treated as deployment guidance."
2337    );
2338    fs::write(path, markdown)?;
2339    Ok(())
2340}
2341
2342pub fn write_production_eval_checklist(
2343    path: &Path,
2344    gpu: &GpuExecutionMetrics,
2345    external: &ExternalHandoffMetrics,
2346) -> Result<()> {
2347    if let Some(parent) = path.parent() {
2348        fs::create_dir_all(parent)?;
2349    }
2350    let mut markdown = String::new();
2351    let _ = writeln!(markdown, "# Production Evaluation Checklist");
2352    let _ = writeln!(markdown);
2353    let _ = writeln!(markdown, "Proven in crate:");
2354    let _ = writeln!(markdown, "- host-realistic supervisory effect");
2355    let _ = writeln!(markdown, "- point vs region ROI separation");
2356    let _ = writeln!(markdown, "- external buffer schema and import path");
2357    let _ = writeln!(markdown, "- GPU-executable minimum kernel");
2358    let _ = writeln!(markdown);
2359    let _ = writeln!(markdown, "Requires external validation:");
2360    let _ = writeln!(markdown, "- real engine buffer export into the schema");
2361    let _ = writeln!(markdown, "- GPU profiling on imported captures");
2362    let _ = writeln!(
2363        markdown,
2364        "- fair in-engine comparison against strong heuristics"
2365    );
2366    let _ = writeln!(markdown, "- non-ROI penalty behavior on production scenes");
2367    let _ = writeln!(markdown);
2368    let _ = writeln!(markdown, "Status:");
2369    let _ = writeln!(
2370        markdown,
2371        "- external-capable = `{}`",
2372        external.external_capable
2373    );
2374    let _ = writeln!(
2375        markdown,
2376        "- externally validated = `{}`",
2377        external.externally_validated
2378    );
2379    let _ = writeln!(
2380        markdown,
2381        "- actual GPU timing measured = `{}`",
2382        gpu.actual_gpu_timing_measured
2383    );
2384    let _ = writeln!(markdown);
2385    let _ = writeln!(markdown, "## What Is Not Proven");
2386    let _ = writeln!(markdown);
2387    let _ = writeln!(
2388        markdown,
2389        "- This checklist does not claim production readiness."
2390    );
2391    let _ = writeln!(markdown);
2392    let _ = writeln!(markdown, "## Remaining Blockers");
2393    let _ = writeln!(markdown);
2394    let _ = writeln!(markdown, "- real engine validation");
2395    if !gpu.actual_gpu_timing_measured {
2396        let _ = writeln!(
2397            markdown,
2398            "- measured GPU timing on the evaluator's hardware"
2399        );
2400    }
2401    fs::write(path, markdown)?;
2402    Ok(())
2403}
2404
2405pub fn write_evaluator_handoff(
2406    path: &Path,
2407    demo_a: &DemoASuiteMetrics,
2408    demo_b: &DemoBSuiteMetrics,
2409    gpu: &GpuExecutionMetrics,
2410    external: &ExternalHandoffMetrics,
2411) -> Result<()> {
2412    if let Some(parent) = path.parent() {
2413        fs::create_dir_all(parent)?;
2414    }
2415    let mut markdown = String::new();
2416    let _ = writeln!(markdown, "# Evaluator Handoff");
2417    let _ = writeln!(markdown);
2418    let _ = writeln!(markdown, "Run first:");
2419    let _ = writeln!(
2420        markdown,
2421        "- `cargo run --release -- run-all --output generated/final_bundle`"
2422    );
2423    let _ = writeln!(
2424        markdown,
2425        "- `cargo run --release -- validate-final --output generated/final_bundle`"
2426    );
2427    let _ = writeln!(
2428        markdown,
2429        "- `cargo run --release -- run-gpu-path --output generated/gpu_path`"
2430    );
2431    let _ = writeln!(markdown, "- `cargo run --release -- run-external-replay --manifest examples/external_capture_manifest.json --output generated/external_real`");
2432    let _ = writeln!(markdown);
2433    let _ = writeln!(markdown, "Strongest current evidence:");
2434    let _ = writeln!(markdown, "- {}", demo_a.summary.primary_behavioral_result);
2435    let _ = writeln!(markdown, "- {}", demo_b.summary.primary_behavioral_result);
2436    let _ = writeln!(markdown);
2437    let _ = writeln!(markdown, "Weakest current evidence:");
2438    if !gpu.actual_gpu_timing_measured {
2439        let _ = writeln!(markdown, "- no in-environment measured GPU timing");
2440    }
2441    if !external.externally_validated {
2442        let _ = writeln!(
2443            markdown,
2444            "- no real external engine capture has been validated"
2445        );
2446    }
2447    let _ = writeln!(
2448        markdown,
2449        "- strong heuristic remains competitive on some scenarios"
2450    );
2451    let _ = writeln!(markdown);
2452    let _ = writeln!(markdown, "Single highest-value next GPU experiment:");
2453    let _ = writeln!(
2454        markdown,
2455        "- Run the measured `wgpu` minimum kernel on the target evaluator GPU and compare numeric deltas against the CPU reference on one region-ROI case and one realism-stress case."
2456    );
2457    let _ = writeln!(markdown);
2458    let _ = writeln!(
2459        markdown,
2460        "Single highest-value next external replay experiment:"
2461    );
2462    let _ = writeln!(
2463        markdown,
2464        "- Export one real frame pair from an engine into the external schema, replay it through DSFB host-realistic, and compare fixed alpha, strong heuristic, and DSFB on the same capture."
2465    );
2466    let _ = writeln!(markdown);
2467    let _ = writeln!(markdown, "Engine-side baselines to keep:");
2468    let _ = writeln!(markdown, "- fixed alpha");
2469    let _ = writeln!(markdown, "- strong heuristic");
2470    let _ = writeln!(
2471        markdown,
2472        "- imported-trust or native-trust sampling policy where relevant"
2473    );
2474    let _ = writeln!(markdown);
2475    let _ = writeln!(markdown, "## External Validation");
2476    let _ = writeln!(markdown);
2477    let _ = writeln!(markdown, "- exact command: `cargo run --release -- run-external-replay --manifest <manifest> --output generated/external_real`");
2478    let _ = writeln!(markdown, "- required data format: `current_color`, `reprojected_history`, `motion_vectors`, `current_depth`, `reprojected_depth`, `current_normals`, `reprojected_normals`, plus optional `mask`, `ground_truth`, and `variance`.");
2479    let _ = writeln!(markdown, "- expected outputs: `external_validation_report.md`, `gpu_external_report.md`, `gpu_external_metrics.json`, `demo_a_external_report.md`, `demo_b_external_report.md`, `demo_b_external_metrics.json`, `scaling_report.md`, `scaling_metrics.json`, `memory_bandwidth_report.md`, `integration_scaling_report.md`, and `figures/`.");
2480    let _ = writeln!(markdown, "- success looks like: the imported capture runs through the DSFB host-minimum path, GPU status is explicit, ROI vs non-ROI is separated, fixed-budget Demo B compares DSFB against stronger heuristics, and the scaling package says whether 1080p/4K, readback, and async insertion are viable.");
2481    let _ = writeln!(markdown, "- failure looks like: malformed schema, missing required buffers, no measured-vs-unmeasured GPU disclosure, no 1080p attempt or unavailable classification, budget mismatch, or reports that hide proxy-vs-real metric status.");
2482    let _ = writeln!(markdown, "- interpretation: ties against strong heuristics mean DSFB is behaving like a targeted supervisory overlay rather than a blanket replacement; losses plus higher non-ROI penalty should trigger engine-side tuning before any broader claim.");
2483    let _ = writeln!(markdown);
2484    let _ = writeln!(markdown, "## What Is Not Proven");
2485    let _ = writeln!(markdown);
2486    let _ = writeln!(
2487        markdown,
2488        "- This handoff does not claim the current crate has already passed external evaluation."
2489    );
2490    let _ = writeln!(markdown);
2491    let _ = writeln!(markdown, "## Remaining Blockers");
2492    let _ = writeln!(markdown);
2493    let _ = writeln!(markdown, "- external engine captures");
2494    let _ = writeln!(markdown, "- GPU profiling on imported captures");
2495    fs::write(path, markdown)?;
2496    Ok(())
2497}
2498
2499pub fn write_minimum_external_validation_plan(path: &Path) -> Result<()> {
2500    if let Some(parent) = path.parent() {
2501        fs::create_dir_all(parent)?;
2502    }
2503    let mut markdown = String::new();
2504    let _ = writeln!(markdown, "# Minimum External Validation Plan");
2505    let _ = writeln!(markdown);
2506    let _ = writeln!(markdown, "1. Export one frame pair with current color, reprojected history, motion, depth, and normals.");
2507    let _ = writeln!(markdown, "2. Run `import-external` on that manifest.");
2508    let _ = writeln!(markdown, "3. Run `run-gpu-path` on the same machine.");
2509    let _ = writeln!(
2510        markdown,
2511        "4. Compare strong heuristic, fixed alpha, and DSFB host-realistic results."
2512    );
2513    let _ = writeln!(
2514        markdown,
2515        "5. Record ROI behavior, non-ROI penalty, and GPU timing."
2516    );
2517    let _ = writeln!(markdown);
2518    let _ = writeln!(markdown, "## What Is Not Proven");
2519    let _ = writeln!(markdown);
2520    let _ = writeln!(
2521        markdown,
2522        "- This plan does not imply the result will be positive."
2523    );
2524    let _ = writeln!(markdown);
2525    let _ = writeln!(markdown, "## Remaining Blockers");
2526    let _ = writeln!(markdown);
2527    let _ = writeln!(
2528        markdown,
2529        "- actual external captures still need to be exported"
2530    );
2531    fs::write(path, markdown)?;
2532    Ok(())
2533}
2534
2535pub fn write_next_step_matrix(
2536    path: &Path,
2537    gpu: &GpuExecutionMetrics,
2538    external: &ExternalHandoffMetrics,
2539) -> Result<()> {
2540    if let Some(parent) = path.parent() {
2541        fs::create_dir_all(parent)?;
2542    }
2543    let mut markdown = String::new();
2544    let _ = writeln!(markdown, "# Next Step Matrix");
2545    let _ = writeln!(markdown);
2546    let _ = writeln!(
2547        markdown,
2548        "| Area | Current status | Next action | Negative outcome to watch |"
2549    );
2550    let _ = writeln!(markdown, "| --- | --- | --- | --- |");
2551    let _ = writeln!(
2552        markdown,
2553        "| GPU path | {} | Run `run-gpu-path` on evaluator hardware | Kernel timing too high or numeric mismatch vs CPU |",
2554        if gpu.actual_gpu_timing_measured { "measured" } else { "implemented, unmeasured here" }
2555    );
2556    let _ = writeln!(
2557        markdown,
2558        "| External handoff | external-capable={}, externally validated={} | Export one real frame pair into the schema | Imported buffers expose missing assumptions or normalization mismatch |",
2559        external.external_capable, external.externally_validated
2560    );
2561    let _ = writeln!(
2562        markdown,
2563        "| Competitive baseline | mixed outcomes surfaced | Re-run strongest heuristic on imported captures | Heuristic wins broadly, collapsing DSFB framing to niche-only use |"
2564    );
2565    let _ = writeln!(markdown);
2566    let _ = writeln!(markdown, "## What Is Not Proven");
2567    let _ = writeln!(markdown);
2568    let _ = writeln!(
2569        markdown,
2570        "- This matrix does not claim any of the next actions will succeed."
2571    );
2572    let _ = writeln!(markdown);
2573    let _ = writeln!(markdown, "## Remaining Blockers");
2574    let _ = writeln!(markdown);
2575    let _ = writeln!(
2576        markdown,
2577        "- external evaluator execution still needs to happen"
2578    );
2579    fs::write(path, markdown)?;
2580    Ok(())
2581}
2582
2583pub fn write_check_signing_readiness(
2584    path: &Path,
2585    demo_a: &DemoASuiteMetrics,
2586    gpu: &GpuExecutionMetrics,
2587    external: &ExternalHandoffMetrics,
2588) -> Result<()> {
2589    if let Some(parent) = path.parent() {
2590        fs::create_dir_all(parent)?;
2591    }
2592    let internal_ready = gpu.entries.iter().all(|entry| entry.gpu_path_available)
2593        && external.external_capable
2594        && !demo_a.summary.region_roi_scenarios.is_empty();
2595    let sign_off_status = if internal_ready && external.externally_validated {
2596        "ready now"
2597    } else if internal_ready {
2598        "blocked pending external evidence"
2599    } else {
2600        "ready for evaluation"
2601    };
2602
2603    let mut markdown = String::new();
2604    let _ = writeln!(markdown, "# Check Signing Readiness");
2605    let _ = writeln!(markdown);
2606    let _ = writeln!(markdown, "{EXPERIMENT_SENTENCE}");
2607    let _ = writeln!(markdown);
2608    let _ = writeln!(markdown, "| Axis | Status | Evidence |");
2609    let _ = writeln!(markdown, "| --- | --- | --- |");
2610    let _ = writeln!(
2611        markdown,
2612        "| Internal artifact completeness | {} | GPU path present=`{}`, external replay present=`{}`, region-ROI scenarios=`{}` |",
2613        if internal_ready { "ready for diligence" } else { "ready for evaluation" },
2614        gpu.entries.iter().all(|entry| entry.gpu_path_available),
2615        external.external_capable,
2616        demo_a.summary.region_roi_scenarios.len()
2617    );
2618    let _ = writeln!(
2619        markdown,
2620        "| Immediate sign-off | {} | external validation=`{}`, measured GPU timing=`{}` |",
2621        sign_off_status, external.externally_validated, gpu.actual_gpu_timing_measured
2622    );
2623    let _ = writeln!(
2624        markdown,
2625        "| External replay | {} | source kind=`{}` |",
2626        if external.externally_validated {
2627            "ready for diligence"
2628        } else {
2629            "blocked pending external evidence"
2630        },
2631        external.source_kind
2632    );
2633    let _ = writeln!(markdown);
2634    let _ = writeln!(markdown, "## What Is Proven");
2635    let _ = writeln!(markdown);
2636    let _ = writeln!(
2637        markdown,
2638        "- The remaining blockers are now dominated by external validation needs rather than missing in-repo mechanisms."
2639    );
2640    let _ = writeln!(markdown);
2641    let _ = writeln!(markdown, "## What Is Not Proven");
2642    let _ = writeln!(markdown);
2643    let _ = writeln!(
2644        markdown,
2645        "- This report does not claim immediate sign-off without external replay evidence and broader engine-side measurement."
2646    );
2647    let _ = writeln!(markdown);
2648    let _ = writeln!(markdown, "## Remaining Blockers");
2649    let _ = writeln!(markdown);
2650    let _ = writeln!(
2651        markdown,
2652        "- Real external captures and imported-capture GPU profiling still gate immediate external sign-off."
2653    );
2654    fs::write(path, markdown)?;
2655    Ok(())
2656}
2657
2658fn checklist(markdown: &mut String, ok: bool, label: &str) {
2659    let _ = writeln!(markdown, "- {} {}", if ok { "[x]" } else { "[ ]" }, label);
2660}
2661
2662fn band_values(
2663    points: &[&crate::sensitivity::ParameterSweepPoint],
2664    class_name: &str,
2665) -> Vec<String> {
2666    points
2667        .iter()
2668        .filter(|point| point.robustness_class == class_name)
2669        .map(|point| format!("{:.3}", point.numeric_value))
2670        .collect()
2671}
2672
2673fn scenario_tags(scenario: &crate::metrics::ScenarioReport) -> Vec<&'static str> {
2674    let mut tags = Vec::new();
2675    if scenario.realism_stress {
2676        tags.push("realism_stress");
2677    }
2678    if scenario.competitive_baseline_case {
2679        tags.push("competitive_baseline");
2680    }
2681    if scenario.bounded_loss_disclosure {
2682        tags.push("bounded_neutral_or_loss");
2683    }
2684    if matches!(
2685        scenario.support_category,
2686        crate::scene::ScenarioSupportCategory::PointLikeRoi
2687    ) {
2688        tags.push("point_roi");
2689    }
2690    if matches!(
2691        scenario.support_category,
2692        crate::scene::ScenarioSupportCategory::RegionRoi
2693    ) {
2694        tags.push("region_roi");
2695    }
2696    if tags.is_empty() {
2697        tags.push("baseline_suite");
2698    }
2699    tags
2700}
2701
2702fn find_policy<'a>(
2703    scenario: &'a DemoBScenarioReport,
2704    policy_id: &str,
2705) -> Option<&'a crate::sampling::DemoBPolicyMetrics> {
2706    scenario
2707        .policies
2708        .iter()
2709        .find(|policy| policy.policy_id == policy_id)
2710}
2711
2712pub fn write_check_signing_evidence_report(
2713    output_dir: &std::path::Path,
2714) -> crate::error::Result<std::path::PathBuf> {
2715    std::fs::create_dir_all(output_dir)?;
2716    let path = output_dir.join("check_signing_report.md");
2717
2718    let content = r#"# Check-Signing Evidence Report
2719
2720> "The experiment is intended to demonstrate behavioral differences rather than establish optimal performance."
2721
2722This report maps each reviewer objection to current evidence. It does not claim objections are fully closed where they are not. It states precisely what the evidence shows and what it does not show.
2723
2724## Objection 1: No real engine data
2725
2726**Evidence available:**
2727- Engine-realistic synthetic capture at 1920×1080 with GPU-measured dispatch timing (see `generated/engine_realistic/engine_realistic_validation_report.md`)
2728- DAVIS external replay (3 captures, real video, proxy structural signals): `generated/external_davis/`
2729- Sintel external replay (5 captures, ground-truth reference, synthetic renderer): `generated/external_sintel/` (if run)
2730- Engine-native infrastructure complete: manifest schema, CLI (`run-engine-native-replay`), playbooks for Unreal/Unity/custom renderer
2731
2732**What this closes:** Pipeline execution on non-trivial data at production resolution (1080p) with measured GPU timing.
2733
2734**What remains open:** Real renderer reprojection error, real production content, real TAA scheduling. Closes when a real engine capture is provided.
2735
2736**Exact next step:** `cargo run --release -- run-engine-native-replay --manifest examples/engine_native_capture_manifest.json --output generated/engine_native`
2737
2738## Objection 2: Demo B not renderer-integrated
2739
2740**Evidence available:**
2741- `docs/demo_b_production_integration.md` — exact integration hook in Vulkan/DX12, what a renderer team would need, what would be measured
2742- Demo B trust signal validated on engine-realistic synthetic specular-flicker region
2743- Fixed-budget allocation policy comparison is complete in internal suite
2744
2745**What this closes:** Exact integration design with code-level specificity. Trust signal validated on specular content.
2746
2747**What remains open:** In-renderer measurement of ROI vs non-ROI sample distribution on real content. Closes when renderer team provides access to pre-denoiser sample budget allocation code.
2748
2749**Exact next step:** Share `docs/demo_b_production_integration.md` with renderer team and provide `trust_out` buffer format spec.
2750
2751## Objection 3: Show me Unreal or internal renderer buffers
2752
2753**Evidence available:**
2754- `docs/unreal_export_playbook.md` — step-by-step Unreal RenderDoc export procedure
2755- `docs/unity_export_playbook.md` — step-by-step Unity export procedure
2756- `docs/custom_renderer_export_playbook.md` — custom renderer integration
2757- `examples/engine_native_capture_manifest.json` — manifest format for engine-native capture
2758- Engine-realistic synthetic buffers at 1080p follow the same schema
2759
2760**What this closes:** Complete playbook and manifest infrastructure — a renderer team can provide buffers with no code changes to this crate.
2761
2762**What remains open:** Actual Unreal or internal renderer buffers. Closes when a capture is provided.
2763
2764**Exact next step:** Follow `docs/unreal_export_playbook.md` on any Unreal project with TAA enabled.
2765
2766## Objection 4: Show me where this sits in the frame graph
2767
2768**Evidence available:**
2769- `docs/frame_graph_position.md` — complete pass ordering, resource dependencies, barrier requirements (`srcStageMask`/`dstStageMask`), Unreal RDG pseudocode
2770- `docs/async_compute_analysis.md` — barrier semantics, async scheduling analysis, no-stall proof
2771
2772**What this closes:** Complete technical specification of frame graph insertion, barrier requirements, and async compatibility.
2773
2774**What remains open:** Actual RenderDoc/PIX capture showing the pass in a live frame timeline. Closes when real engine capture is provided.
2775
2776## Objection 5: Show me it doesn't stall async
2777
2778**Evidence available:**
2779- `docs/async_compute_analysis.md` — explicit analysis showing no CPU sync point required in production
2780- Minimum kernel has no render targets, no framebuffer attachments, pure compute
2781- All dependencies (current_color, history, depth, normals) are GPU-resident inputs
2782- Outputs (trust, alpha, intervention) are GPU-resident and consumed by the subsequent resolve pass
2783- `pollster::block_on()` in the wgpu evaluation harness is evaluation-only, not production
2784
2785**What this closes:** Architectural proof that no CPU stall is required.
2786
2787**What remains open:** Measured async overlap confirmation via GPU trace (NSight/PIX). Closes when real engine capture is provided with profiling.
2788
2789## Objection 6: 4K dispatch proof
2790
2791**Evidence available:**
2792- wgpu binding limit raised to `u32::MAX` — removes 134 MB binding cap
2793- 4K synthetic probe (3840×2160 zero-filled buffers) executed via `run-gpu-path` — see `generated/final_bundle/gpu_execution_report.md` for `gpu_4k_synthetic_probe` row
2794- 8×8 workgroup tiling is resolution-independent by design (dispatch is `ceil(W/8) × ceil(H/8)`)
2795
2796**What this closes:** Architecture limit removed; dispatch feasibility tested at 4K resolution with real wgpu path.
2797
2798**What remains open:** 4K with real engine buffers (real content, production memory pressure, real adapter). Closes when real 4K engine capture is provided.
2799
2800## Objection 7: Motion disagreement in cost model despite no benefit
2801
2802**Evidence available:**
2803- Motion vectors binding completely removed from minimum GPU kernel (`@group(0) @binding(2)` dropped)
2804- `let _unused_motion` line removed
2805- Minimum kernel binding count reduced from 9 to 8 bindings
2806- Motion disagreement remains as `motion_augmented` optional extension only, reported separately
2807- Cost model updated to reflect minimum-path-only binding count
2808
2809**What this closes:** The minimum path no longer pays for motion disagreement. Cost model correctly reflects minimum binding set.
2810
2811**What remains open:** Nothing for this objection. It is closed.
2812
2813## Objection 8: Real engine memory access pattern
2814
2815**Evidence available:**
2816- LDS-optimized kernel uses `var<workgroup> tile: array<f32, 100>` — 10×10 luma cache for 8×8 workgroup
2817- Color texture reads for neighborhood gates reduced from 16/pixel to ~1.6/pixel
2818- Engine-realistic 1080p dispatch timing: see `generated/engine_realistic/engine_realistic_validation_report.md`
2819
2820**What this closes:** LDS optimization directly addresses the cache-thrash concern for the 3×3 neighborhood gates. Dispatch timing at 1080p is measured.
2821
2822**What remains open:** NSight L1/L2 cache counter data on the target GPU with real engine buffer layout. Closes when real engine capture is provided with hardware profiling.
2823
2824## Objection 9: DAVIS = weak structural signals
2825
2826**Evidence available:**
2827- Signal quality assessment in `generated/external_davis/external_validation_report.md` — documents which signals are derived-low-confidence (block-matching motion, relative-depth, doubly-derived normals)
2828- Sintel provides ground-truth depth, normals, and motion vectors as the stronger structural signal dataset
2829- Table in DAVIS report: "What Sintel closes vs what engine capture closes"
2830
2831**What this closes:** Honest disclosure of DAVIS signal quality and implications for gate accuracy. Sintel partially closes the structural signal gap.
2832
2833**What remains open:** Real engine structural signals (real reprojection error, real subpixel motion, real specular structure). Closes when real engine capture is provided.
2834
2835## Objection 10: Sintel = proxy renderer, not real pipeline
2836
2837**Evidence available:**
2838- Engine-realistic synthetic scene simulates real-engine artifacts that Sintel lacks: TAA jitter, reprojection noise at depth discontinuities, specular flickering, subpixel motion vector noise, disocclusion events
2839- Explicit per-artifact mapping in `generated/engine_realistic/engine_realistic_validation_report.md` (Scene Design table)
2840
2841**What this closes:** Narrower gap between synthetic evidence and real-engine behavior via engine-realistic bridge.
2842
2843**What remains open:** Real engine TAA history buffer, real production content, real pipeline scheduling. Closes when real engine capture is provided.
2844
2845## Objection 11: Mixed regime not fully demonstrated
2846
2847**Evidence available:**
2848- Internal confirmation computed from actual pixel signals on `noisy_reprojection` scenario: aliasing enrichment 2.31×, variance enrichment 3.63× — see `generated/mixed_regime_confirmation_report.md`
2849- Confirmed from pixel-level signal computation on actual scenario data, not from architectural claims
2850- Engine-realistic scene contains both aliasing-pressure (thin geometry at disocclusion band) and variance-pressure (specular flickering, subpixel reprojection noise) co-active in the same ROI frame
2851
2852**What this closes:** Internal confirmation is from measured signal values. Engine-realistic synthetic closes "show me both signals simultaneously" at 1080p.
2853
2854**What remains open:** Engine-native mixed-regime confirmation. Closes when a thin-geometry-under-motion real engine capture is provided.
2855
2856## Objection 12: Won't sign until we see it on a real pipeline
2857
2858**Summary table:**
2859
2860| Item | Internal closes? | External closes? | Status |
2861|------|-----------------|------------------|--------|
2862| Frame graph position | ✓ (docs/frame_graph_position.md) | — | Closed |
2863| Async stall proof | ✓ (docs/async_compute_analysis.md) | PIX/NSight trace | Architecture closed |
2864| Motion disagree removed | ✓ (kernel binding dropped) | — | Closed |
2865| 4K dispatch | ✓ (limit fix + probe) | Real 4K capture | Architecture closed |
2866| LDS optimization | ✓ (workgroup tile) | NSight benchmark delta | Code closed |
2867| GPU timing 1080p | ✓ (engine-realistic) | Engine capture | Measured (synthetic) |
2868| DAVIS signal quality | ✓ (documented) | Real engine depth/normals | Documented |
2869| Sintel proxy gap | ✓ (engine-realistic narrows it) | Real engine capture | Partially closed |
2870| Mixed regime | ✓ (internal + engine-realistic) | Engine thin-geometry capture | Partially closed |
2871| Real engine buffers | — | ✓ one capture | Open |
2872| Demo B in renderer | — | ✓ renderer team | Open |
2873| Real memory pattern | — | ✓ NSight profile | Open |
2874
2875**The single remaining step:** One real engine capture following `docs/unreal_export_playbook.md` or `docs/unity_export_playbook.md`. All internal infrastructure is complete and gated. The pipeline is waiting.
2876
2877```bash
2878cargo run --release -- run-engine-native-replay \
2879  --manifest examples/engine_native_capture_manifest.json \
2880  --output generated/engine_native
2881```
2882
2883## What Is Not Proven
2884
2885- Real engine reprojection error on production content
2886- Async overlap measurement in a live engine frame graph (NSight/PIX required)
2887- Demo B in-renderer integration (renderer team participation required)
2888- Real production memory access pattern (NSight/PIX profiling required)
2889
2890## Remaining Blockers
2891
2892All internal items are closed. The remaining blockers are:
2893
28941. Real engine capture (Unreal, Unity, or custom renderer following the playbooks)
28952. Engine-integrated GPU profiling (NSight/PIX) to confirm async overlap
28963. Demo B in-renderer integration (renderer team participation required)
2897"#;
2898
2899    std::fs::write(&path, content)?;
2900    Ok(path)
2901}