spark-inquisitor
Ultra-fast compiled native Rust gatekeeper and automated code reviewer
Brought by drakestapleton
GitHub aien-dev/spark-inquisitor#2 (code only)
Apply it
git checkout -b patch-9677e4b0dd50f8ee 6819552fd5f5fd5dc8c8c6231bb5e93320517abd curl -fsSL https://interplane.io/drakestapleton/spark-inquisitor/patches/9677e4b0dd50f8ee.patch | git am
Provenance
github-import 1
aien-dev/spark-inquisitor
2
95da3c93fae7cd431242533c331714250676d4ee
{"kind":"github-import","owner":"aien-dev","repo":"spark-inquisitor","number":2,"url":"https://github.com/aien-dev/spark-inquisitor/pull/2","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:40:41Z","metadata":"unavailable","state_derived":true}
Changes
diff --git a/src/constitution.rs b/src/constitution.rs index fa3b670..cd7f7ae 100644 --- a/src/constitution.rs +++ b/src/constitution.rs @@ -12,7 +12,6 @@ static CRUCIAL_RE: OnceLock<Regex> = OnceLock::new(); static PIVOTAL_RE: OnceLock<Regex> = OnceLock::new(); static ELEVATE_RE: OnceLock<Regex> = OnceLock::new(); static GAME_CHANGER_RE: OnceLock<Regex> = OnceLock::new(); -static SEAMLESS_RE: OnceLock<Regex> = OnceLock::new(); static UNLEASH_RE: OnceLock<Regex> = OnceLock::new(); static BEACON_TROPE_RE: OnceLock<Regex> = OnceLock::new(); static HARNESS_VERB_RE: OnceLock<Regex> = OnceLock::new(); @@ -54,8 +53,10 @@ impl ConstitutionalChecker { } // GitHub Personal Access Tokens (ghp_... or github_pat_...) - let github_pat_regex = GITHUB_PAT_REGEX.get_or_init(|| Regex::new(r"\bghp_[A-Za-z0-9]{36,}\b").unwrap()); - let github_fine_pat_regex = GITHUB_FINE_PAT_REGEX.get_or_init(|| Regex::new(r"\bgithub_pat_[A-Za-z0-9_]{50,}\b").unwrap()); + let github_pat_regex = + GITHUB_PAT_REGEX.get_or_init(|| Regex::new(r"\bghp_[A-Za-z0-9]{36,}\b").unwrap()); + let github_fine_pat_regex = GITHUB_FINE_PAT_REGEX + .get_or_init(|| Regex::new(r"\bgithub_pat_[A-Za-z0-9_]{50,}\b").unwrap()); if github_pat_regex.is_match(line) || github_fine_pat_regex.is_match(line) { violations.push(ViolationKind::Secret(format!( "Plaintext GitHub Personal Access Token detected in line: [REDACTED_GH_TOKEN]" @@ -63,7 +64,9 @@ impl ConstitutionalChecker { } // Private Keys - let priv_key_regex = PRIV_KEY_REGEX.get_or_init(|| Regex::new(r"-----BEGIN (?:[A-Z0-9 ]+)?PRIVATE KEY-----|BEGIN RSA PRIVATE KEY").unwrap()); + let priv_key_regex = PRIV_KEY_REGEX.get_or_init(|| { + Regex::new(r"-----BEGIN (?:[A-Z0-9 ]+)?PRIVATE KEY-----|BEGIN RSA PRIVATE KEY").unwrap() + }); if priv_key_regex.is_match(line) { violations.push(ViolationKind::Secret(format!( "Plaintext Private Key header detected in line: [REDACTED_PRIVATE_KEY]" @@ -117,8 +120,12 @@ impl ConstitutionalChecker { } // Elevate (exclude CLI flags like --elevate or identifiers with hyphens/underscores) - let elevate_re = ELEVATE_RE.get_or_init(|| Regex::new(r"\belevat(?:e|es|ed|ing)\b").unwrap()); - if elevate_re.is_match(&lower) && !lower.contains("--elevate") && !lower.contains("elevate_") { + let elevate_re = + ELEVATE_RE.get_or_init(|| Regex::new(r"\belevat(?:e|es|ed|ing)\b").unwrap()); + if elevate_re.is_match(&lower) + && !lower.contains("--elevate") + && !lower.contains("elevate_") + { violations.push(ViolationKind::Buzzword(format!( "Forbidden AI buzzword 'elevate' detected in line: {}", line.trim() @@ -126,7 +133,8 @@ impl ConstitutionalChecker { } // Game-changer - let game_changer_re = GAME_CHANGER_RE.get_or_init(|| Regex::new(r"\bgame[ -]?changer\b").unwrap()); + let game_changer_re = + GAME_CHANGER_RE.get_or_init(|| Regex::new(r"\bgame[ -]?changer\b").unwrap()); if game_changer_re.is_match(&lower) { violations.push(ViolationKind::Buzzword(format!( "Forbidden AI buzzword 'game-changer' detected in line: {}", @@ -134,18 +142,13 @@ impl ConstitutionalChecker { ))); } - // Seamlessly / seamless - let seamless_re = SEAMLESS_RE.get_or_init(|| Regex::new(r"\bseamless(?:ly)?\b").unwrap()); - if seamless_re.is_match(&lower) { - violations.push(ViolationKind::Buzzword(format!( - "Forbidden AI buzzword 'seamlessly' detected in line: {}", - line.trim() - ))); - } - // Unleash (exclude CLI flags like --unleash or --unleash-features or identifiers with hyphens/underscores) - let unleash_re = UNLEASH_RE.get_or_init(|| Regex::new(r"\bunleash(?:es|ed|ing)?\b").unwrap()); - if unleash_re.is_match(&lower) && !lower.contains("--unleash") && !lower.contains("unleash_") { + let unleash_re = + UNLEASH_RE.get_or_init(|| Regex::new(r"\bunleash(?:es|ed|ing)?\b").unwrap()); + if unleash_re.is_match(&lower) + && !lower.contains("--unleash") + && !lower.contains("unleash_") + { violations.push(ViolationKind::Buzzword(format!( "Forbidden AI buzzword 'unleash' detected in line: {}", line.trim() @@ -153,7 +156,12 @@ impl ConstitutionalChecker { } // Beacon: when used as trope - let beacon_trope_re = BEACON_TROPE_RE.get_or_init(|| Regex::new(r"\b(?:(?:a|shining)\s+)?beacon\s+(?:of|for|in|to|that)\b|\bas\s+a\s+beacon\b").unwrap()); + let beacon_trope_re = BEACON_TROPE_RE.get_or_init(|| { + Regex::new( + r"\b(?:(?:a|shining)\s+)?beacon\s+(?:of|for|in|to|that)\b|\bas\s+a\s+beacon\b", + ) + .unwrap() + }); if beacon_trope_re.is_match(&lower) { violations.push(ViolationKind::Buzzword(format!( "Forbidden AI buzzword trope 'beacon' detected in line: {}", @@ -171,8 +179,14 @@ impl ConstitutionalChecker { } // 4. Banned Antithesis Tropes: - let antithesis_not_only_re = ANTITHESIS_NOT_ONLY_RE.get_or_init(|| Regex::new(r"\bnot\s+only\s+[^,;\n]+,\s*but\s+").unwrap()); - let antithesis_not_x_but_y_re = ANTITHESIS_NOT_X_BUT_Y_RE.get_or_init(|| Regex::new(r"\b(?:it(?:'s|\s+is)\s+)?not\s+([a-zA-Z0-9_\-]+),\s*but\s+([a-zA-Z0-9_\-]+)\b").unwrap()); + let antithesis_not_only_re = ANTITHESIS_NOT_ONLY_RE + .get_or_init(|| Regex::new(r"\bnot\s+only\s+[^,;\n]+,\s*but\s+").unwrap()); + let antithesis_not_x_but_y_re = ANTITHESIS_NOT_X_BUT_Y_RE.get_or_init(|| { + Regex::new( + r"\b(?:it(?:'s|\s+is)\s+)?not\s+([a-zA-Z0-9_\-]+),\s*but\s+([a-zA-Z0-9_\-]+)\b", + ) + .unwrap() + }); if antithesis_not_only_re.is_match(&lower) || antithesis_not_x_but_y_re.is_match(&lower) { violations.push(ViolationKind::AntithesisTrope(format!( "Forbidden antithesis trope detected in line: {}", diff --git a/tests/constitutional_rules.rs b/tests/constitutional_rules.rs index 6cbd0b0..923dffc 100644 --- a/tests/constitutional_rules.rs +++ b/tests/constitutional_rules.rs @@ -5,23 +5,34 @@ fn test_em_dash_detected_in_code_comments() { let diff = "diff --git a/src/lib.rs b/src/lib.rs\n+// Important note \u{2014} do not delete this function\npub fn keep() {}"; let report = DiffAuditor::audit_text(diff); assert!(!report.clean); - assert!(report.unslop_violations.iter().any(|u| u.contains("Em/En dash detected"))); + assert!(report + .unslop_violations + .iter() + .any(|u| u.contains("Em/En dash detected"))); } #[test] fn test_em_dash_detected_in_string_literals() { - let diff = "diff --git a/src/lib.rs b/src/lib.rs\n+pub const SLOGAN: &str = \"speed \u{2014} power\";"; + let diff = + "diff --git a/src/lib.rs b/src/lib.rs\n+pub const SLOGAN: &str = \"speed \u{2014} power\";"; let report = DiffAuditor::audit_text(diff); assert!(!report.clean); - assert!(report.unslop_violations.iter().any(|u| u.contains("Em/En dash detected"))); + assert!(report + .unslop_violations + .iter() + .any(|u| u.contains("Em/En dash detected"))); } #[test] fn test_em_dash_detected_in_markdown() { - let diff = "diff --git a/README.md b/README.md\n+- Core Feature \u{2014} high throughput engine"; + let diff = + "diff --git a/README.md b/README.md\n+- Core Feature \u{2014} high throughput engine"; let report = DiffAuditor::audit_text(diff); assert!(!report.clean); - assert!(report.unslop_violations.iter().any(|u| u.contains("Em/En dash detected"))); + assert!(report + .unslop_violations + .iter() + .any(|u| u.contains("Em/En dash detected"))); } #[test] @@ -29,7 +40,10 @@ fn test_en_dash_detected_in_code_comments() { let diff = "diff --git a/src/lib.rs b/src/lib.rs\n+// Range 10\u{2013}20 items"; let report = DiffAuditor::audit_text(diff); assert!(!report.clean); - assert!(report.unslop_violations.iter().any(|u| u.contains("Em/En dash detected"))); + assert!(report + .unslop_violations + .iter() + .any(|u| u.contains("Em/En dash detected"))); } #[test] @@ -37,7 +51,10 @@ fn test_en_dash_detected_in_string_literals() { let diff = "diff --git a/src/lib.rs b/src/lib.rs\n+let header = \"Version 1.0\u{2013}beta\";"; let report = DiffAuditor::audit_text(diff); assert!(!report.clean); - assert!(report.unslop_violations.iter().any(|u| u.contains("Em/En dash detected"))); + assert!(report + .unslop_violations + .iter() + .any(|u| u.contains("Em/En dash detected"))); } #[test] @@ -45,7 +62,10 @@ fn test_en_dash_detected_in_markdown() { let diff = "diff --git a/DOCS.md b/DOCS.md\n+Pages 5\u{2013}10 contain benchmarks."; let report = DiffAuditor::audit_text(diff); assert!(!report.clean); - assert!(report.unslop_violations.iter().any(|u| u.contains("Em/En dash detected"))); + assert!(report + .unslop_violations + .iter() + .any(|u| u.contains("Em/En dash detected"))); } #[test] @@ -61,23 +81,34 @@ fn test_banned_buzzword_tapestry() { let diff = "diff --git a/src/main.rs b/src/main.rs\n+// A rich tapestry of microservices"; let report = DiffAuditor::audit_text(diff); assert!(!report.clean); - assert!(report.unslop_violations.iter().any(|u| u.contains("tapestry"))); + assert!(report + .unslop_violations + .iter() + .any(|u| u.contains("tapestry"))); } #[test] fn test_banned_buzzword_testament() { - let diff = "diff --git a/src/main.rs b/src/main.rs\n+// This code is a testament to our engineering"; + let diff = + "diff --git a/src/main.rs b/src/main.rs\n+// This code is a testament to our engineering"; let report = DiffAuditor::audit_text(diff); assert!(!report.clean); - assert!(report.unslop_violations.iter().any(|u| u.contains("testament"))); + assert!(report + .unslop_violations + .iter() + .any(|u| u.contains("testament"))); } #[test] fn test_banned_buzzword_beacon_trope() { - let diff = "diff --git a/src/main.rs b/src/main.rs\n+// Standing as a beacon of hope for open source"; + let diff = + "diff --git a/src/main.rs b/src/main.rs\n+// Standing as a beacon of hope for open source"; let report = DiffAuditor::audit_text(diff); assert!(!report.clean); - assert!(report.unslop_violations.iter().any(|u| u.contains("beacon"))); + assert!(report + .unslop_violations + .iter() + .any(|u| u.contains("beacon"))); } #[test] @@ -89,26 +120,38 @@ fn test_beacon_hardware_term_allowed() { #[test] fn test_banned_buzzword_crucial() { - let diff = "diff --git a/src/main.rs b/src/main.rs\n+// It is crucial to preserve cache coherence"; + let diff = + "diff --git a/src/main.rs b/src/main.rs\n+// It is crucial to preserve cache coherence"; let report = DiffAuditor::audit_text(diff); assert!(!report.clean); - assert!(report.unslop_violations.iter().any(|u| u.contains("crucial"))); + assert!(report + .unslop_violations + .iter() + .any(|u| u.contains("crucial"))); } #[test] fn test_banned_buzzword_pivotal() { - let diff = "diff --git a/src/main.rs b/src/main.rs\n+// A pivotal refactor for the memory engine"; + let diff = + "diff --git a/src/main.rs b/src/main.rs\n+// A pivotal refactor for the memory engine"; let report = DiffAuditor::audit_text(diff); assert!(!report.clean); - assert!(report.unslop_violations.iter().any(|u| u.contains("pivotal"))); + assert!(report + .unslop_violations + .iter() + .any(|u| u.contains("pivotal"))); } #[test] fn test_banned_buzzword_elevate() { - let diff = "diff --git a/src/main.rs b/src/main.rs\n+// Designed to elevate the computing experience"; + let diff = + "diff --git a/src/main.rs b/src/main.rs\n+// Designed to elevate the computing experience"; let report = DiffAuditor::audit_text(diff); assert!(!report.clean); - assert!(report.unslop_violations.iter().any(|u| u.contains("elevate"))); + assert!(report + .unslop_violations + .iter() + .any(|u| u.contains("elevate"))); } #[test] @@ -123,7 +166,10 @@ fn test_banned_buzzword_game_changer() { let diff = "diff --git a/src/main.rs b/src/main.rs\n+// The new allocator is a game-changer"; let report = DiffAuditor::audit_text(diff); assert!(!report.clean); - assert!(report.unslop_violations.iter().any(|u| u.contains("game-changer"))); + assert!(report + .unslop_violations + .iter() + .any(|u| u.contains("game-changer"))); } #[test] @@ -131,7 +177,10 @@ fn test_banned_buzzword_unleash() { let diff = "diff --git a/src/main.rs b/src/main.rs\n+// Unleash the power of local silicon"; let report = DiffAuditor::audit_text(diff); assert!(!report.clean); - assert!(report.unslop_violations.iter().any(|u| u.contains("unleash"))); + assert!(report + .unslop_violations + .iter() + .any(|u| u.contains("unleash"))); } #[test] @@ -146,7 +195,10 @@ fn test_banned_buzzword_harness_verb() { let diff = "diff --git a/src/main.rs b/src/main.rs\n+// We can harness the full throughput of GPU nodes"; let report = DiffAuditor::audit_text(diff); assert!(!report.clean); - assert!(report.unslop_violations.iter().any(|u| u.contains("harness"))); + assert!(report + .unslop_violations + .iter() + .any(|u| u.contains("harness"))); } #[test] @@ -157,19 +209,23 @@ fn test_harness_noun_and_test_harness_allowed() { } #[test] -fn test_banned_buzzword_seamlessly() { - let diff = "diff --git a/src/main.rs b/src/main.rs\n+// Coordinates seamlessly across all instances"; +fn test_allowed_word_seamlessly() { + let diff = + "diff --git a/src/main.rs b/src/main.rs\n+// Coordinates seamlessly across all instances"; let report = DiffAuditor::audit_text(diff); - assert!(!report.clean); - assert!(report.unslop_violations.iter().any(|u| u.contains("seamlessly"))); + assert!(report.clean); } #[test] fn test_antithesis_trope_not_x_but_y() { - let diff = "diff --git a/src/main.rs b/src/main.rs\n+// It is not speed, but correctness that matters"; + let diff = + "diff --git a/src/main.rs b/src/main.rs\n+// It is not speed, but correctness that matters"; let report = DiffAuditor::audit_text(diff); assert!(!report.clean); - assert!(report.unslop_violations.iter().any(|u| u.contains("antithesis trope"))); + assert!(report + .unslop_violations + .iter() + .any(|u| u.contains("antithesis trope"))); } #[test] @@ -177,7 +233,10 @@ fn test_antithesis_trope_not_only_x_but_y() { let diff = "diff --git a/src/main.rs b/src/main.rs\n+// Not only fast, but completely reliable across all tests"; let report = DiffAuditor::audit_text(diff); assert!(!report.clean); - assert!(report.unslop_violations.iter().any(|u| u.contains("antithesis trope"))); + assert!(report + .unslop_violations + .iter() + .any(|u| u.contains("antithesis trope"))); } #[test] @@ -185,7 +244,10 @@ fn test_plaintext_secret_aws_access_key() { let diff = "diff --git a/src/vault.rs b/src/vault.rs\n+let aws_key = \"AKIA1234567890ABCDEF\";"; let report = DiffAuditor::audit_text(diff); assert!(!report.clean); - assert!(report.secret_violations.iter().any(|s| s.contains("AWS Access Key"))); + assert!(report + .secret_violations + .iter() + .any(|s| s.contains("AWS Access Key"))); } #[test] @@ -193,7 +255,10 @@ fn test_plaintext_secret_github_pat() { let diff = "diff --git a/src/auth.rs b/src/auth.rs\n+let token = \"ghp_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\";"; let report = DiffAuditor::audit_text(diff); assert!(!report.clean); - assert!(report.secret_violations.iter().any(|s| s.contains("GitHub Personal Access Token"))); + assert!(report + .secret_violations + .iter() + .any(|s| s.contains("GitHub Personal Access Token"))); } #[test] @@ -201,7 +266,10 @@ fn test_plaintext_secret_github_fine_grained_pat() { let diff = "diff --git a/src/auth.rs b/src/auth.rs\n+let token = \"github_pat_11AAAAAAA01234567890abcdefghijklmnopqrstuvwxyz_01234567890abcdef\";"; let report = DiffAuditor::audit_text(diff); assert!(!report.clean); - assert!(report.secret_violations.iter().any(|s| s.contains("GitHub Personal Access Token"))); + assert!(report + .secret_violations + .iter() + .any(|s| s.contains("GitHub Personal Access Token"))); } #[test] @@ -209,7 +277,10 @@ fn test_plaintext_secret_rsa_private_key() { let diff = "diff --git a/src/crypto.rs b/src/crypto.rs\n+const KEY: &str = \"-----BEGIN RSA PRIVATE KEY-----\\nMIIEowIBAAKCAQEA...\";"; let report = DiffAuditor::audit_text(diff); assert!(!report.clean); - assert!(report.secret_violations.iter().any(|s| s.contains("Private Key header"))); + assert!(report + .secret_violations + .iter() + .any(|s| s.contains("Private Key header"))); } #[test] @@ -217,7 +288,10 @@ fn test_plaintext_secret_generic_private_key() { let diff = "diff --git a/src/crypto.rs b/src/crypto.rs\n+const KEY: &str = \"-----BEGIN PRIVATE KEY-----\\nMIIEowIBAAKCAQEA...\";"; let report = DiffAuditor::audit_text(diff); assert!(!report.clean); - assert!(report.secret_violations.iter().any(|s| s.contains("Private Key header"))); + assert!(report + .secret_violations + .iter() + .any(|s| s.contains("Private Key header"))); } #[test]