u/cascade: strict plan schema validation; clarify exit code contract
- Validate all entries have non-empty string id and instruction - No synthesis: exit 1 on worker failures (partial results) - Synthesis: exit 0 — planner accounts for failures in its answer
This commit is contained in:
parent
664b9e7f93
commit
9ca6b9de8a
|
|
@ -62,8 +62,8 @@ $task")
|
|||
|
||||
# Validate we got JSON with correct schema.
|
||||
printf '%s' "$plan" | jq empty 2>/dev/null || die "planner did not return valid JSON: $plan"
|
||||
printf '%s' "$plan" | jq -e '[.[] | select(.id and .instruction)] | length > 0' >/dev/null \
|
||||
|| die "plan missing required fields (need .id and .instruction per entry)"
|
||||
printf '%s' "$plan" | jq -e 'type=="array" and length>0 and all(.[]; (.id|type=="string" and length>0) and (.instruction|type=="string" and length>0))' >/dev/null \
|
||||
|| die "plan schema invalid (need array of {id: string, instruction: string})"
|
||||
|
||||
# Step 2: Spawn workers in parallel, collect session paths.
|
||||
count=$(printf '%s' "$plan" | jq 'length')
|
||||
|
|
@ -111,6 +111,9 @@ ${out}
|
|||
done
|
||||
|
||||
# Step 5: Synthesize or just print results.
|
||||
# Exit code contract:
|
||||
# No synthesis: exit 1 if any worker failed (caller must handle partial results).
|
||||
# Synthesis: exit 0 — the planner accounts for failures in its answer.
|
||||
if [ "$synthesize" -eq 0 ]; then
|
||||
printf '%s\n' "$results"
|
||||
[ "$failures" -gt 0 ] && exit 1
|
||||
|
|
@ -137,5 +140,4 @@ WORKER RESULTS:
|
|||
$results"
|
||||
fi
|
||||
"$B" "${synth_flags[@]}" "$synth_prompt"
|
||||
[ "$failures" -gt 0 ] && exit 1
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in New Issue