test.sh: refuse the cli suite against a real HOME - #1804
Conversation
The cli suite installs and uninstalls agent configurations for real. HOME
isolation is per-test — tests/test_cli.c calls cbm_setenv("HOME", ...) 58 times,
scripts/test.sh sets it none — so the suite acts on whatever HOME it inherits,
and its results outside isolation are unreliable: running it against a real HOME
produced different failure counts on consecutive runs, all in the agent-config
install/uninstall tests (OpenClaw, VS Code, Gemini, Augment, CodeBuddy/Pochi),
where the same tree under an isolated HOME reported a stable baseline.
test.sh now exits 2 when the cli suite is selected and $HOME contains .claude or
.claude.json, printing the isolated command to use. Default mode is covered too,
since it runs every suite. CBM_ALLOW_REAL_HOME=1 overrides for anyone who wants
the old behaviour.
|
Thanks for opening this — it has been seen, and it is queued. This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence. Current review status: working through a backlog. What that means for this PR, concretely:
Things that will genuinely speed it up whenever review does happen:
If this fixes a bug, a reproduction we can run is worth more than a description of the symptom. Thanks for contributing, and sorry in advance for the wait. |
|
Thank you for the careful framing here, especially for separating a confirmed isolation problem from damage you could not reproduce. I checked current I have labeled this as a high-priority security and maintainer-safety item. The exact policy still needs a maintainer direction decision before detailed review: hard refusal with an escape hatch versus making isolation unconditional at the runner boundary. The current DCO check is also red, so the commit will need a valid |
Why
The
clisuite installs and uninstalls agent configurations for real — it callscbm_cmd_installandcbm_cmd_uninstall, not mocks, across 53 call sites.HOMEisolation is per-test rather than global:tests/test_cli.ccallscbm_setenv("HOME", tmpdir, 1)58 separate times, andscripts/test.shsetsHOMEzero times. So the suite acts on whateverHOMEit inherits, and the safety of a run depends on every individual test remembering — including the ones that fail partway.The observable consequence is that results outside isolation are not trustworthy. Running the suite against a real
$HOMEon my machine gave different failure counts on consecutive runs, and the tests that moved were exactly the agent-config ones — OpenClaw, VS Code, Gemini, Augment, CodeBuddy/Pochi. The same tree underHOME=$(mktemp -d)was stable at the baseline every time.I am not claiming a specific test damages a real config — I tried to reproduce that and could not, twice, against increasingly faithful copies of the home directory in question. The argument here is narrower and I think uncontroversial: a suite that installs and uninstalls agent configurations should not be pointed at a developer's own one by default, and its results there are unreliable regardless.
What this does
scripts/test.shexits 2 when theclisuite is selected and$HOMEcontains.claudeor.claude.json, printing the isolated command to use. Default mode (no--suites) is covered too, since it runs every suite.CBM_ALLOW_REAL_HOME=1overrides for anyone who wants the current behaviour.CI is unaffected in the normal case: a runner whose
$HOMEhas no.claudenever trips it, and the override is available if yours does.Verified in this tree: refuses
--suites clion a real HOME with exit 2, permits--suites discoverthere, and permits--suites cliunder an isolated HOME.Happy to gate it differently — a warning instead of a refusal, or a different env var name — if you would rather.