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

Function has_pending_changes

atomic-agent/src/record/scope.rs:184–208  ·  view source on GitHub ↗

A duplicate Stop can be acknowledged only if its scoped files have no unrecorded changes. Never use unrelated working-tree edits as evidence of a new turn, and never silently accept an invalid or stale manifest.

(
    root: &Path,
    options: &TurnRecordOptions<'_>,
)

Source from the content-addressed store, hash-verified

182/// unrecorded changes. Never use unrelated working-tree edits as evidence of
183/// a new turn, and never silently accept an invalid or stale manifest.
184pub(crate) fn has_pending_changes(
185 root: &Path,
186 options: &TurnRecordOptions<'_>,
187) -> AgentResult<bool> {
188 let Some(files) = manifest(options)? else {
189 return Ok(false);
190 };
191 if files.is_empty() {
192 return Ok(false);
193 }
194 validate(root, &files, options)?;
195 let fail = |error: atomic_repository::RepositoryError| AgentError::RecordFailed {
196 session_id: options.session.session_id.clone(),
197 turn_number: options.turn_number,
198 reason: format!("cannot verify duplicate Stop's scoped files: {error}"),
199 };
200 let repo =
201 Repository::open_readonly_wait(root, std::time::Duration::from_secs(10)).map_err(fail)?;
202 let working_copy = repo.require_working_copy_id().map_err(fail)?;
203 let status = repo
204 .status(working_copy, StatusOptions::default().with_untracked(true))
205 .map_err(fail)?;
206 let scoped = filter(status, Some(&files));
207 Ok(!scoped.is_clean() || scoped.has_untracked() || scoped.has_conflicts())
208}
209
210pub(super) fn filter(status: RepositoryStatus, files: Option<&FileManifest>) -> RepositoryStatus {
211 let Some(files) = files else {

Callers 1

handle_turn_endMethod · 0.85

Calls 11

with_untrackedMethod · 0.80
has_untrackedMethod · 0.80
manifestFunction · 0.70
validateFunction · 0.70
filterFunction · 0.70
is_emptyMethod · 0.45
cloneMethod · 0.45
statusMethod · 0.45
is_cleanMethod · 0.45
has_conflictsMethod · 0.45

Tested by

no test coverage detected