FEATURE: Input and Diagnostics
| Field | Value |
|---|---|
| Version | 20261028 V1 |
| Description | Provide jq input, environment, location, and diagnostic filters. |
| Depends On | FEATURE-Traversal.md |
| Provides | jq input and diagnostic builtins |
| Consumes | jq traversal and streaming builtins |
Purpose
Provide the input and diagnostic facilities described by the jq manual, sharing the interpreter's input stream and preserving its output stream.
Behavior
inputconsumes one subsequent JSON value from the shared input stream;inputsgenerates the remaining values in order. Exhaustion follows jq's catchable behavior.$ENVrepresents the environment at program startup andenvprovides the current environment. Provide the input filename and line number where exercised.debuganddebug(msgs)write their diagnostic side effects to stderr while preserving their specified output streams;stderrwrites its input in raw compact form to stderr and yields the input.$__loc__yields the source file and line at its occurrence. Diagnostic output must not corrupt stdout or suppress values emitted before a runtime error.
Programmatic Acceptance
=== AC input-diagnostics-corpus ===
Intent: Input exhaustion, diagnostics, and source locations execute the corresponding corpus cases.
Suite: scoped
Requires: executable=python3; scope=test
Probe: --list
Probe Count: summary
import json import os import subprocess import sys
SELECT = r"\b(?:input|debug)\b|\$loc" 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, f"selector matched no case: {SELECT}" assert tally["fail"] == 0 and tally["error"] == 0, tally assert result.returncode == 0, result.returncode === END AC input-diagnostics-corpus ===
User Acceptance
- None.
Guardrails
- Diagnostics go to stderr; JSON result values go to stdout.
- Use only the Python standard library and do not alter staged source assets.