Skip to main content

made_core/entities/
agentic_system_publication_outcome.rs

1use crate::value_objects::AgenticSystemDigest;
2
3use super::PublishedAgenticSystem;
4
5/// Result of idempotently sealing one revision of a design.
6///
7/// The same shape as a ceremony definition's publication outcome, and
8/// for the same reason: offering identical content under a revision
9/// that already holds it is not an error, offering different content
10/// under it is, and both digests come back so the caller can see what
11/// differed rather than being told only that something did.
12#[derive(Debug, Clone, PartialEq, Eq)]
13pub enum AgenticSystemPublicationOutcome {
14    Published(PublishedAgenticSystem),
15    AlreadyPublished(PublishedAgenticSystem),
16    RevisionOccupied {
17        published: AgenticSystemDigest,
18        offered: AgenticSystemDigest,
19    },
20}
21
22impl AgenticSystemPublicationOutcome {
23    #[must_use]
24    pub const fn published(&self) -> Option<&PublishedAgenticSystem> {
25        match self {
26            Self::Published(published) | Self::AlreadyPublished(published) => Some(published),
27            Self::RevisionOccupied { .. } => None,
28        }
29    }
30
31    #[must_use]
32    pub const fn is_conflict(&self) -> bool {
33        matches!(self, Self::RevisionOccupied { .. })
34    }
35
36    #[must_use]
37    pub const fn is_new(&self) -> bool {
38        matches!(self, Self::Published(_))
39    }
40
41    #[must_use]
42    pub const fn as_str(&self) -> &'static str {
43        match self {
44            Self::Published(_) => "published",
45            Self::AlreadyPublished(_) => "already_published",
46            Self::RevisionOccupied { .. } => "revision_occupied",
47        }
48    }
49}