Align strategic text limits with Eve schema

This commit is contained in:
Meta Vens 2026-08-26 05:15:27 +02:00
commit 3e86fb95b2
3 changed files with 39 additions and 8 deletions

View file

@ -2236,11 +2236,16 @@ fn apply_strategic_tick_plan(
"institution acts twice in one strategic tick".into(),
));
}
if action.posture.trim().is_empty() || action.posture.len() > 240 {
if action.posture.trim().is_empty() {
return Err(KernelError::Invalid(
"strategic institution posture is empty".into(),
));
}
if action.posture.chars().count() > 240 {
return Err(KernelError::Invalid(
"strategic institution posture exceeds 240 characters".into(),
));
}
if action
.location_ids
.iter()

View file

@ -2272,11 +2272,11 @@ fn validate_cell_appraisal(
inaction.subject_id
));
}
if inaction.reason.len() > 240 {
if inaction.reason.chars().count() > 240 {
return Err(anyhow!(
"inaction reason for subject {} is {} characters but permits at most 240",
inaction.subject_id,
inaction.reason.len()
inaction.reason.chars().count()
));
}
if !permitted_subject_ids.contains(inaction.subject_id.as_str()) {
@ -2508,7 +2508,20 @@ fn validate_constituent_effect(
subject.subject_id
)
})?;
if !crate::resolution::substantive_text_change(current, posture) {
if posture.trim().is_empty() {
return Err(anyhow!(
"institution {} proposed an empty posture",
subject.subject_id
));
}
if posture.chars().count() > 240 {
return Err(anyhow!(
"institution {} proposed a posture of {} characters; the exact maximum is 240",
subject.subject_id,
posture.chars().count()
));
}
if current.trim().eq_ignore_ascii_case(posture.trim()) {
return Err(anyhow!(
"institution {} proposed posture {:?}, but its exact current posture is {:?}; emit a specific different commitment or choose inaction",
subject.subject_id,

View file

@ -1654,7 +1654,7 @@ pub fn select_resolution_wave(
let mut inaction_subject_ids = BTreeSet::new();
for inaction in &appraisal.inactions {
if inaction.reason.trim().is_empty()
|| inaction.reason.len() > 240
|| inaction.reason.chars().count() > 240
|| action_subject_ids.contains(inaction.subject_id.as_str())
|| !inaction_subject_ids.insert(inaction.subject_id.as_str())
|| !cell_contains_attributed_subject(campaign, cell, &inaction.subject_id)
@ -1926,7 +1926,7 @@ fn validate_cell_proposal(
if institution_id != &proposal.subject_id
|| !campaign.institutions.contains_key(institution_id)
|| posture.trim().is_empty()
|| posture.len() > 240
|| posture.chars().count() > 240
|| !substantive_text_change(
&campaign.institutions[institution_id].posture,
posture,
@ -2103,7 +2103,9 @@ fn is_human_controlled_actor(campaign: &Campaign, subject_id: &str) -> bool {
pub fn substantive_text_change(current: &str, candidate: &str) -> bool {
let current = current.trim();
let candidate = candidate.trim();
!candidate.is_empty() && candidate.len() <= 240 && !current.eq_ignore_ascii_case(candidate)
!candidate.is_empty()
&& candidate.chars().count() <= 240
&& !current.eq_ignore_ascii_case(candidate)
}
pub fn validate_gestalt_pressure_transition(
@ -2117,7 +2119,7 @@ pub fn validate_gestalt_pressure_transition(
));
}
let clean = |value: &String| {
!value.is_empty() && value.len() <= 240 && value.trim().len() == value.len()
!value.is_empty() && value.chars().count() <= 240 && value.trim().len() == value.len()
};
if additions.iter().any(|value| !clean(value)) || resolutions.iter().any(|value| !clean(value))
{
@ -3482,6 +3484,17 @@ pub(crate) mod tests {
"holding position",
"releasing the reserve"
));
let schema_max_with_unicode = format!("{}’", "a".repeat(239));
assert_eq!(schema_max_with_unicode.chars().count(), 240);
assert!(schema_max_with_unicode.len() > 240);
assert!(substantive_text_change(
"holding position",
&schema_max_with_unicode
));
assert!(!substantive_text_change(
"holding position",
&format!("{schema_max_with_unicode}a")
));
}
#[test]