Skip to main content

buildfix_core_runtime/
ports.rs

1//! Port traits that isolate buildfix core from host I/O.
2
3use buildfix_receipts::LoadedReceipt;
4use camino::Utf8Path;
5
6/// Source of sensor receipts.
7pub trait ReceiptSource {
8    fn load_receipts(&self) -> anyhow::Result<Vec<LoadedReceipt>>;
9}
10
11/// Git queries (HEAD SHA, dirty status).
12pub trait GitPort {
13    fn head_sha(&self, repo_root: &Utf8Path) -> anyhow::Result<Option<String>>;
14    fn is_dirty(&self, repo_root: &Utf8Path) -> anyhow::Result<Option<bool>>;
15    fn commit_all(&self, _repo_root: &Utf8Path, _message: &str) -> anyhow::Result<Option<String>> {
16        Ok(None)
17    }
18}
19
20/// File-system write operations.
21pub trait WritePort {
22    fn write_file(&self, path: &Utf8Path, contents: &[u8]) -> anyhow::Result<()>;
23    fn create_dir_all(&self, path: &Utf8Path) -> anyhow::Result<()>;
24}