Skip to content

Conversation

@ibro45
Copy link
Contributor

@ibro45 ibro45 commented Nov 19, 2025

Introduces a two-stage reference processing model that enables safer config composition workflows, particularly for config pruning scenarios.

Key Changes:

  • Raw references (%ref) now expand eagerly during update() instead of lazily during resolve()
  • New Preprocessor class handles raw reference expansion before Item creation
  • Enables safe deletion of config sections after copying their values
  • Refactored path pattern utilities from separate module into path_utils

Why this matters:

Previously, both @ref and %ref resolved lazily. This made patterns like "copy value then delete source" impossible:

system:
  lr: 0.001

model:
  optimizer:
    lr: "%system::lr"  # Copy raw value

~system: null  # Delete source

With lazy resolution, the reference would fail because system was deleted. Now % references expand immediately during update(), so deletion happens safely afterward.

Processing stages:

  1. Eager (during update()): % raw references expand and copy values
  2. Lazy (during resolve()): @ resolved references and $ expressions evaluate

This separation maintains backward compatibility while enabling advanced config composition patterns.

ibro45 and others added 6 commits November 17, 2025 13:41
- Move all regex patterns from path_patterns.py into path_utils.py
- Export PathPatterns class from path_utils for backward compatibility
- Update all imports across codebase to use path_utils
- Add comprehensive documentation for each regex pattern
- Add is_yaml_file() helper function

This consolidation improves code organization by keeping all path-related
utilities in a single module.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Implement two-stage processing model:
- Stage 1 (eager): Expand % raw references during update()
- Stage 2 (lazy): Resolve @ references during resolve()

This enables safe config composition and pruning workflows where raw
references are expanded before deletion operators are applied.

Key changes:
- Add process_raw_refs() method to Preprocessor for eager expansion
- Add _contains_raw_refs() optimization to skip unnecessary traversal
- Call process_raw_refs() in Config.update() before merging
- Comprehensive documentation of two-stage processing model

This fixes the Lighter use case where configs reference system sections
that are later pruned/deleted.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Update all examples from Config.load() to Config().update() pattern:
- README.md quick start example
- All examples in docs/user-guide/advanced.md
- All examples in docs/user-guide/expressions.md
- All examples in docs/user-guide/instantiation.md

This clarifies the two-step initialization and update process, making
the eager/lazy processing stages more explicit.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Add comprehensive tests for two-stage processing:
- test_eager_raw_reference_expansion: Verify % refs expand during update()
- test_pruning_with_raw_references: Test the Lighter use case
- Update import statements to use path_utils

These tests ensure that raw references are expanded before deletion
operators, enabling safe config composition and pruning workflows.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Fix ignoreLabels formatting in GitHub workflow (use block scalar)
- Update uv.lock after dependency changes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@codecov
Copy link

codecov bot commented Nov 19, 2025

Codecov Report

❌ Patch coverage is 90.00000% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/sparkwheel/preprocessor.py 82.75% 3 Missing and 2 partials ⚠️
src/sparkwheel/config.py 50.00% 2 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@ibro45 ibro45 changed the title Implement eager raw reference expansion feat: Implement eager raw reference expansion Nov 19, 2025
@ibro45 ibro45 merged commit 9ae5853 into main Nov 19, 2025
7 of 8 checks passed
@ibro45 ibro45 deleted the improve branch November 27, 2025 04:52
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