Skip to content
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
ElbertePlinio merged 3 commits into
mainfrom
fix/237-storage-fallback
Jul 23, 2026
Merged

fix(storage): never fall back to launch-directory database#256
ElbertePlinio merged 3 commits into
mainfrom
fix/237-storage-fallback

Conversation

@ElbertePlinio

Copy link
Copy Markdown
Member

Summary

  • open_database() no longer falls back to a relative pickforge.db when pickforge_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 directory
  • PICKFORGE_HOME override preserved via the new injectable resolve_database_path seam
  • path-resolution tests for the override and no-home error path, plus a placement smoke proving nothing lands in the launch directory
  • test-only follow-up commit: one shared PICKFORGE_HOME env lock + RAII EnvRestore across the three tests touching that global (fixes a reproduced parallel-test flake), panic-safe restore

Closes #237. Deferred with rationale: pre-Builder fatal errors are invisible to packaged GUI users — filed as #255 (affects all three existing .expect sites; needs one shared mechanism).

Validation

  • focused tests + full cargo test --workspace --locked --all-targets green
  • flake proof: 25/25 full-suite runs clean (previously 14–20/25 failing on the branch); all three env-touching tests ok in every run
  • working tree clean after tests (placement smoke leaves no artifacts)

Local 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.

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.
@ElbertePlinio
ElbertePlinio merged commit 6f498f5 into main Jul 23, 2026
4 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(storage): never fall back to launch-directory database

1 participant