Repository navigation
Reuse the machine's Rust toolchain under a verification HOME - #48
Merged
Merged
Conversation
A verification runner gets its own HOME, and rustup reads RUSTUP_HOME with a default of $HOME/.rustup. Under a runner that directory is empty, and rustup does not fail there: it downloads and installs the whole toolchain into it, reports that as a warning, and exits 0. The exit 0 is why this went unnoticed for so long, and why the two workarounds already in the tree never ran. rust-test.sh and swift-test.sh had each diagnosed the missing toolchain correctly and each guarded its recovery behind a cargo invocation failing, which the auto-install prevents. rust-test.sh's recovery was dead code; swift-test.sh read the same success and took its cargo-is-available branch after paying for a download. Every run directory had grown a private copy: 1.3 GB of .rustup plus 128 MB of .cargo per run, 9.1 GB across eleven runs, duplicating a toolchain already installed on the machine. Resolution now happens once, in scripts/toolchain-env.sh, which every script here that calls cargo sources before its first cargo call. It finds the real CARGO_HOME and RUSTUP_HOME from the cargo shim's own location rather than a literal path, and defers to either variable when it is already set. The two failure-guarded workarounds are deleted rather than left beside it. scripts/verify-cargo.sh and scripts/verify-swift.sh are plain-argv entrypoints for the PRD harness, which runs verify commands with execvp and no shell: an "ENV=value cargo ..." binding there fails with ENOENT at verify time, when a sealed run can no longer be amended, so the environment decision has to live in a script. Their target directory is shared across runs rather than keyed by checkout, which the worktree rule permits for the reason it names: every verify run builds the same checkout, so there is one path and sharing is what makes the second run incremental. scripts/tests/test_toolchain_reuse.py is what keeps the next cargo-running script from rediscovering this. It asserts that every tracked shell script which invokes cargo sources the resolver, that the resolver is sourced rather than executed, and that it defers to an explicitly set toolchain.
yansfil
added a commit
that referenced
this pull request
Oct 29, 2026
Closes with-hide/hide-private#180 Closes with-hide/hide-private#277 Closes with-hide/hide-private#202 Closes with-hide/hide-private#198 Closes with-hide/hide-private#199 Closes with-hide/hide-private#48 Closes with-hide/hide-private#114 ## Summary Windows에서만 가끔 실패하던 테스트 묶음을 원인별로 고칩니다. 재시도는 늘리지 않았고, 각 실행의 10초 제한은 그대로 두었으며, 프로세스 정리에 쓸 시간만 더했습니다. 테스트가 같은 파일에 같이 쓰던 것, 처음 실행하는 PowerShell과 node의 비용을 제한 시간 안에서 내던 것, vitest worker를 동기 컴파일로 막던 것, 화면 테스트마다 반복하던 무거운 작업을 없앴습니다. 제품 동작은 바뀌지 않습니다. 설치된 hook이 처음 실행될 때 PowerShell 모듈을 불러오는 비용은 hide-private#318로 남겼습니다. #124는 그 lane이 #1719로 이미 삭제되어 근거 코멘트를 남기고 닫았습니다. 스크린샷 없음: 화면 동작은 바뀌지 않음(`web/src/i18n/instance.ts`는 같은 검증을 하는 시점만 앞당김). <details><summary>이슈별 원인과 처리</summary> - **#198 #199 agy hook 테스트**: 테스트 준비가 PowerShell을 `exit 0`으로만 미리 띄웠습니다. 그래서 hook 명령이 쓰는 `Test-Path`가 모듈을 처음 불러오는 비용(새 runner에서는 설치된 모든 모듈의 캐시를 먼저 만듦)이 15초 제한 안에 들어갔습니다. 미리 띄울 때 `Test-Path`까지 실행합니다. 이것은 warm 상태의 기능 테스트를 위한 준비입니다. 제품 hook 명령의 cold 경로는 그대로이고, 고치려면 설치된 명령 문자열과 HOOK_VERSION이 바뀌어야 해서 hide-private#318로 남겼습니다. - **#202 hide-kit node 테스트**: job에서 처음 실행하는 `node.exe`가 2.5-40초 걸렸습니다(다음 node는 0.1초). 테스트의 제한 시간이 시작되기 전에 `node --version`으로 첫 실행을 냅니다(`stand_ins`, hided 테스트가 이미 쓰는 방식). 바뀌는 것은 테스트 준비뿐입니다. - **#180 #277 herdr-core PowerShell 시작 질문 테스트**: 두 pane이 한 파일에 `Add-Content`로 쓰면서 모든 오류를 잡고 5초 동안 재시도했고, 실패 화면에는 "stayed locked"만 남았습니다. 기록마다 자기 파일에 .NET으로 쓰고 재시도는 없앴습니다. 오류가 나면 그 오류가 그대로 보입니다. - **#48 platform-program.unit.ts**: `beforeAll`이 C 프로그램 6개를 `execFileSync`로 동기 컴파일해서 worker가 81초 동안 막혔습니다. 컴파일과 프로그램 실행을 await하는 자식으로 바꿨습니다(`web/e2e/bounded-child.ts`). 호출마다 동기 호출 때와 같은 제한(컴파일 60초와 1 MiB, 실행 10초)이 있습니다. 어떻게 끝나든(스스로 종료, 제한 초과, 시작 실패, 테스트의 `signal`) 기존 fixture 도구로 자식 트리 전체를 끝냅니다. 첫 프로세스의 종료는 그것이 띄운 자손에 대해 아무것도 말해 주지 않고, Windows에서는 자손이 출력을 쥐고 있어도 그 종료와 함께 `close`가 오기 때문입니다. Unix는 process group 종료를 확인하고, Windows는 `hide-processes`가 identity로 자손을 따라갑니다. 이 도구들은 의존이 없는 `web/e2e/process-tree.ts`로 옮겨 shim 빌드도 함께 씁니다. 종료를 확인하지 못하면 즉시 그렇게 알리고, 호출자는 임시 파일을 지우지 않습니다. 그때까지 트리는 worker 종료 정리(`ownUntilWorkerExit`)에 등록되어 있습니다. Windows에서는 `hide-processes`를 먼저 빌드하고, 이후 컴파일을 따라갑니다. 그 자신의 컴파일이 실패하면 partial 파일을 남깁니다. - **#114 Windows web unit 5초 타임아웃**: Windows runner는 jsdom 테스트가 이 Mac보다 약 7배 느려서, 로컬에서 0.5초를 넘는 테스트가 5초 한도에 붙습니다. 무거운 동기 작업 두 개를 없앴습니다. - 화면 테스트마다 mount할 때 번역 카탈로그(약 4,000키 x 4개 언어)를 다시 검증 -> 정적 카탈로그라 모듈을 불러올 때 한 번만 검증. - `practice/worlds.test.ts`가 입력마다 출발 상태의 snapshot과 화면을 다시 계산(테스트 시간의 87%) -> 상태마다 한 번만 그리고 store에는 매번 다시 넣음. world가 상태를 제자리에서 바꾸지 않는다는 것은 모든 모델을 deep-freeze한 상태로 18개 테스트가 통과하는 것으로 확인했습니다. - **#124 nightly agent journey signed in (windows)**: 이 lane은 #1719(c88d028, 10-27 운영자 결정)로 CI에서 빠졌습니다. 코드 수정 없이 근거 코멘트를 남기고 not planned로 닫았습니다. </details> ## Review - **판단해 주세요**: #198 #199와 #202는 테스트 준비만 바꿉니다. 제품 hook의 cold 첫 실행(hide-private#318)은 이 PR의 범위 밖입니다. - **조심해서 볼 파일**: `web/src/i18n/instance.ts` - 카탈로그 검증이 import 시점으로 옮겨졌습니다. 잘못된 카탈로그는 이제 첫 instance를 만들 때가 아니라 모듈을 불러올 때 throw합니다. - **조심해서 볼 파일**: `web/e2e/bounded-child.ts`, `web/e2e/process-tree.ts`, `web/e2e/shims/build.ts` - 실패 경로의 트리 종료, 종료를 확인하지 못했을 때 파일을 남기는 것, worker 종료 정리. `endStartGroup`, `windowsProcessTree`, `endWindowsProcesses`의 본문이 `process-tree.ts`로 옮겨졌습니다(기존 이름은 그대로 위임). `buildFixtureShims`는 async가 되어, Playwright `globalSetup` 두 곳과 vitest 파일 세 곳이 await합니다. - **남은 한계**: with-hide/hide-private#324 ## Evidence - **확인한 것 (원인)**: run 40449782460에서 PowerShell 테스트 4개가 같은 순간에 시작해 38-48초 걸렸고, 제한 없이 `Test-Path`를 먼저 실행한 `every_windows_command`만 통과했습니다. run 40679837812에서는 node 테스트가 1차에 30초로 시간 초과되고 재시도에 12초 걸렸습니다. run 40679854397의 pane 화면에는 `claude-args stayed locked`가 남았습니다. - **확인한 것 (Windows)**: head 997877724의 `windows check`(run 40723179805)에 TRY 2/FLAKY/onTaskUpdate 줄이 없습니다. herdr-core PowerShell 테스트 10.7초, agy hook 테스트 2.8-5.6초, hide-kit node 테스트 2.4초입니다. web unit에서 가장 느린 테스트는 OverviewGraph overflow 3.9초이고, worlds는 최대 1.5초입니다(main run 40706855580에서는 5.8초). Windows agent journey dispatch run 40719259611 통과. - **확인한 것 (로컬 macOS)**: `verify-web.sh web/desktop typecheck/lint`, `desktop test` 통과. `web test`는 260 files 중 `src/mobile/sleep.test.tsx` 2개만 5초 타임아웃으로 실패했습니다(측정 중 load 98). 단독으로 돌리면 통과하고, 이 PR이 건드리지 않은 파일입니다. `bounded-child.unit.ts`의 세 회귀 테스트(종료 실패를 즉시 알림, 부모가 먼저 끝나고 자손이 stdout을 쥔 경우, worker 종료)는 각 수정을 되돌리면(Unix group 대신 첫 프로세스만 kill, worker 등록 제거, 종료 실패를 close까지 대기) 실패하고, 복원하면 통과합니다. - **확인한 것 (Windows 트리 종료)**: head e2179be05의 `windows check`에서 `bounded-child.unit.ts` 4개(종료 실패, 부모 선종료, 제한 시간 초과 때 출력을 쥔 자손, worker 종료)와 `windows-processes.unit.ts`가 통과했습니다. 한 번의 green은 flaky가 해소됐다는 증명이 아니므로, 이후 main run에서 같은 이슈 코멘트가 다시 붙지 않는지 봐야 합니다. OverviewGraph overflow(3.9초)가 여전히 5초 한도에 가장 가깝습니다. - **확인하지 못한 것**: #180 #277에서 원래 삼켜진 오류가 무엇이었는지는 로그로 복원할 수 없었습니다. 공유 파일과 cmdlet 의존을 둘 다 없애 두 후보를 모두 제거했고, 남는 실패는 자기 메시지를 보입니다. <details><summary>Verification record</summary> - head: e2179be (fix/flaky-windows-lane, origin/main 877ec01 merge 포함) - 이 head의 CI: verify run 40829385062 전체 pass (windows check job 123299939776: TRY 2/FLAKY/onTaskUpdate 줄 없음, web unit 260 files, desktop unit 28 files; windows e2e, windows desktop, package windows, os/agy contract windows pass) - 거쳐 온 head: 5823db114는 Windows에서 부모 종료와 함께 `close`가 와서 `bounded-child.unit.ts`가 실패(run 40823405169). 0bde0ea2b는 `hide-processes` 자신의 컴파일에 아직 없는 경로를 넘겨 Windows 빌드가 실패(run 40826389313). 둘 다 e2179be05에서 고침 - Windows agent journey dispatch: run 40719259611 (systems windows, fake model) pass </details>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed, in one paragraph a new contributor can follow
A verification runner gets its own HOME, and rustup reads
RUSTUP_HOMEwith a default of$HOME/.rustup. Under a runner that directory is empty, and rustup does not fail there: it downloads and installs the whole toolchain into it, reports that as a warning, and exits 0. Because the exit code is 0 nothing downstream notices, so every run directory underagents/runs/had quietly grown its own copy of a toolchain that was already installed on the machine. Resolution now happens once, inscripts/toolchain-env.sh, which every script here that calls cargo sources before its first cargo call.The measured cost was 1.3 GB of
.rustupplus 128 MB of.cargoper run, 9.1 GB across eleven run directories.The same exit 0 is why the two workarounds already in the tree never ran.
rust-test.shandswift-test.shhad each diagnosed the missing toolchain correctly, and each guarded its recovery behind a cargo invocation failing, which the auto-install prevents.rust-test.sh's recovery was dead code;swift-test.shread the same success and took its cargo-is-available branch after paying for the download anyway. Both are deleted here rather than left beside the resolver.scripts/verify-cargo.shandscripts/verify-swift.share plain-argv entrypoints for the PRD harness, which runs verify commands with execvp and no shell: anENV=value cargo ...binding there fails with ENOENT at verify time, when a sealed run can no longer be amended, so the environment decision has to live in a script rather than in a command string.Review boundary
rust-test.shstill exits 1 with theHOME=diagnostic when no toolchain can be resolved.swift-test.sh's cargo-unavailable branch now means what it says: a machine with no Rust, rather than a runner that merely had its own HOME.verify-cargo.shandverify-swift.shexit 2 on an unknown subcommand with a usage line.Evidence
Verified by:
Mechanism reproduced directly, which is the claim the whole change rests on:
Fix verified end to end: a full release build through the new entrypoint under an isolated HOME, checking what the HOME held afterward.
The HOME is still empty. Before this change the same run left
.rustupbehind.Gates run locally, all passing: the script suite (13 tests, including the four new ones),
cargo fmt --all --check, and every structural checkpr.ymlruns (check-harness-ignore-anchor,check-agent-asset-committed,check-capability-readers-off-lock,check-terminal-row-cache,check-no-workstation-identity, the four worktree checks,check-right-panel-sections,check-shortcut-contract,check-herdr-pin-single-source).Regression that catches the old failure:
scripts/tests/test_toolchain_reuse.py. It asserts that every tracked shell script invoking cargo sources the resolver, that the resolver is sourced rather than executed (a subshell's exports would not reach the caller, and the failure would be silent), and that it defers to an explicitly setCARGO_HOMEorRUSTUP_HOME. Written against the current tree it found five cargo callers beyond the two that had diagnosed the problem:build-app.sh,check-hide-full.sh,check-runtime-gates.sh,check-typed-contract.sh,check-typed-live-remote.sh, plusmacos/scripts/build_dev_app.sh. All are wired here.Not verified (and why):
cargo clippy --locked --workspace --all-targetsandcargo test --locked --workspacewere left to CI rather than run locally. No Rust source, manifest or lockfile is touched by this diff, so neither can be affected by it; CI runs both regardless and the merge waits on them.swift testlikewise: no Swift source changed.High-frequency path impact: N/A. Nothing here runs in the app, on the session-sync coordinator, or per input.
Screenshots
N/A - no visual surface changed.
AI tooling
Written with AI tooling. Checked by hand: the auto-install behaviour was reproduced in a scratch HOME before the fix was designed rather than inferred from the symptom, the per-run sizes quoted come from
duon the actual run directories, and the end-to-end result was confirmed by inspecting the isolated HOME after a real release build rather than from the build succeeding. The regression test was run against the pre-fix tree to confirm it fails, which is how the five additional cargo callers were found.