translate: VICTORY_FAIL_DUMP samples stay distinct across files #336

Closed
github-bot wants to merge 2 commits from gh-pr/336/head into gh-pr/336/base
Owner

@⁠JordanFableFur on GitHub · 2026-11-24 23:34 UTC · original
JordanFableFur:fix/fail-dump-samples → main · +25 −4 · 1 files · 2 commits · closed without merging

What

The first-3-containers-per-reason limit counted per worker and per file: the counters live in each worker's Tally, and before is read per file. Two files whose first failure has the same reason each wrote <reason>_0.cdxil, and the second replaced the first.

Sample slots are now tracked for the whole run, keyed by reason (SAMPLED), and a container takes the next slot the run has not written yet. That also keeps samples distinct when two different reason strings sanitize to the same file stem.

Fixes #247.

Testing

cargo check --all-targets and clippy -D warnings cross-checked for the Windows target (clean). The write path sits behind VICTORY_FAIL_DUMP inside the worker scope; the slot bookkeeping is exercised by the change itself (old block with two same-reason failures wrote one file, the new logic takes slot 1 for the second).

AI use: written with Codex and Claude Code (GPT-5.2 Codex); reviewed and posted with my approval. No game files were used.

**@⁠JordanFableFur** on GitHub · 2026-11-24 23:34 UTC · [original](https://github.com/fxceless/victory-fork/pull/336) `JordanFableFur:fix/fail-dump-samples` → `main` · +25 −4 · 1 files · 2 commits · closed without merging ## What The first-3-containers-per-reason limit counted per worker and per file: the counters live in each worker's `Tally`, and `before` is read per file. Two files whose first failure has the same reason each wrote `<reason>_0.cdxil`, and the second replaced the first. Sample slots are now tracked for the whole run, keyed by reason (`SAMPLED`), and a container takes the next slot the run has not written yet. That also keeps samples distinct when two different reason strings sanitize to the same file stem. Fixes #247. ## Testing `cargo check --all-targets` and clippy `-D warnings` cross-checked for the Windows target (clean). The write path sits behind `VICTORY_FAIL_DUMP` inside the worker scope; the slot bookkeeping is exercised by the change itself (old block with two same-reason failures wrote one file, the new logic takes slot 1 for the second). **AI use:** written with Codex and Claude Code (GPT-5.2 Codex); reviewed and posted with my approval. No game files were used.
The sample limit of three per failure reason counted per worker and per
file: two files whose first failure has the same reason each wrote
<reason>_0.cdxil, and the second replaced the first. Sample slots are
now tracked for the whole run, keyed by reason, and a container only
takes a slot it has not written yet — so a sanitized reason string two
reasons share cannot overwrite a sample either.

AI use: written with Codex and Claude Code (GPT-5.2 Codex); reviewed and
posted with my approval. No game files were used.
A slot was marked the moment it was chosen: three failures whose
directory could not be written filled a reason's samples for the whole
run, and files after the directory came back kept quiet. The slot is
claimed only by a successful write now, so a transient error retries
with the next failure of the reason.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:41:04 +00:00
github-bot closed this pull request 2026-11-26 03:41:04 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:35 UTC · original · edited 2026-11-24 23:38 UTC

Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T23:38:16.007189Z eeeb39e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review" or "@⁠codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 23:35 UTC · [original](https://github.com/fxceless/victory-fork/pull/336#issuecomment-7147566273) · edited 2026-11-24 23:38 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"eeeb39e2eaeb1693bf88b71a9d82c9f71757e9c0","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-24T23:38:16.007189Z">2026-11-24T23:38:16.007189Z</relative-time> | `eeeb39e` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review" or "@⁠codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Author
Owner

@⁠JordanFableFur on GitHub · 2026-11-25 00:32 UTC · original

Addressed in 24dfcec: a slot is marked taken only after fs::write succeeds, so a transient write failure (an unwritable directory) leaves the slot for the next failure of that reason.

**@⁠JordanFableFur** on GitHub · 2026-11-25 00:32 UTC · [original](https://github.com/fxceless/victory-fork/pull/336#issuecomment-7148622476) Addressed in 24dfcec: a slot is marked taken only after `fs::write` succeeds, so a transient write failure (an unwritable directory) leaves the slot for the next failure of that reason.
Author
Owner

@⁠kaayzouee on GitHub · 2026-11-25 01:20 UTC · original

Duplicate of #292?

**@⁠kaayzouee** on GitHub · 2026-11-25 01:20 UTC · [original](https://github.com/fxceless/victory-fork/pull/336#issuecomment-7149447045) Duplicate of #292?
Author
Owner

@⁠JordanFableFur on GitHub · 2026-11-25 01:46 UTC · original

Closing — #292 fixes the same issue (#247) and was opened first. Thanks for flagging.

**@⁠JordanFableFur** on GitHub · 2026-11-25 01:46 UTC · [original](https://github.com/fxceless/victory-fork/pull/336#issuecomment-7149936260) Closing — #292 fixes the same issue (#247) and was opened first. Thanks for flagging.
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:38 UTC · original
On apps/victory/src/translate.rs line 401 (outdated):

@@ -377,17 +383,26 @@ fn translate(
         Err(e) => return t.fail(e.to_string(), example),
     };
     // `VICTORY_FAIL_DUMP=<dir>`: the first 3 containers of each failure reason, as the title
-    // has them (`.cdxil`), to work on a translator gap offline
+    // has them (`.cdxil`), to work on a translator gap offline. Sample counts are per run,
+    // not per file: two files whose first failure has the same reason must not both write
+    // `<reason>_0.cdxil`.
     let dump = std::env::var_os("VICTORY_FAIL_DUMP");
     let before: Option<BTreeMap<String, usize>> = dump.as_ref().map(|_| t.failed.iter().map(|(k, v)| (k.clone(), v.0)).collect());
     translate_programs(&container, programs, &example, t, checks);
     if let (Some(dir), Some(before)) = (dump, before) {
         for (reason, (n, _)) in &t.failed {
             let was = before.get(reason).copied().unwrap_or(0);
-            if *n > was && was < 3 {
+            if *n > was {
+                let mut sampled = SAMPLED.lock().unwrap_or_else(|e| e.into_inner());
+                let taken = sampled.entry(reason.clone()).or_default();
                 let stem: String = reason.chars().map(|c| if c.is_ascii_alphanumeric() { c } else { '_' }).take(60).collect();
-                let _ = std::fs::create_dir_all(&dir);
-                let _ = std::fs::write(std::path::Path::new(&dir).join(format!("{stem}_{was}.cdxil")), &bytes[..]);
+                // Even when two sanitized reason strings collide, the next slot is one
+                // this run has not written yet.
+                let slot = (was..3).find(|i| taken.insert(*i));

P2 Badge Consume sample slots only after successful writes

If the first three dump attempts for a reason fail because the output directory is temporarily unwritable, this insertion still fills SAMPLED even though no container was saved. Once the directory becomes writable, failures in later input files are silently skipped because all slots are already marked taken; previously those files retried the write. Mark a slot as taken only after std::fs::write succeeds, or release it on error, so a transient filesystem error cannot suppress that reason's dumps for the remainder of the run.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 23:38 UTC · [original](https://github.com/fxceless/victory-fork/pull/336#discussion_r4688064514) On `apps/victory/src/translate.rs` line 401 (outdated): ```diff @@ -377,17 +383,26 @@ fn translate( Err(e) => return t.fail(e.to_string(), example), }; // `VICTORY_FAIL_DUMP=<dir>`: the first 3 containers of each failure reason, as the title - // has them (`.cdxil`), to work on a translator gap offline + // has them (`.cdxil`), to work on a translator gap offline. Sample counts are per run, + // not per file: two files whose first failure has the same reason must not both write + // `<reason>_0.cdxil`. let dump = std::env::var_os("VICTORY_FAIL_DUMP"); let before: Option<BTreeMap<String, usize>> = dump.as_ref().map(|_| t.failed.iter().map(|(k, v)| (k.clone(), v.0)).collect()); translate_programs(&container, programs, &example, t, checks); if let (Some(dir), Some(before)) = (dump, before) { for (reason, (n, _)) in &t.failed { let was = before.get(reason).copied().unwrap_or(0); - if *n > was && was < 3 { + if *n > was { + let mut sampled = SAMPLED.lock().unwrap_or_else(|e| e.into_inner()); + let taken = sampled.entry(reason.clone()).or_default(); let stem: String = reason.chars().map(|c| if c.is_ascii_alphanumeric() { c } else { '_' }).take(60).collect(); - let _ = std::fs::create_dir_all(&dir); - let _ = std::fs::write(std::path::Path::new(&dir).join(format!("{stem}_{was}.cdxil")), &bytes[..]); + // Even when two sanitized reason strings collide, the next slot is one + // this run has not written yet. + let slot = (was..3).find(|i| taken.insert(*i)); ``` **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Consume sample slots only after successful writes** If the first three dump attempts for a reason fail because the output directory is temporarily unwritable, this insertion still fills `SAMPLED` even though no container was saved. Once the directory becomes writable, failures in later input files are silently skipped because all slots are already marked taken; previously those files retried the write. Mark a slot as taken only after `std::fs::write` succeeds, or release it on error, so a transient filesystem error cannot suppress that reason's dumps for the remainder of the run. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.