script: support type-qualified path resolution in script_path_host #1658
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1665"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-24T16:43:02Z.
Change
Add
resolve_script_typed_pathtotools/script_path_host.cpp(sharingresolvePathImplwithresolve_script_path) to support type-qualified path resolution inscript_path_host:types(const std::uint32_t*) hash array parallel topathat each depth.statesibling to carry both a label-kind (kind == 5)idattribute matchingpath[level]and a label-kindtypeattribute matchingtypes[level].resolve_script_pathid-only behavior unchanged whentypes == nullptr.-1on missing or mismatchedtypeattributes,-2on duplicate(id, type)sibling collisions, and-3on nulltypes, duplicate/non-labeltypeoridattributes, or out-of-bounds node/attribute indices, leaving*activeunchanged on all error paths.script_typed_path_dispatchinCMakeLists.txtrunningTypedScriptPathTestsintests/script_dispatch_check.py, and documents the behavior indocs/experiments.md.Verification
All builds and tests ran after the final edit with 0 compiler warnings/errors:
cmake --preset dev+cmake --build --preset dev --target script_path_host --clean-first: built cleanly (0 warnings, 0 errors).ctest --preset dev --no-tests=error -R "^script_" -V: 4/4 passed (script_path_links: 5 OK,script_state_literals: 16 OK,script_dispatch_pairs: 10 OK,script_typed_path_dispatch: 5 OK).cmake --preset release+cmake --build --preset release --target script_path_host --clean-first: built cleanly (0 warnings, 0 errors).ctest --preset release --no-tests=error -R "^script_" -V: 4/4 passed (script_path_links: 5 OK,script_state_literals: 16 OK,script_dispatch_pairs: 10 OK,script_typed_path_dispatch: 5 OK).python -B tests/script_state_check.py: 16 tests OK.python -B tests/form_coverage_check.py:form coverage checks passed.python -B tests/docs_links_check.py:Checked 16 Markdown files and 350 links.python -B tests/bidi_controls_check.py:Checked 1277 tracked source, script and build/CI files: no bidirectional controls.Evidence and follow-up
tests/script_dispatch_check.py(TypedScriptPathTests) uses synthetic in-memory 16-byte wire-formatNode/Attributetrees (no game files or external dumps).(id, type)disambiguation (itemvsweaponitem), shop-carrier(id, type)pair extraction feedingresolve_script_typed_path, multi-level hierarchy resolution, and relativeup=2branch switching.*activepreservation alongside-1(missingtypeattribute, single-level and multi-level mismatchedtype),-2(duplicate(id, type)siblings), and-3(out-of-bounds sibling index, attribute span,container,active, nulltypes, zero depth, non-labeltype, duplicatetype, and non-labelid).(id, type)remains an open follow-up.Checklist
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T16:48:58Z.
Review: COMMENTED
Review of head
83aed83831.Scope note: "type-qualified" here means a caller-supplied array of
typelabel hashes, one per path segment, not a string qualifier. So string-parsing concerns (drive letters, UNC, separators, encodings) do not apply; the review covers the (id, type) matching, bounds, and the test.Verified
tools/script_path_host.cppon Linux:g++ -std=c++17 -Wall -Wextra -shared -fPIC '-D__declspec(x)=' tools/script_path_host.cpp. No warnings.python3 -B tests/script_dispatch_check.py <host.so>: 10 tests, OK.python3 -B tests/script_dispatch_check.py <host.so> TypedScriptPathTests(the new CTest command line): 5 tests, OK.python3 -B tests/script_path_check.py <host.so>(existing id-only consumer ofresolve_script_path): 5 tests, OK, so the refactor intoresolvePathImplwithtypes == nullptrkeeps the id-only behavior.tools/script_path_host.cpp.*activeis only written on the success path, so "unchanged on all error paths" indocs/experiments.mdis accurate. The documented return codes (-1 missing/mismatched type, -2 duplicate (id, type), -3 malformed/out-of-bounds) match the code and the tests.resolve_script_typed_pathrejects a nulltypeswith -3 before reaching the shared implementation; the test covers it.Mutation checks
Each mutation was applied to
tools/script_path_host.cpp, rebuilt, andTypedScriptPathTestsrun, then the file restored withgit restore. After the last restore, the full suite passes again (10 tests, OK).if (idMatch)): detected (4 failures).nullptrtypes: detected (6 failures).types[0]): detected (1 failure).typesnot rejected: detected (1 failure).typeMatch = true): detected (1 failure).typeattribute allowed: detected (1 failure).typekind not checked: detected (1 failure).idkind not checked: detected (1 failure).10 of 10 detected; no weak spots found in the new test.
Findings
No P1 or P2 findings. Two nits:
tools/script_path_host.cpp:68-72: in typed mode a malformedtypeattribute (non-label kind, or duplicated) on a sibling whoseiddoes not match still aborts the whole lookup with -3. Repro on the PR's own fixture: in_build_typed_collision_tree(), change node 2'stypeattribute to an int attribute and callresolve_typed_path(..., [joaat("trigger_a")], [joaat("item")]). Expected if only candidates were validated: 3. Got: (-3, 2) (unchanged active; baseline without the corruption gives (3, 3)). This is consistent with how a malformedidalready behaves and the docs say malformedtypereturns -3, so it may be intended; worth one sentence in the docs that the check applies to everystatesibling, not only candidates.CMakeLists.txt(newscript_typed_path_dispatchentry):script_dispatch_pairsruns the file with no class filter, so it already executesTypedScriptPathTests; the new entry re-runs the same 5 tests. Harmless (milliseconds), but it is a duplicate of coverage unless the intent is a separately named result. Alsotypeshas no length parameter, so the caller must supplydepthentries; the Python helper does, and the doc sentence "matching each path depth" states it, but a short array from another caller would read out of bounds.Not verified
prpreset and the CTest registration itself were not run; the CMake lines were only read and match the neighboringscript_dispatch_pairsentry.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-25T05:48:14Z.
Review: APPROVED
Verified head
83aed838on Windows x64 (devpreset, MSVC19.44.35228.0, Python 3.12).cmake --build --preset dev --target script_path_host-> succeededctest --preset dev --no-tests=error -R '^script_typed_path_dispatch$' -V-> 1/1 passedVerdict: Approved at
83aed838.