tramai-spring-core
Version: 0.6.0
Status: Preview
Role: Shared Spring integration base for every TramAI Spring adapter.
Purpose
tramai-spring-core is the profile-neutral half of TramAI's Spring support. It turns annotated interfaces into Spring beans and binds tramai.* configuration — without knowing anything about provider SDKs or the sovereign runtime.
It is not normally a direct dependency: tramai-spring-boot-starter brings it in and selects which runtime integration (standard or sovereign) is active.
What it provides
Auto-configuration (registered in META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports)
| Configuration | When it applies |
|---|---|
TramaiSecretResolutionAutoConfiguration | Assembles the bootstrap and full secret-resolution chains |
StandardTramaiProfileAutoConfiguration | Imports TramaiAutoConfiguration when tramai.profile is standard or missing |
AiServiceProxyAutoConfiguration | Registers @AiService interfaces found by classpath scanning |
SecurityClassificationAutoConfiguration | Binds classification rules from tramai.security.* |
TramaiRuntimeProfileEnvironmentPostProcessor (spring.factories) validates tramai.profile early: only standard and sovereign are accepted, and the standard runtime stays the default.
Bean model
@AiServiceinterfaces become injectable proxies throughAiServiceBeanDefinitionRegistrar/AiServiceFactoryBean.@AiToolmethods on existing Spring beans are discovered byAiToolScannerand registered on the runtime.EnableTramaiis an optional annotation for annotation-driven (non-Boot) Spring contexts. It does not select a runtime profile —tramai.profileremains the sole selector.SpringSecretChain/SpringBootstrapSecretChainhold the assembledSecretValueResolverchains: user resolvers first, then built-in module resolvers, thenenv:, then bootstrap resolvers.
Properties — TramaiProperties binds tramai.default-provider, tramai.models, tramai.fallbacks, tramai.resilience.circuit-breaker.*, tramai.resilience.retry.*, tramai.cost.token-budget.*, tramai.cache.in-memory.*, tramai.security.classification.* and tramai.security.model-registry.enabled.
Dependencies
dependencies {
implementation(platform("dev.tramai:tramai-bom:0.6.0"))
implementation("dev.tramai:tramai-spring-core")
implementation("dev.tramai:tramai-spring-provider-openai") // provider adapter
}
tramai:
default-provider: openai
models:
gpt-4o: openai
providers:
openai:
api-key: ${OPENAI_API_KEY}
@AiService
interface InvoiceAnalyzer {
@Operation(prompt = "Analyze this invoice and return a one-line status.", model = "gpt-4o")
suspend fun analyze(invoiceText: String): String
}
When to use this module
- You are writing a provider adapter, a secrets module or a runtime integration and want the shared Spring plumbing.
- You want
@AiServiceproxies andtramai.*property binding without pulling in a runtime profile.
When NOT to use this module
- You are writing an application: depend on tramai-spring-boot-starter instead.
- You need provider adapters or the sovereign runtime: those live in their own modules and must be added explicitly.
- You are not using Spring — see tramai-standalone.
