Crdt
crdt · API reference
CRDT - OCaml CRDT library compatible with json-joy
This library implements the JSON CRDT specification from json-joy, providing:
- JSON CRDT document model (7 node types)
- JSON CRDT Patch operations (18 opcodes)
- Multiple codec formats (verbose, compact, binary)
- Full ClockVector support
- JSON-Rx RPC for real-time synchronization
Getting started
Most applications use Model, Model_api, Value, Model_codec, and Patch_codec_binary:
open Crdt
let model = Model.create 1_000_001
let api = Model_api.create model
let patch =
match Model_api.obj api "/" with
| None -> failwith "root is not editable as an object"
| Some obj ->
let _ =
Model_api.obj_set obj ~key:"title" ~value:(Value.String "Notebook")
in
let _ =
Model_api.obj_set obj ~key:"done" ~value:(Value.Bool false)
in
Model_api.commit api
let view = Model.view model
let snapshot = Model_codec.Binary.encode model
let patch_bytes = Option.map Patch_codec_binary.encode patchModel_api.commit applies pending local edits to the model and returns the generated patch. Send that patch to peers, decode it there, and apply it with Model.apply. Use Model_api.flush when you want the patch but do not want to apply it locally.
Complete public API
The library currently exposes implementation modules directly. The lists below document every public module, type, value, function, and public constructor exposed through open Crdt. Odoc also renders the inferred signatures for each module.
Value
Value is the runtime value tree used for document views, constants, RPC payloads, and codec boundaries.
Types and constructors: Value.t, Null, Undefined, Bool, Int, Float, String, Bytes, Array, Object, Timestamp_ref.
Values and functions: Value.equal, Value.compare, Value.null, Value.undefined, Value.bool, Value.int, Value.float, Value.string, Value.bytes, Value.array, Value.obj, Value.timestamp_ref, Value.is_null, Value.is_undefined, Value.is_bool, Value.is_int, Value.is_float, Value.is_string, Value.is_bytes, Value.is_array, Value.is_object, Value.is_timestamp_ref, Value.to_bool, Value.to_int, Value.to_float, Value.to_string_opt, Value.to_bytes, Value.to_array, Value.to_object, Value.to_timestamp_ref, Value.pp, Value.to_string, Value.type_name.
Example:
let user = Value.obj [ "name", Value.string "Ada"; "age", Value.int 36 ]
let rendered = Value.to_string userValue_codec
Value_codec converts Value.t to and from JSON.
Types: Value_codec.json. Values and functions: Value_codec.to_json, Value_codec.of_json, Value_codec.encode, Value_codec.encode_pretty, Value_codec.decode.
Example:
match Value_codec.decode "{\"ok\":true}" with
| Ok value -> value
| Error msg -> failwith msgPointer
Pointer implements RFC 6901 JSON Pointer paths over Value.t.
Types: Pointer.t. Values and functions: Pointer.empty, Pointer.of_string, Pointer.to_string, Pointer.append, Pointer.parent, Pointer.last, Pointer.length, Pointer.is_root, Pointer.concat, Pointer.resolve, Pointer.pp, Pointer.equal, Pointer.compare, Pointer.parse, Pointer.segments.
Example:
let ptr = Pointer.parse "/profile/name"
let name = Pointer.resolve ptr document_valueClock and Session
Clock provides logical timestamps and vector clocks.
Types: Clock.timestamp, Clock.timespan, Clock.logical_clock, Clock.clock_vector. Values and functions: Clock.compare_ts, Clock.equal_ts, Clock.timestamp, Clock.timespan, Clock.contains, Clock.timespan_end, Clock.create_clock, Clock.tick, Clock.create_vector, Clock.observe, Clock.fork, Clock.clone.
Session contains session ID constants and predicates. Values and functions: Session.system, Session.server, Session.global, Session.local, Session.max_id, Session.is_valid, Session.is_reserved, Session.is_user. Use IDs satisfying Session.is_user for normal replicas.
Example:
let clock = Clock.create_vector 42
let id = Clock.tick clock
Clock.observe clock { Clock.sid = 7; time = 10 }Op
Op defines JSON CRDT operation payloads.
Types: Op.timestamp, Op.timespan, Op.obj_entry, Op.new_con, Op.new_val, Op.new_obj, Op.new_vec, Op.new_str, Op.new_bin, Op.new_arr, Op.ins_val, Op.ins_obj, Op.ins_vec, Op.ins_str, Op.ins_bin, Op.ins_arr, Op.upd_arr, Op.del, Op.nop, Op.op_data, Op.opcode, Op.t.
Operation constructors: Op_new_con, Op_new_val, Op_new_obj, Op_new_vec, Op_new_str, Op_new_bin, Op_new_arr, Op_ins_val, Op_ins_obj, Op_ins_vec, Op_ins_str, Op_ins_bin, Op_ins_arr, Op_upd_arr, Op_del, Op_nop. Opcode constructors: New_con, New_val, New_obj, New_vec, New_str, New_bin, New_arr, Ins_val, Ins_obj, Ins_vec, Ins_str, Ins_bin, Ins_arr, Upd_arr, Del, Nop.
Values and functions: Op.opcode_to_int, Op.int_to_opcode, Op.opcode_of_op, Op.opcode_name, Op.opcode_of_name, Op.op_name, Op.id_span, Op.make_new_con, Op.make_new_val, Op.make_new_obj, Op.make_new_vec, Op.make_new_str, Op.make_new_bin, Op.make_new_arr, Op.make_ins_val, Op.make_ins_obj, Op.make_ins_vec, Op.make_ins_str, Op.make_ins_bin, Op.make_ins_arr, Op.make_upd_arr, Op.make_del, Op.make_nop, Op.name.
Example:
let op = Op.make_new_con (Value.String "hello")
let span = Op.id_span opPatch and Patch_builder
Patch.t is an ordered batch of operations sharing a starting timestamp.
Types: Patch.t, Patch.batch. Values and functions: Patch.empty, Patch.create, Patch.singleton, Patch.span, Patch.length, Patch.is_empty, Patch.end_id, Patch.op_id_at, Patch.add, Patch.add_all, Patch.prepend, Patch.iter_with_id, Patch.fold_with_id, Patch.map, Patch.filter, Patch.slice, Patch.split_at, Patch.rebase, Patch.concat, Patch.empty_batch, Patch.batch_of_list, Patch.add_to_batch, Patch.batch_span, Patch.batch_length, Patch.batch_iter_with_id, Patch.pp, Patch.to_string.
Patch_builder is a mutable helper for constructing patches from a vector clock. Prefer Model_api for common document edits.
Types: Patch_builder.t. Values and functions: Patch_builder.create, Patch_builder.reset, Patch_builder.ensure_start_id, Patch_builder.add_op, Patch_builder.flush, Patch_builder.flush_or_empty, Patch_builder.new_con, Patch_builder.new_val, Patch_builder.new_obj, Patch_builder.new_vec, Patch_builder.new_str, Patch_builder.new_bin, Patch_builder.new_arr, Patch_builder.ins_val, Patch_builder.ins_obj, Patch_builder.ins_vec, Patch_builder.ins_str, Patch_builder.ins_bin, Patch_builder.ins_arr, Patch_builder.upd_arr, Patch_builder.del, Patch_builder.nop, Patch_builder.pending_count, Patch_builder.has_pending, Patch_builder.current_time, Patch_builder.session_id, Patch_builder.next_op_id.
Example:
let patch = Patch.singleton ~id:(Clock.timestamp 10 0) (Op.make_new_obj ())
Patch.iter_with_id
(fun id op ->
Format.printf "%d.%d %s\n" id.Clock.sid id.time (Op.op_name op))
patchNode and Rga
Node defines CRDT nodes. Application code usually reads Model.view instead of manipulating nodes directly.
Types: Node.node_type, Node.rga_chunk, Node.con_node, Node.val_node, Node.obj_entry, Node.obj_node, Node.vec_slot, Node.vec_node, Node.arr_chunk, Node.arr_node, Node.str_node, Node.str_chunk, Node.bin_chunk, Node.bin_node, Node.t. Node variants: Node_con, Node_val, Node_obj, Node_vec, Node_arr, Node_str, Node_bin.
Values and functions: Node.type_name, Node.id, Node.node_type, Node.name, Node.make_con, Node.make_val, Node.make_obj, Node.ordered_obj_entries, Node.obj_entries, Node.find_obj_key, Node.make_vec, Node.make_arr, Node.arr_chunks, Node.arr_values, Node.arr_last_id, Node.arr_find_position, Node.arr_find_spans, Node.arr_length, Node.make_str, Node.make_bin, Node.str_chunk_of_string, Node.materialize_str_chunk, Node.split_str_chunk, Node.str_chunk_span, Node.utf16_offset_to_str_chunk_byte, Node.split_str_chunk_utf16, Node.str_chunks, Node.str_last_id, Node.str_find_position, Node.str_find_spans, Node.str_length, Node.bin_chunk_of_bytes, Node.empty_bin_chunk, Node.materialize_bin_chunk, Node.split_bin_chunk, Node.bin_chunk_span, Node.make_str_with_rga, Node.make_bin_with_rga, Node.bin_chunks, Node.bin_last_id, Node.bin_find_position, Node.bin_find_spans, Node.bin_length, Node.string_view, Node.bytes_view, Node.view, Node.set_val, Node.set_obj_key, Node.set_vec_slot, Node.insert_str, Node.insert_bin, Node.insert_arr, Node.insert_arr_values, Node.seq_contains, Node.delete_range, Node.pp, Node.to_string.
Rga implements the replicated growable array used by array, string, and binary nodes. Types: Rga.chunk, Rga.t, Rga.insert_pos. Values and functions: Rga.consolidate, Rga.chunk_count, Rga.chunk_at, Rga.append_chunk, Rga.insert_chunk_at, Rga.insert_two_chunks_at, Rga.replace_chunks, Rga.empty, Rga.copy, Rga.singleton, Rga.from_chunks, Rga.is_empty, Rga.total_span, Rga.visible_span, Rga.last_id, Rga.find_chunk_containing, Rga.contains, Rga.compare_for_rga, Rga.chunk_contains_ts, Rga.find_insert_position, Rga.is_append_position, Rga.insert_with_split, Rga.insert, Rga.split_chunk_at, Rga.apply_deletes_to_chunk, Rga.process_single_chunk, Rga.span_overlaps_chunk, Rga.prepend_single_delete, Rga.find_single_overlapping_chunk, Rga.remember_overlap, Rga.find_first_overlapping_chunk_forward, Rga.find_first_overlapping_chunk_reverse, Rga.find_first_overlapping_chunk_near, Rga.find_first_overlapping_chunk, Rga.replace_single_chunk, Rga.delete, Rga.iter, Rga.iter_visible, Rga.fold, Rga.fold_visible, Rga.to_list, Rga.to_visible_list, Rga.utf16_offset_to_byte, Rga.split_string, Rga.split_bytes, Rga.split_single, Rga.split_list, Rga.string_span, Rga.bytes_span, Rga.element_span, Rga.list_span, Rga.insert_string, Rga.insert_bytes, Rga.insert_element, Rga.insert_elements, Rga.delete_string, Rga.delete_bytes, Rga.delete_elements, Rga.delete_element_lists, Rga.iter_string_chunks, Rga.string_byte_length, Rga.write_string_to_bytes, Rga.write_string_to_bigstring, Rga.view_string, Rga.bytes_length, Rga.write_bytes_to_bytes, Rga.view_bytes, Rga.view_elements, Rga.visible_length, Rga.find_last_id, Rga.find_position_string, Rga.find_position_bytes, Rga.find_position_arr, Rga.find_spans_string, Rga.find_spans_bytes, Rga.find_spans_arr, Rga.pp_chunk, Rga.pp.
Model
Model is the CRDT document container. It owns the vector clock, root node, and timestamp-indexed node table.
Types: Model.NodeIndex, Model.t. Values and functions: Model.root_id, Model.create, Model.create_at, Model.get_node, Model.add_node, Model.has_node, Model.nodes, Model.node_count, Model.copy_index, Model.clock, Model.session_id, Model.current_time, Model.tick, Model.tick_n, Model.observe, Model.resolve_ref, Model.view_node, Model.view, Model.fork, Model.clone, Model.new_con, Model.new_val, Model.new_obj, Model.new_vec, Model.new_arr, Model.new_str, Model.new_bin, Model.set_root, Model.root_node, Model.pp, Model.to_string, Model.rga_after, Model.apply_op, Model.apply, Model.apply_batch, Model.copy_node, Model.deep_clone, Model.observe_remote_clock, Model.rga_coverage, Model.missing_intervals, Model.merge_rga, Model.str_slice, Model.list_slice, Model.merge_node, Model.absorb, Model.merge.
Example:
let alice = Model.create 1
let bob = Model.fork alice 2
Option.iter (Model.apply bob) patch_from_alice;
let converged = Model.merge alice bobModel_api
Model_api is the high-level editing API. It records local edits and returns patches for replication.
Types: Model_api.t, Model_api.path_result, Model_api.obj_proxy, Model_api.str_proxy, Model_api.arr_proxy, Model_api.bin_proxy, Model_api.vec_proxy. Values and functions: Model_api.create, Model_api.reset, Model_api.flush, Model_api.commit, Model_api.has_pending, Model_api.pending_count, Model_api.current_time, Model_api.session_id, Model_api.model, Model_api.resolve_path, Model_api.get, Model_api.get_value, Model_api.view, Model_api.next_id, Model_api.add_const, Model_api.set_root, Model_api.obj, Model_api.obj_set, Model_api.obj_delete, Model_api.obj_get, Model_api.obj_keys, Model_api.str, Model_api.str_insert, Model_api.str_append, Model_api.str_delete, Model_api.str_value, Model_api.str_length, Model_api.arr, Model_api.arr_insert, Model_api.arr_push, Model_api.arr_delete, Model_api.arr_length, Model_api.bin, Model_api.bin_insert, Model_api.bin_append, Model_api.bin_delete, Model_api.bin_value, Model_api.bin_length, Model_api.vec, Model_api.vec_set, Model_api.vec_get, Model_api.view_document, Model_api.pp_document.
Example:
let model = Model.create 100
let api = Model_api.create model
Model_api.set_root api (Value.Array []);
ignore (Model_api.commit api);
match Model_api.arr api "/" with
| Some arr ->
Model_api.arr_push arr ~value:(Value.String "first");
ignore (Model_api.commit api)
| None -> ()Model codecs
Model_codec is the document codec facade. Values and functions: Model_codec.to_verbose, Model_codec.to_verbose_string, Model_codec.to_verbose_bigstring, Model_codec.of_verbose, Model_codec.of_verbose_string, Model_codec.of_verbose_bigstring, Model_codec.to_compact, Model_codec.to_compact_string, Model_codec.to_compact_bigstring, Model_codec.of_compact, Model_codec.of_compact_string, Model_codec.of_compact_bigstring, Model_codec.to_binary, Model_codec.of_binary.
Model_codec.Binary values and functions: create_encoder, encoder_contents, write_u8, write_u32, set_u32, write_bytes, write_vu57, write_b1vu56, write_id, write_cbor_uint, write_cbor_string, write_cbor_value, create_clock_encoder_from_model, clock_append, write_tl, encode_node, encode, encode_bytes, create_decoder, read_u8, peek_u8, read_u32, read_bytes, read_vu57, read_b1vu56, read_id, read_cbor_length, read_cbor_value, read_key, decoder_pos, set_decoder_pos, decode_clock_table, decode_ts, decode_node, decode, decode_bytes.
Model_codec_verbose values and functions: encode_timestamp, encode_clock_vector, encode_value, encode_str_chunks, encode_bin_chunks, encode_arr_chunks, encode_node, encode, encode_string, encode_bigstring, get_member, decode_timestamp, decode_clock_vector, decode_value, decode_str_chunks, decode_bin_chunks, decode_node, decode, decode_string, decode_bigstring.
Model_codec_compact values and functions: type_code_con, type_code_val, type_code_obj, type_code_vec, type_code_str, type_code_bin, type_code_arr, string_span, bytes_span, create_sid_table, get_or_add_sid, encode_timestamp, encode_value, encode_str_chunks, encode_bin_chunks, encode_arr_chunks, encode_node, encode_clock_from_table, encode, encode_string, encode_bigstring, decode_timestamp, decode_clock, decode_value, decode_node, decode, decode_string, decode_bigstring.
Model_codec_sidecar types: node_meta, chunk_meta, sidecar. Values and functions: escape_component, encode_timestamp, encode_clock_vector, encode_chunk_meta, encode_node_meta, collect_meta, encode, to_json, encode_string, encode_bigstring, decode_timestamp, decode_clock_vector, get_member, decode_chunk_meta, decode_node_meta, decode_paths, from_json, decode, decode_string, decode_bigstring, view_only, view_only_string, view_only_bigstring.
Model_codec_indexed values and functions: ts_to_string, ts_of_string, encode_timestamp, decode_timestamp, encode_clock, decode_clock, encode_value, decode_value, encode_node, encode, encode_string, encode_bigstring, get_member, decode_node, link_val_ref, link_obj_entries, link_vec_slots, link_arr_elements, decode, decode_string, decode_bigstring, get_node_json, get_node_ids.
Example:
let bytes = Model_codec.to_binary model
let decoded = Model_codec.of_binary bytes
let json = Model_codec.to_verbose_string ~minify:false model
let decoded_json = Model_codec.of_verbose_string jsonCBOR and patch codecs
Cbor_simd types: encoder, decoder. Values and functions: create_encoder, reset_encoder, encoder_contents, encoder_contents_string, write_byte, write_head, write_uint, write_negint, write_int, write_bytes, write_string, write_array_header, write_map_header, write_float, write_null, write_undefined, write_bool, write_value, create_decoder, create_decoder_bytes, decoder_remaining, decoder_has_more, decoder_pos, set_decoder_pos, read_byte, peek_byte, read_length, read_bytes_raw, read_string_raw, read_float, read_float16, read_float32, read_value, shared_encoder, encode, encode_string, decode, decode_string, read_string_only, read_uint, value_to_json, json_to_value, encode_via_simdjsont, decode_via_simdjsont.
Model_codec_cbor types: encoder, decoder. Values and functions: create_encoder, reset_encoder, grow, ensure_capacity, encoder_contents, encoder_contents_string, write_u8, write_u32, set_u32, write_bytes, write_string, write_vu57, write_b1vu56, write_id, write_cbor_uint, write_cbor_negint, write_cbor_int, write_cbor_string, write_cbor_bytes, write_cbor_float, write_cbor_null, write_cbor_undefined, write_cbor_bool, write_cbor_array_header, write_cbor_map_header, write_cbor_value, create_decoder, create_decoder_string, decoder_remaining, decoder_has_more, decoder_pos, set_decoder_pos, read_u8, peek_u8, read_u32, read_bytes, read_string, read_vu57, read_b1vu56, read_id, read_cbor_length, read_cbor_float, read_cbor_value, read_cbor_string_only, encode_cbor, encode_cbor_string, decode_cbor, decode_cbor_string.
Op_codec values and functions: encode_timestamp, decode_timestamp, encode_timespan, decode_timespan, encode_obj_entry, decode_obj_entry, encode_con_value, decode_con_value, make_obj, encode_op, get_member, get_string, get_timestamp, get_int, decode_op, encode, decode.
Patch_codec values and functions: encode_patch_json, encode, encode_bigstring, encode_pretty, get_member, decode_patch_json, decode, decode_bigstring, decode_ndjson_seq, encode_batch_json, encode_batch, encode_batch_bigstring, decode_batch_json, decode_batch, decode_batch_bigstring.
Patch_codec_compact values and functions: compact_opcode_of_op, encode_ts, encode_timespan, encode_con_value, encode_op, encode_patch_json, encode, encode_bigstring, encode_pretty, decode_ts, decode_timespan, decode_con_value, decode_int, get_arr_elem, decode_op, decode_patch_json, decode, decode_bigstring, decode_ndjson_seq, encode_batch_json, encode_batch, encode_batch_bigstring, decode_batch_json, decode_batch, decode_batch_bigstring.
Patch_codec_binary types: encoder, decoder. Values and functions: create_encoder, ensure_capacity, write_u8, write_bytes, write_string, encoder_contents, write_vu57, write_b1vu56, create_decoder, read_u8, read_bytes, read_string, read_vu57, read_b1vu56, write_cbor_undefined, write_cbor_uint, write_cbor_negint, write_cbor_string, write_cbor_bytes, write_cbor_float, write_cbor_value, read_cbor_length, read_cbor_value, write_timestamp, read_timestamp, write_timespan, read_timespan, binary_opcode, write_operation, read_operation, encode, encode_hex, read_patch, decode, decode_hex, encode_batch, decode_batch.
Example:
let wire = Patch_codec_binary.encode patch
match Patch_codec_binary.decode wire with
| Ok patch -> Model.apply replica patch
| Error msg -> prerr_endline msgRx and Sync
Rx types: message. Constructors: Request, Response, Error, Notification, Subscribe, Unsubscribe, Data, Complete. Values and functions: Rx.request, Rx.response, Rx.error, Rx.notification, Rx.subscribe, Rx.unsubscribe, Rx.data, Rx.complete, Rx.message_type, Rx.message_id, Rx.expects_response, Rx.is_server_message, Rx.is_client_message, Rx.pp, Rx.to_string. Rx.Type_code values: request, response, error, notification, subscribe, unsubscribe, data, complete, of_message.
Rx_codec.Json values and functions: to_json, of_json, encode, encode_pretty, decode. Rx_codec.Compact values and functions: to_json, of_json, encode, decode. Rx_codec.Framing values and functions: frame, read_length, unframe, unframe_all, frame_json, frame_compact, unframe_json, unframe_compact.
Rx_server types: handler_result, method_handler, notification_handler, subscription_handler, subscription, t, send_fn. Values and functions: create, register_method, register_notification, register_channel, unregister_method, unregister_notification, unregister_channel, handle_request, handle_notification, handle_subscribe, handle_unsubscribe, handle_message, process_one, send_message, run_connection, register_echo, register_ping, create_with_defaults, process_batch, method_count, notification_count, channel_count, subscription_count, method_names, channel_names.
Rx_client types: response_result, pending_request, subscription, t. Values and functions: create, next_request_id, send_message, request, request_async, notify, subscribe, unsubscribe, handle_response, handle_error, handle_data, handle_complete, handle_message, receive_one, await_response, run_receive_loop, call, process_messages, get_pending_result, pending_count, subscription_count, is_connected, disconnect, create_test_pair.
Sync types: doc_state, server_doc, server, client_doc, client, sync_comparison. Sync.Methods values: sync, patch. Sync.Channels functions: changes. Sync values and functions: create_server, register_doc, get_doc_state, clock_to_list, encode_doc_state, decode_doc_state, apply_patch, subscribe_doc, unsubscribe_doc, get_patches_since, encode_patch, create_client, open_doc, on_doc_change, handle_incoming_patch, compare_states, create_sync_pair, client_doc_patches, add_client_patch, is_dominated_by_clock, get_client_patches_since, sync_server_to_client, sync_client_to_server, bidirectional_sync, server_doc_view, client_doc_view.
Example:
let msg = Rx.request ~id:1 ~method_:"ping" ()
let frame = Rx_codec.Framing.frame_json msg
let server = Sync.create_server ()
let doc = Sync.register_doc server ~doc_id:"notes" ~model:(Model.create 1)
let state = Sync.get_doc_state docExtensions
Counter is a PN-counter extension backed by a vector node. Types: Counter.t. Values and functions: Counter.positive_slot, Counter.negative_slot, Counter.create, Counter.of_node, Counter.id, Counter.get_slot_value, Counter.value, Counter.set_slot, Counter.increment, Counter.decrement, Counter.add, Counter.reset_local, Counter.slots, Counter.totals, Counter.session_count, Counter.merge.
Example:
let counter = Counter.create model
Counter.increment ~by:3 counter;
Counter.decrement counter;
let total = Counter.value counterMval is a multi-value register extension backed by an array node. Types: Mval.t, Mval.resolve_strategy. Constructors: First, Last, Custom. Values and functions: Mval.create, Mval.of_node, Mval.id, Mval.get, Mval.count, Mval.has_conflict, Mval.is_empty, Mval.first, Mval.last, Mval.set, Mval.clear, Mval.set_value_only, Mval.set_all, Mval.resolve, Mval.node, Mval.timestamps, Mval.pp, Mval.to_string.
Example:
let register = Mval.create model
Mval.set register (Value.String "draft");
if Mval.has_conflict register then
Mval.resolve register Mval.LastIO modules
Io_intf defines effects used by transport-agnostic RPC helpers. Types: Io_intf.conn_id, Io_intf.timeout_result, Io_intf.io_result, Io_intf.connection_state. Effects: Read_bytes, Write_bytes, Read_byte, Write_byte, Yield, Accept, Connect, Close, Read_frame, Write_frame, With_timeout. Values and functions: Io_intf.read_string, Io_intf.write_string, Io_intf.read_exactly, Io_intf.read_int32_be, Io_intf.write_int32_be, Io_intf.read_framed_message, Io_intf.write_framed_message, Io_intf.yield, Io_intf.new_connection. Io_intf.Mock values and functions: create, set_input, get_output, clear_output, run.
Io_unix types: Io_unix.connection. Values and functions: Io_unix.create, Io_unix.is_open, Io_unix.close, Io_unix.read_exact, Io_unix.write_all, Io_unix.read_one_byte, Io_unix.write_one_byte, Io_unix.read_int32_be_fd, Io_unix.write_int32_be_fd, Io_unix.run_with_fd, Io_unix.run_stdio, Io_unix.listen_tcp, Io_unix.accept_conn, Io_unix.connect_tcp, Io_unix.run_tcp_server, Io_unix.read_file, Io_unix.write_file, Io_unix.create_pipe, Io_unix.run_with_pipe.
see https://github.com/streamich/json-joy json-joy TypeScript implementation see https://github.com/streamich/json-crdt-traces Conformance test traces
Core Types
module Value : sig ... endValue types including JSON and CBOR extensions
module Value_codec : sig ... endJSON codec for Value.t using jsont
module Pointer : sig ... endJSON Pointer (RFC 6901) for path-based access
module Clock : sig ... endLogical timestamps and clock vectors
module Session : sig ... endSession ID constants and validation
Patch Operations
module Op : sig ... endCRDT patch operations - all 18 opcodes with full data structures
module Op_codec : sig ... endJSON codec for operations (verbose format)
module Patch : sig ... endPatch container and batch operations
module Patch_codec : sig ... endJSON codec for patches (verbose format)
module Patch_codec_compact : sig ... endCompact JSON codec for patches
module Patch_codec_binary : sig ... endBinary codec for patches
module Patch_builder : sig ... endBuilder API for constructing patches
Document Model
module Rga : sig ... endRGA (Replicated Growable Array) core implementation
module Node : sig ... endCRDT node types
module Model : sig ... endDocument model container
module Model_api : sig ... endHigh-level editing API
module Model_codec : sig ... endDocument model codec (all formats: verbose, compact, binary)
module Model_codec_verbose : sig ... endVerbose document codec (human-readable JSON)
module Model_codec_compact : sig ... endCompact document codec (compact JSON with type codes)
module Model_codec_sidecar : sig ... endSidecar document codec (view + metadata separation)
module Model_codec_indexed : sig ... endIndexed document codec (flat map by timestamp)
Codecs
module Model_codec_cbor : sig ... endCBOR (RFC 7049) encoding/decoding primitives
module Cbor_simd : sig ... endCBOR with simdjsont integration for Value.t encoding/decoding
IO Abstraction
module Io_intf : sig ... endIO effect signatures for transport-agnostic operations
module Io_unix : sig ... endUnix blocking IO effect handler
RPC
module Rx : sig ... endJSON-Rx reactive RPC protocol
module Rx_codec : sig ... endJSON-Rx message codecs (JSON, Compact, Framing)
module Rx_server : sig ... endJSON-Rx server router/dispatcher
module Rx_client : sig ... endJSON-Rx client with request/response correlation
Synchronization
module Sync : sig ... endCRDT document synchronization protocol
Extensions
module Counter : sig ... endPN-Counter CRDT extension built on vec node
module Mval : sig ... endMulti-value register extension built on arr node