(*--------------------------------------------------------------------------- Copyright (c) 2025 Thomas Gazagnaire. All rights reserved. SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) (** DTN-native administrative records for borealis control. Instead of gRPC, borealis uses Bundle Protocol administrative records for control plane messages. This provides: - Single protocol for control and data - Store-and-forward tolerance - BPSec authentication - Compact CBOR encoding Admin bundles are sent to the node's admin endpoint ([ipn:NODE.0]). *) (** {1 Admin Record Types} *) type status = { node_id : Bundle.eid; uptime_secs : float; bundles_stored : int; bundles_forwarded : int; bundles_delivered : int; bundles_dropped : int; active_contacts : int; } (** Node status information. *) type contact = { from_node : string; to_node : string; start_time : float; stop_time : float; rate_bps : float; owlt_secs : float; } (** A scheduled contact. *) type contact_plan = { contacts : contact list } (** A contact plan update. *) type config_delta = { key : string; value : string option; (** None means delete *) } (** Configuration change. *) type query = | Query_status | Query_contacts | Query_policy | Query_bundles of { filter : string option } (** Query types. *) type response = | Response_status of status | Response_contacts of contact_plan | Response_policy of { source : string } | Response_bundles of { count : int; bundle_ids : string list } | Response_error of { code : int; message : string } (** Query responses. *) type t = | Status_report of status | Policy_update of { compiled : string; source : string } | Contact_update of contact_plan | Config_update of config_delta list | Query of query | Response of response (** Administrative record types. *) (** {1 CBOR Schema} *) val codec : t Cbort.t (** CBOR codec for admin records. *) (** {1 Encoding/Decoding} *) val encode : t -> string (** [encode record] encodes to CBOR bytes. *) val decode : string -> (t, string) result (** [decode bytes] decodes from CBOR bytes. *) (** {1 Bundle Creation} *) val make_bundle : source:Bundle.eid -> destination:Bundle.eid -> timestamp:Bundle.timestamp -> t -> Bundle.t (** [make_bundle ~source ~destination ~timestamp record] creates an admin bundle containing [record]. *) val extract : Bundle.t -> (t, string) result (** [extract bundle] extracts the admin record from an admin bundle. *) val is_admin_bundle : Bundle.t -> bool (** [is_admin_bundle bundle] returns true if this is an admin bundle. *) (** {1 Utilities} *) val pp : t Fmt.t (** Pretty-printer. *) val pp_status : status Fmt.t val pp_contact : contact Fmt.t val pp_query : query Fmt.t val pp_response : response Fmt.t