code.overheid.nl · Architecture decisions

ADR 0003

Quality suggestions, builds and signed artifacts on code.overheid.nl

Status
Proposed
Date
24 November 2026
Discussion
Pull request #102

Context and Problem Statement

Under 0002 code.overheid.nl holds read-only mirrors and checks every mirrored commit (rule 3 there). Those checks read files: publiccode.yml, licenses, leaked secrets, known vulnerabilities. A proposal from within the team goes two steps further.

The first step is building. To say something about quality, code.overheid.nl would build each repository and, while building, produce an SBOM, run the unit tests and measure coverage. Many repositories have no workflow for that, so the proposal adds those workflows to the copy on code.overheid.nl and offers the same change to the origin as a pull request.

The second step is suggestions that the quality picture does not need but that are still worth offering. A missing license is the example: code.overheid.nl cannot choose one for the author, and it can propose EUPL-1.2.

Next to this, a set of template repositories is being made on the forge of developer.overheid.nl and mirrored to code.overheid.nl: an EUPL license, a README, a publiccode.yml with an nl section, an SBOM workflow, trufflehog, pre-commit, and the API Design Rules linter for API templates.

The proposal collides with 0002 in two places. Rule 1 says the mirror is read-only and the origin is the one source of truth, so a workflow added to the copy has nowhere to live. Rule 6 says no account of Code Punt signs in at a forge, and the confirmation of 0002 ends with "code.overheid.nl keeps no account and no access token on any forge"; a pull request at the origin needs some identity there. This ADR decides how far the proposal goes, and where 0002 changes.

An example to hold on to: a municipality has a repository with a Dockerfile, a test directory, no workflows and no license file. It is public and mirrored.

Decision Drivers

Considered Options

Where build and test results come from:

What happens to what is built:

How a suggestion reaches the origin:

Decision Outcome

Chosen option: "C2. A pipeline definition of Code Punt, applied to the mirrored commit from outside the repository". What is built is published and signed: "K2. Published in the package registry of code.overheid.nl, signed by Code Punt". Suggestions are always shown on the mirror (D2) and can be sent by a maintainer in their own name (D4). Pull requests that nobody has to click for come from a bot account of code.overheid.nl (D3) at the forges of organizations that admit it in the register, and from the origin's own workflow (D5) elsewhere. The templates (D6) are where the content of every suggestion comes from.

D3 is an exception to rule 6 of 0002, made per organization and by that organization. A forge that did not admit the bot has no account of code.overheid.nl on it, as before.

flowchart TB
    tmpl["Templates<br/>forge of developer.overheid.nl"]
    origin["Origin forge"]

    subgraph cod["code.overheid.nl"]
        direction TB
        mirror["Read-only mirror"]
        pipe["Pipeline definition of Code Punt<br/>runs on runners of Code Punt"]
        evidence["Results with signed provenance"]
        sugg["Suggestions, as patches"]
        mirror --> pipe --> evidence
        mirror --> sugg
    end

    origin == "pull mirror" ==> mirror
    tmpl -- "mirrored" --> sugg
    sugg -. "sent by a maintainer,<br/>in their own name" .-> origin
    sugg -. "pushed by the bot, where<br/>the organization admits it" .-> origin
    sugg -. "fetched by a workflow<br/>at the origin" .-> origin

The rules continue the numbering of 0002.

10. code.overheid.nl builds from a definition outside the repository. The pipeline definition lives in a repository of Code Punt on code.overheid.nl. A run takes the address of a mirror and a commit, checks that commit out and builds it on runners of Code Punt. Nothing is committed or pushed to the mirror, so rule 1 stands as written. Committing a workflow to the copy (C1) would do more than break a rule: the commit that carries the workflow has a different hash than any commit at the origin, and the results would then describe code that exists only on code.overheid.nl.

