tooling: stage an isolated startup executable directory #1542

Merged
SuperCraft3M merged 1 commit from upstream-pr/1549 into main 2026-11-25 21:51:09 +00:00
SuperCraft3M commented 2026-11-24 13:48:46 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by SuperCraft3M on 2026-11-24T13:48:46Z.


Change

Stage one executable and its adjacent DLLs in a fresh startup directory. Archives and subdirectories stay at the data root used by run.ps1 -DataDir. The command refuses occupied and overlapping destinations and paths through junctions or other reparse points.

The rebased change resolves relative -RunDir from the current PowerShell location and copies files with the exact .dll extension.

Verification

Head 3fa4bde3 on 18f2f85c, Windows 11 build 26300.9711.

  • ctest --preset release --no-tests=error -R '^startup_stage_package$' -V passed under Windows PowerShell 5.1.
  • python -B tests/startup_stage_package_check.py pwsh passed under PowerShell 7.
  • git diff --check upstream/main...HEAD passed.

The synthetic inputs cover staging after Set-Location, exact DLL extensions, DLLs alongside a nested executable, package preservation, a sibling destination, and refusal of an occupied destination, a junction, an overlapping path and an executable outside the package.

AI-assisted (Codex).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6583258266 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1549). Originally posted by [SuperCraft3M](https://github.com/SuperCraft3M) on 2026-11-24T13:48:46Z. --- ## Change Stage one executable and its adjacent DLLs in a fresh startup directory. Archives and subdirectories stay at the data root used by `run.ps1 -DataDir`. The command refuses occupied and overlapping destinations and paths through junctions or other reparse points. The rebased change resolves relative `-RunDir` from the current PowerShell location and copies files with the exact `.dll` extension. ## Verification Head `3fa4bde3` on `18f2f85c`, Windows 11 build 26300.9711. - `ctest --preset release --no-tests=error -R '^startup_stage_package$' -V` passed under Windows PowerShell 5.1. - `python -B tests/startup_stage_package_check.py pwsh` passed under PowerShell 7. - `git diff --check upstream/main...HEAD` passed. The synthetic inputs cover staging after `Set-Location`, exact DLL extensions, DLLs alongside a nested executable, package preservation, a sibling destination, and refusal of an occupied destination, a junction, an overlapping path and an executable outside the package. AI-assisted (Codex).
tedin7 commented 2026-11-24 16:03:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T15:51:16Z.

Review: COMMENTED


Technical review (static reading only: this host has no PowerShell, so neither stage_package.ps1 nor startup_stage_package could be run, and no mutation check was possible on the script. Everything below is from reading the diff against documented .NET and PowerShell behaviour; please treat the two behavioural points as "to confirm on Windows".)

Checked out the PR head in a clean tree.

What I could check:

  • tests/startup_stage_package_check.py is plain Python around subprocess.run; its expectations match the strings in the script ("absent or empty", "separate from PackageDir", "executable file").
  • The sibling-prefix case is handled correctly by design: Test-PathInside appends \ before StartsWith, so package-run is not treated as inside package, and Test-PathInside $package $run rejects a run directory that is a parent of the package. The .TrimEnd('\') on a drive root such as C:\ leaves C:, which still works with the prefix test but is worth knowing.
  • The CMake entry follows the existing REFERENCE_POWERSHELL ... REQUIRED precedent, inside the same INTAKE_PYTHON block.
  • Docs: the new docs/startup-runtime.md text and the docs/experiments.md section agree with the script's behaviour (archives and subdirectories not copied, empty or absent destination, reparse points refused).

Points to confirm on Windows:

  1. $run = [IO.Path]::GetFullPath($RunDir) resolves a relative RunDir against the process's current directory, which PowerShell does not update when you run Set-Location. In an interactive session that did cd after start, -RunDir out\run1 can be staged under the directory the process started in, not the current location, and every later check passes because it works on that absolute path. The test only passes absolute temp paths, so it cannot see this. $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($RunDir) resolves it the PowerShell way (the script already uses Resolve-Path for the other two inputs).
  2. Get-ChildItem -Filter '*.dll' goes through the Win32 wildcard matcher, which also matches longer extensions that begin with dll (the documented three-character-extension behaviour, like *.xls returning .xlsx). A file such as name.dll_ or name.dllold next to the executable would be copied and counted as a DLL. Filtering the result with Where-Object { $_.Extension -ieq '.dll' } removes that.

Untested guards (the script has them, the check does not exercise them): a run directory that is a sibling with the package name as prefix (package-run), an executable outside PackageDir, a destination that is an existing file, a destination under a reparse point (the docs list this refusal), a relative Exe in a subdirectory (its DLLs come from that subdirectory, not the package root), and relative RunDir paths. The reparse-point guard in particular needs a junction created in the test (New-Item -ItemType Junction) to be pinned.

Smaller observation: the second operand of the "inside PackageDir" test ($source.Equals($package)) cannot be true, since $source is a file; harmless.

No other defects found in the diff.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6042638210 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1549#pullrequestreview-6042638210). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T15:51:16Z. **Review:** COMMENTED --- Technical review (static reading only: this host has no PowerShell, so neither `stage_package.ps1` nor `startup_stage_package` could be run, and no mutation check was possible on the script. Everything below is from reading the diff against documented .NET and PowerShell behaviour; please treat the two behavioural points as "to confirm on Windows".) Checked out the PR head in a clean tree. What I could check: - `tests/startup_stage_package_check.py` is plain Python around `subprocess.run`; its expectations match the strings in the script ("absent or empty", "separate from PackageDir", "executable file"). - The sibling-prefix case is handled correctly by design: `Test-PathInside` appends `\` before `StartsWith`, so `package-run` is not treated as inside `package`, and `Test-PathInside $package $run` rejects a run directory that is a parent of the package. The `.TrimEnd('\')` on a drive root such as `C:\` leaves `C:`, which still works with the prefix test but is worth knowing. - The CMake entry follows the existing `REFERENCE_POWERSHELL ... REQUIRED` precedent, inside the same `INTAKE_PYTHON` block. - Docs: the new `docs/startup-runtime.md` text and the `docs/experiments.md` section agree with the script's behaviour (archives and subdirectories not copied, empty or absent destination, reparse points refused). Points to confirm on Windows: 1. `$run = [IO.Path]::GetFullPath($RunDir)` resolves a relative `RunDir` against the process's current directory, which PowerShell does not update when you run `Set-Location`. In an interactive session that did `cd` after start, `-RunDir out\run1` can be staged under the directory the process started in, not the current location, and every later check passes because it works on that absolute path. The test only passes absolute temp paths, so it cannot see this. `$ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($RunDir)` resolves it the PowerShell way (the script already uses `Resolve-Path` for the other two inputs). 2. `Get-ChildItem -Filter '*.dll'` goes through the Win32 wildcard matcher, which also matches longer extensions that begin with `dll` (the documented three-character-extension behaviour, like `*.xls` returning `.xlsx`). A file such as `name.dll_` or `name.dllold` next to the executable would be copied and counted as a DLL. Filtering the result with `Where-Object { $_.Extension -ieq '.dll' }` removes that. Untested guards (the script has them, the check does not exercise them): a run directory that is a sibling with the package name as prefix (`package-run`), an executable outside `PackageDir`, a destination that is an existing file, a destination under a reparse point (the docs list this refusal), a relative `Exe` in a subdirectory (its DLLs come from that subdirectory, not the package root), and relative `RunDir` paths. The reparse-point guard in particular needs a junction created in the test (`New-Item -ItemType Junction`) to be pinned. Smaller observation: the second operand of the "inside PackageDir" test (`$source.Equals($package)`) cannot be true, since `$source` is a file; harmless. No other defects found in the diff. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 13:01:03 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T12:53:53Z.


@SuperCraft3M could you rebase this branch onto current main and force-push?

GitHub reports head de63659b as conflicting with main, so it cannot be merged as is.

Files that conflict with current main (cf97bee1):

  • CMakeLists.txt
  • docs/experiments.md

Commands run locally:

git fetch origin main pull/1549/head
git merge-tree --write-tree --name-only origin/main FETCH_HEAD
gh pr view 1549 --json mergeable   # CONFLICTING

Once it is rebased and CI is green it will be re-checked right away.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7163008738 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1549#issuecomment-7163008738). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T12:53:53Z. --- @SuperCraft3M could you rebase this branch onto current `main` and force-push? GitHub reports head `de63659b` as conflicting with `main`, so it cannot be merged as is. Files that conflict with current `main` (`cf97bee1`): - `CMakeLists.txt` - `docs/experiments.md` Commands run locally: ``` git fetch origin main pull/1549/head git merge-tree --write-tree --name-only origin/main FETCH_HEAD gh pr view 1549 --json mergeable # CONFLICTING ``` Once it is rebased and CI is green it will be re-checked right away. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 22:01:44 +00:00
tedin7 commented 2026-11-25 22:01:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T21:50:53Z.

Review: COMMENTED


Review of head 3fa4bde3 (comment only).

Checked:

  • tools/startup/stage_package.ps1: Exe must be inside PackageDir and a .exe file. RunDir must be separate from the package and its parents. It refuses a RunDir that passes through a reparse point, or that is not absent/empty. Only the exe and exact .dll files beside it are copied (no recursion, no archives).
  • tests/startup_stage_package_check.py covers each guard with a negative control: occupied destination, package overlap, parent of package, non-exe, exe outside the package, junction, changed PowerShell location, .dll_ / .dllold not copied, package bytes unchanged.
  • CMakeLists.txt: the test is registered next to the other startup tests; REQUIRED on the PowerShell lookup matches the existing REFERENCE_POWERSHELL precedent (Windows-only build).
  • Docs: docs/startup-runtime.md and docs/experiments.md updated, links check passes.
  • No other open or merged PR covers this slice. No dependency on another PR. The PR does not claim startup compatibility.

Commands run locally (Linux worktree at the exact head):

  • python3 tests/docs_links_check.py: ok (19 files, 488 links)
  • python3 tests/bidi_controls_check.py: ok
  • git diff --check origin/main...HEAD: clean
  • The staging test needs PowerShell and cmd.exe, so it is not runnable on Linux. I did not run a code mutation locally; the run is on Windows (receipt in the next comment).

No blocking findings.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6065464228 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1549#pullrequestreview-6065464228). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T21:50:53Z. **Review:** COMMENTED --- Review of head 3fa4bde3 (comment only). Checked: - `tools/startup/stage_package.ps1`: Exe must be inside PackageDir and a `.exe` file. RunDir must be separate from the package and its parents. It refuses a RunDir that passes through a reparse point, or that is not absent/empty. Only the exe and exact `.dll` files beside it are copied (no recursion, no archives). - `tests/startup_stage_package_check.py` covers each guard with a negative control: occupied destination, package overlap, parent of package, non-exe, exe outside the package, junction, changed PowerShell location, `.dll_` / `.dllold` not copied, package bytes unchanged. - `CMakeLists.txt`: the test is registered next to the other startup tests; `REQUIRED` on the PowerShell lookup matches the existing `REFERENCE_POWERSHELL` precedent (Windows-only build). - Docs: `docs/startup-runtime.md` and `docs/experiments.md` updated, links check passes. - No other open or merged PR covers this slice. No dependency on another PR. The PR does not claim startup compatibility. Commands run locally (Linux worktree at the exact head): - `python3 tests/docs_links_check.py`: ok (19 files, 488 links) - `python3 tests/bidi_controls_check.py`: ok - `git diff --check origin/main...HEAD`: clean - The staging test needs PowerShell and `cmd.exe`, so it is not runnable on Linux. I did not run a code mutation locally; the run is on Windows (receipt in the next comment). No blocking findings. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 22:02:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T21:50:54Z.


Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 3fa4bde31128f97d7ffc42f7465c454faf7874d6:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev -- -j 2): 541.97s (configure 4.20s)
    • Test (ctest --preset dev -R '^startup_stage_package$' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (4.43s: startup_stage_package 4.26s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release -- -j 2): 169.54s (configure 2.37s)
    • Test (ctest --preset release -R '^startup_stage_package$' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (5.93s: startup_stage_package 5.71s)

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7175615456 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1549#issuecomment-7175615456). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T21:50:54Z. --- Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `3fa4bde31128f97d7ffc42f7465c454faf7874d6`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev -- -j 2`): `541.97s` (configure `4.20s`) - Test (`ctest --preset dev -R '^startup_stage_package$' --parallel 2 --no-tests=error --output-on-failure`): **1/1 passed** (`4.43s`: `startup_stage_package` `4.26s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release -- -j 2`): `169.54s` (configure `2.37s`) - Test (`ctest --preset release -R '^startup_stage_package$' --parallel 2 --no-tests=error --output-on-failure`): **1/1 passed** (`5.93s`: `startup_stage_package` `5.71s`) AI-assisted; commands listed were executed locally.
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!1542
No description provided.