1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//! Read-only task observations keep saved progress distinct from current Git facts.
use crate::{Control, Participant, Problem, Task};
use std::{future::Future, path::PathBuf};
/// Recorded task and evidence available during read-only inspection.
pub struct TaskSnapshot {
/// Name used to identify this entry.
pub name: Option<String>,
/// Location of the task record when available.
pub record: PathBuf,
/// Decoded task when the published record is readable.
pub task: Option<Task>,
/// Independent evidence available for checking the task record.
pub evidence: Option<Task>,
/// Participant index associated with unresolved effect evidence.
pub pending: Option<usize>,
/// Whether another operation currently holds admission.
pub busy: bool,
/// Diagnostics collected while reading or inspecting the task.
pub problems: Vec<Problem>,
}
/// Current branch, worktree location and working-copy observations from Git.
pub struct GitFacts {
/// Verified common Git storage, not the linked worktree administration.
pub common_dir: Option<PathBuf>,
/// Source location verified against the participant's Git backing identity.
pub repository_source: Option<PathBuf>,
/// An observed condition can be known (such as absence) and still need a remedy.
pub problem: Option<Problem>,
/// Worktree location reported by Git, when available.
pub path: Option<PathBuf>,
/// Branch associated with the worktree, when known.
pub branch: Option<String>,
/// Whether the worktree has local changes.
pub dirty: bool,
/// Whether Git reports unresolved conflicts.
pub conflicted: bool,
/// Whether an unfinished repository operation was observed.
pub operation_in_progress: bool,
}
/// Recorded participant paired with its current observation.
pub struct ParticipantInspection {
/// Participant to which this observation or change applies.
pub participant: Participant,
/// Facts collected from the current filesystem or Git inspection.
pub current: Result<GitFacts, Problem>,
}
/// Snapshot and live participant observations for a task.
pub struct TaskInspection {
/// Task and evidence as read before inspecting participants.
pub snapshot: TaskSnapshot,
/// Members associated with this task or operation.
pub participants: Vec<ParticipantInspection>,
}
/// Read-only Git inspection used by status and recovery decisions.
pub trait ObservationGit: Sync {
/// Collect live repository facts for a recorded participant.
fn observe(
&self,
participant: &Participant,
control: &Control,
) -> impl Future<Output = Result<GitFacts, Problem>> + Send;
}
/// Inspect the selected repository or task without applying changes.
pub async fn inspect(
snapshot: TaskSnapshot,
git: &impl ObservationGit,
control: &Control,
) -> Result<TaskInspection, Problem> {
let mut participants = Vec::new();
// Independent evidence can describe intended membership when publication failed.
// It remains separately identified in the result, never reconstructed as a record.
if let Some(task) = snapshot.task.as_ref().or(snapshot.evidence.as_ref()) {
for participant in &task.participants {
control.check()?;
let current = git.observe(participant, control).await;
control.check()?;
participants.push(ParticipantInspection {
participant: participant.clone(),
current,
});
}
}
Ok(TaskInspection {
snapshot,
participants,
})
}