Skip to content

Extend cache hashing to cover config file and template file contents#284

Merged
szmyty merged 3 commits into
mainfrom
copilot/implement-file-based-caching
Apr 11, 2026
Merged

Extend cache hashing to cover config file and template file contents#284
szmyty merged 3 commits into
mainfrom
copilot/implement-file-based-caching

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 11, 2026

The transform and output caches only hashed input file content and variable values — changes to the config file structure or template files were invisible to the cache, causing stale outputs to be served.

Changes

src/cache.rs

  • compute_input_hash: Added config_content: &str parameter — raw config YAML bytes are now mixed into the transform cache key, so any config change (not just variables) triggers a cache miss
  • compute_output_hash: Added template_content: Option<&str> parameter — actual template file bytes are now part of the output hash, so editing a template invalidates its cached render even when the path is unchanged

src/commands/build.rs

  • Reads raw config file content at hash time (post-parse) and passes it to compute_input_hash
  • Reads each output's template file content before calling compute_output_hash; logs a WARN if the file is unreadable so cache degradation is visible
// Before — only input content + variables
let base_input_hash = compute_input_hash(&normalized_content, &config.variables);
let output_hash = compute_output_hash(&transformed, &format_str, output.template.as_deref());

// After — config content and template bytes included
let base_input_hash = compute_input_hash(&normalized_content, &config_content, &config.variables);
let output_hash = compute_output_hash(&transformed, &format_str, output.template.as_deref(), template_content.as_deref());

Tests

  • All existing callers updated for new signatures ("" / None for the new params preserves prior behavior)
  • New unit tests: test_different_config_content_produces_different_hash, test_output_hash_different_template_content_differs, test_cache_miss_when_config_changed

Copilot AI and others added 2 commits April 11, 2026 01:08
- Include config file content in compute_input_hash so any config
  change invalidates the transform cache
- Include template file content in compute_output_hash so template
  edits invalidate the output cache without path changes
- Update build.rs to read config content at hash time and read
  template content for each output before hashing
- Update all tests for new function signatures
- Add tests: config change causes cache miss, template content
  changes output hash

Agent-Logs-Url: https://github.com/egohygiene/renderflow/sessions/91f3fa04-4c19-43d0-b904-51e96f343594

Co-authored-by: szmyty <14865041+szmyty@users.noreply.github.com>
Copilot AI changed the title [WIP] Add file-based caching for input, config, and templates Extend cache hashing to cover config file and template file contents Apr 11, 2026
Copilot AI requested a review from szmyty April 11, 2026 01:13
@szmyty szmyty marked this pull request as ready for review April 11, 2026 01:38
@szmyty szmyty merged commit f0c7c13 into main Apr 11, 2026
@devactivity-app
Copy link
Copy Markdown

Pull Request Summary by devActivity

Metrics

Cycle Time: 36m Coding Time: < 1 min Pickup Time: 25m Review Time: < 1 min

Achievements

@szmyty szmyty deleted the copilot/implement-file-based-caching branch April 11, 2026 01:38
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.

♻️ Implement file-based caching for input, config, and templates

2 participants