Solution ids of a project

Every route id starts with the id of the solution it belongs to: KLK003A1_AiApi is a leg of KLK003. The id is allocated in the tenant's solution registry, <tenant>/integration-solutions: the merge request that adds the folder solutions/<ID>_<slug>/ is the allocation, and a number is never used twice, not even after its solution is removed. klokSolutionCheck checks a project's route ids against that registry, so that a route cannot claim a number nobody allocated and the next allocation does not collide with code that already exists.

./gradlew klokSolutionCheck
./gradlew klokSolutionCheck --report
./gradlew klokSolutionCheck --tenant acme

What it checks

The route ids. The task finds the routes the way klokTopics does: every concrete class in the main source set that extends a framework pattern (dev.klok.framework.patterns or a package below it), directly or through base classes of the project. The class name is the route id, and its prefix is the solution:

Route id Convention Solution
KLK003A1_AiApi <TENANTSHORT><NNN><LEG><seq>_<Description> KLK003
I10A1_UsersOnrampSftp the 1.x convention, I<n><LEGCODE><seq>_<Description> <TENANTSHORT> and <n> padded to three digits: KLK010 for tenant short code KLK

A 1.x name is read exactly as klok-quarkus-extension reads it at run time (KlokRouteIdentity, whose LEGACY pattern the plugin's RouteId copies), so the check sees the solution the running route reports. A route class that follows neither convention names no solution; the task lists it as a warning. A class that extends Camel's RouteBuilder directly is no Klok route and is not checked, whatever its name.

The project's solution id. solutionId in klok-system-project.json (the project directory, else the root project directory), when it is set.

What passes. A solution that is registered with status reserved or active; a descriptor without status is active. A project may carry routes of several solutions (klok-api-ai has KLK003 and KLK008), and klok-system-project.json may name any one of them. Numbers 900 to 999 belong to the framework (KLK900… are test fixtures, KLK999T1_KlokHeartbeat runs in every service) and are never checked.

Code Means What to do
SOLUTION_UNREGISTERED a route's prefix is not a solution in the registry allocate an id with klok solutions new "<name>" or in klok.dev and rename the routes to it, or add solutions/<ID>_<slug>/ to <tenant>/integration-solutions by hand in a merge request; a number the registry has used before is never taken again
SOLUTION_RETIRED a route's prefix, or the project's solutionId, is a solution with status retired remove the routes or move them to a solution that is reserved or active; a retired solution stays retired
SOLUTION_ID_MISMATCH solutionId in klok-system-project.json is set but is not a solution in the registry set it to the registered solution the project belongs to, or register that solution first
REGISTRY_UNREADABLE the registry could not be read (no tenant, 401, 403, 404, 429 after two retries, no network, an answer that is not the archive), so nothing was checked the message names the cause; see Reading the registry

Reading the registry

The task reads the registry's solutions/ folder on main as one zip archive:

GET <gitlab>/api/v4/projects/<tenant>%2Fintegration-solutions/repository/archive.zip?sha=main&path=solutions

and takes solutionId and status from every solutions/<folder>/solution.meta.json. A folder whose descriptor is missing or is not JSON still holds its id (the folder name's prefix), with a warning. One archive is the only way a pipeline can read the registry: a CI job token may read repository/archive and repository/files/:path/raw of another project, but not repository/tree, so the folders cannot be listed one by one. GitLab limits archive downloads per user and project; a 429 is retried twice after the Retry-After GitLab names (at most 30 seconds each).

Setting Source Default
GitLab -PklokGitlabBaseUrl, else KLOK_GITLAB_BASE_URL, the same base URL as the catalogs https://git.klok.dev
token -PklokGitAuthToken (or klokGitAuthToken in ~/.gradle/gradle.properties) or GITLAB_TOKEN, sent as PRIVATE-TOKEN; else CI_JOB_TOKEN, sent as JOB-TOKEN none
strict CI=true a developer's machine
--report command line off

The job token allowlist. In CI the task reads the registry with the job token of the project's pipeline. GitLab accepts it only when <tenant>/integration-solutions allows job tokens from the project, so the registry's job token allowlist (Settings > CI/CD > Job token permissions) must hold the tenant's root group, <tenant>; adding it needs a Maintainer of the registry. Without it GitLab answers 403 or 404, and the task says so with the allowlist named. A 404 also means that the tenant has no registry yet. A personal token needs the read_api scope and membership of the registry.

The tenant, whose registry is read, is the first of:

  1. --tenant <tenant>;
  2. CI_PROJECT_ROOT_NAMESPACE, the GitLab root group of a CI build;
  3. klok.tenant in src/main/resources/application.properties (a %prod. key first);
  4. the build's tenant (klok { tenant }, KLOK_TENANT, the root group of CI_PROJECT_PATH);
  5. the root group of klokDocs.repoPath.

In CI the repository's root group decides, because the registry the project belongs to is its tenant's. A klok.tenant that names another tenant is printed as a warning: the service runs as the tenant klok.tenant names, so it is wrong, but it does not move the check to another tenant's registry.

The tenant short code, which a 1.x route name needs, is the first of klok.tenant.shortname in application.properties (what the service runs with), KLOK_TENANT_SHORT, -PklokTenantShort, and the prefix every id in the registry shares. When none is known, the 1.x routes are listed as a warning and not checked.

When the check cannot run

In CI (CI=true) the build fails with REGISTRY_UNREADABLE and what to configure, because a check that silently skips is a check that does not exist. On a developer's machine the task warns and skips, so a local build works offline or without a token. --report prints whatever it found and never fails. A project with no route id and no solutionId that names a solution (an application, a datamodel) has nothing to check, and the task does not read the registry at all.

The result: solution-check.json

The task prints the solutions it found, the warnings and one block per problem, and writes build/klok-solutions/solution-check.json:

{
  "schemaVersion" : 1,
  "context" : {
    "projectPath" : "klok/integration/klok-api-ai",
    "projectName" : "klok-api-ai",
    "tenant" : "klok",
    "tenantSource" : "CI_PROJECT_ROOT_NAMESPACE",
    "tenantShortCode" : "KLK",
    "tenantShortCodeSource" : "klok.tenant.shortname in application.properties",
    "registryUrl" : "https://git.klok.dev/klok/integration-solutions",
    "generator" : "klok-gradle-plugin/<version>"
  },
  "registry" : { "repoPath" : "klok/integration-solutions", "ref" : "main", "commit" : "d1683b46...", "readable" : true, "solutions" : 8 },
  "checked" : true,
  "ok" : true,
  "routes" : [ { "routeId" : "KLK003A1_AiApi", "solutionId" : "KLK003", "legacy" : false, "framework" : false } ],
  "solutions" : [ { "solutionId" : "KLK003", "registered" : true, "status" : "active", "folder" : "KLK003_klok_ai",
                    "name" : "Klok AI", "routeIds" : [ "KLK003A1_AiApi" ], "inProjectFile" : false } ],
  "problems" : [ ],
  "warnings" : [ ]
}
Field Meaning
context the project, the tenant and the tenant short code with where each came from, the registry's page and projectSolutionId (the solutionId of klok-system-project.json, absent when unset)
registry the registry read: path, branch, the commit the archive was made from, whether it was readable and how many solutions it registers; absent when the registry was not needed or no tenant was known
checked, ok whether the comparison ran, and whether it ran without a problem
routes every route with the solution its name gives, whether the name is a 1.x one and whether its number is a framework number
solutions every solution the project names, with what the registry says
problems {code, solutionId, routeIds, source, message, whatToDo}, source being routes, klok-system-project.json or registry
warnings what the task could not read as expected: route names without a solution, a disagreeing klok.tenant, descriptors it could not read

A change of the file's form raises schemaVersion.

Reading a failure

Each problem is one numbered block with what is wrong and what to do. klok-konvoj-adapter on 2026-10-08:

[KlokPlugin - Solutions] Solutions of klok-konvoj-adapter (tenant klok, klok/integration-solutions on main at d1683b46):
  KLK011  NOT REGISTERED  (5 route(s))
[KlokPlugin - Solutions] 1 problem(s) with the solution ids of klok-konvoj-adapter (tenant klok, klok/integration-solutions on main at d1683b46).

  1. SOLUTION_UNREGISTERED  KLK011  (routes KLK011A1_UserCsvManualTrigger, KLK011E1_UserHttpOfframp, ...)
     KLK011 is the prefix of 5 route(s), but klok/integration-solutions has no solution KLK011 on main. A solution id
     is allocated by the merge request that adds its folder to the registry, so these routes claim a number nobody allocated.
     What to do:  Allocate a solution id: run klok solutions new "<solution name>" (or create the solution in
     klok.dev) and rename the routes to the id it allocates; or add solutions/KLK011_<slug>/ ... by hand, in a merge
     request. ...

  Then run ./gradlew klokSolutionCheck again. The full result is in build/klok-solutions/solution-check.json.

A 1.x route is reported under the solution the runtime gives it: in klok-api-proxies, I15A1_GitLabGateway is KLK015, which is not registered, while I10A1_UsersOnrampSftp is KLK010, which is.

In CI

The integration build template (build-template-integration.yml in klok/environment/build-ci-templates) runs ./gradlew klokSolutionCheck --no-daemon in the job klok_solution_check, with the same rules, needs and artifacts as klok_topic_check and without a Vault login: the job token is all it needs. KLOK_SOLUTION_CHECK decides what a failure does: report (the default while existing projects are brought in line) makes the job allow_failure, so a problem shows as a warning; enforce makes it block. The task itself is strict whenever CI=true; the template decides whether the failed job stops the pipeline. See klok docs read klok-environment-build-ci-templates.

Who uses the task, and how

An integration developer starting a new solution allocates its id first (klok solutions new "<name>" opens the registry merge request; or create the solution in klok.dev) and names the routes with it. After adding or renaming routes, ./gradlew klokSolutionCheck with GITLAB_TOKEN exported shows whether every prefix is registered. A route in an existing solution takes that solution's id, even in a project that carries routes of another.

A reviewer reads the klok_solution_check job of the merge request: a SOLUTION_UNREGISTERED means the routes claim a number the registry never allocated, and the registry merge request must come first.

A maintainer of <tenant>/integration-solutions keeps the tenant's root group on the registry's job token allowlist, so every project's check can read it, and retires a solution by setting its status to retired when no leg runs any more.

An AI agent working in a Klok project:

  1. Never picks a solution number by itself, and never takes the next free number it sees in the code or the registry. It allocates one with klok solutions new or hands that to the person as a manual step.
  2. Runs ./gradlew klokSolutionCheck --report and reads build/klok-solutions/solution-check.json, not the console.
  3. Treats every problem as work for the merge request (rename the routes, correct solutionId) or as a manual step (register the solution, add the allowlist entry), and every warning as something to explain or fix.