A forge usually leans on other services for three things: a search engine for its code, a cache server for its builds, and a signing service for its releases. Atoll Forge runs all three itself. The build cache and the releases live in each repository’s own databases, replicated like everything else (see Scale and replication); the code search index is built by each node for itself. Each answers only what its reader may read.
Code search
The forge keeps a trigram index of main: of every file’s text and of every path, as Google Code Search did and as Russ Cox’s codesearch describes. A regular expression becomes a query over trigrams that any text it matches must contain. The forge reads the lists of texts holding those trigrams, then runs the expression itself on the texts they admit, so every answer is exact, never a guess from the index. An expression too short or too loose to name a trigram, such as ab or ., narrows nothing, and the forge runs it on every indexed text.
- It follows
main. Each node builds its own index, in the background, taking in what changed asmainmoves, each content once however many files hold it, as GitHub’s code search keeps each blob once. Onlymainis searched: a change that is still open is not. - A landing never waits for it. Building the index is no part of landing a change or of replicating one, and nothing of the index is sent between nodes.
- A search can be a moment behind a landing. The index takes
mainin at most once a second while landings keep coming, and at once after a quiet spell, so a search can be about a second behind, a little more for a landing that changes a great many files. A search answers from the index as it is; it never waits for it to catch up. - Each node answers from its own index. The node you ask answers, for the landing its index has reached, so in a cluster two nodes can be a moment apart. An agent’s
searchtool returns that landing ascommit;af searchdoes not print it. - It lives in files on each node’s disk, outside the repository’s databases. Its lists are immutable files: new ones are written each time
mainis taken in, merged into larger ones in the background, and read by seek a block at a time. An index that is lost or damaged is made again frommain. A node that has not built its index yet, or is making it again, finds less until it has caught up. - What counts as text is what
codesearchtakes: valid UTF-8, no line longer than 2,000 bytes, at most 20,000 distinct trigrams, and at most a mebibyte. Anything else is not indexed, and a file that is not text is not in the index at all, soaf search -fdoes not list it either. Symbolic links are not indexed. - You find only what you may read. No result comes from a folder you may not read. Each search is recorded as a read, naming who searched, the landing it answered for and the expression, before it is answered, in the chain of reads that the repository’s receipt log anchors.
- A purge reaches it. When contents are purged, every node removes them from its own index, rewriting the files that held them. See What is kept and what goes.
af search searches the text of files, af search -f keeps only files whose path matches a second expression, and -f alone finds files by path. Agents have a search tool that answers the same way. See Search the code for worked examples.
The build cache
The forge hosts the build cache under the same permissions as the code. It speaks the protocols build tools already use: Gradle’s HTTP build cache and sccache’s WebDAV backend. Bazel’s Remote Execution API is designed for, but not built.
- Only runners write. A runner running a job writes the cache; people and agents read it, through
af cache, which serves it read only to your own builds. An agent’s or a person’s own build output never enters the cache, so no one can poison it. - Scopes keep unlanded code apart, as GitHub Actions scopes a cache to its branch. A change’s job writes that change’s scope, which only that change’s later jobs read. Only jobs of
main’s landings write the scope every reader reads. - An entry is written once: the first whole entry of a key stays.
- Entries are evicted after seven days unused, and the least recently used go first once the cache passes 10 GB. A read refreshes an entry’s time at most once a day.
- An entry is as restricted as its sources. Gradle’s and sccache’s protocols name an entry by its key alone, not by the files that made it. So in a repository with restricted folders, an entry is readable only by someone who may read every folder.
- A purge empties it. An entry built from a tree that held purged contents may hold them, so a purge clears the cache. It also moves the cache’s generation, and an upload from a job given an older generation is refused.
- Reads are recorded, once a day for each reader and each commit an entry’s job built.
Inside af-runner’s sandbox, a job finds the cache at FORGE_GRADLE_CACHE for Gradle and SCCACHE_WEBDAV_ENDPOINT for sccache, on a listener inside the sandbox’s own network.
Releases
A release follows SLSA Build Level 3:
- A writer asks for a release of a commit
mainholds, withaf release request. A release is asked for once, and never changes. - A runner builds it:
main’s.forge/releaseruns on exactly that commit, in the runner’s sandbox, and the runner uploads what the program wrote underFORGE_OUT. - The forge hashes every artifact itself, from the uploaded bytes, and keeps them for good.
- A person approves exactly that build, with
af release approve. By default the asker’s own person may approve it; reports then list that approval as an exception. - The forge publishes it. It writes the provenance: SLSA’s build provenance v1, an in-toto statement in a DSSE envelope, naming the commit, the build and each artifact’s SHA-256. It signs it with the organization’s receipts key, which no person or agent can use, so no build and no person can forge one. The approval and the provenance go into the repository’s receipt log together.
Anyone holding the organization’s public key and the log can check a release, with af release verify, file by file. No outside signing service is involved: Sigstore’s public instance would publish private repositories’ metadata, and its servers are programs the forge does not run.
Release lines, with fixes cherry-picked onto them, are decided but not built.
Next
- Search the code:
af searchwith worked examples. - From a test to a release: a release built, approved, published and verified on a development forge.
af cacheandaf releasein the reference.- What the forge records: the receipt log and the chain of reads that searches, cache reads and releases are recorded in.