artifactize-harness 0.27.0

The Agent evaluation harness for Artifactize.
Documentation
use artifactize_provider::llm::delivery::CADENCE;
use tokio::io::{self, AsyncWriteExt};

use super::{Channel, Line};
use crate::claude::wire::Finished;

#[tokio::test(start_paused = true)]
async fn a_line_split_across_delivery_ticks_is_read_in_full() {
    let (reader, mut peer) = io::duplex(128);
    let mut channel = Channel::new(reader, io::sink());
    // Split the JSON and the UTF-8 for 'é'. Each read is polled before its tick and
    // must wait for the peer to send more bytes rather than returning a partial line.
    for fragment in [
        &b"{\"type\":\"result\",\"subtype\":"[..],
        &b"\"success\",\"result\":\"caf\xc3"[..],
    ] {
        peer.write_all(fragment).await.unwrap();
        tokio::select! {
            biased;
            line = channel.next() => panic!("incomplete line returned before a tick: {line:?}"),
            () = tokio::time::sleep(CADENCE) => {}
        }
    }
    peer.write_all(b"\xa9\"}\r\n\n").await.unwrap();
    drop(peer);

    let Some(Line::Result(Finished::Text(answer))) = channel.next().await.unwrap() else {
        panic!("the complete line must be the turn's answer");
    };
    assert_eq!(answer, "café");
    assert!(channel.next().await.unwrap().is_none());
}