GeezerVison is showing github.com — test(sidecar): one run root per test process, per-test teardown by myakove · Pull Request #1047 · myk-org/pi-config
Conversation
Closes #1046.
#1045 covered tests/node; the sidecar TS suite is a separate package and was left out — 11 files called mkdtempSync(join(tmpdir(), …)) directly, and node:test only removes what it creates. 59 sidecar-* / pi-sidecar-* / transcripts-* dirs were sitting at /tmp top level, and the suite runs in prek on every commit.
Same fixture pattern as tests/node/helpers/temp-dirs.ts:
- one run root per test process (
<tmp>/pi-config-tests/run-<pid>), removed when the file's tests finish — a run adds ONE directory under /tmp;
- scope by creation time: module/
before() dirs die with the file, test dirs by afterEach, pass or fail;
- a run root whose process is gone is reaped on the next import (process check, no timers);
- hooks register on import, so a file cannot forget teardown.
Verification
npx tsx --test "packages/pi-sidecar/tests/test_ts/*.test.ts" → 482 passed, 0 failed
- /tmp top-level dir count unchanged by the run (549 → 549)
- 59 pre-existing leftovers removed
- repo-wide
grep mkdtemp: only the two helpers, plus subagent-tool.ts which creates inside the project by design
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
The sidecar TS suite was the tree #1045 did not cover: 11 files called
`mkdtempSync(join(tmpdir(), …))` directly and node:test only removes what it creates, so every
test leaked a directory (59 of them were sitting at /tmp top level, alongside the 45k the node
suite had accumulated).
Same fixture pattern as `tests/node/helpers/temp-dirs.ts`:
- one run root per test process (`<tmp>/pi-config-tests/run-<pid>`), removed when the file's
tests finish — a run adds ONE directory under /tmp;
- scope by creation time: module/`before()` dirs die with the file, test dirs are removed by
`afterEach`, pass or fail;
- a run root whose process is gone is reaped on the next import (process check, no timers);
- hooks register on import, so a file cannot forget teardown.
Verified: sidecar suite 482 passed / 0 failed, and /tmp top-level count is unchanged by the run
(549 → 549); 59 pre-existing `sidecar-*` leftovers removed.
Assisted-by: PI (rits/deepseek-ai/DeepSeek-V4.1-Flash-1017)
Signed-off-by: Meni Yakove <[email protected]>
|
Report bugs in Issues
Welcome! 🎉
This pull request will be automatically processed with the following features:
🔄 Automatic Actions
- Reviewer Assignment: Reviewers are automatically assigned based on the OWNERS file in the repository root
- Size Labeling: PR size labels (XS, S, M, L, XL, XXL) are automatically applied based on changes
- Issue Creation: Disabled for this repository
- Branch Labeling: Branch-specific labels are applied to track the target branch
- Auto-verification: Auto-verified users have their PRs automatically marked as verified
- Labels: All label categories are enabled (default configuration)
📋 Available Commands
PR Status Management
/wip - Mark PR as work in progress (adds WIP: prefix to title)
/wip cancel - Remove work in progress status
/hold - Block PR merging (PR author or approvers)
/hold cancel - Unblock PR merging (PR author or approvers)
/verified - Mark PR as verified
/verified cancel - Remove verification status
/reprocess - Trigger complete PR workflow reprocessing (useful if webhook failed or configuration changed)
/regenerate-welcome - Regenerate this welcome message
/security-override - Set security check runs to pass (maintainers only)
/security-override cancel - Re-run security checks
Review & Approval
/lgtm - Approve changes (looks good to me)
/approve - Approve PR (approvers only)
/automerge - Enable automatic merging when all requirements are met (maintainers and approvers only)
/automerge cancel - Remove automerge label (maintainers and approvers only)
/assign-reviewers - Assign reviewers based on OWNERS file
/assign-reviewer @username - Assign specific reviewer
/check-can-merge - Check if PR meets merge requirements
Testing & Validation
/retest tox - Run Python test suite with tox
/retest build-container - Rebuild and test container image
/retest all - Run all available tests
Container Operations
/build-and-push-container - Build and push container image (tagged with PR number)
- Supports additional build arguments:
/build-and-push-container --build-arg KEY=value
Cherry-pick Operations
/cherry-pick <branch> - Schedule cherry-pick to target branch when PR is merged
- Multiple branches:
/cherry-pick branch1 branch2 branch3
/cherry-pick-retry <branch> - Retry a failed cherry-pick (merged PRs only)
Branch Management
/rebase - Rebase this PR branch onto its base branch
Label Management
/<label-name> - Add a label to the PR
/<label-name> cancel - Remove a label from the PR
✅ Merge Requirements
This PR will be automatically approved when the following conditions are met:
- Approval:
/approve from at least one approver
- Status Checks: All required status checks must pass
- No Blockers: No wip, hold, has-conflicts labels and PR must be mergeable (no conflicts)
- Verified: PR must be marked as verified
📊 Review Process
Approvers and Reviewers
Approvers:
Reviewers:
Available Labels
- hold
- verified
- wip
- lgtm
- approve
- automerge
AI Features
- Conventional Title: Mode:
fix (EnMaaS/rits/deepseek-ai/DeepSeek-V4.1-Flash-1017)
- Cherry-Pick Conflict Resolution: Enabled (EnMaaS/rits/deepseek-ai/DeepSeek-V4.1-Flash-1017)
Security Checks
- Suspicious Path Detection: Monitors paths:
.claude/, .vscode/, .cursor/, .devcontainer/, .pi/, .github/workflows/, .github/actions/
- Committer Identity Check: Verifies last committer matches PR author
- Mandatory: Security checks block merge (use
/security-override to bypass — maintainers only)
💡 Tips
- WIP Status: Use
/wip when your PR is not ready for review
- Verification: The verified label is removed on new commits unless the push is detected as a clean rebase
- Cherry-picking: Cherry-pick labels are processed when the PR is merged
- Container Builds: Container images are automatically tagged with the PR number
- Permission Levels: Some commands require approver permissions
- Auto-verified Users: Certain users have automatic verification and merge privileges
For more information, please refer to the project documentation or contact the maintainers.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
PR Summary by Qodo
Prevent sidecar tests from leaving temporary directories
🐞 Bug fix 🧪 Tests 🕐 20-40 Minutes

