MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / record_attestation

Method record_attestation

libatomic/src/daemon/services_agent.rs:3151–3403  ·  view source on GitHub ↗
(
        &self,
        request: Request<RecordAttestationRequest>,
    )

Source from the content-addressed store, hash-verified

3149 }
3150
3151 async fn record_attestation(
3152 &self,
3153 request: Request<RecordAttestationRequest>,
3154 ) -> Result<Response<RecordAttestationResponse>, Status> {
3155 let request = request.into_inner();
3156 let target = request.target.ok_or_else(|| {
3157 domain_status(ErrorCode::InvalidArgument, "attestation target required")
3158 })?;
3159 let target_kind = target.kind.ok_or_else(|| {
3160 domain_status(
3161 ErrorCode::InvalidArgument,
3162 "attestation target kind required",
3163 )
3164 })?;
3165 let handle = self.state.resolve(request.repository.as_ref().unwrap())?;
3166 self.state.log_rpc("RecordAttestation", Some(&handle));
3167 let gate_handle = handle.clone();
3168 let _gate = gate_handle.exclusive().await;
3169 let identity_name = request.identity_did.clone();
3170 let meta = request.meta.clone();
3171 let caller_signature = request.signature.clone();
3172
3173 let response = tokio::task::spawn_blocking(move || match target_kind {
3174 TargetKind::IntentId(intent_id) => {
3175 let repo = handle.repository()?;
3176 let entry = repo
3177 .vault_intent_show(&intent_id)
3178 .map_err(repository_error)?;
3179 let frontmatter = parse_frontmatter(&entry)?;
3180 let body = body_of(&entry);
3181 let (node, public_key): (CanonicalNode, _) = if caller_signature.is_empty() {
3182 // Sign here, with this machine's key — the plain `attest`.
3183 let material = load_identity(if identity_name.is_empty() {
3184 None
3185 } else {
3186 Some(&identity_name)
3187 })?;
3188 (
3189 lift_and_attest(&frontmatter, &body, &material.identity, &material.keypair)
3190 .map_err(|error| {
3191 domain_status(
3192 ErrorCode::InvalidArgument,
3193 format!("attest: {error}"),
3194 )
3195 })?,
3196 material.identity.public_key.clone(),
3197 )
3198 } else {
3199 // The key was held elsewhere: verify the caller's
3200 // signature against the target AS IT IS NOW (a stale or
3201 // altered intent hashes differently, so an old signature
3202 // cannot land), and attach exactly the proof it earned.
3203 // No secret key is loaded.
3204 let identity = load_identity_public(&identity_name)?;
3205 let unattested = lift_intent(&frontmatter, &body).map_err(|error| {
3206 domain_status(ErrorCode::InvalidArgument, format!("attest: {error}"))
3207 })?;
3208 refuse_unfillable(&unattested)?;

Callers

nothing calls this directly

Calls 15

domain_statusFunction · 0.85
parse_frontmatterFunction · 0.85
body_ofFunction · 0.85
load_identityFunction · 0.85
lift_and_attestFunction · 0.85
load_identity_publicFunction · 0.85
lift_intentFunction · 0.85
refuse_unfillableFunction · 0.85
validate_intentFunction · 0.85
write_allFunction · 0.85
response_metaFunction · 0.85
lift_and_attest_memoryFunction · 0.85

Tested by

no test coverage detected