# FEATURE: Collection Expressions

| Field | Value |
|-------|-------|
| Version | 20261028 V1 |
| Description | Construct, access, and iterate jq arrays and objects. |
| Depends On | FEATURE-GeneratorCore.md |
| Provides | jq collection expressions |
| Consumes | jq generator evaluation |

## Behavior

Array construction collects every output of its enclosed filter into one array, including an empty array when the filter yields nothing. Object construction evaluates key and value expressions against the original input and emits combinations in generator order. Support identifier, string, expression, and variable key forms and the documented shorthand forms as their prerequisites become available.

Field access, computed indexing, iteration, and slices compose with other filters. Missing object fields and out-of-range array indices produce null; negative indices count from the end. Iteration yields array elements or object values in order. Slices use inclusive start and exclusive end, accept omitted and negative bounds, and operate on arrays and strings. Invalid operand types raise jq runtime errors.

## Programmatic Acceptance

=== AC collections-corpus ===
Intent: Collection construction and access execute the selected corpus programs with the required output streams.
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"^\{a: 1\}$|^\.foo$|^\.\[\]$|^\[\.\]$|^\[\{\}\]$"
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))
print(f"{tally['pass']} passed, {tally['fail']} failed, {tally['error']} errored")
assert sum(tally.values()) > 0
assert tally["fail"] == 0 and tally["error"] == 0, tally
=== END AC collections-corpus ===

## User Acceptance

- None.

## Guardrails

- Preserve ordered generator multiplicity and partial output on runtime errors.
- Use the supplied corpus unchanged; mixed cases requiring later capabilities belong to scoped integration.