AI Description
-
• Add a sidecar temp-directory fixture with one run root per test process.
• Clean up test-scoped directories after each test and file-scoped fixtures after the file finishes.
• Reap abandoned run roots on import and migrate 11 sidecar test files away from top-level temp
directories.
Diagram
-
graph TD
T["Sidecar tests"] --> H["Temp fixture"] --> R["PID run root"] --> D["Scoped directories"]
H --> K["Test hooks"] --> C["Cleanup"] --> D
C --> R
H --> S["Dead-run reaper"] --> O["Abandoned roots"]
Loading
High-Level Assessment
-
The following are alternative approaches to this PR:
1. Share one fixture across node and sidecar suites
-
- ➕ Avoids maintaining two nearly identical cleanup implementations.
- ➖ Couples separate test packages and their node:test hook registration to a shared test module.
Recommendation: Keep the sidecar-local fixture for this targeted cleanup: it follows the established node-suite pattern without introducing a cross-package test dependency. A shared module is worth considering if both fixtures need further changes.
Files changed (12) +162 / -61
-
Bug fix (1) +90 / -0
-
temp-dirs.tsAdd lifecycle-managed sidecar temp-directory fixture +90/-0
Add lifecycle-managed sidecar temp-directory fixture
• Creates directories beneath a PID-specific run root and registers per-test and file-end cleanup hooks on import. Reaps run roots whose owning process is no longer running.
packages/pi-sidecar/tests/test_ts/helpers/temp-dirs.ts
Tests (11) +72 / -61
-
agent-dir-config.test.tsScope agent-directory configuration fixtures +16/-15
Scope agent-directory configuration fixtures
• Creates provider, settings, deployment, request, and working directories through the managed temp fixture instead of directly under the system temp directory.
packages/pi-sidecar/tests/test_ts/agent-dir-config.test.ts
agent-dir-integration.test.tsManage agent-directory validation fixtures +3/-2
Manage agent-directory validation fixtures
• Uses the shared fixture for directories in file-versus-directory validation tests.
packages/pi-sidecar/tests/test_ts/agent-dir-integration.test.ts
models-for-api-key.test.tsManage model-discovery test directories +31/-30
Manage model-discovery test directories
• Moves key-scoped provider and model manifest fixtures into the managed run root without changing their assertions.
packages/pi-sidecar/tests/test_ts/models-for-api-key.test.ts
providers-discovery.test.tsManage provider-discovery file fixture +2/-1
Manage provider-discovery file fixture
• Creates the provider-discovery directory through the fixture so its module-level lifetime ends with the test file.
packages/pi-sidecar/tests/test_ts/providers-discovery.test.ts
recording-route.test.tsManage recording-route transcript directory +2/-1
Manage recording-route transcript directory
• Uses the fixture for the transcript directory established during suite setup.
packages/pi-sidecar/tests/test_ts/recording-route.test.ts
session-api-key.test.tsManage session API-key working directory +2/-1
Manage session API-key working directory
• Creates the suite's working directory within the managed run root.
packages/pi-sidecar/tests/test_ts/session-api-key.test.ts
session-events-route.test.tsManage SSE route agent-directory fixtures +2/-1
Manage SSE route agent-directory fixtures
• Routes offline agent-directory creation through the shared fixture.
packages/pi-sidecar/tests/test_ts/session-events-route.test.ts
session-events-stream.test.tsManage SSE stream transcript fixture +2/-1
Manage SSE stream transcript fixture
• Creates the transcript directory used during stream-test setup under the managed run root.
packages/pi-sidecar/tests/test_ts/session-events-stream.test.ts
session-store.test.tsManage session working-directory fixtures +6/-5
Manage session working-directory fixtures
• Uses managed directories for boot, session, and binary-path fixtures in CLI working-directory tests.
packages/pi-sidecar/tests/test_ts/session-store.test.ts
tools-config.test.tsManage tool-configuration validation fixture +2/-1
Manage tool-configuration validation fixture
• Creates the temporary directory for file-based agent_dir validation through the shared fixture.
packages/pi-sidecar/tests/test_ts/tools-config.test.ts
transcripts.test.tsManage transcript and session-header fixtures +4/-3
Manage transcript and session-header fixtures
• Routes transcript-directory creation and session-header agent and working directories through the managed fixture.
packages/pi-sidecar/tests/test_ts/transcripts.test.ts
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Code Review by Qodo
🐞 Bugs (0) 📘 Rule violations (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


1. Repo-wide mkdtemp check still matches the converted files ✓ Resolved
Resolving commit: 2cccd20
Resolution reason
The commit removes the stale mkdtempSync (and tmpdir where unused) imports from the eleven listed
sidecar test files, including recording-route.test.ts (line 6-8 hunk removing mkdtempSync and
tmpdir), agent-dir-config, agent-dir-integration, models-for-api-key, providers-discovery,
session-api-key, session-events-route, session-events-stream, session-store, tools-config, and
transcripts. This matches the suggested fix of removing unused mkdtempSync/tmpdir imports in each
listed file. Some other files were also cleaned up, and the helper temp-dirs.ts was modified, but
the finding's requested remediation is directly implemented.
Description
The eleven converted sidecar test files keep mkdtempSync in their node:fs import lines even
though every call now goes through makeTempDir, so grep mkdtemp still reports them. This is the
check the PR description and rule 2978989 use to prove that no unmanaged mkdtemp use remains, and
it currently returns the 11 test files in addition to the two helpers and subagent-tool.ts. The
stale imports also trip unused-import lint in these files and mislead a later reader into thinking
the tests still create directories themselves.
2. Parallel test runs can fail during setup ✓ Resolved
Resolving commit: 2cccd20
Resolution reason
Stopped removing the shared TEST_TMP_BASE in after(), so other processes can no longer lose the base
mid-setup; and added a retry around the TEST_RUN_ROOT mkdirSync so a transient ENOENT during
run-root creation is retried.
Description
after() removes the shared TEST_TMP_BASE while another test process can be between creating that
base and creating its run root. When those steps interleave, makeTempDir() can throw ENOENT,
causing an otherwise passing test to fail.

Context sources
✅ Linked PRs:
🌐 PR #1045
⚠️ Tickets: not configured — No jira, linear integration is connected for the linked tickets
Review mode: Auto: 🚀 Fast: Mechanical import cleanup plus a small mkdir retry; localized, low risk.
✅ Fix-loop round: fix loop

Tip of the day
💡 Did you know, you can hide the parts of a finding you never read, like the evidence or the agent prompt
More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Previous reviews
Review updated until commit 2cccd20
Results up to commit 9aa09f6 ⚖️ Balanced
🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)
1. Repo-wide mkdtemp check still matches the converted files ✓ Resolved
Resolving commit: 2cccd20
Resolution reason
The commit removes the stale mkdtempSync (and tmpdir where unused) imports from the eleven listed
sidecar test files, including recording-route.test.ts (line 6-8 hunk removing mkdtempSync and
tmpdir), agent-dir-config, agent-dir-integration, models-for-api-key, providers-discovery,
session-api-key, session-events-route, session-events-stream, session-store, tools-config, and
transcripts. This matches the suggested fix of removing unused mkdtempSync/tmpdir imports in each
listed file. Some other files were also cleaned up, and the helper temp-dirs.ts was modified, but
the finding's requested remediation is directly implemented.
Description
The eleven converted sidecar test files keep mkdtempSync in their node:fs import lines even
though every call now goes through makeTempDir, so grep mkdtemp still reports them. This is the
check the PR description and rule 2978989 use to prove that no unmanaged mkdtemp use remains, and
it currently returns the 11 test files in addition to the two helpers and subagent-tool.ts. The
stale imports also trip unused-import lint in these files and mislead a later reader into thinking
the tests still create directories themselves.
2. Parallel test runs can fail during setup ✓ Resolved
Resolving commit: 2cccd20
Resolution reason
Stopped removing the shared TEST_TMP_BASE in after(), so other processes can no longer lose the base
mid-setup; and added a retry around the TEST_RUN_ROOT mkdirSync so a transient ENOENT during
run-root creation is retried.
Description
after() removes the shared TEST_TMP_BASE while another test process can be between creating that
base and creating its run root. When those steps interleave, makeTempDir() can throw ENOENT,
causing an otherwise passing test to fail.


