@klok-integration/cli 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ ## This repository: application
2
+
3
+ A Klok application (portal, docs portal, agent service or another container) that is built and deployed with the
4
+ platform pipelines: image to `repo.klok.dev`, deployment manifest in the manifests repository, secrets through
5
+ Vault. Read https://docs.klok.dev/klok-environment-build-ci-templates/llm.txt for the release process and the
6
+ repository's own `README.md` and `docs/` for its architecture.
7
+
8
+ ### Rules
9
+
10
+ * Follow the repository's build and test commands from `README.md` or `package.json`; keep type checks and tests
11
+ green before pushing.
12
+ * Anything the application stores about Git content (projects, datamodels, catalog, documentation) is derived data
13
+ with a refresh path from `main`; there is no feature that only works through the application.
14
+ * Tenant, domain and role separation is enforced on the server side; never rely on the UI hiding something.
15
+ * Secrets and environment configuration come from the Vault env secret of the deployment, never from committed
16
+ files.
17
+ * Update `klok-docs/` (or `docs/`) with every change of behaviour, API or configuration.
@@ -0,0 +1,21 @@
1
+ ## This repository: datamodel project
2
+
3
+ A Klok datamodel: an XSD (or JSON schema) under `schema-definition-xsd/`, converted by the pipeline to Avro and to
4
+ a generated Java project that is published as `dev.klok.<tenant>.datamodel:<name>-v<n>` and written into the
5
+ dependency catalog. Read https://docs.klok.dev/klok-framework-klok-common/llm.txt for naming and
6
+ https://docs.klok.dev/klok-environment-build-ci-templates/llm.txt for the pipeline.
7
+
8
+ ### Rules
9
+
10
+ * One root element `<Name>_vN` that references every complex type; a single `xs:` prefix; `targetNamespace` and
11
+ `xmlns:tns` set; `elementFormDefault="qualified"`. Validate with the XSD validation of the CI template before
12
+ pushing (`python3 scripts/validate-xsd.py` from build-ci-templates, or the pipeline's `generate_avro_from_xsd`).
13
+ * The major version is part of the model name (`Customer_v1`, class `CustomerV1`); a breaking change is a new
14
+ major version and a new topic, never a silent change of an existing one.
15
+ * `meta.json` uses the flat form with `targetNamespace`; it drives the generated project's group, name and
16
+ documentation.
17
+ * Consumers reference the artifact only through the catalog alias (`klokLibs.<key>`), never by literal version.
18
+ * Datamodel documentation lives in `klok-docs/` (purpose, fields that need explanation, producers and consumers,
19
+ design decisions) and is mirrored to the documentation project.
20
+ * On `main` the pipeline publishes and updates the catalog; check it, then refresh consumers with
21
+ `./gradlew updateKlokLibsToml`.
@@ -0,0 +1,19 @@
1
+ ## This repository: documentation project
2
+
3
+ A znai documentation project published to https://docs.klok.dev under the doc id in `klok-docs-sync.json`. Read
4
+ https://docs.klok.dev/klok-environment-build-ci-templates/llm.txt (docs sync) for how content arrives here.
5
+
6
+ ### Rules
7
+
8
+ * `docs/klok-docs/` and `docs/generated/` are written by the docs sync of the source repository. Never edit them
9
+ here; change `klok-docs/` in the source repository, or the generator. Only `KLOK:GENERATED` regions of AI
10
+ maintained pages are rewritten automatically.
11
+ * Human pages live in `docs/` next to them (`overview`, `architecture`, `operations`, `changelog`); keep
12
+ `docs/toc` and `docs/toc-manifest.json` in sync when adding a page.
13
+ * The doc id must start with the tenant prefix (`<tenant>-...`); the pipeline refuses others. Do not set the
14
+ tenant, the Vault path or upload tokens in the project CI. This project's `.gitlab-ci.yml` is the include of
15
+ `klok/environment/build-ci-templates:/klok-docs-publish.yml` and nothing else; the job is `klok docs publish`.
16
+ * Visibility follows `meta.json` `scope` (`global`, `tenant`, `domain`, `system`); a page that must not be seen by
17
+ another domain belongs in a project with that scope, not behind a note.
18
+ * Preview locally with `znai --source-root docs --preview`, and check what a publish would do with
19
+ `klok docs publish --dry-run`; the `llm.txt` the build generates is what agents read.
@@ -0,0 +1,19 @@
1
+ ## This repository: framework library
2
+
3
+ Part of the Klok framework (klok-common, the broker client, the Quarkus extension, the gradle plugin or the CI
4
+ templates). Changes here reach every tenant, so read the library's `klok-docs/` and its published documentation
5
+ (`https://docs.klok.dev/klok-framework-<repo>/llm.txt`) before changing behaviour.
6
+
7
+ ### Rules
8
+
9
+ * Public API changes are documented in `klok-docs/` in the same merge request, including a design decision entry
10
+ when a convention changes; a breaking change is a new major version.
11
+ * Names and property keys are defined once in klok-common and mirrored by the other libraries and clients; never
12
+ spell a topic name or a `klok-*` property by hand elsewhere.
13
+ * Builds: `./gradlew build` must stay green, tests run on the JUnit Platform, and the extension's runtime and
14
+ deployment modules must get exactly the same version (one timestamp per build).
15
+ * Releases happen from `main` only, in dependency order (klok-common, broker client, extension), each waiting for
16
+ its publish and the catalog update before the next is merged. Maven Central is immutable: a version is never
17
+ republished.
18
+ * CI template changes are tested with a dry run (`KLOK_CATALOG_UPDATE_DRY_RUN=true`, a branch pointing at the
19
+ template branch) before they are merged to `main`, because every project includes the templates from `main`.
@@ -0,0 +1,33 @@
1
+ ## This repository: integration project
2
+
3
+ A Klok integration on the Quarkus extension 2.0: one Camel route per class, each extending a framework pattern
4
+ (`KlokOnrampRoute`, `KlokProcessingRoute`, `KlokOfframpRoute`, their `Sync` variants, `KlokRestApi` and
5
+ `KlokRestApiHandlerRoute`, `KlokAsyncTaskWorkerRoute`, `KlokCustomRoute`) and implementing the capabilities it
6
+ needs. Read https://docs.klok.dev/klok-framework-klok-quarkus-extension/llm.txt before writing a route.
7
+
8
+ ### Commands
9
+
10
+ ```
11
+ ./gradlew build # compile, unit and @QuarkusTest tests (no broker, recording clients)
12
+ ./gradlew updateKlokLibsToml # refresh gradle/klok-libs.versions.toml from the dependency catalog
13
+ ./gradlew quarkusDev # run locally against the configured broker
14
+ ./gradlew initDocsGeneration # route facts to build/klokRoutes/docs.json
15
+ ```
16
+
17
+ ### Rules
18
+
19
+ * Route class name = route id `<TENANTSHORT><NNN><LEG><seq>_<Description>`; one solution id per business flow.
20
+ Configuration keys are `<RouteId>.<key>` with fallback to `<SolutionId>.<key>` and `klok.route-defaults.<key>`.
21
+ * Datamodels are the type parameters of the pattern class and come from the catalog bundles; never hand write DTOs
22
+ for something a datamodel project should own.
23
+ * Errors: throw `Klok4XXException` for caller errors (no retry) and `Klok5XXException` or plain exceptions for
24
+ retryable failures; the framework retries, republishes to `_DLQ` and emits the failure event. Do not add
25
+ `onException` blocks unless the route owns the failure (`failureHandled()`).
26
+ * Large payloads go through the claim check (`KlokClaimCheckStore`), long running work through tasks
27
+ (`KlokTaskInitiation`, `KlokAsyncTaskWorkerRoute`).
28
+ * Tests: `@QuarkusTest` with the recording broker client factory; assert routes started and published messages,
29
+ never talk to a real broker or OpenSearch in unit tests.
30
+ * `application.properties` keeps every `klok.*` key explicit; secrets come from environment variables that the
31
+ Vault env secret provides in Kubernetes (`KLOK_BROKER_AUTH_CLIENT_ID`, ...).
32
+ * Update `klok-docs/` (overview, design decisions, routes, operations) in the same merge request as the change.
33
+ * On `main` the pipeline builds the image, updates the deployment manifest and syncs the documentation; check it.
@@ -0,0 +1,193 @@
1
+ # Klok platform rules for AI agents
2
+
3
+ These rules apply to every AI coding agent (Claude Code, Codex, OpenCode, Cursor, Antigravity, Copilot, Cline and
4
+ others) working on Klok repositories. `KLOK-AGENTS.md` is the single source of instructions and Klok owns that
5
+ file outright: it is replaced wholesale on every update, so never edit it by hand. The harness files (`AGENTS.md`,
6
+ `CLAUDE.md`, `GEMINI.md`, `.cursor/rules`, `.agents/rules`) carry one managed row that points here and are
7
+ otherwise yours. Do not copy rules into them.
8
+
9
+ ## Read the documentation before guessing
10
+
11
+ The platform documentation is published at https://docs.klok.dev. Every documentation project exposes its full
12
+ content as one markdown file at `https://docs.klok.dev/<doc-id>/llm.txt`; fetch it instead of relying on memory.
13
+
14
+ | Topic | Read |
15
+ |---|---|
16
+ | Platform principles, event driven design, naming, onboarding | https://docs.klok.dev/klok-integration-strategy-and-tactics/llm.txt |
17
+ | Route framework (patterns, config, logging, errors, topics, tasks) | https://docs.klok.dev/klok-framework-klok-quarkus-extension/llm.txt |
18
+ | Naming conventions, message properties, CloudEvents | https://docs.klok.dev/klok-framework-klok-common/llm.txt |
19
+ | Broker client | https://docs.klok.dev/klok-framework-klok-brokerclient-java/llm.txt |
20
+ | Gradle plugin, versions, catalog | https://docs.klok.dev/klok-framework-klok-gradle-plugin/llm.txt |
21
+ | CI templates, release process, Vault roles | https://docs.klok.dev/klok-environment-build-ci-templates/llm.txt |
22
+
23
+ A 404 means the documentation project is not published yet; read the repository's `klok-docs/` folder instead.
24
+ The `klok-docs` skill describes the lookup in detail.
25
+
26
+ ## Git is the truth, everything must work by hand
27
+
28
+ * `main` in Git is the only source of truth for code, datamodels, the dependency catalog, project metadata,
29
+ templates and documentation sources. Fetch fresh `main` before reading or changing a repository; a local clone or
30
+ a database row is never a source.
31
+ * klok.dev is a convenience layer on top of Git. Whatever it does must also be possible by editing repositories in
32
+ GitLab by hand, and klok.dev must notice such manual changes. Never build a feature that makes the portal the
33
+ only path, and never introduce a cache or copy of Git content without a refresh mechanism.
34
+ * Ask of every change: "what happens if someone does this directly in GitLab?" A mismatch between Git and klok.dev
35
+ is a bug in klok.dev.
36
+
37
+ ## One task, one worktree, one branch
38
+
39
+ Every task that changes repository files runs in its own Git worktree on its own branch, created by the agent as
40
+ part of the task. Read-only investigation may use the canonical checkout. The `klok-worktree` skill has the
41
+ step by step procedure; the contract every agent follows is:
42
+
43
+ * Workspace root: the directory `klok sync` mirrors into (config key `workspace`, default `~/devklok`; expand `~`
44
+ to the real home directory, never assume a user name). Canonical checkout: `<root>/<tenant>/<group>/.../<repo>`.
45
+ Task worktree: `<root>/worktrees/<tenant>/<group>/.../<repo>/<task-id>`. Task branch: `agent/<task-id>`.
46
+
47
+ | Purpose | Path |
48
+ |---|---|
49
+ | Canonical | `~/devklok/klok/integration/klok-api-konvoj` |
50
+ | Session A | `~/devklok/worktrees/klok/integration/klok-api-konvoj/20260911-auth-a1b2c3d4` |
51
+ | Session B | `~/devklok/worktrees/klok/integration/klok-api-konvoj/20260911-tests-e5f6a7b8` |
52
+
53
+ * Preserve the complete repository path including every subgroup. Never flatten to the repository name, never put
54
+ a worktree inside `.claude`, inside the canonical checkout or in a tool specific directory. If a tool's own
55
+ worktree automation uses another layout, configure it to follow this contract or create the worktree by hand.
56
+ * `<task-id>` is unique per writing session: lowercase letters, digits and hyphens, `YYYYMMDD-<topic>-<8 hex>`
57
+ (`20260911-auth-a1b2c3d4`). One session owns one worktree per repository; never share a worktree between
58
+ concurrent writers, and give every delegated writer its own worktree and branch. A task that spans repositories
59
+ uses the same task id under each repository's path and records repository, base commit, branch and worktree.
60
+ * Base the worktree on the remote default branch after a fetch (`origin/main` once verified through the remote
61
+ HEAD, not assumed) unless the task names another base. If a branch or directory with the chosen name already
62
+ exists, use a new id; never delete, reset or force reuse it.
63
+ * Leave the canonical checkout's branch, files and uncommitted changes exactly as found. Never run `checkout`,
64
+ `switch`, `pull`, `reset`, `clean`, `stash`, rebase or merge in the canonical checkout or in another session's
65
+ worktree. Dirty canonical files are not a blocker: a worktree starts from committed history and does not copy
66
+ uncommitted or ignored files; if the task needs them, ask for an explicit handoff.
67
+ * Do every edit, build and test in the task worktree, with explicit working directories or `git -C`. Recreate
68
+ dependencies there; do not copy or symlink `.env`, credentials, `node_modules` or build output from another
69
+ checkout. A worktree is not a sandbox: use isolated ports, containers and output directories where parallel
70
+ tasks would collide, and never write through absolute paths into another checkout.
71
+ * Instruction files along the canonical path (`<root>/KLOK-AGENTS.md`, `<root>/<tenant>/KLOK-AGENTS.md`) are not
72
+ above a worktree under `<root>/worktrees`; read them deliberately, together with the `KLOK-AGENTS.md` of the worktree
73
+ revision, and resolve conflicts before editing.
74
+ * State the repository, worktree path and branch before the first edit. A tool that cannot reach the worktree
75
+ reports that limitation instead of silently editing the canonical checkout.
76
+ * Commit finished work to the task branch (stage specific paths, check for secrets and unrelated files), push and
77
+ open a merge request when the task or the established workflow allows it, and report the repository path,
78
+ worktree, branch, commits, tests and merge request status. Unfinished work gets a clear handoff and keeps its
79
+ worktree.
80
+ * Keep the worktree until the branch is merged or cleanup is asked for; a clean status does not mean the commits
81
+ are pushed. Remove with `git worktree remove <exact path>` without force, never `rm -rf`, and never delete a
82
+ branch merely because a session ended. Legacy worktrees are reported, not moved or deleted.
83
+ * Repository discovery and sync (`klok sync`, workspace generators) exclude `<root>/worktrees`; a task tree is
84
+ never a canonical repository.
85
+
86
+ ## Versions come from the dependency catalog
87
+
88
+ * Framework libraries, the gradle plugin and datamodels are released with timestamped versions from `main`
89
+ (`0.3.0+260910043154`, `1.0.0-build.260909105636`). After a release the CI writes the version into
90
+ `klok/framework/klok-gradle-dependency-catalog`.
91
+ * Never pin or edit these versions by hand in a project. Refresh the project's copy with
92
+ `./gradlew updateKlokLibsToml` and commit the refreshed `gradle/klok-libs.versions.toml`.
93
+ * A change that spans framework libraries is merged and published in dependency order: klok-common, then the broker
94
+ client, then the Quarkus extension.
95
+
96
+ ## Pipelines, secrets and infrastructure
97
+
98
+ * After every push to git.klok.dev, check the pipeline (`glab api "projects/<id>/pipelines?per_page=3"`, job traces)
99
+ and fix failures before moving on. Publishing, image pushes, manifest updates and catalog updates only happen on
100
+ `main`; merge request pipelines build and test.
101
+ * Vault (`vault.ipaas.se`) is changed by a human only. Agents may read to diagnose and must then propose the exact
102
+ command, including every existing field of the object.
103
+ * New projects are created through klok.dev, or through the agent at https://agent.klok.dev authenticated as the
104
+ tenant with the right to create projects in the domain. That is the supported path and it provisions what the
105
+ project needs to build. Creating a project by hand is a legitimate fallback under *Git är sanningen*, but it is
106
+ not the normal path: say up front what a human will still have to do, rather than letting it surface as a red
107
+ pipeline. Today that always includes the Vault CI role `<tenant>-ci-project-<gitlab id>`, which needs both
108
+ `default` and the tenant CI read policy; see `klok/application/frontend-klok-dev` issue #7.
109
+ * Never push to `main` of an existing repository, never force push, never merge. Work on a branch and open a
110
+ merge request that is ready for review; only a brand new repository gets its first commit on `main`. A draft
111
+ merge request is not the default, it is what you open when the work is knowingly unfinished, and you say why.
112
+
113
+ ## Logic lives in the Klok tools, not in the pipelines
114
+
115
+ * Klok functionality belongs in the Klok tools: **klok-cli** (`@klok/cli`), **the Klok Gradle plugin** and **the
116
+ Klok build image** (which carries klok-cli). A job in a Klok-owned template is one command, `./gradlew <task>`
117
+ or `klok <command>`, plus the shared Vault login. Inline `curl`, multi-line shell, `if` guards, JSON assembly,
118
+ git plumbing or embedded Python/Node in a `.gitlab-ci.yml` is logic in the wrong place: move it into a tool,
119
+ where it is versioned, unit tested and runnable by hand.
120
+ * The reason is portability. The ecosystem must not be coupled to GitLab; a customer should get Klok running on
121
+ Azure DevOps or GitHub with minimal effort. Everything that lives in a tool moves for free, everything that lives
122
+ in a template has to be rewritten. Read the CI variables (tenant, repository path, commit, pipeline) in one place
123
+ inside the tool, never spread across jobs.
124
+ * The rule is strict for what customers include: `build-ci-templates`, the `project-template-*` repositories and
125
+ the documentation publish include. `application/*` repositories are more free form.
126
+ * The same design is what lets a project that was not created from a Klok template opt in: running klok-cli in its
127
+ own pipeline gives it, for example, documentation publishing. Tool commands are the product surface; templates
128
+ are only the convenient wiring of them.
129
+
130
+ ## Naming
131
+
132
+ * Route ids: `<TENANTSHORT><NNN><LEG><seq>_<Description>` (`KLK002I1_OdlScheduledQuery`); legs `I` ingress,
133
+ `P` processing, `E` egress, `A` API, `S` sub route, `T` timer. The class name is the route id, the config prefix
134
+ and the solution key.
135
+ * Topics: `persistent://<tenant>[_<env>]/<domain>/<Model>[_<purpose>]`, request/reply
136
+ `ReqRes_<Req>_<Res>_Request|_Response`, dead letters `<topic>_DLQ`. The datamodel major version is in the class
137
+ name (`CustomerV1`).
138
+ * Context properties: `klok-correlation-id`, `klok-invocation-id`, `klok-parent-invocation-id`, `klok-task-id`,
139
+ `klok-solution-id`, `klok-route-id`, `klok-tenant`, `klok-domain`, `klok-environment`; same spelling as HTTP
140
+ header, Pulsar property and CloudEvents extension, `klok.`-prefixed as MDC key.
141
+ * Repositories: `<tenant>/integration/domain/<d>/<repo>`, `<tenant>/datamodel/...`, mirrored documentation under
142
+ `<tenant>/documentation/...`; documentation ids are `slug(<tenant>-<group>-...-<repo>)`.
143
+
144
+ ## Documentation is part of every change
145
+
146
+ Klok documentation has three levels, and a change is finished only when all three have been considered:
147
+
148
+ * **The repository's own `klok-docs/`** (znai markdown, `toc-manifest.json`), which the CI mirrors into the
149
+ repository's documentation project. A change that adds or alters a route, a datamodel, a configuration key, a
150
+ CI job, a command or a decision updates `klok-docs/` in the same merge request.
151
+ * **The platform documentation** under `<tenant>/documentation/`: the user guide (`klok-user-guide`), strategy
152
+ and tactics (`klok-integration-strategy-and-tactics`) and the framework, CI and tooling documentation. They
153
+ describe how the platform is used and why. A change that alters a rule, a convention, a workflow, a command or
154
+ a published contract belongs there too, even when the code that changed lives somewhere else entirely.
155
+ * **Generated pages** (`docs/generated/`, `KLOK:GENERATED` regions), which are never edited by hand. A wrong
156
+ generated page is a bug in the generator.
157
+
158
+ ### Before the merge request
159
+
160
+ 1. Update the repository's `klok-docs/` in the same merge request as the change. Documentation that is promised
161
+ for a later merge request is documentation that never arrives.
162
+ 2. Ask what a reader of the platform documentation would now find wrong: a renamed command, a new rule, a changed
163
+ default, a workflow with one more step. Read the affected pages (`https://docs.klok.dev/<doc-id>/llm.txt`)
164
+ instead of guessing what they say.
165
+ 3. Correct what you can judge yourself. A central page that is now plainly wrong is fixed in its own small merge
166
+ request against that documentation project, linked from the change. What you cannot judge is written down
167
+ rather than dropped.
168
+ 4. Write the merge request description for two readers: the reviewer, and the documentation flow that runs after
169
+ the merge. State what changed, why, and which documentation it affects or might affect. A description that
170
+ says only "fixes the build" produces no documentation update.
171
+
172
+ ### After the merge
173
+
174
+ The pipeline on `main` publishes the project's documentation payload (`KlokProjectDocumentationV1`: routes,
175
+ sources, configuration keys and the whole `klok-docs/` folder with a hash per file). A documentation flow that
176
+ reads that payload together with the merge request description and the diff, and proposes the central updates as
177
+ merge requests for a human to review, is being built; until it runs, nothing behind you looks at the central
178
+ documentation. Either way the steps above are the ones that matter: an author who knows what changed writes
179
+ better documentation than a flow that reads the diff afterwards, and a proposal is a safety net for what was
180
+ missed, never a reason to skip writing it.
181
+
182
+ ## How to work
183
+
184
+ 1. Restate the task, then read the relevant documentation and the repository's `KLOK-AGENTS.md` and `klok-docs/`.
185
+ 2. Create the task worktree and branch before the first edit (see *One task, one worktree, one branch*) and say
186
+ which repository, worktree and branch you work in.
187
+ 3. Build and test locally with the repository's standard commands before pushing; keep every commit green.
188
+ 4. Small, reviewable merge requests with a description that states what changed, why, and which documentation
189
+ it affects.
190
+ 5. A new project cloned from a template refreshes the catalog copy and the agent instructions before the first
191
+ push: `./gradlew updateKlokLibsToml updateKlokAgents`. klok.dev does the same HTTP fetch when it creates the
192
+ project. Re-run the tasks later to pick up a new catalog or a new skill set.
193
+ 6. Report outcomes faithfully: failing tests, skipped steps and open questions are stated, not hidden.
@@ -0,0 +1,51 @@
1
+ ---
2
+ name: klok-datamodel
3
+ description: Create or change a Klok datamodel (XSD first, generated Java, published to the dependency catalog) and wire consumers to it. Use when a task adds a domain object, changes a schema or asks which datamodel a route should use.
4
+ ---
5
+
6
+ # Klok datamodels
7
+
8
+ Read https://docs.klok.dev/klok-framework-klok-common/llm.txt (naming) and
9
+ https://docs.klok.dev/klok-environment-build-ci-templates/llm.txt (datamodel pipeline).
10
+
11
+ ## Creating or changing a model
12
+
13
+ 1. The model lives in its own repository `<tenant>/datamodel/<common|public|domain/<d>|system/<s>>/<name>-v<n>`,
14
+ where the repository name is the model name in kebab case (`supplier-invoice-v1`); the XSD file inside keeps
15
+ the PascalCase form (`SupplierInvoice_v1.xsd`).
16
+
17
+ **Create it through klok.dev, or through the agent at https://agent.klok.dev** authenticated as the tenant
18
+ with the right to create projects in the domain. That is the supported path: it creates the repository from
19
+ `project-template-datamodel`, renders the placeholders, and provisions what the project needs to build,
20
+ including its Vault CI role.
21
+
22
+ By hand it is: `git clone` the template, `git remote rename origin template`, `git remote add origin <new
23
+ repo>`, render every `__KLOK_*__` token listed in `klok-template.json` (including the XSD file name), push
24
+ `main`. Keep the `template` remote so later template improvements can be pulled in. Never assemble the
25
+ project by copying files out of a sibling datamodel: the copies go stale and whole files get missed
26
+ (`klok-datamodel-project.json`, `klok-template.json`, the agent instruction files, the three page
27
+ `klok-docs/datamodel/` layout).
28
+
29
+ A hand created project has **no Vault CI role**, so its first `publish_java_projects` fails with
30
+ `role "<tenant>-ci-project-<id>" could not be found`. Say that up front and give the user the command; see
31
+ the `klok-release` skill.
32
+ 2. Write the XSD under `schema-definition-xsd/`: single `xs:` prefix, `targetNamespace` with `xmlns:tns`,
33
+ `elementFormDefault="qualified"`, one root element `<Name>_vN` that references every complex type. Enumerations
34
+ as `xs:enumeration`.
35
+ 3. `meta.json` in the flat form with `targetNamespace`, and `klok-docs/` with the purpose, the important fields and
36
+ the producers and consumers.
37
+ 4. A breaking change is a new major version (`Customer_v2`), which is a new class, a new topic and a new catalog
38
+ key; a compatible change (optional field) stays in the same version.
39
+ 5. Work in the task worktree (`klok-worktree` skill), push its `agent/<task-id>` branch, open a merge request;
40
+ the pipeline validates the XSD and generates the Java project. On `main` it
41
+ publishes `dev.klok.<tenant>.datamodel:<name>-v<n>:1.0.0-build.<ts>` and writes `<nameVn>` (for example
42
+ `klokOdlV1`) into the dependency catalog.
43
+
44
+ ## Using a model in a project
45
+
46
+ * Run `./gradlew updateKlokLibsToml` in the consumer, commit the refreshed `gradle/klok-libs.versions.toml`, and
47
+ reference the alias (`klokLibs.klokOdlV1` or the bundle). Never type a version.
48
+ * The generated class is `dev.klok.<tenant>.datamodel.<group>.<name>_v<n>.<Name>Vn`; the ODL type of an object is
49
+ the fully qualified class name.
50
+ * The topic for the model is derived from the class (`persistent://<tenant>[_<env>]/<domain>/<Name>Vn`); do not
51
+ invent topic strings.
@@ -0,0 +1,51 @@
1
+ ---
2
+ name: klok-docs
3
+ description: Look up Klok platform documentation on docs.klok.dev (llm.txt per documentation project) before designing or changing anything on the Klok integration platform. Use when a task mentions Klok, routes, datamodels, topics, the ODL, tasks, the dependency catalog, CI templates or klok.dev.
4
+ ---
5
+
6
+ # Reading Klok documentation
7
+
8
+ The platform documentation is published on https://docs.klok.dev, one documentation project per repository. Each
9
+ project exposes its whole content as a single markdown file, generated by znai:
10
+
11
+ ```
12
+ https://docs.klok.dev/<doc-id>/llm.txt
13
+ ```
14
+
15
+ Fetch that file and read it; it is the authoritative version of the repository's `klok-docs/` plus the generated
16
+ route, datamodel and configuration pages. Do not answer from memory when a page exists.
17
+
18
+ ## Doc ids
19
+
20
+ The doc id is the repository path without the leading slash, with `/` replaced by `-`, lower case:
21
+ `/klok/framework/klok-quarkus-extension` becomes `klok-framework-klok-quarkus-extension`;
22
+ `/acme/integration/domain/finance/acme-egress-fortnox` becomes
23
+ `acme-integration-domain-finance-acme-egress-fortnox`. Global documentation under `/klok/documentation/<name>`
24
+ drops the `klok-` prefix of the name (`klok-integration-strategy-and-tactics`).
25
+
26
+ | Need | Doc id |
27
+ |---|---|
28
+ | Principles, event driven design with sync compatible interfaces, naming cheat sheet, framework map, onboarding | `klok-integration-strategy-and-tactics` |
29
+ | Route patterns, capabilities, configuration, logging and correlation, error handling, topics and CloudEvents, async tasks, ODL client, testing, migration from 1.x | `klok-framework-klok-quarkus-extension` |
30
+ | Naming conventions, `klok-*` properties, CloudEvents attributes | `klok-framework-klok-common` |
31
+ | Broker client configuration, subscriptions, request/reply | `klok-framework-klok-brokerclient-java` |
32
+ | Gradle plugin, versions, catalog refresh | `klok-framework-klok-gradle-plugin` |
33
+ | CI templates, release process, Vault roles, docs sync, catalog update | `klok-environment-build-ci-templates` |
34
+ | ODL REST and request/reply, tasks API | `klok-integration-klok-api-opensearch` |
35
+ | ODL writers, log receivers | `klok-integration-klok-egress-opensearch` |
36
+ | Scheduled queries, stale task detection | `klok-integration-klok-ingress-opensearch` |
37
+ | OpenAI compatible API, AI tasks, Kloker gateway | `klok-integration-klok-api-ai` |
38
+ | AI workers, transcription, transcript cache | `klok-integration-klok-egress-ai` |
39
+
40
+ ## Procedure
41
+
42
+ 1. Identify the repositories involved and derive their doc ids.
43
+ 2. Fetch `https://docs.klok.dev/<doc-id>/llm.txt` for each. On a 404 the project is not published yet: read the
44
+ repository's `klok-docs/` folder from `main` instead (it is the source of the same pages).
45
+ 3. Read the strategy documentation first when the task touches design, naming or onboarding; read the framework
46
+ documentation before writing or changing a route.
47
+ 4. Cite the page you relied on in your answer or merge request description, so reviewers can check it.
48
+
49
+ The portal at https://docs.klok.dev requires a Keycloak login for tenant and domain scoped documentation; global
50
+ documentation is readable by every platform user. If a fetch is denied, ask the user for the content or run in an
51
+ environment that is logged in.
@@ -0,0 +1,68 @@
1
+ ---
2
+ name: klok-release
3
+ description: Release and deploy on the Klok platform: pipelines, versions, the dependency catalog, deployment manifests, Vault roles and secrets, and what to check after a push. Use when a task involves merging, publishing, deploying, CI failures or setting up a new project.
4
+ ---
5
+
6
+ # Releasing on Klok
7
+
8
+ Read https://docs.klok.dev/klok-environment-build-ci-templates/llm.txt (release process by project type, Vault
9
+ roles and secrets, catalog update) before acting.
10
+
11
+ ## The flow
12
+
13
+ 1. Work in the task worktree on its `agent/<task-id>` branch (`klok-worktree` skill); open a merge request that
14
+ is ready for review (draft only when the work is knowingly unfinished). The merge request pipeline builds and
15
+ tests only.
16
+ 2. After a merge to `main`: framework libraries publish to the GitLab registry and Maven Central and update the
17
+ dependency catalog; datamodels publish the generated artifact and update the catalog; integrations build and
18
+ push an image and update the deployment manifest in `klok/environment/ipaas/ipaas-service-deploy-manifests`,
19
+ which ArgoCD applies; documentation projects publish to https://docs.klok.dev.
20
+ 3. Check the pipeline after every push:
21
+ `glab api --hostname git.klok.dev "projects/<id>/pipelines?per_page=3"`, then
22
+ `projects/<id>/pipelines/<pid>/jobs` and `projects/<id>/jobs/<jid>/trace`. Fix a red pipeline before the next task.
23
+ 4. Framework changes across libraries are released in order: klok-common, broker client, extension. Wait for the
24
+ catalog update of one before merging the next.
25
+
26
+ ## Creating a new project
27
+
28
+ **Create projects through klok.dev, or through the agent at https://agent.klok.dev** authenticated as the
29
+ tenant and holding the right to create projects in the domain. That is the supported path, and it is meant to
30
+ provision everything the project needs so the **first** pipeline is green with no manual step.
31
+
32
+ Creating a project by hand — `glab api POST /projects`, or cloning the template and swapping the remote — is a
33
+ legitimate fallback under *Git är sanningen*, but it is not the normal path and it leaves work behind that the
34
+ portal would have done. When taking the manual route, name the remaining human steps up front instead of
35
+ letting them surface as a red pipeline.
36
+
37
+ > Automatic Vault provisioning is **not implemented yet**: `klok/application/frontend-klok-dev` issue #7,
38
+ > *Provision the Vault CI role when klok.dev or agent.klok.dev creates a project*. Until it ships, every
39
+ > project — however it was created — needs a human to add the role.
40
+
41
+ ## Setting up a new project (what must exist)
42
+
43
+ * Vault JWT role `<tenant>-ci-project-<gitlab id>` bound to that `project_id`, carrying **both** `default` and
44
+ the tenant CI read policy (`klok-cicd-read` for tenant `klok`). A role with only `default` authenticates but
45
+ cannot read the shared secrets, and `publish` still fails — that is why the pipelines of projects 175 and 191
46
+ were red for months. Without any role at all the job fails at `auth/jwt/login` with
47
+ `role "<tenant>-ci-project-<id>" could not be found`.
48
+ * For anything the pipeline resolves from a package registry (framework, plugin, datamodels): the project's
49
+ top-level group must be on the package project's job token allowlist.
50
+ * For a deployed service: a manifest under `klok/integration/<name>/`, the Kubernetes service account, a Vault
51
+ Kubernetes role `<name>-role` with a policy reading `secret/data/<tenant>/integration/<name>/env`, and the env
52
+ secret itself (broker credentials, service specific keys).
53
+ * Documentation projects need the tenant's docs upload client in Keycloak and in Vault (`secret/<tenant>`).
54
+
55
+ Vault is changed by humans only: propose the exact `vault write` / `vault policy write` command with every existing
56
+ field, and let the user run it.
57
+
58
+ ## Common failures and their meaning
59
+
60
+ | Symptom | Cause |
61
+ |---|---|
62
+ | `role "<tenant>-ci-project-<id>" could not be found` at `auth/jwt/login` | no Vault CI role for the project; it was created without provisioning |
63
+ | `permission denied` reading `secret/.../cicd-environment-variables` | CI role exists but lacks the tenant CI read policy (has only `default`) |
64
+ | `403` on `groups/<tenant>/-/packages/maven/...` | job token allowlist of the package project lacks the reader's group |
65
+ | `Could not find dev.klok...:<version>` | the version is not published yet, or the catalog copy is stale (`updateKlokLibsToml`) |
66
+ | `already deployed` from JReleaser | Maven Central already has that version; a `main` build is a new timestamp, do not retry the same job |
67
+ | `sed: can't read klok/integration/<name>/<name>-crds.yaml` | no deployment manifest for the service yet |
68
+ | `cannot run ssh` | the job needs `openssh-client`; the templates install it before pushing over SSH |
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: klok-route
3
+ description: Write or change a Camel route on the Klok Quarkus extension 2.0 (onramp, processing, offramp, REST API handler, async task worker, custom route) with the correct naming, configuration, error handling, tests and klok-docs. Use for any change inside a Klok integration project.
4
+ ---
5
+
6
+ # Writing a Klok route
7
+
8
+ Read https://docs.klok.dev/klok-framework-klok-quarkus-extension/llm.txt first (pages `patterns`, `naming`,
9
+ `config`, `error-handling`, `testing`); read the `klok-docs` skill for other pages.
10
+
11
+ ## Steps
12
+
13
+ 1. **Pick the pattern.** Ingress from a system: `KlokOnrampRoute<SYS, DOM>`; transformation between datamodels:
14
+ `KlokProcessingRoute<IN, OUT>`; egress to a system: `KlokOfframpRoute<DOM, SYS>`; synchronous request/reply:
15
+ the `Sync` variants; REST: `KlokRestApi` plus one `KlokRestApiHandlerRoute` per operation; long running work:
16
+ `KlokAsyncTaskWorkerRoute<REQ, RES>`; anything else: `KlokCustomRoute`.
17
+ 2. **Name it.** `<TENANTSHORT><NNN><LEG><seq>_<Description>`, one class per route, the solution number from the
18
+ portal registry. Sub routes are `S`, timers `T`.
19
+ 3. **Bind the datamodels** as type parameters; take them from the catalog bundle, never hand written DTOs.
20
+ 4. **Configure** through `routeConfig("key", default)` / `requiredRouteConfig("key")` and document every key in
21
+ `application.properties` as `<RouteId>.<key>`. Reserved keys: `enabled`, `logevents.*`, `retry.*`, `dlq.*`,
22
+ `topic.*`, `subscription.*`, `claimcheck.*`.
23
+ 5. **Errors.** Throw `Klok4XXException` for caller errors, let retryable failures propagate; the base route logs,
24
+ retries with backoff, republishes to `<topic>_DLQ` and emits the failure CloudEvent. Override `failureHandled()`
25
+ only when the route owns its failures (custom routes that answer HTTP themselves).
26
+ 6. **Capabilities** as interfaces: `SplitIncomingMessage`, `AggregateOutgoingMessages`, `ClaimCheck`,
27
+ `KlokEmitCloudEventOnSuccess/Failure`, `PersistOutgoingMessages`, `KlokAsyncTaskInitiator`.
28
+ 7. **Test** with `@QuarkusTest` and the recording broker client factory: assert the route status is `Started`,
29
+ send a message, assert the published topic, body and `klok-*` properties.
30
+ 8. **Document** in `klok-docs/`: the route in `routes.md`, decisions in `design-decisions.md`, operations notes.
31
+ 9. Build (`./gradlew build`) in the task worktree (`klok-worktree` skill), push its `agent/<task-id>` branch,
32
+ open a merge request ready for review, check the pipeline.
33
+
34
+ ## Things that are always wrong
35
+
36
+ * A route id that does not start with the solution id, or two routes with the same id.
37
+ * Publishing to a hand written topic string; use the resolver and the datamodel.
38
+ * Catching exceptions to return HTTP 200 with an error text.
39
+ * Pinning a framework or datamodel version in `gradle/klok-libs.versions.toml` by hand.