Reject non-label state ID attributes in the script probe and replay #173

Merged
Vonsek merged 1 commit from upstream-pr/174 into main 2026-11-22 03:00:26 +00:00
Vonsek commented 2026-11-21 17:57:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T17:57:24Z.


Change

resolve_script_path in tools/script_path_host.cpp reports a state child whose id attribute is not label-kind (kind 5) as malformed (-3). script_dispatch_pairs (test_malformed_non_hash_id_returns_error_and_preserves_active) asserts that behavior. The Python side disagreed: script_path_replay.state_index and script_state_probe.inspect_tree silently ignored such an attribute and treated the node as an unnamed state. On a tree with an integer id beside a sibling of the selected state, the replay's parent-index reference expected node 5 while the native walker returned -3.

This change aligns the Python side with the native walker and script_dispatch_pairs. A shared state_ids helper in script_state_probe.py returns a state's id digests and raises ValueError("Non-label state ID attribute") for any id of another kind, in the same style as the existing duplicate-ID error. state_index and inspect_tree both use it. The native host is unchanged.

Tests:

  • tests/script_path_check.py: test_non_label_id_is_malformed adds an integer-kind id spelled panel to a sibling of the selected state, to the selected state beside its label, and to a state on an unrelated branch, and expects the replay to reject the tree.
  • tests/script_state_check.py: test_state_id_must_be_a_label asserted that an integer id whose hash equals the label is ignored and selects nothing. That expectation contradicts the rule now on main (the native host and script_dispatch_pairs treat a non-label id as malformed), so it is replaced by test_non_label_state_id_is_malformed, which expects the error for integer (3) and boolean (4) kinds. The intent of the old test, that a non-label id never selects a state, still holds.

docs/experiments.md describes the rule in the probe and path replay paragraphs.

Verification

  • Linux stand-in: built tools/script_path_host.cpp as a shared object with clang++ and ran tests/script_path_check.py <host>, tests/script_dispatch_check.py <host> and tests/script_state_check.py. All pass with the change. With the two tool files reverted, the new path test fails in all three subtests and the new probe test fails for both kinds; script_dispatch_check.py passes either way.
  • Windows: ctest --preset dev --no-tests=error -R '^script_(state_literals|path_links|dispatch_pairs)$' -V at b679760 on Windows 11 build 26200.9974, VS Build Tools 2022 17.14 (MSVC 14.44.35207), Windows SDK 10.0.26100, Python 3.12: 3/3 passed (script_path_links: Ran 5 tests, OK, with the MSVC-built host; script_state_literals: Ran 13 tests, OK; script_dispatch_pairs: Ran 5 tests, OK). The full ctest --preset dev --no-tests=error passed 107/107, with bvh_wave64_hardware, bvh_wave64_warp and wave_shuffle_warp skipped.

Evidence and follow-up

All inputs are source-built rows. The probe scans every record in an archive, so a record with a non-label id on a state node now stops the probe with an error instead of being counted. If such nodes turn up, the probe would need to report the record rather than raise.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6532429947 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/174). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T17:57:24Z. --- ## Change `resolve_script_path` in `tools/script_path_host.cpp` reports a state child whose `id` attribute is not label-kind (kind 5) as malformed (`-3`). `script_dispatch_pairs` (`test_malformed_non_hash_id_returns_error_and_preserves_active`) asserts that behavior. The Python side disagreed: `script_path_replay.state_index` and `script_state_probe.inspect_tree` silently ignored such an attribute and treated the node as an unnamed state. On a tree with an integer `id` beside a sibling of the selected state, the replay's parent-index reference expected node 5 while the native walker returned `-3`. This change aligns the Python side with the native walker and `script_dispatch_pairs`. A shared `state_ids` helper in `script_state_probe.py` returns a state's `id` digests and raises `ValueError("Non-label state ID attribute")` for any `id` of another kind, in the same style as the existing duplicate-ID error. `state_index` and `inspect_tree` both use it. The native host is unchanged. Tests: - `tests/script_path_check.py`: `test_non_label_id_is_malformed` adds an integer-kind `id` spelled `panel` to a sibling of the selected state, to the selected state beside its label, and to a state on an unrelated branch, and expects the replay to reject the tree. - `tests/script_state_check.py`: `test_state_id_must_be_a_label` asserted that an integer `id` whose hash equals the label is ignored and selects nothing. That expectation contradicts the rule now on main (the native host and `script_dispatch_pairs` treat a non-label `id` as malformed), so it is replaced by `test_non_label_state_id_is_malformed`, which expects the error for integer (3) and boolean (4) kinds. The intent of the old test, that a non-label `id` never selects a state, still holds. `docs/experiments.md` describes the rule in the probe and path replay paragraphs. ## Verification - Linux stand-in: built `tools/script_path_host.cpp` as a shared object with clang++ and ran `tests/script_path_check.py <host>`, `tests/script_dispatch_check.py <host>` and `tests/script_state_check.py`. All pass with the change. With the two tool files reverted, the new path test fails in all three subtests and the new probe test fails for both kinds; `script_dispatch_check.py` passes either way. - Windows: `ctest --preset dev --no-tests=error -R '^script_(state_literals|path_links|dispatch_pairs)$' -V` at b679760 on Windows 11 build 26200.9974, VS Build Tools 2022 17.14 (MSVC 14.44.35207), Windows SDK 10.0.26100, Python 3.12: 3/3 passed (`script_path_links`: Ran 5 tests, OK, with the MSVC-built host; `script_state_literals`: Ran 13 tests, OK; `script_dispatch_pairs`: Ran 5 tests, OK). The full `ctest --preset dev --no-tests=error` passed 107/107, with `bvh_wave64_hardware`, `bvh_wave64_warp` and `wave_shuffle_warp` skipped. ## Evidence and follow-up All inputs are source-built rows. The probe scans every record in an archive, so a record with a non-label `id` on a state node now stops the probe with an error instead of being counted. If such nodes turn up, the probe would need to report the record rather than raise.
upstream-sync closed this pull request 2026-11-24 06:41:40 +00:00
MarlomMedeiros commented 2026-11-24 06:47:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MarlomMedeiros on 2026-11-21T18:07:58Z.


