This repository was archived by the owner on Sep 4, 2026. It is now read-only.
fix(storage): never fall back to launch-directory database - #256
Merged
Conversation
open_database() silently wrote pickforge.db(-shm/-wal) into the process launch directory whenever pickforge_home(None) failed, violating the workspace rule that a launch directory must never become the app's data directory. Fail startup with an actionable error instead, and keep the PICKFORGE_HOME override working. Closes #237
Three tests across lib.rs, telemetry_commands.rs, and project_roots.rs each read or mutate the process-global PICKFORGE_HOME env var. lib.rs and telemetry_commands.rs guarded it with their own independent mutexes, letting them race each other and flake ~14-20/25 runs; the project_roots.rs test read it with no lock at all. Move the lock and the EnvRestore RAII guard into a shared test_support module all three tests acquire, and make the new open_database test restore the prior env var via EnvRestore so it also runs on panic, not just the happy path.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
open_database()no longer falls back to a relativepickforge.dbwhenpickforge_home(None)fails — startup fails fast with an actionable error instead, honoring the workspace rule that a launch directory must never silently become the data directoryPICKFORGE_HOMEoverride preserved via the new injectableresolve_database_pathseamPICKFORGE_HOMEenv lock + RAIIEnvRestoreacross the three tests touching that global (fixes a reproduced parallel-test flake), panic-safe restoreCloses #237. Deferred with rationale: pre-Builder fatal errors are invisible to packaged GUI users — filed as #255 (affects all three existing
.expectsites; needs one shared mechanism).Validation
cargo test --workspace --locked --all-targetsgreenLocal review: standard risk class — one independent correctness/conformance reviewer; its P1 (env-lock split-brain) and P2 (panic-safe restore) fixed and empirically verified, P2 (GUI-visible startup errors) deferred as #255.