Evaluate one Git metadata observation against the reactive preconditions (RFC §11.2 rule 3). Sequence markers of any kind are busy: Git owns that transaction and the bridge does not model half-applied Git state (RFC §7.4).
(observation: &super::git_observation::WorkspaceGitObservation)
| 325 | /// busy: Git owns that transaction and the bridge does not model |
| 326 | /// half-applied Git state (RFC §7.4). |
| 327 | pub fn evaluate(observation: &super::git_observation::WorkspaceGitObservation) -> Self { |
| 328 | match observation { |
| 329 | super::git_observation::WorkspaceGitObservation::NoGit { .. } => Self::Quiescent { |
| 330 | proof: LockScanProof { |
| 331 | inspected: Vec::new(), |
| 332 | skipped_symlink_dirs: Vec::new(), |
| 333 | }, |
| 334 | }, |
| 335 | super::git_observation::WorkspaceGitObservation::Repository(repository) => { |
| 336 | if repository.index_lock.is_present() { |
| 337 | return Self::Busy { |
| 338 | reason: "index_lock", |
| 339 | detail: format!( |
| 340 | "Git index lock present at '{}'", |
| 341 | repository.index_path.display() |
| 342 | ), |
| 343 | }; |
| 344 | } |
| 345 | // Fail closed: an administrative directory that cannot be |
| 346 | // inspected is busy, never silently quiescent (review R2). |
| 347 | let (locks, proof) = match git_locks_present_proved( |
| 348 | &repository.common_dir, |
| 349 | &repository.worktree_git_dir, |
| 350 | ) { |
| 351 | Ok((locks, proof)) => (locks, proof), |
| 352 | Err(detail) => { |
| 353 | return Self::Busy { |
| 354 | reason: "lock_enumeration_failed", |
| 355 | detail, |
| 356 | } |
| 357 | } |
| 358 | }; |
| 359 | if !locks.is_empty() { |
| 360 | return Self::Busy { |
| 361 | reason: "ref_locks", |
| 362 | detail: format!( |
| 363 | "Git ref transaction in flight ({} lock file(s)); inspected namespaces {:?}, skipped symlink dirs {:?}", |
| 364 | locks.len(), |
| 365 | proof.inspected, |
| 366 | proof.skipped_symlink_dirs |
| 367 | ), |
| 368 | }; |
| 369 | } |
| 370 | if repository.operation.is_in_progress() { |
| 371 | let markers: Vec<String> = repository |
| 372 | .operation |
| 373 | .present_markers() |
| 374 | .into_iter() |
| 375 | .map(|marker| marker.to_string()) |
| 376 | .collect(); |
| 377 | return Self::Busy { |
| 378 | reason: "sequence_markers", |
| 379 | detail: format!("Git-owned sequence operation in progress ({markers:?})"), |
| 380 | }; |
| 381 | } |
| 382 | Self::Quiescent { proof } |
| 383 | } |
| 384 | } |
no test coverage detected