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

Function classify_clean_turn

atomic-agent/src/record/mod.rs:727–868  ·  view source on GitHub ↗
(
    repo: &atomic_repository::Repository,
    repo_root: &Path,
    options: &TurnRecordOptions<'_>,
    boundary_start: Option<TurnBoundary>,
    boundary_end: TurnBoundary,
)

Source from the content-addressed store, hash-verified

725/// Classify a turn whose working copy is clean (no durable content change).
726#[allow(clippy::too_many_arguments)]
727fn classify_clean_turn(
728 repo: &atomic_repository::Repository,
729 repo_root: &Path,
730 options: &TurnRecordOptions<'_>,
731 boundary_start: Option<TurnBoundary>,
732 boundary_end: TurnBoundary,
733) -> ClassifiedTurn {
734 let start_git = boundary_start
735 .as_ref()
736 .and_then(|boundary| boundary.git.clone());
737 let end_git = boundary_end.git.clone();
738
739 // A repository without Git has no checkpoint to classify; a clean
740 // turn there is a legitimate ObservationOnly, never an observation
741 // gap. Only a Git-bearing repository refuses unverifiable transitions.
742 if !repo_root.join(".git").exists() {
743 return ClassifiedTurn {
744 outcome: ManagedTurnOutcome::ObservationOnly,
745 boundary_start,
746 boundary_end: Some(boundary_end),
747 incomplete: None,
748 };
749 }
750
751 // No baseline: refuse to claim ObservationOnly, record the observation
752 // gap explicitly, and durably refuse attribution (review R3: the missing
753 // observation is itself evidence, never a silent success).
754 let Some(start_git) = start_git else {
755 log::warn!(
756 "Turn-end classification for session {} has no turn-start baseline; \
757 HEAD/index transition is unverifiable and no attribution is claimed",
758 options.session.session_id
759 );
760 let unbound = boundary_end
761 .git
762 .as_ref()
763 .and_then(|git| git.head_oid.clone())
764 .unwrap_or_default();
765 let incomplete = IncompleteSession::new(
766 "turn-start boundary unavailable; HEAD/index transition unverifiable and \
767 no attribution is claimed (RFC §10.2)",
768 Vec::<String>::new(),
769 String::new(),
770 SessionIncompleteOrigin::ObservationUnavailable,
771 )
772 .with_unbound_commits(vec![unbound]);
773 return ClassifiedTurn {
774 outcome: ManagedTurnOutcome::RepositoryOperations {
775 operations: vec![
776 "turn-start boundary unavailable; HEAD/index transition unverifiable"
777 .to_string(),
778 ],
779 capture: None,
780 },
781 boundary_start,
782 boundary_end: Some(boundary_end),
783 incomplete: Some(incomplete),
784 };

Callers 1

record_turnFunction · 0.85

Calls 8

describe_git_transitionFunction · 0.85
classify_git_transitionFunction · 0.85
as_refMethod · 0.80
with_unbound_commitsMethod · 0.80
cloneMethod · 0.45
existsMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected