Skip to content

Source code

Every SVRBC repository is a project in the svrbc group on GitLab.com. The one subgroup is svrbc/forks, which holds a shared fork of each project. GitLab also runs CI (Builds and CI) and serves the static sites through GitLab Pages (Domains).

The group is on GitLab’s free tier, and CI jobs run on GitLab.com’s shared runners.

Every SVRBC repository’s primary branch is master. Not main, even though GitHub and newer git init default to it. One name everywhere means scripts, CI rules, branch protection and these docs never have to guess.

  • It is the group default, so a project created in GitLab starts on master. A repository created locally and pushed may not. Check with git symbolic-ref --short HEAD before the first push, or start it with git init -b master.
  • Nobody pushes to it, owners included. It changes only by merging a merge request, and nobody can force-push. A Maintainer merges, once the review bot’s statuses say the owners approved and the tests passed.

svrbc-audit reports any project whose default branch isn’t master, or whose master takes pushes.

Changes arrive as merge requests from forks

Section titled “Changes arrive as merge requests from forks”

Every change is a merge request from the project’s fork in svrbc/forks. The project itself keeps only master; branches live in the fork, which every member can push to. One fork per project, shared by everyone, with the project’s own name (svrbc/forks/doreancon.org).

Terminal window
git clone git@gitlab.com:svrbc/<project>.git # clone the project, not the fork
cd <project>
git fetch origin # merges are fast-forward: start from current master
git worktree add -b <topic> ../.worktrees/<project>-<topic> origin/master
cd ../.worktrees/<project>-<topic> # a working tree for the task: see below; …commit…
git fetch origin && git rebase origin/master # if master has moved since
svrbc-mr # push to the fork (made the first time), open the merge request

(svrbc-mr is in this handbook’s tools/.) To release the change as well, svrbc-mr --ship puts the version bump in it, sets auto-merge and watches it deploy (Releases).

What happens next:

  1. It is built and tested once. svrbc-mr does it on your workstation before it pushes: it runs bazel test //..., uploads the results to the shared cache and records the commit as verified. With --no-build, the review bot starts the fork’s pipeline, which does the same (CI in svrbc/forks is trusted to write the cache). A push to a fork starts no pipeline by itself, so a commit already verified is never built again.
  2. Its owners approve it, and a Maintainer merges it, fast-forward, with GitLab’s merge button or Set to auto-merge, once the review bot’s statuses pass. The merged commit is exactly the commit that was built and tested, so its cache keys are the same.
  3. master starts no pipeline. There’s nothing for it to do: the merged commit is the one that was built and tested.
  4. Releases are merge requests too: a reviewed version bump, which the review bot turns into the tag, and the tag’s pipeline deploys (Releases).
  5. The fork’s master catches up: the review bot fast-forwards it, so a branch pushed later doesn’t carry a backlog of master’s commits up with it.

Why it’s set up this way:

  • The project stays clean: no branches, ever. Abandoned work is in the fork, where it bothers nobody, and the source branch is deleted when its merge request merges.
  • The forks belong to SVRBC. A personal fork leaves with its owner, and its CI runs on the owner’s account; a fork in svrbc/forks runs on SVRBC’s, with SVRBC’s cache.
  • Building once. A heavy change is built in its fork, and master and every developer’s machine reuse it. Only the fork pipeline writes; anyone outside SVRBC (a fork somewhere else) can’t.

Each task gets a working tree of its own, made with git worktree. The clone stays on master, and nobody edits in it. Each task is a worktree on its topic branch, beside the clones at ~/projects/.worktrees/<project>-<topic>, as above, and is removed once its merge request merges. Not in /tmp: on many machines it is memory, emptied by a restart, which leaves git a worktree it can’t find (git worktree prune forgets it).

Terminal window
git worktree remove ~/projects/.worktrees/<project>-<topic>

Why:

  • Agents can’t see each other. Two agents in one clone switch branches under each other, commit each other’s edits, and build a tree neither of them wrote. An agent can’t tell that another is working in its clone, so the rule is every task, not just when several run at once.
  • It costs only the branch, which the merge request needs anyway. Worktrees share the clone’s objects, so there is nothing more to clone or fetch, and a task left half done stays where it is, with no stash.
  • Builds stay apart. Bazel gives each worktree an output base of its own, since its default is keyed by the workspace’s path, and svrbc-mr keeps one per worktree too (~/.cache/svrbc-mr/<project>/<tree>-<hash>/). What they share is safe to share: the disk cache (~/.cache/bazel-disk), which takes several builds at once, and the shared cache, so a new worktree’s first build finds most of its steps done.

