bcpack: BCPack refusal inspector review follow-up #3348

Manually merged
github merged 8 commits from github-bot/gh-3346 into main 2026-11-30 19:41:19 +00:00 AGit
Owner

@⁠romn4rch on GitHub · 2026-11-28 11:23 UTC · original
romn4rch:copilot/pr-1940-review-f8d2d51e → main · +583 −7 · 4 files · 8 commits · merged 2026-11-30 19:35 UTC

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.

**@⁠romn4rch** on GitHub · 2026-11-28 11:23 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3346) `romn4rch:copilot/pr-1940-review-f8d2d51e` → `main` · +583 −7 · 4 files · 8 commits · merged 2026-11-30 19:35 UTC 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.
decode_lanes can fill an optional LaneReport saying why it stopped and how far the lanes got; without
one it behaves as before. bcpack_inspect.h turns that into a class for a request (destination size
not a whole number of blocks, request shorter or longer than the stream, a cut stream, trailing input,
and so on) with the bytes read and the symbols per lane. decode_bcpack and the request path are
unchanged. The check runs the repository's synthetic BC1 and BC7 streams; its collapse control
reports every failure as one class and must fail.
A 256 MiB BC7 declaration let a tiny source allocate about 1 GiB of lane
symbols. The cap is now the shared 16 MiB chunk-window bound; larger
declarations return bad_arguments before any allocation. Adds oversized
declared-output cases; short/long/truncated controls unchanged.
A failing BC3, BC4 or BC5 request was reported as unsupported_format. The reason now comes from the lane state, as for BC1 and BC7.
Co-authored-by: Copilot App <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 11:27:28 +00:00
Author
Owner

@⁠KelboLive on GitHub · 2026-11-28 21:24 UTC · original · approved these changes

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** on GitHub · 2026-11-28 21:24 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3346#pullrequestreview-6100145122) · **approved these changes** 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.
Author
Owner

@⁠KelboLive on GitHub · 2026-11-28 21:57 UTC · original · approved these changes

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** on GitHub · 2026-11-28 21:57 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3346#pullrequestreview-6100255184) · **approved these changes** 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.
Author
Owner

@⁠Leyukaka on GitHub · 2026-11-29 06:54 UTC · original · reviewed

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.

**@⁠Leyukaka** on GitHub · 2026-11-29 06:54 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3346#pullrequestreview-6101817134) · **reviewed** 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.
Author
Owner

@⁠JohnConnorNPC on GitHub · 2026-11-29 13:06 UTC · original

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.

**@⁠JohnConnorNPC** on GitHub · 2026-11-29 13:06 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3346#issuecomment-7256291573) 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.
github manually merged commit a6d621790f into main 2026-11-30 19:41:19 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.