startup: add -TraceApi to the PowerShell launcher #2346

Merged
RavenCurseBurg merged 2 commits from upstream-pr/2354 into main 2026-11-25 14:08:10 +00:00
RavenCurseBurg commented 2026-11-25 13:25:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-25T13:25:11Z.


Closes #2351.

run.ps1 -TraceApi enables the existing method-level x2w-api log in the child environment. A caller who already exported X2W_TRACE_API can continue using it. The startup guide distinguishes this switch from -TraceCalls and identifies the provider registration line that confirms a provider was wrapped when method logging is off.

I extended the registered startup_run_ps1 test. Its synthetic child records the environment value next to the debugger arguments, so each default run also checks that the variable is absent. The ordinary -TraceCalls case checks the debugger arguments independently of API tracing.

  • The complete launcher suite passed under both Windows PowerShell and PowerShell 7, including the existing process-tree cleanup cases.
  • I also exercised five child-process combinations in each shell (default, either switch, inherited opt-in, and both switches with inherited zero). Removing the assignment or making it unconditional failed the corresponding control in both shells.
  • The requested Select-String check found the parameter and assignment. The documentation check passed for 19 files and 457 links.

Agent environment and model: Codex + GPT-6.2 Astra xhigh.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6605513127 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2354). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-25T13:25:11Z. --- Closes #2351. `run.ps1 -TraceApi` enables the existing method-level `x2w-api` log in the child environment. A caller who already exported `X2W_TRACE_API` can continue using it. The startup guide distinguishes this switch from `-TraceCalls` and identifies the provider registration line that confirms a provider was wrapped when method logging is off. I extended the registered `startup_run_ps1` test. Its synthetic child records the environment value next to the debugger arguments, so each default run also checks that the variable is absent. The ordinary `-TraceCalls` case checks the debugger arguments independently of API tracing. - The complete launcher suite passed under both Windows PowerShell and PowerShell 7, including the existing process-tree cleanup cases. - I also exercised five child-process combinations in each shell (default, either switch, inherited opt-in, and both switches with inherited zero). Removing the assignment or making it unconditional failed the corresponding control in both shells. - The requested `Select-String` check found the parameter and assignment. The documentation check passed for 19 files and 457 links. Agent environment and model: Codex + GPT-6.2 Astra xhigh.
tedin7 commented 2026-11-25 14:04:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:30:55Z.

Review: COMMENTED


Review of head e160bb222dc3e893969d4018191cfd89ff6f9bbb

Verdict: no blocking findings (P1=0, P2=0).

Scope: tools/startup/run.ps1 (+-TraceApi, sets X2W_TRACE_API=1), docs/startup-runtime.md, tests/startup_run_ps1_check.py. Matches the "Done when" list of #2351.

