@@ -883,6 +883,72 @@ public void TestChildWithEntitiesAndAutoentitiesResolvingZeroLogsNamedWarning()
883883 VerifyAutoentityZeroDiscoveredWarning ( loggerMock , expectedFileNameInMessage : "child-db.json" ) ;
884884 }
885885
886+ /// <summary>
887+ /// Child config with only autoentities that resolve to >0 entities is valid.
888+ /// Simulates the production code path where the metadata provider stores resolution
889+ /// counts on the root (merged) config rather than on the child config directly.
890+ /// This is the regression test for the bug where child-config autoentities caused
891+ /// "No entities found" even when they were expanded successfully.
892+ /// Covers child truth-table row C5 (DS=1, E=0, AE=1, resolved>0, counts on root).
893+ /// </summary>
894+ [ TestMethod ]
895+ public void TestChildWithDataSourceAndAutoentitiesResolvingEntitiesIsValid ( )
896+ {
897+ // Child has no explicit entities; only autoentities.
898+ RuntimeConfig childConfig = BuildTestConfig (
899+ hasDataSource : true ,
900+ entities : new ( ) ,
901+ autoentities : new ( ) { { "ae1" , BuildSimpleAutoentity ( ) } } ) ;
902+ childConfig . IsChildConfig = true ;
903+
904+ RuntimeConfig rootConfig = BuildTestConfig (
905+ hasDataSource : false , entities : new ( ) ,
906+ dataSourceFiles : new DataSourceFiles ( new [ ] { "child-db.json" } ) ) ;
907+ rootConfig . ChildConfigs . Add ( ( "child-db.json" , childConfig ) ) ;
908+
909+ // Simulate production: metadata provider stores counts in the root config,
910+ // NOT directly on the child config.
911+ rootConfig . AutoentityResolutionCounts [ "ae1" ] = 3 ;
912+
913+ RuntimeConfigValidator validator = BuildValidator ( rootConfig ) ;
914+ validator . ValidateDataSourceAndEntityPresence ( rootConfig ) ;
915+
916+ Assert . AreEqual ( 0 , validator . ConfigValidationExceptions . Count ,
917+ "Child config with autoentities that resolved entities should pass validation." ) ;
918+ }
919+
920+ /// <summary>
921+ /// Both root and child configs have autoentities that resolve to >0 entities.
922+ /// Resolution counts for both are stored only on the root config (as the metadata
923+ /// provider does at runtime). Validation must pass for both configs.
924+ /// </summary>
925+ [ TestMethod ]
926+ public void TestRootAndChildBothWithAutoentitiesResolvingEntitiesIsValid ( )
927+ {
928+ RuntimeConfig childConfig = BuildTestConfig (
929+ hasDataSource : true ,
930+ entities : new ( ) ,
931+ autoentities : new ( ) { { "child-ae" , BuildSimpleAutoentity ( ) } } ) ;
932+ childConfig . IsChildConfig = true ;
933+
934+ RuntimeConfig rootConfig = BuildTestConfig (
935+ hasDataSource : true ,
936+ entities : new ( ) ,
937+ dataSourceFiles : new DataSourceFiles ( new [ ] { "child-db.json" } ) ,
938+ autoentities : new ( ) { { "root-ae" , BuildSimpleAutoentity ( ) } } ) ;
939+ rootConfig . ChildConfigs . Add ( ( "child-db.json" , childConfig ) ) ;
940+
941+ // Simulate production: metadata provider stores ALL counts in the root config.
942+ rootConfig . AutoentityResolutionCounts [ "root-ae" ] = 2 ;
943+ rootConfig . AutoentityResolutionCounts [ "child-ae" ] = 4 ;
944+
945+ RuntimeConfigValidator validator = BuildValidator ( rootConfig ) ;
946+ validator . ValidateDataSourceAndEntityPresence ( rootConfig ) ;
947+
948+ Assert . AreEqual ( 0 , validator . ConfigValidationExceptions . Count ,
949+ "Root and child configs both with autoentities that resolved entities should pass validation." ) ;
950+ }
951+
886952 /// <summary>
887953 /// Helper: verifies that the autoentity-discovered-zero warning was logged at least once,
888954 /// optionally also checking that the formatted message contains a child config file name.
0 commit comments