openquiver-graph 0.1.0

OpenQuiver graph IR: nodes, pins, types. Bottom layer, no internal dependencies.
Documentation
//! What a data pin carries, and the literals that can be given to one.

use serde::{Deserialize, Serialize};
use ts_rs::TS;

/// What a data pin carries.
///
/// The vocabulary lives beside [`Value`] because the two answer to each other:
/// a literal in a configuration block has to be checkable against the pin it is
/// given to. Resolved types are never stored on wires — the compiler derives
/// them, and a second copy would go stale.
///
/// `TS` is derived here rather than on a duplicate enum in the editor: the
/// editor's view embeds this type directly, and a second enum mirroring its
/// variants would be the same fact told twice, free to drift the moment one
/// side gains a variant.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, TS)]
#[ts(export, export_to = "../../../clients/web/src/lib/api/")]
pub enum DataType {
    Text,
    Number,
    Bool,
    /// Arbitrary structured data. The escape hatch for anything not worth
    /// naming yet.
    Json,
    Array(Box<DataType>),
    /// A handle to a connected agent process.
    AgentRef,
    /// A handle to an ACP session. The value is the handle's id, not the object:
    /// a session has to survive being written to the journal and read back
    /// after the process that owned it is gone.
    SessionRef,
    FileRef,
    /// The name of a secret, never its value.
    SecretRef,
    /// Adopts the type of whatever it is first connected to, then propagates.
    Wildcard,
}

/// A literal in a node's configuration block.
///
/// Configuration entries *are* the node's data inputs: a pin either takes a
/// literal here or receives a wire, never both. Modelling them as one thing
/// removes the separate notion of a "default value on an unconnected pin" that
/// would otherwise have to exist and be kept in step.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
#[ts(export, export_to = "../../../clients/web/src/lib/api/")]
pub enum Value {
    Text(String),
    Number(f64),
    Bool(bool),
    Array(Vec<Value>),
    /// The *name* of a secret, resolved from the environment or a keychain when
    /// the workflow runs.
    ///
    /// Never the secret itself. A graph carrying a key would leak it the moment
    /// the repository is shared — and sharing the repository is the entire
    /// collaboration story.
    Secret(String),
}