ofFields

fun ofFields(version: String, named: Map<String, String?>): String

The digest of an arbitrary flat set of named fields, run through the same canonical rules as ofTerminal: every field is a length-prefixed token, fields are sorted by name so the bytes never depend on the order a map happens to iterate in, and a null value renders as its own distinct absent marker, kept apart from empty text.

This is the codec a durable backend's own comparison digests — a header's, an invocation record's — should run through, ahead of handing the same map to a general-purpose JSON serializer. A serializer's output moves with things that carry no meaning: which Map implementation built the payload, a library version bumping how it renders a number, a config flag turned on for an unrelated reason. Two writes of the same logical state must produce the same digest regardless of any of that, or a correct retry reads as a conflict.

Parameters

version

Names the field set named belongs to, so two backends digesting different shapes under different versions can never collide. Two calls passing the same version must mean the same set of field names, or their digests are not comparable to each other.

named

The named values to digest, already rendered to the strings that mean what the caller means — this function does no rendering of its own. A null value is encoded as absent, distinct from an empty string.