A new worktree has only what git tracks. Install what the project needs before building: npm ci for node_modules, tofu init in each infra/ stack you plan, and any local file the project’s AGENTS.md names. A tool that makes the worktree itself (T3 Code, Claude Code) is fine: what matters is one working tree per task, not where it is.

Where Branch Push Merge Force-push
svrbc/<project> master No one Maintainers, once the statuses pass no
svrbc/<project> * (anything else) No one No one no
svrbc/forks/<project> master Maintainers (CI’s sync, as svrbc_bot) Maintainers no
svrbc/forks/<project> other branches Developers and up — yes, your own branch

Each project also merges fast-forward only, with squashing turned off, deletes the source branch on merge, and requires the pipeline to pass, never counting a skipped one and never rebasing at merge time (automatic rebase, which would merge a commit no pipeline tested). Both halves of “fast-forward only” matter: a merge commit or a squash would each put a new commit on master, not the one the fork built and tested. The forks are set the same way, so nothing lands on them differently either.

GitLab deletes a merge request’s branch from the fork only when someone merges it in GitLab; a branch merged any other way stays. The audit warns on any branch left in a fork that is already merged into its master; an owner clears them all with glab api -X DELETE "projects/svrbc%2Fforks%2F<project>/repository/merged_branches", which leaves protected and unmerged branches alone.

A new project is enrolled by a merge request, and the bot does the rest. Once its CODEOWNERS has merged, a merge request here adds the line <project> review to tools/review-bot/projects.txt (it is a release: bump the version). Within 15 minutes of that release applying, the bot sets the project up with its own token, as a Maintainer: its fork in svrbc/forks (if svrbc-mr hasn’t made it yet), its deploy key and webhooks, the merge settings above (fast-forward, no squash, Pipelines must succeed, skipped pipelines not successful, no automatic rebase), the protected v* tags and svrbc_bot as a direct member where the project takes releases, its key on the fork’s master (which it keeps in step after every merge), and last the protection: master merged by Maintainers and pushed by No one, and the * rule pushed and merged by No one (made if the project has none). Nobody runs anything, and nobody needs an AWS login: the bot holds the webhook secret. It never writes CODEOWNERS or projects.txt, which people review. svrbc-review-bot-enroll <project> checks how far it has got, with only a GitLab token. Once a day the bot goes over every listed project again and puts back anything changed by hand.

A fork in svrbc/forks keeps its repository, merge requests, CI and container registry, and turns everything else off: issues, wiki, snippets, Pages, the package registry, releases, environments, feature flags, infrastructure, monitor, analytics, requirements, security and compliance, model experiments, model registry and Service Desk. The project’s issues and wiki are where work is tracked; a fork’s would collect what nobody looks for there. The container registry stays because a fork’s pipeline may push an image it builds (this handbook’s does, for the CI image), and merge requests stay because GitLab opens one from the fork only if the fork has them.

GitLab has no group setting for this: a group can’t turn a feature off for its projects, so each fork is set on its own. svrbc-mr sets it when it creates a fork, and the review bot holds every fork of a project it looks after to these settings and fast-forward-only merges on each run, so a fork whose setup didn’t take (made by someone who can’t change its settings) is put right. svrbc-audit warns about a fork with any of them on (fork-features). An owner turns them off by hand with:

Terminal window
glab api -X PUT "projects/svrbc%2Fforks%2F<project>" -F service_desk_enabled=false \
$(for f in issues wiki snippets pages package_registry releases environments feature_flags \
infrastructure monitor analytics requirements security_and_compliance model_experiments \
model_registry; do printf -- '-f %s_access_level=disabled ' "$f"; done)

An exception lets a tool push branches to the project itself, for a tool that can only work that way (a CMS that saves drafts as branches, say). It needs all three:

  1. An owner agrees, and adds a protected-branch rule for exactly that pattern, letting the role that needs it push.
  2. The project’s AGENTS.md explains it: the pattern, what creates those branches, and who cleans them up.
  3. It’s removed when the need goes.

A staging branch is the other kind: a long-lived branch that reviewed changes merge into, deployed to a staging site of its own rather than to production. It follows the same three rules, and is protected exactly as master is; projects.txt names it (<project> review <branch>=review), and the bot treats it like master, by that branch’s own CODEOWNERS. Changes reach it the usual way, svrbc-mr --target <branch>; what is ready for production moves on to master by a merge request from the staging branch to master.

