Skip to main content

ito_domain/changes/
repository.rs

1//! Change repository port definitions.
2
3use super::{Change, ChangeSummary};
4use crate::errors::DomainResult;
5
6/// Deterministic resolution result for a change target input.
7#[derive(Debug, Clone, PartialEq, Eq)]
8pub enum ChangeTargetResolution {
9    /// Exactly one canonical change id matched.
10    Unique(String),
11    /// Multiple canonical change ids matched the target.
12    Ambiguous(Vec<String>),
13    /// No changes matched the target.
14    NotFound,
15}
16
17/// Options for resolving a change target.
18#[derive(Debug, Clone, Copy, Default)]
19pub struct ResolveTargetOptions {
20    /// Include archived changes under `.ito/changes/archive/` as resolver candidates.
21    pub include_archived: bool,
22}
23
24/// Port for accessing change data.
25///
26/// Domain and adapters should depend on this interface rather than concrete
27/// storage details.
28pub trait ChangeRepository {
29    /// Resolve an input change target into a canonical change id.
30    fn resolve_target(&self, input: &str) -> ChangeTargetResolution {
31        self.resolve_target_with_options(input, ResolveTargetOptions::default())
32    }
33
34    /// Resolve an input change target into a canonical change id using options.
35    fn resolve_target_with_options(
36        &self,
37        input: &str,
38        options: ResolveTargetOptions,
39    ) -> ChangeTargetResolution;
40
41    /// Return best-effort suggestions for a change target.
42    fn suggest_targets(&self, input: &str, max: usize) -> Vec<String>;
43
44    /// Check if a change exists.
45    fn exists(&self, id: &str) -> bool;
46
47    /// Get a full change with all artifacts loaded.
48    fn get(&self, id: &str) -> DomainResult<Change>;
49
50    /// List all changes as summaries (lightweight).
51    fn list(&self) -> DomainResult<Vec<ChangeSummary>>;
52
53    /// List changes belonging to a specific module.
54    fn list_by_module(&self, module_id: &str) -> DomainResult<Vec<ChangeSummary>>;
55
56    /// List changes with incomplete tasks.
57    fn list_incomplete(&self) -> DomainResult<Vec<ChangeSummary>>;
58
59    /// List changes with all tasks complete.
60    fn list_complete(&self) -> DomainResult<Vec<ChangeSummary>>;
61
62    /// Get a summary for a specific change (lightweight).
63    fn get_summary(&self, id: &str) -> DomainResult<ChangeSummary>;
64}