Commit 1e634ff
committed
Fix positional argument interpolation with functional refactoring
ROOT CAUSE: InterpolationEngine regex did not support positional parameters like $1, $2.
The pattern only matched $VAR where VAR starts with letter/underscore, not digits.
SOLUTION:
1. Created pure function module (env_interpolation.rs) with:
- build_positional_args_context: Builds interpolation context from args
- interpolate_env_value: Pure function for single value interpolation
- interpolate_workflow_env_with_positional_args: Interpolates all env vars
- positional_args_as_env_vars: Converts args to ARG_1, ARG_2, etc.
- env_values_to_plain_map: Converts EnvValue map to plain strings
2. Added comprehensive unit tests covering:
- Empty args, single arg, multiple args
- Simple references ($1), braced references (${ARG_1})
- Embedded references ("content/blog/$1")
- Multiple references ("cp $1 $2")
- Full workflow integration test
3. Fixed InterpolationEngine regex pattern:
- Changed: r"\$\\{([^}]+)\\}|\$([A-Za-z_][A-Za-z0-9_]*)"
- To: r"\$\\{([^}]+)\\}|\$([A-Za-z_][A-Za-z0-9_]*|\\d+)"
- Now supports: ${VAR}, $VAR, $1, $2, etc.
4. Refactored execution_pipeline.rs to use pure functions:
- Removed inline implementation
- Now uses testable, composable pure functions
- Improved code organization and maintainability
BENEFITS:
- Pure functions enable isolated unit testing
- Easy to identify bugs without running full workflows
- Functional composition improves code clarity
- Tests document expected behavior
- Reduces complexity in execution pipeline
VERIFICATION:
- All 15 unit tests pass
- Workflow now correctly interpolates BLOG_POST: "$1"
- Directory created: rethinking-code-quality-analysis (not .md)
- Commands execute with correct file paths1 parent 025cac7 commit 1e634ff
File tree
5 files changed
+397
-62
lines changed- src/cook
- execution
- mapreduce
- coordination
- orchestrator
5 files changed
+397
-62
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
35 | 37 | | |
36 | | - | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
490 | 490 | | |
491 | 491 | | |
492 | 492 | | |
| 493 | + | |
| 494 | + | |
493 | 495 | | |
| 496 | + | |
494 | 497 | | |
495 | 498 | | |
496 | 499 | | |
| |||
0 commit comments