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 |
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
Probe: --list
import os import re import sys
sys.path.insert(0, "sources") import run_conformance as harness
SELECT = r"^(?:\.message = \"goodbye\"|\.foo = \.bar|\.foo \|= \.\+1|setpath\(\[-1\]; 1\)|map\(getpath\(\[2\]\)\), map\(setpath\(\[2\]; 42\)\), map\(delpaths\(\[\[2\]\]\)\))$" 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 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.