Skip to main content
Version: 0.4.0

What kq build adds

Kanoniq creates a few elements on your behalf. This page lists all of them, where they go, and what happens when they're no longer needed.

The rule​

Kanoniq only adds what a statement names, and only where nothing is declared at that path. It never removes, renames, moves or rewrites anything you wrote, and it never guesses what a statement left out. A statement missing something is an error, not a gap to fill.

Everything it adds goes into <name>.g.kq, marked derived. Your own files stay byte-for-byte as you wrote them.

A derived element is as real as one you wrote: it has an Id, it is committed, and you can refer to it.

What it adds​

An API a connection names​

web-shop -> order-service/orders-api over http

If order-service has no orders-api, Kanoniq creates one: an http-api for http, a grpc-api for grpc, a graphql-api for graphql, a web-socket-api for web-socket, a signal-r-hub for signal-r, an ipc-api for ipc, a mail-api for email, an snmp-api for snmp, an ldap-api for ldap. A payload format (over http/json) changes nothing about what is created, and in-process creates nothing, since it lands on the component itself. order-service itself must exist; only the last segment of a path is ever created. That last segment becomes the new API's code, so it can't be a reserved word: order-service/ldap is an error, not an API called ldap. Name it something else, such as order-service/auth, or write the word with an @, order-service/@ldap. The same goes for a channel. The same goes for a monolith that holds its interfaces itself: a -> mainframe/api over http creates api in the monolith mainframe.

extend shop/storefront/order-service { derived http-api orders-api }

A created API has a Code and no name, so diagrams show its Code. To give it a name or a description, declare it yourself:

component order-service "Order Service" : backend { /// Place, amend and cancel orders. http-api orders-api "Orders API" }

A user interface (spa, mobile-app, desktop-app) is never created this way. A sync over a protocol (from order-service over http) creates nothing either. Who starts it, the source or the holder, is read from what it carries.

A channel a statement names​

order-service -> processing over events/orders

If the broker events has no channel orders, Kanoniq creates one, of the broker's channel kind. The same happens for a one-sided connection (order-service -> events/orders) and a sync (root order from order-service over events/orders). Every statement naming the same channel shares it.

Declare the channel in its broker to give it a name.

A role a grant names​

orders -> payments/payments/api over http auth client-credentials via iam/platform-idp grant write

If the server workload identity of payments declares no role write, Kanoniq creates one there: an app-role, or a scope for a grant on an on-behalf-of call. Every grant naming the same role shares it.

Declare the role in the server's workload block to give it its value.

The initial plateau​

A model that declares no plateau gets one, derived plateau initial, with no name. Declare it yourself, plateau initial "As is", to give it a name; you must once you declare another plateau. It keeps its Id.

Where in time each element lives, from the plateau it enters to the one that removes it, is worked out on every build and never written down, but for a derived element entering a later plateau, which <name>.g.kq writes in that plateau's block. An API or a channel lives where a statement naming it does.

What it does not add​

Each of these must be written. Leaving one out is an error, not something Kanoniq completes:

  • A platform. Every component is written in a platform or a monolith. There is no default platform.
  • A storage. Data sits in a named sql, table, document, log, file or blob block in its component.
  • An origin. Mark at least one holding of each domain object origin.
  • A connection's target. a -> b to a component is an error; name the interface or channel.
  • Domain structure. A domain that gains a sub-domain while still holding functions is an error until you move them.

Orphans​

When you delete the statement that named a derived element, the element is not deleted. The next build marks it as an orphan and says so:

orphan: derived Interface shop/storefront/order-service/orders-api is named by nothing; name it or run kq prune

In <name>.g.kq it becomes derived orphan http-api orders-api. It still exists, references to it still resolve, and validation reports it as a warning (KQ103). In VS Code, a lens above it in <name>.g.kq says so; see What the model makes of a statement.

Derived elementOrphaned when
APINo connection names it
ChannelIt isn't declared in its broker, and nothing sends to it or receives from it
PermissionNo grant names it

A derived element whose every source is assumed is assumed too. That is computed on every build and never written in <name>.g.kq.

To keep it, name it again or declare it yourself. To remove it, run kq prune, which deletes every orphan and every unused Id, and prints each one. Removing is always your decision: kq build never does it.

Don't delete derived elements from <name>.g.kq by hand. If a statement still names one, the next build creates it again under a new Id, and anything bound to the old Id loses it.

Building twice changes nothing​

A build over a built model adds nothing, because everything named already exists. That makes kq build --check a reliable test in CI: it fails when someone changed the model without building it, or when the model has an error.

© 2026 Extenza Works. All rights reserved.