Run artifact

workspace/targets/jq/blueprint/ARCHITECTURE.md

ARCHITECTURE: jq Interpreter

FieldValue
Version20260822 V1
DescriptionStandard-library Python architecture for a standalone jq interpreter.
Depends OnCOMPASS.md, TECHNOLOGY_STACK.md
Providesjq interpreter architecture, executable boundary, parser, evaluator, runtime
Consumes—

System Overview

The application is an executable named jq at the application root. It accepts -c '<program>', reads JSON values from standard input, evaluates the jq program as an ordered generator, and writes compact JSON values one per line.

The implementation is composed of:

All runtime code uses Python 3.11+ standard-library modules only. The implementation must not invoke, import, or bind to another jq implementation.

Module Boundaries

ModuleResponsibility
jqExecutable entry point and command-line validation
jq_runtime.py or equivalentInput stream, evaluation context, errors, output serialization
jq_lexer.py or equivalentTokens, comments, literals, strings, interpolation markers
jq_parser.py or equivalentAST construction, precedence, declarations, syntax validation
jq_eval.py or equivalentOrdered generator evaluation, environments, functions, control flow
jq_values.py or equivalentjq values, numeric handling, comparison, access, mutation
jq_builtins.py or equivalentBuiltin filters and standard-library implementations

The concrete module filenames may vary, but responsibilities remain isolated at these boundaries.

Evaluation Model

Every filter receives one input and yields an ordered stream of zero or more outputs. Pipes evaluate the right-hand filter once per left-hand output. Commas concatenate streams. Filter arguments remain generators, while value arguments are evaluated and bound as values. Runtime errors propagate through the stream and preserve outputs already emitted.

Assignments operate immutably over paths and return replacement values rather than mutating shared input objects.

Process Contract

Technology Stack

TechnologyApplication
PythonInterpreter, parser, evaluator, builtins, CLI
POSIX shSupplied conformance entry point

Only Python standard-library facilities are permitted at runtime.

Source and Test Asset Boundary

The supplied files under sources/ are immutable inputs. The implementation reads them when required but does not modify them. The conformance runner is external to the interpreter and remains the authority for corpus comparison.

Programmatic Acceptance

=== AC architecture-runtime ===
Intent: The declared runtime stack is available using only Python standard-library modules.

import importlib

modules = ["json", "decimal", "math", "re", "datetime", "time", "base64", "unicodedata", "itertools", "functools", "dataclasses", "argparse", "sys"] for module in modules: assert importlib.import_module(module) is not None === END AC architecture-runtime ===

=== AC architecture-contract ===
Intent: The staged conformance runner exposes the process exit-code contract required by the architecture.

import sys sys.path.insert(0, "sources") import run_conformance as harness

assert harness.EXIT_COMPILE_ERROR == 3 assert harness.EXIT_RUNTIME_ERROR == 5 assert harness.PASS == "pass" assert harness.FAIL == "fail" assert harness.ERROR == "error" === END AC architecture-contract ===

User Acceptance

Guardrails