61 — MSS forms and the hyphae payload
BuiltRendered from 61-mss-and-hyphae-form-spec.md in the public repository. Edits belong there.
MSS (Mycelium Schema Standardisation) encodes a set of datums as one self-delimiting binary sequence in which addresses are derived, not stored. MiCyte uses it for document identity, for document transport, and for the .mss files that carry datums between instances.
The wire specification is docs/contracts/mss_binary_sequence/ (MSS_convention.py, the anthology-notes.txt worked example, transport_v4.md, cutover_design.md). The rules the engine holds a document to are docs/contracts/mss_engine_invariants.md.
Three policies
| Policy | Module | What it hashes or carries | Where it is used |
|---|---|---|---|
mos.mss_sha256_v1 | micyte/core/datum_semantics/engine.py | SHA-256 over canonical JSON of the document's rows | The default policy for minting document ids |
mos.mss_binary_v3 | micyte/core/mss/document_codec.py | The document's downward reference closure, re-indexed into an isolated anthology; references outside the document are dropped and counted | Written to datum_document_binary beside every document |
mos.mss_binary_v4 | micyte/core/mss/transport.py | The document's rows as one bitstream that decodes back to the same rows | Written to datum_document_bitstream beside every document. Ids are minted under it only when MOS_CANONICAL_HASH=mss_binary_v4 |
The store refuses a write whose id policy differs from its own. Rows are read from the bitstream only when MOS_READ_FROM_BITSTREAM is 1 (serve decoded rows) or verify (decode, compare, log a mismatch, serve the stored payload); by default the stored payload is the source. A document over the full-semantics row cap gets policy deferred in the bitstream table; one the transport refuses gets refused with the reason in note.
The v3 grammar
All integers use Elias-gamma on value + 1. Fixed-width fields are big-endian; a width of 0 omits the field.
g(L) layer count
for each layer: g(vg_count) value groups per layer
for each (layer, vg): g(vg_value)
for each (layer, vg): g(iter_count) datums per value group
for each layer ≥ 1: <bitmap> which lower-layer datums this layer may reference
g(stop_width); g(stop_count)
stop_count × <stop_width bits> cumulative end of each datum's blob
<value stream> the datum blobs, in canonical orderEach datum blob is <refs-only bit> g(arity) <body> g(title_code). A refs-only body is arity reference indexes; a tuple-bearing body is arity × (reference index, g(kind), g(magnitude)). A reference is an index into the layer's active set, bits_required(active_set_size − 1) wide. The arity is stored explicitly, independent of the value group.
The v4 transport
v4 keeps v3's derived addresses and active-set references for datums the document carries. It also carries what v3 drops:
- any other string (a foreign or upward address, a collection token, a text magnitude, a title) as an index into a per-document table of distinct strings, each stored once; a string of
0and1characters is stored at one bit per character; - integers, booleans and nulls by tag;
- a nested value as canonical JSON;
- the shape of each row and of its title slot.
encode_rows and decode_rows round-trip a document's rows exactly. transport_hash is the v4 hash.
Magnitudes are converted by micyte/core/mss/magnitude.py, which is injective: a bool, an integer, a numeric string and a binary string with leading zeros each decode to what was encoded.
The .mss envelope
micyte/core/mss/envelope.py frames every datum artifact that leaves an instance: the magic MSSF, then uint32 format version, uint32 kind and uint32 length, then the body.
| Kind | Name | Body |
|---|---|---|
| 1 | Document set | One or more datum documents, rows verbatim. A still (stl.) is this kind (still.py) |
| 2 | Hyphae | One datum's downward reference closure, rudi-inclusive, built by build_hyphae (hyphae.py) |
| 3 | Projection | A derived view of documents shaped for one consumer |
A still is transport, not a store: MOS lv. documents remain the only canonical runtime form.
Hyphae
A datum's hyphae closure is the datum, everything it references, and so on down to the rudi base 0-0-*, resolved within the datum's own document first. It includes every preceding rudi datum (a datum that uses 0-0-5 carries 0-0-1 through 0-0-5). 60 covers the hyphae value as a binding key.
Invariants and transforms
micyte/core/mss/invariants.py names each rule and returns every violation as a Refusal with the rule, the address and a sentence. check_datums checks codec datums; check_rows and check_new_rows check stored rows, where the value group of an instance row is its arity.
micyte/core/mss/transform.py holds the editing primitives as set operations over rows: redenote (move a datum to another value group so it can carry another pair), sibling_set and transform_set (move a run of sibling datums as one set), reindex_heads, compact and readdress. Each returns the rows after, the address remap and a digest before and after, and is refused whole when the result would break an invariant.
SAMRAS
The SAMRAS codec (10) encodes the node set of one tree as a magnitude. It is separate from the MSS document codecs.