@klok-integration/cli 0.6.235 → 0.7.248

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.
@@ -10,12 +10,16 @@ project exposes its whole content as a single markdown file, generated by znai (
10
10
  serves it to a browser session and to a GitLab personal access token, which is what klok-cli sends:
11
11
 
12
12
  ```
13
+ klok docs list # the projects you may read: doc id, title, description
13
14
  klok docs read <doc-id> # the markdown on stdout, one status line on stderr
14
15
  klok docs read <doc-id> --json # {docId, url, source, status, etag, fetchedAt, bytes, content}
15
16
  klok docs read <doc-id> --out x.md # to a file
16
17
  klok docs id [tenant/group/.../repo] # the doc id of a repository, this one by default
17
18
  ```
18
19
 
20
+ `klok docs list` reads the portal's index, so it is where to find the doc id of a project you do not know yet. A
21
+ docs server without the index answers 404; derive the doc id with `klok docs id` instead.
22
+
19
23
  Read it; it is the authoritative version of the repository's `klok-docs/` plus the generated route, datamodel and
20
24
  configuration pages. Do not answer from memory when a page exists. The answer is cached under
21
25
  `~/.cache/klok/docs/` with its ETag, so reading a page twice costs one conditional request; without network the
@@ -64,7 +68,8 @@ question is about what a project does.
64
68
 
65
69
  1. Run `klok agents update --check` once at the start of the task; on exit 5 run `klok agents update`, so the
66
70
  skills you read are the catalogs' current ones.
67
- 2. Identify the repositories involved and derive their doc ids (`klok docs id <path>`).
71
+ 2. Identify the repositories involved and find their doc ids: `klok docs list`, or `klok docs id <path>` for a
72
+ repository you know.
68
73
  3. `klok docs read <doc-id>` for each. Handle 404, 401 and 403 as the table says.
69
74
  4. Read the strategy documentation first when the task touches design or naming, and the *Onboarding a tenant*
70
75
  runbook in `klok-framework-development-guide` when it touches onboarding; read the framework documentation
@@ -17,21 +17,26 @@ roles and secrets, catalog update) before acting.
17
17
  dependency catalog; datamodels publish the generated artifact and update the catalog; integrations build and
18
18
  push an image and update the deployment manifest in `klok/environment/ipaas/ipaas-service-deploy-manifests`,
19
19
  which ArgoCD applies; documentation projects publish to https://docs.klok.dev.
20
- 3. Check the pipeline after every push:
20
+ 3. An integration's deploy waits for its broker topics: the job `klok_topic_check` (`./gradlew klokTopicCheck`) asks
21
+ klok.dev whether every topic the service needs exists and is granted, blocks the manifest update on `main` when
22
+ one is not, and only warns in a merge request pipeline. Before a merge, run `./gradlew klokTopics` and hand every
23
+ missing topic or grant over as a request in klok.dev (the link in the message), approved by its owner; the broker
24
+ never creates a topic, so there is nothing to wait out and no automatic creation to ask for.
25
+ 4. Check the pipeline after every push:
21
26
  `glab api --hostname git.klok.dev "projects/<id>/pipelines?per_page=3"`, then
22
27
  `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
28
+ 5. Framework changes across libraries are released in order: klok-common, broker client, extension. Wait for the
24
29
  catalog update of one before merging the next: the catalog's commit for that release, not the merge, which only
25
30
  starts the pipeline that produces it:
26
31
  `glab api --hostname git.klok.dev "projects/klok%2Fframework%2Fklok-gradle-dependency-catalog/repository/commits?ref_name=main&per_page=10" | jq -r '.[].title'`.
27
32
  A library that needs no change of its own is not released by hand: after each catalog update the job runs
28
33
  `klok catalog release-dependents`, which starts the pipeline of every framework library built against an older
29
34
  version of what was released (its log says which; `--dry-run --library <artifact>` shows it by hand).
30
- 5. **Never cancel, stop or restart a running job, pipeline or deployment without a human's explicit yes.** A
35
+ 6. **Never cancel, stop or restart a running job, pipeline or deployment without a human's explicit yes.** A
31
36
  release waiting on Maven Central or npm can take half an hour, and `main` pipelines queue behind each other or run
32
37
  in parallel, so a long wait is normal. Check the current time with `date -u` before judging how long anything has run. Report the
33
38
  job id, its run time, the last log lines with timestamps and what waits behind it, propose what to do, and wait.
34
- 6. Merging is the human's step. Hand it over as KLOK-AGENTS.md *Manual steps are handed over as a guide* says:
39
+ 7. Merging is the human's step. Hand it over as KLOK-AGENTS.md *Manual steps are handed over as a guide* says:
35
40
  every merge request with its link, whether the order matters and why, and for each later step the release
36
41
  result to wait for and the command that shows it.
37
42
 
@@ -42,7 +47,8 @@ project by hand — `glab api POST /projects`, or cloning the template and swapp
42
47
  fallback under *Git är sanningen*.
43
48
 
44
49
  Neither path provisions a pipeline schedule yet, nor for a deployed service the manifest, its Vault objects, its
45
- Keycloak client and its broker grants (see below; tracked in klok/application/frontend-klok-dev#41 and #42). Name
50
+ Keycloak client and its broker grants (see below; tracked in klok/application/frontend-klok-dev#41 and #42). Its
51
+ topics beyond the generic topic of each datamodel are requested in klok.dev and wait for an owner's approval. Name
46
52
  those human steps up front instead of letting them surface
47
53
  as a red pipeline. Vault CI login is not one of them: it needs nothing per project.
48
54
 
@@ -63,7 +69,9 @@ as a red pipeline. Vault CI login is not one of them: it needs nothing per proje
63
69
  hand before the first deploy, with the Kubernetes service account; a Vault Kubernetes role `<name>-role` (with
64
70
  `audience=https://kubernetes.default.svc`) and its policy `<name>-policy` reading
65
71
  `secret/data/<tenant>/integration/<name>/env`; the env secret itself (broker credentials, service specific
66
- keys); and the service's own Keycloak client with its broker grants.
72
+ keys); the service's own Keycloak client with its broker grants; and every topic `./gradlew klokTopics` lists, in
73
+ its owning tenant's Pulsar file and applied (requested in klok.dev, or a merge request to
74
+ `klok/environment/klok-environment-setup`). A topic's `_DLQ` and a `_Request` topic's `_Response` come with it.
67
75
  * Documentation projects need the tenant's docs upload client: Keycloak client `klok-docs-upload-<tenant>` and its
68
76
  id and secret in `secret/<tenant>/common/repo/cicd-environment-variables`.
69
77
 
@@ -84,3 +92,8 @@ field, and let a person run it.
84
92
  | `already deployed` from JReleaser | Maven Central already has that version; a `main` build is a new timestamp, do not retry the same job |
85
93
  | `sed: can't read klok/integration/<name>/<name>-crds.yaml` | no deployment manifest for the service yet |
86
94
  | `cannot run ssh` | the job needs `openssh-client`; the templates install it before pushing over SSH |
95
+ | `klok_topic_check` fails with `TOPIC_MISSING` | a topic the service needs is not in its tenant's Pulsar file: request it with the link in the output, an owner approves |
96
+ | `klok_topic_check` fails with `TOPIC_ACCESS_DENIED` | the service's broker client holds no grant on the topic: request `consume` (or `publish` in its own tenant) with the link |
97
+ | `klok_topic_check` fails with `NOT_APPLIED` | the entry is merged but not on the broker yet: the next *Ensure* run in klok.dev applies it |
98
+ | `klok_topic_check` says to configure `KLOK_DEV_URL` or `KLOK_INTEGRATION_CONTEXT_TOKEN` | the CI environment object lacks them; a person adds them in Vault |
99
+ | a pod restarts with `broker topics are missing or not granted; this service cannot start` | the startup check found the same problems; follow each entry of the report, then restart the deployment |
@@ -20,7 +20,8 @@ motivates.
20
20
  2. **Name it.** `<TENANTSHORT><NNN><LEG><seq>_<Description>`, one class per route, the solution number from the
21
21
  portal registry. Sub routes are `S`, timers `T`.
22
22
  3. **Bind the datamodels** as type parameters; take them from the catalog bundle, never hand written DTOs.
23
- 4. **Choose the topic purpose** of every topic the route publishes or consumes (next section).
23
+ 4. **Choose the topic purpose** of every topic the route publishes or consumes (*Topic purpose*), and make sure every
24
+ topic exists (*Topics on the broker*): the broker never creates one.
24
25
  5. **Configure** through `routeConfig("key", default)` / `requiredRouteConfig("key")` and document every key in
25
26
  `application.properties` as `<RouteId>.<key>`. Reserved keys: `enabled`, `logevents.*`, `retry.*`, `dlq.*`,
26
27
  `topic.*`, `subscription.*`, `claimcheck.*`.
@@ -89,10 +90,42 @@ the purpose.
89
90
  The user guide page *Topic Purpose: One Datamodel, Several Flows* (`klok docs read klok-user-guide`)
90
91
  explains the reasons and the naming in full.
91
92
 
93
+ ## Topics on the broker
94
+
95
+ The broker creates no topics. A topic exists when its owning tenant's Pulsar file in
96
+ `klok/environment/klok-environment-setup` (`ansible-master/playbooks/group_vars/all/pulsar_tenant_<tenant>.yml`)
97
+ lists it and the file has been applied; its `_DLQ`, and for a `_Request` topic its `_Response`, come with it.
98
+ Subscriptions are created by their consumer. klok.dev declares the generic topic `<Model>` of every datamodel; a
99
+ purpose topic, a request/reply pair and a grant on another domain's or tenant's topic are requested.
100
+
101
+ 1. **List.** After adding or changing a route, a purpose, a subscription or an override, run `./gradlew klokTopics`
102
+ and read `build/klok-topics/topics.json` (not the console). Every entry in `warnings` is work: make the purpose,
103
+ subscription or override something the scan can read (configuration or a constant), or name the topic in the
104
+ merge request yourself.
105
+ 2. **Check.** With `KLOK_INTEGRATION_CONTEXT_TOKEN` set, run `./gradlew klokTopicCheck --report` and read
106
+ `build/klok-topics/topic-check.json`. `TOPIC_MISSING`: the topic is not in Git. `TOPIC_ACCESS_DENIED`: the service's
107
+ broker client (`service-account-<klok.broker.auth.client-id>`) holds no grant. `NOT_APPLIED`: in Git, not yet on
108
+ the broker; nothing to request.
109
+ 3. **Add what is missing, through the request.** For each problem, hand the person the request link from the message
110
+ (`https://klok.dev/monitoring/broker/request?topic=…&access=…`) and who approves it (a TenantAdmin of the owning
111
+ tenant or a DomainAdmin of its namespace), or, when the task asks for it, open the merge request that adds the
112
+ exact line the message names to the owning tenant's Pulsar file. List the topic itself, never its `_DLQ` or
113
+ `_Response`. Both are manual steps in your hand-over guide; the deploy waits for them.
114
+ 4. **When a service does not start,** its log has one report from `KlokTopicCheck` with an entry per missing topic or
115
+ grant, each ending with the request link and the line to add by hand. Do what each entry says; never work around
116
+ it.
117
+
118
+ `klok.broker.verify-topics=false` is only for a local broker that creates topics itself, never in a deployed service.
119
+ A route that consumes another tenant's topic cannot write that topic's `_DLQ`; say so in the design, and set
120
+ `<RouteId>.failure.unresolved` deliberately (open question klok/framework/klok-common#11).
121
+
92
122
  ## Things that are always wrong
93
123
 
94
124
  * A route id that does not start with the solution id, or two routes with the same id.
95
125
  * Publishing to a hand written topic string; use the resolver and the datamodel.
126
+ * Asking for automatic topic creation, creating a topic or a grant through the broker's admin API, or retrying a
127
+ `TOPIC_MISSING` or `TOPIC_ACCESS_DENIED` failure as if the broker were down; the topic is requested and approved
128
+ through Git.
96
129
  * Consuming a shared topic and discarding the messages of other flows (a filter on a payload field, an ODL lookup
97
130
  per message) where the producer could publish the flow with a topic purpose.
98
131
  * A purpose with `_`, a version or an environment in it, a second suffix after the purpose, a tenant in it that the
@@ -74,8 +74,9 @@ shared platform service) in `klok/integration-solutions`.
74
74
  * When the document and the code disagree, the code on `main` is what is built: correct the document. When the code
75
75
  differs from what was agreed, file an issue in the owning project and name it in the document's open questions.
76
76
  * The deployed landscape counts too: a leg that is on `main` but not deployed, or deployed from somewhere the
77
- document does not name, is written down. Deployment manifests are in `klok/environment/ipaas-se-deploy-manifests`,
78
- hosts and stateful services in the Ansible inventories of `klok/environment/klok-environment-setup`.
77
+ document does not name, is written down. Deployment manifests are in
78
+ `klok/environment/ipaas/ipaas-service-deploy-manifests`, hosts and stateful services in the Ansible inventories of
79
+ `klok/environment/klok-environment-setup`.
79
80
 
80
81
  ## Things that are always wrong
81
82
 
@@ -35,7 +35,8 @@ basename, never put the worktree inside `.claude`, inside the canonical checkout
35
35
  work on. A worktree under `<root>/worktrees` does not sit below those directories, so no tool loads them for
36
36
  you. Keep the existing project rules; this skill does not replace them.
37
37
  3. **Inspect, do not touch.** `git -C <canonical> status --short`, `git -C <canonical> worktree list --porcelain`
38
- and the canonical branch. Never `stash`, `reset`, `clean`, `checkout` or `switch` there. Uncommitted changes in
38
+ and the canonical branch. Never `stash`, `reset`, `clean`, `checkout` or `switch` there; the only update of a
39
+ canonical checkout is `klok sync pull`, which fast-forwards it or reports why it cannot. Uncommitted changes in
39
40
  the canonical checkout are not a blocker; the worktree starts from committed history. If the task depends on
40
41
  those changes, say so and ask for a handoff instead of moving them.
41
42
  4. **Choose the base.** Fetch the remote and resolve its default branch from the remote HEAD