Skip to main content

wire/answer/
evidence.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4// Copyright (c) 2026 2youg1 and the sprawling contributors
5
6//! What a run left behind that somebody can check it by.
7//!
8//! **No bytes travel here.** A screenshot is a `cas:` locator and two
9//! integer sides; fetching the picture is the asset endpoint's, for the
10//! reason a whole batch of patch text is refused on a change list -
11//! "show me what this run did" must not cost what every pixel it took
12//! costs.
13
14use kernel::{Locator, RunId, Seq};
15use serde::{Deserialize, Serialize};
16
17/// Which kind of evidence one row is.
18///
19/// Exhaustive and small: a row exists because the Ledger holds a
20/// locator, and there are two records that write one.
21#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
22#[serde(rename_all = "snake_case")]
23#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
24pub enum EvidenceKind {
25    /// A picture the browser tool put in the content store.
26    Screenshot,
27    /// The completion a plan node was closed with.
28    Finished,
29}
30
31/// The two sides and the media type of a picture, as the record wrote
32/// them. Absent on a row whose record named a locator and no size,
33/// which is a row worth showing and not a size worth inventing.
34#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
35#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
36pub struct Picture {
37    pub media_type: String,
38    pub width: u32,
39    pub height: u32,
40}
41
42/// One thing a run wrote down that can be looked at again.
43#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
44#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
45pub struct EvidenceItem {
46    /// Where in the Ledger the record sits, so a reader can go on from
47    /// there.
48    pub at: Seq,
49    pub kind: EvidenceKind,
50    pub locator: Locator,
51    pub picture: Option<Picture>,
52}
53
54/// Everything one run left as evidence, oldest first.
55#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
56#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
57pub struct EvidenceAnswer {
58    pub run: RunId,
59    pub items: Vec<EvidenceItem>,
60}