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

Function worktree_has_remainder

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

Whether the working tree carries changes beyond the Git HEAD (unstaged or untracked content) — the CB-12A follow-up exact-separability oracle. A clean worktree at the boundary means the turn's recorded content equals the commit tree exactly (no remainder), so the verified capture's HEAD→index delta IS the recorded delta. Read-only; any git failure is conservatively a remainder (never claims exactn

(repo_root: &Path)

Source from the content-addressed store, hash-verified

917/// HEAD→index delta IS the recorded delta. Read-only; any git failure is
918/// conservatively a remainder (never claims exactness).
919fn worktree_has_remainder(repo_root: &Path) -> bool {
920 let Ok(output) = std::process::Command::new("git")
921 .args(["status", "--porcelain"])
922 .current_dir(repo_root)
923 .output()
924 else {
925 return true;
926 };
927 if !output.status.success() {
928 return true;
929 }
930 // Atomic-owned state (.atomic/, .vault/) is never content remainder.
931 let stdout = String::from_utf8_lossy(&output.stdout).into_owned();
932 let remainder_lines: Vec<&str> = stdout
933 .lines()
934 .filter(|line| {
935 let path = line.get(3..).unwrap_or(line);
936 !(path.starts_with(".atomic/") || path.starts_with(".vault/"))
937 })
938 .collect();
939 !remainder_lines.is_empty()
940}
941
942/// Build a `ChangeHeader` for an agent turn.///
943/// The message is built from the file changes and prompt context:

Callers 1

classify_git_transitionFunction · 0.85

Calls 6

successMethod · 0.80
getMethod · 0.65
outputMethod · 0.45
collectMethod · 0.45
linesMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected