kcode-k1-kmap-format 0.1.0

Durable Kmap domain invariants and versioned binary formats
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
# kcode-k1-kmap-format

This crate owns Kmap node, connection, measurement, action, and binary-wire invariants. It contains no persistence, callbacks, access policy, sampling, randomness, networking, or application behavior.

`NodeId` converts losslessly to and from the canonical 12-byte K1 `TxId`. A `Node` has no identity field; its projection row owns its identity. `CreateNode` likewise has no identity because its callback transaction ID becomes the new node ID. Connections are directed values inside their source node and contain a target, `Navigation` or `Automated` tier, and learned weight. Targets are unique per node. At most 12 connections may be `Navigation`; `Automated` connections and all text fields have no arbitrary cardinality or length cap.

A new connection has weight value 1 and mass 3. Values are finite in `[0,1]`; masses are finite and positive. `Weight::update(x, m)` ages prior mass by `2^(-m/30)`, adds measurement mass `m`, and returns the mass-weighted value. It returns `None` when the result is below the pruning epsilon 0.01. Tier changes preserve weight. Node connection changes and measurements are atomic on validation errors.

`KmapAction` contains ID-free creation, identified node update, and ordered connection measurements. Constructors validate action-local invariants. Projection code applies updates to a node and remains responsible for validating the resulting node. Measurement values and masses use the same weight constraints; an absent target is a no-op.

`Node::encode` and `KmapAction::encode` emit deterministic Postcard payloads prefixed by format version 1. Their decoders reject empty, unsupported, malformed, trailing, and invariant-invalid values. Consumers must use these methods rather than serializing public fields directly as a wire substitute.

Operations are synchronous, perform no network request, retry, or timeout, and take work and allocation linear in the encoded value or supplied collection.