yog 0.0.31

yog: the standalone server for litany loops — the world, the balls and the conversations, behind one wire
Documentation
//! The receipts (§8.5): what one act earned. Small values, but each one is a
//! variant, and a variant with no fixture leaves its encode arm unexecuted.

use std::path::PathBuf;

use super::super::super::super::{ConfigView, Reply};

use crate::actions::verbs::Outcome;
use crate::opslog::Origin;
use crate::start::Prepared;

/// A role bound to a provider row brazen's table does not carry — the one
/// §9.5 judgement that is not a fact of the text, so the corpus spells a
/// faulted setting beside the clean ones.
const DEAD_ROLE: &str =
    "roles:\n  worker:\n    provider: gone\n    model: m-1\n    tools: [bash]\n";

/// The §9 config read's fixtures (bl-dc3f) — its own function so [`receipts`]
/// stays inside the per-function line bound, and because these three are one
/// subject: a file with no grammar, and two with one.
fn config_views() -> Vec<Reply> {
    vec![
        // A file yog has no grammar for: the raw text alone, `settings` an
        // EMPTY array rather than an absent key — §9.5's raw-text fallback is
        // the general path with empty input, not a branch (bl-dc3f).
        Reply::Config(ConfigView {
            text: "roles: []".into(),
            settings: Vec::new(),
        }),
        // And the typed answer, generated by the schema fold itself so the
        // fixture cannot state a shape the engine does not produce. Two files,
        // because one cannot carry four controls: `providers.yaml` spells
        // provider (faulted — brazen's table has no `gone` row), text and list,
        // `cadence.yaml` spells the bounded number, whose min/max ride the
        // control because a seat judging at input needs the range.
        Reply::Config(ConfigView {
            text: DEAD_ROLE.into(),
            settings: crate::config_edit::form::read(
                &crate::config_edit::form::ROLES_SCHEMA,
                DEAD_ROLE,
                &["codex".to_owned()],
            ),
        }),
        Reply::Config(ConfigView {
            text: crate::app::cadence::TEMPLATE.into(),
            settings: crate::config_edit::form::read(
                &crate::config_edit::form::CADENCE_SCHEMA,
                crate::app::cadence::TEMPLATE,
                &[],
            ),
        }),
    ]
}

pub(super) fn receipts() -> Vec<Reply> {
    vec![
        // A non-zero exit on purpose: `ok: false` on an answer is the one
        // envelope the refusal shape could be confused with.
        Reply::Outcome(Outcome {
            exit: 3,
            stdout: "out".into(),
            stderr: "err".into(),
        }),
        Reply::Prepared(Prepared {
            workspace: crate::naming::leaf(&(PathBuf::from("/ws"))),
            binding: Some(PathBuf::from("/target")),
            goal: "g".into(),
            origin: Origin::Balls,
            lineage: None,
        }),
        // The fan family's three receipts (§3.8; V3's delivery). The fanned
        // rows are `prepared` bodies; the delivery is taken at both of its
        // shapes — the landed squash, and upstream's "the target already
        // contained everything the source had", whose two fields are absent.
        Reply::Fanned(vec![Prepared {
            workspace: crate::naming::leaf(&(PathBuf::from("/ws"))),
            binding: Some(PathBuf::from("/candidate")),
            goal: "g".into(),
            origin: Origin::Balls,
            lineage: None,
        }]),
        Reply::Retired { discarded: true },
        Reply::Delivered(crate::fan::Delivery {
            target: "work/bl-1f2a".into(),
            base: "aaa1".into(),
            source: Some("bbb2".into()),
            commit: Some("ccc3".into()),
        }),
        Reply::Delivered(crate::fan::Delivery {
            target: "main".into(),
            base: "aaa1".into(),
            source: None,
            commit: None,
        }),
        Reply::Started {
            conversation: "brave-fox".into(),
        },
        Reply::Deleted,
        Reply::Armed { armed: true },
        Reply::Flagged,
        Reply::Answered {
            tool_use: "toolu_1".into(),
            tool: "Bash".into(),
            ruling: crate::control::judge::Ruling::Hold,
            advanced: false,
        },
        // `seen`'s receipt (bl-5cfe), at both of its shapes: the ordinary one,
        // whose remainder still holds rows, and the last acknowledgement in a
        // world — an EMPTY remainder, which is the answer a reader must not be
        // able to confuse with a refusal or with an absent key.
        Reply::Acknowledged(crate::boundary::answer::queue::Acknowledged {
            workspace: "ws".into(),
            agent: "c-9".into(),
            remaining: super::listings::queue(),
        }),
        Reply::Acknowledged(crate::boundary::answer::queue::Acknowledged {
            workspace: "ws".into(),
            agent: "c-9".into(),
            remaining: vec![],
        }),
        Reply::Floored { standing: true },
        Reply::Nudged,
        Reply::Acked,
        Reply::TrailCleared,
        Reply::Applied,
        Reply::Marks {
            branch: "marks/alba".into(),
        },
        // Both readings of bl-66d4's receipt, because the false one is the
        // ordinary reconnect and the true one is the whole point: a client
        // that decoded only the shape it usually sees would miss the event.
        Reply::Advertised { wrote: false },
        Reply::Advertised { wrote: true },
        // REMOTE §1.4's enrollment (bl-f4e3), at both grades. **The material is
        // fabricated and says so**: a real minted key must never enter this
        // corpus, and what a client needs from the fixture is the shape — three
        // opaque strings carrying newlines — never a certificate. The key's
        // banner is deliberately not a private key's, because `make leak-scan`
        // reads every committed byte in this tree and must never find one.
        Reply::Enrolled(crate::registry::enroll::Enrolled {
            grade: crate::registry::Grade::Operator,
            name: "phone-1".into(),
            address: "engine.invalid:7737".into(),
            ca: "-----BEGIN CERTIFICATE-----\nnotreal\n-----END CERTIFICATE-----\n".into(),
            cert: "-----BEGIN CERTIFICATE-----\nnotreal\n-----END CERTIFICATE-----\n".into(),
            key: "-----BEGIN notreal KEY-----\nnotreal\n-----END notreal KEY-----\n".into(),
        }),
        Reply::Enrolled(crate::registry::enroll::Enrolled {
            grade: crate::registry::Grade::Foot,
            name: "builder".into(),
            address: "engine.invalid:7737".into(),
            ca: "-----BEGIN CERTIFICATE-----\nnotreal\n-----END CERTIFICATE-----\n".into(),
            cert: "-----BEGIN CERTIFICATE-----\nnotreal\n-----END CERTIFICATE-----\n".into(),
            key: "-----BEGIN notreal KEY-----\nnotreal\n-----END notreal KEY-----\n".into(),
        }),
        // The routing leg's one answer at both of its moments (bl-024b): the
        // handle alone while the far machine runs it, and the capture once it
        // has answered — including a non-zero verdict and text on stderr, which
        // is the arm a tool that failed takes.
        Reply::Routed {
            invocation: "inv-1".into(),
            capture: None,
        },
        Reply::Routed {
            invocation: "inv-2".into(),
            capture: Some(crate::registry::mailbox::Capture {
                stdout: "hello\n".into(),
                stderr: "warned\n".into(),
                exit_code: 3,
            }),
        },
    ]
    .into_iter()
    .chain(config_views())
    .chain(logins())
    .collect()
}

/// The sign-in's standing (REMOTE §8.3, bl-c285) at each of its three moments,
/// because a fixture that only ever spelled the live one would prove only that
/// the live one crosses: a run that has said nothing, a run mid-flow — both
/// stream tags, since bz writes its human-facing flow to stderr and its
/// machine-readable output to stdout — and a settled non-zero exit carrying the
/// §8.3 run-by-hand fallback.
fn logins() -> Vec<Reply> {
    let line = |text: &str, err: bool| crate::cli_outbound::StreamedLine {
        text: text.to_owned(),
        err,
    };
    vec![
        Reply::Login(crate::login::LoginView::default()),
        Reply::Login(crate::login::LoginView {
            lines: vec![
                line("open https://provider.invalid/auth", true),
                line("{\"ready\":true}", false),
            ],
            outcome: None,
            fallback: None,
        }),
        Reply::Login(crate::login::LoginView {
            lines: vec![line(
                "this provider has no device endpoint; use `--browser`",
                true,
            )],
            outcome: Some(78),
            fallback: Some("yog exec --ws /ws bz --login --provider acme --browser".into()),
        }),
    ]
}