bcpack: BCPack refusal inspector review follow-up #3346

Merged
romn4rch merged 8 commits from upstream-pr/3346 into main 2026-11-30 19:35:33 +00:00
romn4rch commented 2026-11-28 11:23:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by romn4rch on 2026-11-28T11:23:37Z.


Alternate review revision for #1940. This branch contains the existing BCPack inspector work plus verified review fixes and consistency checks. The original PR remains open because its author-owned branch was not writable from this account; these submissions overlap, so please keep only one and close/mark the other as superseded when choosing.

Validation: git diff --check and the Python consistency check across inspector, decoder, and fixture lane tables passed. C++ tests were not run because the required MSVC cl toolchain is unavailable in this environment.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5539606432 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3346). Originally posted by [romn4rch](https://github.com/romn4rch) on 2026-11-28T11:23:37Z. --- Alternate review revision for #1940. This branch contains the existing BCPack inspector work plus verified review fixes and consistency checks. The original PR remains open because its author-owned branch was not writable from this account; these submissions overlap, so please keep only one and close/mark the other as superseded when choosing. Validation: `git diff --check` and the Python consistency check across inspector, decoder, and fixture lane tables passed. C++ tests were not run because the required MSVC `cl` toolchain is unavailable in this environment.
KelboLive commented 2026-11-28 21:24:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-28T21:24:20Z.

Review: APPROVED


LGTM — clean cold-path inspector that names the class of BCPack failure.

  • LaneFailure enum and LaneReport struct thread through decode_lanes_reference with note() and stall_failure() helpers.
  • New bcpack_inspect.h is independent of the hot path: runs the lane decode with a report, maps failures to InspectClass, supports BC1–BC7.
  • 16 MiB output cap prevents oversized scratch allocation before any decode.
  • bcpack_inspect_check.cpp covers exact/truncated/padded/damaged streams for BC1/BC7 plus BC2/BC3/BC4/BC5/BC6 edge cases, with a --mutate collapse negative control.

The inspector is a pure read of lane state — no request-path changes.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6100145122 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3346#pullrequestreview-6100145122). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-28T21:24:20Z. **Review:** APPROVED --- LGTM — clean cold-path inspector that names the class of BCPack failure. - `LaneFailure` enum and `LaneReport` struct thread through `decode_lanes_reference` with `note()` and `stall_failure()` helpers. - New `bcpack_inspect.h` is independent of the hot path: runs the lane decode with a report, maps failures to `InspectClass`, supports BC1–BC7. - 16 MiB output cap prevents oversized scratch allocation before any decode. - `bcpack_inspect_check.cpp` covers exact/truncated/padded/damaged streams for BC1/BC7 plus BC2/BC3/BC4/BC5/BC6 edge cases, with a `--mutate collapse` negative control. The inspector is a pure read of lane state — no request-path changes.
KelboLive commented 2026-11-28 21:57:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-28T21:57:47Z.

Review: APPROVED


LGTM — clean cold-path inspector that names the class of BCPack failure.

  • LaneFailure enum and LaneReport struct thread through decode_lanes_reference with note() and stall_failure() helpers.
  • New bcpack_inspect.h is independent of the hot path: runs the lane decode with a report, maps failures to InspectClass, supports BC1–BC7.
  • 16 MiB output cap prevents oversized scratch allocation before any decode.
  • bcpack_inspect_check.cpp covers exact/truncated/padded/damaged streams for BC1/BC7 plus BC2/BC3/BC4/BC5/BC6 edge cases, with a --mutate collapse negative control.

The inspector is a pure read of lane state — no request-path changes.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6100255184 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3346#pullrequestreview-6100255184). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-28T21:57:47Z. **Review:** APPROVED --- LGTM — clean cold-path inspector that names the class of BCPack failure. - `LaneFailure` enum and `LaneReport` struct thread through `decode_lanes_reference` with `note()` and `stall_failure()` helpers. - New `bcpack_inspect.h` is independent of the hot path: runs the lane decode with a report, maps failures to `InspectClass`, supports BC1–BC7. - 16 MiB output cap prevents oversized scratch allocation before any decode. - `bcpack_inspect_check.cpp` covers exact/truncated/padded/damaged streams for BC1/BC7 plus BC2/BC3/BC4/BC5/BC6 edge cases, with a `--mutate collapse` negative control. The inspector is a pure read of lane state — no request-path changes.
Leyukaka commented 2026-11-29 06:54:30 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T06:54:30Z.

Review: COMMENTED


Reviewed head f8d2d51e by reading its diff against main 212d4b5f. Nothing was built or run. git merge-tree --write-tree origin/main f8d2d51e exits 0.

Checked by reading

  • INSPECT_LAYOUTS (bcpack_inspect.h:59-67) matches decode_bcpack on main for all seven formats: the alphabets table (bcpack_decoder.h:1391-1399), the lane counts (:1404), the block sizes (:1400) and the per-lane target output_size / 8 (:1403).
  • Every return false in decode_lanes_reference now records a failure first (bcpack_decoder.h:280, 285, 379, 399, 405, 419, 423 at head).
  • phase1 returns false in two places only: :165 (eab > 8) and :230 (flushed fragment not at the home state, reached only after a header with eab <= 8). The ln.eab > 8 test at head :378 therefore separates header_invalid from fragment_not_home exactly.
  • The block-stage note in the header holds. BC1 to BC5 refuse only on capacity or symbol count. BC6H refuses a mode outside 1 to 14 (bcpack_blocks_extra.inl:108, mode = symbol + 1). BC7 refuses an unmapped control code (bcpack_decoder.h:1104 at head).
  • The new cases test what their names say. Symbol 13 is mode 14, which is valid, and symbol 14 is mode 15, which is not. symbols[30] = 31, symbols[31] = 3 gives code (3 << 5) | 31 = 0x07f, whose table entry has valid = 0 (bcpack_tables.h:975).
  • decode_bcpack is unchanged, and decode_lanes without a report takes the same path as before. No refusal is removed.

Needs a run before merge

  • On pull requests the workflow runs cmake --build --preset pr and ctest --preset pr (windows.yml:490-493). In CMakePresets.json the pr build targets (:28-38) do not include bcpack_inspect_check, and the pr test filter (:51) matches no bcpack_inspect name. The PR description says the C++ tests were not run. So nothing shows that test_bc2_bc6_bc7 and test_inspect_layouts compile or pass at this head. Please post a dev run of ctest -R "^bcpack_inspect" at f8d2d51e (2 tests, the collapse control is WILL_FAIL).

Relation to #1940

  • The description presents this PR as an alternate revision of #1940. It carries #1940's commits up to 7de1131b plus one commit, and it edits the same four files.
  • #1940 has since moved to 23ab9d48, which also adds the BC2 and BC6H layouts. Two differences remain between the heads:
    • This PR gives the BC6H mode failure its own class, bc6_mode_invalid. #1940 reports it as control_code_unmapped.
    • #1940's test_all_formats_agree runs a 17-block fixture stream for each of formats 1 to 7, checks ok and request_shorter_than_stream, and compares each answer with decode_bcpack. Here BC2 and BC6H get a 1-block exact case, and the two block-stage failures are 1-block cases.
  • Only one of the two should merge.

Minor

  • inspect_bcpack maps lanes_ok == false with failure == none to ok (bcpack_inspect.h:136-138). No exit leaves none today. Mapping that case to a failure class would keep a future exit without note() from reporting ok.
  • The C++ test is registered inside the if(EXISTS "${INTAKE_PYTHON}") block but needs no Python. bcpack_encoder_check is registered outside it.
  • At bcpack_decoder.h:328, !met && is redundant after if (met) return.

No defect found by reading f8d2d51e. Open before merge: the dev run of the two bcpack_inspect tests, and the choice between this PR and #1940.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6101817134 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3346#pullrequestreview-6101817134). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-29T06:54:30Z. **Review:** COMMENTED --- Reviewed head `f8d2d51e` by reading its diff against `main` `212d4b5f`. Nothing was built or run. `git merge-tree --write-tree origin/main f8d2d51e` exits 0. **Checked by reading** - `INSPECT_LAYOUTS` (`bcpack_inspect.h:59-67`) matches `decode_bcpack` on `main` for all seven formats: the `alphabets` table (`bcpack_decoder.h:1391-1399`), the lane counts (`:1404`), the block sizes (`:1400`) and the per-lane target `output_size / 8` (`:1403`). - Every `return false` in `decode_lanes_reference` now records a failure first (`bcpack_decoder.h:280, 285, 379, 399, 405, 419, 423` at head). - `phase1` returns false in two places only: `:165` (`eab > 8`) and `:230` (flushed fragment not at the home state, reached only after a header with `eab <= 8`). The `ln.eab > 8` test at head `:378` therefore separates `header_invalid` from `fragment_not_home` exactly. - The block-stage note in the header holds. BC1 to BC5 refuse only on capacity or symbol count. BC6H refuses a mode outside 1 to 14 (`bcpack_blocks_extra.inl:108`, mode = symbol + 1). BC7 refuses an unmapped control code (`bcpack_decoder.h:1104` at head). - The new cases test what their names say. Symbol 13 is mode 14, which is valid, and symbol 14 is mode 15, which is not. `symbols[30] = 31, symbols[31] = 3` gives code `(3 << 5) | 31 = 0x07f`, whose table entry has `valid = 0` (`bcpack_tables.h:975`). - `decode_bcpack` is unchanged, and `decode_lanes` without a report takes the same path as before. No refusal is removed. **Needs a run before merge** - On pull requests the workflow runs `cmake --build --preset pr` and `ctest --preset pr` (`windows.yml:490-493`). In `CMakePresets.json` the `pr` build targets (`:28-38`) do not include `bcpack_inspect_check`, and the `pr` test filter (`:51`) matches no `bcpack_inspect` name. The PR description says the C++ tests were not run. So nothing shows that `test_bc2_bc6_bc7` and `test_inspect_layouts` compile or pass at this head. Please post a `dev` run of `ctest -R "^bcpack_inspect"` at `f8d2d51e` (2 tests, the collapse control is `WILL_FAIL`). **Relation to #1940** - The description presents this PR as an alternate revision of #1940. It carries #1940's commits up to `7de1131b` plus one commit, and it edits the same four files. - #1940 has since moved to `23ab9d48`, which also adds the BC2 and BC6H layouts. Two differences remain between the heads: - This PR gives the BC6H mode failure its own class, `bc6_mode_invalid`. #1940 reports it as `control_code_unmapped`. - #1940's `test_all_formats_agree` runs a 17-block fixture stream for each of formats 1 to 7, checks `ok` and `request_shorter_than_stream`, and compares each answer with `decode_bcpack`. Here BC2 and BC6H get a 1-block exact case, and the two block-stage failures are 1-block cases. - Only one of the two should merge. **Minor** - `inspect_bcpack` maps `lanes_ok == false` with `failure == none` to `ok` (`bcpack_inspect.h:136-138`). No exit leaves `none` today. Mapping that case to a failure class would keep a future exit without `note()` from reporting `ok`. - The C++ test is registered inside the `if(EXISTS "${INTAKE_PYTHON}")` block but needs no Python. `bcpack_encoder_check` is registered outside it. - At `bcpack_decoder.h:328`, `!met &&` is redundant after `if (met) return`. No defect found by reading `f8d2d51e`. Open before merge: the `dev` run of the two `bcpack_inspect` tests, and the choice between this PR and #1940.
JohnConnorNPC commented 2026-11-29 13:06:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-29T13:06:17Z.


Independent re-review of head f8d2d51e against main af1cab5c. Verdict: 2 MUST. Holding, not merging.

Checked

  • git merge-tree --write-tree origin/main f8d2d51e exits 0. main has not touched the four files since.
  • On a pull request, CI runs cmake --build --preset pr / ctest --preset pr (windows.yml, GITHUB_EVENT_NAME -eq 'pull_request' branch). CMakePresets.json on main has 0 bcpack_inspect entries, so tests/bcpack_inspect_check.cpp has never been compiled at this head.

MUST

  1. Show a run of the new C++ test: the result of ctest --preset dev --no-tests=error -R '^bcpack_inspect$' -V on this head, plus its --mutate collapse negative control. The body says no MSVC was available, and CI cannot build it. Leyukaka asked for the same thing.
  2. This PR and #1940 make the same change to the same four files, and the body asks for only one to be kept. Merging it would make that choice for the maintainer. #1940 at 23ab9d48 also carries the 17-block per-format agreement test against decode_bcpack (see Leyukaka's comparison). Please say which one you want to keep.

AI-assisted review.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7256291573 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3346#issuecomment-7256291573). Originally posted by [JohnConnorNPC](https://github.com/JohnConnorNPC) on 2026-11-29T13:06:17Z. --- Independent re-review of head `f8d2d51e` against `main` `af1cab5c`. Verdict: 2 MUST. Holding, not merging. **Checked** - `git merge-tree --write-tree origin/main f8d2d51e` exits 0. `main` has not touched the four files since. - On a pull request, CI runs `cmake --build --preset pr` / `ctest --preset pr` (windows.yml, `GITHUB_EVENT_NAME -eq 'pull_request'` branch). `CMakePresets.json` on `main` has 0 `bcpack_inspect` entries, so `tests/bcpack_inspect_check.cpp` has never been compiled at this head. **MUST** 1. Show a run of the new C++ test: the result of `ctest --preset dev --no-tests=error -R '^bcpack_inspect$' -V` on this head, plus its `--mutate collapse` negative control. The body says no MSVC was available, and CI cannot build it. Leyukaka asked for the same thing. 2. This PR and #1940 make the same change to the same four files, and the body asks for only one to be kept. Merging it would make that choice for the maintainer. #1940 at `23ab9d48` also carries the 17-block per-format agreement test against `decode_bcpack` (see Leyukaka's comparison). Please say which one you want to keep. AI-assisted review.
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
R0Y00/Xbox2Windows!3346
No description provided.