test: isolate user state across platforms - #1215
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 2, 2026, 1:09 AM ET / 05:09 UTC. ClawSweeper reviewWhat this changesThis PR adds a shared cross-platform Go-test user-directory isolation helper, applies it to affected CLI and provider tests, and expands the existing Windows CI job to exercise the isolation path natively. Merge readinessKeep open: current Likely related people: Priority: P1 Review scores
Verification
How this fits togetherCrabbox CLI and provider tests create claims, keys, and configuration through the same user-directory resolvers used by the product. Test setup must redirect those state and config paths into temporary directories so tests cannot read, modify, or collide with a developer's persistent local Crabbox state. flowchart TD
A[Go CLI and provider tests] --> B[Shared test user-directory isolation]
B --> C[Home AppData and XDG overrides]
C --> D[State and config directory resolution]
D --> E[Private per-test directories]
B --> F[Package safety nets]
F --> G[Native Windows CI coverage]
Before merge
Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Merge the shared isolation helper and its focused Windows coverage so test-created state and configuration remain inside test-owned directories across supported platforms. Do we have a high-confidence way to reproduce the issue? Yes. The linked reports and the PR body provide a controlled current-main reproduction that leaves a Crabbox lock under a fallback home directory; the reported Windows path is also covered by native CI proof. Is this the best way to solve the issue? Yes. A shared helper that redirects both XDG and Windows user-directory inputs, backed by targeted tests and package-wide guards where broad coverage is needed, is the narrowest maintainable fix for this cross-platform test isolation defect. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0171ae2ee19f. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
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