use meerkat_machine_schema::catalog::dsl::OptionValueExt;
pub use meerkat_machine_schema::catalog::dsl::mob_host_binding_authority::{
FlowTurnOutcomeKind, HostAdmissionRejectKind, HostBindingPhase, MaterializeRejectKind,
MemberSessionDisposal, TrackedInputCancelKind,
};
#[derive(
Debug,
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Default,
serde::Serialize,
serde::Deserialize,
)]
pub struct MobId(pub String);
impl<T: Into<String>> From<T> for MobId {
fn from(s: T) -> Self {
Self(s.into())
}
}
impl MobId {
pub fn from_domain(mob_id: &crate::ids::MobId) -> Self {
Self(mob_id.as_str().to_owned())
}
}
#[derive(
Debug,
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Default,
serde::Serialize,
serde::Deserialize,
)]
pub struct AgentIdentity(pub String);
impl<T: Into<String>> From<T> for AgentIdentity {
fn from(s: T) -> Self {
Self(s.into())
}
}
impl AgentIdentity {
pub fn from_domain(identity: &crate::ids::AgentIdentity) -> Self {
Self(identity.as_str().to_owned())
}
}
#[derive(
Debug,
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Default,
serde::Serialize,
serde::Deserialize,
)]
pub struct PeerId(pub String);
impl<T: Into<String>> From<T> for PeerId {
fn from(s: T) -> Self {
Self(s.into())
}
}
#[derive(
Debug,
Clone,
Copy,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Default,
serde::Serialize,
serde::Deserialize,
)]
pub struct PeerSigningKey(pub [u8; 32]);
impl From<[u8; 32]> for PeerSigningKey {
fn from(key: [u8; 32]) -> Self {
Self(key)
}
}
#[derive(
Debug,
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Default,
serde::Serialize,
serde::Deserialize,
)]
pub struct SessionId(pub String);
impl<T: Into<String>> From<T> for SessionId {
fn from(s: T) -> Self {
Self(s.into())
}
}
#[derive(
Debug,
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Default,
serde::Serialize,
serde::Deserialize,
)]
pub struct InputId(pub String);
impl<T: Into<String>> From<T> for InputId {
fn from(s: T) -> Self {
Self(s.into())
}
}
#[derive(
Debug,
Clone,
Copy,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Default,
serde::Serialize,
serde::Deserialize,
)]
pub struct Generation(pub u64);
impl From<u64> for Generation {
fn from(v: u64) -> Self {
Self(v)
}
}
impl From<crate::ids::Generation> for Generation {
fn from(generation: crate::ids::Generation) -> Self {
Self(generation.get())
}
}
impl Generation {
pub const fn to_domain(self) -> crate::ids::Generation {
crate::ids::Generation::new(self.0)
}
}
#[derive(
Debug,
Clone,
Copy,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Default,
serde::Serialize,
serde::Deserialize,
)]
pub struct FenceToken(pub u64);
impl From<u64> for FenceToken {
fn from(v: u64) -> Self {
Self(v)
}
}
impl From<crate::ids::FenceToken> for FenceToken {
fn from(fence_token: crate::ids::FenceToken) -> Self {
Self(fence_token.get())
}
}
impl FenceToken {
pub const fn to_domain(self) -> crate::ids::FenceToken {
crate::ids::FenceToken::new(self.0)
}
}
#[derive(
Debug,
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Default,
serde::Serialize,
serde::Deserialize,
)]
pub struct MemberKey {
pub mob_id: MobId,
pub agent_identity: AgentIdentity,
}
impl MemberKey {
pub fn new(mob_id: MobId, agent_identity: AgentIdentity) -> Self {
Self {
mob_id,
agent_identity,
}
}
pub fn from_domain(mob_id: &crate::ids::MobId, identity: &crate::ids::AgentIdentity) -> Self {
Self {
mob_id: MobId::from_domain(mob_id),
agent_identity: AgentIdentity::from_domain(identity),
}
}
}
#[derive(
Debug,
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Default,
serde::Serialize,
serde::Deserialize,
)]
pub struct TurnKey {
pub mob_id: MobId,
pub agent_identity: AgentIdentity,
pub generation: Generation,
pub fence_token: FenceToken,
pub input_id: InputId,
}
impl TurnKey {
pub fn new(
mob_id: MobId,
agent_identity: AgentIdentity,
generation: Generation,
fence_token: FenceToken,
input_id: InputId,
) -> Self {
Self {
mob_id,
agent_identity,
generation,
fence_token,
input_id,
}
}
pub fn from_domain(
mob_id: &crate::ids::MobId,
identity: &crate::ids::AgentIdentity,
generation: crate::ids::Generation,
fence_token: crate::ids::FenceToken,
input_id: &str,
) -> Self {
Self {
mob_id: MobId::from_domain(mob_id),
agent_identity: AgentIdentity::from_domain(identity),
generation: Generation::from(generation),
fence_token: FenceToken::from(fence_token),
input_id: InputId(input_id.to_owned()),
}
}
}
meerkat_machine_schema::mob_host_binding_authority_dsl!(
"meerkat-mob",
"machines::mob_host_binding_authority"
);
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum MobHostBindingAuthorityRuntimeInternalReason {
HostBindingAdmissionAuthority,
MaterializeDedupAuthority,
ReleaseDedupAuthority,
TurnOutcomeJournalAuthority,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct MobHostBindingAuthorityRuntimeInternalClassificationRecord {
pub input: MobHostBindingAuthorityInputVariant,
pub reason: MobHostBindingAuthorityRuntimeInternalReason,
}
const MOB_HOST_BINDING_AUTHORITY_RUNTIME_INTERNAL_CLASSIFICATIONS:
&[MobHostBindingAuthorityRuntimeInternalClassificationRecord] = &[
MobHostBindingAuthorityRuntimeInternalClassificationRecord {
input: MobHostBindingAuthorityInputVariant::ResolveHostBind,
reason: MobHostBindingAuthorityRuntimeInternalReason::HostBindingAdmissionAuthority,
},
MobHostBindingAuthorityRuntimeInternalClassificationRecord {
input: MobHostBindingAuthorityInputVariant::ResolveHostRebind,
reason: MobHostBindingAuthorityRuntimeInternalReason::HostBindingAdmissionAuthority,
},
MobHostBindingAuthorityRuntimeInternalClassificationRecord {
input: MobHostBindingAuthorityInputVariant::RevokeHostBinding,
reason: MobHostBindingAuthorityRuntimeInternalReason::HostBindingAdmissionAuthority,
},
MobHostBindingAuthorityRuntimeInternalClassificationRecord {
input: MobHostBindingAuthorityInputVariant::ResolveHostCommandAdmission,
reason: MobHostBindingAuthorityRuntimeInternalReason::HostBindingAdmissionAuthority,
},
MobHostBindingAuthorityRuntimeInternalClassificationRecord {
input: MobHostBindingAuthorityInputVariant::ResolveMaterializeAdmission,
reason: MobHostBindingAuthorityRuntimeInternalReason::MaterializeDedupAuthority,
},
MobHostBindingAuthorityRuntimeInternalClassificationRecord {
input: MobHostBindingAuthorityInputVariant::ResolveMaterializePreflight,
reason: MobHostBindingAuthorityRuntimeInternalReason::MaterializeDedupAuthority,
},
MobHostBindingAuthorityRuntimeInternalClassificationRecord {
input: MobHostBindingAuthorityInputVariant::RecordMaterializedMember,
reason: MobHostBindingAuthorityRuntimeInternalReason::MaterializeDedupAuthority,
},
MobHostBindingAuthorityRuntimeInternalClassificationRecord {
input: MobHostBindingAuthorityInputVariant::ResolveReleaseAdmission,
reason: MobHostBindingAuthorityRuntimeInternalReason::ReleaseDedupAuthority,
},
MobHostBindingAuthorityRuntimeInternalClassificationRecord {
input: MobHostBindingAuthorityInputVariant::RecordMemberRelease,
reason: MobHostBindingAuthorityRuntimeInternalReason::ReleaseDedupAuthority,
},
MobHostBindingAuthorityRuntimeInternalClassificationRecord {
input: MobHostBindingAuthorityInputVariant::RecordTurnOutcome,
reason: MobHostBindingAuthorityRuntimeInternalReason::TurnOutcomeJournalAuthority,
},
MobHostBindingAuthorityRuntimeInternalClassificationRecord {
input: MobHostBindingAuthorityInputVariant::CancelTrackedInput,
reason: MobHostBindingAuthorityRuntimeInternalReason::TurnOutcomeJournalAuthority,
},
MobHostBindingAuthorityRuntimeInternalClassificationRecord {
input: MobHostBindingAuthorityInputVariant::CompleteTrackedInputCancel,
reason: MobHostBindingAuthorityRuntimeInternalReason::TurnOutcomeJournalAuthority,
},
];
#[doc(hidden)]
#[must_use]
pub const fn canonical_mob_host_binding_authority_runtime_internal_classifications()
-> &'static [MobHostBindingAuthorityRuntimeInternalClassificationRecord] {
MOB_HOST_BINDING_AUTHORITY_RUNTIME_INTERNAL_CLASSIFICATIONS
}
#[doc(hidden)]
#[must_use]
pub fn canonical_mob_host_binding_authority_runtime_internal_input_variant_manifest()
-> Vec<MobHostBindingAuthorityInputVariant> {
MOB_HOST_BINDING_AUTHORITY_RUNTIME_INTERNAL_CLASSIFICATIONS
.iter()
.map(|record| record.input)
.collect()
}