test(resume): sandbox opencode by pinning XDG_DATA_HOME in ScopedHome#142
Open
bdelanghe wants to merge 1 commit into
Open
test(resume): sandbox opencode by pinning XDG_DATA_HOME in ScopedHome#142bdelanghe wants to merge 1 commit into
bdelanghe wants to merge 1 commit into
Conversation
The opencode `PathResolver` prefers `$XDG_DATA_HOME` over `$HOME` when locating `opencode.db`. `ScopedHome` only pinned `$HOME`, so on a machine that sets `$XDG_DATA_HOME` (common on Linux; set on this dev box) the opencode resume test escaped its sandbox: it seeded — and the projector wrote into — the *real* user database. The seed's `CREATE TABLE` then hit the already-populated real DB and failed with "table project already exists" (green in CI where XDG is unset, red locally), and a fresh-DB run would silently mutate the user's live opencode data. Pin `$XDG_DATA_HOME` to `<tempdir>/.local/share` in ScopedHome (restored on drop) so every harness — opencode included — stays sandboxed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
file_input_explicit_opencode_projects_and_records_execfails locally with:(green in CI, red on dev machines).
Root cause
The opencode
PathResolverprefers$XDG_DATA_HOMEover$HOMEwhen locatingopencode.db.ScopedHomeonly pinned$HOME, so on any machine that sets$XDG_DATA_HOME(common on Linux; set on this dev box) the test escaped its sandbox:opencode.db;CREATE TABLEthen hit the already-populated real DB and failed;CI passes only because
$XDG_DATA_HOMEis typically unset there, so the resolver falls back to the scoped$HOME.Fix
Pin
$XDG_DATA_HOMEto<tempdir>/.local/shareinScopedHome(saved + restored on drop), so every harness — opencode included — resolves inside the sandbox.Verification
cargo test -p path-cli --test resume→ all 12 pass, includingfile_input_explicit_opencode_*.Versioning
None — test-harness isolation only, no crate or public-API changes.
Stack (review bottom-up): #141 empty-seed projection fix → #142 opencode test isolation → #145
path resume --remote.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.