Skip to content

refactor(config): split compaction settings and share XDG app directories - #253

Merged
hakula139 merged 1 commit into
mainfrom
refactor/config-conventions
Oct 16, 2026
Merged

hakula139 merged 1 commit into
mainfrom
refactor/config-conventions

Conversation

@hakula139

Copy link
Copy Markdown
Owner

Summary

config.rs grouped the config snapshot, thinking request types, compaction threshold math, display formatters, and URL validation in one long helper section. Five modules also paired an XDG variable with its $HOME fallback and declared their own "ox" directory. This moves each concern next to its owner and centralizes all XDG lookups in one helper. Behavior is unchanged.

  • Compaction module: config/compaction.rs now owns CompactionConfig, AutoCompactionConfig, the threshold policy and percent types, their resolution from env and files, the threshold math, and test_thresholds. resolve_auto_threshold takes the env token and percent values as separate named arguments. Unit tests now check the threshold clamps directly against resolve_policy, and the test-only constructor is limited to the enabled-threshold case used by every caller. Callers import these items from config::compaction.
  • Thinking types: ThinkingConfig, ThinkingDisplay, and BlockBinding move to model.rs. Since ModelSpec::thinking is their only constructor and the model catalogue already owns per-model request capabilities, the client imports them from model.
  • config.rs layout: The Helpers section is split into Resolution, Env Overrides, Base URL, and Display sections. Resolution helpers follow the order in which Config::load calls them. The config code now imports permission::{Mode, Policy}, util::env, and the test CA bundle instead of spelling them inline.
  • config.rs tests: A load_with(&dir, overrides) helper replaces the repeated temp_env and Config::load setup in most load tests. Tests that unset a variable or load interactively still construct the environment by hand. The Config::load test sections now follow the order in which settings resolve, with new sections for status line and compaction.
  • OAuth store: The private keychain-or-file enum is now named Backend, avoiding a name conflict with provenance::Source. Store already names the login-location struct, which now also handles the old credentials_path lookup. Test names now state their outcomes, the test for missing claudeAiOauth asserts the error text, and the parse tests use the shared credential fixture.
  • XDG directories: util::path gains XdgBase { Config, Data, State } and app_dir(base), centralizing the variable names, the spec defaults under $HOME, and the single "ox" directory name. Config loading, the log file, the permission gate's protected app directories, session storage, the device id, and OAuth login now resolve through them.

Test plan

  • cargo fmt --all --check
  • cargo build
  • cargo clippy --all-targets -- -D warnings
  • cargo test
  • cargo llvm-cov, with every changed line covered
  • pnpm format, pnpm lint, and pnpm spellcheck
  • app_dir returning None without a home directory has no unit test because std::env::home_dir falls back to the passwd entry on Unix
  • Linux-only and Windows-only test paths are verified only by CI

@hakula139 hakula139 added this to the v0.1.0 milestone Oct 16, 2026
@hakula139 hakula139 added refactor Restructured code that preserves behavior (refactor) area: config Touches config loading, layering, or credential discovery labels Oct 16, 2026
@hakula139 hakula139 self-assigned this Oct 16, 2026
@codecov

codecov Bot commented Oct 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…ries

config.rs held the snapshot, the thinking request types, compaction
threshold math, display formatters, and URL validation under one long
helper section, and five modules paired each XDG variable with its
$HOME fallback by hand. Behavior is unchanged.

- Move the compaction types, their resolution, and the threshold math
  into config/compaction.rs, and test the threshold math directly.
- Move ThinkingConfig, ThinkingDisplay, and BlockBinding to model.rs,
  since ModelSpec::thinking is their only constructor.
- Split the config.rs helpers into resolution, env, base URL, and
  display sections, add a load_with test helper, and order the
  Config::load test sections by call order.
- Rename the OAuth keychain-or-file enum to Backend, since Store already
  names the login-location struct, and state outcomes in its test names.
- Add util::path::XdgBase and app_dir, which every config, data, and
  state lookup now uses, with one "ox" directory constant.
@hakula139
hakula139 force-pushed the refactor/config-conventions branch from d3b3581 to b3b6e41 Compare October 16, 2026 09:07
@hakula139
hakula139 merged commit 7430083 into main Oct 16, 2026
10 checks passed
@hakula139
hakula139 deleted the refactor/config-conventions branch October 16, 2026 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: config Touches config loading, layering, or credential discovery refactor Restructured code that preserves behavior (refactor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant