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

Configure Feed

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

claude: complete Err -> Error module rename across call sites

Follow up to the module rename: update the remaining callers that
still referenced [Err] (library [claude.ml{,i}], [client.ml], the test
driver [test.ml]), and fix one stray [^ e] string concatenation in
hermest's CLI that needed [Json.Error.to_string e] now that
[Json.of_string] yields a structured error.

+122 -110
+106 -94
lexicons/atp_lexicon_scitt.ml
··· 2 2 3 3 (** Utility functions for resilient parsing. *) 4 4 module Filter = struct 5 - (** [filter_list jsont json_list] parses each element with [jsont], 5 + (** [filter_list codec items] parses each element with [codec], 6 6 returning only successfully parsed elements. Non-compliant records 7 7 are silently skipped. *) 8 - let filter_list (type a) (jsont : a Json.codec) (json_list : Json.t list) : a list = 9 - List.filter_map (fun json -> 10 - match Json.decode jsont json with 11 - | Ok v -> Some v 12 - | Error _ -> None 13 - ) json_list 8 + let filter_list (type a) (codec : a Json.codec) (items : Json.t list) 9 + : a list = 10 + List.filter_map 11 + (fun v -> 12 + match Json.decode codec v with 13 + | Ok v -> Some v 14 + | Error _ -> None) 15 + items 14 16 end 15 17 16 18 module Com = struct ··· 22 24 uri : string; 23 25 } 24 26 25 - let main_jsont = 26 - Json.Codec.Object.map ~kind:"Main" 27 - (fun _typ cid uri -> { cid; uri }) 28 - |> Json.Codec.Object.mem "$type" Json.Codec.string ~dec_absent:"com.atproto.repo.strongRef" ~enc:(fun _ -> "com.atproto.repo.strongRef") 29 - |> Json.Codec.Object.mem "cid" Json.Codec.string ~enc:(fun r -> r.cid) 30 - |> Json.Codec.Object.mem "uri" Json.Codec.string ~enc:(fun r -> r.uri) 31 - |> Json.Codec.Object.finish 27 + let main_json : main Json.codec = 28 + let open Json.Codec in 29 + Object.map ~kind:"Main" 30 + (fun _typ cid uri : main -> { cid; uri }) 31 + |> Object.mem "$type" string ~dec_absent:"com.atproto.repo.strongRef" ~enc:(fun _ -> "com.atproto.repo.strongRef") 32 + |> Object.mem "cid" string ~enc:(fun (r : main) -> r.cid) 33 + |> Object.mem "uri" string ~enc:(fun (r : main) -> r.uri) 34 + |> Object.finish 32 35 33 36 end 34 37 end ··· 47 50 subject : string; 48 51 } 49 52 50 - let main_jsont = 51 - Json.Codec.Object.map ~kind:"Main" 52 - (fun _typ content_type cose created_at issuer payload_digest subject -> { content_type; cose; created_at; issuer; payload_digest; subject }) 53 - |> Json.Codec.Object.mem "$type" Json.Codec.string ~dec_absent:"space.run.scitt.statement" ~enc:(fun _ -> "space.run.scitt.statement") 54 - |> Json.Codec.Object.mem "contentType" Json.Codec.string ~enc:(fun r -> r.content_type) 55 - |> Json.Codec.Object.mem "cose" Json.Codec.binary_string ~enc:(fun r -> r.cose) 56 - |> Json.Codec.Object.mem "createdAt" Json.Codec.string ~enc:(fun r -> r.created_at) 57 - |> Json.Codec.Object.mem "issuer" Json.Codec.string ~enc:(fun r -> r.issuer) 58 - |> Json.Codec.Object.opt_mem "payloadDigest" Json.Codec.string ~enc:(fun r -> r.payload_digest) 59 - |> Json.Codec.Object.mem "subject" Json.Codec.string ~enc:(fun r -> r.subject) 60 - |> Json.Codec.Object.finish 53 + let main_json : main Json.codec = 54 + let open Json.Codec in 55 + Object.map ~kind:"Main" 56 + (fun _typ content_type cose created_at issuer payload_digest subject : main -> { content_type; cose; created_at; issuer; payload_digest; subject }) 57 + |> Object.mem "$type" string ~dec_absent:"space.run.scitt.statement" ~enc:(fun _ -> "space.run.scitt.statement") 58 + |> Object.mem "contentType" string ~enc:(fun (r : main) -> r.content_type) 59 + |> Object.mem "cose" binary_string ~enc:(fun (r : main) -> r.cose) 60 + |> Object.mem "createdAt" string ~enc:(fun (r : main) -> r.created_at) 61 + |> Object.mem "issuer" string ~enc:(fun (r : main) -> r.issuer) 62 + |> Object.opt_mem "payloadDigest" string ~enc:(fun (r : main) -> r.payload_digest) 63 + |> Object.mem "subject" string ~enc:(fun (r : main) -> r.subject) 64 + |> Object.finish 61 65 62 66 end 63 67 module RegisterStatement = struct 64 68 type input = unit 65 - let input_jsont = Json.Codec.ignore 69 + let input_json = Json.Codec.ignore 66 70 67 71 type output = { 68 72 receipt : string; ··· 72 76 tree_size : int; 73 77 } 74 78 75 - let output_jsont = 76 - Json.Codec.Object.map ~kind:"Output" 77 - (fun _typ receipt receipt_uri root statement_uri tree_size -> { receipt; receipt_uri; root; statement_uri; tree_size }) 78 - |> Json.Codec.Object.mem "$type" Json.Codec.string ~dec_absent:"space.run.scitt.registerStatement#output" ~enc:(fun _ -> "space.run.scitt.registerStatement#output") 79 - |> Json.Codec.Object.mem "receipt" Json.Codec.binary_string ~enc:(fun r -> r.receipt) 80 - |> Json.Codec.Object.opt_mem "receiptUri" Json.Codec.string ~enc:(fun r -> r.receipt_uri) 81 - |> Json.Codec.Object.mem "root" Json.Codec.binary_string ~enc:(fun r -> r.root) 82 - |> Json.Codec.Object.opt_mem "statementUri" Json.Codec.string ~enc:(fun r -> r.statement_uri) 83 - |> Json.Codec.Object.mem "treeSize" Json.Codec.int ~enc:(fun r -> r.tree_size) 84 - |> Json.Codec.Object.finish 79 + let output_json : output Json.codec = 80 + let open Json.Codec in 81 + Object.map ~kind:"Output" 82 + (fun _typ receipt receipt_uri root statement_uri tree_size : output -> { receipt; receipt_uri; root; statement_uri; tree_size }) 83 + |> Object.mem "$type" string ~dec_absent:"space.run.scitt.registerStatement#output" ~enc:(fun _ -> "space.run.scitt.registerStatement#output") 84 + |> Object.mem "receipt" binary_string ~enc:(fun (r : output) -> r.receipt) 85 + |> Object.opt_mem "receiptUri" string ~enc:(fun (r : output) -> r.receipt_uri) 86 + |> Object.mem "root" binary_string ~enc:(fun (r : output) -> r.root) 87 + |> Object.opt_mem "statementUri" string ~enc:(fun (r : output) -> r.statement_uri) 88 + |> Object.mem "treeSize" int ~enc:(fun (r : output) -> r.tree_size) 89 + |> Object.finish 85 90 86 91 end 87 92 module Receipt = struct ··· 94 99 vds_algorithm : int option; 95 100 } 96 101 97 - let main_jsont = 98 - Json.Codec.Object.map ~kind:"Main" 99 - (fun _typ cose created_at root statement tree_size vds_algorithm -> { cose; created_at; root; statement; tree_size; vds_algorithm }) 100 - |> Json.Codec.Object.mem "$type" Json.Codec.string ~dec_absent:"space.run.scitt.receipt" ~enc:(fun _ -> "space.run.scitt.receipt") 101 - |> Json.Codec.Object.mem "cose" Json.Codec.binary_string ~enc:(fun r -> r.cose) 102 - |> Json.Codec.Object.mem "createdAt" Json.Codec.string ~enc:(fun r -> r.created_at) 103 - |> Json.Codec.Object.mem "root" Json.Codec.binary_string ~enc:(fun r -> r.root) 104 - |> Json.Codec.Object.mem "statement" Com.Atproto.Repo.StrongRef.main_jsont ~enc:(fun r -> r.statement) 105 - |> Json.Codec.Object.opt_mem "treeSize" Json.Codec.int ~enc:(fun r -> r.tree_size) 106 - |> Json.Codec.Object.opt_mem "vdsAlgorithm" Json.Codec.int ~enc:(fun r -> r.vds_algorithm) 107 - |> Json.Codec.Object.finish 102 + let main_json : main Json.codec = 103 + let open Json.Codec in 104 + Object.map ~kind:"Main" 105 + (fun _typ cose created_at root statement tree_size vds_algorithm : main -> { cose; created_at; root; statement; tree_size; vds_algorithm }) 106 + |> Object.mem "$type" string ~dec_absent:"space.run.scitt.receipt" ~enc:(fun _ -> "space.run.scitt.receipt") 107 + |> Object.mem "cose" binary_string ~enc:(fun (r : main) -> r.cose) 108 + |> Object.mem "createdAt" string ~enc:(fun (r : main) -> r.created_at) 109 + |> Object.mem "root" binary_string ~enc:(fun (r : main) -> r.root) 110 + |> Object.mem "statement" Com.Atproto.Repo.StrongRef.main_json ~enc:(fun (r : main) -> r.statement) 111 + |> Object.opt_mem "treeSize" int ~enc:(fun (r : main) -> r.tree_size) 112 + |> Object.opt_mem "vdsAlgorithm" int ~enc:(fun (r : main) -> r.vds_algorithm) 113 + |> Object.finish 108 114 109 115 end 110 116 module Defs = struct ··· 115 121 root : string; 116 122 } 117 123 118 - let inclusion_proof_jsont = 119 - Json.Codec.Object.map ~kind:"Inclusion_proof" 120 - (fun _typ index leaf_hash path root -> { index; leaf_hash; path; root }) 121 - |> Json.Codec.Object.mem "$type" Json.Codec.string ~dec_absent:"space.run.scitt.defs#inclusionProof" ~enc:(fun _ -> "space.run.scitt.defs#inclusionProof") 122 - |> Json.Codec.Object.mem "index" Json.Codec.string ~enc:(fun r -> r.index) 123 - |> Json.Codec.Object.mem "leafHash" Json.Codec.binary_string ~enc:(fun r -> r.leaf_hash) 124 - |> Json.Codec.Object.mem "path" (Json.Codec.list Json.Codec.binary_string) ~enc:(fun r -> r.path) 125 - |> Json.Codec.Object.mem "root" Json.Codec.binary_string ~enc:(fun r -> r.root) 126 - |> Json.Codec.Object.finish 124 + let inclusion_proof_json : inclusion_proof Json.codec = 125 + let open Json.Codec in 126 + Object.map ~kind:"Inclusion_proof" 127 + (fun _typ index leaf_hash path root : inclusion_proof -> { index; leaf_hash; path; root }) 128 + |> Object.mem "$type" string ~dec_absent:"space.run.scitt.defs#inclusionProof" ~enc:(fun _ -> "space.run.scitt.defs#inclusionProof") 129 + |> Object.mem "index" string ~enc:(fun (r : inclusion_proof) -> r.index) 130 + |> Object.mem "leafHash" binary_string ~enc:(fun (r : inclusion_proof) -> r.leaf_hash) 131 + |> Object.mem "path" (list binary_string) ~enc:(fun (r : inclusion_proof) -> r.path) 132 + |> Object.mem "root" binary_string ~enc:(fun (r : inclusion_proof) -> r.root) 133 + |> Object.finish 127 134 128 135 type transparent_statement = { 129 136 receipts : string list; 130 137 statement : string; 131 138 } 132 139 133 - let transparent_statement_jsont = 134 - Json.Codec.Object.map ~kind:"Transparent_statement" 135 - (fun _typ receipts statement -> { receipts; statement }) 136 - |> Json.Codec.Object.mem "$type" Json.Codec.string ~dec_absent:"space.run.scitt.defs#transparentStatement" ~enc:(fun _ -> "space.run.scitt.defs#transparentStatement") 137 - |> Json.Codec.Object.mem "receipts" (Json.Codec.list Json.Codec.binary_string) ~enc:(fun r -> r.receipts) 138 - |> Json.Codec.Object.mem "statement" Json.Codec.binary_string ~enc:(fun r -> r.statement) 139 - |> Json.Codec.Object.finish 140 + let transparent_statement_json : transparent_statement Json.codec = 141 + let open Json.Codec in 142 + Object.map ~kind:"Transparent_statement" 143 + (fun _typ receipts statement : transparent_statement -> { receipts; statement }) 144 + |> Object.mem "$type" string ~dec_absent:"space.run.scitt.defs#transparentStatement" ~enc:(fun _ -> "space.run.scitt.defs#transparentStatement") 145 + |> Object.mem "receipts" (list binary_string) ~enc:(fun (r : transparent_statement) -> r.receipts) 146 + |> Object.mem "statement" binary_string ~enc:(fun (r : transparent_statement) -> r.statement) 147 + |> Object.finish 140 148 141 149 end 142 150 module GetStatement = struct ··· 145 153 uri : string option; 146 154 } 147 155 148 - let params_jsont = 149 - Json.Codec.Object.map ~kind:"Params" 150 - (fun subject uri -> { 156 + let params_json : params Json.codec = 157 + let open Json.Codec in 158 + Object.map ~kind:"Params" 159 + (fun subject uri : params -> { 151 160 subject; 152 161 uri; 153 162 }) 154 - |> Json.Codec.Object.opt_mem "subject" Json.Codec.string 155 - ~enc:(fun r -> r.subject) 156 - |> Json.Codec.Object.opt_mem "uri" Json.Codec.string 157 - ~enc:(fun r -> r.uri) 158 - |> Json.Codec.Object.finish 163 + |> Object.opt_mem "subject" string 164 + ~enc:(fun (r : params) -> r.subject) 165 + |> Object.opt_mem "uri" string 166 + ~enc:(fun (r : params) -> r.uri) 167 + |> Object.finish 159 168 160 169 type output = { 161 170 receipt : Receipt.main option; ··· 163 172 transparent_statement : Defs.transparent_statement option; 164 173 } 165 174 166 - let output_jsont = 167 - Json.Codec.Object.map ~kind:"Output" 168 - (fun _typ receipt statement transparent_statement -> { receipt; statement; transparent_statement }) 169 - |> Json.Codec.Object.mem "$type" Json.Codec.string ~dec_absent:"space.run.scitt.getStatement#output" ~enc:(fun _ -> "space.run.scitt.getStatement#output") 170 - |> Json.Codec.Object.opt_mem "receipt" Receipt.main_jsont ~enc:(fun r -> r.receipt) 171 - |> Json.Codec.Object.mem "statement" Statement.main_jsont ~enc:(fun r -> r.statement) 172 - |> Json.Codec.Object.opt_mem "transparentStatement" Defs.transparent_statement_jsont ~enc:(fun r -> r.transparent_statement) 173 - |> Json.Codec.Object.finish 175 + let output_json : output Json.codec = 176 + let open Json.Codec in 177 + Object.map ~kind:"Output" 178 + (fun _typ receipt statement transparent_statement : output -> { receipt; statement; transparent_statement }) 179 + |> Object.mem "$type" string ~dec_absent:"space.run.scitt.getStatement#output" ~enc:(fun _ -> "space.run.scitt.getStatement#output") 180 + |> Object.opt_mem "receipt" Receipt.main_json ~enc:(fun (r : output) -> r.receipt) 181 + |> Object.mem "statement" Statement.main_json ~enc:(fun (r : output) -> r.statement) 182 + |> Object.opt_mem "transparentStatement" Defs.transparent_statement_json ~enc:(fun (r : output) -> r.transparent_statement) 183 + |> Object.finish 174 184 175 185 end 176 186 module GetReceipt = struct ··· 179 189 uri : string option; 180 190 } 181 191 182 - let params_jsont = 183 - Json.Codec.Object.map ~kind:"Params" 184 - (fun statement uri -> { 192 + let params_json : params Json.codec = 193 + let open Json.Codec in 194 + Object.map ~kind:"Params" 195 + (fun statement uri : params -> { 185 196 statement; 186 197 uri; 187 198 }) 188 - |> Json.Codec.Object.opt_mem "statement" Json.Codec.string 189 - ~enc:(fun r -> r.statement) 190 - |> Json.Codec.Object.opt_mem "uri" Json.Codec.string 191 - ~enc:(fun r -> r.uri) 192 - |> Json.Codec.Object.finish 199 + |> Object.opt_mem "statement" string 200 + ~enc:(fun (r : params) -> r.statement) 201 + |> Object.opt_mem "uri" string 202 + ~enc:(fun (r : params) -> r.uri) 203 + |> Object.finish 193 204 194 205 type output = { 195 206 inclusion_proof : Defs.inclusion_proof option; 196 207 receipt : Receipt.main; 197 208 } 198 209 199 - let output_jsont = 200 - Json.Codec.Object.map ~kind:"Output" 201 - (fun _typ inclusion_proof receipt -> { inclusion_proof; receipt }) 202 - |> Json.Codec.Object.mem "$type" Json.Codec.string ~dec_absent:"space.run.scitt.getReceipt#output" ~enc:(fun _ -> "space.run.scitt.getReceipt#output") 203 - |> Json.Codec.Object.opt_mem "inclusionProof" Defs.inclusion_proof_jsont ~enc:(fun r -> r.inclusion_proof) 204 - |> Json.Codec.Object.mem "receipt" Receipt.main_jsont ~enc:(fun r -> r.receipt) 205 - |> Json.Codec.Object.finish 210 + let output_json : output Json.codec = 211 + let open Json.Codec in 212 + Object.map ~kind:"Output" 213 + (fun _typ inclusion_proof receipt : output -> { inclusion_proof; receipt }) 214 + |> Object.mem "$type" string ~dec_absent:"space.run.scitt.getReceipt#output" ~enc:(fun _ -> "space.run.scitt.getReceipt#output") 215 + |> Object.opt_mem "inclusionProof" Defs.inclusion_proof_json ~enc:(fun (r : output) -> r.inclusion_proof) 216 + |> Object.mem "receipt" Receipt.main_json ~enc:(fun (r : output) -> r.receipt) 217 + |> Object.finish 206 218 207 219 end 208 220 end
+12 -12
lexicons/atp_lexicon_scitt.mli
··· 5 5 (** Utility functions for resilient parsing. *) 6 6 module Filter : sig 7 7 val filter_list : 'a Json.codec -> Json.t list -> 'a list 8 - (** [filter_list jsont json_list] parses each element with [jsont], 8 + (** [filter_list json json_list] parses each element with [json], 9 9 returning only successfully parsed elements. Non-compliant records 10 10 are silently skipped. *) 11 11 end ··· 22 22 } 23 23 24 24 (** Jsont codec for {!type:main}. *) 25 - val main_jsont : main Json.codec 25 + val main_json : main Json.codec 26 26 27 27 end 28 28 end ··· 44 44 } 45 45 46 46 (** Jsont codec for {!type:main}. *) 47 - val main_jsont : main Json.codec 47 + val main_json : main Json.codec 48 48 49 49 end 50 50 module RegisterStatement : sig ··· 53 53 (** COSE_Sign1 encoded signed statement. *) 54 54 55 55 type input = unit 56 - val input_jsont : input Json.codec 56 + val input_json : input Json.codec 57 57 58 58 59 59 type output = { ··· 65 65 } 66 66 67 67 (** Jsont codec for {!type:output}. *) 68 - val output_jsont : output Json.codec 68 + val output_json : output Json.codec 69 69 70 70 end 71 71 module Receipt : sig ··· 81 81 } 82 82 83 83 (** Jsont codec for {!type:main}. *) 84 - val main_jsont : main Json.codec 84 + val main_json : main Json.codec 85 85 86 86 end 87 87 module Defs : sig ··· 95 95 } 96 96 97 97 (** Jsont codec for {!type:inclusion_proof}. *) 98 - val inclusion_proof_jsont : inclusion_proof Json.codec 98 + val inclusion_proof_json : inclusion_proof Json.codec 99 99 100 100 (** A signed statement bundled with its receipts — everything needed for offline verification. *) 101 101 ··· 105 105 } 106 106 107 107 (** Jsont codec for {!type:transparent_statement}. *) 108 - val transparent_statement_jsont : transparent_statement Json.codec 108 + val transparent_statement_json : transparent_statement Json.codec 109 109 110 110 end 111 111 module GetStatement : sig ··· 118 118 } 119 119 120 120 (** Jsont codec for {!type:params}. *) 121 - val params_jsont : params Json.codec 121 + val params_json : params Json.codec 122 122 123 123 124 124 type output = { ··· 128 128 } 129 129 130 130 (** Jsont codec for {!type:output}. *) 131 - val output_jsont : output Json.codec 131 + val output_json : output Json.codec 132 132 133 133 end 134 134 module GetReceipt : sig ··· 141 141 } 142 142 143 143 (** Jsont codec for {!type:params}. *) 144 - val params_jsont : params Json.codec 144 + val params_json : params Json.codec 145 145 146 146 147 147 type output = { ··· 150 150 } 151 151 152 152 (** Jsont codec for {!type:output}. *) 153 - val output_jsont : output Json.codec 153 + val output_json : output Json.codec 154 154 155 155 end 156 156 end
+1 -1
lib/atp/scitt_atp.ml
··· 110 110 | None -> String.make 32 '\x00' 111 111 112 112 let err_duplicate key = Error ("duplicate key: " ^ key) 113 - let err_encoding e = Error ("encoding error: " ^ Json.Error.to_string e) 113 + let err_encoding e = Error ("encoding error: " ^ e) 114 114 115 115 let repo_key_of_vds_key key = 116 116 match String.index_opt key '/' with
+1 -1
lib/vds.ml
··· 617 617 | (key, value) :: rest -> ( 618 618 match append vds ~key ~value with 619 619 | Ok _ -> go rest 620 - | Error e -> Error ("import: " ^ Json.Error.to_string e)) 620 + | Error e -> Error ("import: " ^ e)) 621 621 in 622 622 let* () = go entries in 623 623 (* Verify root integrity if present in export *)
+1 -1
test/test_scitt.ml
··· 1337 1337 let decode_key_exn hex = 1338 1338 match X509.Public_key.decode_der (hex_to_raw hex) with 1339 1339 | Ok k -> k 1340 - | Error (`Msg e) -> Alcotest.failf "decode key: %s" (Json.Error.to_string e) 1340 + | Error (`Msg e) -> Alcotest.failf "decode key: %s" e 1341 1341 1342 1342 let test_roundtrip_decode_verify () = 1343 1343 let transparent_bytes = hex_to_raw interop_transparent_hex in
+1 -1
test/test_vds.ml
··· 43 43 Scitt.Vds_rfc9162.import exported ~create:(fun ~hash () -> 44 44 Scitt.Vds_rfc9162.in_memory ~hash ()) 45 45 with 46 - | Error e -> Alcotest.failf "import failed: %s" (Json.Error.to_string e) 46 + | Error e -> Alcotest.failf "import failed: %s" e 47 47 | Ok imported -> 48 48 Alcotest.(check int) 49 49 "size preserved" original_size (Scitt.vds_size imported);