pub fn close_unit(
mana_dir: &Path,
id: &str,
opts: CloseOpts,
) -> Result<CloseOutcome, Error>Expand description
Close a unit — run verify, archive, and cascade to parents.
The full close lifecycle:
- Pre-close hook (if configured)
- Run verify command (unless
opts.forceis true) - Worktree merge (if in worktree mode)
- Feature gate (feature units require manual confirmation)
- Mark closed and archive
- Post-close hook and on_close actions
- Auto-close parents whose children are all done
Returns a close::CloseOutcome that describes what happened — the unit
may have been closed, verify may have failed, or the close may have been
blocked by a hook or feature gate.
§Errors
anyhow::Error— unit not found or unexpected I/O failure
§Example
use mana_core::api::close_unit;
use mana_core::ops::close::{CloseOpts, CloseOutcome};
use std::path::Path;
let outcome = close_unit(Path::new("/project/.mana"), "1", CloseOpts {
reason: Some("Implemented and tested".to_string()),
force: false,
defer_verify: false,
}).unwrap();
match outcome {
CloseOutcome::Closed(r) => println!("Closed! Auto-closed parents: {:?}", r.auto_closed_parents),
CloseOutcome::VerifyFailed(r) => eprintln!("Verify failed: {}", r.output),
_ => {}
}