mars-protocol · entry
Public declarations and documentation for mars-protocol::entry.
Package: mars-protocol · Workspace version: 0.1.0 · Module: entry
This reference follows declared modules and public syntax, including public implementation methods. Function bodies and constant values are omitted. Feature conditions are retained. Private-module re-exports and trait resolution require the compiler; not every declaration is a root import.
entry::EntryType
The 10 OAS-aligned entry types plus 4 MAP plugin types (14 total).
Each variant maps to an [oas_did::EntityKind] value via the
oas_kind method.
Serialization
Variants serialize to their PascalCase name (e.g. "AgentDefinition").
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
pub enum EntryType {
/// A registered autonomous agent.
AgentDefinition,
/// A tool that agents can invoke.
ToolDefinition,
/// A composable skill unit.
SkillDefinition,
/// A multi-step workflow definition.
WorkflowDefinition,
/// A machine learning model with provenance.
ModelDefinition,
/// A dataset with verified lineage.
DatasetDefinition,
/// An infrastructure or API service.
ServiceDefinition,
/// An autonomous organization record.
OrganizationDefinition,
/// A single verified human root (HMR).
HumanRootRecord,
/// A threshold-group multi-human root (MHR).
MultiHumanRootRecord,
// MAP Plugin ecosystem types
/// A MAP plugin definition + metadata.
MapPlugin,
/// A specific version binary + config for a MAP plugin.
MapPluginRelease,
/// A reusable integration type definition for MAP plugins.
MapIntegrationSchema,
/// A curated bundle of MAP plugins.
MapPluginCollection,
}Source line: 48.
entry::EntryType::as_str
Returns the canonical string name of this entry type.
use mars_protocol::EntryType;
assert_eq!(EntryType::AgentDefinition.as_str(), "AgentDefinition");pub fn as_str(&self) -> &'static str;Source line: 87.
entry::EntryType::oas_kind
Returns the corresponding [oas_did::EntityKind] for this entry type.
use mars_protocol::EntryType;
use oas_did::EntityKind;
assert_eq!(EntryType::AgentDefinition.oas_kind(), EntityKind::Agent);
assert_eq!(EntryType::HumanRootRecord.oas_kind(), EntityKind::Hmr);pub fn oas_kind(&self) -> EntityKind;Source line: 114.
entry::EntryType::all
Returns all 14 entry type variants.
pub fn all() -> &'static [EntryType; 14];Source line: 134.
entry::ExtensionEntryType
Extension entry types that do not correspond to an OAS entity kind.
These cover governance, schema governance, ontology, auditing, evaluation, and reputation domains.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
pub enum ExtensionEntryType {
/// A governance or access policy definition.
Policy,
/// A published JSON Schema / protocol schema.
SchemaDefinition,
/// An ontology or vocabulary definition.
Ontology,
/// An audit policy specifying compliance rules.
AuditPolicy,
/// A template for evaluating agents, tools, or services.
EvaluationTemplate,
/// A reputation data feed for an entity.
ReputationFeed,
}Source line: 170.
entry::ExtensionEntryType::as_str
Returns the canonical string name of this extension type.
pub fn as_str(&self) -> &'static str;Source line: 187.
entry::ExtensionEntryType::all
Returns all 6 extension type variants.
pub fn all() -> &'static [ExtensionEntryType; 6];Source line: 199.
entry::LineageReference
A reference to the human lineage chain of a MARS entry's publisher.
Every non-root entry traces back to a human root DID through a chain of delegations.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
#[serde(rename_all = "camelCase")]
pub struct LineageReference {
/// The DID of the originating human root.
#[cfg_attr(feature = "contracts", schemars(regex(pattern = r"^did:oas:")))]
pub human_root_did: String,
/// The generation distance from the root (0 = direct child).
pub generation: u32,
/// Ordered chain of DIDs from root to publisher.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
#[cfg_attr(feature = "contracts", schemars(inner(regex(pattern = r"^did:oas:"))))]
pub lineage_chain: Vec<String>
}Source line: 228.
entry::AccessPolicy
Access control policy for a MARS entry.
When public is true the entry is discoverable by any resolver. When
false, only DIDs listed in allowed_dids (or those presenting a required
attestation type) may resolve it.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
#[serde(rename_all = "camelCase")]
pub struct AccessPolicy {
/// Whether the entry is publicly discoverable.
#[serde(default = "default_true")]
pub public: bool,
/// Explicit DID allow-list (relevant when `public` is `false`).
#[serde(skip_serializing_if = "Option::is_none")]
pub allowed_dids: Option<Vec<String>>,
/// Attestation type URIs that grant access (relevant when `public` is
/// `false`).
#[serde(skip_serializing_if = "Option::is_none")]
pub required_attestation_types: Option<Vec<String>>
}Source line: 252.
entry::MarsEntry
A complete MARS registry entry (MARS Specification Section 5).
This is the canonical on-wire and at-rest representation of every artifact
registered in the MARS ecosystem. Required fields are always present;
optional fields are omitted from JSON when None or empty.
Validation
Call validate to check structural invariants before
signing or persisting.
Examples
use mars_protocol::entry::{MarsEntry, EntryType};
let entry: MarsEntry = serde_json::from_str(r#"{ ... }"#)?;
entry.validate()?;
# Ok::<(), Box<dyn std::error::Error>>(())#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
#[serde(rename_all = "camelCase")]
pub struct MarsEntry {
// ----- required fields -----
/// MARS protocol version. Must be `"1.0.0"`.
#[cfg_attr(feature = "contracts", schemars(regex(pattern = r"^1\.0\.0$")))]
pub mars_version: String,
/// The OAS DID uniquely identifying this entry.
#[cfg_attr(feature = "contracts", schemars(regex(pattern = r"^did:oas:")))]
pub entry_did: String,
/// The primary entry type (one of 10 OAS kinds).
pub entry_type: EntryType,
/// Human-readable name (max 256 characters).
#[cfg_attr(feature = "contracts", schemars(length(min = 1, max = 256)))]
pub name: String,
/// MARS shard assignment (from gal topology map).
#[serde(skip_serializing_if = "Option::is_none")]
pub shard_assignment: Option<String>,
/// Semantic version of this entry.
#[cfg_attr(feature = "contracts", schema(value_type = String))]
pub version: semver::Version,
/// DID of the publishing entity.
#[cfg_attr(feature = "contracts", schemars(regex(pattern = r"^did:oas:")))]
pub publisher_did: String,
/// Timestamp of initial publication.
pub published_at: chrono::DateTime<chrono::Utc>,
/// URI of the JSON Schema that `item_data` conforms to.
pub item_schema_uri: String,
/// The entry payload conforming to `item_schema_uri`.
pub item_data: serde_json::Value,
/// Content hash of `item_data` in `sha256:<hex>` format.
#[cfg_attr(
feature = "contracts",
schemars(regex(pattern = r"^sha256:[a-f0-9]{64}$"))
)]
pub item_data_hash: String,
/// Cryptographic signature over the canonical entry content.
pub signature: EntrySignature,
// ----- optional / defaulted fields -----
/// Human-readable description (max 4096 characters).
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "contracts", schemars(length(max = 4096)))]
pub description: Option<String>,
/// Discovery tags.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
#[cfg_attr(
feature = "contracts",
schemars(length(max = 50), inner(length(max = 64)))
)]
pub tags: Vec<String>,
/// Timestamp of the most recent update.
#[serde(skip_serializing_if = "Option::is_none")]
pub updated_at: Option<chrono::DateTime<chrono::Utc>>,
/// Current lifecycle status (defaults to `Active`).
#[serde(default)]
pub lifecycle_status: LifecycleStatus,
/// Lineage chain to the originating human root.
#[serde(skip_serializing_if = "Option::is_none")]
pub lineage_reference: Option<LineageReference>,
/// Associated economic bond.
#[serde(skip_serializing_if = "Option::is_none")]
pub bond_reference: Option<BondReference>,
/// Verifiable attestations (opaque JSON; validated at a higher layer).
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub verifiable_attestations: Vec<serde_json::Value>,
/// Typed relationships to other entries.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub relationships: Vec<Relationship>,
/// RDF-style semantic annotations.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub semantic_annotations: Vec<SemanticAnnotation>,
/// Access control policy.
#[serde(skip_serializing_if = "Option::is_none")]
pub access_policy: Option<AccessPolicy>,
/// Service endpoints for OpenAgent resolution.
///
/// Per the MARS/OpenAgent Endpoint Contract (v1.0.0), entries MAY declare
/// transport endpoints. Day-one clients consume only `https` endpoints;
/// `weave` and `wss` entries are stored for forward compatibility.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub service_endpoints: Vec<ServiceEndpoint>,
/// Arbitrary extension metadata.
#[serde(skip_serializing_if = "Option::is_none")]
pub custom_metadata: Option<serde_json::Map<String, serde_json::Value>>,
/// Registry-managed anchor projection for the current immutable snapshot.
///
/// This field is excluded from the publisher signing payload and can only
/// be advanced by the registry's durable anchor outbox.
#[serde(default)]
pub anchor_state: AnchorState,
/// Monotonically increasing counter for replay protection.
#[serde(default)]
pub sequence: u64
}Source line: 308.
entry::MarsEntry::validate
Validates structural invariants of this entry.
Checks performed:
mars_versionequals"1.0.0".entry_didis non-empty.nameis non-empty and at most [crate::MAX_NAME_LENGTH] characters.publisher_didis non-empty.item_schema_uriis non-empty.item_data_hashstarts with"sha256:".description, if present, is at most [crate::MAX_DESCRIPTION_LENGTH] characters.- Every [
SemanticAnnotation] passes its ownvalidate().
Errors
Returns [MarsError::ValidationError] on the first violated rule.
pub fn validate(&self) -> Result<(), MarsError>;Source line: 443.
Source provenance
Source: mars-protocol/src/entry.rs · SHA-256 a2b87b4e5d15c0016ee5607be42a12f0f4be0bc329b9fda994fe2b99b9e27c81. Package overview.