|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…iner
Two review findings on the sidecar conversion.
- The stale `mkdtempSync` imports defeated the repo-wide check this PR uses to prove that
nothing manages its own temp dirs: 66 occurrences across `tests/node` (left by #1045) and the
sidecar tree imported a name their code no longer calls, and unused-import lint tripped on
them. Removed, along with `tmpdir` where it became unused — `grep mkdtemp` outside the two
helpers is now 0.
- Removing the shared container raced a concurrent test process: `after()` deleted
`/tmp/pi-config-tests` while another file's process could be between creating the base and its
run root, so that `mkdir` failed with ENOENT. The container is no longer removed (it holds only
run roots), and `create()` retries once for the window where it does vanish.
Verified: node suite 3822 passed / 0 failed (two runs), sidecar suite 482 passed / 0 failed,
typecheck green.
Assisted-by: PI (rits/deepseek-ai/DeepSeek-V4.1-Flash-1017)
Signed-off-by: Meni Yakove <[email protected]>
|
/qodo
The following review comments were reviewed and a decision was made:
packages/pi-sidecar/tests/test_ts/recording-route.test.ts:10 (qodo finding) — Repo-wide mkdtemp check still matches the converted files
Addressed: Fixed in 2cccd20. Every stale mkdtempSync import is gone — 66 occurrences across the sidecar tree and tests/node (the node-suite ones were left by #1045), plus tmpdir where it became unused. grep -rn mkdtemp --include=*.test.ts tests/node packages/pi-sidecar/tests | grep -v helpers/temp-dirs now returns 0, so the repo-wide check the PR relies on is green, and unused-import lint no longer trips.
packages/pi-sidecar/tests/test_ts/helpers/temp-dirs.ts:86 (qodo finding) — Parallel test runs can fail during setup
Addressed: Fixed in 2cccd20. The shared container is no longer removed by a test process at all — after() deletes only this process's run root, because another file's process can be between creating /tmp/pi-config-tests and creating its run root, and the rmdir made that mkdir fail with ENOENT. create() also retries once for the window where the container does vanish (e.g. a manual cleanup), so a parallel run cannot fail in setup.
Assisted-by: PI (rits/deepseek-ai/DeepSeek-V4.1-Flash-1017)
|
qodo-code-review[bot] reacted with eyes emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
The following review comments were reviewed and a decision was made:
packages/pi-sidecar/tests/test_ts/recording-route.test.ts:10 (qodo finding) — Repo-wide mkdtemp check still matches the converted files
Addressed: Fixed in 2cccd20. Every stale mkdtempSync import is gone — 66 occurrences across the sidecar tree and tests/node (the node-suite ones were left by #1045), plus tmpdir where it became unused. grep -rn mkdtemp --include=*.test.ts tests/node packages/pi-sidecar/tests | grep -v helpers/temp-dirs now returns 0, so the repo-wide check the PR relies on is green, and unused-import lint no longer trips.
packages/pi-sidecar/tests/test_ts/helpers/temp-dirs.ts:86 (qodo finding) — Parallel test runs can fail during setup
Addressed: Fixed in 2cccd20. The shared container is no longer removed by a test process at all — after() deletes only this process's run root, because another file's process can be between creating /tmp/pi-config-tests and creating its run root, and the rmdir made that mkdir fail with ENOENT. create() also retries once for the window where the container does vanish (e.g. a manual cleanup), so a parallel run cannot fail in setup.
Assisted-by: PI (rits/deepseek-ai/DeepSeek-V4.1-Flash-1017)
Both findings are resolved in the current code, and I checked the two claims in the reply against the PR checkout.
finding 1 (stale mkdtemp imports): Searching packages/pi-sidecar/tests finds one mkdtempSync call, in helpers/temp-dirs.ts:29, which is the helper itself. The converted test files no longer contain it. I only searched the sidecar tests, not tests/node.
finding 2 (parallel-run setup failures): after() now removes only this process's run root, so the shared pi-config-tests base is no longer deleted under other processes. create() retries the mkdirSync of the run root once. That covers a single transient ENOENT, but not a repeated race, so the retry is a partial guard rather than a full fix.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Nov 7, 2026
|
New container for ghcr.io/myk-org/pi-config:latest published
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Nov 17, 2026
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
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.
|