Run artifact

evidence/prompt_outputs/20261028.150755.074Z_jq_lineage_attribute_codex.output.txt

<requirement name="halt-error" stories="io">
def halt_error: halt_error(5);
</requirement>
<requirement name="error-message" stories="control">
def error(msg): msg|error;
</requirement>
<requirement name="map" stories="collection-builtins">
def map(f): [.[] | f];
</requirement>
<requirement name="select" stories="collection-builtins">
def select(f): if f then . else empty end;
</requirement>
<requirement name="sort-by" stories="collection-builtins">
def sort_by(f): _sort_by_impl(map([f]));
</requirement>
<requirement name="group-by" stories="collection-builtins">
def group_by(f): _group_by_impl(map([f]));
</requirement>
<requirement name="unique-by" stories="collection-builtins">
def unique_by(f): _unique_by_impl(map([f]));
</requirement>
<requirement name="max-by" stories="collection-builtins">
def max_by(f): _max_by_impl(map([f]));
</requirement>
<requirement name="min-by" stories="collection-builtins">
def min_by(f): _min_by_impl(map([f]));
</requirement>
<requirement name="add" stories="collection-builtins">
def add(f): reduce f as $x (null; . + $x);
def add: add(.[]);
</requirement>
<requirement name="delete-paths" stories="assignment,paths">
def del(f): delpaths([path(f)]);
</requirement>
<requirement name="absolute-value" stories="numeric">
def abs: if . < 0 then - . else . end;
</requirement>
<requirement name="assign-paths" stories="assignment,paths">
def _assign(paths; $value): reduce path(paths) as $p (.; setpath($p; $value));
</requirement>
<requirement name="modify-paths" stories="assignment,paths">
def _modify(paths; update):
    reduce path(paths) as $p ([., []];
        . as $dot
      | null
      | label $out
      | ($dot[0] | getpath($p)) as $v
      | (
          (   $$$$v
            | update
            | (., break $out) as $v
            | $$$$dot
            | setpath([0] + $p; $v)
          ),
          (
              $$$$dot
            | setpath([1, (.[1] | length)]; $p)
          )
        )
    ) | . as $dot | $dot[0] | delpaths($dot[1]);
