=== BEGIN ARTIFACT FEATURE-SqlBuiltins.md === # FEATURE: SQL-Style Builtins and Inventory | Field | Value | |-------|-------| | Version | 20261028 V1 | | Description | Provide SQL-style stream operations and the builtin function inventory. | | Depends On | FEATURE-InputDiagnostics.md | | Provides | jq SQL-style builtins and inventory | | Consumes | jq input and diagnostic builtins | ## Questions - None. ## Purpose and behavior The interpreter provides `INDEX(stream; index_expression)` and `INDEX(index_expression)`, producing an object keyed by the string conversion of each row's index expression. The one-argument form uses the input's elements as its stream. `JOIN` supports the two-, three-, and four-argument forms described in the manual. It pairs each stream value with the indexed value at its computed key, using null for a missing key; the four-argument form applies the join expression to each pair. `IN` supports its one- and two-argument forms and tests stream membership using jq equality. `builtins` emits an array of supported builtin names in `name/arity` form, with separate entries for distinct arities. Preserve argument evaluation, stream order, and short-circuit behavior defined by the manual and `sources/builtin.jq`. ## Programmatic Acceptance === AC sql-builtins-corpus === Intent: The SQL-style operators and builtin inventory pass their matching corpus programs. Suite: scoped Requires: executable=python3; scope=test import json import os import subprocess import sys SELECT = r"\b(INDEX|JOIN|IN|builtins)\b" 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"] print(f"{tally['pass']} passed, {tally['fail']} failed, {tally['error']} errored") 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 sql-builtins-corpus === ## User Acceptance - None. ## Guardrails - Use the Python standard library only; do not invoke or bind an external jq implementation. - Keep staged source assets unchanged. === END ARTIFACT === === BEGIN ARTIFACT FEATURE-Command.md === # FEATURE: Command Interface | Field | Value | |-------|-------| | Version | 20261028 V1 | | Description | Run jq filters on standard input through the root executable. | | Depends On | FEATURE-SqlBuiltins.md | | Provides | ./jq -c | | Consumes | jq SQL-style builtins and inventory | ## Questions - None. ## Purpose and behavior Invoke the executable at the application root as `./jq -c ''`. Compile the supplied jq program, read JSON values from standard input, and evaluate the program on each input using the shared generator and input stream. Emit each produced value as compact JSON on its own standard-output line, preserving order and multiplicity. Exit 0 when compilation and execution complete, 3 for a compile or static error, and 5 for a runtime error. Retain values emitted before a runtime error. Send diagnostics to standard error. Only `-c` is required. ## Programmatic Acceptance === AC command-stream === Intent: The command returns each input unchanged in order as a compact JSON value. Requires: executable=python3; scope=test import json import subprocess import sys values = [{"a": [1, 2]}, [3, 4]] payload = "\n".join(json.dumps(value) for value in values) + "\n" result = subprocess.run(["./jq", "-c", "."], input=payload, capture_output=True, text=True) print(result.stdout) print(result.stderr, file=sys.stderr) assert result.returncode == 0 assert [json.loads(line) for line in result.stdout.splitlines()] == values assert all(line == json.dumps(json.loads(line), separators=(",", ":")) for line in result.stdout.splitlines()) === END AC command-stream === === AC command-errors === Intent: Compilation and runtime failures have distinct exit statuses, and prior output survives a runtime failure. Requires: executable=python3; scope=test import json import subprocess import sys invalid = subprocess.run(["./jq", "-c", "{"], input="null", capture_output=True, text=True) print(invalid.stdout) print(invalid.stderr, file=sys.stderr) assert invalid.returncode == 3 value = 7 runtime = subprocess.run( ["./jq", "-c", "., error"], input=json.dumps(value), capture_output=True, text=True ) print(runtime.stdout) print(runtime.stderr, file=sys.stderr) assert runtime.returncode == 5 assert [json.loads(line) for line in runtime.stdout.splitlines()] == [value] === END AC command-errors === === AC command-corpus === Intent: Identity programs execute successfully through the command and supplied corpus runner. Suite: scoped Requires: executable=python3; scope=test import json import os import subprocess import sys SELECT = r"^\.$" 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"] print(f"{tally['pass']} passed, {tally['fail']} failed, {tally['error']} errored") 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 command-corpus === ## User Acceptance - None. ## Guardrails - Implement in Python with only standard-library runtime dependencies. - Do not shell out to system jq or use a third-party jq implementation. - Do not modify staged source assets. === END ARTIFACT === === BEGIN ARTIFACT FEATURE-Documentation.md === # FEATURE: Usage Documentation | Field | Value | |-------|-------| | Version | 20261028 V1 | | Description | Document the standalone command and its verification interface. | | Depends On | FEATURE-Command.md | | Provides | jq usage documentation | | Consumes | ./jq -c | ## Questions - None. ## Purpose and behavior Deliver a concise application-root README describing `./jq -c ''`, JSON input on standard input, compact JSON values on standard output, the completion, compilation-error, and runtime-error exit codes 0, 3, and 5, and the supplied `sh sources/full_test.sh` verification command. Diagnostics are written to standard error. ## Programmatic Acceptance === AC documented-command === Intent: The documented command accepts JSON input and returns the input value as JSON. Requires: executable=python3; scope=test import json import subprocess import sys value = {"items": [1, 2]} result = subprocess.run( ["./jq", "-c", "."], input=json.dumps(value), capture_output=True, text=True ) print(result.stdout) print(result.stderr, file=sys.stderr) assert result.returncode == 0 assert json.loads(result.stdout) == value === END AC documented-command === === AC documented-corpus === Intent: The documented command passes an executing slice of identity filters. Suite: scoped Requires: executable=python3; scope=test import json import os import subprocess import sys SELECT = r"^\.$" 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"] print(f"{tally['pass']} passed, {tally['fail']} failed, {tally['error']} errored") 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 documented-corpus === ## User Acceptance - None. ## Guardrails - Keep the supplied scoring assets unchanged. === END ARTIFACT === === BEGIN ARTIFACT FEATURE-ScopedConformance.md === # FEATURE: Scoped Conformance Integration | Field | Value | |-------|-------| | Version | 20261028 V1 | | Description | Execute cross-feature corpus cases through the completed interpreter. | | Depends On | FEATURE-Command.md, FEATURE-CorpusStaging.md | | Provides | scoped conformance integration | | Consumes | ./jq -c, staged conformance assets | ## Questions - None. ## Purpose and behavior Run the supplied corpus through executing, selected runner invocations after the interpreter's feature providers are available. Cover cross-feature programs deferred from earlier gates, including lexical and parser cases, and ensure every runnable corpus case belongs to an intermediate executing slice. Preserve the corpus, exclusions, and runner unchanged. Each selected run supplies `JQ`, reads the JSON report, requires a nonzero selected count, zero failures and errors, and exit 0. ## Programmatic Acceptance === AC integration-programs === Intent: All nonempty program texts, including cross-feature and front-end cases, pass an executing selected corpus run. Suite: scoped Requires: executable=python3; scope=test import json import os import subprocess import sys SELECT = r".+" 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"] print(f"{tally['pass']} passed, {tally['fail']} failed, {tally['error']} errored") 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 integration-programs === ## User Acceptance - None. ## Guardrails - Only the terminal verification story invokes the full scoring script. - Do not alter any file under `sources/`. === END ARTIFACT === === BEGIN ARTIFACT VERIFICATION.md === # FEATURE: Terminal Conformance Verification | Field | Value | |-------|-------| | Version | 20261028 V1 | | Description | Verify the completed interpreter with the supplied scoring script. | | Depends On | FEATURE-ScopedConformance.md, FEATURE-Documentation.md | | Consumes | scoped conformance integration, jq usage documentation | ## Questions - None. ## Purpose and behavior After all implementation and staging work has completed, execute the supplied scoring entry point from the application root. Its exit status is the full-suite verdict. This story adds no interpreter capability. ## Programmatic Acceptance === AC complete-conformance === Intent: The supplied scoring script accepts the completed interpreter against the full corpus. Suite: full Requires: executable=sh; scope=test Requires: executable=python3; scope=test import subprocess import sys result = subprocess.run( ["sh", "sources/full_test.sh"], capture_output=True, text=True ) print(result.stdout) print(result.stderr, file=sys.stderr) assert result.returncode == 0, result.returncode === END AC complete-conformance === ## User Acceptance - None. ## Guardrails - Run the scoring script unchanged and do not modify any file under `sources/`. - This is the only story that invokes the full scoring script. === END ARTIFACT ===