Skip to content

feat(cli): thread Config through the document cache - #204

Draft
ecalifornica wants to merge 1 commit into
robert/config-resumefrom
robert/config-cache
Draft

feat(cli): thread Config through the document cache#204
ecalifornica wants to merge 1 commit into
robert/config-resumefrom
robert/config-cache

Conversation

@ecalifornica

@ecalifornica ecalifornica commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Part of #184 (PR 11 of the plan there). Stacked on #203 (branch
robert/config-resume). The cleanup PR stacks on this one. path-cli only.

What

  • Every cache.rs function takes &Config as its first parameter and resolves
    the documents directory through Config::config_dir: cache_dir,
    cache_path, write_cached, cache_ref, list_cached, remove_cached.
  • make_id and pathbase_cache_id are pure string functions. They are
    unchanged.
  • cache.rs reads no environment variable.
  • Every call site passes the &Config it already holds. Three helper
    functions gain a &Config to carry it to the cache:
    • cmd_export::load_path_doc, plus build_gemini_conversation,
      build_pi_session, and build_codex_session.
    • query::run, query::stream_files, and query::select_files.
    • sync::engine::is_unchanged.
  • cmd_cache::run_ls takes the &Config that cmd_cache::run already
    receives.
  • The free config_dir() in config.rs had no caller left, so it is deleted
    along with the unit test that drove it. Config::config_dir is the only
    config-directory resolution in the crate.
  • p derive still loads a transitional Config and hands it to cmd_import.
    The cleanup PR owns that load.
  • Emscripten: cache.rs compiles on every target, and so does the &Config
    threading in cmd_cache; only pathbase_cache_id keeps its existing
    #[cfg(not(target_os = "emscripten"))] gate.

Behavior change

  • None. The cache directory is still $TOOLPATH_CONFIG_DIR/documents, falling
    back to ~/.toolpath/documents. The value is read once, in run().

Tests

  • 11 of the 13 cache.rs unit tests inject a Config rooted at a tempdir. The
    helper is config_in_tempdir, which returns the Config and its TempDir.
    The tests set no environment variable and take no TEST_ENV_LOCK, so they do
    not serialize against the rest of the suite. The 2 make_id tests need no
    Config.
  • query's select_files_input_only_skips_cache passes Config::default().
    That Config has no config directory, so it strengthens the assertion: an
    input-only scope that read the cache would error.
  • sync::engine's with_cfg keeps its $TOOLPATH_CONFIG_DIR write. The
    cleanup PR owns it.
  • The cmd_resume unit tests and the tests/resume.rs integration tests keep
    their $TOOLPATH_CONFIG_DIR scaffolding. The cleanup PR owns it.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Every `cache.rs` function takes `&Config` and resolves the documents
directory through `Config::config_dir`. The cache reads no environment
variable.

- `cache_dir`, `cache_path`, `write_cached`, `cache_ref`, `list_cached`,
  and `remove_cached` take `&Config` as their first parameter.
  `make_id` and `pathbase_cache_id` are pure and unchanged.
- Every call site passes the `&Config` it already holds. `cmd_export`'s
  `load_path_doc` and its three session builders take `&Config`;
  `query::run`, `stream_files`, and `select_files` take one;
  `sync::engine::is_unchanged` takes one.
- `p derive` still loads a transitional `Config` and hands it to
  `cmd_import`. The cleanup PR owns that load.
- The free `config_dir()` in `config.rs` had no caller left, so it is
  deleted along with the test that drove it.
- The `cache.rs` unit tests inject a `Config` rooted at a tempdir. They
  set no environment variable and take no `TEST_ENV_LOCK`.
@github-actions

Copy link
Copy Markdown

🔍 Preview deployed: https://8e21b149.toolpath.pages.dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant