Class CortexAutoConfiguration

java.lang.Object
ai.chatur.cortex.spring.CortexAutoConfiguration

@AutoConfiguration @EnableConfigurationProperties(CortexProperties.class) public class CortexAutoConfiguration extends Object
Core auto-configuration for Cortex: the ontology, SHACL shapes, rule reasoner, the two Jena Datasets, the eleven core services composed into Cortex, the UsageService that weights search ranking, and the composed Cortex bean.

Every bean here is @ConditionalOnMissingBean, so a consumer may substitute their own OntModel, Shapes, Dataset, GenericRuleReasoner, or Cortex simply by declaring a bean of that type — auto-configured beans that depend on it then wire against the supplied instance instead of building their own.

The two Dataset beans are matched by bean name, not by type (see assertions(CortexProperties, OntModel) and inferences()): a bare @ConditionalOnMissingBean matches on return type and is evaluated in bean-definition order, so inferences would silently back off because assertions already registered a Dataset — the graph would boot with inferences == assertions, and every search would return nothing without ever throwing. Naming the conditions keeps the two independent.

Neither Dataset bean is @Primary, so a downstream consumer injecting a bare Dataset (rather than @Qualifier("assertions") or @Qualifier("inferences")) gets a NoUniqueBeanDefinitionException. That is intentional: it forces the caller to say which dataset they mean rather than silently getting one of the two.

CortexWebAutoConfiguration and CortexMcpAutoConfiguration both run after this configuration, so the core beans declared here are always available to the controllers and MCP tools they register.

  • Constructor Details

    • CortexAutoConfiguration

      public CortexAutoConfiguration()
      Creates the auto-configuration. Spring instantiates this; consumers do not.