Game: recover SGD5 records from unparsed databases alongside intact ones #3049

Open
github-bot wants to merge 1 commit from github-bot/gh-3049 into main AGit
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 05:23 UTC · original
fuzeofficlal:fix/game-sgd5-mixed-fallback → main · +80 −9 · 1 files · 1 commits · open

Problem

crates/victory-game/src/sgd5.rs::records currently gates marker-based record recovery on dbs.is_empty(). When an archive contains multiple SGD5 databases and at least one parses cleanly while a sibling fails parse() (e.g. a damaged or unrecognized effect table after intact shader records), dbs is non-empty and every recoverable shader record in the unparsed sibling is silently omitted—even though scanning that database alone recovers them via marker fallback.

Fix

  • Factor scan_databases(file) to return (Vec<Database>, bool) indicating whether any SGD5 magic failed parse().
  • Keep the existing fast path when all databases parse cleanly (!unparsed) or when none parse (dbs.is_empty()).
  • When both parsed and unparsed databases are present, also scan MARKER occurrences strictly outside parsed [db.start..db.end) spans (via partition_point over the sorted non-overlapping spans) and merge records by file offset so every record is returned once in file order.

Verification

  • cargo test --locked -p victory-game (16 passed, including intact_database_does_not_suppress_fallback_for_damaged_sibling testing both good-then-bad and bad-then-good archive orders)
  • cargo test --locked -p victory (18 passed)
  • cargo clippy --locked -p victory-game -p victory --all-targets -- -D warnings
  • cargo xtask policy (191 files ok)
**@⁠fuzeofficlal** on GitHub · 2026-11-26 05:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/3049) `fuzeofficlal:fix/game-sgd5-mixed-fallback` → `main` · +80 −9 · 1 files · 1 commits · open ### Problem `crates/victory-game/src/sgd5.rs::records` currently gates marker-based record recovery on `dbs.is_empty()`. When an archive contains multiple SGD5 databases and at least one parses cleanly while a sibling fails `parse()` (e.g. a damaged or unrecognized effect table after intact shader records), `dbs` is non-empty and every recoverable shader record in the unparsed sibling is silently omitted—even though scanning that database alone recovers them via marker fallback. ### Fix - Factor `scan_databases(file)` to return `(Vec<Database>, bool)` indicating whether any `SGD5` magic failed `parse()`. - Keep the existing fast path when all databases parse cleanly (`!unparsed`) or when none parse (`dbs.is_empty()`). - When both parsed and unparsed databases are present, also scan `MARKER` occurrences strictly outside parsed `[db.start..db.end)` spans (via `partition_point` over the sorted non-overlapping spans) and merge records by file offset so every record is returned once in file order. ### Verification - `cargo test --locked -p victory-game` (16 passed, including `intact_database_does_not_suppress_fallback_for_damaged_sibling` testing both good-then-bad and bad-then-good archive orders) - `cargo test --locked -p victory` (18 passed) - `cargo clippy --locked -p victory-game -p victory --all-targets -- -D warnings` - `cargo xtask policy` (191 files ok)
`sgd5::records` only fell back to marker scanning when `databases(file)`
returned zero parsed databases. In an archive holding multiple SGD5
databases where at least one table parses cleanly and another fails
`parse()` (for example, due to an effect-table mismatch or truncation
after its shader records), all recoverable shader records from the
unparsed database were silently dropped.

Track whether any `SGD5` magic occurrence failed `parse()` during
`scan_databases`. When all databases parse cleanly, keep the fast table
path unchanged; when an archive mixes parsed and unparsed databases, also
scan for markers strictly outside parsed `[db.start..db.end)` spans and
merge all records in file order without duplicates.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:27:31 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 06:17 UTC · original

Automated triage for the maintainers.

Verdict: merge candidate. In crates/victory-game/src/sgd5.rs, records on main uses the marker fallback only when no database parses. In an archive where one database parses and a sibling does not, the sibling's records are therefore dropped. scan_databases now also reports whether any SGD5 magic failed to parse. If so, markers outside the parsed [start, end) spans are recovered and merged by file offset.

I checked the following:

  • The spans are sorted and do not overlap, because the scan resumes at db.end, so the partition_point lookup is valid.
  • Table-parsed records and marker-found records both use the marker position as offset, so sorting by offset cannot interleave them wrongly.
  • When every database parses, the fast path is unchanged. databases() behaves as before.

