diff --git a/pkgs/id/src/boards.rs b/pkgs/id/src/boards.rs index a5e8932ec9..574310a470 100644 --- a/pkgs/id/src/boards.rs +++ b/pkgs/id/src/boards.rs @@ -88,6 +88,13 @@ use sha2::{Digest, Sha256}; use crate::artifact::SignedArtifact; +mod game; +pub use game::*; +mod records; +pub use records::*; +mod projection; +pub use projection::*; + /// Signed-artifact kind used for all typed board objects in v1. pub const BOARD_OBJECT_KIND: &str = "board_object.v1"; /// Largest text field accepted by a board object. @@ -138,483 +145,6 @@ impl<'de> Deserialize<'de> for ArtifactHash { } } -/// Typed reference to a signed game-post object; game execution is out of scope. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct GamePostRef { - /// Hash of the immutable `BoardObject::GamePost` in the board graph. - pub object: ArtifactHash, -} - -/// Immutable package identity pinned by a game post. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct GamePackageRef { - /// SHA-256 hash of the package bytes. A new package build has a new hash. - pub hash: ArtifactHash, - /// Human-facing package version associated with the pinned bytes. - pub version: String, -} - -/// Play mode supported by playable posts in v1. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(rename_all = "kebab-case")] -pub enum GameMode { - /// Players submit signed turns asynchronously against a pinned frontier. - AsyncTurns, -} - -/// One author assigned to a package-defined game role. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct GameParticipant { - /// Canonical Ed25519 public key of the assigned author. - pub author: String, - /// Canonical role identifier understood by the pinned game package. - pub role: String, -} - -/// Signed metadata for a package-pinned playable post. -/// -/// This object records the immutable package reference, package-specific -/// configuration and initial state, and the authors assigned to package-defined -/// roles. It is data, not executable code; accepting it does not run the package. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct GamePost { - /// Board root hash. - pub board: ArtifactHash, - /// Immutable package bytes and their human-facing version. - pub package: GamePackageRef, - /// The v1 play mode. - pub mode: GameMode, - /// Package-defined configuration, carried as data. - pub configuration: serde_json::Value, - /// Authors assigned to package-defined roles. - pub participants: Vec, - /// Package-specific initial state, carried as data. - pub genesis: serde_json::Value, -} - -/// Signed acceptance of a game post's challenge by one assigned participant. -/// -/// The game post's own author cannot accept their own challenge; an -/// acceptance is the record that opens the game for [`GameTurn`] objects. -/// Competing acceptance records from one participant (re-signed envelopes, -/// divergent arrivals) are all kept as signed history: acceptance is -/// effective by existence, never by a first-arrival-wins check, so peers -/// holding the same signed set converge in any arrival order — the same -/// rule [`BoardGraph::has_role`] documents for role grants. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct GameChallengeAcceptance { - /// Board root hash. - pub board: ArtifactHash, - /// Hash of the immutable `BoardObject::GamePost` being accepted. - pub game_post: ArtifactHash, -} - -/// One signed asynchronous turn in a package-pinned game. -/// -/// A turn is bound to its game post (and through it to the pinned package -/// hash and version), to the role its signer is assigned in that post, to -/// its index in a lineage, and to the prior turn it builds on (`prev_turn`, -/// `None` only for the opening turn). The acting participant rotates -/// through the game post's participant list by turn index — turn `i` must -/// be signed by `participants[i % participants.len()]` under that -/// participant's role — so a lineage cannot advance on one player's -/// signatures alone. Two valid turns may name the same `prev_turn`: they -/// are competing branches of the game, kept as forks in the graph, never -/// erased or overwritten by acceptance. Two authorization extensions -/// sit on top of rotation, both recorded as signed objects in the -/// graph: a turn in a [`GameFork`] instance names the fork in -/// `fork_ref` and resolves against the fork's own participants, and -/// on a line an accepted [`GameHandoff`] governs, the recipient may -/// sign a base-line turn under the seat role rotation assigns (the -/// recipient's leg — design #2054 section 4). -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct GameTurn { - /// Board root hash. - pub board: ArtifactHash, - /// Hash of the immutable `BoardObject::GamePost` this turn belongs to. - pub game_post: ArtifactHash, - /// Package-defined role the signer is assigned in the game post. - pub role: String, - /// Zero-based position of this turn in its lineage. - pub turn_index: u64, - /// The prior turn in this lineage; `None` for the opening turn. - pub prev_turn: Option, - /// The [`GameFork`] instance this turn belongs to, when it - /// continues a fork rather than the game post's base line. A - /// fork turn builds on the fork's cited save-point frontier or - /// on another turn of the same fork, and its signer resolves - /// against the fork's own participant list. Absent (the base - /// line) in objects written before this field existed. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub fork_ref: Option, - /// Package-defined action data, carried as data; replay interprets it. - pub action: serde_json::Value, -} - -/// A signed save point in one game line: the pinned package, the -/// frontier turn it saves, and the hash of the replayed state at -/// that frontier. -/// -/// A save point is signed by an assigned participant of the line -/// it saves: the post's participants for a base-line frontier, or -/// the fork's own participants when the frontier is a fork turn. -/// post and must name that post's exact pinned package (hash and -/// version) — a save recorded against different package bytes is a -/// save of a different game. The state hash is the saver's signed -/// claim about [`BoardGraph::replay_game_lineage`]'s snapshot at -/// the frontier; peers can recompute it from the same lineage and -/// the same bytes. Save blobs themselves stay content-addressed -/// references: this record carries hashes, never state bytes. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct GameSavePoint { - /// Board root hash. - pub board: ArtifactHash, - /// Hash of the immutable `BoardObject::GamePost` this save belongs to. - pub game_post: ArtifactHash, - /// The pinned package the saved line replays through; must equal - /// the game post's package reference exactly. - pub package: GamePackageRef, - /// Hash of the [`GameTurn`] at the saved frontier. - pub frontier: ArtifactHash, - /// SHA-256 hash of the replayed package state at the frontier. - pub state_hash: ArtifactHash, -} - -/// Signed handoff of a saved game line to a named recipient. -/// -/// Only the save point's own author may hand it off, and the -/// recipient must be an assigned participant of the game post — -/// turn validation binds continuation turns to the participant -/// list, so a handoff to anyone else could never be continued. -/// Competing handoffs of one save point are all kept as signed -/// history; an accepted handoff selects the social main line (see -/// [`BoardGraph::game_main_line_head`]) and the alternatives are -/// never deleted. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct GameHandoff { - /// Board root hash. - pub board: ArtifactHash, - /// Hash of the immutable `BoardObject::GamePost` this handoff belongs to. - pub game_post: ArtifactHash, - /// Hash of the `BoardObject::GameSavePoint` being handed off. - pub save_point: ArtifactHash, - /// Canonical Ed25519 public key of the named recipient. - pub recipient: String, - /// Handoff terms, carried as data. - pub terms: serde_json::Value, -} - -/// Signed acceptance of a [`GameHandoff`] by its named recipient. -/// -/// Only the recipient the handoff names may accept it. Acceptance -/// is effective by existence, never by a first-arrival-wins check — -/// the same rule [`GameChallengeAcceptance`] documents — so peers -/// holding the same signed set converge in any arrival order. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct GameHandoffAcceptance { - /// Board root hash. - pub board: ArtifactHash, - /// Hash of the immutable `BoardObject::GamePost` this acceptance belongs to. - pub game_post: ArtifactHash, - /// Hash of the `BoardObject::GameHandoff` being accepted. - pub handoff: ArtifactHash, -} - -/// A signed fork of a game from a cited save point, by any author. -/// -/// The fork record starts an independent continuation: turns that -/// build on the save point's frontier are a branch of the game -/// (see [`GameTurn`]), replayed independently of the source line -/// through [`BoardGraph::replay_game_lineage`]. The citation -/// preserves source-line attribution — the save point, its author, -/// and the lineage behind its frontier stay named in the graph. -/// Board-level [`BoardFork`] is a different feature (whole-board -/// provenance); this is a game-level fork inside one board. The -/// fork carries its own participant list: fork turns resolve their -/// signers against it, not the game post's, so a third-party fork -/// actually proceeds as an alternate instance (design #2054 -/// section 4). Seating is phase-aligned to the absolute turn -/// index — a fork turn's seat is `participants[turn_index % len]`, -/// matching the move count already inside the saved state — so a -/// fork opened mid-rotation continues the saved state's rotation -/// instead of restarting it. For the same reason the participant -/// list must preserve the saved instance's seat layout: the same -/// number of seats with the same role at each seat; only the -/// assigned authors may change. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct GameFork { - /// Board root hash. - pub board: ArtifactHash, - /// Hash of the immutable `BoardObject::GamePost` this fork belongs to. - pub game_post: ArtifactHash, - /// Hash of the `BoardObject::GameSavePoint` the fork cites. - pub save_point: ArtifactHash, - /// Authors assigned to package-defined roles in the fork - /// instance, in fork-turn rotation order. The fork's own - /// author must hold one of the assignments: a fork its author - /// cannot play in does not proceed. - pub participants: Vec, -} - -/// Stable identity root for one public board. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct Board { - /// Stable ID chosen by the creator; the signed author's key scopes it. - pub board_id: String, - /// Optional source root when this board is a successor fork. - pub forked_from: Option, - /// Theme applied by reference, if the board names one. The named - /// [`Theme`] object must already be in the graph when the board root - /// is accepted: publish the theme first, then the board that applies - /// it. Older v1 board bodies written before this field existed decode - /// as `None`. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub theme_ref: Option, -} - -/// Versioned board rules. A revision is a new immutable object. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct Rules { - /// Board root hash. - pub board: ArtifactHash, - /// One-based revision number within this board. - pub revision: u64, - /// Human-readable rule text; no executable content is interpreted. - pub text: String, -} - -/// A named discussion area within a board. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct Forum { - /// Board root hash. - pub board: ArtifactHash, - /// Display name. - pub name: String, -} - -/// A discussion thread, optionally scoped to a forum and rules revision. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct Thread { - /// Board root hash. - pub board: ArtifactHash, - /// Optional forum object hash. - pub forum_ref: Option, - /// Optional rules revision pinned by this thread. - pub rules_ref: Option, - /// Thread title. - pub title: String, -} - -/// Immutable post or post revision. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct Post { - /// Board root hash. - pub board: ArtifactHash, - /// Thread object hash. - pub thread: ArtifactHash, - /// Parent post hash for a reply, if any. - pub parent_post: Option, - /// Markdown/plain text body; media bytes are never embedded here. - pub body: String, - /// Attachment-record hashes. - pub attachments: Vec, - /// Typed hook for a signed game post; it does not imply execution. - pub embed_ref: Option, -} - -/// Metadata-only reference to a content-addressed attachment blob. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct Attachment { - /// Board root hash. - pub board: ArtifactHash, - /// Content-addressed blob hash (not an inline payload). - pub blob: ArtifactHash, - /// Declared media type. - pub media_type: String, - /// Blob size in bytes. - pub size_bytes: u64, -} - -/// Optional self-authored membership statement. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct Membership { - /// Board root hash. - pub board: ArtifactHash, - /// Member's canonical Ed25519 public key; must match the signer. - pub member: String, - /// Optional signed display-name claim; it is not globally unique. - pub display_name: Option, -} - -/// Board-scoped role names. Ownership is always the board-root signer. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] -pub enum BoardRole { - /// May publish rules/forums and signed moderation records. - Moderator, -} - -/// Owner-signed grant or revocation of a board-scoped role. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct RoleAttestation { - /// Board root hash. - pub board: ArtifactHash, - /// Subject's canonical Ed25519 public key. - pub member: String, - /// Role being granted or revoked. - pub role: BoardRole, - /// Whether the role is active after this attestation. - pub granted: bool, - /// Previous attestation this record supersedes, if changing a role. - pub supersedes: Option, -} - -/// Supported append-only moderation log actions; these do not enforce a view. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] -pub enum ModerationActionKind { - /// Mark a referenced object hidden in a board view. - Hide, - /// Reverse a prior hide by adding another log entry. - Restore, -} - -/// Append-only, board-scoped moderation statement. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct ModerationAction { - /// Board root hash. - pub board: ArtifactHash, - /// Object in this board's graph being acted upon. - pub target: ArtifactHash, - /// Action recorded by the signer. - pub action: ModerationActionKind, - /// Optional human-readable explanation. - pub reason: Option, -} - -/// A fork cites a source board and the source graph frontier it starts from. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct BoardFork { - /// Source board root hash. - pub source_board: ArtifactHash, - /// New board root hash, whose `forked_from` names `source_board`. - pub fork_board: ArtifactHash, - /// Source objects included in the fork's cited starting frontier. - pub source_frontier: Vec, -} - -/// Explicit immutable version link between two objects by the same author. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct Supersede { - /// Board root hash. - pub board: ArtifactHash, - /// Earlier object hash. - pub previous: ArtifactHash, - /// New object hash that replaces it in a projection. - pub replacement: ArtifactHash, -} - -/// Author-signed deletion request; the original signed object stays intact. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct Tombstone { - /// Board root hash. - pub board: ArtifactHash, - /// Object requested for deletion by its author. - pub target: ArtifactHash, - /// Optional explanation. - pub reason: Option, -} - -/// Closed set of board layouts a theme may select. Custom HTML templates -/// are explicitly out of v1: a theme is data (tokens, one layout, asset -/// references), never markup or code. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] -pub enum ThemeLayout { - /// A single vertical list of threads. - List, - /// A grid of thread cards. - Grid, - /// A dense list with reduced spacing. - Compact, -} - -/// A signed, portable board theme: design tokens, one layout, and -/// content-addressed asset references. -/// -/// A theme names no board. It is a reusable signed package, and a board -/// applies one by reference through [`Board::theme_ref`]. That keeps the -/// content-addressed graph acyclic: a theme that named its board could -/// never be referenced from that board's own root hash. `forked_from` is -/// the fork lineage — the theme this one derives from, if any. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct Theme { - /// Human-readable theme name. - pub name: String, - /// Design tokens by name (for example `accent`, `surface`); values - /// are plain data — colors, sizes, font names — never markup. - pub tokens: BTreeMap, - /// Layout selected from the closed v1 set. - pub layout: ThemeLayout, - /// Content-addressed asset blobs (logos, backgrounds); metadata - /// references only, payloads are never embedded. - pub assets: Vec, - /// Theme this one was forked from, if any (fork lineage). - pub forked_from: Option, -} - -/// A signed, opt-in host listing for one board (#3806). -/// -/// The board creator signs a listing naming a host (by its Ed25519 key) -/// that replicates the board's signed object set. Listings are versioned -/// per (board, host): the first listing is version 1, and every later -/// listing supersedes the previous one and advances the version by -/// exactly one, so publication and withdrawal both follow the signed -/// version/supersede rules of the graph — never host clocks and never -/// an unsigned host assertion. A withdrawal is a newer listing with -/// `listed == false`. Delisting is host-local in effect: it ends this -/// listing's replication offer, deletes nothing from any graph, and -/// makes no claim of global erasure. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct BoardListing { - /// Board root hash being listed. - pub board: ArtifactHash, - /// Canonical Ed25519 hex key of the host offering replication. - pub host: String, - /// One-based per-(board, host) listing version. - pub version: u64, - /// True publishes the listing; false withdraws it. - pub listed: bool, - /// Optional human/transport contact for the host (plain data). - pub contact: Option, - /// Previous listing for the same board and host, if any. - pub supersedes: Option, -} - /// One typed body carried by a [`SignedBoardObject`]. #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(tag = "type", content = "data", rename_all = "snake_case")] @@ -2707,150 +2237,6 @@ impl BoardGraph { } } -/// Which layer of a composed board view hid an object. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] -pub enum ViewLayer { - /// The viewer's own filter: personal hides and muted authors. - Personal, - /// The board's own signed record: moderation log and tombstones. - Board, - /// The serving host's policy set. - Host, -} - -/// One object a composed view hid, and the layer that hid it. -/// -/// The object itself stays in the graph — hidden is not erased — so -/// this entry (plus the public moderation log for board-layer hides) -/// is how a viewer, or an auditor, can tell that something is missing -/// from the projection and why. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct HiddenObject { - /// Hash of the hidden object. - pub object: ArtifactHash, - /// Layer that hid it (outermost applicable: board, host, personal). - pub layer: ViewLayer, - /// Moderation action or tombstone that hid it, for board-layer - /// hides; `None` for host and personal hides, which are not signed - /// graph records. - pub action: Option, - /// Recorded reason, when the hiding record carries one. - pub reason: Option, -} - -/// Caller-supplied outer layers for [`BoardGraph::compose_view`]. -/// -/// Host and personal filters are serving/viewing state, not signed -/// graph objects — a host's policy and a viewer's mutes are theirs to -/// keep — so they are inputs to the projection, never inserted. -#[derive(Clone, Debug, Default, PartialEq, Eq)] -pub struct ViewLayers { - /// Objects this viewer has personally hidden. - pub personal_hidden: BTreeSet, - /// Authors (canonical Ed25519 public keys) this viewer has muted. - pub muted_authors: BTreeSet, - /// Objects the serving host will not serve. - pub host_hidden: BTreeSet, -} - -/// A composed three-layer view of one board. This is a projection of -/// the graph, not a copy of it: every hash names an object that stays -/// in the graph, hidden ones included. -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct BoardView { - /// Board root hash this view was composed for. - pub board: ArtifactHash, - /// Theme the board applies by reference, resolved from the graph. - pub theme: Option, - /// Visible current objects: the board root and its content objects, - /// in deterministic content-hash order. - pub objects: Vec, - /// Objects hidden by one of the three layers, with the layer and - /// (for board-layer hides) the record that hid them. - pub hidden: Vec, - /// Every moderation action recorded for this board, in - /// deterministic content-hash order. The moderation log is public: - /// it is listed whether or not each entry currently hides anything. - pub moderation_log: Vec, -} - -/// Whether a replica holds a source board's full signed set. -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub enum ReplicaState { - /// The replica holds every object of the source board set. - Complete, - /// The replica is behind on at least one signed listing version: - /// its view of who serves the board (and what the set is) is old. - Stale, - /// Objects are missing without a listing-version lag (for example - /// the board root itself has not arrived yet). - Incomplete, -} - -/// Explicit comparison of one replica against a source board set. -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct ReplicaStatus { - /// Board root compared. - pub board: ArtifactHash, - /// Complete / stale / incomplete verdict. - pub state: ReplicaState, - /// Objects in the source board set. - pub expected_objects: usize, - /// Of those, objects this replica already holds. - pub present_objects: usize, - /// Source objects this replica does not hold yet. - pub missing: Vec, - /// Per host, `(replica version, source version)` where the signed - /// listing version in this replica lags the source. - pub listing_version_lag: BTreeMap, -} - -/// Outcome of one [`BoardGraph::replicate_board_from`] pass. -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct ReplicationReport { - /// Board root replicated. - pub board: ArtifactHash, - /// Hashes newly accepted into this graph, in acceptance order. - pub transferred: Vec, - /// Exported objects this graph already held. - pub already_present: usize, - /// Replica status against the source after the pass. - pub status: ReplicaStatus, -} - -/// One host's local serving policy. This is the host layer, kept -/// deliberately OUTSIDE the signed graph: it is unsigned, host-local, -/// and governs only what this host serves. Delisting a board here -/// stops this host serving it; the board's signed objects stay in the -/// graph and on every other host, portability is replication plus -/// re-listing elsewhere, and no delisting — here or in a signed -/// [`BoardListing`] withdrawal — is a promise of global deletion. -/// Host policy is also separate from board moderation: moderation is -/// the board's signed log inside the graph, this policy is not. -#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct HostServingPolicy { - /// Board roots this host will not serve. - pub delisted_boards: BTreeSet, - /// Optional local note (for example the legal basis); plain data. - pub note: Option, -} - -impl HostServingPolicy { - /// Whether this host serves `board` under its local policy. - pub fn serves_board(&self, board: &ArtifactHash) -> bool { - !self.delisted_boards.contains(board) - } - - /// Delist `board` on this host only. Returns true if it was served - /// before this call. The signed graph is untouched. - pub fn delist_board(&mut self, board: &ArtifactHash) -> bool { - self.delisted_boards.insert(board.clone()) - } -} - fn validate_board_id(value: &str) -> Result<()> { ensure!( (1..=128).contains(&value.len()) diff --git a/pkgs/id/src/boards/game.rs b/pkgs/id/src/boards/game.rs new file mode 100644 index 0000000000..67c68bb3cb --- /dev/null +++ b/pkgs/id/src/boards/game.rs @@ -0,0 +1,231 @@ +use serde::{Deserialize, Serialize}; + +use super::ArtifactHash; + +/// Typed reference to a signed game-post object; game execution is out of scope. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct GamePostRef { + /// Hash of the immutable `BoardObject::GamePost` in the board graph. + pub object: ArtifactHash, +} + +/// Immutable package identity pinned by a game post. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct GamePackageRef { + /// SHA-256 hash of the package bytes. A new package build has a new hash. + pub hash: ArtifactHash, + /// Human-facing package version associated with the pinned bytes. + pub version: String, +} + +/// Play mode supported by playable posts in v1. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "kebab-case")] +pub enum GameMode { + /// Players submit signed turns asynchronously against a pinned frontier. + AsyncTurns, +} + +/// One author assigned to a package-defined game role. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct GameParticipant { + /// Canonical Ed25519 public key of the assigned author. + pub author: String, + /// Canonical role identifier understood by the pinned game package. + pub role: String, +} + +/// Signed metadata for a package-pinned playable post. +/// +/// This object records the immutable package reference, package-specific +/// configuration and initial state, and the authors assigned to package-defined +/// roles. It is data, not executable code; accepting it does not run the package. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct GamePost { + /// Board root hash. + pub board: ArtifactHash, + /// Immutable package bytes and their human-facing version. + pub package: GamePackageRef, + /// The v1 play mode. + pub mode: GameMode, + /// Package-defined configuration, carried as data. + pub configuration: serde_json::Value, + /// Authors assigned to package-defined roles. + pub participants: Vec, + /// Package-specific initial state, carried as data. + pub genesis: serde_json::Value, +} + +/// Signed acceptance of a game post's challenge by one assigned participant. +/// +/// The game post's own author cannot accept their own challenge; an +/// acceptance is the record that opens the game for [`GameTurn`] objects. +/// Competing acceptance records from one participant (re-signed envelopes, +/// divergent arrivals) are all kept as signed history: acceptance is +/// effective by existence, never by a first-arrival-wins check, so peers +/// holding the same signed set converge in any arrival order — the same +/// rule [`BoardGraph::has_role`] documents for role grants. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct GameChallengeAcceptance { + /// Board root hash. + pub board: ArtifactHash, + /// Hash of the immutable `BoardObject::GamePost` being accepted. + pub game_post: ArtifactHash, +} + +/// One signed asynchronous turn in a package-pinned game. +/// +/// A turn is bound to its game post (and through it to the pinned package +/// hash and version), to the role its signer is assigned in that post, to +/// its index in a lineage, and to the prior turn it builds on (`prev_turn`, +/// `None` only for the opening turn). The acting participant rotates +/// through the game post's participant list by turn index — turn `i` must +/// be signed by `participants[i % participants.len()]` under that +/// participant's role — so a lineage cannot advance on one player's +/// signatures alone. Two valid turns may name the same `prev_turn`: they +/// are competing branches of the game, kept as forks in the graph, never +/// erased or overwritten by acceptance. Two authorization extensions +/// sit on top of rotation, both recorded as signed objects in the +/// graph: a turn in a [`GameFork`] instance names the fork in +/// `fork_ref` and resolves against the fork's own participants, and +/// on a line an accepted [`GameHandoff`] governs, the recipient may +/// sign a base-line turn under the seat role rotation assigns (the +/// recipient's leg — design #2054 section 4). +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct GameTurn { + /// Board root hash. + pub board: ArtifactHash, + /// Hash of the immutable `BoardObject::GamePost` this turn belongs to. + pub game_post: ArtifactHash, + /// Package-defined role the signer is assigned in the game post. + pub role: String, + /// Zero-based position of this turn in its lineage. + pub turn_index: u64, + /// The prior turn in this lineage; `None` for the opening turn. + pub prev_turn: Option, + /// The [`GameFork`] instance this turn belongs to, when it + /// continues a fork rather than the game post's base line. A + /// fork turn builds on the fork's cited save-point frontier or + /// on another turn of the same fork, and its signer resolves + /// against the fork's own participant list. Absent (the base + /// line) in objects written before this field existed. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub fork_ref: Option, + /// Package-defined action data, carried as data; replay interprets it. + pub action: serde_json::Value, +} + +/// A signed save point in one game line: the pinned package, the +/// frontier turn it saves, and the hash of the replayed state at +/// that frontier. +/// +/// A save point is signed by an assigned participant of the line +/// it saves: the post's participants for a base-line frontier, or +/// the fork's own participants when the frontier is a fork turn. +/// post and must name that post's exact pinned package (hash and +/// version) — a save recorded against different package bytes is a +/// save of a different game. The state hash is the saver's signed +/// claim about [`BoardGraph::replay_game_lineage`]'s snapshot at +/// the frontier; peers can recompute it from the same lineage and +/// the same bytes. Save blobs themselves stay content-addressed +/// references: this record carries hashes, never state bytes. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct GameSavePoint { + /// Board root hash. + pub board: ArtifactHash, + /// Hash of the immutable `BoardObject::GamePost` this save belongs to. + pub game_post: ArtifactHash, + /// The pinned package the saved line replays through; must equal + /// the game post's package reference exactly. + pub package: GamePackageRef, + /// Hash of the [`GameTurn`] at the saved frontier. + pub frontier: ArtifactHash, + /// SHA-256 hash of the replayed package state at the frontier. + pub state_hash: ArtifactHash, +} + +/// Signed handoff of a saved game line to a named recipient. +/// +/// Only the save point's own author may hand it off, and the +/// recipient must be an assigned participant of the game post — +/// turn validation binds continuation turns to the participant +/// list, so a handoff to anyone else could never be continued. +/// Competing handoffs of one save point are all kept as signed +/// history; an accepted handoff selects the social main line (see +/// [`BoardGraph::game_main_line_head`]) and the alternatives are +/// never deleted. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct GameHandoff { + /// Board root hash. + pub board: ArtifactHash, + /// Hash of the immutable `BoardObject::GamePost` this handoff belongs to. + pub game_post: ArtifactHash, + /// Hash of the `BoardObject::GameSavePoint` being handed off. + pub save_point: ArtifactHash, + /// Canonical Ed25519 public key of the named recipient. + pub recipient: String, + /// Handoff terms, carried as data. + pub terms: serde_json::Value, +} + +/// Signed acceptance of a [`GameHandoff`] by its named recipient. +/// +/// Only the recipient the handoff names may accept it. Acceptance +/// is effective by existence, never by a first-arrival-wins check — +/// the same rule [`GameChallengeAcceptance`] documents — so peers +/// holding the same signed set converge in any arrival order. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct GameHandoffAcceptance { + /// Board root hash. + pub board: ArtifactHash, + /// Hash of the immutable `BoardObject::GamePost` this acceptance belongs to. + pub game_post: ArtifactHash, + /// Hash of the `BoardObject::GameHandoff` being accepted. + pub handoff: ArtifactHash, +} + +/// A signed fork of a game from a cited save point, by any author. +/// +/// The fork record starts an independent continuation: turns that +/// build on the save point's frontier are a branch of the game +/// (see [`GameTurn`]), replayed independently of the source line +/// through [`BoardGraph::replay_game_lineage`]. The citation +/// preserves source-line attribution — the save point, its author, +/// and the lineage behind its frontier stay named in the graph. +/// Board-level [`BoardFork`] is a different feature (whole-board +/// provenance); this is a game-level fork inside one board. The +/// fork carries its own participant list: fork turns resolve their +/// signers against it, not the game post's, so a third-party fork +/// actually proceeds as an alternate instance (design #2054 +/// section 4). Seating is phase-aligned to the absolute turn +/// index — a fork turn's seat is `participants[turn_index % len]`, +/// matching the move count already inside the saved state — so a +/// fork opened mid-rotation continues the saved state's rotation +/// instead of restarting it. For the same reason the participant +/// list must preserve the saved instance's seat layout: the same +/// number of seats with the same role at each seat; only the +/// assigned authors may change. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct GameFork { + /// Board root hash. + pub board: ArtifactHash, + /// Hash of the immutable `BoardObject::GamePost` this fork belongs to. + pub game_post: ArtifactHash, + /// Hash of the `BoardObject::GameSavePoint` the fork cites. + pub save_point: ArtifactHash, + /// Authors assigned to package-defined roles in the fork + /// instance, in fork-turn rotation order. The fork's own + /// author must hold one of the assignments: a fork its author + /// cannot play in does not proceed. + pub participants: Vec, +} diff --git a/pkgs/id/src/boards/projection.rs b/pkgs/id/src/boards/projection.rs new file mode 100644 index 0000000000..92f98dbd23 --- /dev/null +++ b/pkgs/id/src/boards/projection.rs @@ -0,0 +1,149 @@ +use std::collections::{BTreeMap, BTreeSet}; + +use serde::{Deserialize, Serialize}; + +use super::{ArtifactHash, Theme}; + +/// Which layer of a composed board view hid an object. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] +pub enum ViewLayer { + /// The viewer's own filter: personal hides and muted authors. + Personal, + /// The board's own signed record: moderation log and tombstones. + Board, + /// The serving host's policy set. + Host, +} + +/// One object a composed view hid, and the layer that hid it. +/// +/// The object itself stays in the graph — hidden is not erased — so +/// this entry (plus the public moderation log for board-layer hides) +/// is how a viewer, or an auditor, can tell that something is missing +/// from the projection and why. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct HiddenObject { + /// Hash of the hidden object. + pub object: ArtifactHash, + /// Layer that hid it (outermost applicable: board, host, personal). + pub layer: ViewLayer, + /// Moderation action or tombstone that hid it, for board-layer + /// hides; `None` for host and personal hides, which are not signed + /// graph records. + pub action: Option, + /// Recorded reason, when the hiding record carries one. + pub reason: Option, +} + +/// Caller-supplied outer layers for [`BoardGraph::compose_view`]. +/// +/// Host and personal filters are serving/viewing state, not signed +/// graph objects — a host's policy and a viewer's mutes are theirs to +/// keep — so they are inputs to the projection, never inserted. +#[derive(Clone, Debug, Default, PartialEq, Eq)] +pub struct ViewLayers { + /// Objects this viewer has personally hidden. + pub personal_hidden: BTreeSet, + /// Authors (canonical Ed25519 public keys) this viewer has muted. + pub muted_authors: BTreeSet, + /// Objects the serving host will not serve. + pub host_hidden: BTreeSet, +} + +/// A composed three-layer view of one board. This is a projection of +/// the graph, not a copy of it: every hash names an object that stays +/// in the graph, hidden ones included. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct BoardView { + /// Board root hash this view was composed for. + pub board: ArtifactHash, + /// Theme the board applies by reference, resolved from the graph. + pub theme: Option, + /// Visible current objects: the board root and its content objects, + /// in deterministic content-hash order. + pub objects: Vec, + /// Objects hidden by one of the three layers, with the layer and + /// (for board-layer hides) the record that hid them. + pub hidden: Vec, + /// Every moderation action recorded for this board, in + /// deterministic content-hash order. The moderation log is public: + /// it is listed whether or not each entry currently hides anything. + pub moderation_log: Vec, +} + +/// Whether a replica holds a source board's full signed set. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum ReplicaState { + /// The replica holds every object of the source board set. + Complete, + /// The replica is behind on at least one signed listing version: + /// its view of who serves the board (and what the set is) is old. + Stale, + /// Objects are missing without a listing-version lag (for example + /// the board root itself has not arrived yet). + Incomplete, +} + +/// Explicit comparison of one replica against a source board set. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct ReplicaStatus { + /// Board root compared. + pub board: ArtifactHash, + /// Complete / stale / incomplete verdict. + pub state: ReplicaState, + /// Objects in the source board set. + pub expected_objects: usize, + /// Of those, objects this replica already holds. + pub present_objects: usize, + /// Source objects this replica does not hold yet. + pub missing: Vec, + /// Per host, `(replica version, source version)` where the signed + /// listing version in this replica lags the source. + pub listing_version_lag: BTreeMap, +} + +/// Outcome of one [`BoardGraph::replicate_board_from`] pass. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct ReplicationReport { + /// Board root replicated. + pub board: ArtifactHash, + /// Hashes newly accepted into this graph, in acceptance order. + pub transferred: Vec, + /// Exported objects this graph already held. + pub already_present: usize, + /// Replica status against the source after the pass. + pub status: ReplicaStatus, +} + +/// One host's local serving policy. This is the host layer, kept +/// deliberately OUTSIDE the signed graph: it is unsigned, host-local, +/// and governs only what this host serves. Delisting a board here +/// stops this host serving it; the board's signed objects stay in the +/// graph and on every other host, portability is replication plus +/// re-listing elsewhere, and no delisting — here or in a signed +/// [`BoardListing`] withdrawal — is a promise of global deletion. +/// Host policy is also separate from board moderation: moderation is +/// the board's signed log inside the graph, this policy is not. +#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct HostServingPolicy { + /// Board roots this host will not serve. + pub delisted_boards: BTreeSet, + /// Optional local note (for example the legal basis); plain data. + pub note: Option, +} + +impl HostServingPolicy { + /// Whether this host serves `board` under its local policy. + pub fn serves_board(&self, board: &ArtifactHash) -> bool { + !self.delisted_boards.contains(board) + } + + /// Delist `board` on this host only. Returns true if it was served + /// before this call. The signed graph is untouched. + pub fn delist_board(&mut self, board: &ArtifactHash) -> bool { + self.delisted_boards.insert(board.clone()) + } +} diff --git a/pkgs/id/src/boards/records.rs b/pkgs/id/src/boards/records.rs new file mode 100644 index 0000000000..837217d505 --- /dev/null +++ b/pkgs/id/src/boards/records.rs @@ -0,0 +1,252 @@ +use serde::{Deserialize, Serialize}; + +use super::*; + +/// Stable identity root for one public board. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct Board { + /// Stable ID chosen by the creator; the signed author's key scopes it. + pub board_id: String, + /// Optional source root when this board is a successor fork. + pub forked_from: Option, + /// Theme applied by reference, if the board names one. The named + /// [`Theme`] object must already be in the graph when the board root + /// is accepted: publish the theme first, then the board that applies + /// it. Older v1 board bodies written before this field existed decode + /// as `None`. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub theme_ref: Option, +} + +/// Versioned board rules. A revision is a new immutable object. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct Rules { + /// Board root hash. + pub board: ArtifactHash, + /// One-based revision number within this board. + pub revision: u64, + /// Human-readable rule text; no executable content is interpreted. + pub text: String, +} + +/// A named discussion area within a board. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct Forum { + /// Board root hash. + pub board: ArtifactHash, + /// Display name. + pub name: String, +} + +/// A discussion thread, optionally scoped to a forum and rules revision. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct Thread { + /// Board root hash. + pub board: ArtifactHash, + /// Optional forum object hash. + pub forum_ref: Option, + /// Optional rules revision pinned by this thread. + pub rules_ref: Option, + /// Thread title. + pub title: String, +} + +/// Immutable post or post revision. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct Post { + /// Board root hash. + pub board: ArtifactHash, + /// Thread object hash. + pub thread: ArtifactHash, + /// Parent post hash for a reply, if any. + pub parent_post: Option, + /// Markdown/plain text body; media bytes are never embedded here. + pub body: String, + /// Attachment-record hashes. + pub attachments: Vec, + /// Typed hook for a signed game post; it does not imply execution. + pub embed_ref: Option, +} + +/// Metadata-only reference to a content-addressed attachment blob. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct Attachment { + /// Board root hash. + pub board: ArtifactHash, + /// Content-addressed blob hash (not an inline payload). + pub blob: ArtifactHash, + /// Declared media type. + pub media_type: String, + /// Blob size in bytes. + pub size_bytes: u64, +} + +/// Optional self-authored membership statement. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct Membership { + /// Board root hash. + pub board: ArtifactHash, + /// Member's canonical Ed25519 public key; must match the signer. + pub member: String, + /// Optional signed display-name claim; it is not globally unique. + pub display_name: Option, +} + +/// Board-scoped role names. Ownership is always the board-root signer. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] +pub enum BoardRole { + /// May publish rules/forums and signed moderation records. + Moderator, +} + +/// Owner-signed grant or revocation of a board-scoped role. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct RoleAttestation { + /// Board root hash. + pub board: ArtifactHash, + /// Subject's canonical Ed25519 public key. + pub member: String, + /// Role being granted or revoked. + pub role: BoardRole, + /// Whether the role is active after this attestation. + pub granted: bool, + /// Previous attestation this record supersedes, if changing a role. + pub supersedes: Option, +} + +/// Supported append-only moderation log actions; these do not enforce a view. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] +pub enum ModerationActionKind { + /// Mark a referenced object hidden in a board view. + Hide, + /// Reverse a prior hide by adding another log entry. + Restore, +} + +/// Append-only, board-scoped moderation statement. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct ModerationAction { + /// Board root hash. + pub board: ArtifactHash, + /// Object in this board's graph being acted upon. + pub target: ArtifactHash, + /// Action recorded by the signer. + pub action: ModerationActionKind, + /// Optional human-readable explanation. + pub reason: Option, +} + +/// A fork cites a source board and the source graph frontier it starts from. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct BoardFork { + /// Source board root hash. + pub source_board: ArtifactHash, + /// New board root hash, whose `forked_from` names `source_board`. + pub fork_board: ArtifactHash, + /// Source objects included in the fork's cited starting frontier. + pub source_frontier: Vec, +} + +/// Explicit immutable version link between two objects by the same author. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct Supersede { + /// Board root hash. + pub board: ArtifactHash, + /// Earlier object hash. + pub previous: ArtifactHash, + /// New object hash that replaces it in a projection. + pub replacement: ArtifactHash, +} + +/// Author-signed deletion request; the original signed object stays intact. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct Tombstone { + /// Board root hash. + pub board: ArtifactHash, + /// Object requested for deletion by its author. + pub target: ArtifactHash, + /// Optional explanation. + pub reason: Option, +} + +/// Closed set of board layouts a theme may select. Custom HTML templates +/// are explicitly out of v1: a theme is data (tokens, one layout, asset +/// references), never markup or code. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] +pub enum ThemeLayout { + /// A single vertical list of threads. + List, + /// A grid of thread cards. + Grid, + /// A dense list with reduced spacing. + Compact, +} + +/// A signed, portable board theme: design tokens, one layout, and +/// content-addressed asset references. +/// +/// A theme names no board. It is a reusable signed package, and a board +/// applies one by reference through [`Board::theme_ref`]. That keeps the +/// content-addressed graph acyclic: a theme that named its board could +/// never be referenced from that board's own root hash. `forked_from` is +/// the fork lineage — the theme this one derives from, if any. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct Theme { + /// Human-readable theme name. + pub name: String, + /// Design tokens by name (for example `accent`, `surface`); values + /// are plain data — colors, sizes, font names — never markup. + pub tokens: BTreeMap, + /// Layout selected from the closed v1 set. + pub layout: ThemeLayout, + /// Content-addressed asset blobs (logos, backgrounds); metadata + /// references only, payloads are never embedded. + pub assets: Vec, + /// Theme this one was forked from, if any (fork lineage). + pub forked_from: Option, +} + +/// A signed, opt-in host listing for one board (#3806). +/// +/// The board creator signs a listing naming a host (by its Ed25519 key) +/// that replicates the board's signed object set. Listings are versioned +/// per (board, host): the first listing is version 1, and every later +/// listing supersedes the previous one and advances the version by +/// exactly one, so publication and withdrawal both follow the signed +/// version/supersede rules of the graph — never host clocks and never +/// an unsigned host assertion. A withdrawal is a newer listing with +/// `listed == false`. Delisting is host-local in effect: it ends this +/// listing's replication offer, deletes nothing from any graph, and +/// makes no claim of global erasure. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct BoardListing { + /// Board root hash being listed. + pub board: ArtifactHash, + /// Canonical Ed25519 hex key of the host offering replication. + pub host: String, + /// One-based per-(board, host) listing version. + pub version: u64, + /// True publishes the listing; false withdraws it. + pub listed: bool, + /// Optional human/transport contact for the host (plain data). + pub contact: Option, + /// Previous listing for the same board and host, if any. + pub supersedes: Option, +}