Fix SOURCE node resolution for user inputs in execute_recipe

- SOURCE nodes with :input true now resolve CID from input_hashes
- Tries multiple name formats: exact, lowercase-dashes, lowercase-underscores
- Only return "completed" status for runs with actual output
- Add integration tests for SOURCE CID resolution

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gilesb
2026-01-13 01:36:48 +00:00
parent bf188f4671
commit d08fbfc0bd
3 changed files with 286 additions and 14 deletions

View File

@@ -734,6 +734,26 @@ def execute_recipe(self, recipe_sexp: str, input_hashes: Dict[str, str], run_id:
# Handle SOURCE nodes
if step.node_type == "SOURCE":
source_cid = step.config.get("cid")
# If source has :input true, resolve CID from input_hashes
if not source_cid and step.config.get("input"):
source_name = step.config.get("name", "")
# Try various key formats for lookup
name_variants = [
source_name,
source_name.lower().replace(" ", "-"),
source_name.lower().replace(" ", "_"),
source_name.lower(),
]
for variant in name_variants:
if variant in input_hashes:
source_cid = input_hashes[variant]
logger.info(f"Resolved SOURCE '{source_name}' -> {source_cid[:16]}... via '{variant}'")
break
if not source_cid:
raise ValueError(f"SOURCE '{source_name}' not found in input_hashes. Available: {list(input_hashes.keys())}")
if source_cid:
source_path = cache_manager.get_by_cid(source_cid)
if source_path:
@@ -747,7 +767,9 @@ def execute_recipe(self, recipe_sexp: str, input_hashes: Dict[str, str], run_id:
total_cached += 1
continue
else:
raise ValueError(f"Source content not found: {source_cid}")
raise ValueError(f"Source content not found in cache: {source_cid[:16]}...")
else:
raise ValueError(f"SOURCE step has no cid and no :input flag: {step.config}")
# Get executor for this step type
executor = get_executor(step.node_type)