dev.klok.framework.common.KlokNamingConventions is the single Java implementation of the platform's names. The broker
client, the Quarkus extension (KlokTopicResolver) and the Klok Gradle plugin (klokTopics, klokTopicCheck, the
documentation scan) call it. Code in another language, klok.dev and the TypeScript and Python broker clients, implements
the same rules from the wire contract and runs its fixture cases. Nothing else builds these strings.
Names group when sorted alphabetically
The principle behind every standard on this page: the shared subject comes first and the variant last, so that what
belongs together stands together in any sorted list, whether that is a folder, a catalog, the ODL's types or a
repository group.
| Good |
Not |
AiUsageDailyV1, AiUsageMonthlyV1, AiUsageRowV1 |
DailyAiUsageV1, AiMonthlyUsageV1 |
klok-postmark-ingress, klok-postmark-egress |
klok-ingress-postmark, klok-egress-postmark |
It holds for classes, datamodels, projects and everything else that gets a name, so check a new name against its
neighbours before you choose it. A name already on the wire keeps its spelling until its next major version, since a new
name means a new class and a new topic.
Topics
A topic has a simple name derived from the datamodel class, and a full name that adds the Pulsar tenant and
namespace. Publish and subscribe always use the full name, so both sides resolve identically.
| Method |
Result |
Example |
topicNameAsyncMessage(payloadType, purpose) |
<Model> or <Model>_<purpose> |
CustomerV1, KlokOdlObjectEventV1_orders |
topicNameAsyncMessage(modelSimpleName, purpose) |
the same from the class simple name as a string |
used by tooling that has no class |
topicNameRequest(req, res, purpose) |
ReqRes_<Req>_<Res>[_<purpose>]_Request |
ReqRes_KlokOdlSearchV1_KlokOdlSearchResponseV1_Request |
topicNameResponse(req, res, purpose) |
ReqRes_<Req>_<Res>[_<purpose>]_Response |
ReqRes_KlokOdlSearchV1_KlokOdlSearchResponseV1_Response |
topicNameRequest(reqName, resName, purpose), topicNameResponse(reqName, resName, purpose) |
the same from simple names as strings |
|
fullTopicName(tenant, environment, domain, simple) |
persistent://<tenant>[_<env>]/<domain>/<simple> |
persistent://acme_test/finance/CustomerV1 |
dlqTopicName(topic) |
<topic>_DLQ |
persistent://acme/finance/CustomerV1_DLQ |
companionTopics(topic) |
the topics that exist with it: its _DLQ, and for a _Request topic also the _Response topic and its _DLQ; none for a _DLQ topic |
persistent://acme/finance/CustomerV1 → [persistent://acme/finance/CustomerV1_DLQ] |
simpleTopicName(topic) |
strips scheme, tenant and namespace |
CustomerV1 |
isFullTopicName(topic) |
true when the name contains :// |
|
parseTopicName(topic) |
the parts of a full or simple name |
persistent://acme_test/finance/CustomerV1_created → tenant acme, environment test, domain finance, model CustomerV1, purpose created |
Rules encoded in fullTopicName:
- The environment is a suffix on the Pulsar tenant:
acme_test, acme_dev. Production (prod, case insensitive) and a
blank environment give the bare tenant, so production topics have the shortest name.
- A blank domain falls back to
common (DEFAULT_DOMAIN). A tenant's requests to a platform service live in the tenant's
own namespace, in common unless the model belongs to a domain: persistent://<tenant>[_<env>]/common/KlokLogEventV6,
persistent://<tenant>[_<env>]/common/KlokAiTaskRequestV1_<taskType>. The platform worker is granted consume there
and takes the tenant from the namespace, never from the message. What the platform writes back for a tenant lives in
klok's namespace, one topic per tenant: persistent://klok[_<env>]/<domain>/<Model>_<tenant> (or _<account> where the
service has accounts, as mail does).
- The major version is part of the datamodel class name (
CustomerV1, CustomerV2), which is why a breaking datamodel
change is a new topic and never a silent schema change on an existing one.
- A name that is already full is returned unchanged, so callers may pass either form.
The purpose (called producer intention in the method signatures for historical reasons) separates streams of the
same datamodel with different meanings, for example the ODL object events of two scheduled queries. In the Quarkus
extension it comes from the route's topicPurpose() or the configuration key <RouteId>.topic.purpose.
The publisher chooses the purpose; a reader is never part of the topic name (decided 2026-10-06, replacing the
reader suffix of 2026-09-27). A topic is always <Model>[_<purpose>], never two suffixes. The purpose is an optional
suffix that the publishing side sets as a requirement of the solution, so that one general datamodel can serve several
flows, and the reader configures the same purpose to read that flow. A reader is identified by its subscription name,
which is its route id (KLK003E1_ChatWorker, DGR012E1_PersonecEmployment) and therefore carries the reader tenant's
short name. When content belongs to one reader, the publisher may choose that reader's tenant slug as the purpose:
persistent://konvoj/hr/PersonnelScheduleExportV1_degerfors is written by konvoj for Degerfors, and Degerfors' route
reads it through its own subscription. That is the publisher's choice, not a requirement for reading across tenants. The
rule behind access is unchanged, write narrow, consume wide: a tenant writes only in its own namespace, and others are
granted consume on named topics (framework development guide, Broker Access And Tenant Isolation).
parseTopicName(topic) is the reverse of the methods above. It takes a full or simple name apart into a
KlokTopicName: scheme (persistent), tenant, environment (prod when the Pulsar tenant has no suffix), domain,
simple name, and either the datamodel and purpose or, for request/reply, the request and reply datamodels and the side,
plus whether it is a dead letter topic. A name that breaks the rules (an empty segment, two purposes, an underscore in
the environment, a request/reply name without its side) is rejected. Tools that read topic names from the broker, such
as klok.dev's broker view, use it to tell which datamodel and flow a topic carries.
Topics are provisioned, never created automatically
Decided 2026-10-08. A topic on the Klok broker exists only when it is listed in its tenant's Pulsar file in Git,
ansible-master/playbooks/group_vars/all/pulsar_tenant_<tenant>.yml in klok/environment/klok-environment-setup (the
tenant slug with - written as _), and that file has been applied. The klok5 brokers enforce it with automatic topic
creation turned off (Pulsar's allowAutoTopicCreation, pulsar_auto_creation.allow_topic: "false" in
group_vars/pulsar_klok5/pulsar_broker.yml of that repository), so a client's first use does not create a topic.
Subscriptions are still created by their consumer: a subscription is the reader's identity, its route id, and the
consume grant already decides who may read. The rules are topics.provisioning and topics.companions in the wire
contract.
Companions. A topic never comes alone. Every topic has its dead letter topic <topic>_DLQ, and a request topic
ReqRes_<Req>_<Res>[_<purpose>]_Request has its _Response topic and that topic's _DLQ. They are created, listed and
granted with the topic, and nobody requests them on their own. A _DLQ topic has no companion. companionTopics(topic)
returns them:
| Topic |
Companions |
persistent://acme/finance/InvoiceV1 |
persistent://acme/finance/InvoiceV1_DLQ |
persistent://klok/common/ReqRes_KlokOdlSearchV1_KlokOdlSearchResponseV1_Request |
..._Request_DLQ, ..._Response, ..._Response_DLQ |
persistent://klok/common/ReqRes_KlokOdlSearchV1_KlokOdlSearchResponseV1_Response |
..._Response_DLQ |
persistent://acme/finance/InvoiceV1_DLQ |
none |
Where a consumer dead letters. The companion _DLQ is where the topic's own tenant and domain dead letter. A
service that reads a topic of another domain or tenant may not publish there (write narrow, consume wide), and its dead
letters are its own output, so it dead letters to the same simple name in its own tenant and domain; its tenant file
lists that _DLQ, which has no topic beside it to come with. A topic in the consumer's own domain or its tenant's
common keeps its companion. klok-original-topic keeps the source. The rule is messaging.deadLetter.topic in the
wire contract (decided 2026-11-23, klok-common#11, klok-quarkus-extension#76), and klok-quarkus-extension implements it
from 3.18.0:
| A consumer in klok/mail reads |
It dead letters to |
persistent://klok/mail/KlokMailOutboundV1 |
persistent://klok/mail/KlokMailOutboundV1_DLQ |
persistent://klok/common/KlokFileReceivedV1_mail |
persistent://klok/common/KlokFileReceivedV1_mail_DLQ |
persistent://klok/mailbox/KlokMailOutboundV1 |
persistent://klok/mail/KlokMailOutboundV1_DLQ |
persistent://konvoj/hr/PersonnelScheduleExportV1_klok |
persistent://klok/mail/PersonnelScheduleExportV1_klok_DLQ |
When a topic or a grant is missing
A client that fails on a topic says so with one of two error codes, both not retryable, because the same call fails
again until a person changes Git:
| Code |
Meaning |
Request link access |
TOPIC_MISSING |
the topic does not exist on the broker |
create |
TOPIC_ACCESS_DENIED |
the client's role holds no publish or consume grant on the topic |
the operation |
dev.klok.framework.common.messaging.KlokTopicProvisioning renders the message for both, from the templates in the wire
contract, so that every client says exactly the same thing. A message names the topic, the client's broker role
(service-account-<client id>), the operation, the link to request the topic or the access in klok.dev, who approves
it, and the entry to add by hand. For example:
TOPIC_MISSING: the topic persistent://acme_dev/finance/InvoiceV1_created does not exist, so service-account-acme-invoice-egress cannot publish on it.
Topics are never created automatically on the Klok broker. A topic exists only when it is listed in its tenant's Pulsar file in Git and that file has been applied; its _DLQ topic, and the _Response topic of a _Request topic, are created with it.
Request the topic in klok.dev: https://klok.dev/monitoring/broker/request?topic=persistent%3A%2F%2Facme_dev%2Ffinance%2FInvoiceV1_created&access=create
It is approved by a TenantAdmin of acme or a DomainAdmin of acme/finance.
By hand: add `- persistent://acme_dev/finance/InvoiceV1_created` under `topics:` in ansible-master/playbooks/group_vars/all/pulsar_tenant_acme.yml in the repository klok/environment/klok-environment-setup, in a merge request; after the merge it is applied on the broker.
More: https://docs.klok.dev/klok-framework-klok-common/common/naming-conventions/
The klok.dev base URL of the link is https://klok.dev, or KLOK_DEV_URL when that environment variable is set
(topicMissingMessage(topic, role, operation, klokDevUrl) takes it as an argument instead). The request page
/monitoring/broker/request is the request form of klok.dev's broker monitoring (klok/application/frontend-klok-dev).
The by-hand path in the same message works without klok.dev.
For a developer or an AI agent who meets the message: do what it says. Request the topic or the access through the
link, or add the line it names to the tenant's Pulsar file in a merge request. List the topic itself, never its _DLQ
or _Response companion: they come with it. Never create a topic or a grant directly through the broker's admin API:
Git is the truth, and such a topic is drift.
For an implementer of a client or a tool: take the tenant, domain and namespace from the topic name, never from the
message, and render the message with KlokTopicProvisioning (Java) or from topics.provisioning in the contract (any
other language). Run the cases in topic-provisioning-cases.json.
Permission vocabulary
Decided 2026-09-27 (klok-integration-strategy-and-tactics#11). Each word has one meaning, and the layers are never
mixed.
| Layer |
Words |
Where |
| What a service is |
ingress / egress |
repository names, route legs I and E, prose. Never a permission. |
| What a role may do on a topic or namespace (the Klok level) |
publish / consume |
grants, klok.dev, Ansible variables, documentation. Granted per topic or namespace, never per service type: an egress that publishes a send result holds publish on that topic. |
| Pulsar's own actions |
produce / consume |
only inside the grant command or API call; publish maps one to one onto produce. |
| klok.dev's integration context graph |
read / ingest |
ingest means writing into the context graph and nothing else. |
emit is not used for anything.
Context properties, MDC keys and log fields
A Klok context value has one name in three forms: the message property and HTTP header (klok-corr-global), the MDC key
(klok.corr-global, mdcKey) and the OpenSearch field and JSON console key (klok_corr_global, logField: every -
and . written as _). A route's own values follow the same rule (klok.file.name is klok_file_name). Fields that
are not Klok context keep the names the tools expect: @timestamp, message, log_level, logger, log_type,
kubernetes.*. The three correlation ids (klok-corr-global, klok-corr-platform, klok-corr-service) and the whole
field table are on Log fields and correlation.
Repositories and packages
| Method |
Result |
repoName(tenant, domainType, domainOrSystem, projectType, name) |
<tenant>[-<domainType>[-<domainOrSystem>]]-<typeShort>-<name> |
globalRepoName(tenant, projectType, name) |
same with DomainType.GLOBAL, which adds no segment |
publicRepoName(tenant, projectType, name) |
same with DomainType.PUBLIC |
projectPackageName(base, tenant, domainType, projectType) |
<base>.<tenant>.<domainType>.<projectType>, tenant omitted when the base already contains it as a segment (dev.klok, tenant klok) |
repoDisplayName(repoName) |
dash separated segments capitalised, klok-api-proxies becomes Klok Api Proxies |
Only integration and datamodel projects get the domain or system segment. Dashes and spaces are removed from tenant,
domain and project names and everything is lower case. ProjectType.shortName() gives the type segment (int, mdl,
app, gui, doc, lib); ProjectType.OTHER has no segment.
These methods predate the repository convention the platform decided on 2026-09-25: integration repositories are named
<tenant>-<system>-<type> (klok-postmark-ingress) and live under <tenant>/integration/domain/<domain>/. repoName
does not build that form, and no Klok component calls these methods today; only this library's
KlokNamingConventionsTest does. Aligning them is
klok-common#8.
The documentation naming, from a repository path to its documentation project and its doc id
(<tenant>/<group>/.../<repo> to <tenant>/documentation/<group>/.../<repo> and slug(<tenant>-<group>-...-<repo>)),
is not in klok-common. It has four ports that share one fixture file, docs-naming-fixtures.json: the Klok Gradle
plugin (DocsNaming), klok-cli (packages/cli/src/docs/naming.ts in klok-integration-agent), klok.dev
(lib/server/docs-naming.ts) and the documentation server (DocIdRules in frontend-klok-docs).
The separators and affixes are constants (PURPOSE_SEPARATOR, REQUEST_REPLY_PREFIX, REQUEST_SUFFIX,
RESPONSE_SUFFIX, DLQ_SUFFIX, PERSISTENT_SCHEME) and are stated in the wire contract.
Tests
The topic rules are fixture driven: src/main/resources/dev/klok/wire-contract/topic-naming-cases.json lists inputs and
expected results (including the calls that must fail), KlokNamingConventionsFixtureTest runs every case, and the
TypeScript and Python clients run the same file. Add a case there whenever a rule is extended, never only a Java
assertion. The messages for a missing topic or grant have their own cases, topic-provisioning-cases.json, run by
KlokTopicProvisioningFixtureTest. KlokNamingConventionsTest keeps the repository and package rules, which are Java
only.