1use chrono::{DateTime, TimeZone, Utc};
4use ito_common::fs::{FileSystem, StdFs};
5use ito_common::match_::nearest_matches;
6use ito_common::paths;
7use ito_domain::changes::{
8 Change, ChangeLifecycleFilter, ChangeRepository as DomainChangeRepository, ChangeStatus,
9 ChangeSummary, ChangeTargetResolution, ResolveTargetOptions, Spec, extract_module_id,
10 extract_sub_module_id, parse_change_id, parse_module_id,
11};
12use ito_domain::discovery;
13use ito_domain::errors::{DomainError, DomainResult};
14use ito_domain::tasks::TaskRepository as DomainTaskRepository;
15use regex::Regex;
16use std::collections::{BTreeMap, BTreeSet};
17use std::path::{Path, PathBuf};
18
19use crate::front_matter;
20use crate::task_repository::FsTaskRepository;
21
22pub struct FsChangeRepository<'a, F: FileSystem = StdFs> {
24 ito_path: &'a Path,
25 task_repo: FsTaskRepository<'a>,
26 fs: F,
27}
28
29#[derive(Debug, Clone, Copy, PartialEq, Eq)]
30enum ChangeLifecycle {
31 Active,
32 Archived,
33}
34
35#[derive(Debug, Clone)]
36struct ChangeLocation {
37 id: String,
38 path: PathBuf,
39 lifecycle: ChangeLifecycle,
40}
41
42impl<'a> FsChangeRepository<'a, StdFs> {
43 pub fn new(ito_path: &'a Path) -> Self {
45 Self::with_fs(ito_path, StdFs)
46 }
47}
48
49impl<'a, F: FileSystem> FsChangeRepository<'a, F> {
50 pub fn with_fs(ito_path: &'a Path, fs: F) -> Self {
52 Self::with_task_repo(ito_path, FsTaskRepository::new(ito_path), fs)
53 }
54
55 pub fn with_task_repo(ito_path: &'a Path, task_repo: FsTaskRepository<'a>, fs: F) -> Self {
60 Self {
61 ito_path,
62 task_repo,
63 fs,
64 }
65 }
66
67 pub fn resolve_target(&self, input: &str) -> ChangeTargetResolution {
69 DomainChangeRepository::resolve_target(self, input)
70 }
71
72 pub fn resolve_target_with_options(
74 &self,
75 input: &str,
76 options: ResolveTargetOptions,
77 ) -> ChangeTargetResolution {
78 DomainChangeRepository::resolve_target_with_options(self, input, options)
79 }
80
81 pub fn suggest_targets(&self, input: &str, max: usize) -> Vec<String> {
83 DomainChangeRepository::suggest_targets(self, input, max)
84 }
85
86 pub fn exists(&self, id: &str) -> bool {
88 DomainChangeRepository::exists(self, id)
89 }
90
91 pub fn get(&self, id: &str) -> DomainResult<Change> {
93 DomainChangeRepository::get(self, id)
94 }
95
96 pub fn list(&self) -> DomainResult<Vec<ChangeSummary>> {
98 DomainChangeRepository::list(self)
99 }
100
101 pub fn list_by_module(&self, module_id: &str) -> DomainResult<Vec<ChangeSummary>> {
103 DomainChangeRepository::list_by_module(self, module_id)
104 }
105
106 pub fn list_incomplete(&self) -> DomainResult<Vec<ChangeSummary>> {
108 DomainChangeRepository::list_incomplete(self)
109 }
110
111 pub fn list_complete(&self) -> DomainResult<Vec<ChangeSummary>> {
113 DomainChangeRepository::list_complete(self)
114 }
115
116 pub fn get_summary(&self, id: &str) -> DomainResult<ChangeSummary> {
118 DomainChangeRepository::get_summary(self, id)
119 }
120
121 fn changes_dir(&self) -> std::path::PathBuf {
122 paths::changes_dir(self.ito_path)
123 }
124
125 fn list_change_locations(&self, filter: ChangeLifecycleFilter) -> Vec<ChangeLocation> {
126 let mut active = Vec::new();
127 if filter.includes_active() {
128 active = self.list_active_locations();
129 }
130
131 let mut archived = Vec::new();
132 if filter.includes_archived() {
133 archived = self.list_archived_locations();
134 }
135
136 match filter {
137 ChangeLifecycleFilter::Active => active,
138 ChangeLifecycleFilter::Archived => archived,
139 ChangeLifecycleFilter::All => {
140 let mut merged: BTreeMap<String, ChangeLocation> = BTreeMap::new();
141 for loc in active {
142 merged.insert(loc.id.clone(), loc);
143 }
144 for loc in archived {
145 merged.entry(loc.id.clone()).or_insert(loc);
146 }
147 merged.into_values().collect()
148 }
149 }
150 }
151
152 fn list_active_locations(&self) -> Vec<ChangeLocation> {
153 let mut out = Vec::new();
154 for name in discovery::list_change_dir_names(&self.fs, self.ito_path).unwrap_or_default() {
155 let path = self.changes_dir().join(&name);
156 out.push(ChangeLocation {
157 id: name,
158 path,
159 lifecycle: ChangeLifecycle::Active,
160 });
161 }
162 out.sort_by(|a, b| a.id.cmp(&b.id));
163 out
164 }
165
166 fn list_archived_locations(&self) -> Vec<ChangeLocation> {
167 let archive_dir = self.changes_dir().join("archive");
168 let mut by_id: BTreeMap<String, String> = BTreeMap::new();
169 let archived = discovery::list_dir_names(&self.fs, &archive_dir).unwrap_or_default();
170
171 for name in archived {
172 let Some(change_id) = self.parse_archived_change_id(&name) else {
173 continue;
174 };
175 let entry = by_id.entry(change_id).or_insert(name.clone());
176 if name > *entry {
177 *entry = name;
178 }
179 }
180
181 let mut out = Vec::new();
182 for (id, dir_name) in by_id {
183 out.push(ChangeLocation {
184 id,
185 path: archive_dir.join(dir_name),
186 lifecycle: ChangeLifecycle::Archived,
187 });
188 }
189 out
190 }
191
192 fn parse_archived_change_id(&self, name: &str) -> Option<String> {
193 if let Some(remainder) = self.strip_archive_date_prefix(name)
194 && parse_change_id(remainder).is_some()
195 {
196 return Some(remainder.to_string());
197 }
198
199 if parse_change_id(name).is_some() {
200 return Some(name.to_string());
201 }
202
203 None
204 }
205
206 fn strip_archive_date_prefix<'b>(&self, name: &'b str) -> Option<&'b str> {
207 let mut parts = name.splitn(4, '-');
208 let year = parts.next()?;
209 let month = parts.next()?;
210 let day = parts.next()?;
211 let remainder = parts.next()?;
212
213 if year.len() != 4 || month.len() != 2 || day.len() != 2 {
214 return None;
215 }
216 if !year.chars().all(|c| c.is_ascii_digit())
217 || !month.chars().all(|c| c.is_ascii_digit())
218 || !day.chars().all(|c| c.is_ascii_digit())
219 {
220 return None;
221 }
222 if remainder.trim().is_empty() {
223 return None;
224 }
225 Some(remainder)
226 }
227
228 fn list_change_ids(&self, filter: ChangeLifecycleFilter) -> Vec<String> {
229 let mut out: Vec<String> = self
230 .list_change_locations(filter)
231 .into_iter()
232 .map(|loc| loc.id)
233 .collect();
234 out.sort();
235 out.dedup();
236 out
237 }
238
239 fn find_change_location(
240 &self,
241 id: &str,
242 filter: ChangeLifecycleFilter,
243 ) -> Option<ChangeLocation> {
244 self.list_change_locations(filter)
245 .into_iter()
246 .find(|loc| loc.id == id)
247 }
248
249 fn split_canonical_change_id<'b>(&self, name: &'b str) -> Option<(String, String, &'b str)> {
250 let (module_id, change_num) = parse_change_id(name)?;
251 let slug = name.split_once('_').map(|(_id, s)| s).unwrap_or("");
252 Some((module_id, change_num, slug))
253 }
254
255 fn tokenize_query(&self, input: &str) -> Vec<String> {
256 input
257 .split_whitespace()
258 .map(|s| s.trim().to_lowercase())
259 .filter(|s| !s.is_empty())
260 .collect()
261 }
262
263 fn normalized_slug_text(&self, slug: &str) -> String {
264 let mut out = String::new();
265 for ch in slug.chars() {
266 if ch.is_ascii_alphanumeric() {
267 out.push(ch.to_ascii_lowercase());
268 } else {
269 out.push(' ');
270 }
271 }
272 out
273 }
274
275 fn slug_matches_tokens(&self, slug: &str, tokens: &[String]) -> bool {
276 if tokens.is_empty() {
277 return false;
278 }
279 let text = self.normalized_slug_text(slug);
280 for token in tokens {
281 if !text.contains(token) {
282 return false;
283 }
284 }
285 true
286 }
287
288 fn is_numeric_module_selector(&self, input: &str) -> bool {
289 let trimmed = input.trim();
290 !trimmed.is_empty() && trimmed.chars().all(|ch| ch.is_ascii_digit())
291 }
292
293 fn extract_two_numbers_as_change_id(&self, input: &str) -> Option<(String, String)> {
294 let re = Regex::new(r"\d+").ok()?;
295 let mut parts: Vec<&str> = Vec::new();
296 for m in re.find_iter(input) {
297 parts.push(m.as_str());
298 if parts.len() > 2 {
299 return None;
300 }
301 }
302 if parts.len() != 2 {
303 return None;
304 }
305 let parsed = format!("{}-{}", parts[0], parts[1]);
306 parse_change_id(&parsed)
307 }
308
309 fn resolve_unique_change_id(
310 &self,
311 input: &str,
312 filter: ChangeLifecycleFilter,
313 ) -> DomainResult<String> {
314 match self.resolve_target_with_options(input, ResolveTargetOptions { lifecycle: filter }) {
315 ChangeTargetResolution::Unique(id) => Ok(id),
316 ChangeTargetResolution::Ambiguous(matches) => {
317 Err(DomainError::ambiguous_target("change", input, &matches))
318 }
319 ChangeTargetResolution::NotFound => Err(DomainError::not_found("change", input)),
320 }
321 }
322
323 fn resolve_unique_change_location(
324 &self,
325 input: &str,
326 filter: ChangeLifecycleFilter,
327 ) -> DomainResult<ChangeLocation> {
328 let id = self.resolve_unique_change_id(input, filter)?;
329 self.find_change_location(&id, filter)
330 .ok_or_else(|| DomainError::not_found("change", input))
331 }
332
333 fn read_optional_file(&self, path: &Path) -> DomainResult<Option<String>> {
334 if self.fs.is_file(path) {
335 let content = self
336 .fs
337 .read_to_string(path)
338 .map_err(|source| DomainError::io("reading optional file", source))?;
339 Ok(Some(content))
340 } else {
341 Ok(None)
342 }
343 }
344
345 fn load_specs(&self, change_path: &Path) -> DomainResult<Vec<Spec>> {
346 let specs_dir = change_path.join("specs");
347 if !self.fs.is_dir(&specs_dir) {
348 return Ok(Vec::new());
349 }
350
351 let mut specs = Vec::new();
352 for name in discovery::list_dir_names(&self.fs, &specs_dir)? {
353 let spec_file = specs_dir.join(&name).join("spec.md");
354 if self.fs.is_file(&spec_file) {
355 let content = self
356 .fs
357 .read_to_string(&spec_file)
358 .map_err(|source| DomainError::io("reading spec file", source))?;
359 specs.push(Spec { name, content });
360 }
361 }
362
363 specs.sort_by(|a, b| a.name.cmp(&b.name));
364 Ok(specs)
365 }
366
367 fn has_specs(&self, change_path: &Path) -> bool {
368 let specs_dir = change_path.join("specs");
369 if !self.fs.is_dir(&specs_dir) {
370 return false;
371 }
372
373 discovery::list_dir_names(&self.fs, &specs_dir)
374 .map(|entries| {
375 entries
376 .into_iter()
377 .any(|name| self.fs.is_file(&specs_dir.join(name).join("spec.md")))
378 })
379 .unwrap_or(false)
380 }
381
382 fn validate_artifact_front_matter(
389 &self,
390 content: &str,
391 expected_change_id: &str,
392 ) -> DomainResult<()> {
393 let parsed = front_matter::parse(content).map_err(|e| {
394 DomainError::io(
395 "parsing front matter",
396 std::io::Error::new(std::io::ErrorKind::InvalidData, e.to_string()),
397 )
398 })?;
399
400 let Some(fm) = &parsed.front_matter else {
401 return Ok(());
402 };
403
404 front_matter::validate_id("change_id", fm.change_id.as_deref(), expected_change_id)
406 .map_err(|e| {
407 DomainError::io(
408 "front matter validation",
409 std::io::Error::new(std::io::ErrorKind::InvalidData, e.to_string()),
410 )
411 })?;
412
413 front_matter::validate_integrity(fm, &parsed.body).map_err(|e| {
415 DomainError::io(
416 "front matter integrity",
417 std::io::Error::new(std::io::ErrorKind::InvalidData, e.to_string()),
418 )
419 })?;
420
421 Ok(())
422 }
423
424 fn get_last_modified(&self, change_path: &Path) -> DomainResult<DateTime<Utc>> {
425 let mut latest = Utc.with_ymd_and_hms(1970, 1, 1, 0, 0, 0).unwrap();
426
427 for entry in walkdir::WalkDir::new(change_path)
428 .into_iter()
429 .filter_map(|e| e.ok())
430 {
431 if let Ok(metadata) = entry.metadata()
432 && let Ok(modified) = metadata.modified()
433 {
434 let dt: DateTime<Utc> = modified.into();
435 if dt > latest {
436 latest = dt;
437 }
438 }
439 }
440
441 Ok(latest)
442 }
443
444 fn load_tasks_for_location(
445 &self,
446 location: &ChangeLocation,
447 ) -> DomainResult<ito_domain::tasks::TasksParseResult> {
448 match location.lifecycle {
449 ChangeLifecycle::Active => self.task_repo.load_tasks(&location.id),
450 ChangeLifecycle::Archived => self.task_repo.load_tasks_from_dir(&location.path),
451 }
452 }
453
454 fn build_summary_for_location(&self, location: &ChangeLocation) -> DomainResult<ChangeSummary> {
455 let tasks = self.load_tasks_for_location(location)?;
456 let progress = tasks.progress;
457 let completed_tasks = progress.complete as u32;
458 let shelved_tasks = progress.shelved as u32;
459 let in_progress_tasks = progress.in_progress as u32;
460 let pending_tasks = progress.pending as u32;
461 let total_tasks = progress.total as u32;
462 let last_modified = self.get_last_modified(&location.path)?;
463
464 let has_proposal = self.fs.is_file(&location.path.join("proposal.md"));
465 let has_design = self.fs.is_file(&location.path.join("design.md"));
466 let has_specs = self.has_specs(&location.path);
467 let has_tasks = total_tasks > 0;
468 let module_id = extract_module_id(&location.id);
469 let sub_module_id = extract_sub_module_id(&location.id);
470 let meta = crate::change_meta::read_change_meta_from_dir(&self.fs, &location.path);
471
472 Ok(ChangeSummary {
473 id: location.id.clone(),
474 module_id,
475 sub_module_id,
476 completed_tasks,
477 shelved_tasks,
478 in_progress_tasks,
479 pending_tasks,
480 total_tasks,
481 last_modified,
482 has_proposal,
483 has_design,
484 has_specs,
485 has_tasks,
486 orchestrate: meta.orchestrate,
487 })
488 }
489}
490
491impl<'a, F: FileSystem> DomainChangeRepository for FsChangeRepository<'a, F> {
492 fn resolve_target_with_options(
493 &self,
494 input: &str,
495 options: ResolveTargetOptions,
496 ) -> ChangeTargetResolution {
497 let names = self.list_change_ids(options.lifecycle);
498 if names.is_empty() {
499 return ChangeTargetResolution::NotFound;
500 }
501
502 let input = input.trim();
503 if input.is_empty() {
504 return ChangeTargetResolution::NotFound;
505 }
506
507 if names.iter().any(|name| name == input) {
508 return ChangeTargetResolution::Unique(input.to_string());
509 }
510
511 let mut numeric_matches: BTreeSet<String> = BTreeSet::new();
512 let numeric_selector =
513 parse_change_id(input).or_else(|| self.extract_two_numbers_as_change_id(input));
514 if let Some((module_id, change_num)) = numeric_selector {
515 let numeric_prefix = format!("{module_id}-{change_num}");
516 let with_separator = format!("{numeric_prefix}_");
517 for name in &names {
518 if name == &numeric_prefix || name.starts_with(&with_separator) {
519 numeric_matches.insert(name.clone());
520 }
521 }
522 if !numeric_matches.is_empty() {
523 let numeric_matches: Vec<String> = numeric_matches.into_iter().collect();
524 if numeric_matches.len() == 1 {
525 return ChangeTargetResolution::Unique(numeric_matches[0].clone());
526 }
527 return ChangeTargetResolution::Ambiguous(numeric_matches);
528 }
529 }
530
531 if let Some((module, query)) = input.split_once(':') {
532 let query = query.trim();
533 if !query.is_empty() {
534 let module_id = parse_module_id(module);
535 let tokens = self.tokenize_query(query);
536 let mut scoped_matches: BTreeSet<String> = BTreeSet::new();
537 for name in &names {
538 let Some((name_module, _name_change, slug)) =
539 self.split_canonical_change_id(name)
540 else {
541 continue;
542 };
543 if name_module != module_id {
544 continue;
545 }
546 if self.slug_matches_tokens(slug, &tokens) {
547 scoped_matches.insert(name.clone());
548 }
549 }
550
551 if scoped_matches.is_empty() {
552 return ChangeTargetResolution::NotFound;
553 }
554 let scoped_matches: Vec<String> = scoped_matches.into_iter().collect();
555 if scoped_matches.len() == 1 {
556 return ChangeTargetResolution::Unique(scoped_matches[0].clone());
557 }
558 return ChangeTargetResolution::Ambiguous(scoped_matches);
559 }
560 }
561
562 if self.is_numeric_module_selector(input) {
563 let module_id = parse_module_id(input);
564 let mut module_matches: BTreeSet<String> = BTreeSet::new();
565 for name in &names {
566 let Some((name_module, _name_change, _slug)) = self.split_canonical_change_id(name)
567 else {
568 continue;
569 };
570 if name_module == module_id {
571 module_matches.insert(name.clone());
572 }
573 }
574
575 if !module_matches.is_empty() {
576 let module_matches: Vec<String> = module_matches.into_iter().collect();
577 if module_matches.len() == 1 {
578 return ChangeTargetResolution::Unique(module_matches[0].clone());
579 }
580 return ChangeTargetResolution::Ambiguous(module_matches);
581 }
582 }
583
584 let mut matches: BTreeSet<String> = BTreeSet::new();
585 for name in &names {
586 if name.starts_with(input) {
587 matches.insert(name.clone());
588 }
589 }
590
591 if matches.is_empty() {
592 let tokens = self.tokenize_query(input);
593 for name in &names {
594 let Some((_module, _change, slug)) = self.split_canonical_change_id(name) else {
595 continue;
596 };
597 if self.slug_matches_tokens(slug, &tokens) {
598 matches.insert(name.clone());
599 }
600 }
601 }
602
603 if matches.is_empty() {
604 return ChangeTargetResolution::NotFound;
605 }
606
607 let matches: Vec<String> = matches.into_iter().collect();
608 if matches.len() == 1 {
609 return ChangeTargetResolution::Unique(matches[0].clone());
610 }
611
612 ChangeTargetResolution::Ambiguous(matches)
613 }
614
615 fn suggest_targets(&self, input: &str, max: usize) -> Vec<String> {
616 let input = input.trim().to_lowercase();
617 if input.is_empty() || max == 0 {
618 return Vec::new();
619 }
620
621 let names = self.list_change_ids(ChangeLifecycleFilter::Active);
622 let canonical_names: Vec<String> = names
623 .iter()
624 .filter_map(|name| {
625 self.split_canonical_change_id(name)
626 .map(|(_module, _change, _slug)| name.clone())
627 })
628 .collect();
629 let mut scored: Vec<(usize, String)> = Vec::new();
630 let tokens = self.tokenize_query(&input);
631
632 for name in &canonical_names {
633 let lower = name.to_lowercase();
634 let mut score = 0;
635
636 if lower.starts_with(&input) {
637 score = score.max(100);
638 }
639 if lower.contains(&input) {
640 score = score.max(80);
641 }
642
643 let Some((_module, _change, slug)) = self.split_canonical_change_id(name) else {
644 continue;
645 };
646 if !tokens.is_empty() && self.slug_matches_tokens(slug, &tokens) {
647 score = score.max(70);
648 }
649
650 if let Some((module_id, change_num)) = parse_change_id(&input) {
651 let numeric_prefix = format!("{module_id}-{change_num}");
652 if name.starts_with(&numeric_prefix) {
653 score = score.max(95);
654 }
655 }
656
657 if score > 0 {
658 scored.push((score, name.clone()));
659 }
660 }
661
662 scored.sort_by(|(a_score, a_name), (b_score, b_name)| {
663 b_score.cmp(a_score).then_with(|| a_name.cmp(b_name))
664 });
665
666 let mut out: Vec<String> = scored
667 .into_iter()
668 .map(|(_score, name)| name)
669 .take(max)
670 .collect();
671
672 if out.len() < max {
673 let nearest = nearest_matches(&input, &canonical_names, max * 2);
674 for candidate in nearest {
675 if out.iter().any(|existing| existing == &candidate) {
676 continue;
677 }
678 out.push(candidate);
679 if out.len() == max {
680 break;
681 }
682 }
683 }
684
685 out
686 }
687
688 fn exists(&self, id: &str) -> bool {
689 self.exists_with_filter(id, ChangeLifecycleFilter::Active)
690 }
691
692 fn exists_with_filter(&self, id: &str, filter: ChangeLifecycleFilter) -> bool {
693 let resolution =
694 self.resolve_target_with_options(id, ResolveTargetOptions { lifecycle: filter });
695 match resolution {
696 ChangeTargetResolution::Unique(_) => true,
697 ChangeTargetResolution::Ambiguous(_) => false,
698 ChangeTargetResolution::NotFound => false,
699 }
700 }
701
702 fn get_with_filter(&self, id: &str, filter: ChangeLifecycleFilter) -> DomainResult<Change> {
703 let location = self.resolve_unique_change_location(id, filter)?;
704 let actual_id = location.id.clone();
705
706 let proposal = self.read_optional_file(&location.path.join("proposal.md"))?;
707 let design = self.read_optional_file(&location.path.join("design.md"))?;
708
709 if let Some(content) = &proposal {
712 self.validate_artifact_front_matter(content, &actual_id)?;
713 }
714 if let Some(content) = &design {
715 self.validate_artifact_front_matter(content, &actual_id)?;
716 }
717
718 let specs = self.load_specs(&location.path)?;
719 let tasks = self.load_tasks_for_location(&location)?;
720 let last_modified = self.get_last_modified(&location.path)?;
721 let path = location.path;
722 let meta = crate::change_meta::read_change_meta_from_dir(&self.fs, &path);
723
724 let sub_module_id = extract_sub_module_id(&actual_id);
725
726 Ok(Change {
727 id: actual_id.clone(),
728 module_id: extract_module_id(&actual_id),
729 sub_module_id,
730 path,
731 proposal,
732 design,
733 specs,
734 tasks,
735 orchestrate: meta.orchestrate,
736 last_modified,
737 })
738 }
739
740 fn list_with_filter(&self, filter: ChangeLifecycleFilter) -> DomainResult<Vec<ChangeSummary>> {
741 let mut summaries = Vec::new();
742 for location in self.list_change_locations(filter) {
743 summaries.push(self.build_summary_for_location(&location)?);
744 }
745
746 summaries.sort_by(|a, b| a.id.cmp(&b.id));
747 Ok(summaries)
748 }
749
750 fn list_by_module_with_filter(
751 &self,
752 module_id: &str,
753 filter: ChangeLifecycleFilter,
754 ) -> DomainResult<Vec<ChangeSummary>> {
755 let normalized_id = parse_module_id(module_id);
756 let all = self.list_with_filter(filter)?;
757 Ok(all
758 .into_iter()
759 .filter(|c| c.module_id.as_deref() == Some(&normalized_id))
760 .collect())
761 }
762
763 fn list_incomplete_with_filter(
764 &self,
765 filter: ChangeLifecycleFilter,
766 ) -> DomainResult<Vec<ChangeSummary>> {
767 let all = self.list_with_filter(filter)?;
768 Ok(all
769 .into_iter()
770 .filter(|c| c.status() == ChangeStatus::InProgress)
771 .collect())
772 }
773
774 fn list_complete_with_filter(
775 &self,
776 filter: ChangeLifecycleFilter,
777 ) -> DomainResult<Vec<ChangeSummary>> {
778 let all = self.list_with_filter(filter)?;
779 Ok(all
780 .into_iter()
781 .filter(|c| c.status() == ChangeStatus::Complete)
782 .collect())
783 }
784
785 fn get_summary_with_filter(
786 &self,
787 id: &str,
788 filter: ChangeLifecycleFilter,
789 ) -> DomainResult<ChangeSummary> {
790 let location = self.resolve_unique_change_location(id, filter)?;
791 self.build_summary_for_location(&location)
792 }
793}
794
795pub type ChangeRepository<'a> = FsChangeRepository<'a, StdFs>;
797
798#[cfg(test)]
799#[path = "change_repository_tests.rs"]
800mod change_repository_tests;