Skip to main content

claim_unit

Function claim_unit 

Source
pub fn claim_unit(
    mana_dir: &Path,
    id: &str,
    params: ClaimParams,
) -> Result<ClaimResult, Error>
Expand description

Claim a unit for work.

Sets status to InProgress, records who claimed it and when, and starts a new attempt in the attempt log.

If params.force is false and the unit has a verify command with fail_first: true, the verify command is run first. If it already passes, the claim is rejected (nothing to do). This enforces fail-first/TDD semantics.

§Errors

  • anyhow::Error — unit not found, not open, or verify pre-check failed

§Example

use mana_core::api::claim_unit;
use mana_core::ops::claim::ClaimParams;
use std::path::Path;

let r = claim_unit(Path::new("/project/.mana"), "1", ClaimParams {
    by: Some("agent-42".to_string()),
    force: true,
}).unwrap();
println!("Claimed by: {}", r.claimer);