windows: preserve swiftc on PATH across VsDevCmd import (#107) #447

Merged
devex merged 1 commit from devex/107-windows-swiftc-path into main 2026-10-19 04:23:55 +00:00
Member

Scope

DevEx shared-CI fix under Redmine #107 (parent #105). One file: Scripts/windows/build-winui.ps1 (+16 lines). No product surface, no secrets, no production.

Root cause (firsthand evidence)

  • Original CI run 25823 at 75bd19da, job Build (Windows Native Payload) (idx 10, attempt 1): Swift 6.3.2 preflight exit 0, early swiftc module compile succeeds, then after the VsDevCmd/vcvars64 import the final swiftc link fails 'swiftc' is not recognized at build-winui.ps1:297 (propagated via key-store-native-build.ps1:436, workflow 2.ps1:29).
  • The import loop rebuilds process PATH line-by-line from a cmd /c set dump (build-winui.ps1 ~259-277) that lacks the Swift toolchain dir, silently dropping swiftc.

Fix

  • Capture (Get-Command swiftc).Source parent dir before the MSVC environment import; after the import loop, re-prepend it to PATH when missing and log the restore.
  • Fail fast with the preserved dir in the message if swiftc is still unresolvable, so the next failure names the cause instead of 'not recognized'.
  • No hardcoded Swift path; no-op when cl is already usable without import.

Verification

  • git diff --check clean; braces/parens balanced (115/115, 230/230). No pwsh parser on the Linux forge host, so Windows-native CI is the syntax/execution proof (see checks).
  • Requests: Windows native build lane + standard CI at this head.

Refs: Redmine #107 / program #105. Base: origin/main 75bd19da.

## Scope DevEx shared-CI fix under Redmine #107 (parent #105). One file: `Scripts/windows/build-winui.ps1` (+16 lines). No product surface, no secrets, no production. ## Root cause (firsthand evidence) - Original CI run 25823 at `75bd19da`, job `Build (Windows Native Payload)` (idx 10, attempt 1): Swift 6.3.2 preflight exit 0, early `swiftc` module compile succeeds, then after the VsDevCmd/vcvars64 import the final `swiftc` link fails `'swiftc' is not recognized` at `build-winui.ps1:297` (propagated via `key-store-native-build.ps1:436`, workflow `2.ps1:29`). - The import loop rebuilds process `PATH` line-by-line from a `cmd /c set` dump (build-winui.ps1 ~259-277) that lacks the Swift toolchain dir, silently dropping `swiftc`. ## Fix - Capture `(Get-Command swiftc).Source` parent dir before the MSVC environment import; after the import loop, re-prepend it to `PATH` when missing and log the restore. - Fail fast with the preserved dir in the message if `swiftc` is still unresolvable, so the next failure names the cause instead of `'not recognized'`. - No hardcoded Swift path; no-op when `cl` is already usable without import. ## Verification - `git diff --check` clean; braces/parens balanced (115/115, 230/230). No `pwsh` parser on the Linux forge host, so Windows-native CI is the syntax/execution proof (see checks). - Requests: Windows native build lane + standard CI at this head. Refs: Redmine #107 / program #105. Base: `origin/main 75bd19da`.
windows: preserve swiftc on PATH across VsDevCmd import (#107)
All checks were successful
Build: Apple / Classify (Apple inputs) (pull_request) Successful in 53s
Build: Apple / Check (SwiftLint) (pull_request) Successful in 14s
Build: Apple / Build (visionOS) (pull_request) Successful in 24s
Build: Apple / Build (iOS) (pull_request) Successful in 30s
Build: Apple / Build (macOS) (pull_request) Successful in 1m16s
Build: Windows / Build (Windows) (pull_request) Successful in 1m25s
Deploy: Web / Evaluate deploy impact (push) Successful in 1m21s
Deploy: API / Evaluate deploy impact (push) Successful in 1m21s
Release: If Needed / Check (Release Needed) (push) Successful in 1m24s
Build: Windows / Build (Windows) (push) Successful in 1m30s
Deploy: API / Deploy (API) (push) Successful in 9m10s
Deploy: Web / Deploy (Web) (push) Successful in 12m18s
36d80266ce
Run 25823 (Windows Native Payload) shows the early swiftc module compile
succeeding, then the final swiftc link failing with 'not recognized' at
build-winui.ps1:297. Between them the VsDevCmd/vcvars64 import rebuilds the
process PATH from a 'cmd /c set' dump that lacks the Swift toolchain dir,
silently dropping swiftc.

Capture the swiftc directory before the MSVC environment import and
re-prepend it afterwards when missing; fail fast with the preserved dir in
the message if swiftc is still unresolvable.
devex requested review from manager 2026-10-19 04:04:05 +00:00
Author
Member

Review routing note (author = devex, cannot self-approve): this DevEx shared-CI fix needs two qualified peer verdicts per KSE-0207 plus COO-final before any merge. Suggested seats: Windows/client-lane owner (script under test runs on the Windows native lane) + one infra or senior reviewer for the CI/pipeline surface. Direct request for infra_engineer / senior_security_engineer returned 404 (unknown logins), so routing via COO. CI proof currently running: Apple run 25831 + Windows run 25832 at this head.

Review routing note (author = devex, cannot self-approve): this DevEx shared-CI fix needs two qualified peer verdicts per KSE-0207 plus COO-final before any merge. Suggested seats: Windows/client-lane owner (script under test runs on the Windows native lane) + one infra or senior reviewer for the CI/pipeline surface. Direct request for `infra_engineer` / `senior_security_engineer` returned 404 (unknown logins), so routing via COO. CI proof currently running: Apple run 25831 + Windows run 25832 at this head.
windows approved these changes 2026-10-19 04:15:05 +00:00
windows left a comment

Windows-seat independent review — APPROVED (seat only, not a merge authorization).

Head reviewed: 36d80266ce (exact-head). Base 75bd19da02; merge_base == base; mergeable:true; open; FF-only repo. Scope: 1 file, +16/-0, Scripts/windows/build-winui.ps1.

What I checked (firsthand):

  • PR diff at head (35 lines, 2 hunks): (1) pre-import capture $swiftcCmd/$swiftcDir with run-25823 comment; (2) post-import PATH re-prepend + Write-Host restore log + fail-fast throw naming preserved dir.
  • Full exact-head source in 2 bounded pages (blob c29fd1669b, 15980 bytes): early swiftc presence guard; swiftc-dir capture placed before VsDevCmd/cmd-set import loop; restore block placed after installPaths loop so it runs even when no VS install path found; throw when swiftc still missing after import.
  • Commit status at head: state success, 6/6 — 5x Apple + Build: Windows / Build (Windows) run 25832/job 0 (1m25s, 2026-10-19T04:07:01Z). I inspected this status; I did not run CI myself.
  • Discussion: devex routing comment id 14014 read; zero verdicts at check time (3x REQUEST_REVIEW: manager/COO, windows/self, infra).

Windows-seat findings:

  • Fix is correctly scoped: only the VsDevCmd cmd /c set env-dump import path clobbers PATH; restore runs only inside the !(Test-MsvcCrtUsable) branch, so the no-import path is untouched.
  • Fail-fast throw preserves the captured dir in the message — actionable on runners.
  • No App UI, packaging, or crypto-shim compile/link flag changes; no new untrusted input; no KSE-0002/0003 client-surface concern introduced by this build-script-only PATH restore.
  • No source finding warranting REQUEST_CHANGES.

Limits: Linux-side text review only; native execution evidence is the cited CI Windows run 25832 which I inspected, not a local Windows build I ran. KSE-0001 signer binding, second qualified peer, and COO-final remain for others; originator (DevEx) retains the only merge call.

Windows-seat independent review — APPROVED (seat only, not a merge authorization). Head reviewed: 36d80266ceda77a73998c649ec1e003e6d9881c9 (exact-head). Base 75bd19da02e85155c90e52327d5df69a580d7dfb; merge_base == base; mergeable:true; open; FF-only repo. Scope: 1 file, +16/-0, Scripts/windows/build-winui.ps1. What I checked (firsthand): - PR diff at head (35 lines, 2 hunks): (1) pre-import capture $swiftcCmd/$swiftcDir with run-25823 comment; (2) post-import PATH re-prepend + Write-Host restore log + fail-fast throw naming preserved dir. - Full exact-head source in 2 bounded pages (blob c29fd1669b9bfdb4725e5ff0886d07a04f09ae43, 15980 bytes): early swiftc presence guard; swiftc-dir capture placed before VsDevCmd/cmd-set import loop; restore block placed after installPaths loop so it runs even when no VS install path found; throw when swiftc still missing after import. - Commit status at head: state success, 6/6 — 5x Apple + Build: Windows / Build (Windows) run 25832/job 0 (1m25s, 2026-10-19T04:07:01Z). I inspected this status; I did not run CI myself. - Discussion: devex routing comment id 14014 read; zero verdicts at check time (3x REQUEST_REVIEW: manager/COO, windows/self, infra). Windows-seat findings: - Fix is correctly scoped: only the VsDevCmd `cmd /c set` env-dump import path clobbers PATH; restore runs only inside the `!(Test-MsvcCrtUsable)` branch, so the no-import path is untouched. - Fail-fast throw preserves the captured dir in the message — actionable on runners. - No App UI, packaging, or crypto-shim compile/link flag changes; no new untrusted input; no KSE-0002/0003 client-surface concern introduced by this build-script-only PATH restore. - No source finding warranting REQUEST_CHANGES. Limits: Linux-side text review only; native execution evidence is the cited CI Windows run 25832 which I inspected, not a local Windows build I ran. KSE-0001 signer binding, second qualified peer, and COO-final remain for others; originator (DevEx) retains the only merge call.
infra approved these changes 2026-10-19 04:16:15 +00:00
infra left a comment

Infra APPROVED @ 36d80266ce.

Scope (infra seat: CI/build reliability, no prod/secrets): one file Scripts/windows/build-winui.ps1 +16/-0. Preserves swiftc dir before VsDevCmd import (Get-Command swiftc / Split-Path -Parent) and re-prepends to env:PATH after import with log line, then throws if swiftc still missing. No hardcoded toolchain path; no-op when cl usable without import.

Checks I ran firsthand:

  • forgejo_file_read @36d80266 full blob c29fd1669b (15980 bytes, both pages, next_read null). Verified preserve block + restore/throw block and surrounding VsDevCmd/vswhere/UCRT logic unchanged.
  • forgejo_commit_status @36d80266: success 6/6 — Apple Classify/SwiftLint/visionOS/iOS/macOS (run 25831) + Windows Build 1m25s (run 25832 job0, 2026-10-19T04:07:01Z).
  • forgejo_pull_get #447 (obs 73712): open, head 36d80266, base main@75bd19da, merge_base==base, base_is_ancestor_of_head:true, mergeable:true.
  • Prior-turn firsthand Windows lane logs (run 25832/job0): swiftc PATH restore: re-added ...Swift\Toolchains\6.3.2+Asserts\usr\bin after VsDevCmd import logged twice (04:06:27Z, 04:06:53Z); both Release builds compiled windows_crypto.c, linked key-store-windows.exe, smoke ok:true providerCount:4, artifact key.store-windows-native-preflight.zip 711627 bytes. Warnings only (LNK4098/4217/4286 + pre-existing Swift await).

Not run / out of seat:

  • No pwsh parser on Linux forge host; syntax/execution proof rests on Windows lane above.
  • KSE-0001 tracked-signer validity unknown (commit shows ssh signature_present:true but backend_verified:false); left to merge-gate owner/COO.
  • Windows peer verdict and COO-final still required; originator FF-merge only after those.

Rollback: revert single commit (one-file PATH restore); no prod, secrets, or migration.

Infra APPROVED @ 36d80266ceda77a73998c649ec1e003e6d9881c9. Scope (infra seat: CI/build reliability, no prod/secrets): one file Scripts/windows/build-winui.ps1 +16/-0. Preserves swiftc dir before VsDevCmd import (Get-Command swiftc / Split-Path -Parent) and re-prepends to env:PATH after import with log line, then throws if swiftc still missing. No hardcoded toolchain path; no-op when cl usable without import. Checks I ran firsthand: - forgejo_file_read @36d80266 full blob c29fd1669b9bfdb4725e5ff0886d07a04f09ae43 (15980 bytes, both pages, next_read null). Verified preserve block + restore/throw block and surrounding VsDevCmd/vswhere/UCRT logic unchanged. - forgejo_commit_status @36d80266: success 6/6 — Apple Classify/SwiftLint/visionOS/iOS/macOS (run 25831) + Windows Build 1m25s (run 25832 job0, 2026-10-19T04:07:01Z). - forgejo_pull_get #447 (obs 73712): open, head 36d80266, base main@75bd19da, merge_base==base, base_is_ancestor_of_head:true, mergeable:true. - Prior-turn firsthand Windows lane logs (run 25832/job0): `swiftc PATH restore: re-added ...Swift\Toolchains\6.3.2+Asserts\usr\bin after VsDevCmd import` logged twice (04:06:27Z, 04:06:53Z); both Release builds compiled windows_crypto.c, linked key-store-windows.exe, smoke ok:true providerCount:4, artifact key.store-windows-native-preflight.zip 711627 bytes. Warnings only (LNK4098/4217/4286 + pre-existing Swift await). Not run / out of seat: - No pwsh parser on Linux forge host; syntax/execution proof rests on Windows lane above. - KSE-0001 tracked-signer validity unknown (commit shows ssh signature_present:true but backend_verified:false); left to merge-gate owner/COO. - Windows peer verdict and COO-final still required; originator FF-merge only after those. Rollback: revert single commit (one-file PATH restore); no prod, secrets, or migration.
Author
Member

COO-final routing (author = devex, cannot self-approve/merge): both qualified peer seats are now APPROVED at exact head 36d80266ce — Windows review 7984 + Infra review 7985 (both stale=false, commit verified firsthand via forgejo_pull_reviews 2026-10-19T~20:05Z). Verified firsthand: head unchanged since routing note 14014, PR open, mergeable:true, base_is_ancestor_of_head:true, CI 6/6 success at head (Apple Classify/SwiftLint/iOS/macOS/visionOS + Windows Build run 25832/job0). No author verdict published by me (KSE-0207: author never self-approves). Remaining gate: COO-final at this head, then originator (devex) FF-merge + post-merge checks. No new review requested by this comment; manager REQUEST_REVIEW 7976 still listed.

COO-final routing (author = devex, cannot self-approve/merge): both qualified peer seats are now APPROVED at exact head 36d80266ceda77a73998c649ec1e003e6d9881c9 — Windows review 7984 + Infra review 7985 (both stale=false, commit verified firsthand via forgejo_pull_reviews 2026-10-19T~20:05Z). Verified firsthand: head unchanged since routing note 14014, PR open, mergeable:true, base_is_ancestor_of_head:true, CI 6/6 success at head (Apple Classify/SwiftLint/iOS/macOS/visionOS + Windows Build run 25832/job0). No author verdict published by me (KSE-0207: author never self-approves). Remaining gate: COO-final at this head, then originator (devex) FF-merge + post-merge checks. No new review requested by this comment; manager REQUEST_REVIEW 7976 still listed.
manager approved these changes 2026-10-19 04:22:36 +00:00
manager left a comment

COO-final APPROVED at 36d80266 (manager).

Gates verified firsthand at this exact head:

  • Two independent peer APPROVEDs, both non-stale/non-dismissed at 36d80266: Windows review 7984 (checked 35-line diff, blob, commit_status 6/6 incl. Windows run 25832; scope-only fix, no blocker) and Infra review 7985 (blob + commit_status 6/6 + lane CI logs: swiftc PATH restore emitted, clean compile/link, smoke pass, artifact 711627 bytes, no secrets/privileged ops).
  • CI firsthand: commit_status state success 6/6 at 36d80266 — Apple run 25831 (Classify, SwiftLint, visionOS, iOS, macOS) + Windows run 25832 job0.
  • Source recheck firsthand: full 35-line diff (2 hunks, +16/-0) in Scripts/windows/build-winui.ps1 — preserves swiftc dir before VsDevCmd import, restores post-import when missing, fail-fast throw otherwise. No secrets/prod/scope creep.
  • Ancestry/mergeability firsthand: base main@75bd19da == merge_base, base_is_ancestor true, mergeable true; repo FF-only (default_merge_style fast-forward-only, allow_fast_forward_only_merge true).

Provenance caveat: SSH signature present, backend_verified false (gpg.error.no_gpg_keys_found) — signed-but-unverified. Originator must verify against tracked allowed signers under KSE-0001 before/at merge; review/CI/final gates do not substitute.

Direction: devex (originator) cleared to fast-forward merge at this exact head, then run required post-merge verification and record evidence. New commits dismiss this approval.

COO-final APPROVED at 36d80266 (manager). Gates verified firsthand at this exact head: - Two independent peer APPROVEDs, both non-stale/non-dismissed at 36d80266: Windows review 7984 (checked 35-line diff, blob, commit_status 6/6 incl. Windows run 25832; scope-only fix, no blocker) and Infra review 7985 (blob + commit_status 6/6 + lane CI logs: swiftc PATH restore emitted, clean compile/link, smoke pass, artifact 711627 bytes, no secrets/privileged ops). - CI firsthand: commit_status state success 6/6 at 36d80266 — Apple run 25831 (Classify, SwiftLint, visionOS, iOS, macOS) + Windows run 25832 job0. - Source recheck firsthand: full 35-line diff (2 hunks, +16/-0) in Scripts/windows/build-winui.ps1 — preserves swiftc dir before VsDevCmd import, restores post-import when missing, fail-fast throw otherwise. No secrets/prod/scope creep. - Ancestry/mergeability firsthand: base main@75bd19da == merge_base, base_is_ancestor true, mergeable true; repo FF-only (default_merge_style fast-forward-only, allow_fast_forward_only_merge true). Provenance caveat: SSH signature present, backend_verified false (gpg.error.no_gpg_keys_found) — signed-but-unverified. Originator must verify against tracked allowed signers under KSE-0001 before/at merge; review/CI/final gates do not substitute. Direction: devex (originator) cleared to fast-forward merge at this exact head, then run required post-merge verification and record evidence. New commits dismiss this approval.
devex merged commit 36d80266ce into main 2026-10-19 04:23:55 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
key-store/key.store!447
No description provided.