Skip to main content

ev/
lint.rs

1//! Best-effort lexical lints over built-in, deterministic word lists.
2//! R3: the subject of self-evolve/self-improve language must be a human, not the system.
3//! R5: no auto-close / auto-prune / self-stop op language.
4//! Honest limit: a re-wording evades these — they are heuristics, not semantic guarantees.
5
6const R3_VERBS: &[&str] = &[
7    "self-evolve",
8    "self-improve",
9    "self-grade",
10    "self-optimize",
11    "self-tune",
12    "self-evaluate",
13];
14const R5_OPS: &[&str] = &["auto-close", "auto-prune", "self-stop", "auto-inherit"];
15
16fn hits(text: &str, words: &[&str]) -> Vec<String> {
17    let lower = text.to_lowercase();
18    words
19        .iter()
20        .filter(|w| lower.contains(*w))
21        .map(|w| w.to_string())
22        .collect()
23}
24
25/// R3: free-text fields that carry a self-evolve verb (subject should be a human).
26pub fn r3_self_evolve(text: &str) -> Vec<String> {
27    hits(text, R3_VERBS)
28}
29
30/// R5: free-text fields that describe a forbidden machine-initiated op.
31pub fn r5_forbidden_op(text: &str) -> Vec<String> {
32    hits(text, R5_OPS)
33}
34
35#[cfg(test)]
36mod tests {
37    use super::*;
38    #[test]
39    fn r3_should_return_the_verb_when_the_system_is_a_self_evolve_subject() {
40        // given: text where the system is the subject of a self-evolve verb
41        let text = "the retrieval system will self-evolve its schema";
42
43        // when: the R3 lint scans it
44        let hits = r3_self_evolve(text);
45
46        // then: it returns the offending verb
47        assert_eq!(hits, vec!["self-evolve".to_string()]);
48    }
49
50    #[test]
51    fn r3_should_return_no_hits_when_text_is_ordinary() {
52        // given: ordinary text with no self-evolve verb
53        let text = "build our own retrieval; reject pgvector";
54
55        // when: the R3 lint scans it
56        let hits = r3_self_evolve(text);
57
58        // then: it returns no hits
59        assert!(hits.is_empty());
60    }
61
62    #[test]
63    fn r5_should_return_the_op_when_text_describes_an_auto_close() {
64        // given: text describing a machine-initiated auto-close op
65        let text = "the system will auto-close stale grounds";
66
67        // when: the R5 lint scans it
68        let hits = r5_forbidden_op(text);
69
70        // then: it returns the forbidden op
71        assert_eq!(hits, vec!["auto-close".to_string()]);
72    }
73}