yog 0.0.93

yog: the standalone server for litany loops — the world, the balls and the conversations, behind one wire
//! **The gesture surface** (bl-32cb): one populated value per boundary
//! spelling, assembled from the family lists the round trips are already cut
//! along.
//!
//! It has two readers and that is the point. The codec's own round trip walks
//! it — encode → decode is the identity over every entry — and
//! [`crate::boundary::corpus`] renders it into the conformance corpus every
//! wire client replays. One list, so a fixture a client is judged against and a
//! fixture yog proves itself against can never be two different things.
//!
//! Where a variant carries an enum, a bounded option or a collection, the list
//! holds **one entry per arm** and the empty case beside the populated one: a
//! table that only ever spells the easy case proves only that the easy case
//! crosses.

mod ball;
mod conversation;

use crate::boundary::Gesture;

/// Every gesture, in family order. Deterministic — the corpus is a committed
/// artifact, so the order this returns is part of what is committed.
pub(crate) fn gestures() -> Vec<Gesture> {
    [
        conversation::surface(),
        ball::surface(),
        super::start::surface(),
        super::fan::surface(),
        super::fork::surface(),
        super::control::surface(),
        super::fleet::surface(),
        super::retarget::surface(),
        super::workflow::surface(),
        super::query::surface(),
        login(),
        pins(),
        offer(),
        spend(),
        crate::boundary::codec::config::tests::surface(),
    ]
    .concat()
}

/// The §4.1 pin (bl-b986) — **one entry per direction**, because the direction
/// is the op token and a fixture that only ever spelled `pin` would leave the
/// instruction that is not the default unproven on the wire.
fn pins() -> Vec<Gesture> {
    [true, false]
        .into_iter()
        .map(|pinned| {
            Gesture::Act(crate::boundary::Action::Pin {
                workspace: "ws".to_owned(),
                pinned,
            })
        })
        .collect()
}

/// The §3.5 spend family (bl-53d1) — **one entry per arm of each act**: a row
/// priced on all four rates, one priced on two (the absent rates are the
/// table's own zeros), the delete, a ceiling set and a ceiling deleted, and
/// the table read beside them. The absences are the second instruction of
/// each act, so a fixture that only ever spelled a write would leave the
/// delete unproven on the wire.
fn spend() -> Vec<Gesture> {
    use crate::boundary::Action;
    let price = |model: &str, rates| {
        Gesture::Act(Action::Price {
            provider: "anthropic".to_owned(),
            model: model.to_owned(),
            rates,
        })
    };
    vec![
        price(
            "claude-opus-4-1",
            Some(crate::spend::Price {
                input: 15_000_000,
                output: 75_000_000,
                cache_read: 1_500_000,
                cache_write: 18_750_000,
            }),
        ),
        price(
            crate::spend::ANY,
            Some(crate::spend::Price {
                input: 3_000_000,
                output: 15_000_000,
                cache_read: 0,
                cache_write: 0,
            }),
        ),
        price("claude-opus-4-1", None),
        Gesture::Act(Action::Ceiling {
            micro_usd: Some(25_000_000),
        }),
        Gesture::Act(Action::Ceiling { micro_usd: None }),
        Gesture::Ask(crate::boundary::Query::Prices),
    ]
}

/// The §8.3 sign-in (REMOTE §8.3, bl-c285) — one entry, because the act's
/// whole envelope is the pair it names: the flow is the row's own capability
/// and never a field a seat spells (DESIGN §8.3 rule 1), so there is no arm
/// here for a fixture to walk.
fn login() -> Vec<Gesture> {
    vec![Gesture::Act(crate::boundary::Action::Login {
        workspace: "ws".to_owned(),
        provider: "acme".to_owned(),
    })]
}

/// REMOTE §15.1's offer family (bl-9ea6) — the mint at both grades, because
/// the grade is a two-armed vocabulary, and the three that name an offer.
fn offer() -> Vec<Gesture> {
    use crate::registry::offer::Verb;
    let (workspace, name) = ("ws".to_owned(), "phone-1".to_owned());
    [
        Verb::Mint {
            workspace: workspace.clone(),
            name: name.clone(),
            grade: crate::registry::Grade::Operator,
        },
        Verb::Mint {
            workspace: workspace.clone(),
            name: name.clone(),
            grade: crate::registry::Grade::Foot,
        },
        Verb::List {
            workspace: workspace.clone(),
        },
        Verb::Approve {
            workspace: workspace.clone(),
            name: name.clone(),
        },
        Verb::Decline { workspace, name },
    ]
    .map(|verb| Gesture::Act(crate::boundary::Action::Offer(verb)))
    .to_vec()
}