fix(autoplan): task aggregator returned zero tasks on every run — jq scope bug

Inside ($commits | split("|") | ...) the "." context is the split ARRAY, so
the filter's bare .commit raised "Cannot index array with string" on every
record — and the 2>/dev/null swallowed it, so aggregation silently produced
zero tasks no matter how many the reviews emitted. Bind .commit to $c before
the pipe. Reproduced live before the fix; regenerated autoplan/SKILL.md.

Fixes #2018.

Contributed by @kkroo (PR #2416; regenerated against the current template).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Garry Tan 2026-08-14 18:59:45 -07:00
parent 7847fcf9ba
commit 4f891303f2
No known key found for this signature in database
GPG Key ID: C1F69E85C74EFE1D
2 changed files with 10 additions and 2 deletions

View File

@ -1668,8 +1668,12 @@ if command -v jq >/dev/null 2>&1; then
# Filter to current branch + recent commits, then keep records for the
# latest run_id only. (Single phase may have multiple files if the user
# re-ran the review; aggregator takes the newest.)
# NOTE: bind .commit BEFORE the split pipe. Inside ($commits | split(...))
# the "." context is the resulting ARRAY, so a bare .commit there raises
# "Cannot index array with string" on every record — and the 2>/dev/null
# below swallows it, so the whole aggregation silently yields zero tasks.
jq -c --arg branch "$BRANCH" --arg commits "$COMMITS_RECENT" \
'select(.branch == $branch and ($commits | split("|") | index(.commit) != null))' \
'select(.branch == $branch and ((.commit) as $c | ($commits | split("|") | index($c)) != null))' \
"$f" 2>/dev/null >> "$ALL_JSONL" || true
done < <(find "$TASKS_DIR" -maxdepth 1 -name "tasks-$phase-*.jsonl" 2>/dev/null | sort)
# Reduce to latest run_id per phase

View File

@ -118,8 +118,12 @@ if command -v jq >/dev/null 2>&1; then
# Filter to current branch + recent commits, then keep records for the
# latest run_id only. (Single phase may have multiple files if the user
# re-ran the review; aggregator takes the newest.)
# NOTE: bind .commit BEFORE the split pipe. Inside ($commits | split(...))
# the "." context is the resulting ARRAY, so a bare .commit there raises
# "Cannot index array with string" on every record and the 2>/dev/null
# below swallows it, so the whole aggregation silently yields zero tasks.
jq -c --arg branch "$BRANCH" --arg commits "$COMMITS_RECENT" \\
'select(.branch == $branch and ($commits | split("|") | index(.commit) != null))' \\
'select(.branch == $branch and ((.commit) as $c | ($commits | split("|") | index($c)) != null))' \\
"$f" 2>/dev/null >> "$ALL_JSONL" || true
done < <(find "$TASKS_DIR" -maxdepth 1 -name "tasks-$phase-*.jsonl" 2>/dev/null | sort)
# Reduce to latest run_id per phase