test: isolate user state across platforms - #1215
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 31, 2026, 7:54 PM ET / 23:54 UTC. ClawSweeper reviewWhat this changesThe branch adds a shared Go test helper that redirects user state and config directories into private temporary paths, applies it to affected CLI/provider tests, and expands native Windows CI coverage. Merge readinessKeep this PR open for maintainer merge review. Current Priority: P1 Review scores
Verification
How this fits togetherCrabbox Go tests exercise CLI and provider code that reads user configuration, state, and platform home directories. The new test utility redirects those inputs before tests create claims, credentials, or provider artifacts, so test execution no longer reaches persistent developer state. flowchart LR
A[Go CLI and provider tests] --> B[User-directory resolver]
B --> C[Shared test isolation helper]
C --> D[Private temporary home and state]
D --> E[Claim and config test files]
C --> F[Package-wide test setup]
F --> G[Native Windows CI]
E --> H[Hermetic test results]
Before merge
Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Merge the shared isolation helper and its targeted test/Windows-CI coverage so all affected packages keep user-state artifacts inside test-owned temporary directories. Do we have a high-confidence way to reproduce the issue? Yes—source inspection confirms current main falls back to OS user configuration directories, and the PR body provides a controlled before/after CLI reproduction plus native Windows CI evidence. Is this the best way to solve the issue? Yes—the shared helper covers the actual resolver inputs across supported platforms and package-wide setup protects tests that do not install per-test isolation themselves. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f793138a161e. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
Summary
testutil.IsolateUserDirshelper that redirects state, config, home, AppData, and local AppData into a private per-test tree on every supported OSThe helper asserts that
os.UserConfigDir()remains inside the test root and creates every synthetic user directory with private permissions. Package-wide isolation preserves the original Go build and module cache locations so nested CLI builds do not redownload dependencies.Thanks to @paulcam206 for the detailed reports and cross-platform reproduction work.
Reproduction and proof
On unmodified
main, running one reported CLI test with a controlled fallback home passed but left this persistent lock behind:The same controlled-fallback check on this branch leaves no Crabbox path behind:
Verification
The full local parallel race command was also attempted, but this machine had only 2.9 GiB free and parallel linking stopped with
no space left on device; the identical suite passed with-p 1. The hosted Go job passed the exactgo test -race ./...command at https://github.com/openclaw/crabbox/actions/runs/30673261639/job/91295228438.Native Windows execution passed in the expanded existing Windows CI job at https://github.com/openclaw/crabbox/actions/runs/30673261639/job/91295228445. That job exercised the shared helper plus AWS, Daytona, DigitalOcean, Hyper-V, Namespace, Scaleway, Vast, and Vultr before rerunning the existing Pond Mesh cancellation proof. Locally, the Windows implementation was checked against Go's documented
os.UserConfigDirbehavior:%AppData%is redirected viaAPPDATA, whileUSERPROFILEandLOCALAPPDATAcover the other standard-library user-directory resolvers.Closes #1212
Closes #1213