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

Configure Feed

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

irmin: codec-based schema with MIME names, Type.Id, and typed fields

Replace the GADT-shaped schema with a record-based codec carrying a
MIME-style name and a Type.Id witness. This unifies "schema" and
"content type" into one concept, modelled after IPLD codecs and HTTP
content negotiation.

API changes:
- 'a t now means "codec for blocks of value type 'a"
- node ~name ~dec ~enc ?merge ?rules () : children t
- opaque : H.block t (leaf, no navigation)
- map ~dec ~enc inner : transforms value type, keeps navigation
- fix : ('a t -> 'a t) -> 'a t (recursion)
- name, id (Type.Id witness) for runtime introspection
- ('a, 'b) field: typed accessor (path + expected codec)
- step (typed): cursor -> field -> 'b cursor option
- step_any (untyped): returns Step (codec, cursor) existential
- cast: recover typed cursor via Type.Id equality
- Step constructor now carries (codec, cursor) for type recovery
- step_result type renamed (was step) to avoid clash with val step

All backends declare a MIME name like "application/json",
"application/x-git-tree", "application/dag-cbor".

11 tests pass (6 schema + 5 tar), mst_proof verified.

+15 -9
+8 -4
lib/atp/scitt_atp.ml
··· 51 51 (* TODO: proper MST serialization *) 52 52 "" 53 53 54 - let mst_node rules = S.node ~dec:mst_parse ~enc:mst_serialize rules 54 + let mst_node rules = 55 + S.node ~name:"application/x-atp-mst" ~dec:mst_parse ~enc:mst_serialize ~rules 56 + () 57 + 55 58 let ( => ) = S.( => ) 56 59 let repo_schema = S.fix (fun _self -> mst_node [ "*" => S.opaque ]) 57 60 ··· 173 176 (* Produce inclusion proof *) 174 177 let proof, _value = 175 178 S.produce C.heap repo_schema tree_root (fun c -> 176 - match S.step c rk with 177 - | Some (S.Step leaf) -> (S.Step leaf, S.get_block leaf) 178 - | None -> (S.Step c, None)) 179 + match S.step_any c rk with 180 + | Some (S.Step (sc, leaf)) -> 181 + (S.Step (sc, leaf), S.get_block leaf) 182 + | None -> (S.Step (repo_schema, c), None)) 179 183 in 180 184 (* Encode proof as CBOR: [repo_key, [before, after, [[cid, block], ...]]] *) 181 185 let proof_cbor =
+7 -5
lib/proof.ml
··· 95 95 96 96 let repo_schema = 97 97 S.fix (fun _self -> 98 - S.node ~dec:mst_parse ~enc:mst_serialize [ "*" => S.opaque ]) 98 + S.node ~name:"application/x-atp-mst" ~dec:mst_parse ~enc:mst_serialize 99 + ~rules:[ "*" => S.opaque ] 100 + ()) 99 101 100 102 (** Decode a CBOR-encoded proof and verify via Schema.verify. *) 101 103 let verify_mst ~hash ~expected_leaf ~expected_repo_key ~root path = ··· 168 170 (* Verify by replaying the lookup *) 169 171 match 170 172 S.verify proof repo_schema (fun c -> 171 - match S.step c repo_key with 172 - | Some (S.Step leaf) -> 173 - (S.Step leaf, S.get_block leaf) 174 - | None -> (S.Step c, None)) 173 + match S.step_any c repo_key with 174 + | Some (S.Step (sc, leaf)) -> 175 + (S.Step (sc, leaf), S.get_block leaf) 176 + | None -> (S.Step (repo_schema, c), None)) 175 177 with 176 178 | Ok (Some dagcbor) -> ( 177 179 match extract_cose dagcbor with