Documentation/ Decision records
ADR 0019: Extensions are compiled into the build; nothing is uploaded into a running image
Status: Accepted
Context
Implementers need to change Karyo's behaviour for a client - a stock-selection filter, a putaway strategy, a carrier adapter - without forking the source.
Karyo is a Quarkus application packaged as a fast-jar image. Quarkus discovers CDI beans during build-time augmentation, so the set of beans an image contains is fixed when it is built: a JAR placed beside a running process is invisible to it.
Extension code runs inside the application process with the same trust as Karyo's own code. Nothing sandboxes it.
Decision
- An extension is a module compiled against the Apache-2.0
-apimodules and the CDI API only, never against a-core. It carriesMETA-INF/beans.xml, is added to the application build before Quarkus augmentation, and the image is rebuilt. - There is no runtime plugin mechanism: no upload endpoint, no hot discovery, no directory scanned at start-up.
- The worked example is
karyo-inventory-ext-example. Its build compiles againstkaryo-inventory-apiand the CDI API withcompileOnly.HeldLotStockFilteris active:@Alternative @Priority(1000)switches the CDI alternative on, andpriority() = 500places it in the filter chain - two numbers doing two different jobs.HazmatStockFilteris deliberately inactive: an@Alternativewith no@Priority. The module is always compiled and tested, and it is included in the application only when the build is run with-PkaryoInventoryExample=true. - The running application reports its seams, and says which are for implementation.
GET /api/v1/admin/extensions(ADMIN) lists every interface declared in a*.spipackage and the beans that implement each; a seam whose module is not on the classpath is dropped from the response. Each row carries akind:STRATEGY_SEAM(an extension may implement it),LOOKUP(a read-only in-process contract) orPORT(an in-process command or orchestration contract). A lookup or a port is implemented by Karyo's own modules and is not for implementation. - The registry is the only list. The console reads it for the Extensions page, the navigation badge and the sidebar footer, and keeps no catalogue of its own. When the registry cannot answer, the page shows the standard error state and the shell shows no count.
- Compatibility is not unconditional. Additive, defaulted members aim to keep extensions working,
but an extension must be recompiled and tested against each release. No
-apiartefact is published to a Maven repository; an extension builds against this repository's module graph. - The engine modules plug into their seams the same way, as build-time modules (ADR 0029).
Consequences
- An installation runs exactly the code that was built and tested into its image, and the image is the unit of deployment and rollback.
- Anyone can build their own extended image, with no involvement from the vendor.
- Changing an extension is a rebuild and a redeploy.
- Extension code must preserve Karyo's invariants itself - stock arithmetic, owner isolation, the transaction it runs in. A bean is trusted in-process code.
- A row's kind is set by hand in the registry list, from the interface's own KDoc and from how its
consumer finds it.
AdminExtensionsResourceSeamListTestfails when a row has no kind, and when a*Lookup, a*Portor a*Strategycarries the wrong one. Presence in the list is still not a promise that a second implementation of aSTRATEGY_SEAMwill be called by every consumer. - An administrator who cannot read the registry sees no seam count, not a bundled one.
Alternatives considered
- Drop-in JARs loaded by the running application. Rejected. Quarkus resolves CDI beans at build-time augmentation, so a JAR added after the build is never discovered; supporting it would mean giving up the build-time model the application is packaged on.
- Forking the source per client. Not a supported route. The supported routes are configuration (ADR 0018), integration through the API and webhooks, and a build-time extension of a published contract. Why forks are excluded is not recorded beyond that preference.
- Publishing the
-apimodules to a Maven repository so an extension can build outside this repository. Not done: it would add a distribution channel and a versioning surface to own.
Evidence
settings.gradle.kts,include(":services:inventory-service:karyo-inventory-ext-example")- the example module is always part of the buildservices/karyo-app/build.gradle.kts,providers.gradleProperty("karyoInventoryExample")- included in the application only on request, "never a runtime JAR upload"services/inventory-service/karyo-inventory-ext-example/build.gradle.kts,dependencies.compileOnly- compiled against the API module and CDI onlyservices/inventory-service/karyo-inventory-ext-example/src/main/resources/META-INF/beans.xml- bean discovery for the extension moduleservices/inventory-service/karyo-inventory-ext-example/src/main/kotlin/com/karyo/inventory/ext/example/HeldLotStockFilter.kt,HeldLotStockFilter- activation priority and chain priorityservices/inventory-service/karyo-inventory-ext-example/src/main/kotlin/com/karyo/inventory/ext/example/HazmatStockFilter.kt,HazmatStockFilter- an alternative that is never activatedservices/karyo-app/src/main/kotlin/com/karyo/app/admin/AdminExtensionsResource.kt,AdminExtensionsResource.listExtensions,AdminExtensionsResource.resolve,ExtensionKind- the live registry, the rule that makes it complete and the kind of every rowservices/inventory-service/karyo-inventory-api/src/main/kotlin/com/karyo/inventory/api/spi/StockSelectionFilter.kt,StockSelectionFilterandservices/warehouse-layout-service/karyo-layout-api/src/main/kotlin/com/karyo/layout/spi/LocationFilter.kt,LocationFilter- the discovery descriptions, which say a bean is compiled into the buildfrontend/web/src/pages/admin/admin-strategies-page.tsx,AdminStrategiesPage,frontend/web/src/config/admin-navigation.ts,adminNavItems, visibleAdminNavItemsandfrontend/web/src/components/layout/admin-shell.tsx,AdminShell- the only readers of the registry; none keeps a list of seams
Related
- ADR 0006 - why an extension compiles against
-apionly - ADR 0018 - how each seam selects among implementations
- ADR 0029 - the engine modules as build-time modules
- Extension SPIs and installation - the seams and the installation route in full
- Implementer guide - building and verifying an extended image