@@ -12,8 +12,8 @@ use serde::{Deserialize, Deserializer};
1212use serde_json:: { Map , Value } ;
1313
1414use crate :: config:: {
15- BackupConfig , Config , InspectConfig , SemanticBackend , SemanticBackendConfig , UserServerDef ,
16- MAX_SEMANTIC_QUERY_TIMEOUT_MS , MIN_SEMANTIC_QUERY_TIMEOUT_MS ,
15+ BackupConfig , CheckConfig , Config , InspectConfig , SemanticBackend , SemanticBackendConfig ,
16+ UserServerDef , MAX_SEMANTIC_QUERY_TIMEOUT_MS , MIN_SEMANTIC_QUERY_TIMEOUT_MS ,
1717} ;
1818use crate :: jsonc:: strip_jsonc;
1919
@@ -91,6 +91,7 @@ pub struct RawAftConfig {
9191 #[ serde( deserialize_with = "deserialize_opt_usize" ) ]
9292 pub callgraph_chunk_size : Option < usize > ,
9393 pub inspect : Option < RawInspect > ,
94+ pub check : Option < RawCheck > ,
9495 pub backup : Option < RawBackup > ,
9596 pub bash : Option < RawBash > ,
9697 pub experimental : Option < RawExperimental > ,
@@ -368,6 +369,18 @@ impl RawInspect {
368369 }
369370}
370371
372+ #[ derive( Debug , Clone , Default , Deserialize , PartialEq ) ]
373+ #[ serde( default ) ]
374+ pub struct RawCheck {
375+ pub enabled : Option < bool > ,
376+ }
377+
378+ impl RawCheck {
379+ fn is_empty ( & self ) -> bool {
380+ self . enabled . is_none ( )
381+ }
382+ }
383+
371384/// Only `expected_mirrors` survives here: `lower_bound`, `discard_cost`, and
372385/// `anonymize` were accepted-but-never-read knobs (the scanner hardcodes its
373386/// cost bounds and anonymization rules), so they were removed from the schema
@@ -573,6 +586,9 @@ fn merge_trusted_config(base: &mut RawAftConfig, override_config: RawAftConfig)
573586 if override_config. inspect . is_some ( ) {
574587 base. inspect = override_config. inspect ;
575588 }
589+ if override_config. check . is_some ( ) {
590+ base. check = override_config. check ;
591+ }
576592 if override_config. backup . is_some ( ) {
577593 base. backup = override_config. backup ;
578594 }
@@ -640,6 +656,7 @@ fn merge_project_config(base: &mut RawAftConfig, project: RawAftConfig) {
640656 base. experimental = merge_experimental_config ( base. experimental . clone ( ) , project. experimental ) ;
641657 base. bash = merge_bash_config ( base. bash . clone ( ) , project. bash ) ;
642658 base. inspect = merge_inspect_config ( base. inspect . clone ( ) , project. inspect ) ;
659+ base. check = merge_check_config ( base. check . clone ( ) , project. check ) ;
643660}
644661
645662fn merge_formatter_map (
@@ -855,6 +872,18 @@ fn merge_inspect_config(
855872 ( !inspect. is_empty ( ) ) . then_some ( inspect)
856873}
857874
875+ fn merge_check_config (
876+ base : Option < RawCheck > ,
877+ override_check : Option < RawCheck > ,
878+ ) -> Option < RawCheck > {
879+ let Some ( override_check) = override_check else {
880+ return base;
881+ } ;
882+ let mut check = base. unwrap_or_default ( ) ;
883+ check. enabled = override_check. enabled . or ( check. enabled ) ;
884+ ( !check. is_empty ( ) ) . then_some ( check)
885+ }
886+
858887fn merge_inspect_duplicates (
859888 base : Option < RawInspectDuplicates > ,
860889 override_duplicates : Option < RawInspectDuplicates > ,
@@ -998,6 +1027,7 @@ fn apply_resolved_config(raw: &RawAftConfig, config: &mut Config) {
9981027 }
9991028 config. semantic = resolve_semantic_config ( raw. semantic . as_ref ( ) ) ;
10001029 config. inspect = resolve_inspect_config ( raw. inspect . as_ref ( ) ) ;
1030+ config. check = resolve_check_config ( raw. check . as_ref ( ) ) ;
10011031 config. backup = resolve_backup_config ( raw. backup . as_ref ( ) ) ;
10021032 resolve_lsp_config ( raw, config) ;
10031033 resolve_bash_fields ( raw, config) ;
@@ -1056,6 +1086,16 @@ fn resolve_inspect_config(raw: Option<&RawInspect>) -> InspectConfig {
10561086 inspect
10571087}
10581088
1089+ fn resolve_check_config ( raw : Option < & RawCheck > ) -> CheckConfig {
1090+ let mut check = CheckConfig :: default ( ) ;
1091+ if let Some ( raw) = raw {
1092+ if let Some ( enabled) = raw. enabled {
1093+ check. enabled = enabled;
1094+ }
1095+ }
1096+ check
1097+ }
1098+
10591099fn resolve_backup_config ( raw : Option < & RawBackup > ) -> BackupConfig {
10601100 let mut backup = BackupConfig :: default ( ) ;
10611101 if let Some ( raw) = raw {
@@ -2033,4 +2073,28 @@ mod tests {
20332073 Some ( "rustfmt" )
20342074 ) ;
20352075 }
2076+
2077+ #[ test]
2078+ fn check_config_defaults_to_disabled ( ) {
2079+ let result = resolve_config ( & [ tier ( "user" , r#"{ "tool_surface": "all" }"# ) ] ) ;
2080+ assert ! ( !result. config. check. enabled) ;
2081+ }
2082+
2083+ #[ test]
2084+ fn check_config_enabled_via_user_tier ( ) {
2085+ let result = resolve_config ( & [ tier (
2086+ "user" ,
2087+ r#"{ "check": { "enabled": true } }"# ,
2088+ ) ] ) ;
2089+ assert ! ( result. config. check. enabled) ;
2090+ }
2091+
2092+ #[ test]
2093+ fn check_config_project_tier_overrides_user ( ) {
2094+ let result = resolve_config ( & [
2095+ tier ( "user" , r#"{ "check": { "enabled": true } }"# ) ,
2096+ tier ( "project" , r#"{ "check": { "enabled": false } }"# ) ,
2097+ ] ) ;
2098+ assert ! ( !result. config. check. enabled) ;
2099+ }
20362100}
0 commit comments