artifactize 0.27.1

The AI-native collaboration layer for one-of-a-kind teammates and their agents: split a project into Artifacts with their own evals, and reuse every review while it still holds.
use super::*;
use artifactize_core::{platform::path_text, store};
use serde_json::json;

#[tokio::test]
async fn refused_human_actions_release_the_database_before_returning_the_error() {
    let root = crate::test_os::tempdir();
    let repo = root.path().join("repo");
    let state = root.path().join("state");
    std::fs::create_dir(&repo).unwrap();
    let receipts = store::OwnedReceipts::open(&state, &repo).await.unwrap();
    let run: store::Run = serde_json::from_value(json!({
        "id":"run-1", "repoPath":path_text(&repo), "stateDir":path_text(&state), "status":"GREEN",
        "createdAt":"2026-01-01T00:00:00Z", "completedAt":"2026-01-01T00:00:01Z",
        "selection":{"kind":"all"}, "validation":null, "definitions":null
    }))
    .unwrap();
    let request =
        crate::test_request::request("app/check", "GREEN", json!({"cwd":path_text(&repo)}))
            .request
            .as_ref()
            .clone();
    let id = request.id.clone();
    receipts.create_run(&run, &[request]).await.unwrap();
    store::Receipts::clone(&receipts).close().await.unwrap();
    let reviewer = Some("alice".parse().unwrap());
    for command in [
        RequestCommand::Claim {
            id: id.clone(),
            reviewer: reviewer.clone(),
        },
        RequestCommand::Unclaim {
            id: id.clone(),
            reviewer: reviewer.clone(),
        },
        RequestCommand::Tool {
            id,
            reviewer,
            tool: "inspect".parse().unwrap(),
        },
    ] {
        let error = execute(&state, command, true).await.unwrap_err();
        assert!(error.contains("not waiting for a Human review"), "{error}");
        assert!(crate::test_os::database_released(&state.join(store::DATABASE)).unwrap());
    }
    root.close().unwrap();
}