use super::*;
mod display;
mod methods;
#[derive(Debug, Clone)]
pub enum WarningHint {
MissingRequiredSection {
entity_type: String,
key: String,
heading: String,
write_rules: Vec<String>,
},
MissingRequiredField {
entity_type: String,
key: String,
description: String,
enum_values: Vec<String>,
},
UndeclaredRelationshipOpen { rel_type: String, message: String },
DuplicateRelationship {
rel_type: String,
from: EntityId,
to: EntityId,
},
NoSuchRelationship {
rel_type: String,
from: EntityId,
to: EntityId,
},
UnknownIncludeKey { key: String, allowed: Vec<String> },
LimitClamped { requested: usize, actual: usize },
TitleNormalizedToSlugNoop {
requested_title: String,
current_slug: String,
},
TitleCharsDroppedFromSlug {
title: String,
dropped_chars: Vec<char>,
slug: String,
},
UpdateNoop { id: EntityId },
StubFilterExcludesAll { entity_type: String },
UnknownFilterKey {
key: String,
scoped_type: Option<String>,
declared_on_other_types: Vec<String>,
},
FieldNotFilterable { field: String },
FilterValueMultiMember { key: String, value: String },
FilterValueNotInEnum {
key: String,
value: String,
allowed: Vec<String>,
},
NeighbourhoodCapped { kept: usize, total: usize },
SearchResultsTruncated { kept: usize, budget: usize },
RangeFilterKeyMalformed { key: String },
UnknownRangeFilterField {
field: String,
key: String,
scoped_type: Option<String>,
declared_on_other_types: Vec<String>,
},
FieldNotRangeFilterable { field: String },
SearchMemIndexUnavailable {
mem: String,
reason: &'static str,
error: Option<String>,
},
TitleTrimmed { original: String, trimmed: String },
SuspiciousNestedPrefix {
from: EntityId,
resolved_id: EntityId,
candidate_target: Option<EntityId>,
section: String,
prefix_mounted: bool,
},
InlineWikiLinkAutoStubbed {
from: EntityId,
stubs: Vec<EntityId>,
},
SelfLinkIgnored { id: EntityId },
CrossSchemaLinkUndeclared {
from: EntityId,
target: EntityId,
source_schema: String,
target_schema: String,
},
CrossMemTargetMemUncreated {
from_mem: String,
to_mem: String,
target_id: EntityId,
},
NoteMissing { tool: String },
IgnoredReadonlyField { field: String, supplied: String },
OuterRepoNotIgnoringMemRepo {
outer_repo_root: String,
workspace_root: String,
},
MissingRequiredOutgoing {
entity_type: String,
entity_id: EntityId,
missing: Vec<MissingRequiredOutgoingBlock>,
},
SignalThresholdCrossed {
entity_id: EntityId,
signal: String,
value: u64,
old_level: String,
new_level: String,
},
ConstraintUnsatisfied {
entity_type: String,
entity_id: EntityId,
violations: Vec<crate::ops::health::UnsatisfiedConstraint>,
},
DuplicateSectionHeading {
entity_id: EntityId,
section_key: String,
heading: String,
occurrences: usize,
},
MemReloaded {
mem: String,
old_head: String,
new_head: String,
entities_loaded: usize,
},
MemRosterChanged {
added: Vec<String>,
removed: Vec<String>,
quarantined: Vec<String>,
failures: Vec<String>,
},
OutOfBandEditsUndetected { mem: String },
UnanchoredMention {
mem: String,
binding: String,
entity: EntityId,
artifact: String,
section: String,
},
ConfigWriteIntervened { mem: String, fields: Vec<String> },
ShortIdResolved { given: String, resolved: EntityId },
AutoStubCreated { stub_id: EntityId, pending: bool },
DerivationBaselineRefreshed {
from: EntityId,
rel_type: String,
to: EntityId,
},
ParsedRelationInvalid {
entity_id: EntityId,
rel_type: String,
target: EntityId,
reason: String,
origin: String,
recovery: Option<ParsedRelationRecovery>,
},
ResidualStubForReadOnlyReferrers {
id: EntityId,
referrers: Vec<EntityId>,
},
MemFilesNotDeleted {
mem: String,
reason: String,
path: Option<String>,
error: Option<String>,
},
MemReattachedAfterUnregister {
mem: String,
unregistered_at: String,
},
ReadMemsMigratedToMounts {
mems: Vec<String>,
from_host_mems: Vec<String>,
},
EngineVersionSkew {
mem: String,
stamped_engine: String,
running_engine: String,
stamped_schema: String,
direction: crate::build_info::SkewDirection,
},
SchemaGenerationsBehind {
mem: String,
pinned: String,
newest: String,
},
FolderMemProvenance { mem: String },
SchemaAuthoringSourceMissing {
schema_ref: String,
stamped_path: String,
mems: Vec<String>,
},
SchemaAuthoringSourceDiverged {
schema_ref: String,
stamped_path: String,
mems: Vec<String>,
detail: String,
},
SchemaUnstampedSourceRot {
schema_ref: String,
mems: Vec<String>,
detail: String,
},
AmbiguousDescriptionDelimiter {
from: EntityId,
rel_type: String,
target: EntityId,
trailing: String,
},
ParseMissingRequiredDescription {
from: EntityId,
rel_type: String,
target: EntityId,
},
ParseDescriptionNotPermitted {
from: EntityId,
rel_type: String,
target: EntityId,
},
SchemaPinMismatch {
mem: String,
config_pin: String,
mount_pin: String,
},
MountUnbacked {
mem: String,
reason: MountUnbackedReason,
location: String,
},
InterruptedCommitCompleted {
mem: String,
files: Vec<String>,
},
WriteFollowUpFailed {
mem: String,
step: String,
detail: String,
},
SectionHeadingDivergence {
entity_id: EntityId,
section_key: String,
writing_heading: String,
existing_heading: String,
},
SchemaHeadingRoundtripViolation {
mem: String,
schema_ref: String,
violations: Vec<SchemaHeadingViolation>,
},
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
pub struct SchemaHeadingViolation {
pub type_name: String,
pub key: String,
pub heading: String,
pub derived_key: String,
}
impl From<&memstead_schema::HeadingKeyViolation> for SchemaHeadingViolation {
fn from(v: &memstead_schema::HeadingKeyViolation) -> Self {
Self {
type_name: v.type_name.clone(),
key: v.key.clone(),
heading: v.heading.clone(),
derived_key: v.derived_key.clone(),
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct MissingRequiredOutgoingBlock {
pub relationships: Vec<String>,
pub cardinality: String,
#[serde(skip_serializing_if = "severity_is_warn")]
pub severity: memstead_schema::ConstraintSeverity,
#[serde(skip_serializing_if = "Option::is_none")]
pub when_field: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub when_value: Option<String>,
}
fn severity_is_warn(s: &memstead_schema::ConstraintSeverity) -> bool {
*s == memstead_schema::ConstraintSeverity::Warn
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
pub struct ParsedRelationRecovery {
pub kind: String,
pub source_id: EntityId,
pub target_id: EntityId,
pub rel_type: String,
}
impl ParsedRelationRecovery {
pub const KIND_REMOVE_EXPLICIT_RELATION: &'static str = "remove_explicit_relation";
pub fn remove_explicit_relation(
source_id: EntityId,
target_id: EntityId,
rel_type: String,
) -> Self {
Self {
kind: Self::KIND_REMOVE_EXPLICIT_RELATION.to_string(),
source_id,
target_id,
rel_type,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct ParseRecoveryEntry {
pub entity_id: EntityId,
pub rel_type: String,
pub target: EntityId,
pub outcome: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub reason: Option<String>,
}
impl ParseRecoveryEntry {
pub const OUTCOME_REMOVED: &'static str = "removed";
pub const OUTCOME_SKIPPED: &'static str = "skipped";
pub const OUTCOME_FAILED: &'static str = "failed";
pub const REASON_READONLY_MOUNT: &'static str = "readonly_mount";
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct ParseRecoveryReport {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub entries: Vec<ParseRecoveryEntry>,
#[serde(default, skip_serializing_if = "String::is_empty")]
pub write_id: String,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum MountUnbackedReason {
MissingRef,
MissingPath,
Empty,
}
impl MountUnbackedReason {
pub fn as_str(self) -> &'static str {
match self {
Self::MissingRef => "missing_ref",
Self::MissingPath => "missing_path",
Self::Empty => "empty",
}
}
}
impl Serialize for WarningHint {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
let details = self.details_payload();
let mut state = serializer.serialize_struct("WarningHint", 3)?;
state.serialize_field("code", self.code())?;
state.serialize_field("message", &self.message())?;
state.serialize_field("details", &details)?;
state.end()
}
}