</requirement>
<requirement name="map-values" stories="collection-builtins,assignment">
def map_values(f): .[] |= f;
</requirement>
<requirement name="recurse" stories="traversal">
def recurse(f): def r: ., (f | r); r;
def recurse(f; cond): def r: ., (f | select(cond) | r); r;
def recurse: recurse(.[]?);
</requirement>
<requirement name="to-entries" stories="collection-builtins">
def to_entries: [keys_unsorted[] as $k | {key: $k, value: .[$k]}];
</requirement>
<requirement name="from-entries" stories="collection-builtins">
def from_entries: map({ (.key // .Key // .name // .Name):
  if has("value") then .value else .Value end }) | add // {};
</requirement>
<requirement name="with-entries" stories="collection-builtins">
def with_entries(f): to_entries | map(f) | from_entries;
</requirement>
<requirement name="reverse" stories="collection-builtins">
def reverse: [.[length - 1 - range(0;length)]];
</requirement>
<requirement name="indices" stories="collection-builtins,strings">
def indices($i): if type == "array" and ($i|type) == "array" then .[$i]
  elif type == "array" then .[[$i]]
  elif type == "string" and ($i|type) == "string" then _strindices($i)
  else .[$i] end;
</requirement>
<requirement name="index" stories="collection-builtins,strings">
def index($i):   indices($i) | .[0];       # TODO: optimize
</requirement>
<requirement name="rindex" stories="collection-builtins,strings">
def rindex($i):  indices($i) | .[-1:][0];  # TODO: optimize
</requirement>
<requirement name="paths" stories="paths,traversal">
def paths: path(recurse)|select(length > 0);
def paths(node_filter): path(recurse|select(node_filter))|select(length > 0);
</requirement>
<requirement name="isfinite" stories="numeric">
def isfinite: type == "number" and (isinfinite | not);
</requirement>
<requirement name="arrays" stories="conversion">
def arrays: select(type == "array");
</requirement>
<requirement name="objects" stories="conversion">
def objects: select(type == "object");
</requirement>
<requirement name="iterables" stories="conversion">
def iterables: select(type|. == "array" or . == "object");
</requirement>
<requirement name="booleans" stories="conversion">
def booleans: select(type == "boolean");
</requirement>
<requirement name="numbers" stories="conversion">
def numbers: select(type == "number");
</requirement>
<requirement name="normals" stories="numeric">
def normals: select(isnormal);
</requirement>
<requirement name="finites" stories="numeric">
def finites: select(isfinite);
</requirement>
<requirement name="strings" stories="conversion">
def strings: select(type == "string");
</requirement>
<requirement name="nulls" stories="conversion">
def nulls: select(. == null);
</requirement>
<requirement name="values" stories="conversion">
def values: select(. != null);
</requirement>
<requirement name="scalars" stories="conversion">
def scalars: select(type|. != "array" and . != "object");
</requirement>
<requirement name="join" stories="strings">
def join($x): reduce .[] as $i (null;
            (if .==null then "" else .+$x end) +
            ($i | if type=="boolean" or type=="number" then tostring else .//"" end)
        ) // "";
</requirement>
<requirement name="flatten" stories="collection-builtins">
def _flatten($x): reduce .[] as $i ([]; if $i | type == "array" and $x != 0 then . + ($i | _flatten($x-1)) else . + [$i] end);
def flatten($x): if $x < 0 then error("flatten depth must not be negative") else _flatten($x) end;
def flatten: _flatten(-1);
</requirement>
<requirement name="range-to" stories="loops">
def range($x): range(0;$x);
</requirement>
<requirement name="iso-date-conversion" stories="dates">
def fromdateiso8601: strptime("%Y-%m-%dT%H:%M:%SZ")|mktime;
def todateiso8601: strftime("%Y-%m-%dT%H:%M:%SZ");
def fromdate: fromdateiso8601;
def todate: todateiso8601;
</requirement>
<requirement name="trim-left" stories="strings">
def ltrimstr($left): if startswith($left) then .[$left | length:] end;
</requirement>
<requirement name="trim-right" stories="strings">
def rtrimstr($right): if endswith($right) then .[:length - ($right | length)] end;
</requirement>
<requirement name="trim-string" stories="strings">
def trimstr($val): ltrimstr($val) | rtrimstr($val);
</requirement>
<requirement name="match" stories="strings">
def match(re; mode): _match_impl(re; mode; false)|.[];
def match($val): ($val|type) as $vt | if $vt == "string" then match($val; null)
   elif $vt == "array" and ($val | length) > 1 then match($val[0]; $val[1])
   elif $vt == "array" and ($val | length) > 0 then match($val[0]; null)
   else error( $vt + " not a string or array") end;
</requirement>
<requirement name="test-regex" stories="strings">
def test(re; mode): _match_impl(re; mode; true);
def test($val): ($val|type) as $vt | if $vt == "string" then test($val; null)
   elif $vt == "array" and ($val | length) > 1 then test($val[0]; $val[1])
   elif $vt == "array" and ($val | length) > 0 then test($val[0]; null)
   else error( $vt + " not a string or array") end;
</requirement>
<requirement name="capture" stories="strings">
def capture(re; mods): match(re; mods) | reduce ( .captures | .[] | select(.name != null) | { (.name) : .string } ) as $pair ({}; . + $pair);
def capture($val): ($val|type) as $vt | if $vt == "string" then capture($val; null)
   elif $vt == "array" and ($val | length) > 1 then capture($val[0]; $val[1])
   elif $vt == "array" and ($val | length) > 0 then capture($val[0]; null)
   else error( $vt + " not a string or array") end;
</requirement>
<requirement name="scan" stories="strings">
def scan($re; $flags):
  match($re; "g" + $flags)
    | if (.captures|length > 0)
      then [ .captures | .[] | .string ]
      else .string
      end;
def scan($re): scan($re; null);
</requirement>
<requirement name="splits" stories="strings">
# splits/1 produces a stream; split/1 is retained for backward compatibility.
def splits($re; $flags):
  .[foreach (match($re; $flags+"g"), null) as {$offset, $length}
      (null; {start: .next, end: $offset, next: ($offset+$length)})];
def splits($re): splits($re; null);
</requirement>
<requirement name="split" stories="strings">
# split emits an array for backward compatibility
def split($re; $flags): [ splits($re; $flags) ];
</requirement>
<requirement name="sub" stories="strings">
# If s contains capture variables, then create a capture object and pipe it to s, bearing
# in mind that s could be a stream
def sub($re; s; $flags):
   . as $in
   | (reduce match($re; $flags) as $edit
        ({result: [], previous: 0};
            $in[ .previous: ($edit | .offset) ] as $gap
            # create the "capture" objects (one per item in s)
            | [reduce ( $edit | .captures | .[] | select(.name != null) | { (.name) : .string } ) as $pair
                 ({}; . + $pair) | s ] as $inserts
            | reduce range(0; $inserts|length) as $ix (.; .result[$ix] += $gap + $inserts[$ix])
            | .previous = ($edit | .offset + .length ) )
          | .result[] + $in[.previous:] )
      // $in;

def sub($re; s): sub($re; s; "");
</requirement>
<requirement name="gsub" stories="strings">
def gsub($re; s; flags): sub($re; s; flags + "g");
def gsub($re; s): sub($re; s; "g");
</requirement>
<requirement name="while" stories="loops">
def while(cond; update):
     def _while:
         if cond then ., (update | _while) else empty end;
     _while;
</requirement>
<requirement name="until" stories="loops">
def until(cond; next):
     def _until:
         if cond then . else (next|_until) end;
     _until;
</requirement>
<requirement name="limit" stories="loops">
def limit($n; expr):
  if $n > 0 then label $out | foreach expr as $item ($n; . - 1; $item, if . <= 0 then break $out else empty end)
  elif $n == 0 then empty
  else error("limit doesn't support negative count") end;
</requirement>
<requirement name="skip" stories="loops">
def skip($n; expr):
  if $n > 0 then foreach expr as $item ($n; . - 1; if . < 0 then $item else empty end)
  elif $n == 0 then expr
  else error("skip doesn't support negative count") end;
</requirement>
<requirement name="range-step" stories="loops">
# range/3, with a `by` expression argument
def range($init; $upto; $by):
    if $by > 0 then $init|while(. < $upto; . + $by)
  elif $by < 0 then $init|while(. > $upto; . + $by)
  else empty end;
</requirement>
<requirement name="first-generator" stories="loops">
def first(g): label $out | g | ., break $out;
</requirement>
<requirement name="isempty" stories="loops">
def isempty(g): first((g|false), true);
</requirement>
<requirement name="all" stories="loops,collection-builtins">
def all(generator; condition): isempty(generator|condition and empty);
def all(condition): all(.[]; condition);
def all: all(.[]; .);
</requirement>
<requirement name="any" stories="loops,collection-builtins">
def any(generator; condition): isempty(generator|condition or empty)|not;
def any(condition): any(.[]; condition);
def any: any(.[]; .);
</requirement>
<requirement name="nth-generator" stories="loops">
def nth($n; g):
  if $n < 0 then error("nth doesn't support negative indices")
  else first(skip($n; g)) end;
</requirement>
<requirement name="first-element" stories="collection-builtins">
def first: .[0];
</requirement>
<requirement name="last-element" stories="collection-builtins">
def last: .[-1];
</requirement>
<requirement name="nth-element" stories="collection-builtins">
def nth($n): .[$n];
</requirement>
<requirement name="combinations" stories="collection-builtins">
def combinations:
    if length == 0 then [] else
        .[0][] as $x
          | (.[1:] | combinations) as $y
          | [$x] + $y
    end;
def combinations(n):
    . as $dot
      | [range(n) | $dot]
      | combinations;
</requirement>
<requirement name="transpose" stories="collection-builtins">
# transpose a possibly jagged matrix, quickly;
# rows are padded with nulls so the result is always rectangular.
def transpose: [range(0; map(length)|max // 0) as $i | [.[][$i]]];
</requirement>
<requirement name="in" stories="collection-builtins">
def in(xs): . as $x | xs | has($x);
</requirement>
<requirement name="inside" stories="collection-builtins">
def inside(xs): . as $x | xs | contains($x);
</requirement>
<requirement name="repeat" stories="loops">
def repeat(exp):
     def _repeat:
         exp, _repeat;
     _repeat;
</requirement>
<requirement name="inputs" stories="io">
def inputs: try repeat(input) catch if .=="break" then empty else error end;
</requirement>
<requirement name="ascii-downcase" stories="strings">
# like ruby's downcase - only characters A to Z are affected
def ascii_downcase:
  explode | map( if 65 <= . and . <= 90 then . + 32  else . end) | implode;
</requirement>
<requirement name="ascii-upcase" stories="strings">
# like ruby's upcase - only characters a to z are affected
def ascii_upcase:
  explode | map( if 97 <= . and . <= 122 then . - 32  else . end) | implode;
</requirement>
<requirement name="truncate-stream" stories="traversal">
def truncate_stream(stream):
  . as $n | null | stream | . as $input | if (.[0]|length) > $n then setpath([0];$input[0][$n:]) else empty end;
</requirement>
<requirement name="fromstream" stories="traversal">
def fromstream(i): {x: null, e: false} as $init |
  # .x = object being built; .e = emit and reset state
  foreach i as $i ($init
  ; if .e then $init else . end
  | if $i|length == 2
    then setpath(["e"]; $i[0]|length==0) | setpath(["x"]+$i[0]; $i[1])
    else setpath(["e"]; $i[0]|length==1) end
  ; if .e then .x else empty end);
</requirement>
<requirement name="tostream" stories="traversal">
def tostream:
  path(def r: (.[]?|r), .; r) as $p |
  getpath($p) |
  reduce path(.[]?) as $q ([$p, .]; [$p+$q]);
</requirement>
<requirement name="walk" stories="traversal">
# Apply f to composite entities recursively, and to atoms
def walk(f):
  def w:
    if type == "object"
    then map_values(w)
    elif type == "array" then map(w)
    else .
    end
    | f;
  w;
</requirement>
<requirement name="pick" stories="paths">
# pathexps could be a stream of dot-paths
def pick(pathexps):
  . as $in
  | reduce path(pathexps) as $a (null;
      setpath($a; $in|getpath($a)) );
</requirement>
<requirement name="debug-messages" stories="io">
# ensure the output of debug(m1,m2) is kept together:
def debug(msgs): (msgs | debug | empty), .;
</requirement>
<requirement name="sql-index" stories="sql">
def INDEX(stream; idx_expr):
  reduce stream as $row ({}; .[$row|idx_expr|tostring] = $row);
def INDEX(idx_expr): INDEX(.[]; idx_expr);
</requirement>
<requirement name="sql-join" stories="sql">
def JOIN($idx; idx_expr):
  [.[] | [., $idx[idx_expr]]];
def JOIN($idx; stream; idx_expr):
  stream | [., $idx[idx_expr]];
def JOIN($idx; stream; idx_expr; join_expr):
  stream | [., $idx[idx_expr]] | join_expr;
</requirement>
<requirement name="sql-in" stories="sql">
def IN(s): any(s == .; .);
def IN(src; s): any(src == s; .);
</requirement>
<unattached story="foundation"/>
<unattached story="corpus-staging"/>
<unattached story="lexer"/>
<unattached story="parser"/>
<unattached story="core"/>
<unattached story="constructors"/>
<unattached story="operators"/>
<unattached story="bindings"/>
<unattached story="formats"/>
<unattached story="cli"/>
<unattached story="documentation"/>
<unattached story="scoped-integration"/>
<unattached story="terminal-verification"/>