Publishing And Release Flow
Publishing in Klok should leave durable, reviewable evidence in Git and update the context used by humans and agents.
Git-Based Project Updates
When admin flows create or update project files, the backend should use a Git client workflow: clone or pull, write files, commit, and push. Avoid GitLab file API for changes that should appear as real source commits.
The backend must always fetch fresh main before reading or writing. A local clone in KLOK_GIT_LOCAL_WORKSPACE is a
workspace, not a source: the repository may have been changed manually since klok.dev last touched it, and such changes
must never be overwritten or ignored. The same project update must always be possible by hand directly in Git with the
same result. See Git Is The Truth: Everything Must Be Possible By
Hand.
Standard project creation flow:
- Clone the correct template repository into
KLOK_GIT_LOCAL_WORKSPACE. - Rename template
origintotemplate. - Add the new GitLab project as
origin. - Write project-specific metadata or generated files.
- Commit changes if files were written.
- Push
mainto the target origin. - Create a corresponding documentation project.
- Index the new project back into the admin GUI.
CI/CD Responsibilities
A good pipeline should:
- Build and test the project.
- Run schema and contract checks.
- Scan route code and metadata.
- Generate documentation.
- Publish Integration Context snapshots.
- Publish artifacts.
- Deploy according to the environment model.
- Report observations back to Kloker or the admin GUI where supported.
Commit Messages Choose The Pipeline Path
Every commit and merge request title in a Klok repository is a Conventional
Commit: feat(odl): add a scheduled query leg, fix: take the tenant from the topic, docs: describe the retry policy. The Klok templates read the type and do only the work that kind of
change needs.
The merge request title is the one that counts. GitLab writes it into the merge commit, and the main pipeline reads it
there, so give the title the type of the whole change, not of the branch's last commit.
A merge request titled docs that only touches klok-docs/ and Markdown files at the repository root skips the build,
the image, the release and the deployment, and only builds and publishes the documentation. A check in the same pipeline
fails it when anything else changed, so a code change typed docs by mistake turns red instead of reaching main
unbuilt. A pipeline started by hand always runs in full. Which templates have the docs path, and how a project with its
own job rules keeps it, is the Change types page of the CI templates (klok docs read klok-environment-build-ci-templates).
Renaming, Moving, Archiving Or Deleting A Repository
A repository's documentation project follows the repository. Do it in GitLab as usual; nothing else has to be done, and
nobody moves or deletes a documentation project by hand. The link is the repository's GitLab project id, which a rename
or a move never changes, recorded in the documentation project's klok-documented-project.json.
| You do in GitLab | What happens to the documentation |
|---|---|
| Rename the repository, move it to another group, or rename a group it is in | On the repository's next main pipeline, or within the hour without one, the documentation project moves to the mirrored path under <tenant>/documentation, publishes under the new doc id in the new group on docs.klok.dev, and the old doc id redirects there (klok docs read <old id> says it moved). The agent skill and the Used by rows of the datamodels it uses get the new name |
| Archive the repository | Within the hour the documentation leaves docs.klok.dev, the tenant's agent skills and the Used by pages, and the documentation project is archived. Unarchive the repository and it all comes back |
| Delete the repository, or move it into another tenant | The same as an archive, and the documentation project is deleted 30 days later. Another tenant documents a repository it receives in its own documentation group |
Your local checkouts do not move by themselves: klok sync pull reports a checkout whose project moved, was archived or
is gone, with the commands to fix it. The details for each role, including what the operator sees, are the Lifecycle:
guide of the documentation egress (klok docs read klok-integration-klok-documentation-egress).
Release Evidence
A release should make it possible to answer:
- Which commit is running?
- Which route classes were built?
- Which data models and topics are used?
- Which generated docs belong to the build?
- Which context snapshot was ingested?
- Which environment was deployed?
- Which service principal and ACLs are used?
Rollback And Replay
Because messages are persisted on the broker, operations may involve replay as well as application rollback. Before release, know:
- Whether messages are idempotent.
- Whether target systems can handle duplicates.
- Whether a failed deployment can be rolled back safely.
- Whether DLQ reprocessing needs a manual approval step.
- Whether schema changes require parallel bridges.
Rolling A Service Back
Retrying the deploy job of an old pipeline does not roll a service back. Pipelines of main run in parallel, so the
deploy job (update_manifest, which runs klok manifest update) leaves an image built from a newer commit in place: an
older pipeline that finishes last must not undo a newer deploy. A retried old job therefore ends green and changes
nothing, and its log says that it left the newer image as it is.
To roll back:
- Revert the change on
main. The revert is a new commit, so its pipeline builds and deploys like any other, andmainand what runs agree afterwards. This is the normal way. - When the service must go back at once, a person who may push to the tenant's manifests repository runs
klok manifest update --image <the older image> --allow-older, with--dry-runfirst.mainstill holds the newer code, so the next pipeline ofmaindeploys it again: make the revert as well.
A rollback of the image does not undo a database migration, published messages, or a version released to the dependency
catalog. The steps, the job log lines and the variable KLOK_MANIFEST_ALLOW_OLDER are in Rolling back a service of
klok docs read klok-application-klok-integration-agent.