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

Function exact_managed_commit

atomic-cli/src/commands/agent/hooks.rs:610–633  ·  view source on GitHub ↗

The exact managed commit that explains a detached-HEAD refusal at turn end, if there is one (CB-12A follow-up AC-8). The agent library proves the commit is the turn's own work (authenticated commit-time capture, no worktree remainder). This adds the checks only the CLI can make: the verified checkpoint still names the session's Draft view at the commit's parent, and the commit is that parent's si

(
    repository: &Repository,
    repository_root: &std::path::Path,
    session_id: &str,
    remediation: &atomic_repository::WorkspaceRemediation,
)

Source from the content-addressed store, hash-verified

608/// at the commit's parent, and the commit is that parent's single direct
609/// child, so an amend, rebase, merge or foreign commit never qualifies.
610fn exact_managed_commit(
611 repository: &Repository,
612 repository_root: &std::path::Path,
613 session_id: &str,
614 remediation: &atomic_repository::WorkspaceRemediation,
615) -> Option<atomic_agent::record::ExactManagedCommit> {
616 let atomic_repository::WorkspaceRemediation::Unanchored {
617 state: atomic_repository::UnanchoredWorkspace::DetachedHead { oid },
618 ..
619 } = remediation
620 else {
621 return None;
622 };
623 match exact_managed_commit_at(repository, repository_root, session_id, oid) {
624 Ok(commit) => Some(commit),
625 Err(reason) => {
626 log::info!(
627 "hooks: detached HEAD {oid} is not absorbed into the turn of session \
628 {session_id}: {reason}"
629 );
630 None
631 }
632 }
633}
634
635/// [`exact_managed_commit`] with the reason a commit does not qualify.
636fn exact_managed_commit_at(

Callers 1

guard_agent_boundaryFunction · 0.85

Calls 1

exact_managed_commit_atFunction · 0.85

Tested by

no test coverage detected