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

Method insert_change

atomic-repository/src/repository/insert.rs:2428–2856  ·  view source on GitHub ↗

Insert a change into the current view. This is the high-level method for inserting a single change into the repository. It loads the change from the change store, validates dependencies, applies atoms to the graph, and updates the view state. # Arguments `hash` - The hash of the change to insert `options` - Options controlling insertion behavior # Returns An `InsertOutcome` containing the new

(
        &self,
        hash: &Hash,
        mut options: InsertOptions,
    )

Source from the content-addressed store, hash-verified

2426 /// println!("New state: {}", result.new_state.to_base32());
2427 /// ```
2428 pub fn insert_change(
2429 &self,
2430 hash: &Hash,
2431 mut options: InsertOptions,
2432 ) -> Result<InsertOutcome, RepositoryError> {
2433 let _review_boundary = self.review_evidence_lock()?;
2434 let change = self.load_change(hash)?;
2435 self.fence_legacy_span_storage(&change)?;
2436 let view_name = options
2437 .view
2438 .as_deref()
2439 .unwrap_or(&self.current_view)
2440 .to_string();
2441 let _span_lock = if self.span_in_closure(std::slice::from_ref(hash))? {
2442 let working_copy = self.require_working_copy_id()?;
2443 let lock = self.try_lock_workspace_operation(working_copy)?;
2444 self.preflight_span_references(&view_name, std::slice::from_ref(hash), true)?;
2445 Some(lock)
2446 } else {
2447 None
2448 };
2449 self.ensure_project_identity(atomic_core::kg::project_id::MintReason::Upgrade)?;
2450 let trace_insert = std::env::var_os("ATOMIC_TRACE_INSERT").is_some();
2451 let t0 = std::time::Instant::now();
2452
2453 // Native shared insertion checks approved application content, not
2454 // agent capture. An explicitly retained legacy decision keeps its own
2455 // compatibility policy; plain native VCS does not need an agent session.
2456 if !options.skip_publication_gate {
2457 let shared_target = {
2458 let txn = self
2459 .pristine
2460 .read_txn()
2461 .map_err(|e| RepositoryError::Database(e.to_string()))?;
2462 txn.get_view(&view_name)
2463 .map_err(|e| RepositoryError::Database(e.to_string()))?
2464 .map(|view| view.kind == atomic_core::pristine::ViewScope::Shared)
2465 .unwrap_or(false)
2466 };
2467 if shared_target {
2468 let admission =
2469 self.native_review_for_insert(&view_name, std::slice::from_ref(hash))?;
2470 options.review_approval = admission.approval;
2471 if !admission.configured {
2472 options.review_decision = self
2473 .review_decision_for_direct_insert(&view_name, std::slice::from_ref(hash))?
2474 .map(|review| {
2475 Hash::from_base32(review.decision.as_bytes())
2476 .expect("verified review decision")
2477 });
2478 if options.review_decision.is_some() {
2479 let closure = super::provenance_gate::reachable_closure(
2480 self,
2481 std::slice::from_ref(hash),
2482 )?;
2483 let provider = super::provenance_gate::local_session_mac_key_provider(self);
2484 let did_provider = super::provenance_gate::local_did_key_provider(self);
2485 self.enforce_publication_gate(

Calls 15

reachable_closureFunction · 0.85
local_did_key_providerFunction · 0.85
WorkingCopyInterface · 0.85
working_copy_state_refFunction · 0.85
graph_visibility_closureFunction · 0.85
write_change_to_graphFunction · 0.85
review_evidence_lockMethod · 0.80