The rule itself is stated in AGENTS.md ("Branching
workflow — not optional"); this document is the how-to. The shape:
local dev ──commit──▶ local dev ──push──▶ origin/dev ──MR merge──▶ origin/main
▲ │
│ CI must pass ▼
└────────────── local main (pull only)
Changes are made locally on dev, pushed to the remote dev branch,
and reach main only through a merge request on GitLab, once they
work. Nothing is ever committed to main directly — not locally, not
on the server.
| Branch | Role | Local use |
|---|---|---|
dev |
Where work happens. Long-lived, never deleted. | Check out, commit, push. |
main |
Known-good. Every commit on it arrived via a reviewed, CI-green merge. | Pull only. git checkout main && git pull after a merge, then go back to dev. |
main being known-good is a guarantee, not a habit: a commit landing on
it directly — even a one-line fix — means there is now a revision of
main that was also the first place the change was tried.
git checkout dev # or: git switch dev
# ... edit, commit as usual ...
make test # the suite must pass before pushing
git push # dev tracks origin/dev; plain push is enoughPush early and often — dev is allowed to be in progress. The quality
gate sits at the merge, not at the push. Every push does trigger CI, so
a red pipeline on dev is a nudge, not a crisis.
When the work on dev is ready:
- Open (or revisit) the merge request from
devintomain. An open MR follows the branch: later pushes todevjoin it automatically. - Read the diff once on the MR page. It reads differently than it does
in the terminal, and this is the last look before
mainchanges. - Wait for the pipeline to be green. The merge is conditional on it —
"it works" is the condition for the merge, not something to discover
on
mainafterwards. - Check the two checkboxes are right:
- Delete source branch: unchecked.
devis long-lived, not a feature branch. - Squash commits: unchecked. The commits on
devare individually meaningful; squashing flattens separate decisions into one blob.
- Delete source branch: unchecked.
- Merge. The project uses the merge commit method (GitLab's
default), which is the
--no-ffbehaviour the AGENTS.md rule asks for: the merge commit records which commits landed together as one unit of work.
git checkout main && git pull # fast-forwards to the merge commit
git checkout dev # back to where work happensLocal main exists only to mirror origin/main. If git pull on
main ever reports anything other than a fast-forward, something was
committed to main directly — stop and untangle that before continuing.
.gitlab-ci.yml runs the same checks pre-commit runs locally, with the
same scopes, on python:3.12-slim — the shipped runtime and the mypy
target. Green in CI means exactly what a clean local run means.
| Job | Checks | Gates the merge |
|---|---|---|
test |
pytest (synthetic source trees and throwaway git repositories; no clones and no network needed — git is installed into the slim image for the pull tests) |
yes |
lint |
black --check, isort --check, flake8, mypy, bandit |
yes |
audit |
pip-audit on the pinned runtime deps |
no — allow_failure: true, so a new upstream advisory shows a visible warning on every pipeline without blocking an unrelated merge. Flip it to false in .gitlab-ci.yml for a hard gate. |
One pipeline runs per change: a merge-request pipeline while an MR is open, a branch pipeline otherwise — never both for the same commit.
All under the project's Settings on GitLab. These turn the workflow from prose into mechanics:
- Merge requests → Merge checks → "Pipelines must succeed" — the merge button refuses a red pipeline.
- Merge requests → Merge method → "Merge commit" — keeps the
--no-ffgrouping. - Merge requests → uncheck "Enable 'Delete source branch' option by
default" — new MRs start with the box empty, so
devcannot be deleted by a reflexive click. - Repository → Protected branches →
main: Allowed to push: No one; Allowed to merge: Maintainers — nobody, including the owner and any agent with push access, can commit tomaindirectly.
- Two long-lived branches is the whole model. Feature branches off
devare not used; if two unrelated changes are ever in flight at once, that is the moment to add short-lived branches that MR intodev— not before. - Nothing merges on a schedule and nothing automerges. The human pressing the merge button, with a green pipeline and the diff read, is the release process.