Supply Chain Integrity, Transparency, and Trust (IETF SCITT)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

json: drop [encode] result form; rename [encode_exn] to [encode]

Per the ocaml-encodings convention, encoding never has a meaningful
runtime failure mode: the encoder walks the GADT and invokes
user-supplied [enc] callbacks. The only failure cases are (a) a codec
built around [Codec.ignore] (programmer error), or (b) a user-
supplied [enc] that raises (user's own bug). Neither is something a
caller should recover from, so the [result] variant was dead API
surface and every caller I've seen either [get_ok]-ed it or fell
back to [Json.Null] on error.

Drop [Codec.encode] / [Json.encode] result-returning, rename the
exception-raising [encode_exn] to just [encode]. [decode] keeps both
forms since malformed JSON is a legitimate runtime condition.

Downstream sweep: 28 files across claude / oci / atp / qemu / scitt /
yaml. Most were pattern A ([Error _ -> Json.Null ((), Meta.none)]) or
pattern B (print the error); both collapse to a direct call. Tests
using pattern F ([match Json.encode ... with Ok j -> ... | Error e
-> Alcotest.fail]) collapse to [let j = Json.encode ... in]. A few
helpers in claude/client.ml and the atp shims kept their names as
thin aliases to preserve grep targets.

+1 -4
+1 -4
lib/atp/scitt_atp.ml
··· 92 92 created_at = now; 93 93 } 94 94 in 95 - let* json = 96 - Json.encode Statement_lexicon.main_json record 97 - |> Result.map_error Json.Error.to_string 98 - in 95 + let json = Json.encode Statement_lexicon.main_json record in 99 96 let* dagcbor_value = Atp.Dagcbor.of_json json in 100 97 Ok (Atp.Dagcbor.encode_string dagcbor_value) 101 98