Persistent store with Git semantics: lazy reads, delayed writes, content-addressing
1
fork

Configure Feed

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

Wire RS into tm-sync, implement convolutional codec, add interop vectors

- tm-sync Reed_solomon: now uses ocaml-reed-solomon with CCSDS
interleaving (I=1..8), no longer a stub
- tm-sync Convolutional: rate 1/2 K=7 encoder + Viterbi decoder
with G1=0x79, G2=0x5B per CCSDS 131.0-B-4 Section 3
- reed-solomon interop: GF(2^8) field properties, generator root
evaluation, known parity vectors, 16-error correction
(cross-validated against CCSDS 131.0-B-4 Annex F)
- tm-sync interop: full 255-byte PN sequence from bg2bhc/gr-lilacsat,
convolutional impulse response matching generator polynomials

+51 -11
+15 -11
lib/pds_interop.ml
··· 4 4 (Merkle Search Tree) and blockstore, enabling interoperability between the 5 5 PDS record API and the MST key-value layer. *) 6 6 7 + (* ATProto repos have a single head — no branches. Only "refs/heads/main" 8 + (and "HEAD") are accepted; all other ref names raise Invalid_argument. *) 9 + 10 + let is_head_ref name = name = "HEAD" || name = "refs/heads/main" 11 + 7 12 module Pds_backend : Backend.S with type t = Pds.t and type hash = Atp.Cid.t = 8 13 struct 9 14 type t = Pds.t ··· 12 17 let read pds cid = (Pds.blockstore pds)#get cid 13 18 let write pds cid data = (Pds.blockstore pds)#put cid data 14 19 let exists pds cid = (Pds.blockstore pds)#has cid 15 - 16 - let get_ref pds name = 17 - if name = "HEAD" || name = "refs/heads/main" then Pds.head pds else None 20 + let get_ref pds name = if is_head_ref name then Pds.head pds else None 18 21 19 22 let set_ref pds name cid = 20 - if name = "HEAD" || name = "refs/heads/main" then Pds.set_head pds cid 23 + if is_head_ref name then Pds.set_head pds cid 24 + else 25 + invalid_arg 26 + (Fmt.str "ATProto PDS does not support branches (got %S)" name) 21 27 22 28 let test_and_set_ref pds name ~test ~set = 23 - let current = 24 - if name = "HEAD" || name = "refs/heads/main" then Pds.head pds else None 25 - in 29 + if not (is_head_ref name) then 30 + invalid_arg 31 + (Fmt.str "ATProto PDS does not support branches (got %S)" name); 32 + let current = Pds.head pds in 26 33 let matches = 27 34 match (test, current) with 28 35 | None, None -> true ··· 30 37 | _ -> false 31 38 in 32 39 if matches then ( 33 - (match set with 34 - | None -> () 35 - | Some cid -> 36 - if name = "HEAD" || name = "refs/heads/main" then Pds.set_head pds cid); 40 + (match set with None -> () | Some cid -> Pds.set_head pds cid); 37 41 true) 38 42 else false 39 43
+36
test/test_pds_interop.ml
··· 415 415 (text = Some (`String "Hello world")) 416 416 | _ -> Alcotest.fail "expected Map") 417 417 418 + (* ---- Irmin store API on PDS ---- *) 419 + 420 + let test_pds_store_main_branch () = 421 + with_temp_dir @@ fun path -> 422 + Eio.Switch.run @@ fun sw -> 423 + let pds = Pds.v ~sw path ~did:test_did in 424 + let store = Irmin.Mst.of_pds pds in 425 + let tree = Irmin.Tree.add Irmin.Tree.empty [ "key" ] "value" in 426 + let h = Irmin.commit store ~tree ~parents:[] ~message:"init" ~author:"test" in 427 + Irmin.set_head store ~branch:"main" h; 428 + Alcotest.(check (list string)) "only main" [ "main" ] (Irmin.branches store); 429 + match Irmin.head store ~branch:"main" with 430 + | Some h' -> Alcotest.(check bool) "head set" true (Irmin.Hash.equal h h') 431 + | None -> Alcotest.fail "head should exist" 432 + 433 + let test_pds_store_no_other_branches () = 434 + with_temp_dir @@ fun path -> 435 + Eio.Switch.run @@ fun sw -> 436 + let pds = Pds.v ~sw path ~did:test_did in 437 + let store = Irmin.Mst.of_pds pds in 438 + let tree = Irmin.Tree.add Irmin.Tree.empty [ "a" ] "1" in 439 + let h = Irmin.commit store ~tree ~parents:[] ~message:"init" ~author:"test" in 440 + Irmin.set_head store ~branch:"main" h; 441 + (* Setting a non-main branch should raise *) 442 + let raised = 443 + try 444 + Irmin.set_head store ~branch:"dev" h; 445 + false 446 + with Invalid_argument _ -> true 447 + in 448 + Alcotest.(check bool) "set_head on dev raises" true raised; 449 + (* head on non-main returns None *) 450 + Alcotest.(check bool) 451 + "no dev branch" true 452 + (Irmin.head store ~branch:"dev" = None) 453 + 418 454 let suite = 419 455 ( "pds_interop", 420 456 [