@klok-integration/cli 0.3.2 → 0.3.4

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.
package/README.md CHANGED
@@ -43,6 +43,8 @@ Credentials are written to `~/.config/klok/credentials.json` with mode 0600.
43
43
  | `klok agents init` | Write the Klok agent instructions and skills into a repository. |
44
44
  | `klok bead list\|show\|report` | Progress beads in the current repository. |
45
45
  | `klok docs publish` | Build this repository's znai documentation and upload it to the docs portal. |
46
+ | `klok solutions validate` | Check the descriptors of an integration solution registry against the descriptor contract. |
47
+ | `klok ci env` | Show what klok-cli detected about the CI job it runs in. |
46
48
  | `klok manifest update` | Set a container's image in a deploy manifest of your GitOps repository, then commit and push. |
47
49
  | `klok sync clone\|pull\|status` | Clone and refresh every repository you can see, in one workspace folder. |
48
50
 
@@ -93,8 +95,8 @@ Cursor (`.cursor/mcp.json`):
93
95
  ## Agent instructions
94
96
 
95
97
  `klok agents init` writes `KLOK-AGENTS.md` with the rules, one managed row in every harness file
96
- (`AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, `.cursorrules`, `.clinerules`,
97
- `.github/copilot-instructions.md`), the klok named rule files (`.cursor/rules`, `.agents/rules`) and the
98
+ (`AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, `.cursorrules`, `.clinerules` or a file inside a
99
+ `.clinerules/` directory, `.github/copilot-instructions.md`), the klok named rule files (`.cursor/rules`, `.agents/rules`) and the
98
100
  Klok skills. `KLOK-AGENTS.md`, the klok rule files and the `klok-*` skills belong to Klok and are
99
101
  replaced wholesale; every other file keeps its content and only has its single row created or replaced,
100
102
  so an update can never duplicate text. Klok skills the CLI no longer ships are removed.
@@ -10,12 +10,16 @@ https://docs.klok.dev/klok-environment-build-ci-templates/llm.txt for the pipeli
10
10
  * One root element `<Name>_vN` that references every complex type; a single `xs:` prefix; `targetNamespace` and
11
11
  `xmlns:tns` set; `elementFormDefault="qualified"`. Validate with the XSD validation of the CI template before
12
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.
13
+ * One name, in kebab case, from the repository down: `customer-v1` is the repository, the XSD file
14
+ (`customer-v1.xsd`), the Maven artifact and the npm and Python packages, and `customer_v1` ends the Java package.
15
+ Inside the XSD the model keeps its PascalCase form: root element `Customer_v1`, root type and class `CustomerV1`.
16
+ * The major version is part of the model name; a breaking change is a new major version and a new topic, never a
17
+ silent change of an existing one.
15
18
  * `meta.json` uses the flat form with `targetNamespace`; it drives the generated project's group, name and
16
19
  documentation.
17
20
  * Consumers reference the artifact only through the catalog alias (`klokLibs.<key>`), never by literal version.
18
21
  * Datamodel documentation lives in `klok-docs/` (purpose, fields that need explanation, producers and consumers,
19
- design decisions) and is mirrored to the documentation project.
22
+ design decisions). Datamodel projects publish no documentation payload yet, because the datamodel template runs
23
+ no Klok Gradle task, so these pages do not reach docs.klok.dev until it does; write them anyway.
20
24
  * On `main` the pipeline publishes and updates the catalog; check it, then refresh consumers with
21
25
  `./gradlew updateKlokLibsToml`.
@@ -1,15 +1,25 @@
1
1
  ## This repository: documentation project
2
2
 
3
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.
4
+ https://docs.klok.dev/klok-environment-build-ci-templates/llm.txt (documentation from a source repository) for how
5
+ content arrives here. There are two kinds, and they are edited differently:
6
+
7
+ * **The documentation project of a source repository** (`<tenant>/documentation/<group>/.../<repo>`, mirroring the
8
+ source path) is output. KlokDocumentationEgress (`klok/integration/klok-documentation-egress`, KLK007) builds it
9
+ from the `KlokProjectDocumentationV1` payload the source repository's `main` pipeline publishes, replaces
10
+ everything under `docs/` on every run and commits the AI sections under `docs/_ai/`. Never edit it: a change made
11
+ here is overwritten by the next run. There are exactly two places to change it:
12
+ * `klok-docs/` in the source repository, in a merge request there: the hand written pages, their order and
13
+ chapter titles (`toc-manifest.json`), and where an AI section appears (`<!-- KLOK:GENERATED:START <id> -->` …
14
+ `<!-- KLOK:GENERATED:END <id> -->`);
15
+ * what is generated and how (chapters, sections, prompts, languages, model): klok.dev, Tenant Administration,
16
+ Documentation generation, which tenant admins change.
17
+ * **A standalone documentation project** (directly under `<tenant>/documentation/`, such as
18
+ `klok-integration-strategy-and-tactics`) is written by hand in this repository, and the egress never touches it.
19
+ Keep `docs/toc` and `docs/toc-manifest.json` in sync when adding a page.
5
20
 
6
21
  ### Rules
7
22
 
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
23
  * The doc id must start with the tenant prefix (`<tenant>-...`); the pipeline refuses others. Do not set the
14
24
  tenant, the Vault path or upload tokens in the project CI. This project's `.gitlab-ci.yml` is the include of
15
25
  `klok/environment/build-ci-templates:/klok-docs-publish.yml` and nothing else; the job is `klok docs publish`.
@@ -30,7 +30,8 @@ needs. Read https://docs.klok.dev/klok-framework-klok-quarkus-extension/llm.txt
30
30
  * `application.properties` keeps every `klok.*` key explicit; secrets come from environment variables that the
31
31
  Vault env secret provides in Kubernetes (`KLOK_BROKER_AUTH_CLIENT_ID`, ...).
32
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.
33
+ * On `main` the pipeline builds the image, updates the deployment manifest and publishes the documentation payload
34
+ that KlokDocumentationEgress turns into the documentation project; check it.
34
35
  * The `Dockerfile` copies `build/quarkus-app/lib/` in a `COPY` of its own before `quarkus-run.jar`, `quarkus/`
35
36
  and `app/`, all with `COPY --chown`, never `COPY build/quarkus-app/ .` followed by `RUN chown -R`, which stores
36
37
  every dependency twice in every build.
@@ -19,6 +19,9 @@ content as one markdown file at `https://docs.klok.dev/<doc-id>/llm.txt`; fetch
19
19
  | Broker client | https://docs.klok.dev/klok-framework-klok-brokerclient-java/llm.txt |
20
20
  | Gradle plugin, versions, catalog | https://docs.klok.dev/klok-framework-klok-gradle-plugin/llm.txt |
21
21
  | CI templates, release process, Vault roles | https://docs.klok.dev/klok-environment-build-ci-templates/llm.txt |
22
+ | Developer rules: identity and access, Keycloak, Vault paths, certificates, infrastructure as code | https://docs.klok.dev/klok-framework-development-guide/llm.txt |
23
+ | How people use the platform: concepts, roles and access, workflow, operations | https://docs.klok.dev/klok-user-guide/llm.txt |
24
+ | Infrastructure: stateful services, certificates, Ansible, Keycloak clients | https://docs.klok.dev/klok-environment-klok-environment-setup/llm.txt |
22
25
 
23
26
  A 404 means the documentation project is not published yet; read the repository's `klok-docs/` folder instead.
24
27
  The `klok-docs` skill describes the lookup in detail.
@@ -111,8 +114,10 @@ step by step procedure; the contract every agent follows is:
111
114
  tenant with the right to create projects in the domain. That is the supported path and it provisions what the
112
115
  project needs to build. Creating a project by hand is a legitimate fallback under *Git är sanningen*, but it is
113
116
  not the normal path: say up front what a human will still have to do, rather than letting it surface as a red
114
- pipeline. Today that always includes the Vault CI role `<tenant>-ci-project-<gitlab id>`, which needs both
115
- `default` and the tenant CI read policy; see `klok/application/frontend-klok-dev` issue #7.
117
+ pipeline. Vault needs nothing per project: the tenant CI role `<tenant>-ci` accepts every project under the
118
+ tenant's root group. A tenant without it fails every job at `auth/jwt/login` with
119
+ `role "<tenant>-ci" could not be found`; setting a tenant up is described in `klok-docs/ci/tenant-onboarding.md`
120
+ of `klok/environment/build-ci-templates`.
116
121
  * Never push to `main` of an existing repository, never force push, never merge. Work on a branch and open a
117
122
  merge request that is ready for review; only a brand new repository gets its first commit on `main`. A draft
118
123
  merge request is not the default, it is what you open when the work is knowingly unfinished, and you say why.
@@ -152,9 +157,15 @@ step by step procedure; the contract every agent follows is:
152
157
 
153
158
  Klok documentation has three levels, and a change is finished only when all three have been considered:
154
159
 
155
- * **The repository's own `klok-docs/`** (znai markdown, `toc-manifest.json`), which the CI mirrors into the
156
- repository's documentation project. A change that adds or alters a route, a datamodel, a configuration key, a
157
- CI job, a command or a decision updates `klok-docs/` in the same merge request.
160
+ * **The repository's own `klok-docs/`** (znai markdown, `toc-manifest.json`). On every `main` pipeline
161
+ `./gradlew publishKlokDocs` publishes it, together with the scan of the code, as `KlokProjectDocumentationV1` on
162
+ `persistent://klok[_<env>]/common/KlokProjectDocumentationV1_prepared`. KlokDocumentationEgress
163
+ (`klok/integration/klok-documentation-egress`, KLK007) builds the repository's documentation project from it. That
164
+ documentation project is output, and nobody edits it. There are two places to change a project's documentation:
165
+ `klok-docs/` in the source repository (including the `KLOK:GENERATED` markers that place AI sections in a page),
166
+ and the documentation generation settings in klok.dev, which tenant admins own. A change that adds or alters a
167
+ route, a datamodel, a configuration key, a CI job, a command or a decision updates `klok-docs/` in the same merge
168
+ request.
158
169
 
159
170
  `klok-docs/` has to answer **two different questions**, and a repository that answers only the first is not
160
171
  documented:
@@ -177,8 +188,9 @@ Klok documentation has three levels, and a change is finished only when all thre
177
188
  and tactics (`klok-integration-strategy-and-tactics`) and the framework, CI and tooling documentation. They
178
189
  describe how the platform is used and why. A change that alters a rule, a convention, a workflow, a command or
179
190
  a published contract belongs there too, even when the code that changed lives somewhere else entirely.
180
- * **Generated pages** (`docs/generated/`, `KLOK:GENERATED` regions), which are never edited by hand. A wrong
181
- generated page is a bug in the generator.
191
+ * **Generated pages**: everything KlokDocumentationEgress writes into a documentation project, including the AI
192
+ sections that fill `KLOK:GENERATED` regions. They are never edited by hand. A wrong generated page is fixed in
193
+ the egress or in the documentation generation settings in klok.dev.
182
194
 
183
195
  ### Before the merge request
184
196
 
@@ -191,19 +203,18 @@ Klok documentation has three levels, and a change is finished only when all thre
191
203
  3. Correct what you can judge yourself. A central page that is now plainly wrong is fixed in its own small merge
192
204
  request against that documentation project, linked from the change. What you cannot judge is written down
193
205
  rather than dropped.
194
- 4. Write the merge request description for two readers: the reviewer, and the documentation flow that runs after
195
- the merge. State what changed, why, and which documentation it affects or might affect. A description that
206
+ 4. Write the merge request description for the reviewer: state what changed, why, and which documentation it
207
+ affects or might affect. A description that
196
208
  says only "fixes the build" produces no documentation update.
197
209
 
198
210
  ### After the merge
199
211
 
200
212
  The pipeline on `main` publishes the project's documentation payload (`KlokProjectDocumentationV1`: routes,
201
- sources, configuration keys and the whole `klok-docs/` folder with a hash per file). A documentation flow that
202
- reads that payload together with the merge request description and the diff, and proposes the central updates as
203
- merge requests for a human to review, is being built; until it runs, nothing behind you looks at the central
204
- documentation. Either way the steps above are the ones that matter: an author who knows what changed writes
205
- better documentation than a flow that reads the diff afterwards, and a proposal is a safety net for what was
206
- missed, never a reason to skip writing it.
213
+ sources, configuration keys and the whole `klok-docs/` folder with a hash per file). KlokDocumentationEgress
214
+ (`klok/integration/klok-documentation-egress`) turns it into the project's published documentation: your
215
+ `klok-docs/` pages as written, with `KLOK:GENERATED` regions filled, next to generated pages for routes,
216
+ datamodels and configuration. Nothing behind you updates the central platform documentation, so the steps above
217
+ are the ones that matter.
207
218
 
208
219
  ## How to work
209
220
 
@@ -11,8 +11,10 @@ https://docs.klok.dev/klok-environment-build-ci-templates/llm.txt (datamodel pip
11
11
  ## Creating or changing a model
12
12
 
13
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`).
14
+ where the repository name is the model name in kebab case (`supplier-invoice-v1`). The XSD file has the same
15
+ name (`supplier-invoice-v1.xsd`), and so do the Maven artifact and the npm and Python packages; the Java package
16
+ ends in `supplier_invoice_v1`. Inside the XSD the model keeps its PascalCase form: root element
17
+ `SupplierInvoice_v1`, root type `SupplierInvoiceV1`.
16
18
 
17
19
  **Create it through klok.dev, or through the agent at https://agent.klok.dev** authenticated as the tenant
18
20
  with the right to create projects in the domain. That is the supported path: it creates the repository from
@@ -26,9 +28,9 @@ https://docs.klok.dev/klok-environment-build-ci-templates/llm.txt (datamodel pip
26
28
  (`klok-datamodel-project.json`, `klok-template.json`, the agent instruction files, the three page
27
29
  `klok-docs/datamodel/` layout).
28
30
 
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.
31
+ Vault needs nothing per project: the tenant CI role `<tenant>-ci` accepts every project under the tenant's
32
+ root group. If `publish_java_projects` fails at `auth/jwt/login`, the tenant itself is not set up; see the
33
+ `klok-release` skill.
32
34
  2. Write the XSD under `schema-definition-xsd/`: single `xs:` prefix, `targetNamespace` with `xmlns:tns`,
33
35
  `elementFormDefault="qualified"`, one root element `<Name>_vN` that references every complex type. Enumerations
34
36
  as `xs:enumeration`.
@@ -45,7 +47,8 @@ https://docs.klok.dev/klok-environment-build-ci-templates/llm.txt (datamodel pip
45
47
 
46
48
  * Run `./gradlew updateKlokLibsToml` in the consumer, commit the refreshed `gradle/klok-libs.versions.toml`, and
47
49
  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 generated class is `dev.klok.<tenant>.datamodel.<group>.<name_with_underscores>_v<n>.<Name>Vn` (for
51
+ `klok-task-event-v1`: `dev.klok.klok.datamodel.common.klok_task_event_v1.KlokTaskStatusEventV1`); the ODL type of an object is the
52
+ fully qualified class name, so moving a class to another package is a data migration of its ODL index.
50
53
  * The topic for the model is derived from the class (`persistent://<tenant>[_<env>]/<domain>/<Name>Vn`); do not
51
54
  invent topic strings.
@@ -30,7 +30,7 @@ drops the `klok-` prefix of the name (`klok-integration-strategy-and-tactics`).
30
30
  | Naming conventions, `klok-*` properties, CloudEvents attributes | `klok-framework-klok-common` |
31
31
  | Broker client configuration, subscriptions, request/reply | `klok-framework-klok-brokerclient-java` |
32
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` |
33
+ | CI templates, release process, Vault roles, documentation chain, catalog update | `klok-environment-build-ci-templates` |
34
34
  | ODL REST and request/reply, tasks API | `klok-integration-klok-api-opensearch` |
35
35
  | ODL writers, log receivers | `klok-integration-klok-egress-opensearch` |
36
36
  | Scheduled queries, stale task detection | `klok-integration-klok-ingress-opensearch` |
@@ -40,17 +40,19 @@ letting them surface as a red pipeline.
40
40
 
41
41
  ## Setting up a new project (what must exist)
42
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`.
43
+ * Nothing in Vault per project. Every job logs in with the tenant CI role `<tenant>-ci` (a Vault JWT role bound
44
+ to `namespace_path` `<tenant>` and `<tenant>/*`, carrying `default` and the tenant CI read policy
45
+ `<tenant>-cicd-read`). The templates set `VAULT_AUTH_ROLE: $KLOK_TENANT-ci`. A tenant without the role fails
46
+ every job at `auth/jwt/login` with `role "<tenant>-ci" could not be found`; the tenant setup is in
47
+ `klok-docs/ci/tenant-onboarding.md` of `klok/environment/build-ci-templates`, every credential and the step
48
+ that uses it in `klok-docs/ci/authentication.md` there.
48
49
  * For anything the pipeline resolves from a package registry (framework, plugin, datamodels): the project's
49
50
  top-level group must be on the package project's job token allowlist.
50
51
  * For a deployed service: a manifest under `klok/integration/<name>/`, the Kubernetes service account, a Vault
51
52
  Kubernetes role `<name>-role` with a policy reading `secret/data/<tenant>/integration/<name>/env`, and the env
52
53
  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
+ * Documentation projects need the tenant's docs upload client: Keycloak client `klok-docs-upload-<tenant>` and its
55
+ id and secret in `secret/<tenant>/common/repo/cicd-environment-variables`.
54
56
 
55
57
  Vault is changed by humans only: propose the exact `vault write` / `vault policy write` command with every existing
56
58
  field, and let the user run it.
@@ -59,8 +61,9 @@ field, and let the user run it.
59
61
 
60
62
  | Symptom | Cause |
61
63
  |---|---|
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
+ | `role "<tenant>-ci" could not be found` at `auth/jwt/login` | the tenant has no CI role yet (tenant onboarding) |
65
+ | `claim "namespace_path" does not match` at `auth/jwt/login` | the project is outside the tenant's root group, or `VAULT_AUTH_ROLE` names another tenant's role |
66
+ | `permission denied` reading `secret/.../cicd-environment-variables` | the CI role lacks the tenant CI read policy (has only `default`) |
64
67
  | `403` on `groups/<tenant>/-/packages/maven/...` | job token allowlist of the package project lacks the reader's group |
65
68
  | `Could not find dev.klok...:<version>` | the version is not published yet, or the catalog copy is stale (`updateKlokLibsToml`) |
66
69
  | `already deployed` from JReleaser | Maven Central already has that version; a `main` build is a new timestamp, do not retry the same job |