osyra_ome.memory.omp
Private pre-release / network boundary: The currently usable customer surface is offline verification of an existing signed artifact against an out-of-band trust anchor. Memory/network RPC APIs and host snippets on this page describe protocol and interface shape; the public Edge bridge, package publication, and release acceptance remain pending. Do not treat
api.osyra.ai:443examples as a released customer route.
OMP v1 — cross-vendor portable-memory archive ENCODER (Python port).
Faithful port of the Go reference encoder (``docs/architecture/ref/omp/``) and the Java port (``ai.osyra.ome.omp``). Produces byte-identical signed OMP archives for the same logical inputs — the GA-blocking cross-language byte-identity contract (design ``AP00011-OMP-PORTABLE-MEMORY-DESIGN.md`` D4).
Reuses the verify-side mini-kernel's ``encode_canonical_cbor`` (cbor2 ``canonical=True``) for the canonical-CBOR profile (RFC 8949 §4.2, design §4).
Two parity traps the port closes (both verified by ``tests/test_omp_kat.py``):
-
**cbor2 map-key ordering** — cbor2 ``canonical=True`` sorts map keys length-first then bytewise-lex over the encoded key bytes (CTAP2 / RFC 7049 §3.9), which is IDENTICAL to fxamacker
CoreDetEncOptions(RFC 8949 §4.2.1 length-first) for the OMP key sets. Confirmed empirically against the Go reference forvendor_metadata({b, aa, ccc} → length first) and the archive/item maps. (NOT the divergence the design warned about — that warning was a precaution; for OMP's key sets the two agree.) -
**float encoding** — the embedding ``values`` are semantically **float32** (Go
[]float32/ Javafloat[]). A naive Pythonfloatis float64 and cbor2 would emit an 8-bytefbdouble, DIVERGING from the Gofa(float32) /f9(float16-when-lossless) wire. The port rounds every value through float32 (structpack/unpack'f') so cbor2's shortest-float canonicalization reproduces the reference bytes exactly.
The ``item_id`` / ``archive_id`` / Form-B preimage constructions mirror the Go ``item.go`` / ``sign.go`` byte-for-byte.
Constants
| Name | Value |
| --- | --- |
| OMP_CONTENT_TYPE | 'application/vnd.osyra.omp.archive.v1+cbor' |
| OMP_DOMAIN_TAG | 'osyra-omp-archive-v1' |
| OMP_VERSION | 1 |
Functions
encode_archive
def encode_archive(a: OmpArchive) -> bytesSerialize the signed archive to canonical CBOR (the wire bytes).
new_archive
def new_archive(origin_vendor: str, origin_model_family: str, origin_workspace_did: str, origin_signing_key_id: str, retention_policy_did: str, archive_created_at: int) -> OmpArchivePre-fill the v1 invariants (Go ``NewArchive``).
new_assertion_item
def new_assertion_item(canonical_text: str, write_capability_did: str, write_purpose_did: str, access_policy: str, memory_subject: str, memory_predicate: str, valid_time: int, written_at: int) -> OmpItem``new_item`` + the bitemporal merge keys (Go ``NewAssertionItem``).
new_item
def new_item(canonical_text: str, write_capability_did: str, write_purpose_did: str, access_policy: str, written_at: int) -> OmpItemConstruct an item with NFC text + computed item_id + SimHash (Go ``NewItem``).
sign_archive
def sign_archive(a: OmpArchive, private_key: Ed25519PrivateKey) -> OmpArchiveCompute archive_id, build the Form-B preimage, Ed25519-sign, set sig+pub.
Mutates + returns ``a`` (Go ``Sign`` semantics).
Classes
class OmpArchive (dataclass)
The signed portable-memory archive envelope (design §3.2).
Attributes
| Name | Type | Default |
| --- | --- | --- |
| archive_created_at | int | |
| archive_id | bytes | b'' |
| items | list[OmpItem] | field(default_factory=list) |
| origin_model_family | str | |
| origin_signing_key_id | str | |
| origin_vendor | str | |
| origin_workspace_did | str | |
| retention_policy_did | str | |
| sig | bytes | b'' |
| signer_pub | bytes | b'' |
Methods
to_map
def to_map(self) -> dict[str, Any]Full signed archive map (cbor2 canonical sorts keys length-first).
class OmpItem (dataclass)
One portable memory record. Field order + omitempty mirror the Go struct.
Attributes
| Name | Type | Default |
| --- | --- | --- |
| access_policy | str | |
| canonical_text | str | |
| cross_model_equivalence_class | bytes | b'' |
| item_id | bytes | |
| memory_predicate | str | '' |
| memory_subject | str | '' |
| origin_embedding | OmpOptEmbedding | None | None |
| origin_embedding_model | str | '' |
| prior_item_id | bytes | b'' |
| source_uri | str | '' |
| valid_time | int | 0 |
| vendor_metadata | dict[str, str] | field(default_factory=dict) |
| write_capability_did | str | |
| write_purpose_did | str | |
| written_at | int | |
Methods
to_map
def to_map(self) -> dict[str, Any]Build the CBOR map, applying Go's omitempty semantics + float32 values.
cbor2 ``canonical=True`` will sort the keys length-first; the Go encoder does the same, so the literal insertion order here is irrelevant — but WHICH keys are present (omitempty) is load-bearing, so this mirrors the Go `,omitempty` tags exactly (an absent optional field is OMITTED, never emitted as null).
class OmpOptEmbedding (dataclass)
Optional carry-original embedding ({dim, values}). Values are float32.
Attributes
| Name | Type | Default |
| --- | --- | --- |
| dim | int | |
| values | list[float] | |