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

Function capture_turn_boundary

atomic-agent/src/record/mod.rs:130–196  ·  view source on GitHub ↗

Capture one durable turn boundary from a live repository handle. Observation only: nothing is interpreted, reconciled or materialized (RFC §12.1/§12.2 — reconciliation happens in repository command boundaries; the agent boundary observes). Fields the repository cannot compute yet stay `None` and are documented on `TurnBoundary`.

(
    repo: &atomic_repository::Repository,
    repo_root: &Path,
    session_id: &str,
    turn: u32,
)

Source from the content-addressed store, hash-verified

128/// boundaries; the agent boundary observes). Fields the repository cannot
129/// compute yet stay `None` and are documented on `TurnBoundary`.
130pub fn capture_turn_boundary(
131 repo: &atomic_repository::Repository,
132 repo_root: &Path,
133 session_id: &str,
134 turn: u32,
135) -> Option<TurnBoundary> {
136 let working_copy = match repo.require_working_copy_id() {
137 Ok(working_copy) => working_copy.to_string(),
138 Err(error) => {
139 log::warn!(
140 "Boundary capture: cannot resolve working-copy identity: {}",
141 error
142 );
143 return None;
144 }
145 };
146
147 let view = repo.current_view().to_string();
148 let (view_state, set_id) = match repo.view_identity(&view) {
149 Ok(identity) => (Some(identity.merkle), Some(identity.set_id)),
150 Err(error) => {
151 // The view does not exist yet (e.g. a session view forked at
152 // first record) — record the boundary with unknown identity.
153 log::debug!(
154 "Boundary capture: view '{}' identity unavailable: {}",
155 view,
156 error
157 );
158 (None, None)
159 }
160 };
161
162 let git = match atomic_repository::observe_git_metadata(repo_root) {
163 Ok(observation) => Some(git_checkpoint(&observation.token())),
164 Err(error) => {
165 log::warn!("Boundary capture: git observation failed: {}", error);
166 None
167 }
168 };
169
170 Some(TurnBoundary {
171 working_copy,
172 operation: (|| {
173 use atomic_core::pristine::OperationTxnT;
174 let id = repo.require_working_copy_id().ok()?;
175 let txn = repo.pristine().read_txn().ok()?;
176 let heads = txn
177 .get_operation_heads(atomic_core::operation::OperationScope::WorkingCopy(id))
178 .ok()?;
179 match heads.as_slice() {
180 [head] => Some(head.to_string()),
181 _ => None,
182 }
183 })(),
184 view,
185 view_state,
186 set_id,
187 snapshot: None,

Calls 13

observe_git_metadataFunction · 0.85
git_checkpointFunction · 0.85
WorkingCopyInterface · 0.85
view_identityMethod · 0.80
tokenMethod · 0.80
read_txnMethod · 0.80
pristineMethod · 0.80
current_viewMethod · 0.45
okMethod · 0.45
get_operation_headsMethod · 0.45
as_sliceMethod · 0.45