04 What Klok Dev Does In Git

What klok.dev Does In Git

klok.dev is a layer on top of Git. It guides you to make a change the way Klok's standards say, with the right names, from the right template, reviewed by the right people, but the change itself lands in GitLab, where anyone could have made it by hand. This page shows what each kind of action writes and where, so that nothing klok.dev does is hidden, and so that you know how to do the same without it.

klok.dev writes to Git only through the GitLab API: it clones nothing and holds no SSH key. Every commit message and merge request title it writes is a Conventional Commit, the same as a person's.

Four Ways A Change Lands

Way When Examples
1. Your draft, then a merge request You change something that is described in Git: a solution, a system, a datamodel, an integration project Edit, then Review → Create merge request
2. Created at once Something that has nothing to review yet, or is itself a conversation New integration, New model, New system (its GitLab group), a change request, a question, a comment
3. Merged by klok.dev after an approval The approval is the review Broker → Requests → Approve and apply
4. Outside Git State that is not Git's to hold ODL records and settings, process definitions, people's groups in Keycloak, Kloker's tasks

1. Your Draft, Then A Merge Request

The item pages (Solutions, Systems, Datamodels, Integration projects) work the same way. Edit changes the item's files as your draft, which only you see and which is kept in klok.dev, not in Git. Review shows every changed file, what the pipeline would refuse, the merge request's title and description, and who merges it. Then:

Action What lands in Git
Create merge request (on Review) Your draft as commits on a branch klok-dev/<item>-<first 8 characters of the draft's id>, started at the commit your draft started from, and a merge request to main with your Conventional Commits title
Save to branch only (on Review) The same branch, without a merge request
Continue locally (in the page header) Your draft pushed to its branch when it has changes, and the commands to clone the repository and go on in your own editor

A person with the role for the item merges the merge request in GitLab; klok.dev never merges an item's merge request itself. A new solution is the one case where the merge request does more: opening it reserves the solution's id (Solutions).

2. Created At Once

Action in klok.dev What lands in Git
New integration → Create the project The repository <tenant>/integration/<group>/<tenant>-<system>-<type> from project-template-integration, as one commit chore: initialize <name> from project-template-integration [skip ci] on main, which is then protected; its documentation project; and a merge request feat(<name>): add the deploy manifest of <name> adding <project path>/<name>-crds.yaml, with replicas: 0, to klok/environment/ipaas/ipaas-service-deploy-manifests, for a person to merge
New model → Create the datamodel The repository <tenant>/datamodel/<group>/<model>-v<n> from project-template-datamodel, as one commit on main the same way; the tenant's root group on its CI job token allowlist, so the consumers' pipelines may read its packages; its generic topic in the tenant's Pulsar file, which klok.dev merges (section 3); and its documentation project
New system The GitLab group <tenant>/datamodel/system/<system> at once; the system's documentation follows from its Review as a merge request docs(systems): document <name>
New change request, Ask a question, Add issue Issues in <tenant>/integration-solutions (a change request labelled change-request, solution:<ID> and change:<kind>; a question labelled question) or in a project, linked to the change request
Build this and Save on a change request's design A commit docs(<ID>): approve the plan of <registry>#<iid> on the open design merge request, or a small merge request of its own once the design is merged
Close on a change request; a Kloker task finishing, failing or waiting for an answer A comment on the change request, and for Close the issue closed
New image on an integration project klok-docs/project-image.json with the next revision, on the default branch or as a merge request when it is protected
Save on Documentation → Visibility klok-documentation-settings.json at the root of the documentation project, committed to its default branch as chore(docs): set visibility of <doc-id> to <level>
Share with a tenant on an integration project's or a datamodel's Overview The project shared with the tenant's root group as Reporter and the group on its job token allowlist, in GitLab's settings, at once; and in the documentation project a merge request chore(docs): share <doc-id> with <tenant> that changes sharedWith in klok-documentation-settings.json, for a person to merge
Create domain The GitLab groups <tenant>/datamodel/domain/<domain> and <tenant>/integration/domain/<domain>, and a merge request adding the domain's namespace to the tenant's Pulsar file, left for a person to merge

A repository is created on main with [skip ci], so nothing builds or deploys before the first real change, and main is protected from then on: every later change is a merge request.

3. Merged By klok.dev After An Approval

A request for a topic or for access to one is reviewed by the topic's owner in klok.dev. When the owner chooses Approve and apply, klok.dev writes a merge request to the owning tenant's Pulsar file in klok/environment/klok-environment-setup, such as feat(pulsar): grant <reader> consume on <topic>, merges it itself and applies it to the broker. The approval is the review; the merge request is the record of it in Git, and Ansible, run by a person, applies the same file. A topic or grant made only in the broker's admin API, outside the file, is drift. See Broker.

klok.dev merges two other kinds of Pulsar-file changes itself, because a rule decides them and nobody would review them differently: the generic topic of a datamodel, when the model is created or when a build needs it, and the change-event topic of an ODL type, which it declares before the first record of that type is written. After a build on main, klok.dev also asks for any other topic or grant the project's routes need and lack: a request like a person's, with klok.dev as the requester and the project named, which waits for the owner's Approve and apply the same way. Everything else klok.dev opens as a merge request is merged by a person: drafts, solution reservations, plan approvals, a new domain's namespace and a tenant's onboarding.

4. Outside Git

Action in klok.dev Where it lands
Editing or deleting a record under Operative data, saving a process definition, cancelling a run The tenant's ODL and task API, with your own login; cancelling publishes a cancel command to the run
Saving Logs → Settings or Documentation → Generation The tenant's settings object in tenant klok's ODL
Saving a file flow The flow's record in the tenant's ODL; its secrets sealed in klok.dev's server first
Adding a person, changing their roles or appointing a domain owner under Tenant → People Their account and groups in Keycloak, and their user and memberships in GitLab; a removed person's GitLab user is blocked, not deleted
Sending a broker request, or klok.dev asking for what a build needs A request row in klok.dev, and a mail to the topic's owners; nothing in Git until it is approved
Starting a Kloker task The Klok Integration Agent, whose own writes end as merge requests, issues and comments a person reviews
Saving a business case under Business cases A new version of the case in klok.dev's own database; why a solution exists goes into its document through Ask Kloker to write why it exists and a merge request

What klok.dev Keeps Itself

klok.dev's own database holds two kinds of rows. Copies of Git and of the builds, each with a way back to main: the solutions (read again when the list opens and the last check is more than five minutes old), the datamodel library (read again when a model's latest commit moves), and the context graph (updated by every build). Its own records, which are not Git's to hold: your drafts, broker access requests (a person's, or klok.dev's for a build), Kloker's chats, the mirror of Kloker's tasks, the last progress of each bead, saved prompts, and business cases with every saved version. None of them is the only place where something in Git is described.

Doing It By Hand

In klok.dev By hand
A change to a solution, system, datamodel or project The same change on a branch, and a merge request
New solution klok solutions new "<name>" in a clone of the registry, or the folder in a merge request
New integration or New model Create the project from its template in GitLab, replace its __KLOK_*__ tokens (a project) or fill the schema (a model), push; for a project, its deploy manifest in a merge request to the manifests repository, modelled on another service's; for a model, the tenant's root group under Settings → CI/CD → Job token permissions
New system Create the group <tenant>/datamodel/system/<system> in GitLab, and the system's folder in a merge request
A change request or a question The same issue and labels in GitLab
Approve and apply The same lines in the tenant's Pulsar file in a merge request, then ansible-playbook playbooks/pulsar.yml --check --diff, and the same without --check
Starting a Kloker task klok agent ask, klok agent plan and the other klok agent commands

klok.dev notices what is done by hand: its lists read Git again, and its copies are refreshed from main. If you find something klok.dev does that cannot be done by hand, that is a bug in klok.dev.

Read More