test(resume): pin XDG_DATA_HOME in ScopedHome to sandbox opencode - #253
Open
bdelanghe wants to merge 1 commit into
Open
test(resume): pin XDG_DATA_HOME in ScopedHome to sandbox opencode#253bdelanghe 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>
|
🔍 Preview deployed: https://16c1cf45.toolpath.pages.dev |
bdelanghe
marked this pull request as ready for review
September 1, 2026 18:37
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.
ScopedHomepins$HOMEand$TOOLPATH_CONFIG_DIR, which sandboxes every reader that derives its paths from$HOME. The opencodePathResolverdoes not: it prefers$XDG_DATA_HOMEwhen locatingopencode.db.On a machine that sets
$XDG_DATA_HOME— common on Linux, and set on this dev box — the projector goes to the real user database. The test fails withtable … already exists, and, worse, mutates live opencode data on the way.Pinning it alongside the other two keeps every harness inside the sandbox.
Verified
file_input_explicit_opencode_projects_and_records_exec, with$XDG_DATA_HOMEexported:Provenance
This is the commit from #142, which was closed unmerged when the
bdelanghe/toolpathfork was retired. The work was preserved beforehand as tagarchive/fork/fix-opencode-test-xdg-isolation; this branch is that commit cherry-picked onto current main, unchanged apart from the rebase.Relationship to #251
Both touch
crates/path-cli/tests/support/mod.rs, and both close the same class of hole — an env var that outranks the sandboxed$HOME. They are independent fixes for different variables and different readers, so they are separate PRs; whichever lands second will want a trivial rebase, as they add adjacent fields toScopedHome.Together they take
cargo test --workspaceon a developer machine from 29 failures to 0. Neither is visible in CI, which sets neither variable.$XDG_DATA_HOMEescaping the test sandbox. Test-support code only.cargo test -p path-cli --test resume10/10 with the fix, 9/10 without it on the same box and the same shell;cargo fmt --all --checkcleanPathResolverprefers$XDG_DATA_HOMEover$HOME;ScopedHomepinned only the latter, so an exported value escaped the sandbox and reached the realopencode.dbScopedHomefor$HOMEand$TOOLPATH_CONFIG_DIRrather than adding a parallel mechanism$CLAUDE_CONFIG_DIRescape is test(cli): the sandbox holds when CLAUDE_CONFIG_DIR is set #251; the clippy sweep is chore(clippy): the lints newer toolchains enforce #252Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.