Repository navigation
test(isolation): reject temporary directories inside Git checkouts - #1349
Conversation
- Resolve the real temporary-directory path and reject any ancestor .git directory or linked-worktree file before fixtures can inherit a contributor's repository root and deliver files into it. - Install the same global preflight in both Vitest configurations, before worker HOME/TMP setup and before the E2E OpenCode installer, with actionable TMPDIR/TMP/TEMP guidance. - Cover safe roots, nested repositories, checkout roots and symlink targets; load each actual runner config in a subprocess and prove that later setup and worker writes never run after rejection. - Verify all 7 guard and runner-subprocess cases, TypeScript and lint, and document safe temporary-directory selection in the contributor guide. Refs: Tencent#1338
|
No findings in the specified PR diff. The changes are limited to test infrastructure and contributor documentation, so no real-CLI/E2E record is required under the review rules. The PR description nevertheless provides detailed validation records and identifies independently reproduced baseline failures. I did not run, build, or install anything from the PR. |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
@nateEc Thanks, approving. This is tests-only, so no real-CLI record is needed.
We ran both Vitest configs on fresh clones of this head, its merge-base 83f6d1db and main 54622c3a, with TMPDIR pointing inside the clone.
- base and main: the run writes
.agents/,.codex/and.mcp.jsoninto the clone and adds sixhook.teamai-*entries to its.git/config. - this head: it stops with exit 1 before writing anything: "TMPDIR … is inside the Git checkout …. Set TMPDIR, TMP and TEMP to a directory outside every Git checkout before running tests."
With TMPDIR outside the checkout, the new unit file passes 7/7 and muse-support passes 6/6. tsc, lint and CI pass. Refs #1338 fits: this covers the issue's test-isolation part, and the init subdirectory anchoring stays open.
Optional:
[P3 nit]The unit-config probe spreadsbase.test.globalSetupwithout a fallback, so if that wiring is ever removed it fails withglobalSetup is not iterableinstead of the guard message.?? []would cover it.[P3 nit]ATMPDIRthat doesn't exist fails with a bareENOENT. Base does the same, so it isn't a regression.- The body's full-suite failure in
submodule-checkout-1041passes 21/21 in isolation on both this head and base here, so we couldn't reproduce it.
CI review: it reported no findings and said no real-CLI record is needed for a tests-only change. We agree on both. We couldn't reproduce the baseline failures it refers to (above).
…encent#1349) - Resolve the real temporary-directory path and reject any ancestor .git directory or linked-worktree file before fixtures can inherit a contributor's repository root and deliver files into it. - Install the same global preflight in both Vitest configurations, before worker HOME/TMP setup and before the E2E OpenCode installer, with actionable TMPDIR/TMP/TEMP guidance. - Cover safe roots, nested repositories, checkout roots and symlink targets; load each actual runner config in a subprocess and prove that later setup and worker writes never run after rejection. - Verify all 7 guard and runner-subprocess cases, TypeScript and lint, and document safe temporary-directory selection in the contributor guide. Refs: Tencent#1338
If
TMPDIRlives inside a contributor's checkout, a temporary fixture without its own.gitcan inherit that checkout's Git root and deliver TeamAI files into the source tree. HOME isolation alone cannot prevent this.Run a shared temporary-directory guard before workers in both Vitest configurations, before the shared OpenCode installer in E2E. Resolve the real temporary path and reject any ancestor
.gitdirectory or file with an actionable environment-variable message. This is tests-only; production CLI behavior is unchanged.Validation:
npx vitest run src/__tests__/test-tmpdir-safety.test.ts: 7 passed, covering safe roots, nested Git directories, linked-worktree.gitfiles, symlinks and checkout roots. Subprocesses load each actual runner configuration and prove rejection before any later setup/worker marker write.npx tsc --noEmit,npm run lint, andgit diff --check: passed.npm run test:e2ecompleted the entire 182-file suite: 175 files passed, 6 skipped, 1 failed; 1,404 tests passed, 64 skipped, 1 failed. The sole failure is the existingsubmodule-checkout-1041.test.tscasedelivers, inherits, cleans up and uninstalls submodules through the real CLI, at the missinghook.teamai-post-checkout.commandassertion. A clean main (83f6d1db) build independently reproduced the same case and assertion (focused baseline run with the already-prepared OpenCode installer omitted). Environment: macOS, Node 22.22.1, Apple Git 2.50.1. The final probe-fixture slash normalization also passed all 7 guard/subprocess tests, TypeScript and lint; E2E runtime/setup sources were unchanged by that final test-only adjustment.State review: global setup only reads
os.tmpdir(), real paths and ancestor Git markers; it runs before HOME/TMP fixture creation and before OpenCode preparation. It neither changes process environment nor writes contributor files. Contributor instructions explain how to select a safe temporary directory.Broader regression:
npx vitest run --maxWorkers=6in a frozen integration worktree containing the five changes finished with 500 files passed, 12,285 tests passed, 36 skipped, 2 failed. Both failures are the pre-existingsubmodule-checkout.test.tsempty legacy hook-file cases; a clean83f6d1dbworktree independently reproduced 24 passed / the same 2 failed. This is an integration-suite record, not a claim that the baseline is fully green.Refs #1338. One independently reviewable defect from the issue; the audit/issue remains open for its other items.