wine: normalize device IDs with one process (WINE-DEVICE-ID-NORMALIZE) #3268

Closed
chagedUserHello wants to merge 3 commits from upstream-pr/3268 into main
chagedUserHello commented 2026-12-03 00:02:30 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by chagedUserHello on 2026-12-03T00:02:30Z.


No description provided.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5616986670 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3268). Originally posted by [chagedUserHello](https://github.com/chagedUserHello) on 2026-12-03T00:02:30Z. --- _No description provided._
copilot-pull-request-reviewer[bot] commented 2026-12-03 00:04:11 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-12-03T00:04:11Z.

Review: COMMENTED


No active review issues were identified for the Wine launcher device-selection optimization.

No open issues 🎉

What changed in this PR

Optimizes Wine launcher device selection by normalizing the requested PCI ID once while preserving case-insensitive matching and CRLF handling.

Changes:

  • Replaces per-node lowercase conversions with Bash case-insensitive matching.
  • Extends synthetic coverage to two render nodes, mixed-case IDs, and exactly one lowercase conversion.
File Description
tests/​test_run_game_wine_safety.py Adds mixed-case, CRLF fixtures and conversion-count verification.
scripts/​run_game_wine.sh Normalizes the selector once and matches sysfs IDs case-insensitively.

Review effort: Balanced

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6161308634 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3268#pullrequestreview-6161308634). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-12-03T00:04:11Z. **Review:** COMMENTED --- <!-- ccr-overview-v2 --> ### 🟢 Approval recommended No active review issues were identified for the Wine launcher device-selection optimization. **No open issues** 🎉 <details> <summary><strong>What changed in this PR</strong></summary> Optimizes Wine launcher device selection by normalizing the requested PCI ID once while preserving case-insensitive matching and CRLF handling. **Changes:** - Replaces per-node lowercase conversions with Bash case-insensitive matching. - Extends synthetic coverage to two render nodes, mixed-case IDs, and exactly one lowercase conversion. | File | Description | | ---- | ----------- | | tests/​test_run_game_wine_safety.py | Adds mixed-case, CRLF fixtures and conversion-count verification. | | scripts/​run_game_wine.sh | Normalizes the selector once and matches sysfs IDs case-insensitively. | </details> <sub>Review effort: Balanced</sub>
merzleckeier commented 2026-12-03 00:08:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T00:08:46Z.

Review: COMMENTED


One state-preservation edge case on 2293effb against main at 81efe4566. The unconditional shopt -u nocasematch at the end of the device scan clears an option that may already be on. When the caller exports BASHOPTS with nocasematch, downstream Bash helpers inherit the changed value.

I reran the actual launcher with the synthetic sysfs fixture and a stub Wine command that records shopt -q nocasematch. With the option initially on, the stub sees on on main and off on this PR. Recording the entry state and only undoing shopt -s when the launcher enabled it made both the initially-on and initially-off cases pass in a scratch copy.

The intended optimization works on this head. The new assertion sees five conversions on main and one here, and all 36 Linux tests across the launcher, safety, and summary suites passed. They also pass with the state-preservation change. Synthetic fixtures only. AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6161353864 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3268#pullrequestreview-6161353864). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-03T00:08:46Z. **Review:** COMMENTED --- One state-preservation edge case on `2293effb` against `main` at `81efe4566`. The unconditional `shopt -u nocasematch` at the end of the device scan clears an option that may already be on. When the caller exports `BASHOPTS` with `nocasematch`, downstream Bash helpers inherit the changed value. I reran the actual launcher with the synthetic sysfs fixture and a stub Wine command that records `shopt -q nocasematch`. With the option initially on, the stub sees `on` on main and `off` on this PR. Recording the entry state and only undoing `shopt -s` when the launcher enabled it made both the initially-on and initially-off cases pass in a scratch copy. The intended optimization works on this head. The new assertion sees five conversions on main and one here, and all 36 Linux tests across the launcher, safety, and summary suites passed. They also pass with the state-preservation change. Synthetic fixtures only. AI-assisted.
fiestorra commented 2026-12-03 00:20:32 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-03T00:20:32Z.


VERIFY-3268 — Windows nativo: red then green (el script de wine, corrido por su test en bash)

Own commit 2293effb4 — scripts/run_game_wine.sh (7), tests/test_run_game_wine_safety.py (+34)

Ran at the head

python -I tests/test_run_game_wine_safety.py     3 tests — OK

Negative control: main's run_game_wine.sh back, tests kept:

FAIL: test_uppercase_device_inner_bash_lock_parent_and_summary_exit_propagation

It bites.

What the change is: the device id is normalised once instead of on every use — a WINE_DEVICE_ID-style string being lowercased in each of several places becomes lowercased once, where it is read. Seven lines in a shell script.

And the test is a small victory of its own: it drives the actual run_game_wine.sh through bash with a fake wine, and asserts the exit status propagates through the inner bash, the lock and the summary — a shell script's three most common ways to lose an exit code, all in one test name. That is why the test caught my reversal: the normalisation is one of the things that name pins.

What I could not test

  • A real Wine run: the test fakes wine; the device id's effect on a driver needs the title under Wine.

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7363079357 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3268#issuecomment-7363079357). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-03T00:20:32Z. --- ## VERIFY-3268 — Windows nativo: `red then green` (el script de wine, corrido por su test en bash) | | | |---|---| | Own commit | `2293effb4` — `scripts/run_game_wine.sh` (7), `tests/test_run_game_wine_safety.py` (+34) | **Ran at the head** ``` python -I tests/test_run_game_wine_safety.py 3 tests — OK ``` **Negative control**: `main`'s `run_game_wine.sh` back, tests kept: ``` FAIL: test_uppercase_device_inner_bash_lock_parent_and_summary_exit_propagation ``` **It bites.** **What the change is**: **the device id is normalised once instead of on every use** — a `WINE_DEVICE_ID`-style string being lowercased **in each of several places** becomes **lowercased once, where it is read.** **Seven lines in a shell script.** **And the test is a small victory of its own**: it drives the *actual* `run_game_wine.sh` **through bash with a fake `wine`**, and asserts **the exit status propagates through the inner bash, the lock and the summary** — **a shell script's three most common ways to lose an exit code**, all in one test name. **That is why the test caught my reversal**: the normalisation is one of the things that name pins. **What I could not test** - **A real Wine run**: the test fakes `wine`; **the device id's effect on a driver** needs the title under Wine. Written with an AI assistant.
josefernanlo commented 2026-12-03 00:35:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by josefernanlo on 2026-12-03T00:35:31Z.


Addressed the nocasematch state-preservation review in 8fc604271.

The launcher now records shopt -q nocasematch before enabling it and only clears the option when this scan enabled it. The safety fixture checks both inherited states at the actual wine stub: off -> off and exported BASHOPTS with nocasematch on -> on. The off-state case is also deterministic when the test process itself inherits BASHOPTS=nocasematch.

Validation:

  • python -I tests/test_run_game_wine_safety.py: 3 passed (including with hostile inherited BASHOPTS=nocasematch)
  • python -I tests/test_run_wine_tests.py: 65 passed, 14 skipped
  • python -I scripts/check_no_game_data.py scripts/run_game_wine.sh tests/test_run_game_wine_safety.py: passed
  • bash -n scripts/run_game_wine.sh, git diff --check: passed
  • Independent read-only re-review: LGTM

Synthetic fixtures only; no real Wine run or GPU.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7363365812 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3268#issuecomment-7363365812). Originally posted by [josefernanlo](https://github.com/josefernanlo) on 2026-12-03T00:35:31Z. --- Addressed the `nocasematch` state-preservation review in `8fc604271`. The launcher now records `shopt -q nocasematch` before enabling it and only clears the option when this scan enabled it. The safety fixture checks both inherited states at the actual `wine` stub: `off -> off` and exported `BASHOPTS` with `nocasematch` `on -> on`. The off-state case is also deterministic when the test process itself inherits `BASHOPTS=nocasematch`. Validation: - `python -I tests/test_run_game_wine_safety.py`: 3 passed (including with hostile inherited `BASHOPTS=nocasematch`) - `python -I tests/test_run_wine_tests.py`: 65 passed, 14 skipped - `python -I scripts/check_no_game_data.py scripts/run_game_wine.sh tests/test_run_game_wine_safety.py`: passed - `bash -n scripts/run_game_wine.sh`, `git diff --check`: passed - Independent read-only re-review: LGTM Synthetic fixtures only; no real Wine run or GPU.
merzleckeier commented 2026-12-03 00:42:52 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T00:42:52Z.

Review: COMMENTED


Rechecked 8fc60427. The new regression detects the inherited nocasematch loss with the previous launcher 2293effb and passes with the fix. The inherited-on and default-off cases now both reach the synthetic Wine subprocess with their original state. All 36 tests in the Wine launcher, safety and summary suites passed on Linux, including the one-conversion check. This resolves my earlier review point. AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6161685687 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3268#pullrequestreview-6161685687). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-03T00:42:52Z. **Review:** COMMENTED --- Rechecked `8fc60427`. The new regression detects the inherited `nocasematch` loss with the previous launcher `2293effb` and passes with the fix. The inherited-on and default-off cases now both reach the synthetic Wine subprocess with their original state. All 36 tests in the Wine launcher, safety and summary suites passed on Linux, including the one-conversion check. This resolves my earlier review point. AI-assisted.
Copilot commented 2026-12-03 00:50:10 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Copilot on 2026-12-03T00:50:10Z.

Code review location: tests/test_run_game_wine_safety.py; line 217

@@ -196,11 +214,24 @@ def test_uppercase_device_inner_bash_lock_parent_and_summary_exit_propagation(se
                 _to_bash_path(out1),
             ]
             env = os.environ.copy()
+            env.pop("BASHOPTS", None)

Without exported BASHOPTS, the Wine stub starts with nocasematch off even if the launcher leaves it enabled, so the new off assertion cannot detect a missing restore. Explicitly disable nocasematch and export BASHOPTS in the first wrapper so leaked options reach the probe.

<!-- greyfinch-sync:ubiquitarianism/leonida:review-comment:4778307200 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3268#discussion_r4778307200). Originally posted by [Copilot](https://github.com/apps/copilot-pull-request-reviewer) on 2026-12-03T00:50:10Z. **Code review location:** `tests/test_run_game_wine_safety.py`; line 217 ~~~~diff @@ -196,11 +214,24 @@ def test_uppercase_device_inner_bash_lock_parent_and_summary_exit_propagation(se _to_bash_path(out1), ] env = os.environ.copy() + env.pop("BASHOPTS", None) ~~~~ --- Without exported `BASHOPTS`, the Wine stub starts with `nocasematch` off even if the launcher leaves it enabled, so the new `off` assertion cannot detect a missing restore. Explicitly disable `nocasematch` and export `BASHOPTS` in the first wrapper so leaked options reach the probe.
copilot-pull-request-reviewer[bot] commented 2026-12-03 00:50:11 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-12-03T00:50:11Z.

Review: COMMENTED


The Wine safety test can pass despite a missing nocasematch restore because the wrapper does not export BASHOPTS to the stub.

1 open issue

Review effort: Max

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6161754192 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3268#pullrequestreview-6161754192). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-12-03T00:50:11Z. **Review:** COMMENTED --- <!-- ccr-overview-v2 --> ### 🟡 Changes recommended The Wine safety test can pass despite a missing `nocasematch` restore because the wrapper does not export `BASHOPTS` to the stub. <details open> <summary><strong>1 open issue</strong></summary> - <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.png" alt="Medium severity" width="62" height="18" align="texttop"></picture> [Export nocasematch in the wrapper to detect leaked shell options](https://github.com/ProjectLeonida/mandy/pull/3268#discussion_r4778307200) · New </details> <sub>Review effort: Max</sub>

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
ProjectLeonida/mandy!3268
No description provided.