The only caller is the victory CLI's shader source listing (apps/victory/src/shader.rs), so the impact is limited to that tool. The new test covers both orders of a good and a damaged database.

CI: check passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 06:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/3049#issuecomment-7184283657) <!-- victory-triage v1 head=98d2d1eeb5b1ff6926a3f32b0a0e6e07a5f31707 verdict=merge-candidate at=2026-11-26T06:18:10Z --> Automated triage for the maintainers. **Verdict: merge candidate.** In `crates/victory-game/src/sgd5.rs`, `records` on `main` uses the marker fallback only when no database parses. In an archive where one database parses and a sibling does not, the sibling's records are therefore dropped. `scan_databases` now also reports whether any `SGD5` magic failed to parse. If so, markers outside the parsed `[start, end)` spans are recovered and merged by file offset. I checked the following: - The spans are sorted and do not overlap, because the scan resumes at `db.end`, so the `partition_point` lookup is valid. - Table-parsed records and marker-found records both use the marker position as `offset`, so sorting by offset cannot interleave them wrongly. - When every database parses, the fast path is unchanged. `databases()` behaves as before. The only caller is the `victory` CLI's shader source listing (`apps/victory/src/shader.rs`), so the impact is limited to that tool. The new test covers both orders of a good and a damaged database. CI: `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-26 05:25 UTC · original · approved these changes

Verified: scan_databases reports whether any magic failed to parse; records keeps the all-or-nothing fallback but on a mixed archive unions table records with marker records outside intact spans, deduplicated via covered (partition_point is correct on the parser's non-overlapping file-ordered spans) and re-sorted by offset. The test's corrupted sibling in both orders + the name/offset assertions discriminate the fix.

**@⁠kotekompotek** on GitHub · 2026-11-26 05:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/3049#pullrequestreview-6068968150) · **approved these changes** Verified: `scan_databases` reports whether any magic failed to parse; `records` keeps the all-or-nothing fallback but on a mixed archive unions table records with marker records outside intact spans, deduplicated via `covered` (partition_point is correct on the parser's non-overlapping file-ordered spans) and re-sorted by offset. The test's corrupted sibling in both orders + the name/offset assertions discriminate the fix.
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 09:11 UTC · original · approved these changes

Verified against origin/main (63bcca4):

  • cargo test -p victory-game -- --test-threads=1: 16/16 passed (including sgd5::tests::intact_database_does_not_suppress_fallback_for_damaged_sibling).
  • cargo clippy -p victory-game --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Cleanly ensures intact sibling databases do not suppress marker fallback recovery for damaged SGD5 databases.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 09:11 UTC · [original](https://github.com/Marvisak/VIctory/pull/3049#pullrequestreview-6071288530) · **approved these changes** Verified against `origin/main` (`63bcca4`): - `cargo test -p victory-game -- --test-threads=1`: 16/16 passed (including `sgd5::tests::intact_database_does_not_suppress_fallback_for_damaged_sibling`). - `cargo clippy -p victory-game --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Cleanly ensures intact sibling databases do not suppress marker fallback recovery for damaged SGD5 databases. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-26 19:31 UTC · original

NVIDIA full-suite run, to go with the reports above by Dukestar69, since none of them names a GPU run. Tested exact head 98d2d1e (on its base 63bcca4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 867 passed, 0 failed, 10 ignored.
  • The new tests ran and passed: intact_database_does_not_suppress_fallback_for_damaged_sibling.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-26 19:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/3049#issuecomment-7201689655) NVIDIA full-suite run, to go with the reports above by Dukestar69, since none of them names a GPU run. Tested exact head `98d2d1e` (on its base `63bcca4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **867 passed, 0 failed, 10 ignored**. - The new tests ran and passed: `intact_database_does_not_suppress_fallback_for_damaged_sibling`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3049/head:github-bot/gh-3049'
git switch 'github-bot/gh-3049'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3049'
git switch 'github-bot/gh-3049'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3049'
git switch 'github-bot/gh-3049'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3049'
git switch 'main'
git merge --squash 'github-bot/gh-3049'
git switch 'main'
git merge --ff-only 'github-bot/gh-3049'
git switch 'main'
git merge 'github-bot/gh-3049'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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!3049
No description provided.