CLI: victory compare, an A/B of two translate --list outputs program by program (branch ready; PRs are collaborator-only) #787

Open
opened 2026-11-26 04:13:58 +00:00 by github-bot · 4 comments
Owner

@⁠Pablo-Barros on GitHub · 2026-11-24 10:47 UTC · original

Every per-program measurement on this tracker has been made so far with a script of the reporter's own (#736, #233, #201, #459). victory compare <before> <after> reads two translate --list outputs and gives that answer without one:

victory translate --validate --pipelines --list > before.txt    # main
victory translate --validate --pipelines --list > after.txt     # the change
victory compare before.txt after.txt

It prints:

  • each run's pipelines and validations (the runs' own totals), then what was gained and lost;
  • how many pipelines come from modules the validator refuses, and how many of the gained ones do (the "5 of the 98" question on #233);
  • every program that ends differently, counted by its reason before and after;
  • every loss, with both reasons.

The key is the file's name, offset, record and stage, so copies of the title in other folders compare. A program a run stopped earlier counts as not made for that run's checks, so "pipeline created before, refused by the translator now" is a loss.

Checked

  • #180 5ff639e merged onto main ffe310e, whole title, RTX 3070 (32-lane waves): 25,953 programs in both, 528 pipelines gained and 12 lost, 0 validations lost, each loss with both reasons. The result is on #180.
  • #459's head merged onto the same main: 0 gained, 0 lost, as four reports there measured by hand.

Branch

https://github.com/Pablo-Barros/VIctory/tree/cli/translate-compare: one commit, 31953ea, on main ffe310e. apps/victory/src/compare.rs (5 tests on synthetic list text, no game data), the command in main.rs, one line in the README's command list.

  • CI's two clippy commands (-D warnings, with and without --all-features): clean.
  • cargo test --workspace --locked: 347 passed, 0 failed, 6 ignored (main here: 342 / 0 / 6).
  • cargo xtask policy: 3 files ok.

Not covered

The tool reads text files only; the title was not run with it.

AI use: the agent (Claude Code) wrote the code and tests and ran everything above on this machine at my request; the counts are from those runs. No game data is included.

**@⁠Pablo-Barros** on GitHub · 2026-11-24 10:47 UTC · [original](https://github.com/Marvisak/VIctory/issues/787) Every per-program measurement on this tracker has been made so far with a script of the reporter's own (#736, #233, #201, #459). `victory compare <before> <after>` reads two `translate --list` outputs and gives that answer without one: ``` victory translate --validate --pipelines --list > before.txt # main victory translate --validate --pipelines --list > after.txt # the change victory compare before.txt after.txt ``` It prints: - each run's pipelines and validations (the runs' own totals), then what was gained and lost; - how many pipelines come from modules the validator refuses, and how many of the gained ones do (the "5 of the 98" question on #233); - every program that ends differently, counted by its reason before and after; - every loss, with both reasons. The key is the file's name, offset, record and stage, so copies of the title in other folders compare. A program a run stopped earlier counts as not made for that run's checks, so "pipeline created before, refused by the translator now" is a loss. ## Checked - #180 `5ff639e` merged onto `main` `ffe310e`, whole title, RTX 3070 (32-lane waves): 25,953 programs in both, 528 pipelines gained and 12 lost, 0 validations lost, each loss with both reasons. The result is on #180. - #459's head merged onto the same `main`: 0 gained, 0 lost, as four reports there measured by hand. ## Branch https://github.com/Pablo-Barros/VIctory/tree/cli/translate-compare: one commit, `31953ea`, on `main` `ffe310e`. `apps/victory/src/compare.rs` (5 tests on synthetic list text, no game data), the command in `main.rs`, one line in the README's command list. - CI's two clippy commands (`-D warnings`, with and without `--all-features`): clean. - `cargo test --workspace --locked`: 347 passed, 0 failed, 6 ignored (`main` here: 342 / 0 / 6). - `cargo xtask policy`: 3 files ok. ## Not covered The tool reads text files only; the title was not run with it. AI use: the agent (Claude Code) wrote the code and tests and ran everything above on this machine at my request; the counts are from those runs. No game data is included.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:13:58 +00:00
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-24 11:43 UTC · original

I ran the compare command from 31953ea on two synthetic lists saved with > in Windows PowerShell 5.1. The files had a UTF-16LE BOM, and the CLI exited with stream did not contain valid UTF-8. The plain UTF-8 control reported two matching programs and one pipeline loss. PowerShell encoding defaults

The follow-up accepts the UTF-16 BOMs and strips the UTF-8 BOM before parsing. The built CLI prints the same report for the PowerShell files, a UTF-8 BOM input, and a UTF-16BE input as it does for plain UTF-8. All seven compare tests passed, including the first record and malformed encoding cases.

AI-assisted. Reproduced and verified with synthetic text on Windows.

Incremental patch on 31953ea
diff --git a/apps/victory/src/compare.rs b/apps/victory/src/compare.rs
index 81799c7..66e215a 100644
--- a/apps/victory/src/compare.rs
+++ b/apps/victory/src/compare.rs
@@ -3,8 +3,9 @@
 //! `main` with it, each run on the tester's own copy of the title.
 
+use std::borrow::Cow;
 use std::collections::{BTreeMap, BTreeSet};
 use std::path::{Path, PathBuf};
 
-use anyhow::{Context, Result};
+use anyhow::{Context, Result, ensure};
 
 /// Who refuses a module, in the order it meets them: our translator, the
@@ -142,7 +143,28 @@ fn parse(text: &str) -> Option<(Programs, usize)> {
 }
 
+fn decode_listing(bytes: &[u8]) -> Result<Cow<'_, str>> {
+    match bytes {
+        [0xff, 0xfe, rest @ ..] => decode_utf16(rest, u16::from_le_bytes).map(Cow::Owned),
+        [0xfe, 0xff, rest @ ..] => decode_utf16(rest, u16::from_be_bytes).map(Cow::Owned),
+        _ => {
+            let bytes = bytes.strip_prefix(&[0xef, 0xbb, 0xbf]).unwrap_or(bytes);
+            std::str::from_utf8(bytes)
+                .map(Cow::Borrowed)
+                .context("invalid UTF-8 listing")
+        }
+    }
+}
+
+fn decode_utf16(bytes: &[u8], order: fn([u8; 2]) -> u16) -> Result<String> {
+    let (units, tail) = bytes.as_chunks::<2>();
+    ensure!(tail.is_empty(), "incomplete UTF-16 code unit");
+    char::decode_utf16(units.iter().copied().map(order))
+        .collect::<std::result::Result<String, _>>()
+        .context("invalid UTF-16 listing")
+}
+
 fn read(path: &Path) -> Result<(Programs, usize)> {
-    let text =
-        std::fs::read_to_string(path).with_context(|| format!("reading {}", path.display()))?;
+    let bytes = std::fs::read(path).with_context(|| format!("reading {}", path.display()))?;
+    let text = decode_listing(&bytes).with_context(|| format!("decoding {}", path.display()))?;
     parse(&text).with_context(|| {
         format!(
@@ -337,4 +359,26 @@ shaders.rpf@0x70 G_Wrapped Vs  pipeline created\n";
     }
 
+    #[test]
+    fn unicode_boms_preserve_the_first_record() {
+        let listing = "shader.rpf@0x20 Cs  pipeline: par\u{e1}metro\r\n";
+        let expected = parse(listing).unwrap();
+        let mut utf8_bom = vec![0xef, 0xbb, 0xbf];
+        utf8_bom.extend_from_slice(listing.as_bytes());
+        let mut utf16_le = vec![0xff, 0xfe];
+        utf16_le.extend(listing.encode_utf16().flat_map(u16::to_le_bytes));
+        let mut utf16_be = vec![0xfe, 0xff];
+        utf16_be.extend(listing.encode_utf16().flat_map(u16::to_be_bytes));
+        for bytes in [listing.as_bytes(), &utf8_bom, &utf16_le, &utf16_be] {
+            assert_eq!(parse(&decode_listing(bytes).unwrap()).unwrap(), expected);
+        }
+    }
+
+    #[test]
+    fn malformed_unicode_listings_fail() {
+        assert!(decode_listing(&[0xff]).is_err());
+        assert!(decode_listing(&[0xff, 0xfe, 0x41]).is_err());
+        assert!(decode_listing(&[0xff, 0xfe, 0x00, 0xd8]).is_err());
+    }
+
     #[test]
     fn lines_of_one_program_make_one_outcome() {
**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-24 11:43 UTC · [original](https://github.com/Marvisak/VIctory/issues/787#issuecomment-7130456098) I ran the `compare` command from `31953ea` on two synthetic lists saved with `>` in Windows PowerShell 5.1. The files had a UTF-16LE BOM, and the CLI exited with `stream did not contain valid UTF-8`. The plain UTF-8 control reported two matching programs and one pipeline loss. [PowerShell encoding defaults](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_character_encoding?view=powershell-5.1) The follow-up accepts the UTF-16 BOMs and strips the UTF-8 BOM before parsing. The built CLI prints the same report for the PowerShell files, a UTF-8 BOM input, and a UTF-16BE input as it does for plain UTF-8. All seven compare tests passed, including the first record and malformed encoding cases. AI-assisted. Reproduced and verified with synthetic text on Windows. <details> <summary>Incremental patch on 31953ea</summary> ```diff diff --git a/apps/victory/src/compare.rs b/apps/victory/src/compare.rs index 81799c7..66e215a 100644 --- a/apps/victory/src/compare.rs +++ b/apps/victory/src/compare.rs @@ -3,8 +3,9 @@ //! `main` with it, each run on the tester's own copy of the title. +use std::borrow::Cow; use std::collections::{BTreeMap, BTreeSet}; use std::path::{Path, PathBuf}; -use anyhow::{Context, Result}; +use anyhow::{Context, Result, ensure}; /// Who refuses a module, in the order it meets them: our translator, the @@ -142,7 +143,28 @@ fn parse(text: &str) -> Option<(Programs, usize)> { } +fn decode_listing(bytes: &[u8]) -> Result<Cow<'_, str>> { + match bytes { + [0xff, 0xfe, rest @ ..] => decode_utf16(rest, u16::from_le_bytes).map(Cow::Owned), + [0xfe, 0xff, rest @ ..] => decode_utf16(rest, u16::from_be_bytes).map(Cow::Owned), + _ => { + let bytes = bytes.strip_prefix(&[0xef, 0xbb, 0xbf]).unwrap_or(bytes); + std::str::from_utf8(bytes) + .map(Cow::Borrowed) + .context("invalid UTF-8 listing") + } + } +} + +fn decode_utf16(bytes: &[u8], order: fn([u8; 2]) -> u16) -> Result<String> { + let (units, tail) = bytes.as_chunks::<2>(); + ensure!(tail.is_empty(), "incomplete UTF-16 code unit"); + char::decode_utf16(units.iter().copied().map(order)) + .collect::<std::result::Result<String, _>>() + .context("invalid UTF-16 listing") +} + fn read(path: &Path) -> Result<(Programs, usize)> { - let text = - std::fs::read_to_string(path).with_context(|| format!("reading {}", path.display()))?; + let bytes = std::fs::read(path).with_context(|| format!("reading {}", path.display()))?; + let text = decode_listing(&bytes).with_context(|| format!("decoding {}", path.display()))?; parse(&text).with_context(|| { format!( @@ -337,4 +359,26 @@ shaders.rpf@0x70 G_Wrapped Vs pipeline created\n"; } + #[test] + fn unicode_boms_preserve_the_first_record() { + let listing = "shader.rpf@0x20 Cs pipeline: par\u{e1}metro\r\n"; + let expected = parse(listing).unwrap(); + let mut utf8_bom = vec![0xef, 0xbb, 0xbf]; + utf8_bom.extend_from_slice(listing.as_bytes()); + let mut utf16_le = vec![0xff, 0xfe]; + utf16_le.extend(listing.encode_utf16().flat_map(u16::to_le_bytes)); + let mut utf16_be = vec![0xfe, 0xff]; + utf16_be.extend(listing.encode_utf16().flat_map(u16::to_be_bytes)); + for bytes in [listing.as_bytes(), &utf8_bom, &utf16_le, &utf16_be] { + assert_eq!(parse(&decode_listing(bytes).unwrap()).unwrap(), expected); + } + } + + #[test] + fn malformed_unicode_listings_fail() { + assert!(decode_listing(&[0xff]).is_err()); + assert!(decode_listing(&[0xff, 0xfe, 0x41]).is_err()); + assert!(decode_listing(&[0xff, 0xfe, 0x00, 0xd8]).is_err()); + } + #[test] fn lines_of_one_program_make_one_outcome() { ``` </details>
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-24 12:06 UTC · original

One more Windows check for 31953ea. A synthetic listing with the relative path copy Ps files/shader.rpf dropped a program line. The two spaces after Ps were picked as the outcome delimiter before the parser checked whether the text before them was a complete label.

With the fix, the built victory compare reports two programs in both runs and one pipeline loss. The parser regression fails with the original split and passes with the patch. It also checks that an instruction offset in the label and double spaces in the diagnostic are preserved as expected. All six compare tests passed. The patch also applies over the BOM follow-up above.

AI-assisted. Verified with synthetic lists on Windows.

Incremental patch on 31953ea
diff --git a/apps/victory/src/compare.rs b/apps/victory/src/compare.rs
index 81799c7..37be546 100644
--- a/apps/victory/src/compare.rs
+++ b/apps/victory/src/compare.rs
@@ -77,14 +77,15 @@ impl Outcome {
 
 /// One line of the list into the program's key and the line's outcome.
 fn split(line: &str) -> Option<(String, &str)> {
-    // A validator's message may hold two spaces itself: the outcome starts
-    // at the first pair that ends a program's label.
-    let cut = line
-        .match_indices("  ")
-        .map(|(at, _)| at)
-        .find(|&at| ends_a_label(&line[..at]))?;
-    let (label, outcome) = line.split_at(cut);
-    Some((key(label)?, &outcome[2..]))
+    // Both a path and a diagnostic can contain two spaces. The boundary
+    // is the first pair preceded by a complete program label.
+    line.match_indices("  ").find_map(|(at, _)| {
+        let (label, outcome) = line.split_at(at);
+        if !ends_a_label(label) {
+            return None;
+        }
+        Some((key(label)?, &outcome[2..]))
+    })
 }
 
 /// Whether `head` ends in a stage, as a program's label does, with the
@@ -397,6 +398,17 @@ shaders.rpf@0x70 G_Wrapped Vs  pipeline created\n";
         assert_eq!(parse("containers   6\n"), None);
     }
 
+    #[test]
+    fn stage_like_path_text_does_not_hide_the_program() {
+        let label = "copy Ps  files/shader.rpf@0x20 A_Wrapped Cs";
+        let key = "shader.rpf@0x20 A_Wrapped Cs";
+        let success = format!("{label}  pipeline created");
+        let message = "emit: unsupported instruction  at a test offset";
+        let failure = format!("{label} at 0x2c  {message}");
+        assert_eq!(split(&success), Some((key.into(), "pipeline created")));
+        assert_eq!(split(&failure), Some((key.into(), message)));
+    }
+
     #[test]
     fn the_report_counts_gains_losses_and_moves() {
         let (before, after) = parse_both();
**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-24 12:06 UTC · [original](https://github.com/Marvisak/VIctory/issues/787#issuecomment-7130983804) One more Windows check for `31953ea`. A synthetic listing with the relative path `copy Ps files/shader.rpf` dropped a program line. The two spaces after `Ps` were picked as the outcome delimiter before the parser checked whether the text before them was a complete label. With the fix, the built `victory compare` reports two programs in both runs and one pipeline loss. The parser regression fails with the original `split` and passes with the patch. It also checks that an instruction offset in the label and double spaces in the diagnostic are preserved as expected. All six compare tests passed. The patch also applies over the BOM follow-up above. AI-assisted. Verified with synthetic lists on Windows. <details> <summary>Incremental patch on 31953ea</summary> ```diff diff --git a/apps/victory/src/compare.rs b/apps/victory/src/compare.rs index 81799c7..37be546 100644 --- a/apps/victory/src/compare.rs +++ b/apps/victory/src/compare.rs @@ -77,14 +77,15 @@ impl Outcome { /// One line of the list into the program's key and the line's outcome. fn split(line: &str) -> Option<(String, &str)> { - // A validator's message may hold two spaces itself: the outcome starts - // at the first pair that ends a program's label. - let cut = line - .match_indices(" ") - .map(|(at, _)| at) - .find(|&at| ends_a_label(&line[..at]))?; - let (label, outcome) = line.split_at(cut); - Some((key(label)?, &outcome[2..])) + // Both a path and a diagnostic can contain two spaces. The boundary + // is the first pair preceded by a complete program label. + line.match_indices(" ").find_map(|(at, _)| { + let (label, outcome) = line.split_at(at); + if !ends_a_label(label) { + return None; + } + Some((key(label)?, &outcome[2..])) + }) } /// Whether `head` ends in a stage, as a program's label does, with the @@ -397,6 +398,17 @@ shaders.rpf@0x70 G_Wrapped Vs pipeline created\n"; assert_eq!(parse("containers 6\n"), None); } + #[test] + fn stage_like_path_text_does_not_hide_the_program() { + let label = "copy Ps files/shader.rpf@0x20 A_Wrapped Cs"; + let key = "shader.rpf@0x20 A_Wrapped Cs"; + let success = format!("{label} pipeline created"); + let message = "emit: unsupported instruction at a test offset"; + let failure = format!("{label} at 0x2c {message}"); + assert_eq!(split(&success), Some((key.into(), "pipeline created"))); + assert_eq!(split(&failure), Some((key.into(), message))); + } + #[test] fn the_report_counts_gains_losses_and_moves() { let (before, after) = parse_both(); ``` </details>
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-24 19:45 UTC · original

@⁠Pablo-Barros your fix for this issue is now in a pull request, #1610, with seven other fixes from contributors' forks: the branch is merged as it is, with your commit(s) and your name unchanged, onto main ffe310e. Clippy (both runs) and cargo test --workspace pass on the result. If you would rather open your own pull request for this one, say so and I will take it out of #1610. AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-24 19:45 UTC · [original](https://github.com/Marvisak/VIctory/issues/787#issuecomment-7142545530) @⁠Pablo-Barros your fix for this issue is now in a pull request, #1610, with seven other fixes from contributors' forks: the branch is merged as it is, with your commit(s) and your name unchanged, onto `main` `ffe310e`. Clippy (both runs) and `cargo test --workspace` pass on the result. If you would rather open your own pull request for this one, say so and I will take it out of #1610. AI-assisted (Claude Code); no game data.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 03:52 UTC · original

Automated triage for the maintainers. A request for a victory compare command that diffs two translate --list outputs program by program. It fits the project: it is an offline tool that works on listings of the user's own copy. The branch cli/translate-compare (with the BOM and label-parsing follow-ups in the comments) has no open PR, and the combined PR #1610 mentioned above is not open either. Pull requests are open to everyone, so please open one.

Open PR #1541 (list-diff, which compares two translate listings program by program) covers the same ground. The two should be compared there so only one lands.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 03:52 UTC · [original](https://github.com/Marvisak/VIctory/issues/787#issuecomment-7152325112) <!-- victory-issue-triage v1 verdict=tracked seen=2026-11-24T19:45:26Z at=2026-11-25T03:52:48Z --> Automated triage for the maintainers. A request for a `victory compare` command that diffs two `translate --list` outputs program by program. It fits the project: it is an offline tool that works on listings of the user's own copy. The branch `cli/translate-compare` (with the BOM and label-parsing follow-ups in the comments) has no open PR, and the combined PR #1610 mentioned above is not open either. Pull requests are open to everyone, so please open one. Open PR #1541 (`list-diff`, which compares two translate listings program by program) covers the same ground. The two should be compared there so only one lands. --- _Generated by [Claude Code](https://claude.ai/code)_
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory#787
No description provided.