artifactize-core 0.27.0

The library behind artifactize: Artifacts, evals, reviews, the monitor and review models, and the shared operations every interface calls.
Documentation
//! Resolve the exact review and the owner that receives Human actions.
use std::path::Path;

use crate::{
    inspect::RequestView,
    store::{self, Shown},
    types::RequestId,
};

use super::HumanClaim;

/// The exact request the person opened and the request that owns its live review.
pub struct Review {
    pub exact: RequestView,
    pub owner: RequestView,
}

/// Read an exact review receipt without loading the Run's definitions.
pub async fn request(state: &Path, id: &RequestId) -> Result<RequestView, String> {
    request_with(state, id, Shown::Requests).await
}

pub(super) async fn request_with(
    state: &Path,
    id: &RequestId,
    shown: Shown,
) -> Result<RequestView, String> {
    store::read_request_by_id(state, id, shown).await
}

pub async fn read(state: &Path, id: &RequestId) -> Result<Review, String> {
    resolve(state, request(state, id).await?).await
}

/// Resolve the owner of an exact receipt already returned by a review search.
pub async fn resolve(state: &Path, exact: RequestView) -> Result<Review, String> {
    let owner = store::read_review_owner(state, &exact).await?;
    Ok(Review { exact, owner })
}

/// Test the exact acquisition, not just the reviewer name: a later claim by the same
/// person is not the claim this surface remembers taking.
pub async fn claim_is_current(state: &Path, claim: &HumanClaim) -> Result<bool, String> {
    Ok(
        store::read_optional_request(state, &claim.request_id, Shown::Requests)
            .await?
            .is_some_and(|view| view.claim.as_ref() == Some(claim)),
    )
}