Heads-up on a test interaction with main. #133 added
script_dispatch_pairs, whose
test_malformed_non_hash_id_returns_error_and_preserves_active builds a
sibling list where one state carries a kind=4 (bool) id attribute and
expects (-3, active preserved). With this change that attribute is
skipped instead, so the walk proceeds to the remaining label-kind
trigger_a sibling. Verified locally on this branch merged with
ccfa703: the test now returns (6, 6) where it expects (-3, 2), so
it fails once this lands.

The semantic change itself matches the probe behavior, but the fixture
needs to land in the same PR or CI breaks. The same case still
exercises something useful under the new semantics: the non-label id
is skipped, it no longer counts toward the duplicate check, and the
labeled sibling still resolves, i.e. asserting (6, 6). If -3
coverage should be kept, two label-kind id attributes on a single
state still produce it.

One data point for the semantics decision, whichever way it lands: the
kind=4 id case is not synthetic-only. In #19 we found real states
with true/false bool id attributes under one sibling list in the
local corpus (record index 872). Skipping them makes the walker
treat those states as unnamed rather than reporting malformed data,
which changes what the tool surfaces about the real file.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7067025479 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/174#issuecomment-7067025479). Originally posted by [MarlomMedeiros](https://github.com/MarlomMedeiros) on 2026-11-21T18:07:58Z. --- Heads-up on a test interaction with main. #133 added `script_dispatch_pairs`, whose `test_malformed_non_hash_id_returns_error_and_preserves_active` builds a sibling list where one state carries a kind=4 (bool) `id` attribute and expects (-3, active preserved). With this change that attribute is skipped instead, so the walk proceeds to the remaining label-kind `trigger_a` sibling. Verified locally on this branch merged with ccfa703: the test now returns `(6, 6)` where it expects `(-3, 2)`, so it fails once this lands. The semantic change itself matches the probe behavior, but the fixture needs to land in the same PR or CI breaks. The same case still exercises something useful under the new semantics: the non-label `id` is skipped, it no longer counts toward the duplicate check, and the labeled sibling still resolves, i.e. asserting `(6, 6)`. If `-3` coverage should be kept, two label-kind `id` attributes on a single state still produce it. One data point for the semantics decision, whichever way it lands: the kind=4 `id` case is not synthetic-only. In #19 we found real states with `true`/`false` bool `id` attributes under one sibling list in the local corpus (record index 872). Skipping them makes the walker treat those states as unnamed rather than reporting malformed data, which changes what the tool surfaces about the real file.
R0Y00 commented 2026-11-24 06:47:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T18:12:02Z.


The Windows run at 713eea63 fails script_dispatch_pairs: expected (-3, 2) and got (6, 6). The path replay and dispatch now disagree about a non-label ID. Please preserve the existing dispatch contract while fixing path replay, or document the proposed dispatch change for a lead decision before changing its expected value. Windows test log

The dispatch contract decision is tracked in #197.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7067076292 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/174#issuecomment-7067076292). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-21T18:12:02Z. --- The Windows run at `713eea63` fails `script_dispatch_pairs`: expected `(-3, 2)` and got `(6, 6)`. The path replay and dispatch now disagree about a non-label ID. Please preserve the existing dispatch contract while fixing path replay, or document the proposed dispatch change for a lead decision before changing its expected value. [Windows test log](https://github.com/R0Y00/Xbox2Windows/actions/runs/44932844466/job/136933026551) The dispatch contract decision is tracked in #197.
Vonsek commented 2026-11-24 06:47:49 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T18:29:10Z.


Reworked (b679760, on current main). The first version made the native walker skip non-label id attributes, which contradicts script_dispatch_pairs on main (test_malformed_non_hash_id_returns_error_and_preserves_active failed in CI). This version follows main's rule instead: the native host is unchanged, and the Python probe and replay now reject a non-label state id as malformed, so all three agree. Title and description are updated; script_state_literals, script_path_links and script_dispatch_pairs pass on Windows 11 26200.9974, and the full suite passes 107/107.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7067289612 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/174#issuecomment-7067289612). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T18:29:10Z. --- Reworked (b679760, on current main). The first version made the native walker skip non-label `id` attributes, which contradicts `script_dispatch_pairs` on main (`test_malformed_non_hash_id_returns_error_and_preserves_active` failed in CI). This version follows main's rule instead: the native host is unchanged, and the Python probe and replay now reject a non-label state `id` as malformed, so all three agree. Title and description are updated; `script_state_literals`, `script_path_links` and `script_dispatch_pairs` pass on Windows 11 26200.9974, and the full suite passes 107/107.
chatgpt-codex-connector[bot commented 2026-11-24 06:47:49 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T18:31:32Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T18:34:02.395498Z b679760 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7067318203 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/174#issuecomment-7067318203). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-21T18:31:32Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"b679760e532e17ed8c5fa04aa358823068acb227","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-21T18:34:02.395498Z">2026-11-21T18:34:02.395498Z</relative-time> | `b679760` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
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!173
No description provided.