From 9ca6b9de8a36240dfeb397a4d2c1363624f2f383 Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Sun, 17 May 2026 13:27:56 +0200 Subject: [PATCH] u/cascade: strict plan schema validation; clarify exit code contract MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- scripts/u/cascade | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/u/cascade b/scripts/u/cascade index 2d61687..c4b1e11 100755 --- a/scripts/u/cascade +++ b/scripts/u/cascade @@ -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