Skip to main content
Version: 0.4.0

Change a model safely

Rename, move and restructure a model without losing what is bound to its elements, and check each change before it is merged. The guide grows one small model, a shop, a step at a time, and every step is a whole model that builds with no error or lint: type it into model/ in a repository kq init made, and check it with kq validate or in VS Code as you type. Every step keeps the Ids of the step before. What an Id is, and why it lasts, is in Identity.

Commit the .g.kq with the change​

Every element has an Id that never changes, and renaming or moving an element keeps it. kq build, and VS Code on save, write the Ids into the model's .g.kq file, which holds the Ids that keep each element's identity across renames and moves. Commit it in the same commit as the change that made it. The shop to start from:

ecosystem shop "Shop" { domain selling "Selling" { function place-order "Place an order" function pay "Take payments" } platform storefront "Storefront" { component web-shop "Web Shop" : user-facing-app { spa web-shop-ui "Web Shop" } component order-service "Order Service" : backend component payments "Payments" : saas web-shop -> order-service/orders-api over http auth user-token order-service -> payments/payments-api over http auth key web-shop realizes selling/place-order order-service realizes selling/place-order payments realizes selling/pay } }

The order service's line in the .g.kq gives it its Id:

Component 30abfc8b-1977-45da-b899-88ecc7728ee2 "shop/storefront/order-service"

Before you merge, run the checks. Each of these writes nothing and exits with 1 when the model needs attention, so a pipeline can run them on every pull request:

CommandExits with 1 when
kq validateThe model breaks a rule
kq fmt --checkA file would change
kq build --checkA .g.kq file would change

See CI.

Rename with the editor​

Rename (F2) in VS Code renames an element's Code in its declaration, every reopening of it and every path naming it, and repoints the portal's pages in the same edit. A Code changed by hand is matched to its previous Id where the build can, and anything it cannot match is printed. Rename the order service to orders:

ecosystem shop "Shop" { domain selling "Selling" { function place-order "Place an order" function pay "Take payments" } platform storefront "Storefront" { component web-shop "Web Shop" : user-facing-app { spa web-shop-ui "Web Shop" } component orders "Orders" : backend component payments "Payments" : saas web-shop -> orders/orders-api over http auth user-token orders -> payments/payments-api over http auth key web-shop realizes selling/place-order orders realizes selling/place-order payments realizes selling/place-order } }

The .g.kq keeps its Id under the new path:

Component 30abfc8b-1977-45da-b899-88ecc7728ee2 "shop/storefront/orders"

Its connections and its realization keep their Ids too. See Identity.

Move with Refactor: Move​

Refactor: Move in VS Code moves an element to another parent, keeping its Id, and rewrites every path naming it. Move the payment provider into a platform of its own, finance:

ecosystem shop "Shop" { domain selling "Selling" { function place-order "Place an order" function pay "Take payments" } platform storefront "Storefront" { component web-shop "Web Shop" : user-facing-app { spa web-shop-ui "Web Shop" } component orders "Orders" : backend web-shop -> orders/orders-api over http auth user-token orders -> finance/payments/payments-api over http auth key web-shop realizes selling/place-order orders realizes selling/place-order } platform finance "Finance" { component payments "Payments" : saas payments realizes selling/pay } }

The payment provider has the Id it had in the storefront:

Component 1c10bdfa-c7b2-434b-8d09-e0d452bde995 "shop/finance/payments"

A move between plateaus is a different statement, written move legacy/payments to central/payments in the later plateau's block. See Plan a change over time.

Where next​

© 2026 Extenza Works. All rights reserved.