=== BEGIN ARTIFACT ANALYSIS.md === # Blueprint Analysis: jq ## Commander Expectations - assert the interpreter accepts the supplied jq programs and produces the expected outputs for every runnable case in the pinned conformance corpus - assert the executable reads JSON from stdin and writes compact JSON values to stdout, one per line - assert the interpreter is implemented in Python without a third-party jq implementation or system jq dependency ## Crew | Crew | Charge | |---|---| | Commander | Defines intent and decides what done means. | | Team Lead | Confirms epic completeness and stakeholder expectations. | | Planning Crew | Authors atomic specifications and the ordered Manifest. | | Shipyard Crew | Builds the tickets without synchronous Commander access. | ## Story List ### Feature: Language Front End | ID | Story | High-level AC | |---|---|---| | FRONTEND-001 | Parse jq expressions into an abstract syntax tree | The parser accepts the supplied valid syntax and rejects the supplied invalid syntax with compile exit code 3. | | FRONTEND-002 | Tokenize literals, strings, interpolation, and comments | The lexer handles jq literals, escapes, interpolated strings, format strings, and comments as exercised by the corpus. | ### Feature: Generator Evaluation Core | ID | Story | High-level AC | |---|---|---| | CORE-001 | Evaluate identity, literals, pipelines, and generators | Filters preserve jq input/output semantics, stream order, and cartesian-product behavior. | | CORE-002 | Construct and iterate arrays and objects | Array and object construction, indexing, iteration, and slicing produce the expected values. | | CORE-003 | Evaluate arithmetic, comparison, and logical operators | Operators follow jq type rules, value ordering, and generator behavior. | | CORE-004 | Evaluate conditionals, alternatives, and error handling | `if`, boolean operators, `//`, `try`, `catch`, and optional expressions produce the expected streams and errors. | | CORE-005 | Evaluate reductions, loops, and control transfer | `reduce`, `foreach`, `limit`, `skip`, `first`, `last`, `nth`, labels, and `break` preserve generator behavior. | | CORE-006 | Evaluate variables, destructuring, and user-defined functions | Bindings, patterns, function arguments, scoping, recursion, and destructuring alternatives behave as specified. | ### Feature: Paths and Assignment | ID | Story | High-level AC | |---|---|---| | PATHS-001 | Evaluate paths and path-based lookup | `path`, `paths`, `getpath`, and `pick` identify and retrieve the expected locations. | | PATHS-002 | Set, update, and delete values by path | Assignment operators and path mutation functions update or remove the expected values. | ### Feature: Built-in Functions | ID | Story | High-level AC | |---|---|---| | BUILTINS-001 | Provide type, length, and conversion functions | Type inspection, length, string conversion, numeric and boolean parsing, and Unicode conversions follow jq behavior. | | BUILTINS-002 | Provide array and object utilities | Sorting, grouping, uniqueness, entries, containment, combinations, transpose, flattening, and related utilities produce expected results. | | BUILTINS-003 | Provide string and regular expression functions | String manipulation, matching, capture, splitting, substitution, and scanning produce expected results. | | BUILTINS-004 | Provide formatting and encoding functions | jq format filters for JSON, HTML, URI, CSV, TSV, shell, and Base64 produce expected outputs. | | BUILTINS-005 | Provide math and numeric edge-case functions | Math functions and special numeric values follow the corpus expectations, including the non-decnum behavior. | | BUILTINS-006 | Provide date and time functions | Date parsing, conversion, formatting, and broken-down time functions produce expected results. | | BUILTINS-007 | Provide streaming, recursion, and traversal utilities | `recurse`, `walk`, `tostream`, `fromstream`, and related generators produce expected streams. | | BUILTINS-008 | Provide environment, diagnostics, and input functions | Environment access, `input`, `inputs`, `debug`, `stderr`, and location values follow the interface and corpus expectations. | | BUILTINS-009 | Provide SQL-style operators and builtin inventory | `INDEX`, `JOIN`, `IN`, and `builtins` produce the expected results. | ### Feature: Command-Line Interpreter | ID | Story | High-level AC | |---|---|---| | CLI-001 | Run jq filters through the executable interface | The root-level executable accepts `-c` and a filter, reads JSON from stdin, and emits compact JSON values one per line with jq-compatible exit codes. | | CLI-002 | Document interpreter usage and verification | The README documents stdin/stdout behavior, exit codes, and the supplied full-suite command. | ### Feature: Conformance Verification | ID | Story | High-level AC | |---|---|---| | VERIFY-001 | Run the scoped conformance cases for implemented constructs | Each implementation story's scoped runner invocation executes its matching cases and exits zero. | | VERIFY-002 | Gate completion on the complete conformance corpus | The terminal verification runs `sh sources/full_test.sh` and asserts its return code is zero. | ## Surfaced Acceptance Criteria None. ## Relationship Model | Source or group | Relationship type | Related source or group | Evidence | Delivery implication | |---|---|---|---|---| | `sources/lexer.l` | dependency | `sources/parser.y` | Lexer tokens and string-interpolation states feed the grammar. | Implement tokenization before or alongside parser work. | | `sources/parser.y` | dependency | `sources/jq-manual.txt` | Grammar settles syntax and precedence; the manual defines behavior. | Parser work precedes evaluator behavior. | | `sources/jq-manual.txt` | normative specification | Interpreter implementation | Manual sections define filter and builtin semantics. | Build stories should cite the relevant manual sections. | | `sources/builtin.jq` | reference-to-replacement | Builtin implementation | The file defines jq-level builtin implementations and compositions. | Use it as semantic guidance while implementing builtins. | | `sources/jq.test` | test-kit-to-implementation | Interpreter implementation | Corpus exercises syntax, generators, paths, assignments, builtins, and edge cases. | Each implementation story runs a nonempty scoped slice. | | `sources/run_conformance.py` | instruction-to-test | `sources/jq.test` | Runner parses cases and supports `--select`; it compares values and exit codes. | Stage unchanged and use scoped runs except at the terminal gate. | | `sources/full_test.sh` | instruction-to-test | `sources/run_conformance.py` | Script checks executable presence and invokes the runner unfiltered. | Only the terminal verification story invokes this script. | | `sources/exclusions.txt` | test-kit-to-implementation | `sources/run_conformance.py` | Runner applies declared exclusions and errors on stale entries. | Stage unchanged with the corpus and runner. | | `sources/INSTRUCTIONS.md` | author intent | All implementation and verification stories | It defines the interface, restrictions, implementation order, and done conditions. | Use as prompt context; the imported instruction file is not staged. | ## Source Roles | Path | Role | Plan disposition | Build disposition | |---|---|---|---| | `sources/INSTRUCTIONS.md` | author intent | prompt-only | prompt-only | | `sources/builtin.jq` | reference implementation | context | stage | | `sources/exclusions.txt` | conformance harness | context | stage | | `sources/full_test.sh` | conformance harness | context | stage | | `sources/jq-manual.txt` | normative specification | context | stage | | `sources/jq.test` | normative specification and conformance test suite | context | stage | | `sources/lexer.l` | normative specification | context | stage | | `sources/parser.y` | normative specification | context | stage | | `sources/run_conformance.py` | conformance harness | context | stage | ## Planning Instructions ### Delivery Shape A local command-line interpreter reads JSON from standard input, evaluates a jq filter supplied on the command line, and writes each compact JSON result to standard output. The build flow is to implement the lexer and parser, add the generator-based evaluator and language features, implement builtins, provide the executable and README, run scoped corpus slices during implementation, then run the supplied full harness once as the terminal verification. ### Story Realization Map | Story ID | Durable Blueprint scope | Evidence | Related files | Requires | |---|---|---|---|---| | FRONTEND-001 | jq grammar and AST | `sources/parser.y` | `sources/lexer.l`, `sources/jq-manual.txt` | capability | | FRONTEND-002 | jq lexical rules | `sources/lexer.l` | `sources/parser.y`, `sources/jq.test` | capability | | CORE-001 | Generator execution model and core filters | `sources/jq-manual.txt`, `sources/jq.test` | `sources/parser.y` | capability | | CORE-002 | Constructors, indexing, iteration, and slices | `sources/jq-manual.txt`, `sources/jq.test` | `sources/parser.y` | capability | | CORE-003 | Arithmetic, comparisons, and boolean operators | `sources/jq-manual.txt`, `sources/jq.test` | `sources/builtin.jq` | capability | | CORE-004 | Conditional and error control | `sources/jq-manual.txt`, `sources/jq.test` | `sources/parser.y` | capability | | CORE-005 | Reducers, generators, labels, and breaks | `sources/jq-manual.txt`, `sources/jq.test` | `sources/builtin.jq` | capability | | CORE-006 | Bindings, patterns, functions, and scope | `sources/jq-manual.txt`, `sources/parser.y`, `sources/jq.test` | `sources/builtin.jq` | capability | | PATHS-001 | Path generation and lookup functions | `sources/jq-manual.txt`, `sources/jq.test` | `sources/builtin.jq` | capability | | PATHS-002 | Assignment and deletion | `sources/jq-manual.txt`, `sources/jq.test` | `sources/parser.y`, `sources/builtin.jq` | capability | | BUILTINS-001 | Type, length, conversion, and Unicode functions | `sources/jq-manual.txt`, `sources/jq.test` | `sources/builtin.jq` | capability | | BUILTINS-002 | Array and object utilities | `sources/jq-manual.txt`, `sources/jq.test` | `sources/builtin.jq` | capability | | BUILTINS-003 | Strings and regular expressions | `sources/jq-manual.txt`, `sources/jq.test` | `sources/lexer.l`, `sources/builtin.jq` | capability | | BUILTINS-004 | Output formatting and encoding filters | `sources/jq-manual.txt`, `sources/jq.test` | `sources/builtin.jq` | capability | | BUILTINS-005 | Math and numeric behavior | `sources/jq-manual.txt`, `sources/jq.test` | `sources/builtin.jq` | capability | | BUILTINS-006 | Date and time functions | `sources/jq-manual.txt`, `sources/jq.test` | `sources/builtin.jq` | capability | | BUILTINS-007 | Streaming and recursive traversal utilities | `sources/jq-manual.txt`, `sources/jq.test` | `sources/builtin.jq` | capability | | BUILTINS-008 | Environment, I/O, diagnostics, and locations | `sources/jq-manual.txt`, `sources/jq.test` | `sources/builtin.jq` | capability | | BUILTINS-009 | SQL-style operators and builtin list | `sources/jq-manual.txt`, `sources/jq.test` | `sources/builtin.jq` | capability | | CLI-001 | Executable command interface | `sources/INSTRUCTIONS.md` | `sources/full_test.sh`, `sources/run_conformance.py` | capability | | CLI-002 | Project README | `sources/INSTRUCTIONS.md` | `sources/full_test.sh` | documentation | | VERIFY-001 | Scoped conformance verification | `sources/INSTRUCTIONS.md` | `sources/run_conformance.py`, `sources/jq.test`, `sources/exclusions.txt` | test harness | | VERIFY-002 | Complete-suite terminal verification | `sources/INSTRUCTIONS.md`, `SEA_TRIALS.md` | `sources/full_test.sh`, `sources/run_conformance.py`, `sources/jq.test`, `sources/exclusions.txt` | acceptance contract | ### Test and Acceptance Strategy Implementation stories run `sources/run_conformance.py` with `JQ` set and a nonempty `--select` expression scoped to the construct implemented by that story. Use `--list` during planning to inspect and size selectors, not as a behavior acceptance check. The sole terminal verification invokes `sh sources/full_test.sh`, asserts only that the return code is zero, and prints captured output for diagnosis. It is the only unfiltered full-suite run and carries the Sea Trial. ### Sequencing and Dependencies Implement the lexer and parser before evaluator features. Establish generator evaluation before paths, assignment, control flow, functions, and builtins. The executable and README complete the user-facing interface. Scoped verification accompanies implementation; terminal verification depends on every implementation story. Stage the corpus, harness, exclusions, manual, grammar, lexer, and builtin reference so build and acceptance steps can read them. ### Source Conflicts and Gaps No unresolved conflicts or human-owned questions were found. The imported sources specify the product, implementation language, runtime restrictions, interface, corpus, exclusions, and verification command. Deployment is not applicable to the described local CLI. ## Analysis Notes generated: 2026-10-28 blueprint: /mnt/c/Users/barlo/projects/drydock/uat/jq/runs/20261028.145919/workspace/targets/jq/blueprint Quality: Ready blockers: 0 questions: 0 features: 6 stories: 23 stack: Python display_name: not proposed short_description: not proposed None. === END ARTIFACT === === BEGIN ARTIFACT SEA_TRIALS.md === # Sea Trials: jq ## st-001: The supplied scoring script passes Type: technical Required: yes Criterion: The completed interpreter shall make sh sources/full_test.sh exit zero; that script's exit status is the sole acceptance verdict. Testability: deterministic Consequence: blocks Verification: proof Command: ["sh", "sources/full_test.sh"] Pattern: ubiquitous === END ARTIFACT === === BEGIN ARTIFACT TECHNOLOGY_STACK.md === # Technology Stack | Technology | Rigging | Notes | |---|---|---| | Python | `python.md` | Required implementation language; standard library only. | | POSIX sh | `cli.md` | Used to invoke the supplied scoring script. | === END ARTIFACT ===