pub fn check(
repository: &Repository,
index: &Index,
kinds: &KindSchema,
) -> LayoutReportExpand description
Check both halves of repository against their declared layouts.
Reads git at the repository’s root — the tracked half’s index entries and the ones its
ignore rules match — and the local half’s Markdown and YAML files. A root git cannot
read is answered unmeasured rather than passing; a local half the manifest does not
declare excludes: [canonical] for is counted but not judged.
use majordomus_cli::layout;
use majordomus_cli::metadata::KindSchema;
use majordomus_cli::repository::Repository;
use majordomus_cli::share::Share;
use majordomus_cli::synthetic::{crate_share, SyntheticRepository};
let repo = SyntheticRepository::small().unwrap();
let root = repo.root();
// the local half declares that authored knowledge never lives there
let manifest = root.join(".ai/manifest.yaml");
let text = std::fs::read_to_string(&manifest).unwrap().replace(
" implicit_context: false\n",
" implicit_context: false\n lifecycle: runtime\n excludes: [canonical]\n",
);
std::fs::write(&manifest, text).unwrap();
let git = |args: &[&str]| {
let mut git = std::process::Command::new("git");
assert!(git.arg("-C").arg(root).args(args).status().unwrap().success());
};
git(&["init", "-q"]);
git(&["add", ".ai"]);
// a byte copy of a tracked rule, left in the local half
let rule = std::fs::read(root.join(".ai/repo/rules/project/rule-0.v1.md")).unwrap();
std::fs::create_dir_all(root.join(".ai/local/notes")).unwrap();
std::fs::write(root.join(".ai/local/notes/rule-0.md"), rule).unwrap();
let repository = Repository::discover(root).unwrap();
let share = Share::locate(Some(&crate_share()), root).unwrap();
let kinds = KindSchema::load(&share, &repository).unwrap();
let report = layout::check(&repository, &repo.index().unwrap(), &kinds);
assert!(report.measured && !report.passes);
assert_eq!(report.findings.len(), 1);
assert_eq!(report.findings[0].path, ".ai/local/notes/rule-0.md");
assert!(report.findings[0].reason.contains(".ai/repo/rules/project/rule-0.v1.md"));