Skip to content

Drop the hard jq dependency from gstack-gbrain-source-wireup - #2369

Open
benjaminberes-bp wants to merge 1 commit into
garrytan:mainfrom
benjaminberes-bp:fix/wireup-drop-jq
Open

Drop the hard jq dependency from gstack-gbrain-source-wireup#2369
benjaminberes-bp wants to merge 1 commit into
garrytan:mainfrom
benjaminberes-bp:fix/wireup-drop-jq

Conversation

@benjaminberes-bp

Copy link
Copy Markdown

check_source_state() shells out to jq and hard-fails without it:

gstack-gbrain-source-wireup: jq required for source state detection. Install jq (brew install jq) and re-run.
WARNING: gbrain wireup failed; run .../gstack-gbrain-source-wireup manually after fixing prereqs

Two separate problems.

The dependency is unnecessary

The comment justifying it is stale:

# jq is documented as a dependency of gstack-gbrain-detect (transitive)

gstack-gbrain-detect is TypeScript and no longer shells out to jq — its own
comments refer to "the bash version's jq -n" in the past tense. So jq had
become a hard dependency of this one code path, for exactly two identical
extractions:

jq -r --arg id "$id" '.sources[] | select(.id==$id) | .local_path'

bun is already a hard dependency of gstack — several bins carry a
#!/usr/bin/env bun shebang. Parsing the JSON with it removes a dependency
rather than documenting one.

The advice is not actionable

brew install jq does not apply on Windows/git-bash, where jq is absent by
default. The practical effect there is that the gbrain wireup is skipped on
every run, as a warning the run continues past. brain-restore carrying on
is the right call, but the breakage becomes routine and stops being read.

What is preserved

The loud-failure property adversarial review asked for. Without a JSON parser
we still cannot distinguish absent from missing-tool, and would falsely
re-add an existing source — so check_source_state still probes and still
dies. Only the tool it probes for changed, to one that is already required.

Verification

On Windows 11 / git-bash / bun 1.3.14:

  • --probe returns byte-identical output with jq present and with jq
    removed from PATH, where it previously died.
  • The bun extraction was checked against jq on real
    gbrain sources list --json output, plus the absent-id and invalid-JSON
    cases, which both yield "" as before.

Happy to keep a jq fast path if you would rather not add a bun call in a bash
bin — but given bun is already required, this seemed like the smaller surface.

check_source_state() shelled out to jq and hard-failed without it:

    jq required for source state detection. Install jq (brew install jq) and re-run.
    WARNING: gbrain wireup failed; run .../gstack-gbrain-source-wireup manually

Two separate problems.

The dependency itself was unnecessary. Its stated justification in the comment
-- "jq is documented as a dependency of gstack-gbrain-detect (transitive)" --
is stale: gstack-gbrain-detect is TypeScript and no longer shells out to jq, as
its own comments about "the bash version's jq" record. jq had become a hard
dependency of this one code path. Meanwhile bun already is a hard dependency of
gstack, several bins carrying a `#!/usr/bin/env bun` shebang, so parsing the two
identical `.sources[] | select(.id==$id) | .local_path` extractions with bun
removes a dependency instead of documenting one.

The advice was not actionable. `brew install jq` does not apply on
Windows/git-bash, where jq is absent by default. The practical effect there:
the gbrain wireup is skipped on every run, as a warning that the run continues
past. brain-restore carrying on is the right behaviour, but the breakage
becomes routine and therefore stops being read.

The loud-failure property that adversarial review asked for is kept -- without
a JSON parser we still cannot tell "absent" from "missing-tool" and would
falsely re-add an existing source, so check_source_state still probes and still
dies. Only the tool it probes for changed, to one that is already required.

Verified on Windows 11 / git-bash / bun 1.3.14: `--probe` returns identical
output with jq present and with jq removed from PATH, where it previously died.
The bun extraction was checked against jq on real `gbrain sources list --json`
output, plus the absent-id and invalid-JSON cases, which both yield "".

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@trunk-io

trunk-io Bot commented Jul 27, 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

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.

1 participant