Fixed on branch test-suite-debt (35a97d09), CI green on the tip ce7b9441, Astra review running, not merged. This covers #226 too.
Cause. useTempCredentials pins HOME to one t.TempDir() and chdirs to another. Config discovery walks up from the working directory by path, so with TMPDIR under a logged-in home it reaches the real ~/.carlos/config whatever HOME says.
Fix. A guard in the root package's TestMain (isolateTempRoot). Before any test runs it checks every ancestor of os.TempDir() for a .carlos/config:
- none above (every CI run): nothing changes;
- one above: it moves TMPDIR to a fresh
/var/tmp/carlos-test-*for the binary and its children, and removes it at exit; - no clear base writable: the binary exits 1 and says why, rather than run against the real config.
Neither fix suggested here would have worked alone: the scratch cwd is a sibling of the pinned HOME, not under it, so stopping the walk at HOME changes nothing (and would change behaviour for real users); pinning CARLOS_CONFIG breaks the tests that write their own config.
Measured, TMPDIR under $HOME on a logged-in machine. Before: TestResolveModeNonTTYErrorsUnchanged and TestConfigDefaultWalk fail, the *VerbAPIMode tests abort the binary. After: the 37 tests on this thread's list pass, TestResolveModeExpiredOffersRelogin passes in 2s, and the whole root package passes in 440s with no non-loopback connection seen.
Limits. A test that leaves its cwd in the checkout and runs discovery without CARLOS_CONFIG would still leak; none does today. If the binary dies by log.Fatal or a timeout, its /var/tmp/carlos-test-* directory is left behind (the path is printed).