Skip to content

Add repository configuration management with YAML parsing and caching#73

Open
Ziinc wants to merge 1 commit into
mainfrom
claude/repo-yaml-config-vtopd6
Open

Add repository configuration management with YAML parsing and caching#73
Ziinc wants to merge 1 commit into
mainfrom
claude/repo-yaml-config-vtopd6

Conversation

@Ziinc

@Ziinc Ziinc commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR introduces a repository configuration system that allows projects to define settings via a .treq/config.yaml file. The configuration is parsed, cached in the local SQLite database, and exposed through Tauri commands for the frontend to consume.

Key Changes

  • New repo_config module (src-tauri/src/repo_config.rs):
    • Defines RepoConfig struct with optional fields: branch_name_pattern, default_model, default_agent, target_branch, and included_copy_files
    • Implements load_and_cache() to read .treq/config.yaml, parse it with serde_yaml, and cache to the local DB
    • Implements get_cached() to retrieve previously cached configuration without re-reading the file
    • Includes comprehensive test coverage for parsing, caching, and partial configurations
  • Database layer enhancements (src-tauri/src/local_db.rs):
    • Added repo_config_cache table to store configuration key-value pairs with timestamps
    • Implemented cache_repo_config() to store individual config fields, replacing stale entries
    • Implemented get_cached_repo_config() to reconstruct the config from cached rows
    • Added clear_db_cache_for_testing() helper for test isolation
    • Includes tests verifying table creation, caching behavior, and stale data cleanup
  • Tauri command layer (src-tauri/src/commands/repo_config.rs):
    • Exposed load_repo_yaml_config() command to load and cache config from YAML
    • Exposed get_cached_repo_config() command to retrieve cached config without file I/O
  • Module integration:
    • Registered new repo_config module in lib.rs
    • Added repo_config command module to commands/mod.rs
    • Added serde_yaml dependency to Cargo.toml

Implementation Details

  • Configuration fields are stored individually in the database, allowing selective queries without full deserialization
  • None fields are explicitly deleted from the cache to prevent stale data from persisting across reloads
  • The system gracefully handles missing .treq/config.yaml files by returning a default all-None configuration
  • Comprehensive test suite covers edge cases including partial configs, cache updates, and round-trip serialization
    https://claude.ai/code/session_01FuRgGXaZYdL4z1bEVVpc5z

Reads `.treq/config.yaml` at the repository root, parses it, and caches
each field as an individual key-value row in a new `repo_config_cache`
table in the per-repo local SQLite DB (`.treq/local.db`). If the file is
absent, an all-None default is cached, which also clears any stale entries
from a prior run.

Exposes two Tauri commands:
- `load_repo_yaml_config(repo_path)` — parse YAML → cache → return config
- `get_cached_repo_config(repo_path)` — return previously cached config

Supported YAML fields: `branch_name_pattern`, `default_model`,
`default_agent`, `target_branch`, `included_copy_files`.

Tests written first (TDD): 14 unit tests covering parse, cache, round-trip,
partial config, update-on-reload, and default-when-absent scenarios.
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.

2 participants