Repository navigation
test: take the probe and prewarm scratch dirs from pytest-owned roots - #38265
Conversation
First Principles Review (Opus 5.5) — ⏭️ skippedRevision |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the change is test-only, reuses the suite's existing Notes
[DESIGN-REVIEWED] 45b6a29 Description read[DESCRIPTION-READ] 9690cf3249871af5ab69839cdc84a18cf00b79ab9ec29d9c06d183fdc92b107e That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
The test-shared-tmp-dir rule (widened in #38029) matches five mkdtemp sites that predate it. The footprint probe tests now take the existing short_sock_dir fixture, which keeps the short AF_UNIX path from short_tmp_base() and SHORT_TMP_PREFIX. The prewarm sandbox test makes its scratch inside the per-test data home. Fixes #38264
e4ff589 to
45b6a29
Compare
|
GPT F1 (socket path over CodeQL neutral: "configuration not found" comes from main having no |
Code change approver recommendation: A person should decideWhy: the decider estimates a 6% chance that this change introduces a defect, within the 12% limit for approving on its own, but it is held at tier pending: being reviewed. Test-only change that replaces five tempfile.mkdtemp calls with pytest-owned dirs. The probe tests now take the existing short_sock_dir fixture. It is built on the same short_tmp_base() and SHORT_TMP_PREFIX as the old code and cleans up at teardown, so the removed try/rmtree blocks lose nothing. On Linux the fixture never falls back to tmp_path, and _probe() makes and removes its own kc-fp- subdir, so the empty-directory assertions stay meaningful. The extra "unixsock-" label makes the worst-case socket path 104 bytes, under the 107-byte _MAX_SOCKET_PATH, and a new test pins that calculation. The prewarm scratch moves to a fixed name under the data home, which is unique per test because of the _isolation_dirs counter. CI is green, including SAST. Tier: pending: being reviewed. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
I reviewed head 45b6a29. All five flagged tempfile.mkdtemp sites are gone. The four footprint probe tests now use the existing short_sock_dir fixture. That fixture uses the same short root and SHORT_TMP_PREFIX, and it cleans up at teardown, so the removed try/rmtree blocks lose nothing and the iterdir() == [] checks still start from an empty directory. The prewarm test's fixed scratch child sits under a per-test data home taken from tmp_path_factory, so two tests cannot collide. I recomputed the worst-case socket path: 104 bytes against the 107-byte limit, and 110 if the old probe/ level comes back. No assertion, rule or baseline is loosened. The change adds no sleep, clock or port, and the getpass.getuser patch goes through monkeypatch. PR Readiness is green on this head.
Done well: the fix uses the suite's one short-path fixture instead of a suppression, and it pins the sun_path budget that the move to the fixture tightens.
Optional:
test_the_short_sock_dir_socket_fits_sun_pathbuilds its path from its own copies ofshort-,unixsock-andkc-fp-. If any of those labels gets longer, the test stays green. Making them constants in the modules that own them, and importing those constants, would let the pin catch that.- The edited hunk in
test_acp_node_compile_cache_engine.pyis in a@needs_sandboxtest, and that test is skipped in CI. If you have a host with the engine and a sandbox backend, a single local run would add evidence for that hunk.
Problem / Motivation
Goal: A PR whose merge-base predates two test files no longer fails SAST on five lines it never touched.
Five
tempfile.mkdtempcalls in two test modules matchkirocrew.test-shared-tmp-dir, which #38029 widened to every test file. The SAST job scans only lines that are new against the PR's merge-base. When the merge-base predates these files, the job counts the five lines as new and the PR fails SAST: run 44008212922 on #38238 is the example. Main's own CI never reports them because the SAST job does not run on pushes to main.Why it matters
Until the files are fixed, any contributor whose branch is older than #36922 or #30671 gets a red SAST check for code outside their diff, and has to rebase to clear it.
Not a goal
What changed (motivation → approach → change)
The rule asks for a pytest-owned directory.
test_mcp_footprint_stub_probe.pymade its socket dirs withmkdtemp(prefix=SHORT_TMP_PREFIX, dir=short_tmp_base())because macOS caps an AF_UNIX path at 104 bytes and a deeptmp_pathexceeds that. The suite already has a fixture for exactly that case,short_sock_dirintest/conftest_opt_in.py, built on the sameshort_tmp_base()andSHORT_TMP_PREFIXand removed at teardown. The four probe tests now take it, so the short path is kept and the hand-writtentry/rmtreeblocks go. The 15% PSS test already usedshort_sock_dirfor the daemon socket, so its probe gets an emptyprobe/subdirectory of it.test_acp_node_compile_cache_engine.pymade the prewarm sandbox scratch withmkdtemp(dir=run_parent)under the data home. The data home in a test is that test's own isolation dir under pytest's basetemp, so the scratch is now a fixedscratchchild of the same parent: still inside the data home the sandbox reads, unique per test, and removed with the run.Backwards compatibility
Compatible: test files only; no production code changes.
Removes nothing: the diff drops two unused imports and test-local
rmtreecleanup that the fixture now does.Tests
Both modules pass before and after on Linux: 18 passed, 2 skipped (no agent engine or sandbox backend on the test host, the same two skips as main).
semgrep --config semgrep/reports nothing on either file. Pre-push gate: 21 ran, 0 failed.Proof: not provable -- test-only change
Manual verification
N/A — test-only change; the module runs and the Semgrep rule are the check.
Related Issues
Fixes #38264
Surfaced by #38238 (run 44008212922). Rule widened in #38029; earlier conversions under #37621.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)