=== BEGIN ARTIFACT FEATURE-Assignment.md ===
# FEATURE: Path Mutation
| Field | Value |
|-------|-------|
| Version | 20261028 V1 |
| Description | Update and delete jq values through path expressions. |
| Depends On | FEATURE-Paths.md |
| Provides | jq path mutation |
| Consumes | jq path lookup |
## Questions
- None.
## Purpose
Provide immutable path-based mutation through `setpath`, `delpaths`, `del`, and assignment expressions. Filters receive the original input value; mutation emits replacement values without changing other references to that input.
## Behavior
`setpath` creates missing objects and arrays as required by a path. `delpaths` removes the supplied paths, and `del` derives those paths from its filter argument. Respect jq's array index, negative-index, slice, type, and depth rules, including errors and deletion of multiple array locations.
For plain `=`, evaluate the right side against the original input and emit a separate updated input for each right-side result. For `|=`, evaluate the update against each selected old value, use only its first result, and delete that path if it produces no result. Arithmetic and alternative updates follow their jq definitions, including the evaluation context of their operands. Path expressions retain generator order and invalid path expressions raise runtime errors.
## Programmatic Acceptance
=== AC assignment-conformance ===
Intent: Path mutation and assignment cases execute with the jq output and error behavior specified by the corpus.
Suite: scoped
Requires: executable=python3; scope=test
import json
import os
import subprocess
import sys
SELECT = r"^(?:\.message = \"goodbye\"|\.foo = \.bar|\.foo \|= \.\+1|setpath\(\[-1\]; 1\)|map\(getpath\(\[2\]\)\), map\(setpath\(\[2\]; 42\)\), map\(delpaths\(\[\[2\]\]\)\))$"
result = subprocess.run(
[sys.executable, "sources/run_conformance.py", "--select", SELECT, "--json"],
capture_output=True, text=True,
env={**os.environ, "JQ": os.path.abspath("jq")},
)
print(result.stdout)
print(result.stderr, file=sys.stderr)
report = json.loads(result.stdout)
tally = report["summary"]
assert sum(tally.values()) > 0, SELECT
assert tally["fail"] == 0 and tally["error"] == 0, tally
assert result.returncode == 0, result.returncode
=== END AC assignment-conformance ===
## User Acceptance
- None.
## Guardrails
- Do not mutate any file under `sources/`.
- Preserve output order, multiplicity, and partial output before runtime errors.
- Cross-feature corpus cases requiring later builtins remain covered by scoped integration.
=== END ARTIFACT ===
=== BEGIN ARTIFACT FEATURE-GeneratorControl.md ===
# FEATURE: Generator Control
| Field | Value |
|-------|-------|
| Version | 20261028 V1 |
| Description | Reduce streams and control generator execution. |
| Depends On | FEATURE-Bindings.md, FEATURE-Assignment.md |
| Provides | jq reductions and generator control |
| Consumes | jq lexical bindings and functions, jq path mutation |
## Questions
- None.
## Purpose
Provide reductions, intermediate accumulator streams, lexical control transfer, and bounded consumption of generators.
## Behavior
`reduce` evaluates its source stream in order, binds each result to its pattern, and applies the update to accumulator states initialized by the initializer. `foreach` follows the same accumulation model and emits the extraction stream for each intermediate state; omitted extraction is identity. Initializers and updates may produce multiple values.
`label` and `break` use lexical scope and stop the targeted stream without suppressing outputs already emitted. Implement `limit`, `skip`, `first`, `last`, and `nth` in their documented arities. Stop consuming a source when the selected result or limit is reached, so an unneeded later error is not evaluated. Preserve jq's behavior for empty streams, zero and negative counts, and multi-output arguments.
## Programmatic Acceptance
=== AC generator-control-conformance ===
Intent: Reduction, intermediate extraction, and bounded generator consumption pass their applicable corpus cases.
Suite: scoped
Requires: executable=python3; scope=test
import json
import os
import subprocess
import sys
SELECT = r"^(?:reduce \.\[\] as \$x \(0; \. \+ \$x\)|\[foreach \.\[\] as \[\$i, \$j\] \(0; \. \+ \$i - \$j\)\]|\[limit\(3; \.\[\]\)\]|\[skip\(3; \.\[\]\)\]|first\(1,error\(\"foo\"\)\)|nth\(1; 0,1,error\(\"foo\"\)\))$"
result = subprocess.run(
[sys.executable, "sources/run_conformance.py", "--select", SELECT, "--json"],
capture_output=True, text=True,
env={**os.environ, "JQ": os.path.abspath("jq")},
)
print(result.stdout)
print(result.stderr, file=sys.stderr)
report = json.loads(result.stdout)
tally = report["summary"]
assert sum(tally.values()) > 0, SELECT
assert tally["fail"] == 0 and tally["error"] == 0, tally
assert result.returncode == 0, result.returncode
=== END AC generator-control-conformance ===
## User Acceptance
- None.
## Guardrails
- Do not mutate any file under `sources/`.
- Preserve lazy evaluation, generator order, multiplicity, and partial output.
- Cross-feature cases requiring later builtins remain covered by scoped integration.
=== END ARTIFACT ===
=== BEGIN ARTIFACT FEATURE-Conversion.md ===
# FEATURE: Type and Conversion Builtins
| Field | Value |
|-------|-------|
| Version | 20261028 V1 |
| Description | Inspect jq values and convert among numeric, Boolean, string, JSON, and Unicode representations. |
| Depends On | FEATURE-GeneratorControl.md |
| Provides | jq type and conversion builtins |
| Consumes | jq reductions and generator control |
## Questions
- None.
## Purpose
Expose jq's type and conversion filters to programs, using the manual and corpus as the behavioral authority.
## Behavior
Implement `type`, `length`, `utf8bytelength`, `tonumber`, `toboolean`, `tostring`, `tojson`, `fromjson`, `explode`, and `implode`, including their specified input types and errors. String length counts Unicode codepoints; UTF-8 byte length counts encoded bytes. Preserve jq's conversion and serialization behavior, including non-decnum numeric behavior and special numeric values. Unicode conversion follows jq's replacement behavior for invalid codepoints. Errors caught by jq programs are values and must match the corpus where it specifies them.
## Programmatic Acceptance
=== AC conversion-conformance ===
Intent: Type, length, conversion, and Unicode filters execute their applicable corpus cases.
Suite: scoped
Requires: executable=python3; scope=test
import json
import os
import subprocess
import sys
SELECT = r"^(?:utf8bytelength|\[\.\[\] \| length\]|\[\.\[\] \| try utf8bytelength catch \.\]|implode\|explode|fromjson \| isnan|tojson \| fromjson)$"
result = subprocess.run(
[sys.executable, "sources/run_conformance.py", "--select", SELECT, "--json"],
capture_output=True, text=True,
env={**os.environ, "JQ": os.path.abspath("jq")},
)
print(result.stdout)
print(result.stderr, file=sys.stderr)
report = json.loads(result.stdout)
tally = report["summary"]
assert sum(tally.values()) > 0, SELECT
assert tally["fail"] == 0 and tally["error"] == 0, tally
assert result.returncode == 0, result.returncode
=== END AC conversion-conformance ===
## User Acceptance
- None.
## Guardrails
- Do not mutate any file under `sources/`.
- Use Python's standard library only.
- Cross-feature cases requiring later builtins remain covered by scoped integration.
=== END ARTIFACT ===
=== BEGIN ARTIFACT FEATURE-CollectionBuiltins.md ===
# FEATURE: Collection Builtins
| Field | Value |
|-------|-------|
| Version | 20261028 V1 |
| Description | Transform, compare, and organize jq arrays and objects. |
| Depends On | FEATURE-Conversion.md |
| Provides | jq collection builtins |
| Consumes | jq type and conversion builtins |
## Questions
- None.
## 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
import json
import os
import subprocess
import sys
SELECT = r"^(?:sort|unique|flatten|flatten\(0\)|flatten\(2\)|transpose|to_entries|from_entries|map\(has\(2\)\)|map\(keys\)|map_values\(\.\+1\)|contains\(\"bar\"\))$"
result = subprocess.run(
[sys.executable, "sources/run_conformance.py", "--select", SELECT, "--json"],
capture_output=True, text=True,
env={**os.environ, "JQ": os.path.abspath("jq")},
)
print(result.stdout)
print(result.stderr, file=sys.stderr)
report = json.loads(result.stdout)
tally = report["summary"]
assert sum(tally.values()) > 0, SELECT
assert tally["fail"] == 0 and tally["error"] == 0, tally
assert result.returncode == 0, result.returncode
=== END AC collection-builtins-conformance ===
## User Acceptance
- None.
## Guardrails
- Do not mutate any file under `sources/`.
- Preserve jq value ordering and generator semantics rather than Python's default mixed-type ordering.
- Cross-feature cases requiring later builtins remain covered by scoped integration.
=== END ARTIFACT ===
=== BEGIN ARTIFACT FEATURE-Strings.md ===
# FEATURE: String and Regular Expression Builtins
| Field | Value |
|-------|-------|
| Version | 20261028 V1 |
| Description | Manipulate strings and evaluate jq regular expression filters. |
| Depends On | FEATURE-CollectionBuiltins.md |
| Provides | jq string and regex builtins |
| Consumes | jq collection builtins |
## Questions
- None.
## Purpose
Provide the string and regular expression operations specified by the manual and exercised by the conformance corpus.
## Behavior
Implement prefix and suffix tests and trimming, whitespace trimming, splitting and joining, indices and search, ASCII case conversion, and related string operations. Preserve Unicode codepoint indexing, embedded null characters, empty separators, stream-valued arguments, and jq error behavior.
Implement `test`, `match`, `capture`, `scan`, `split`, `splits`, `sub`, and `gsub` with the corpus-required regular expression syntax and flags. Match offsets and lengths count Unicode codepoints; unmatched captures have the specified null value and negative offset. Substitution evaluates its replacement filter against named captures and preserves multiple replacement results. Use only standard-library facilities while matching the required jq behavior.
## Programmatic Acceptance
=== AC string-conformance ===
Intent: String searches, trimming, splitting, and joining execute their applicable corpus cases.
Suite: scoped
Requires: executable=python3; scope=test
import json
import os
import subprocess
import sys
SELECT = r"^(?:split\(\"\"\)|indices\(1\)|indices\(\[1,2\]\)|indices\(\", \"\)|index\(\"!\"\)|ascii_upcase|trim, ltrim, rtrim|join\(\",\"\))$"
result = subprocess.run(
[sys.executable, "sources/run_conformance.py", "--select", SELECT, "--json"],
capture_output=True, text=True,
env={**os.environ, "JQ": os.path.abspath("jq")},
)
print(result.stdout)
print(result.stderr, file=sys.stderr)
report = json.loads(result.stdout)
tally = report["summary"]
assert sum(tally.values()) > 0, SELECT
assert tally["fail"] == 0 and tally["error"] == 0, tally
assert result.returncode == 0, result.returncode
=== END AC string-conformance ===
## User Acceptance
- None.
## Guardrails
- Do not mutate any file under `sources/`.
- Do not install packages or use a third-party jq implementation.
- Cross-feature cases requiring later builtins remain covered by scoped integration.
=== END ARTIFACT ===Run artifact