The pipeline builds what it can recognize, starting with a Dockerfile and the common package manifests, and a repository can name its build and test commands in the nl section of publiccode.yml. For the example repository it builds the image, writes an SBOM of the result, runs the tests and records coverage. A repository it cannot build shows "not built" with the reason, which is not a failed check. Builds run for the head of the default branch and for release tags, with a time limit per run. That matches what the proof of concept of 0002 checks today (the head of each default branch) and keeps the bill proportional to the number of repositories, not the number of commits. We have no measurement of the cost yet.

Every mirror is built, including mirrors of government code whose organization is not in the register, such as code on GitHub.

Next to that pipeline, a mirror runs the origin's own workflows, exactly as the YAML at the origin says. A push or a tag that arrives through the mirror sync starts them, and so do schedule and workflow_dispatch. Pull requests are off on a mirror, so those triggers never fire. code.overheid.nl has none of the origin's secrets, so a job that needs one fails. Artifacts of jobs that succeed are kept, and published and signed under rule 11. They are the origin's own artifacts, made by the origin's definition; the SBOM, the test result and the coverage figure still come from the pipeline of Code Punt.

A build runs code that code.overheid.nl did not write, and so does a workflow of the origin. Each run gets a fresh runner without secrets, and the runner does not hold the signing key of rule 11. Dependencies have to be downloaded, so the runner has outbound network access; a build that needs a private registry fails and shows "not built".

11. A build result is evidence about one commit, and what was built is published, both signed by code.overheid.nl. Every run produces a provenance statement that names the origin's address, the commit, the version of the pipeline definition and the digests of what was built. A service outside the runner signs it. The SBOM, the test report and the coverage figure hang on that statement, and the bot that posts the results of rule 3 sets them as commit statuses on the mirror. A forge that reports back (rule 3) receives them the same way as the other results, and decides in its branch protection what they block.

What a run builds is published in the package registry of code.overheid.nl, which is Forgejo's own: container images in its OCI registry, SBOMs and other build output as generic packages. They sit under the organization on code.overheid.nl, next to the mirror, and anyone can download them. This holds for the pipeline of Code Punt and for the artifacts of the origin's workflows on the mirror (rule 10).

A run does not publish anything itself. In Forgejo 15.0.11 the automatic token of a run cannot write packages: services/packages/perm.go gives the actions user read access at most. A workflow therefore only leaves Actions artifacts. Code Punt collects them after a successful run, told by an organization webhook and by polling, and publishes them by a naming convention. An artifact with an image.tar becomes an image tagged with the commit and the tag, a *.cdx.json or sbom*.json becomes the SBOM, and any other file a generic package.

Code Punt signs in a step of its own, after the run and outside the runner, with a key that the repository's code cannot read. An image gets a cosign signature, the SBOM and the provenance statement become signed attestations, and any other file gets a detached signature. The public key is published, so anyone can verify. This is another key than the one a forge signs its own commits with (0002, rule 7). That one shows which forge made a commit. This one says: Code Punt saw this as the output of run X of commit Y on its runner. The statement is SLSA provenance v1, signed by the platform. It does not say that the code is safe, and it says nothing about the artifact the organization itself released.

That statement is as strong as the isolation of the build. On a shared runner in host mode a job can pose as the runner, and the provenance is then weak. Production needs a runner that is thrown away after each job. Coverage is shown as a number, without a threshold.

In production the signing key lives in a hardware security module (HSM). The service asks the HSM for a signature and never holds the key, so whoever takes over the service does not walk away with it. The HSM does not judge what it signs. Someone in control of the service can still ask for a signature on a false statement, and the HSM records who asked and when. The proof of concept keeps the key in the service. It records its signatures in no public transparency log, so a verifier has to tell cosign not to look for one (--insecure-ignore-tlog=true). Whether signatures go into a public log such as Rekor, which shows everything that was ever signed, is still open.

12. A suggestion is a change taken from the templates. The templates on the forge of developer.overheid.nl are the one source: a new repository starts from them, and a suggestion for an existing repository is the template's file where the repository has none. There are two groups.

