Skip to content

refactor(config-reader): cache base path resolution#3038

Merged
laststylebender14 merged 4 commits intomainfrom
chore/config-reader-base-path-cache
Apr 16, 2026
Merged

refactor(config-reader): cache base path resolution#3038
laststylebender14 merged 4 commits intomainfrom
chore/config-reader-base-path-cache

Conversation

@amitksingh1490
Copy link
Copy Markdown
Contributor

Summary

Stabilize Forge config path behavior so the process uses a single consistent base directory decision for the full runtime.

Context

Config path selection influences where Forge reads and writes user settings. Recomputing that decision repeatedly in one process can introduce unnecessary variability and make behavior harder to reason about when environment state changes between calls. This change makes path resolution deterministic for the process lifetime while preserving current legacy/default fallback semantics.

Changes

  • Cache the resolved config base path once per process and return that cached value from base_path().
  • Keep resolver logic in a dedicated function so tests can continue validating path precedence behavior directly.
  • Update base-path tests to assert resolver behavior explicitly.

Testing

  • cargo build -p forge_main
  • FORGE_LOG=debug ./target/debug/forge
  • FORGE_LOG=debug ./target/debug/forge
  • cargo +nightly fmt --all && cargo +nightly clippy --all-features --workspace --all-targets --fix --allow-dirty -- -D warnings

Co-Authored-By: ForgeCode <noreply@forgecode.dev>
@github-actions github-actions bot added the type: refactor Code refactoring and restructuring. label Apr 16, 2026
@laststylebender14 laststylebender14 merged commit 445f876 into main Apr 16, 2026
8 checks passed
@laststylebender14 laststylebender14 deleted the chore/config-reader-base-path-cache branch April 16, 2026 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: refactor Code refactoring and restructuring.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants