fix(autoplan): bind commit before split-array index in tasks aggregator

The Phase 4 implementation-tasks aggregator filtered per-phase JSONL by
branch and recent commit with:

  select(.branch == $branch and ($commits | split("|") | index(.commit) != null))

Inside the ($commits | split("|") | ...) pipe the input is the split
array, so index(.commit) tried to index an array with the string
"commit" and jq errored with "Cannot index array with string". The
surrounding invocation swallowed it via 2>/dev/null, so every run
silently dropped all records and reported no actionable tasks even when
valid task records existed for the current branch and commits.

Bind the record's commit to $c before entering the split-array pipe so
index() receives the commit string and the membership test works.

Fixes #2018.
This commit is contained in:
0xDevNinja 2026-06-16 12:16:34 +05:30
parent c7ae63201a
commit 1948e54e88
2 changed files with 8 additions and 2 deletions

View File

@ -1637,8 +1637,11 @@ 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.)
# Bind the record's .commit to $c BEFORE entering the split-array pipe —
# inside ($commits | split("|") | ...) the input is the array, so a bare
# index(.commit) would index the array with the string "commit" and error.
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,11 @@ 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.)
# Bind the record's .commit to \$c BEFORE entering the split-array pipe
# inside (\$commits | split("|") | ...) the input is the array, so a bare
# index(.commit) would index the array with the string "commit" and error.
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