Class CborCodec

java.lang.Object
ai.badmonkey.agentspaces.common.codec.CborCodec

public final class CborCodec extends Object
The canonical AgentSpaces codec: CBOR (RFC 8949) for all wire payloads and entry serialization, with a JSON view for logs and debugging. Records serialize in declared component order, which is the v0.1 canonical form that advertisement signatures are computed over.

Unknown fields are ignored on read, so a v0.1 peer tolerates cards and entries from newer peers that add fields.

  • Method Details

    • defaultCodec

      public static CborCodec defaultCodec()
      Returns the shared default codec.
    • toBytes

      public byte[] toBytes(Object value)
      Serializes a value to canonical CBOR bytes.
      Parameters:
      value - the value to serialize
      Returns:
      the CBOR encoding
    • fromBytes

      public <T> T fromBytes(byte[] bytes, Class<T> type)
      Deserializes CBOR bytes into the given type.
      Type Parameters:
      T - the target type
      Parameters:
      bytes - the CBOR encoding
      type - the target type
      Returns:
      the deserialized value
    • toJson

      public String toJson(Object value)
      Renders a value as JSON, for logs and debugging only. The wire format is CBOR.
      Parameters:
      value - the value to render
      Returns:
      a JSON string