The first group is the workflows that do at the origin what the pipeline of rule 10 does on code.overheid.nl: build, SBOM, tests, coverage. code.overheid.nl keeps building either way, since every mirror gets the same evidence. The gain for the origin is feedback on a pull request before it is merged, which code.overheid.nl never sees. These suggestions exist only for forge software the templates have workflows for, and they need Actions at the origin.

The second group is everything else the templates carry: a license, a README, a publiccode.yml with its nl section, secret scanning with trufflehog, pre-commit, and the API Design Rules linter where the repository publishes an OpenAPI description.

A suggestion never changes a file the organization wrote. A repository with an MIT license gets no suggestion to move to EUPL. The one kind of file code.overheid.nl proposes changes to is a file it suggested itself: when a template changes, it offers the update where its earlier suggestion was merged and the file is still byte for byte what was merged. Once the organization has edited the file, it is the organization's and gets no more updates.

13. Every suggestion is shown on the mirror, and delivery goes as far as the repository and its organization choose. One key takes three values. off: code.overheid.nl makes no suggestions. show: suggestions appear on the page of the mirror, each as a patch with the command to apply it, and with the button of rule 14. pull-request: suggestions also arrive at the origin as pull requests without anyone clicking. The organization sets the value in the register (rule 9) and a repository sets it in the nl section of its publiccode.yml. The repository wins, and where neither says anything the value is show. A repository can also list single suggestions that do not apply, with a reason, as it can for checks under rule 3.

In the register pull-request is more than a default. With it the organization admits the bot of rule 14 to its forge.

14. A pull request at the origin comes from a person, from the bot where the organization admits it, or from the origin's own workflow.

By a person: under show and pull-request, someone the owning organization vouches for sees a button next to each suggestion on the mirror, and nobody else does. code.overheid.nl then pushes the suggested commit to refs/for/<target branch>/code-overheid-<suggestion> at the origin, in that person's name and with their consent, as in rule 2 but without a fork. The commit names code.overheid.nl as author; the pull request is the person's.

By the bot: an organization whose register entry says pull-request creates an account for the bot of code.overheid.nl on its forge, in no team and without rights on any repository, and gives Code Punt a token for it outside the register. The bot pushes suggestions to the same AGit reference, under its own name, for every repository of that organization whose value is pull-request. A repository there that says show or off is left alone. When the organization changes its entry, Code Punt destroys the token and the organization removes the account. For a forge that Code Punt runs (rule 8) the organization's administrator creates the account, the same as anywhere else.

By the origin: a repository that says pull-request in an organization without the bot gets its pull requests from the workflow of rule 3. That workflow fetches the suggestions for its repository along with the results and opens the pull request with the origin's own token. Adding the workflow is itself a suggestion of the first group, sent once by a person.

An organization that is not in the register has nobody who is vouched and no entry that could admit the bot. Its repositories are built and their suggestions are shown, with the patch. They never get a pull request from code.overheid.nl, whatever their publiccode.yml says.

15. One suggestion at a time, and closing one means no. A repository has at most one open pull request from suggestions. The topic in the branch name is fixed per suggestion, so sending the same suggestion twice updates the pull request that is there and never opens a second. The order is fixed too: the license comes first, then publiccode.yml, then the workflows, and updates under rule 12 last. The next suggestion follows no sooner than a week after the previous one was merged or closed.

When a pull request from a suggestion is closed without a merge, code.overheid.nl records that suggestion as declined for that repository and does not deliver it again. It stays visible on the mirror as declined, and someone of the organization can reopen it there. code.overheid.nl learns the state by reading the origin's public API without signing in. The bot closes its own pull request when the origin has settled the matter another way; that is not a decline.

16. A license suggestion is a proposal by code.overheid.nl and a decision by the organization. The suggestion adds the EUPL-1.2 text as LICENSE, the license the templates use, and only where the repository has no license file and names no license in publiccode.yml. Its description says three things: that the code is not licensed until someone who may decide that for the organization merges it, that the organization has to hold the rights to all of the code, including contributions from suppliers and outside contributors, and that it has to check its dependencies against the EUPL.

