| 1961 | } |
| 1962 | |
| 1963 | pub(super) fn record_with_lifecycle( |
| 1964 | &self, |
| 1965 | working_copy: WorkingCopyId, |
| 1966 | header: ChangeHeader, |
| 1967 | options: RecordOptions, |
| 1968 | lifecycle: super::snapshot::RecordLifecycle, |
| 1969 | ) -> Result<RecordOutcome, RecordError> { |
| 1970 | self.validate_working_copy(working_copy) |
| 1971 | .map_err(RecordError::Repository)?; |
| 1972 | // Keep the selected view and the span baseline stable from status |
| 1973 | // through assembly and journaled publication. Nested record operations |
| 1974 | // on this thread reuse the workspace lock. |
| 1975 | let _span_lock = { |
| 1976 | use atomic_core::pristine::{CapabilityTxnT, SPAN_RANGE_CAPABILITY}; |
| 1977 | let txn = self |
| 1978 | .pristine |
| 1979 | .read_txn() |
| 1980 | .map_err(|error| RecordError::Database(error.to_string()))?; |
| 1981 | let capability = txn |
| 1982 | .required_capability_version(SPAN_RANGE_CAPABILITY.id()) |
| 1983 | .map_err(|error| RecordError::Database(error.to_string()))?; |
| 1984 | if capability == Some(2) { |
| 1985 | return Err(RecordError::Database( |
| 1986 | "span capability version 2 requires migration before recording".into(), |
| 1987 | )); |
| 1988 | } |
| 1989 | let enabled = capability.is_some(); |
| 1990 | drop(txn); |
| 1991 | if enabled { |
| 1992 | Some( |
| 1993 | self.try_lock_workspace_operation(working_copy) |
| 1994 | .map_err(RecordError::Repository)?, |
| 1995 | ) |
| 1996 | } else { |
| 1997 | None |
| 1998 | } |
| 1999 | }; |
| 2000 | let desired_view = self |
| 2001 | .desired_view_name(working_copy) |
| 2002 | .map_err(RecordError::Repository)?; |
| 2003 | let effective_view = options |
| 2004 | .get_view() |
| 2005 | .map(str::to_owned) |
| 2006 | .unwrap_or_else(|| desired_view.clone()); |
| 2007 | if effective_view != desired_view { |
| 2008 | return Err(RecordError::Repository(RepositoryError::InvalidOperation { |
| 2009 | message: format!( |
| 2010 | "record view '{}' does not match working copy {} desired view '{}'", |
| 2011 | effective_view, working_copy, desired_view |
| 2012 | ), |
| 2013 | })); |
| 2014 | } |
| 2015 | |
| 2016 | let target_view = lifecycle.target_view(&desired_view).to_string(); |
| 2017 | |
| 2018 | // Scoped stale-conflict cleanup: when the caller explicitly names paths |
| 2019 | // and opts into conflict-marker content, reconcile persisted conflict |
| 2020 | // rows that no longer describe a real graph conflict. This runs before |