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

Method save_attestation

atomic-repository/src/repository/changes.rs:530–579  ·  view source on GitHub ↗

Save an attestation to the repository. Serializes the attestation to disk and registers it in the graph with `node_type::ATTESTATION`. Also registers dependencies from `changes_covered` in the DEPS table so the graph knows which changes this attestation covers. # Arguments `attestation` - The attestation to save # Returns The content hash of the saved attestation.

(
        &self,
        attestation: &atomic_core::change::Attestation,
    )

Source from the content-addressed store, hash-verified

528 ///
529 /// The content hash of the saved attestation.
530 pub fn save_attestation(
531 &self,
532 attestation: &atomic_core::change::Attestation,
533 ) -> Result<Hash, RepositoryError> {
534 let _review_boundary = self.review_evidence_lock()?;
535 self.ensure_project_identity(atomic_core::kg::project_id::MintReason::Upgrade)?;
536 use atomic_core::pristine::MutTxnT;
537
538 // Save to disk
539 let hash = self
540 .change_store
541 .save_attestation(attestation)
542 .map_err(|e| RepositoryError::Database(e.to_string()))?;
543
544 // Register in the graph
545 let mut txn = self
546 .pristine
547 .write_txn()
548 .map_err(|e| RepositoryError::Database(e.to_string()))?;
549
550 let attest_id = txn
551 .register_attestation(&hash)
552 .map_err(|e| RepositoryError::Database(e.to_string()))?;
553
554 // Register dependencies: attestation → covered changes. A downloaded
555 // change may not have been inserted into a view yet (`--download-only`),
556 // but it still needs an internal ID so this relationship is durable.
557 // Insertion reuses the same content-addressed registration later.
558 for change_hash in &attestation.changes_covered {
559 let change_id = txn
560 .register_change(change_hash)
561 .map_err(|e| RepositoryError::Database(e.to_string()))?;
562 txn.put_dep(attest_id, change_id)
563 .map_err(|e| RepositoryError::Database(e.to_string()))?;
564 }
565
566 // If chained, register dependency on previous attestation too
567 if let Some(ref prev_hash) = attestation.previous_attestation {
568 if let Ok(Some(prev_id)) = txn.get_internal(prev_hash) {
569 txn.put_dep(attest_id, prev_id)
570 .map_err(|e| RepositoryError::Database(e.to_string()))?;
571 }
572 }
573
574 txn.commit()
575 .map_err(|e| RepositoryError::Database(e.to_string()))?;
576
577 self.refresh_session_kg()?;
578 Ok(hash)
579 }
580
581 /// Build and persist the latest content-addressed manifest for a session.
582 ///

Calls 9

review_evidence_lockMethod · 0.80
write_txnMethod · 0.80
register_attestationMethod · 0.80
register_changeMethod · 0.80
put_depMethod · 0.80
refresh_session_kgMethod · 0.80
get_internalMethod · 0.45
commitMethod · 0.45