Checked:

  • X2W_TRACE_API is read in src/startup_stubs/runtime_proxy.cpp:181 via env_on, so the switch maps to an existing opt-in. The x2w-runtime provider ... (proxied as #%d) line quoted in the docs exists at runtime_proxy.cpp:371.
  • The assignment is placed next to the other env-var switches and runs only when the switch is given. Launches without it are untouched. An inherited X2W_TRACE_API is left alone.
  • Test: the stub now records [argv, X2W_TRACE_API]. The default run expects it to be absent. The new -TraceApi case with inherited 0 expects 1. The inherited 1 case without the switch expects 1. The -TraceCalls case still checks the debugger args. The three new cases cover the behaviors named in the PR.
  • CI on this head: Linux Python checks pass, Windows build and test pass, gfx1013 fixtures pass.
  • Mergeable, not draft, title neutral, nothing that breaks clean-room.

Commands executed locally in a worktree of this head:

  • git diff --stat origin/main...HEAD: 3 files, +23/-6
  • python3 tests/docs_links_check.py: self-test passed, 19 files, 457 links
  • python3 tests/bidi_controls_check.py: 1641 files, no bidirectional controls
  • git diff --check origin/main...HEAD: clean
  • python3 tests/startup_run_ps1_check.py: exit 0, but only in "text only: not a Windows host" mode

Mutation: I deleted the if ($TraceApi) { $env:X2W_TRACE_API = "1" } line and reran the check on Linux. It still passed. The Linux run does not execute PowerShell, so it cannot kill this mutation. The kill depends on the Windows CI job, which passed on this head. The PR body also reports killing the same mutation in both shells. I did not rerun it on Win2025: this is a launcher/docs change with no shader or C++ change.

Nits (non-blocking):

  • The mutation result above means the Linux "text only" mode gives no protection for the new assignment. A cheap text assertion for the -TraceApi parameter and the assignment line would help. The PR body says a Select-String check was run by hand, but nothing in the test does this.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6058516540 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2354#pullrequestreview-6058516540). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T13:30:55Z. **Review:** COMMENTED --- Review of head `e160bb222dc3e893969d4018191cfd89ff6f9bbb` **Verdict: no blocking findings (P1=0, P2=0).** Scope: `tools/startup/run.ps1` (+`-TraceApi`, sets `X2W_TRACE_API=1`), `docs/startup-runtime.md`, `tests/startup_run_ps1_check.py`. Matches the "Done when" list of #2351. Checked: - `X2W_TRACE_API` is read in `src/startup_stubs/runtime_proxy.cpp:181` via `env_on`, so the switch maps to an existing opt-in. The `x2w-runtime provider ... (proxied as #%d)` line quoted in the docs exists at `runtime_proxy.cpp:371`. - The assignment is placed next to the other env-var switches and runs only when the switch is given. Launches without it are untouched. An inherited `X2W_TRACE_API` is left alone. - Test: the stub now records `[argv, X2W_TRACE_API]`. The default run expects it to be absent. The new `-TraceApi` case with inherited `0` expects `1`. The inherited `1` case without the switch expects `1`. The `-TraceCalls` case still checks the debugger args. The three new cases cover the behaviors named in the PR. - CI on this head: Linux Python checks pass, Windows build and test pass, gfx1013 fixtures pass. - Mergeable, not draft, title neutral, nothing that breaks clean-room. Commands executed locally in a worktree of this head: - `git diff --stat origin/main...HEAD`: 3 files, +23/-6 - `python3 tests/docs_links_check.py`: self-test passed, 19 files, 457 links - `python3 tests/bidi_controls_check.py`: 1641 files, no bidirectional controls - `git diff --check origin/main...HEAD`: clean - `python3 tests/startup_run_ps1_check.py`: exit 0, but only in "text only: not a Windows host" mode Mutation: I deleted the `if ($TraceApi) { $env:X2W_TRACE_API = "1" }` line and reran the check on Linux. It still passed. The Linux run does not execute PowerShell, so it cannot kill this mutation. The kill depends on the Windows CI job, which passed on this head. The PR body also reports killing the same mutation in both shells. I did not rerun it on Win2025: this is a launcher/docs change with no shader or C++ change. Nits (non-blocking): - The mutation result above means the Linux "text only" mode gives no protection for the new assignment. A cheap text assertion for the `-TraceApi` parameter and the assignment line would help. The PR body says a `Select-String` check was run by hand, but nothing in the test does this. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 14:04:58 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Review of head 907dbf9580e28fe2c5d90e20254e0b2bb35e9805 (changes: tools/startup/run.ps1, tests/startup_run_ps1_check.py, docs/startup-runtime.md).

Findings: P1 = 0, P2 = 0

What I checked:

  • run.ps1: -TraceApi sets X2W_TRACE_API=1 before the debugger launch. env_on() in src/startup_stubs/local_log.h:18 accepts only a value starting with 1, so "1" is correct. The variable is set only when the switch is passed, so it leaves -TraceCalls alone.
  • Test: the debugger stub now records [argv, X2W_TRACE_API]. The new cases cover the switch with an inherited "0" (must become "1") and an inherited "1" without the switch (must stay "1"). The test also clears any X2W_TRACE_API inherited from the caller, so the other cases are not skewed.
  • Docs: the paragraph matches the log line at runtime_proxy.cpp:371 (x2w-runtime provider ... (proxied as #N)).
  • PR is not a draft, mergeable. CI: Linux checks, gfx1013 fixtures and Windows build/test all pass. The /O2 job was skipped.

Commands run locally on the PR head (all clean):

  • python3 tests/startup_run_ps1_check.py --text-only -> startup run.ps1 exit code: 0 failed (text only: requested)
  • python3 tests/docs_links_check.py -> Checked 19 Markdown files and 457 links.
  • python3 tests/bidi_controls_check.py -> no bidirectional controls.
  • git diff --check origin/main...HEAD -> no output

Mutations (both killed, then reverted with git checkout -- .):

  1. X2W_TRACE_API = "1" changed to "0" -> FAIL text: missing -TraceApi environment opt-in before launch
  2. The if ($TraceApi) {...} line deleted -> same FAIL

Not run: the PowerShell execution cases (no pwsh/powershell on this Linux host). The Windows CI job covers them. No Win2025 run was needed, since there are no shader or C++ changes.

Nit (optional): the text check only matches the exact if ($TraceApi) { $env:X2W_TRACE_API = "1" } form, so a harmless reformat would trip it. The runtime cases on Windows cover the behaviour, so this is fine.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6058649728 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2354#pullrequestreview-6058649728). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T13:39:50Z. **Review:** COMMENTED --- Review of head `907dbf9580e28fe2c5d90e20254e0b2bb35e9805` (changes: `tools/startup/run.ps1`, `tests/startup_run_ps1_check.py`, `docs/startup-runtime.md`). **Findings: P1 = 0, P2 = 0** What I checked: - `run.ps1`: `-TraceApi` sets `X2W_TRACE_API=1` before the debugger launch. `env_on()` in `src/startup_stubs/local_log.h:18` accepts only a value starting with `1`, so `"1"` is correct. The variable is set only when the switch is passed, so it leaves `-TraceCalls` alone. - Test: the debugger stub now records `[argv, X2W_TRACE_API]`. The new cases cover the switch with an inherited `"0"` (must become `"1"`) and an inherited `"1"` without the switch (must stay `"1"`). The test also clears any `X2W_TRACE_API` inherited from the caller, so the other cases are not skewed. - Docs: the paragraph matches the log line at `runtime_proxy.cpp:371` (`x2w-runtime provider ... (proxied as #N)`). - PR is not a draft, mergeable. CI: Linux checks, gfx1013 fixtures and Windows build/test all pass. The /O2 job was skipped. Commands run locally on the PR head (all clean): - `python3 tests/startup_run_ps1_check.py --text-only` -> `startup run.ps1 exit code: 0 failed (text only: requested)` - `python3 tests/docs_links_check.py` -> `Checked 19 Markdown files and 457 links.` - `python3 tests/bidi_controls_check.py` -> `no bidirectional controls.` - `git diff --check origin/main...HEAD` -> no output Mutations (both killed, then reverted with `git checkout -- .`): 1. `X2W_TRACE_API = "1"` changed to `"0"` -> `FAIL text: missing -TraceApi environment opt-in before launch` 2. The `if ($TraceApi) {...}` line deleted -> same FAIL Not run: the PowerShell execution cases (no `pwsh`/`powershell` on this Linux host). The Windows CI job covers them. No Win2025 run was needed, since there are no shader or C++ changes. Nit (optional): the text check only matches the exact `if ($TraceApi) { $env:X2W_TRACE_API = "1" }` form, so a harmless reformat would trip it. The runtime cases on Windows cover the behaviour, so this is fine. AI-assisted; commands listed were executed locally.
RavenCurseBurg commented 2026-11-25 14:05:10 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-25T13:34:34Z.


907dbf95 adds the text-only checks for the switch declaration and the guarded environment assignment before launch. The text-only entry point passed. Deleting the assignment, making it unconditional, or renaming the switch each produced the intended diagnostic. The original behavioral tests also ran locally under Windows PowerShell 5.1 and PowerShell 7.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7163976596 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2354#issuecomment-7163976596). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-25T13:34:34Z. --- 907dbf95 adds the text-only checks for the switch declaration and the guarded environment assignment before launch. The text-only entry point passed. Deleting the assignment, making it unconditional, or renaming the switch each produced the intended diagnostic. The original behavioral tests also ran locally under Windows PowerShell 5.1 and PowerShell 7.
upstream-sync closed this pull request 2026-11-25 15:01:39 +00:00
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!2346
No description provided.