svrbc-audit fails a project with no * rule, and warns about an exception its AGENTS.md doesn’t mention and about any branch other than master that no exception covers.

Every project has a CODEOWNERS file saying who must approve its changes. It lives at .gitlab/CODEOWNERS, in GitLab’s format, and its first rule, *, names the project’s owners: whoever must approve any change. Narrower rules after it give parts of the project their own owners (the last matching rule wins):

# .gitlab/CODEOWNERS
* @cco3
/content/ @cco3 @a-content-editor

An owner is a person, by GitLab username. A change to CODEOWNERS is reviewed like any other, by the owners of *. doreancon.org’s is * @cco3: one owner for the whole project.

The rule is that a merge request needs approval from the owners of every path it changes. GitLab Free (svrbc’s plan) records approvals but never requires them; that is Premium. So people merge, and the bot tells GitLab whether they may: it posts two commit statuses, and Pipelines must succeed holds the merge button until they, and the tests, pass.

  • Approve with GitLab’s Approve button. That is all an owner does. An author who owns what they changed approves it by not marking it a draft: GitLab won’t let authors press Approve, and the merge is their go-ahead. Draft is how to say “not yet”. Approvals given after the latest change count; a rebase that leaves the changes alone keeps them.
  • review-bot/approved is pending until every changed path has its owners’ approval (its description says whose), then success; failed for a CODEOWNERS the bot can’t read. The rules come from the target branch’s CODEOWNERS, never the merge request’s, so a merge request can’t change the rules it is judged by. The bot reads a strict subset of GitLab’s syntax (@username owners, sections such as [Docs][2] for two approvals and ^[Optional]) and refuses anything else with a message, rather than guessing. A path no line covers blocks it. It is also pending, “held”, for a release whose version the target branch already has, which would merge releasing nothing (Two releases at once).
  • The tests: a commit verified on a developer’s workstation, with no pipeline of its own, gets review-bot/verified, success. Otherwise the bot starts the fork’s pipeline, whose jobs speak for themselves. It never reruns a failed one: push a fix, or retry it in GitLab. A pipeline that did run always counts, verified or not, since a project’s pipeline may do more than the marker vouches for. An external pipeline, the kind GitLab makes for a status posted through its API, never counts as tests.
  • Every fork pipeline waits for the bot at its last job, review-bot (ci/review-bot.yml, which ci/bazel.yml includes), a manual job the bot starts once its statuses are in that pipeline. GitLab judges a merge request by its commit’s latest pipeline, so without it a pipeline someone starts by hand (Run pipeline, the API) could pass, and auto-merge merge it, before the bot’s pending was in it, merging unapproved. Started by anyone else, the job fails. To get a stuck pipeline moving, retry its failed job; don’t start a new pipeline, which only waits for the bot’s next run. A project whose CI doesn’t include ci/bazel.yml includes ci/review-bot.yml (svrbc-audit’s review-gate).
  • Merge with the button, or Set to auto-merge. Auto-merge is the merge queue. Merges are fast-forward, so each merge leaves the others behind, and GitLab cancels their auto-merge; the bot rebases the first approved one in the queue (never with skip_ci, which would leave GitLab judging a skipped pipeline), sets auto-merge on it again, and GitLab merges it once its statuses pass; then the next. The rest wait unrebased, so a batch of n merge requests costs n pipelines, not one per merge for each. GitLab won’t set auto-merge on one already behind: click Rebase first. One that fails or conflicts leaves the queue, and the bot says why.
  • It keeps one comment on the merge request, edited in place, saying what it is waiting for and where it is in the queue.
  • After a merge it releases and syncs the fork: a version bump gets its v<version> tag, created through the API, and the bot starts the tag’s pipeline (Releases); the fork’s master is fast-forwarded with its key to match. A push event starts it, and it comes before the bot looks at any merge request; the 15-minute sweep finishes either if a run didn’t, for an hour after the merge, and the daily full sweep after that.

A guardrail, not enforcement. It stops mistakes: merging before the owners approve or the tests pass. It doesn’t stop someone determined: anyone with Developer can post a status named like the bot’s (the bot names such a status in its comment and posts its own again), and a Maintainer can turn Pipelines must succeed off. Developers are trusted already; getting around the bot on purpose is a breach of these rules, not a workaround.

