Redouble AI Nucleo documentation
Part 13 · Inside the runtime

Inside the Quarkus extension

ai.redouble.nucleo.quarkus · nucleo-quarkus

This page is for people working on the runtime itself. How to run Nucleo in a Quarkus application is in Quarkus.

What is here

TypeRole
QuarkusSecretsThe runtime's credential store: nucleo.credentials.<id> answers the secret, .user and .host the other parts, read through ConfigProvider on every lookup. The runtime builds it by reflection through a no-argument constructor, so it holds no container reference.
QuarkusEnvironmentThe NucleoConfigurator the extension registers under META-INF/services: it assigns QuarkusSecrets as the store and leaves every other default alone.
QuarkusSettingsBinderMaps nucleo.* config properties onto the registered Settings classes: nucleo.http.pool-size binds HttpSettings.poolSize - the class minus Settings and the field, both kebab-cased - at startup, before the dispatcher runs.
NucleoRuntimeThe application-scoped bean that binds the properties and starts the dispatcher on StartupEvent, subscribes the event log and the CostLedger, registers the ledger as the spend gate, and drains the dispatcher on shutdown. The lifecycle is process-scoped: a StartupEvent that finds the dispatcher already running does nothing, and shutdown runs only in a normal launch, never on a dev-mode reload or a test restart. The ledger is static, so every restart's bean exposes the instance that is subscribed.
NucleoDatabaseRegisters the core CountingDBResourceProvider from nucleo.database.* when max-concurrent is set, observing StartupEvent after NucleoRuntime binds the properties, and unregisters it on shutdown.
NativeSubstitutions (in ai.redouble.nucleo.quarkus.graal)GraalVM substitutions for the native image: dependencies that reach for a class the closed world does not carry (brotli in Apache HttpClient's content-compression, JBoss VFS in the reflections scan) are rebuilt without it, so no third-party native metadata is hand-rolled.

Why the lifecycle is process-scoped

A dev-mode live reload and a test-mode profile switch both stop and restart the application in the same JVM. The dispatcher singleton, and the cost ledger held by NucleoRuntime, live in the classloader that persists across those restarts, and the dispatcher does not restart once shut down (its message bus does not reopen). So the dispatcher starts once and its subscribers are registered once, and shutdown is skipped on a reload or a test restart.

The deployment module

nucleo-quarkus-deployment carries the extension's build steps (NucleoQuarkusProcessor), which run inside the Quarkus build of an application and never at application runtime:

The native substitutions

NativeSubstitutions handles the two dependencies whose own code is native-hostile. Apache HttpClient's ContentCompressionExec names a Brotli decoder in its constructor, so the substitution re-declares that constructor to build the gzip and deflate registry the runtime always gets, without the Brotli entry it never gets. org.reflections' JbossDir, a handler for JBoss VFS URLs that matches no URL outside an application server, is deleted from the image. No jars are added and no reflection or resource metadata is written for either.

^