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

Open
fuzeofficlal wants to merge 1 commit from upstream-pr/3049 into main
fuzeofficlal commented 2026-11-26 05:23:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T05:23:38Z.


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)
<!-- greyfinch-sync:Marvisak/VIctory:issue:5504512084 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3049). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T05:23:38Z. --- ### 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)
kotekompotek commented 2026-11-26 05:25:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T05:25:53Z.

Review: APPROVED


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.

<!-- greyfinch-sync:Marvisak/VIctory:review:6068968150 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3049#pullrequestreview-6068968150). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-26T05:25:53Z. **Review:** APPROVED --- 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.
Marvisak commented 2026-11-26 07:01:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T06:17:29Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7184283657 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3049#issuecomment-7184283657). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T06:17:29Z. --- <!-- 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)_
Dukestar69 commented 2026-11-26 09:11:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T09:11:58Z.

Review: APPROVED


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).

<!-- greyfinch-sync:Marvisak/VIctory:review:6071288530 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3049#pullrequestreview-6071288530). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T09:11:58Z. **Review:** APPROVED --- 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).
futurepro62 commented 2026-11-26 19:31:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T19:31:53Z.


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.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7201689655 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3049#issuecomment-7201689655). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-26T19:31:53Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3049:upstream-pr/3049'
git switch 'upstream-pr/3049'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3049'
git switch 'upstream-pr/3049'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3049'
git switch 'upstream-pr/3049'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3049'
git switch 'main'
git merge --squash 'upstream-pr/3049'
git switch 'main'
git merge --ff-only 'upstream-pr/3049'
git switch 'main'
git merge 'upstream-pr/3049'
git push origin 'main'
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
Marvisak/VIctory!3047
No description provided.