Skip to main content
Version: Next

kq arrange

Rewrites the model into the conventional layout: a file per Ecosystem in model/, then a folder per Ecosystem holding domains.kq, motivation.kq for the motivation blocks of the Ecosystem and its Domains, and a file per Platform or monolith, and a folder per Platform or monolith holding the motivation blocks of the Platform and its modules and Components in motivation.kq, each Domain's software in <domain>.s.kq, its data in <domain>.d.kq and its identities and roles in <domain>.i.kq. A component goes with the top-level Domain above its primary Domain: the one Domain its realizations lead to, or, where they lead to several, the Domain of the realization marked primary. What belongs to no single Domain goes in files named after the Platform or monolith, and so does a component that realizes nothing. An Ecosystem's environments line stays in its file, and database servers and the rest of the infrastructure go where brokers do, a pool with its server. An Ecosystem's job roles go in <ecosystem>.i.kq in its folder, its processes, its Domains' included, in processes.kq, and its scenarios in scenarios.kq. Every file in a folder starts with scoped. See Splitting a model.

kq arrange [options] <path>...

Arguments

ArgumentIs
<path>...A file or folder of each model to arrange.

Options

OptionDoes
--checkWrite nothing; list what would be created, rewritten, renamed or deleted, and exit 1 if anything would.

Environment

VariableDoes
KANONIQ_TELEMETRYoff, 0 or false stops kq reporting the run; so does DO_NOT_TRACK=1.

Exit codes

CodeMeans
0Done
1Failed: the model has an error, a check found a change, or a file could not be read or written
2Usage error: an unknown command or option, a missing or extra argument, a path that does not exist, or an output folder kq will not clear

A model with plateaus gets a plateaus/ folder: 000-<code>.kq holds the first plateau's declaration alone, and 001-<code>.kq, 002-<code>.kq and on each later plateau's whole block, numbered in order. The layout above holds the first plateau's state. A before block is rewritten forward: the earlier plateau becomes the first, and the later one a block after it.

A monolith is arranged as a Platform is: its declaration and its modules go in its own file, and its components by their Domain in its folder. What a monolith holds itself, its interfaces, storages and statements, goes where a component's would. A user interface that no component serves goes in the software file named after the Platform or monolith it sits in. An identity goes in the .i.kq beside its identity provider's software file, and a role beside its application's, each with its component or monolith reopened there; the idp mark stays on the declaration in .s.kq. A workload identity goes in the .i.kq beside its component's software file too, with its roles; one a platform holds stays in the platform's software file. The model's policies go in policies.kq at the top of model/, and each Ecosystem's in <ecosystem>/policies.kq, those written on a platform or a component in an extend block by path, then the Ecosystem's exemptions.

kq arrange models/shop

It creates the files and folders the layout needs, deletes every other .kq file in the model except <name>.g.kq, and removes the folders it empties. A file that fits no place in the layout is dissolved: what it declares moves where the layout puts it. A plateau's file whose number changes, or a file whose text moves unchanged to another path, is renamed. In a git repository, a tracked file it renames or deletes goes through git mv or git rm, so git status shows a rename as a rename; new files are left for you to add. It refuses a model that doesn't parse or link; validation findings don't stop it. Comments and blank lines move with what they sit above; one that has nowhere to go stops it (KB054), and nothing is written. Ids are untouched: <name>.g.kq is the same before and after. A second run changes nothing.

Its first run sets "arranged": true in kanoniq.repository.json, changing nothing else in the file, its comments included. From then on kq build, kq validate and the editor report any file out of place as an error, KB024, that says to run kq arrange first: a file in a folder the layout has no place for, or a declaration in a file other than its own. The model is still built and its Ids kept. Remove the setting, or set it to false, to stop the checking.

With --check it writes nothing, lists what it would create, rewrite, rename or delete, and exits 1 if there is anything.

© 2026 Extenza Works. All rights reserved.