Run artifact

workspace/targets/jq/blueprint/FEATURE-CollectionBuiltins.md

FEATURE: Collection Builtins

FieldValue
Version20261028 V1
DescriptionTransform, compare, and organize jq arrays and objects.
Depends OnFEATURE-Conversion.md
Providesjq collection builtins
Consumesjq type and conversion builtins

Purpose

Provide the collection filters described by the manual and the definitions in sources/builtin.jq.

Behavior

Implement map, map_values, select, type selectors, keys and membership operations, entries conversion, addition and containment, sorting, grouping, uniqueness, extrema, reverse, flatten, transpose, combinations, binary search, and related collection utilities exercised by the corpus.

map collects every result for every element. map_values uses the first update result and removes a value when the update is empty. Sorting and grouping use jq's total value ordering and evaluate filter keys as ordered streams. Containment recursively follows jq's array and object rules. Preserve argument Cartesian products, stable result order where specified, empty inputs, and jq errors and depth boundaries.

Programmatic Acceptance

=== AC collection-builtins-conformance ===
Intent: Collection transformations, ordering, membership, and containment pass their applicable corpus cases.
Suite: scoped
Requires: executable=python3; scope=test
Probe: --list

import os import re import sys

sys.path.insert(0, "sources") import run_conformance as harness

SELECT = r"^(?:sort|unique|flatten|flatten\(0\)|flatten\(2\)|transpose|to_entries|from_entries|map\(has\(2\)\)|map\(keys\)|map_values\(\.\+1\)|contains\(\"bar\"\))$" cases = harness.parse_corpus(harness.CORPUS.read_text(encoding="utf-8")) excluded = harness.apply_exclusions(cases, harness.parse_exclusions(harness.EXCLUSIONS)) selected = [case for case in cases if re.search(SELECT, case.program)] results = [ harness.Result(case, harness.SKIP) if case.line in excluded else harness.run_case(case, [os.path.abspath("jq")], harness.DEFAULT_TIMEOUT) for case in selected ] tally = {status: sum(result.status == status for result in results) for status in (harness.PASS, harness.FAIL, harness.ERROR, harness.SKIP)} for result in results: if result.status in (harness.FAIL, harness.ERROR): print(harness._render_failure(result)) assert sum(tally.values()) > 0, SELECT assert tally["fail"] == 0 and tally["error"] == 0, tally === END AC collection-builtins-conformance ===

User Acceptance

Guardrails