テクノロジー · 実用ガイド
jq の cannot index string with string?filter を変える前に JSON shape を証明
jq input mode と各 path の type を保存し、証明済み mixed boundary だけを guard して rejects を保持します。

jq の object key lookup は string、array、number、boolean を受け取ると失敗します。generator は先に valid value を出力し、後の別 type で失敗できるため partial output と nonzero exit が同居します。
raw bytes、input mode、正確な filter を保存し path-type ledger を作ります。schema drift は失敗させ、正当な mixed collection だけを狭く guard します。
bytes、mode、filter を固定
input file、jq --version、完全な filter、shell quoting、upstream command、-R、-s、-n を保存します。-R は string、-s は array を作ります。
保存 file が JSON か検証し、成功 record と失敗 record を並べます。値を出した後の exit 5 も失敗です。
path-type ledger を作成
root と各 traversal step で type を実行します。RFC 8259 は object と array を分け、array の elements は同型でなくてもよいとします。
path、observed type、count を記録します。object の .[] は全 member values を出すため、次の .name が string に適用され得ます。
三つの shape failure を分離
wrong root traversal、mixed collection、stringified object を区別します。最後は再 parse 前に provenance 判断が必要です。
shell echo を authoritative bytes としません。quoting が内容を変え得るため、保存 file を直接読み producer schema と比較します。
証明済み boundary だけを guard
mixed collection が仕様なら type==object を選んで key を読み、他を path と type 付き reject ledger に残します。
広い try、catch、optional は empty で error を隠します。契約上許され reject count が計測される場合だけ使います。
output、reject、exit を証明
object、array、string、boolean、null、missing key、mixed array をテストし、accepted と rejected を input count に一致させます。
終了条件は mode、path types、output count、reject の説明と、必須 object が scalar になった時の nonzero failure です。
