pub struct Registration { /* private fields */ }Expand description
A registration record stored in the DHT.
Contains all information needed to contact an agent and verify its identity. Registrations have a TTL and must be refreshed to remain active.
§Mutability
A record names the Ed25519 key that is allowed to change it. Every later
write must carry a MutationProof signed by that
key, and must advance Registration::sequence. Without both, knowing an
agent’s URI would be enough to repoint it at attacker infrastructure.
§Examples
use std::time::Duration;
use agent_uri::AgentUri;
use agent_uri_attestation::SigningKey;
use agent_uri_dht::{Endpoint, Registration};
let uri = AgentUri::parse("agent://anthropic.com/assistant/chat/llm_01h455vb4pex5vsknk084sn02q").unwrap();
let endpoint = Endpoint::https("agent.anthropic.com:443");
let agent_key = SigningKey::generate();
let registration = Registration::new(uri, agent_key.verifying_key(), vec![endpoint])
.with_ttl(Duration::from_secs(3600));Implementations§
Source§impl Registration
impl Registration
Sourcepub const DEFAULT_TTL: Duration
pub const DEFAULT_TTL: Duration
Default TTL for registrations (1 hour).
Sourcepub fn new(
agent_uri: AgentUri,
agent_key: VerifyingKey,
endpoints: Vec<Endpoint>,
) -> Self
pub fn new( agent_uri: AgentUri, agent_key: VerifyingKey, endpoints: Vec<Endpoint>, ) -> Self
Creates a new registration with default TTL.
§Arguments
agent_uri- The agent’s identity URIagent_key- The public key that may later change or remove this recordendpoints- Network endpoints for contacting the agent
Sourcepub fn with_attestation(self, attestation: impl Into<String>) -> Self
pub fn with_attestation(self, attestation: impl Into<String>) -> Self
Sets the attestation token.
Sourcepub fn with_expires_at(self, expires_at: SystemTime) -> Self
pub fn with_expires_at(self, expires_at: SystemTime) -> Self
Sets the expiration time directly.
Sourcepub fn with_registered_at(self, registered_at: SystemTime) -> Self
pub fn with_registered_at(self, registered_at: SystemTime) -> Self
Sets the registration time (for testing/simulation).
Sourcepub const fn with_sequence(self, sequence: u64) -> Self
pub const fn with_sequence(self, sequence: u64) -> Self
Sets the sequence number this record starts its history at.
Records open at zero, which is right for an agent registering a URI for the first time. An agent that has held this URI before should instead continue past the highest sequence it ever signed: a record that starts over at zero sits below every proof its previous incarnation handed out, and a kept deregistration could evict it again each time it returns.
Sourcepub fn agent_key(&self) -> &VerifyingKey
pub fn agent_key(&self) -> &VerifyingKey
Returns the key permitted to change or remove this record.
Sourcepub const fn sequence(&self) -> u64
pub const fn sequence(&self) -> u64
Returns the sequence number of the last write applied to this record.
A write must present a strictly greater number, so a caller preparing a
mutation signs sequence() + 1.
Sourcepub fn attestation(&self) -> Option<&str>
pub fn attestation(&self) -> Option<&str>
Returns the attestation token, if any.
Sourcepub fn expires_at(&self) -> SystemTime
pub fn expires_at(&self) -> SystemTime
Returns the expiration time.
Sourcepub fn registered_at(&self) -> SystemTime
pub fn registered_at(&self) -> SystemTime
Returns the registration time.
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Returns true if this registration has expired.
Sourcepub fn remaining_ttl(&self) -> Option<Duration>
pub fn remaining_ttl(&self) -> Option<Duration>
Returns the remaining TTL, or None if expired.
Sourcepub fn update_endpoints(&mut self, endpoints: Vec<Endpoint>)
pub fn update_endpoints(&mut self, endpoints: Vec<Endpoint>)
Updates the endpoints for this registration.
Sourcepub const fn set_expires_at(&mut self, expires_at: SystemTime)
pub const fn set_expires_at(&mut self, expires_at: SystemTime)
Moves the registration’s expiry to an instant a write has authorized.
Callers are the store, applying a write it has already checked. The
instant is taken rather than derived from a TTL because it is what the
agent signed: a store that computed now + ttl for itself would write
an expiry the agent never put its name to, and on a wire protocol that
field would then be one an observer could rewrite freely.
registered_at is deliberately left alone. It identifies this record
instance, which is what a MutationProof binds
itself to; moving it on every refresh would invalidate proofs an agent
had already prepared, and would make the field misreport when the agent
actually registered.
Sourcepub const fn set_sequence(&mut self, sequence: u64)
pub const fn set_sequence(&mut self, sequence: u64)
Records the sequence number of a write that has been authorized.
Callers are the store, applying a write it has already checked. The number is not validated here: whether it advances is a question about the record’s history, which only the store holding that record can answer.
Trait Implementations§
Source§impl Clone for Registration
impl Clone for Registration
Source§impl Debug for Registration
impl Debug for Registration
Source§impl<'de> Deserialize<'de> for Registration
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Registration
serde only.