@@ -12,7 +12,7 @@ use serde::{Deserialize, Deserializer};
1212use serde_json:: { Map , Value } ;
1313
1414use crate :: config:: {
15- BackupConfig , Config , InspectConfig , SemanticBackend , SemanticBackendConfig , UserServerDef ,
15+ BackupConfig , CheckConfig , Config , InspectConfig , SemanticBackend , SemanticBackendConfig , UserServerDef ,
1616} ;
1717use crate :: jsonc:: strip_jsonc;
1818
@@ -90,6 +90,7 @@ pub struct RawAftConfig {
9090 #[ serde( deserialize_with = "deserialize_opt_usize" ) ]
9191 pub callgraph_chunk_size : Option < usize > ,
9292 pub inspect : Option < RawInspect > ,
93+ pub check : Option < RawCheck > ,
9394 pub backup : Option < RawBackup > ,
9495 pub bash : Option < RawBash > ,
9596 pub experimental : Option < RawExperimental > ,
@@ -364,6 +365,18 @@ impl RawInspect {
364365 }
365366}
366367
368+ #[ derive( Debug , Clone , Default , Deserialize , PartialEq ) ]
369+ #[ serde( default ) ]
370+ pub struct RawCheck {
371+ pub enabled : Option < bool > ,
372+ }
373+
374+ impl RawCheck {
375+ fn is_empty ( & self ) -> bool {
376+ self . enabled . is_none ( )
377+ }
378+ }
379+
367380/// Only `expected_mirrors` survives here: `lower_bound`, `discard_cost`, and
368381/// `anonymize` were accepted-but-never-read knobs (the scanner hardcodes its
369382/// cost bounds and anonymization rules), so they were removed from the schema
@@ -569,6 +582,9 @@ fn merge_trusted_config(base: &mut RawAftConfig, override_config: RawAftConfig)
569582 if override_config. inspect . is_some ( ) {
570583 base. inspect = override_config. inspect ;
571584 }
585+ if override_config. check . is_some ( ) {
586+ base. check = override_config. check ;
587+ }
572588 if override_config. backup . is_some ( ) {
573589 base. backup = override_config. backup ;
574590 }
@@ -636,6 +652,7 @@ fn merge_project_config(base: &mut RawAftConfig, project: RawAftConfig) {
636652 base. experimental = merge_experimental_config ( base. experimental . clone ( ) , project. experimental ) ;
637653 base. bash = merge_bash_config ( base. bash . clone ( ) , project. bash ) ;
638654 base. inspect = merge_inspect_config ( base. inspect . clone ( ) , project. inspect ) ;
655+ base. check = merge_check_config ( base. check . clone ( ) , project. check ) ;
639656}
640657
641658fn merge_formatter_map (
@@ -850,6 +867,18 @@ fn merge_inspect_config(
850867 ( !inspect. is_empty ( ) ) . then_some ( inspect)
851868}
852869
870+ fn merge_check_config (
871+ base : Option < RawCheck > ,
872+ override_check : Option < RawCheck > ,
873+ ) -> Option < RawCheck > {
874+ let Some ( override_check) = override_check else {
875+ return base;
876+ } ;
877+ let mut check = base. unwrap_or_default ( ) ;
878+ check. enabled = override_check. enabled . or ( check. enabled ) ;
879+ ( !check. is_empty ( ) ) . then_some ( check)
880+ }
881+
853882fn merge_inspect_duplicates (
854883 base : Option < RawInspectDuplicates > ,
855884 override_duplicates : Option < RawInspectDuplicates > ,
@@ -990,6 +1019,7 @@ fn apply_resolved_config(raw: &RawAftConfig, config: &mut Config) {
9901019 }
9911020 config. semantic = resolve_semantic_config ( raw. semantic . as_ref ( ) ) ;
9921021 config. inspect = resolve_inspect_config ( raw. inspect . as_ref ( ) ) ;
1022+ config. check = resolve_check_config ( raw. check . as_ref ( ) ) ;
9931023 config. backup = resolve_backup_config ( raw. backup . as_ref ( ) ) ;
9941024 resolve_lsp_config ( raw, config) ;
9951025 resolve_bash_fields ( raw, config) ;
@@ -1044,6 +1074,16 @@ fn resolve_inspect_config(raw: Option<&RawInspect>) -> InspectConfig {
10441074 inspect
10451075}
10461076
1077+ fn resolve_check_config ( raw : Option < & RawCheck > ) -> CheckConfig {
1078+ let mut check = CheckConfig :: default ( ) ;
1079+ if let Some ( raw) = raw {
1080+ if let Some ( enabled) = raw. enabled {
1081+ check. enabled = enabled;
1082+ }
1083+ }
1084+ check
1085+ }
1086+
10471087fn resolve_backup_config ( raw : Option < & RawBackup > ) -> BackupConfig {
10481088 let mut backup = BackupConfig :: default ( ) ;
10491089 if let Some ( raw) = raw {
@@ -1996,4 +2036,28 @@ mod tests {
19962036 Some ( "rustfmt" )
19972037 ) ;
19982038 }
2039+
2040+ #[ test]
2041+ fn check_config_defaults_to_disabled ( ) {
2042+ let result = resolve_config ( & [ tier ( "user" , r#"{ "tool_surface": "all" }"# ) ] ) ;
2043+ assert ! ( !result. config. check. enabled) ;
2044+ }
2045+
2046+ #[ test]
2047+ fn check_config_enabled_via_user_tier ( ) {
2048+ let result = resolve_config ( & [ tier (
2049+ "user" ,
2050+ r#"{ "check": { "enabled": true } }"# ,
2051+ ) ] ) ;
2052+ assert ! ( result. config. check. enabled) ;
2053+ }
2054+
2055+ #[ test]
2056+ fn check_config_project_tier_overrides_user ( ) {
2057+ let result = resolve_config ( & [
2058+ tier ( "user" , r#"{ "check": { "enabled": true } }"# ) ,
2059+ tier ( "project" , r#"{ "check": { "enabled": false } }"# ) ,
2060+ ] ) ;
2061+ assert ! ( !result. config. check. enabled) ;
2062+ }
19992063}
0 commit comments