ADR 0021: Entitlement is an Ed25519-signed token, resolved once at startup
Status: Superseded by ADR 0029. Kept as history: it
records how 1.x decided which present engines may run. At the Karyo 2.0.0 release every engine is
present in the one distribution, and ADR 0030
retires the gate this record describes: no licence withholds anything, and the settings and
GET /api/v1/license remain only as a compatibility bridge.
Context
A commercial engine can be present in an image and still not be paid for (ADR 0020). Something inside the running application has to decide which of the engines present may run. It has to work on a host the customer controls, with no service to call, it must not be defeated by editing configuration, and the product must never need the vendor's signing secret to make the decision.
Decision
- A licence is a signed token: a base64url JSON payload, a dot, and a base64url Ed25519
signature computed over the payload substring itself. The payload carries
licenseId,customer,entitlements,issuedAtand a nullableexpiresAt. Unknown payload fields are ignored on purpose, so a vendor can mint claims that other tooling reads without changing any entitlement decision made here. - Verification needs only a public key. It uses the JDK's own
Ed25519providers, so the product carries no extra cryptographic dependency. The public key has one home, a resource file inlibs/karyo-licensethat holds the key and nothing else, so every reader is a strip and no two readers have to agree on a format;karyo.license.public-keycan override it. The private key and the minting tool are not in this repository. LicenseServiceresolves the entitlement set once, when the application-scoped bean is constructed:karyo.license.keyset and verifying (good signature, not expired): the token's entitlements.karyo.license.keyset and not verifying: the empty set. A present but invalid licence never falls back to anything weaker.- No signed key: the unsigned
karyo.license.entitlementslist (KARYO_LICENSE), which the class documents as a development fallback.
- Entitlements are global to the instance.
isEntitled(moduleKey)takes no goods owner. Under silo tenancy one instance serves one operating company and the licence belongs to that company (ADR 0014). - Each commercial engine checks its own entitlement at its entry points.
require(key)throwsLicenseRequiredException, answered as HTTP 403 with a problem type of its own (.../license-required), where the engine adds a capability with no free equivalent;isEntitled(key)with an early return where the engine replaces a free behaviour, so the free behaviour runs instead. - The edition is a property of the image, not of the licence. An image with no
LicensedModuleInstallationbean iscommunity; any other iscommercial.GET /api/v1/licensetells an anonymous caller only the edition, and an authenticated one the entitlements it holds that the image actually installs.
Consequences
- No network call, no licence server and no vendor secret in the product. The gate is open source; only the signing key is secret.
- A licence cannot add an engine to an image that does not contain one. In the free build of this repository there is nothing for any entitlement to unlock.
- A missing or empty public-key file fails the boot and names the file, rather than silently locking every engine. Replacing the key is a one-line change to that file, after which every licence signed with the old key stops verifying at the next restart.
- 1.x defect, gone with the gate: a licence that expires while the application runs keeps working until the next restart. The entitlement set is computed in a property initialiser and never recomputed, so expiry takes effect at whatever restart comes next, not at the moment it passes.
- 1.x defect, gone with the gate: nothing defines what happens to work in flight when a restart finds an entitlement gone. A wave released while the instance was entitled is then finishable by no route. Every wave, sort and pack-out operation is refused, cancel included, and the free per-order packing route refuses the wave's orders because they are consolidated in a wave. Goods sit on a cart with live reservations and no supported way forward, and no message explains why. Cross-docking has the same shape in a milder form: its expiry sweep is gated, so rows past their staging deadline are neither disposed of nor cancellable. What a customer is owed for data an engine wrote before its entitlement lapsed has not been decided; the rows stay in the schema and the API that reads them answers 403.
- 1.x defect, gone with the gate: the unsigned list is honoured in every profile. Nothing in the
%prodprofile switches thekaryo.license.entitlementsfallback off, so in an image that contains commercial engines, one environment line enables any of them with no signature, no expiry and no record of who did it. In this repository's free build it unlocks nothing, and the environment template says to keepKARYO_LICENSEempty. - Coverage is held by convention. Every entry point of every commercial engine carries its own check; no annotation, interceptor, test or build rule fails when a new entry point forgets one.
Alternatives considered
- Checking the entitlement on every call, so that expiry takes effect when it passes. Not built. The reason entitlements are resolved once rather than per call is not recorded.
- An entitlement per goods owner. Not built. Under silo tenancy the licence belongs to the company that owns the instance, so the instance-wide scope matches who holds the licence.
- Unsigned configuration as the production mechanism. Rejected: anyone holding the environment file could turn any engine on. The signed token is the mechanism; the unsigned list survives only as the development fallback described above.
Evidence
These citations describe the historical tree at commit 16de0cb5, before the licence gate was
retired. LicenseEdition, LicenseRequiredExceptionMapper and the entitlement checks no longer
exist in the current tree; ADR 0030 owns the compatibility bridge that replaced them.
libs/karyo-license/src/main/kotlin/com/karyo/license/LicenseVerifier.kt,LicenseVerifier- token format, ignored fields, the JDK's Ed25519 providersLicenseVerifier.verify- signature verification and the one-time expiry checklibs/karyo-license/src/main/kotlin/com/karyo/license/LicenseService.kt,LicenseService.resolveEntitlements- the resolution orderLicenseService.keys- resolved in a property initialiser, never againLicenseService.isEntitledandLicenseService.require- take no goods ownerlibs/karyo-license/src/main/kotlin/com/karyo/license/VendorKey.kt,VendorKey- one home for the public key, and a boot failure when it is missinglibs/karyo-license/src/main/kotlin/com/karyo/license/LicenseRequiredExceptionMapper.kt,LicenseRequiredExceptionMapper- the 403 and its problem typelibs/karyo-license/src/main/kotlin/com/karyo/license/LicenseEdition.kt,LicenseEditionandlibs/karyo-license/src/main/kotlin/com/karyo/license/LicenseResource.kt,LicenseResource- edition and disclosureservices/karyo-app/src/main/resources/application.yaml,karyo.license.entitlements- the unsigned fallback and its placeholder defaultscripts/.env.prod.example,KARYO_LICENSE, KARYO_LICENSE_KEY- the template keeps both licence variables emptyservices/fulfillment-service/karyo-fulfillment-core/src/main/kotlin/com/karyo/fulfillment/service/PackingService.kt,PackingServiceand.../fulfillment/service/ConsolidatedOrderGuard.kt,ConsolidatedOrderGuard- the free packing route refusing a wave's orders- Licence and entitlement
- Gating and degradation
- The commercial boundary