It acts within seconds of an approval, a push or a pipeline finishing or waiting at its review-bot job: webhooks start it, and a sweep every 15 minutes, of what changed in the last hour, catches anything they missed (a full one, daily). The code is tools/review-bot/, and it runs as an AWS Lambda function (review-bot). The projects it looks after are listed in tools/review-bot/projects.txt, with any branch besides master it looks after (<branch>=review, a staging branch), and it sets each one up itself (How it’s enforced). svrbc-audit fails a project with no CODEOWNERS or no * rule, and checks the settings review mode relies on (merge-checks).

Breaking glass. A Maintainer can merge past a stuck status by turning Pipelines must succeed off. Do it only when the bot is down and a fix can’t wait. The bot puts it back at its daily enrolment (12:00 UTC), or turn it on again yourself once the bot is back; the audit flags the project until then.

You can’t request access from the group page; that button is turned off. Ask an owner to add you. New members start as Developer, which is enough to contribute: push branches to the forks and open merge requests.

Role Can
Developer Push branches to svrbc/forks, open merge requests and issues, create projects
Maintainer Also change project settings, and merge once the review bot’s statuses pass
Owner Also manage members, subgroups and group settings, and grant exceptions

Nobody, owners included, pushes to a project’s master.

Clone over SSH once your key is on your GitLab profile:

Terminal window
git clone git@gitlab.com:svrbc/<project>.git

glab, GitLab’s CLI, is the easiest way to script against the API. The examples in this handbook use it. Log in once with glab auth login.

  • Create it in the svrbc group, not under your own account, so it never has to be transferred.

  • Public by default. Most SVRBC projects are public, and this handbook is written on that assumption. Make a project private only when its contents are private, such as member information or unpublished material. Even in a private project, credentials still go in CI/CD variables, never in the repository.

  • Name a project that publishes a site after its domain (baptistcatechism.org, psalter.svrbc.org). Name anything else in lowercase kebab case (review-bot, doreanreceipts). A project that publishes several sites from one build is named in kebab case after what they share (symbolics-sites), and lists the hosts it serves in .gitlab/hosts, one a line, so svrbc-audit checks them as it would a site named after its domain.

  • No svrbc- prefix inside the group: the group already says whose it is (svrbc/review-bot, not svrbc/svrbc-review-bot). Keep the prefix where names are global or shared: AWS resources (Naming), commands on PATH (svrbc-mr), and local clones in a flat ~/projects/ (~/projects/svrbc-review-bot). A project that already has the prefix keeps it: renaming one breaks every clone and link, so it isn’t worth doing just for this.

  • Add an AGENTS.md that points back to this handbook. See Agents files.

  • A new site starts from the template: svrbc-new-site writes its repository, and its AWS resources and DNS records here, step by step.

  • Give it a GitLab avatar of its own (Settings → General → Project avatar), so lists, merge requests and notifications tell the projects apart at a glance. A project with a site uses the site’s logo; others build on SVRBC’s cross, the circuit-board one in svrbc.org’s static/logo-transparent.svg (this handbook’s is that cross in angle brackets). Put it on a solid background: a black logo on a transparent one disappears in GitLab’s dark theme.

  • Name the same logo in a t3.json at the repository’s root, so T3 Code shows it beside the project as GitLab does. Point iconPath at the committed image the avatar comes from (a site’s public/favicon.svg):

    {
    "$schema": "https://t3.codes/schema/t3.json",
    "iconPath": "public/favicon.svg"
    }

    The image must stand alone: an SVG that draws another file through <image href> (a site’s icons/maskable.svg) shows up blank.

A project nobody works on any more is archived, not left failing the handbook’s rules (Settings → General → Advanced → Archive project). An archived project is read-only: no pushes, merge requests or pipelines, though it stays visible and can be cloned, and a site it already deployed keeps serving. svrbc-audit and svrbc-review-bot-enroll skip it.

Delete its fork in svrbc/forks when you archive or delete it: work pushed there could never merge. And take its line out of tools/review-bot/projects.txt, so the bot stops looking after it. svrbc-audit fails a fork, or a line in projects.txt, whose project is archived, gone or marked for deletion (no-stray-forks, bot-projects-live).

Unarchive it to work on it again (and svrbc-mr makes it a new fork); it then has to meet the rules like any other project.

  • Require two-factor authentication for group members. It is currently off.