Canonical Wire & Artifacts
Architectura defines two complementary serialization contracts:
- Canonical Semantic Wire (
archsem_core::canonical): A deterministic,serde-independent binary encoding used for content-addressed semantic fingerprints (fragment and whole-function dual fingerprints). - Versioned Artifact Envelopes (
archsem_core::artifact,archsem-ir,archsem-symex,archsem-conformance): Self-identifying, resource-bounded JSON/RON envelopes for runtime-loaded semantic programs, decode tables, symbolic execution reports, proof obligations, and oracle exchanges.
Canonical Binary Wire (archsem_core::canonical)
Defined normatively in CANONICAL_WIRE.md, CanonicalEncode requires every encoded struct field and enum variant to be named explicitly—adding a Rust enum variant never silently assigns a wire tag.
Primitive & Aggregate Encodings
| Type | Wire Format |
|---|---|
u8, u16, u32, u64, u128, i64 | Fixed-width little-endian two's complement |
usize | Admitted only if it fits u64; encoded as little-endian u64 (lengths only) |
bool | 0x00 (false) or 0x01 (true) |
| Byte strings & UTF-8 text | u64 byte length ` |
| Enum tags | Normative UTF-8 tag strings |
Option<T> | 0x00 (absent) or `0x01 |
| Wide bitvectors | u16 width ` |
| Sequences | u64 item count ` |
| Maps | Sorted lexicographically by the complete canonical bytes of each key (duplicate canonical keys rejected) |
Recursive semantic-program encoding is bounded by MAX_CANONICAL_NESTING and the caller's byte limit.
Dual Fingerprints (Definition vs. Lift Instance)
archsem-ir fragments and complete Functions expose two SHA-256 canonical projections (current core canonical wire revision 2, embedded by neutral fragment schema 2.2 and neutral function schema 2.2):
| Projection | Retained | Redacted |
|---|---|---|
| Semantic-Definition | Wide constants, architectural choices, ordered events, unified control shape, semantic sites, origin-DAG topology, relocatable PC + displacement basis/displacement, dense first-occurrence InstructionExecutionGroup ordinals (or group-id-redacted on standalone fragments) | Concrete instruction address, exact bytes, decode-context instance, direct control addresses, concrete relocatable PC base/value |
| Lift-Instance | Everything in definition plus specification revision, exact architecture/decode-state identity, bytes/address, decoder options, code epoch, semantic-program revision, exact InstructionExecutionGroup IDs, and concrete relocatable bases | None |
[!NOTE] Schema major
1(which embeddedserde_jsonwire) is intentionally rejected by revision2. Within a major version, existing tags, widths, and field orders never change; additive IR vocabulary increments the minor version (e.g.,2.1addedextract-element/insert-element;2.2addedinstruction-execution-group). Golden fixtures pin the exact canonical bytes and SHA-256 digests.
Versioned JSON & RON Artifact Envelopes
Runtime-loaded programs and decode tables cross an explicit trust boundary in archsem_core::artifact (serde feature):
- Envelope:
ArtifactEnvelope<T>carries:schema:"archsem.semantic-artifact"(ARCHSEM_ARTIFACT_SCHEMA)version:SchemaVersion { major: 1, minor: 0 }(ARCHSEM_ARTIFACT_VERSION)kind:ArtifactKind::SemanticProgram("semantic_program") orArtifactKind::DecodeTable("decode_table")payload:OwnedProgramorOwnedDecodeTable
- Loaders:
load_program_json,load_program_ron,load_decode_table_json,load_decode_table_ron. - Fail-Closed Admission:
- Checks
ResourceLimits::input_bytesbefore parsing. - Rejects wrong
schema, incompatiblemajorversion, and newer unsupportedminorversions (never assuming unknown fields are inert). - Validates the decoded payload structurally (
ExecutableProgram/OwnedTableDecoder) before returning or leaking any process-lifetime state.
- Checks
- Legacy
UndefRejection: Artifacts containing removed pre-v0.2Undefencodings are rejected at admission rather than silently mapped toChoice.
Other versioned bounded artifacts in the workspace follow the same hostile-input admission pattern:
archsem-symex:ExecutionReportArtifact,ConcolicExecutionArtifact,ProofObligationArtifact,InstructionValidationArtifact,InstructionCounterexampleArtifactarchsem-conformance:ExternalOracleRequest/ExternalOracleResponse,OracleDisagreementArtifactarchsem-lang/archsemc:.asemcportable semantic packages