One library, no framework dependency
Names and property keys are the contract between components written in different languages and at different layers.
Keeping them in a library with no Camel, Quarkus or Pulsar dependency means the gradle plugin, the portal and CI scripts
can depend on it without dragging the runtime in. Anything that needs Camel belongs in the Quarkus extension, anything
that needs Pulsar in the broker client.
The build follows from this: it resolves from Maven Central only and declares no GitLab package registry, so building
the library needs no token, and no build output ever contains one. Only publishing in CI uses the job token.
The wire contract is data, the Java constants implement it
Mirroring Java constants "line by line" into another language is how the 1.x TypeScript and Python clients drifted
(different topic separators, different property names, JSON instead of Avro). Since 0.3.1 the contract is a JSON file
with fixture cases, published with the library; the Java constants are asserted against it and every other client
vendors and verifies the same files. A change to a name is a change to the file first, and the parity tests tell every
implementation what to update.
Full topic names everywhere
1.x published to short names and subscribed to full names, which only worked because the broker defaulted the tenant.
2.0 resolves the full name (persistent://<tenant>[_<env>]/<domain>/<simple>) once, in fullTopicName, and both the
broker client and the extension pass full names around. The environment is a suffix on the Pulsar tenant rather than a
namespace level, so a namespace stays <domain> and the production name is the shortest form.
The datamodel major version is in the class name
CustomerV1 and CustomerV2 are different classes, different topics and different Avro schemas. A breaking change
therefore never surprises a consumer of the old topic, and a topic name is enough to know which schema to expect.
klok-* property names, one spelling
The same string is the HTTP header, the Pulsar property and, in derived form, the MDC key (klok.) and the CloudEvents
extension (klokcorrelationid). The 1.x names (klokChainId, e2eid, globalid) had three different spellings for
the same id and one of them was never propagated by Camel's MDC pattern. The legacy names are still written by the Java
broker client until 0.4, for the integrations that are still on the 1.x extension; the new TypeScript and Python clients
start clean and never use them.
CloudEvents binary mode, not structured
The payload stays the typed datamodel and the CloudEvents attributes travel as ce-* properties. A consumer that does
not care about CloudEvents reads exactly the same message as before, and Avro schemas stay per datamodel instead of one
envelope schema with a blob inside.
The retry defaults grow beside the old ones (0.3.6)
The platform's principles of error handling (2026-11-05) give a route that answers its caller no retries by default, and
a failure that says try later about 15 minutes on a route that consumes from the broker. The contract says so in new
objects, transientRetryDefaults, syncRetryDefaults and syncRetryLimits, and leaves retryDefaults as it was.
Changing retryDefaults itself would have been shorter to read, but the Python and TypeScript broker clients compare
their own defaults with that object as a whole, against the newest contract their build vendors, so one more field there
would turn their pipelines red at the moment this library is released. They also have no error codes to tell a transient
failure by, so for them every failure is still a retryDefaults failure. Nothing changes meaning, so the contract stays
version 1.
A pending reply is kept as long as its requester waits (pendingReplyLifetime). The fixed pendingReplyTtlMs it
replaces is gone rather than kept beside it: no client read it, each had the number in its own code, and keeping a value
that describes the bug would invite the next client to copy it.
Timestamped versions, catalog driven consumers
Releases are <major.minor.patch>+<timestamp> and every main pipeline is a new, unique release. A plain version would
have to be bumped by hand and can never be republished (Maven Central is immutable). After each release the CI writes
the version into the dependency catalog, and consumers refresh their catalog copy with the gradle plugin instead of
editing version numbers.
No helper without a user
A helper lives here only while at least two modules use it. 0.3.5 removed PlanningPokerEstimator, which was documented
as used by the portal, but the portal is TypeScript and never called it. KlokSymmetricEncryption has no user either
but stays, by decision, as the shared implementation for encrypting caller ids.
Write narrow, consume wide
Decided 2026-09-27. A tenant publishes only in its own Pulsar namespace. Another tenant, or a shared platform worker in
tenant klok, is granted consume on the specific topics it may read, and nothing ever holds publish in another
tenant's namespace. The namespace therefore always names the writer, so no message field has to say whose data it is (a
tenant field can be set to anything by whoever may publish on the topic); a tenant that floods a topic fills its own
quota; and an external party such as a scheduling vendor never gets write access into a customer's namespace. The
platform services follow the same rule: a tenant's log events, mail requests and AI requests live in the tenant's
namespace and the klok worker consumes them, while what the platform writes back lives in klok's namespace, one topic
per tenant. Two costs are accepted: a slow reader's backlog grows in the writer's namespace, and a worker that serves
many tenants subscribes to a list of topics, because a pattern subscription cannot span namespaces. The whole model,
identities and grants included, is in the framework development guide, Broker Access And Tenant Isolation.
The publisher chooses the purpose, the subscription names the reader
Decided 2026-10-06, replacing the reader suffix of 2026-09-27, which appended the reader's name after the purpose. A
topic is always <Model>[_<purpose>]. The purpose exists so that one general datamodel can serve several flows; it is
part of the solution's design, set by the publishing side and matched by the reader. A reader is identified by its
subscription name, its route id, which carries its tenant's short name. The reader suffix put two optional suffixes on
one name although a purpose may not contain an underscore, made a topic's name depend on who reads it, and duplicated
what the subscription already says. A publisher whose content belongs to one reader may still choose that reader's
tenant slug as the purpose (PersonnelScheduleExportV1_degerfors). parseTopicName reads every name back into its
parts, and the wire contract carries its cases so that every language agrees.
Clients announce their route, instance and concurrency to the broker
Decided 2026-10-06. A broker client attaches klok-route-id, klok-instance and, on a consumer,
klok-subscription-concurrency as Pulsar consumer and producer properties (messaging.clientMetadata in the wire
contract, KlokClientMetadata in Java). The broker shows them in the topic stats, so a tool that reads the broker sees
which route and pod consume or publish and the concurrency that is really in effect, including one set from the
deployment's environment that no file in Git shows. The alternative, having every service report itself to klok.dev or
the ODL, needs a new datamodel, a new route in every service and a store that can go stale; the broker's own stats are
live and need nothing but the client to say who it is.
@KlokDocs is a source annotation in klok-common
Decided 2026-09-29. Documentation generated from a route's source alone hallucinated what the classes it calls do, so
important project classes are marked with dev.klok.framework.common.docs.KlokDocs and the Gradle plugin gives them
their own pages and gives the routes that use them their source. The annotation follows this library's package
convention (dev.klok.framework.common.<area>), has CLASS retention because only the plugin's source scan reads it,
and lives here rather than in the Quarkus extension so that any Java project can use it without Camel. See The
@KlokDocs annotation.
Klok knowledge is bundled at build time and read once
Decided 2026-09-30. The same platform knowledge was restated by hand in many prompts (the Kloker gateway, the agent
runner, klok.dev, the documentation egress), and the copies drifted into teaching retired rules. The blocks are now
written once in klok-integration-agent and travel the existing catalog pipeline in klok-agents.zip; the Gradle plugin
bundles them into each service at build time and KlokKnowledge reads them once at start. We chose the build over a
runtime fetch from GitLab (a runtime dependency on every AI request) and over the ODL (a database call, and Git is the
truth). The blocks are indexed in klok-knowledge.properties because a classpath directory cannot be listed reliably
inside a jar. A missing block fails only the call that asks for it, so a service builds and starts before the catalog
carries a new block. See Klok knowledge.
Replies are addressed to one reply subscription
Decided 2026-10-06. Request/reply uses one shared response topic per pair and a reply subscription per requester,
because a reply must reach the instance that waits for it (a shared subscription cannot promise that), and a topic per
instance would name its reader, could not be created in advance or granted in Git, and would multiply topics with every
pod. The cost of the shared topic was that every live requester received every reply. Rather than give that up, the
request now names its reply subscription (klok-reply-subscription), the replier keys the reply with it, and a broker
entry filter delivers each reply only to that subscription. We chose the broker filter over Key_Shared with sticky hash
ranges (a dead pod's range would stall in a backlog) and over a partitioned response topic read by pod ordinal (it would
tie deployments to StatefulSets and replica counts to partitions). The reply subscription is non-durable, so it ends
with its process. See Wire contract, request/reply.
Topics are provisioned, and a missing one says how to get it
Decided 2026-10-08. Topics on the Klok broker are never created on first use; a topic exists only when it is listed in
its tenant's Pulsar file in Git and applied, together with its companions (_DLQ, and _Response for a _Request
topic). Automatic creation made every typo a new topic, left topics nobody had decided on, and could not be granted in
advance, since Pulsar grants only on an existing topic. Subscriptions are still created by their consumer, because the
subscription is the reader's identity and the consume grant already decides who may read. The companions are a rule
rather than entries of their own, so nobody has to remember the dead letter topic that is otherwise first needed on the
day a message fails.
The cost is that a forgotten topic now fails where it used to work. That is why the two failures, TOPIC_MISSING and
TOPIC_ACCESS_DENIED, are not retryable (retrying a missing topic as if the broker were down hid the cause) and why
their message is part of the wire contract: it names the topic, the role, the operation, who approves, the klok.dev
request link and the exact line to add by hand, in the same words from every client, so that a developer or an AI agent
can act on it without looking anything up. The templates live in the contract rather than in each client because four
implementations in three languages would otherwise drift apart. See Naming
conventions.
A consumer dead letters in its own namespace
Decided 2026-11-23 (klok-common#11, klok-quarkus-extension#76). Under write narrow, consume wide a service reads another
domain's or tenant's topic with a consume grant on that one topic and never publishes there, so it cannot write that
topic's companion _DLQ. Its dead letters go to the same simple name in its own tenant and domain
(messaging.deadLetter.topic in the wire contract); a topic in its own domain or its tenant's common, where it may
publish, keeps the companion. The dead letter is the reader's failure, handled by the reader's team under the reader's
grants, and klok-original-topic keeps the source. Granting the reader publish on the owner's _DLQ (the issue's
second option) was not taken: it breaks write narrow. Sending every dead letter to the reader's own domain, common
included, was not taken either: it moves dead letters that already sit where the reader may publish and would need a new
topic for each, for no gain. The cost is that such a _DLQ has no topic beside it and is listed on its own in the
reader's tenant file. Why the Quarkus extension implements it this way is in its design decisions (A route's dead
letters are its own; so is an offramp's result).
Three correlation ids, and one name for a field in every log (0.4.0)
Decided 2026-11-16. A chain is followed at three widths, klok-corr-global, klok-corr-platform and
klok-corr-service, and every Klok context value has one name in OpenSearch, the property name with - and . written
as _ (klok_corr_global, klok_route_id). The rules are on Log fields and
correlation.
Why three ids. Until 0.4.0 one id, klok-correlation-id, had to be all of them. It was created by Klok, so a caller
that sent its own x-request-id or traceparent could not find its call in our logs, and a call that left Klok and
came back started a chain nobody could join to the first. Taking the id from the caller fixes the first, but then the id
is no longer ours: a caller may send the same id with every request, and one id would merge unrelated work. So the id
that may come from outside, and goes out again, is the global id; the platform id is always ours and never leaves the
broker, so it marks one pass through Klok; and the service id marks what one service did with one input, which the
invocation ids did not, since one input often runs several invocations (sub routes, request/reply). We weighed two ids
(global and platform) against three: without the service id, finding what one service did with one message meant reading
invocation and parent ids by hand.
Why this header order. Klok's own names come first, so a chain inside Klok is never broken by a header a caller
happened to send. W3C traceparent comes next because OpenTelemetry is the standard a caller most likely has, then an
arriving Camel breadcrumbId, then the correlation and request ids of common gateways and tracers. A value is used only
when it is 1–128 characters of a small, safe set: an id goes into Pulsar keys, headers, log lines and keyword fields,
and a value with spaces, separators or a kilobyte of text is someone else's payload. An unusable value falls through to
the next source rather than failing, since a broken header must never stop a call. The order and the cases are in the
wire contract, so that Java, TypeScript and Python pick the same id from the same headers.
Why one field name. The transaction, event and console documents used different names for the same value
(correlation_id, chain_id_global, a bracket in the console text, route_id against route_ids, severity against
log_level), so one OpenSearch Dashboards table or one query could not show a chain's transaction, events and console
lines together. A rule (logField) beats a table: a route's own klok.file.name gets its field without anybody adding
a mapping. Fields that are not Klok context keep the names the tools already expect (@timestamp, message,
kubernetes.*).
Why JSON on the console. In a cluster a service writes JSON so that every MDC value reaches OpenSearch under its
field name without the shipper parsing text by position, which could only ever carry six brackets. Text stays in dev
mode and tests, where a person reads it.
What was accepted. Breaking changes: the whole fleet is rebuilt, and indexes keep their old names until the 30 days
of retention remove them. The contract file stays klok-wire-contract-v1.json, although names change meaning: every
client is released with this change anyway, and a new file name would only make every vendored copy rename a file.
During the transition every publisher still writes klok-correlation-id with the value of the global id and every
reader falls back to it, so old and new services keep one chain. That ends when no service publishes KlokLogEventV4
(klok-common#12). klokChainId stays the alias of
klok-correlation-id rather than becoming one of klok-corr-global: both are earlier names of the global id, written
and retired together.