Projector guard: "short-term" is ordinary English, its one kebab exemption; shortTerm and short_term are still caught

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-19 23:43:49 +01:00
commit 33b42226f5
2 changed files with 10 additions and 3 deletions

View file

@ -116,6 +116,10 @@ pub(crate) fn words(text: &str) -> usize {
text.split_whitespace().count()
}
/// The one kebab form that is ordinary English: "short-term" folds to the schema key `shortTerm`, and prose must not fail
/// the judge for it. `shortTerm`, `short_term` and the run-together `shortterm` are still caught.
const KEBAB_ENGLISH: &str = "short-term";
/// Her persona state's schema: its property names are the identifiers a narration must never carry.
const PERSONA_SCHEMA: &str = include_str!("../../../../schemas/cultnet/gamecult.persona_state.v0.schema.json");
@ -173,7 +177,7 @@ pub(crate) fn field_names(narration: &str, ids: &[String]) -> Vec<String> {
let known = identifiers();
let mut found = BTreeSet::new();
for token in narration.split(|c: char| !(c.is_alphanumeric() || c == '_' || c == '-')).map(|token| token.trim_matches('-')).filter(|token| !token.is_empty()) {
if known.contains(&folded(token)) {
if known.contains(&folded(token)) && !token.eq_ignore_ascii_case(KEBAB_ENGLISH) {
found.insert(token.to_owned());
}
}

View file

@ -1065,8 +1065,11 @@ fn the_guard_catches_every_case_convention() {
for leak in ["social-bonds", "socialbonds", "SOCIAL_BONDS", "SocialBonds", "candidate-actions", "the voice-summary", "inclusion-score", "activationProfile.situationalState"] {
assert!(!field_names(leak, &[]).is_empty(), "{leak:?}");
}
// The cost, recorded: a schema key that reads as English hyphenated is flagged too.
assert_eq!(field_names("a short-term thing", &[]), ["short-term"]);
// The one exemption: "short-term" is ordinary English; its identifier forms are still caught.
assert!(field_names("a short-term thing, and a Short-Term one", &[]).is_empty());
for leak in ["shortTerm", "short_term", "ShortTerm", "shortterm"] {
assert_eq!(field_names(&format!("her {leak} list"), &[]), [leak], "{leak}");
}
for prose in ["the DevOps crew", "an iPhone", "GameCult", "PlayStation", "need-to-know", "trust: she waits"] {
assert!(field_names(prose, &[]).is_empty(), "{prose:?}");
}