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

Function record_last_shim_operation

atomic-cli/src/commands/git/shim.rs:909–944  ·  view source on GitHub ↗

One `atomic git shim reconcile` run under an explicit effect budget. `Command` (the CLI command) may project Atomic→Git under its expected-old lease. `MetadataOnly` (the optional shim watch daemon, CB-13D) runs the identical shared transaction path — the same entry boundary, observation, classification, and import code — but never exports and never materializes: an export-classified run is refuse

(root: &Path)

Source from the content-addressed store, hash-verified

907/// Best-effort: suppression attribution is advisory, and a failure to
908/// record it never fails the reconciled pass.
909pub(crate) fn record_last_shim_operation(root: &Path) {
910 let record = (|| -> CliResult<()> {
911 let repo = Repository::open_readonly(root).map_err(CliError::from)?;
912 let working_copy = repo.require_working_copy_id().map_err(CliError::from)?;
913 let log = repo
914 .operation_log(
915 atomic_core::operation::OperationScope::WorkingCopy(working_copy),
916 Some(1),
917 true,
918 )
919 .map_err(CliError::from)?;
920 let head = match &log.head_state {
921 atomic_repository::repository::OperationHeadState::Single(id) => id.to_string(),
922 _ => String::new(),
923 };
924 let heads = head.clone();
925 let path = Repository::canonical_dot_dir(root)
926 .map_err(CliError::from)?
927 .join("bridge/suppressed-operation.json");
928 if let Some(parent) = path.parent() {
929 std::fs::create_dir_all(parent).map_err(CliError::from)?;
930 }
931 let payload = format!(
932 "{{\"operation_id\":\"{head}\",\"heads\":\"{heads}\",\"recorded_at\":{}}}",
933 std::time::SystemTime::now()
934 .duration_since(std::time::UNIX_EPOCH)
935 .map(|d| d.as_millis())
936 .unwrap_or(0)
937 );
938 std::fs::write(&path, payload).map_err(CliError::from)?;
939 Ok(())
940 })();
941 if let Err(error) = record {
942 log::warn!("shim watch: could not record the suppression attribution: {error}");
943 }
944}
945
946#[tracing::instrument(name = "reconcile", skip_all, fields(budget = ?budget))]
947pub(crate) fn reconcile_transaction_budgeted(

Callers 2

Calls 6

WorkingCopyInterface · 0.85
operation_logMethod · 0.80
parentMethod · 0.80
writeFunction · 0.50
cloneMethod · 0.45

Tested by

no test coverage detected