Skip to content

test: verify gojq parity for all 27 queries#188

Merged
jakebromberg merged 3 commits into
mainfrom
verify/gojq-compat
May 30, 2026
Merged

test: verify gojq parity for all 27 queries#188
jakebromberg merged 3 commits into
mainfrom
verify/gojq-compat

Conversation

@jakebromberg

Copy link
Copy Markdown
Owner

Summary

  • Adds pipeline/queries/_tests/test_gojq_parity.sh, a parity test that runs every runnable query under both gojq and system jq against the curated fixtures and verifies semantic equivalence (canonical-form JSONL + byte-identical text).
  • Verifies the engine choice from ADR-0005: 54/54 invocations pass — no queries need #! engine: jq annotation, gojq is safe as the binary's default engine.
  • Wires the script into CI: gojq install step (pinned 0.12.19 Linux binary) + parity-test step + shellcheck entry.

Unblocks PR 3 (binary skeleton) in the audit-binary tracker (#177).

Test plan

  • pipeline/queries/_tests/test_gojq_parity.sh → PASS: 54 / FAIL: 0
  • pipeline/queries/_tests/test_canonical.sh → 26/26 pass (no regression)
  • pipeline/queries/_tests/test_queries_integration.sh → 124/124 pass (no regression)
  • shellcheck on the new script and the existing set → rc=0
  • CI green on push

Closes #187

Verifies every runnable query produces semantically equivalent output under gojq and system jq, against the curated fixtures the integration test already exercises. 54 invocations (26 queries × text + jsonl modes); all pass with text-mode byte-identical and JSONL set-equal after canonical-form normalization (gojq alphabetizes JSON keys; jq preserves insertion order — same data, different serialization).

Closes the verification step from ADR-0005's "Consequences": gojq is safe as the binary's default engine; no queries need `#! engine: jq`. The script becomes a permanent CI target so future query changes can't silently break parity.

CI gains a gojq install step (Linux release tarball, pinned to 0.12.19) and a new shellcheck entry for the parity script.
…che gojq

- Drop the `env_prefix_str` 5th param of run_parity (always `""` at all 28 call sites) along with its word-splitting and SC2206 disable. Trims 28 lines of dead `""` from the table.
- Replace the per-line awk-pipes-to-jq-cmd canonicalization with a single stream-level `jq -cS .` switched on `$format`. Fixes a latent foot-gun (text-mode lines starting with `{` would have been incorrectly canonicalized) and cuts runtime ~30% (2.4s → 1.7s) by collapsing dozens of subprocess forks.
- Unify the `-n` vs path branch with an `input_args=()` array — one invocation per engine instead of two parallel branches.
- Drop the push-only `DIVERGENCES` array + footer summary; inline failure prints already carry the diff and are richer.
- CI: wrap the gojq install in actions/cache@v4 keyed on version, matching the SwiftPM cache pattern. Saves the ~3 MB download per run after first.
- Verify both cross-catalog split files are non-empty before continuing; a missing or malformed TYPES_FIXTURE used to slip through and surface as "outputs differ" later.
- Compute expected invocations from the queries directory and assert PASS+FAIL hits it before declaring success — catches "added a query, forgot a both_modes row."
- One-line comment justifying the `set -e` drop vs peer scripts.
@jakebromberg jakebromberg changed the title test: verify gojq parity for all 26 queries test: verify gojq parity for all 27 queries May 30, 2026
@jakebromberg
jakebromberg merged commit d895e6d into main May 30, 2026
3 checks passed
@jakebromberg
jakebromberg deleted the verify/gojq-compat branch May 30, 2026 17:20
jakebromberg added a commit that referenced this pull request May 30, 2026
Follow-up to PR 3a (#193). Implements the gojq evaluator and the `audit query` handler.

internal/engine adds a gojq wrapper supporting -L, --arg, --argjson, --slurpfile, -n, -r, $ENV.NAME, plus a `#! engine: jq` shell-out fallback per ADR-0005. Library resolution works against both filesystem-rooted and embed.FS-rooted query directories.

internal/cli/query.go parses each query's front-matter to validate --arg / --argjson and wires the catalog declarations into positional input + slurpfile bindings. Covers all seven distinct catalog combinations produced by PR 2's front-matter (including the two-of-same-kind cross-catalog-name-collisions case).

cmd/audit/main.go re-enables the `query` case that PR 3a stubbed out, and cmd/audit/audit_test.go ships an integration test exercising extract → query → status end-to-end on a synthetic file-hashes fixture.

go.mod pins itchyny/gojq v0.12.19 — the version verified parity-clean in #188.
jakebromberg added a commit that referenced this pull request May 30, 2026
Follow-up to PR 3a (#193). Implements the gojq evaluator and the `audit query` handler.

internal/engine adds a gojq wrapper supporting -L, --arg, --argjson, --slurpfile, -n, -r, $ENV.NAME, plus a `#! engine: jq` shell-out fallback per ADR-0005. Library resolution works against both filesystem-rooted and embed.FS-rooted query directories.

internal/cli/query.go parses each query's front-matter to validate --arg / --argjson and wires the catalog declarations into positional input + slurpfile bindings. Covers all seven distinct catalog combinations produced by PR 2's front-matter (including the two-of-same-kind cross-catalog-name-collisions case).

cmd/audit/main.go re-enables the `query` case that PR 3a stubbed out, and cmd/audit/audit_test.go ships an integration test exercising extract → query → status end-to-end on a synthetic file-hashes fixture.

go.mod pins itchyny/gojq v0.12.19 — the version verified parity-clean in #188.
jakebromberg added a commit that referenced this pull request May 30, 2026
Follow-up to PR 3a (#193). Implements the gojq evaluator and the `audit query` handler.

internal/engine adds a gojq wrapper supporting -L, --arg, --argjson, --slurpfile, -n, -r, $ENV.NAME, plus a `#! engine: jq` shell-out fallback per ADR-0005. Library resolution works against both filesystem-rooted and embed.FS-rooted query directories.

internal/cli/query.go parses each query's front-matter to validate --arg / --argjson and wires the catalog declarations into positional input + slurpfile bindings. Covers all seven distinct catalog combinations produced by PR 2's front-matter (including the two-of-same-kind cross-catalog-name-collisions case).

cmd/audit/main.go re-enables the `query` case that PR 3a stubbed out, and cmd/audit/audit_test.go ships an integration test exercising extract → query → status end-to-end on a synthetic file-hashes fixture.

go.mod pins itchyny/gojq v0.12.19 — the version verified parity-clean in #188.
jakebromberg added a commit that referenced this pull request May 30, 2026
Follow-up to PR 3a (#193). Implements the gojq evaluator and the `audit query` handler.

internal/engine adds a gojq wrapper supporting -L, --arg, --argjson, --slurpfile, -n, -r, $ENV.NAME, plus a `#! engine: jq` shell-out fallback per ADR-0005. Library resolution works against both filesystem-rooted and embed.FS-rooted query directories.

internal/cli/query.go parses each query's front-matter to validate --arg / --argjson and wires the catalog declarations into positional input + slurpfile bindings. Covers all seven distinct catalog combinations produced by PR 2's front-matter (including the two-of-same-kind cross-catalog-name-collisions case).

cmd/audit/main.go re-enables the `query` case that PR 3a stubbed out, and cmd/audit/audit_test.go ships an integration test exercising extract → query → status end-to-end on a synthetic file-hashes fixture.

go.mod pins itchyny/gojq v0.12.19 — the version verified parity-clean in #188.
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.

test: verify gojq parity for all 27 queries

1 participant