From 52f438c8647482581ed3280100edde7b8aa75d3f Mon Sep 17 00:00:00 2001 From: Lucenx9 <185146821+Lucenx9@users.noreply.github.com> Date: Thu, 22 Oct 2026 19:45:06 +0200 Subject: [PATCH] fix(xtask): derive scorecard corpus counts from pinned manifests --- docs/development.md | 2 ++ docs/scorecard.md | 6 +++--- xtask/src/scorecard.rs | 37 +++++++++++++++++++++++++++++++++++-- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/docs/development.md b/docs/development.md index 034127ad53..16a4533437 100644 --- a/docs/development.md +++ b/docs/development.md @@ -385,6 +385,8 @@ cargo xtask perf --update-baseline # also write perf/baseline.json from this r `cargo xtask perf --update-baseline`, with the machine (CPU, RAM, GPU adapter, OS), its machine class, commit, date and load average. - `crates/io/tests/corpus.rs`: the corpus floors (every `Source { .. }` constant). +- `xtask/*-corpus.sha256`: file counts for pinned corpora, so stale counts in doc comments cannot + change the reported denominators. No downloaded corpus is needed to generate the scorecard. - The prefs audit: `Preferences` fields that no code reads (target 0, #204), plus counts taken from the tree (never-crash attribute coverage, `docs/parity-checklist.md`). diff --git a/docs/scorecard.md b/docs/scorecard.md index 7d64bb098a..30544e7403 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -1,13 +1,13 @@ # PhotoCraft scorecard -Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.json`, `crates/io/tests/corpus.rs`, `scorecard/*.toml` and the source tree. Do not edit by hand: change the sources and regenerate (CI runs `cargo xtask scorecard --check`). Checklist statuses are verified against the code; numbers here supersede estimates elsewhere. +Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.json`, `crates/io/tests/corpus.rs`, `xtask/*-corpus.sha256`, `scorecard/*.toml` and the source tree. Do not edit by hand: change the sources and regenerate (CI runs `cargo xtask scorecard --check`). Checklist statuses are verified against the code; numbers here supersede estimates elsewhere. ## Summary | Area | Done | Partial | Missing | Key numbers | |---|---:|---:|---:|---| | [Performance](#performance) | 3 | 22 | 26 | 60 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 22 not run, 4 not measurable yet (baseline 2026-10-05) | -| [File compatibility](#file-compatibility) | 9 | 13 | 5 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 190/256, round trip ≥ 258/256 | +| [File compatibility](#file-compatibility) | 9 | 13 | 5 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 190/258, round trip ≥ 258/258 | | [Tools](#tools) | 36 | 8 | 0 | | | [Workspace and UI](#workspace-and-ui) | 14 | 6 | 3 | settings that do nothing: 21 of 176 (target 0) | | [Type](#type) | 5 | 4 | 0 | | @@ -98,7 +98,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t |---|---|---:|---:|---:| | io corpus | `corpus/psd` | 170 | 148 | 169 | | psd-tools corpus | `corpus/psd-tools` | 309 | 249 | 308 | -| photoshop oracles | `corpus/photoshop` | 256 | 190 | 258 | +| photoshop oracles | `corpus/photoshop` | 258 | 190 | 258 | | Id | Target | Status | Issue | Note | |---|---|---|---|---| diff --git a/xtask/src/scorecard.rs b/xtask/src/scorecard.rs index f7f270bd00..05fd3be68b 100644 --- a/xtask/src/scorecard.rs +++ b/xtask/src/scorecard.rs @@ -5,6 +5,7 @@ //! numbers against the budgets). A fresh `cargo xtask perf` result in `target/` is not used: //! publish it with `cargo xtask perf --update-baseline`. //! - `crates/io/tests/corpus.rs`: the corpus floors (`Source { .. }` constants). +//! - `xtask/*-corpus.sha256`: file counts for the pinned corpora. //! - `scorecard/*.toml`: per-area checklists (id, target, status, issue, note). //! - the prefs audit: `Preferences` fields that no code outside `prefs.rs` / `prefs_ui.rs` reads. //! - counted from the tree: never-crash attribute coverage, `docs/parity-checklist.md`'s live count. @@ -474,7 +475,15 @@ pub fn gather(root: &Path) -> Result { Ok(t) => Some(serde_json::from_str(&t).map_err(|e| format!("{}: {e}", perf::BASELINE))?), Err(_) => None, }; - let corpora = parse_corpus(&std::fs::read_to_string(root.join(CORPUS_RS)).map_err(|e| format!("read {CORPUS_RS}: {e}"))?); + let mut corpora = parse_corpus(&std::fs::read_to_string(root.join(CORPUS_RS)).map_err(|e| format!("read {CORPUS_RS}: {e}"))?); + for corpus in &mut corpora { + let Some(pinned) = crate::corpus_pins::ALL.iter().find(|p| corpus.dir == format!("corpus/{}", p.dest)) else { continue }; + let manifest = std::fs::read_to_string(root.join(pinned.manifest)).map_err(|e| format!("read {}: {e}", pinned.manifest))?; + corpus.files = Some( + u32::try_from(manifest.lines().filter(|line| !line.trim().is_empty()).count()) + .map_err(|_| format!("{}: corpus file count exceeds u32", pinned.manifest))?, + ); + } Ok(Inputs { budgets, baseline, @@ -522,7 +531,7 @@ pub fn render(inp: &Inputs) -> String { let mut s = String::from( "# PhotoCraft scorecard\n\nGenerated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.json`, \ -`crates/io/tests/corpus.rs`, `scorecard/*.toml` and the source tree. Do not edit by hand: change the sources and \ +`crates/io/tests/corpus.rs`, `xtask/*-corpus.sha256`, `scorecard/*.toml` and the source tree. Do not edit by hand: change the sources and \ regenerate (CI runs `cargo xtask scorecard --check`). Checklist statuses are verified against the code; numbers \ here supersede estimates elsewhere.\n\n## Summary\n\n| Area | Done | Partial | Missing | Key numbers |\n|---|---:|---:|---:|---|\n", ); @@ -791,6 +800,30 @@ const PHOTOSHOP: Source = Source { label: "photoshop oracles", dir: "corpus/phot assert!(parse_corpus("const X: u32 = 1;").is_empty()); } + #[test] + fn scorecard_uses_pinned_corpus_file_counts() { + let root = crate::root(); + let inp = gather(&root).unwrap(); + let rendered = render(&inp); + for corpus in &inp.corpora { + let pinned = crate::corpus_pins::ALL.iter().find(|p| corpus.dir == format!("corpus/{}", p.dest)).unwrap(); + let manifest = std::fs::read_to_string(root.join(pinned.manifest)).unwrap(); + let files = manifest.lines().filter(|line| !line.trim().is_empty()).count(); + assert!( + rendered.contains(&format!( + "{}: oracle ≥ {}/{files}, round trip ≥ {}/{files}", + corpus.label, + corpus.pass_floor.unwrap(), + corpus.roundtrip_floor.unwrap() + )), + "{} must use the {files} files in {} instead of a count from a doc comment", + corpus.label, + pinned.manifest + ); + assert!(rendered.contains(&format!("| {} | `{}` | {files} |", corpus.label, corpus.dir))); + } + } + #[test] fn checklists_validate() { let ok = "area = \"tools\"\ntitle = \"Tools\"\norder = 3\n[[item]]\nid = \"T-1\"\ntarget = \"Pencil\"\nstatus = \"partial\"\nissue = 213\n";