Skip to content

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

Open
0xDevNinja wants to merge 2 commits into
garrytan:mainfrom
0xDevNinja:fix/2018-autoplan-jq-commit-filter
Open

fix(autoplan): bind commit before split-array index in tasks aggregator (#2018)#2021
0xDevNinja wants to merge 2 commits into
garrytan:mainfrom
0xDevNinja:fix/2018-autoplan-jq-commit-filter

Conversation

@0xDevNinja

Copy link
Copy Markdown
Contributor

Problem

/autoplan's Phase 4 implementation-tasks aggregator returned zero tasks on every run, even when valid per-phase tasks-<phase>-*.jsonl records existed for the current branch and recent commits. Users saw No actionable tasks emitted from any phase with no diagnostic.

Root cause

The branch+commit filter was:

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

Inside ($commits | split("|") | ...) the pipe's input is the split array, so index(.commit) tried to index that array with the string "commit":

jq: error (at <stdin>:1): Cannot index array with string "commit"

The surrounding jq ... >> "$ALL_JSONL" swallowed the error via 2>/dev/null, so the aggregator silently dropped every record. Repro'd on v1.58.1.0 (also affects v1.52.2.0).

Fix

Bind the record's .commit to a variable before entering the split-array pipe, so index() receives the commit string:

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

One-line change in the source resolver (scripts/resolvers/tasks-section.ts), autoplan/SKILL.md regenerated via bun run gen:skill-docs. Added a short comment so the binding isn't "simplified" back into the bug later.

Tests

New free regression test test/autoplan-tasks-aggregator.test.ts extracts the shipped select(...) filter from autoplan/SKILL.md and runs it through jq:

  • matching branch+commit → kept, no jq error
  • non-matching commit → excluded, no error
  • wrong branch → excluded, no error
  • record missing commit field → excluded, no error
  • asserts the filter no longer contains the bare index(.commit) form

5/5 pass. Full free suite green (bun test gen-skill-docs + skill-validation: 734 pass), gen-skill-docs freshness check clean.

Fixes #2018.

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 garrytan#2018.
…lter

Extracts the shipped select filter from autoplan/SKILL.md and runs it
through jq over sample records: matching branch+commit is kept, a
non-matching commit / wrong branch / missing commit field are excluded
without a jq error. Pins the garrytan#2018 fix and fails on the bare
index(.commit) form (which errors).

Refs garrytan#2018.
@trunk-io

trunk-io Bot commented Jun 16, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

time-attack pushed a commit to time-attack/gstack that referenced this pull request Jul 14, 2026
@time-attack

Copy link
Copy Markdown
Contributor

@16francej ensures commits are real and dont get split can merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/autoplan aggregator silently returns 0 tasks: jq scope bug in commit filter

2 participants