The license suggestion is never delivered automatically. The bot does not push it and the origin's workflow does not open it; under every value it is shown, and it becomes a pull request only through the button of rule 14, so a person of the organization has chosen to put the question. While it waits for that click it does not hold up the suggestions after it.

A public repository without a license may be public without being meant as open source. The organization says so by marking the license check as not applicable with a reason (rule 3). code.overheid.nl then shows that reason on the mirror, with the notice that the code can be read and not reused, and makes no license suggestion.

Changes to ADR 0002

The changes are made in 0002. In short:

Consequences

Confirmation

The proof of concept collects, publishes and signs artifacts as rule 11 describes, on a shared runner. The rest is not built. Five things have to be tried on Forgejo before the decision is firm: that a mirror sync starts the workflows in the mirrored commit, that an account without rights can open a pull request on a public repository through AGit and with which token scope, that a workflow at the origin can open a pull request with the automatic token of its run, that a push to the same AGit topic after the pull request was closed does not silently reopen it, and that a run in a repository of Code Punt can be started per mirrored commit with the commit as input.

Pros and Cons of the Options

Scored against the drivers as in 0002: ✓ meets it, ~ meets it partly or at a cost, ✗ does not.

Where build and test results come from
Driver C1 C2 C3 C4
The mirror is identical to the origin ✗ ✓ ✓ ✓
Every mirror gets the same evidence ✓ ✓ ✗ ~
A result is traceable to one commit and a builder ✗ ✓ ~ ✓
The cost of building is bounded ~ ~ ✓ ✓
Works with Forgejo as it is ✗ ✓ ✓ ✓

How a suggestion reaches the origin. D3 is scored as an account at every forge; the decision takes it only where the organization admits it, which turns its first two rows into ✓ for everyone else.

Driver D1 D2 D3 D4 D5 D6
No account or token at a forge that did not ask ✓ ✓ ✗ ✓ ✓ ✓
No pull request unasked ✓ ✓ ✗ ✓ ✓ ✓
The organization decides what enters ✓ ✓ ✓ ✓ ✓ ✓
The suggestion reaches a maintainer who is not looking ✗ ✗ ✓ ~ ~ ✗
Existing repositories are covered ~ ✓ ✓ ✓ ✓ ✗
Works with Forgejo as it is ✓ ✓ ✓ ✓ ~ ✓

D3 is the only option that reaches a maintainer who never asked, and as a rule for all forges the only one that fails the account rule.

C1. Workflows committed to the copy on code.overheid.nl

C2. A pipeline definition of Code Punt, applied to the mirrored commit from outside the repository

See rule 10.

C3. Only what the origin builds and reports itself

The origin runs its own workflows and sends signed results to code.overheid.nl.

C4. No builds, only the checks of 0002

K1. Thrown away after the run; only the evidence stays

K2. Published in the package registry of code.overheid.nl, signed by Code Punt

See rule 11.

K3. Published in that registry as the run left it, unsigned

D1. No suggestions; the check results are the message

D2. Shown on the page of the mirror, for a maintainer to apply by hand

This is what rule 3 of 0002 does for the report-back workflow.

D3. Pull requests by a bot account of code.overheid.nl at the forge

The forge creates an account for code.overheid.nl, which pushes suggestions through AGit. On Forgejo any signed-in account can open a pull request on a public repository this way, so the account needs no rights. See rule 14 for the form the decision takes it in.

D4. Pull requests in the name of a maintainer, through the acting route of 0002 rule 2

See rule 14.

D5. The origin fetches its suggestions and opens the pull request with its own token

See rule 14. This is how a self-hosted dependency bot works: the bot runs at the repository and carries the repository's own credentials.

D6. Templates only: good defaults at creation, nothing afterwards

More Information

Still open, each for a later decision: