victory-hle: stop on unparseable switches and single-read env toggles #202
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/vktory6--VKtory!202
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-202"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@waldirjunior on GitHub · 2026-12-02 10:09 UTC · original
waldirjunior:fix/victory-hle-toggle-parsing→main· +791 −152 · 15 files · 2 commits · merged 2026-12-02 17:36 UTCWhat
Addresses part of
docs/TASKS.mditem "victory-hle's switches in the toggle inventory" (Related to #65).Under
docs/AGENTS.mdrule 2, every environment switch must be read in one place with one default, and a set value that fails to parse must stop the start instead of silently falling back to the default. This PR validates all parsedvictory-hleswitches eagerly at startup before the title is loaded, beforevkback-unix/unixgateis opened, and before DirectStorage worker threads are spawned (following theResult<_, String>startup check pattern from PR #34), consolidates duplicated path reads behindOnceLockhelpers, and cleans up thevictory-hlepolicy inventory.Changes
crates/victory-hle/src/env.rs,apps/victory/src/run.rs):victory_hle::env::Switch<T>(holding name, default, parser, andOnceLock<T>in one place),parse_var,parse_trace_level,parse_auto_or_range, andpub fn validate_switches() -> Result<(), String>.victory_hle::env::validate_switches().map_err(anyhow::Error::msg)?;at the start ofapps/victory/src/run.rs(before CPU checks, title loading,vkback-unix, or worker threads) so invalid or non-UTF-8 values stop the start cleanly with exit code1instead of panicking lazily in worker threads or acrossextern "system"FFI boundaries.victory-hleswitches covered (11 switches):VICTORY_DSP_GAIN(crates/victory-hle/src/modules/dsp.rs): finite positivef32(v.is_finite() && v > 0.0, default1.0).VICTORY_DSTORAGE_IO(crates/victory-hle/src/modules/dstorage.rs):one,handles,overlapped, ordirect(defaulthandles).VICTORY_WALLS_TRACE(crates/victory-hle/src/modules/dstorage.rs):0..=2(default0).VICTORY_DSTORAGE_TRACE(crates/victory-hle/src/modules/dstorage.rs):0..=2(default0).VICTORY_DSTORAGE_RETRIES(crates/victory-hle/src/modules/dstorage.rs):u32(default12, accepts0, rejects negative/non-numeric).VICTORY_MAP_THREADS(crates/victory-hle/src/modules/xmem.rs,xmem/pool.rs):autoor1..=32(default8; removes silent.clamp(1, 32)).VICTORY_IMAGE_WATCH(crates/victory-hle/src/image_watch.rs): comma-separatedname=hex[:1|2|4|8]entries (rejects empty/malformed entries instead of silently discarding them).VICTORY_KEYS(crates/victory-hle/src/modules/gameinput.rs,diagnosticsfeature): comma-separated<seconds>:<key>or<from>-<to>:<key>entries (rejects empty entries, invalid times,to < from, and unknown keys).VICTORY_PROCESS_PRIORITY(crates/victory-hle/src/runtime.rs):normal/0orabove_normal/1(default above normal).VICTORY_HOST_PADS(crates/victory-hle/src/modules/gameinput.rs):onoroff(defaulton).VICTORY_UMEM_SO(crates/victory-hle/src/modules/umem.rs): non-empty valid UTF-8 path (default/tmp/libumem_unix.so; rejects non-UTF-8 and blank values instead of silently falling back).victory-hleenvironment variables (rule 22 scope accounting):VICTORY_DSTORAGE_HALF,VICTORY_EFFICIENCY_MODE,VICTORY_UMEM_CPU_PROBE,VICTORY_PORT_CONSTANTS,VICTORY_INPLACE_COMMIT,VICTORY_TITLE_PRIORITIES,VICTORY_DSP_CONVOLVE,VICTORY_ONE_PAD,VICTORY_SECTION_WINDOW,VICTORY_STREAM_NOTICE,VICTORY_MAP_LEAN,VICTORY_STREAM_PRIORITY,VKB_STRICT): intentionally kept as0/1flags consistent withgreenfield/umem/src/switches.rs(Kind::Flagacceptst != "0", tested byswitches::tests::set_and_parse) andgreenfield/umem/src/loud.rs(which sharesVKB_STRICT). The fiveabswitches among them are also slated for removal indocs/TASKS.md.VICTORY_DSTORAGE_LOG,VICTORY_AUDIO_CAPTURE,VICTORY_KEYS_FILE,VICTORY_XMA_DUMP): read viavar_oswith no text parsing.VICTORY_DSTORAGE_LOG(dstorage/stream_log.rs) andVICTORY_AUDIO_CAPTURE(audio/capture.rs) are consolidated into singleOnceLock-cached helpers (path(),output_path()).external) variables (VICTORY_AUDIO_CAPTURE_OF,VICTORY_RELAUNCHED_FROM): set internally by our own child-process spawns.greenfield/tools/policy/toggles.txt: removed stale pre-#79 comment and aligned inaccurate kinds/notes (VICTORY_DSTORAGE_IOtune->ab,VICTORY_EFFICIENCY_MODEmode->option,VICTORY_PROCESS_PRIORITYtune->option,VICTORY_STREAM_PRIORITYtune->debug,VICTORY_UMEM_SOgpu->path, plus updated notes).greenfield/tools/policy/oversize.txtcounts where files shrank:crates/victory-hle/src/modules/xmem.rs(2521->2519) andcrates/victory-hle/src/modules/dstorage.rs(1820->1817).parse_var,parse_gain,Io::parse,parse_walls_trace,parse_dstorage_trace,parse_retries,parse_map_threads,parse_words,host::parse_keys,parse_process_priority,parse_host_pads,parse_so_path) andvalidate_switches/validate_switches_withare tested directly against production definitions (Switch::parse_raw).This intentionally keeps #65 and the
docs/TASKS.mditem open: removing the answeredabswitches and adding owner/removal comments to the untouched switches remain separate follow-up work.The reference
No console, vkd3d-proton, or D3D12-path counterpart (rule 12): this enforces our own rule 2 environment-switch policy in
victory-hleand keeps the repository's policy tables accurate.Evidence
Unit tests, end-to-end startup rejection under Proton Wine, policy checks, full
tools/build.shbuilds, and all workspace clippy checks are sufficient here (rule 27): default behaviour when switches are unset or valid is unchanged, and every parsed switch andvalidate_switchesis exercised directly by unit tests. No Vulkan calls or SPIR-V output are touched, so no Vulkan validation run is needed (rule 30).Verified on Linux x86_64 (
rustc 1.98.1,cargo-xwin 0.24.1, Proton Experimental Wine):tools/build.shbuilds (4/4 pass):cargo xwin build --profile diag -p victory --target x86_64-pc-windows-msvc --features diagnostics -j 6— passed.(cd greenfield/wine && cargo build --release -p vkback-unix -j 6)— passed.(cd greenfield/vkback && cargo build --release --bin vk-store -j 6)— passed.(cd greenfield/vkback/translate && cargo build --release --bins -j 6)— passed.-D warnings, 5/5 + default-features PE check pass):cargo xwin clippy --workspace --all-targets --all-features --target x86_64-pc-windows-msvc --locked -- -D warnings— 0 warnings.cargo xwin clippy -p victory-hle -p victory --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings(withoutdiagnostics) — 0 warnings.cargo clippy -p victory-shader -p victory-formats -p victory-core -p xtask --all-targets --locked -- -D warnings— 0 warnings.(cd greenfield && cargo clippy --workspace --all-targets --locked -- -D warnings)— 0 warnings.(cd greenfield/wine && cargo clippy --workspace --all-targets --locked -- -D warnings)— 0 warnings.(cd greenfield/vkback/translate && cargo clippy --workspace --all-targets --locked -- -D warnings)— 0 warnings.cargo test -p victory-shader -p victory-formats -p victory-core -p xtask --locked— passed (victory-core: 13,victory-formats: 49 passed / 5 ignored,victory-shader: 240 passed / 2 ignored,xtask: 6 includingrepository_passes_policyandlint_tables_match).(cd greenfield && cargo test -p umem -p frame -p vkback --lib --locked)— passed (umem: 13,frame: 22,vkback: 168 passed / 3 ignored).(cd greenfield && cargo test -p vkback --test policy --locked -- --nocapture)— 6/6 passed (xmem.rs2519/2519,dstorage.rs1817/1817,gameinput.rs1485/1500,toggles_registeredclean).cargo xtask policy— passed (asset policy: 532 files ok).victory-hleunit tests and E2E startup check under Proton Experimental Wine:cargo xwin test -p victory-hle --features diagnostics --target x86_64-pc-windows-msvc --no-run -j 6.victory_hle.exe): 187 passed, 0 failed, 2 ignored (benchmarksread_benchandmap_bench).env::tests dsp_gain dstorage_io dstorage_trace dstorage_retries map_threads words_are_read process_priority umem_so_path only_an_explicit_switch victory_keys): 19 passed, 0 failed, 170 filtered out (including the Windows-only non-UTF-8OsStringtests forparse_varandVICTORY_UMEM_SO).VICTORY_WALLS_TRACE=bogus VICTORY_DSP_GAIN=-1 VICTORY_DSTORAGE_RETRIES=many victory.exe run nonexistent.exe): exited immediately with code1, printing all three switch errors before attempting to open the executable or startvkback-unix.Checklist (docs/AGENTS.md)
docs/TASKS.mdnot edited, the fixed item named above (rule 29)VICTORY_DSP_GAINretains its textbook1.0default while rejecting non-positive/non-finite values at startupvictory-hleswitch stops the start on a bad value (rule 2; remaining untouched switches tracked in #65)unsafeblock has a// SAFETY:comment; no raw pointer around the borrow checker (rule 36) — nounsafeadded or changedTRANSLATOR_VERSIONbumped if the translator's output changes (rule 27) — translator untouchedAGENTS.md rule 2 requires each environment switch to be read in one place with one default and to stop the start when a set value does not parse instead of silently falling back to the default (docs/TASKS.md 'victory-hle's switches in the toggle inventory'). - Add crate::env::{parse_or, parse_var} so every parsed victory-hle switch returns its default when unset and panics naming the variable and bad value when non-UTF-8 or invalid. - Apply it to the whole class of parsed victory-hle switches: VICTORY_DSP_GAIN (finite f32), VICTORY_DSTORAGE_IO (known I/O mode), VICTORY_WALLS_TRACE (u8), VICTORY_DSTORAGE_TRACE (u8), VICTORY_DSTORAGE_RETRIES (u32), and VICTORY_MAP_THREADS (auto or 1..=32). - Read VICTORY_DSTORAGE_LOG (stream_log.rs) and VICTORY_AUDIO_CAPTURE (audio/capture.rs) in one helper each instead of two call sites. - Clean up stale pre-#79 comments and inaccurate notes/kinds for victory-hle entries in greenfield/tools/policy/toggles.txt, and lower dstorage.rs's count from 1820 to 1818 in oversize.txt. - Add unit tests calling the production parsers directly (env, dsp, dstorage, xmem). No Vulkan calls or SPIR-V output are touched, so no validation run is needed (rule 30).@vktory6 on GitHub · 2026-12-02 17:37 UTC · original
Merged, thanks: every victory-hle switch is read once and a value that does not parse stops the start (rule 2). #224 can merge main now, as you planned.