Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Site
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software/vole.git

Self-hosted forge that lives in your Git repo.

Blame · ARCHITECTURE.md

Line attribution on main · 207 line(s)

520470e1
Keenan Nemetz
40d ago
1 # Architecture and design
2
3 This page is for people who want to understand how Vole works and why it makes
4 the choices it does. If you only want to use Vole, the guides are enough.
5
6 The goal is not novelty. The goal is a forge that stays understandable, works on
7 hardware you control, and keeps the important parts in Git.
8
9 Vole is built for one team on one server. It does not try to be a hosted service,
10 and it does not connect to other Vole instances. That keeps the design small.
11
6c84d387
Keenan Nemetz
40d ago
12 ## Trust: a credential resolves to an account
520470e1
Keenan Nemetz
40d ago
13
14 Vole uses one rule everywhere:
15
6c84d387
Keenan Nemetz
40d ago
16 > A credential proves which account you are. Vole checks every change before
17 > accepting it, and records the decision in `data/audit.log`.
520470e1
Keenan Nemetz
40d ago
18
62576fa8
Keenan Nemetz
38d ago
19 There are two credentials, and they resolve to the same account: the **name**
20 fixed at creation. Contributor branches and metadata authors are written with it,
21 and access rules, approval files, locks and CI records are keyed by it.
6c84d387
Keenan Nemetz
40d ago
22
23 - an **SSH key** for Git over SSH, administration, and CI;
24 - a **passkey** for browser sessions.
25
bca53bda
Keenan Nemetz
16d ago
26 The SSH endpoint may be Vole's own listener or the system sshd in front of it, and
27 the key resolves to an account the same way in both. With sshd in front, sshd keeps
28 the host key and runs a short forced command as an account that cannot read
29 `/var/lib/vole`; that command hands the session to `vole serve` over a local
30 socket, so the process that authenticates and the process that writes stay
31 separate, and the writer is still one. See
d1f44d83
Keenan Nemetz
21h ago
32 [Put sshd in front of Vole](docs/deploy/linux.md#put-sshd-in-front-of-vole).
bca53bda
Keenan Nemetz
16d ago
33
6c84d387
Keenan Nemetz
40d ago
34 There is no password database. The browser performs a WebAuthn ceremony, Vole
35 stores only the credential's public half, and the resulting session is an opaque
3047be84
Keenan Nemetz
17d ago
36 token whose hash alone is in `instance.db`.
6c84d387
Keenan Nemetz
40d ago
37
7e0b5950
Keenan Nemetz
30d ago
38 There are two ways to write metadata, and they offer the same account the same
39 actions: a browser session, where each form asks for one capability, and a push,
40 where pre-receive asks the same capabilities path by path. Both are built on the
41 same metadata writers, so the file format and its validation do not fork. An
42 untrusted contributor's Git writes are confined to `refs/heads/contrib/<name>/`,
43 and the `vole` branch it may also write is checked the same way the browser's
44 forms are; CI for a contributor branch does not run until a maintainer allows the
45 exact tip. A change request opened from a
e050e14a
Keenan Nemetz
37d ago
46 branch follows it: after an accepted push, the server records the new tip as the
47 request's head, so approvals of the old tip stop counting. Everything else still
48 changes by pushing over SSH. Approvals, comments, and CI results belong to the
49 account the credential resolved to, never to a name typed into a form.
520470e1
Keenan Nemetz
40d ago
50
51 Vole does not require or check Git commit signatures. A signature would only
6c84d387
Keenan Nemetz
40d ago
52 repeat what the credential already established, and it cannot reliably prove who
53 authored a commit. Vole would rather keep one clear path than add a second one
54 that can disagree with the first.
520470e1
Keenan Nemetz
40d ago
55
56 ## What that means
57
58 On the server, Vole can show a complete history of who pushed what. A clone of a
59 repository, by itself, cannot prove who pushed a commit. The instance promises a
60 complete record; it does not promise offline proof.
61
348a43c3
Keenan Nemetz
20d ago
62 That trade-off is wrong if you need a mirror to prove who pushed each commit.
63 For a team running its own forge, it leaves one authentication path and one
64 auditable record on the instance.
520470e1
Keenan Nemetz
40d ago
65
66 ## Where data lives
67
1a9b3838
Keenan Nemetz
3d ago
68 Git holds the repository history. SQLite holds the authoritative instance
69 database (accounts, access rules, release channels, the CI queue and records, and
70 the sealed secret rows) and the derived index. That is two files rather than one
71 because the index is rebuilt wholesale and is the only part an operator can skip
72 when backing up; everything that has to be restored together lives in
73 `instance.db`. The
3047be84
Keenan Nemetz
17d ago
74 user-facing
d1f44d83
Keenan Nemetz
21h ago
75 [instance data reference](docs/configuration.md#instance-data)
34a6094a
Keenan Nemetz
20d ago
76 inventories each path and its backup requirements;
d1f44d83
Keenan Nemetz
21h ago
77 [Backup and restore](docs/backup-and-restore.md#back-up-an-instance) provides the procedure.
520470e1
Keenan Nemetz
40d ago
78
8f6548a6
Keenan Nemetz
3d ago
79 SQLite has one writer per file, and the instance has several: a push, a merge, a
80 runner reporting a result. They queue rather than collide, and the settings that
81 make that true live in one place (`internal/sqlstore`): WAL so a reader never waits
82 for a writer, immediate transactions so a writer takes the lock up front instead of
83 failing to upgrade, and a busy timeout so a second process waits its turn. A process
84 that only reads — the push hook, sshd's key lookup — opens a read-only handle and
85 cannot write a schema. The write-ahead log is synced at a checkpoint rather than at
86 every commit, so a power loss can drop the newest commits but cannot corrupt the
87 file.
88
dced06da
Keenan Nemetz
34d ago
89 The web index is derived from each repository's `vole` branch. Post-receive applies
90 a push's delta as the push lands, so a page does not pay for the work the push
91 already did. Every read still checks the branch it was built from — reading the
92 loose ref, which is a file, rather than starting a process — and repairs the rows
93 if a hook did not run. `vole admin index rebuild` is the last resort.
94
122cbe4f
Keenan Nemetz
31d ago
95 Writers of that branch take turns. A write reads the branch, decides, and moves the
96 ref only if nobody else moved it first, so two people commenting at the same time
97 cannot lose either comment; the price of that safety is that a writer which loses
98 the race reads the branch again. Under load that price is the whole cost, so writers
99 of one repository queue behind each other instead: the read, the decision, and the
100 ref move happen while one writer holds the branch, and the compare-and-swap is left
101 for a push or a hand-run git command that could not wait.
102
103 A push only queues behind those writers when it has metadata to move. Most do not:
104 a branch becomes interesting to a change request when one is opened from it, and
105 post-receive asks the index which open requests follow the branch before it reads
106 the metadata branch at all. A push to a branch nobody is proposing from therefore
107 writes an audit line and nothing else.
108
520470e1
Keenan Nemetz
40d ago
109 The `vole` branch contains:
110
111 ```text
112 issues/<ulid>/issue.md
113 issues/<ulid>/comments/<ulid>.md
b492b557
Keenan Nemetz
27d ago
114 changes/<ulid>/change.md
115 changes/<ulid>/comments/<ulid>.md
116 changes/<ulid>/approvals/<account-name>.md
520470e1
Keenan Nemetz
40d ago
117 releases/<tag>/<artifact>
118 ```
119
b312e166
Keenan Nemetz
35d ago
120 People write the issue and request files. Vole moves the head of a change request
121 that follows a branch: post-receive derives the new head from the accepted ref and
122 validates the request tree before committing it. A tagged build that publishes
123 release artifacts writes those pointers the same way. Everything that is pushed is
124 checked at the boundary.
125
59badc63
Keenan Nemetz
35d ago
126 Run records are not in Git. A runner sends its result over the authenticated SSH
1a9b3838
Keenan Nemetz
3d ago
127 channel that leased the job, and the server stores it in `data/instance.db`; a
128 clone or backup of a repository does not carry CI history.
520470e1
Keenan Nemetz
40d ago
129
b7396a11
Keenan Nemetz
24d ago
130 ## URL layout
131
132 A repository owns the root of the URL space. `/<name>` is its summary page,
133 `/<name>/issues` and the rest are its tabs, and `/<name>.git` is the Git
134 transport a clone uses. There is no owner segment: repository names are unique
135 on the instance, so one name is enough.
136
137 Every page the forge itself serves is under `/-/`: `/-/admin`, `/-/u/<account>`,
138 `/-/activity`, `/-/login`, and so on. A repository name can never begin with `-`,
139 so the two spaces cannot collide and no route has to know the repository names.
140 The four names the forge keeps at the root are the ones a URL cannot move:
141 `static` for assets, and `robots.txt`, `sitemap.xml`, `sitemap-pages.xml` because
142 crawlers only look there. Repository creation refuses those names.
143
144 `/<name>.git` is recognized before the router, because a wildcard in a route
145 fills a whole path segment and cannot match `<name>.git`. Keeping the suffix on
146 the transport is what lets the page (`/<name>`, which is also the Go module path)
147 and the clone URL share a name.
148
520470e1
Keenan Nemetz
40d ago
149 ## Why these choices
150
151 | Choice | Reason |
152 |---|---|
153 | Use the Git command-line tool | Full push behavior and hooks without reimplementing Git |
474a812d
Keenan Nemetz
40d ago
154 | SSH for Git writes, passkeys for the browser | Each transport gets the credential it can actually use, and both resolve to one account |
bca53bda
Keenan Nemetz
16d ago
155 | One SSH endpoint per instance | Vole's listener or the system sshd in front of it — one setting — and either way `vole serve` is the only writer |
6c84d387
Keenan Nemetz
40d ago
156 | Check everything before accepting a change | The push boundary and the narrow web writers share the same metadata validation |
3047be84
Keenan Nemetz
17d ago
157 | Store metadata in Git, rules in SQLite | Repository content travels with clones; local settings stay local. Release channels are the deliberate server-side exception: they are consumed from the public URL, so they live in `data/instance.db` rather than a clone. |
ab326d3a
Keenan Nemetz
38d ago
158 | Passkeys, not passwords | No shared secret to phish, reset, or store; recovery is an instance-admin-issued enrollment link |
520470e1
Keenan Nemetz
40d ago
159 | One program with separate serve and runner modes | Easy to deploy anywhere |
0c40a1d3
Keenan Nemetz
31d ago
160 | Two long-term secrets: the host key, and the key that seals repository secrets | A deploy key has to live somewhere, and a value in Git is a value in every clone |
520470e1
Keenan Nemetz
40d ago
161
162 ## Using Vole as a library
163
164 Vole is also a Go library. You can build tools that talk to an instance or embed
165 parts of Vole without running the `vole` command.
166
167 | Package | What it does |
168 |---|---|
169 | `client` | Talks to an instance: metadata writes, identity lookups, file transfer, reviews, and site deploys |
170 | `core/id`, `core/git`, `core/lfs` | Shared primitives and storage |
171 | `forge` | Instance setup and administration |
0c40a1d3
Keenan Nemetz
31d ago
172 | `forge/config`, `forge/identity`, `forge/access`, `forge/repo`, `forge/index`, `forge/session`, `forge/secret` | Settings, accounts, permissions, repositories, search, browser sessions, and each repository's sealed secrets |
520470e1
Keenan Nemetz
40d ago
173 | `metadata` | Issues, requests, releases, comments, approvals, and validation |
3b39a84c
Keenan Nemetz
39d ago
174 | `ci` | Workflow validation and the job queue |
175 | `ci/agent` | The embeddable runner: leasing, execution, and reporting |
de3eec16
Keenan Nemetz
2h ago
176 | `ci/execute` | The execution interface a job runs behind: one implementation per kind of environment |
177 | `ci/container` | The OCI implementation: the container a job runs in, shared by the runner and `vole workflow run` |
3b39a84c
Keenan Nemetz
39d ago
178 | `ci/cache` | The per-repository job cache: namespaces, environment, and eviction |
520470e1
Keenan Nemetz
40d ago
179 | `server` | Network listeners and web pages, with adapters for SSH, Git HTTP, sites, and hooks |
180
181 `cmd/vole` is only the command-line front end. Logic shared by more than one
182 caller lives in the packages above.
183
184 ## Scope
185
186 Vole is built for one team on one server. It does not support multiple tenants,
7da9111e
Keenan Nemetz
40d ago
187 federation, custom domains with automatic certificates, horizontal scaling, or a
188 Kubernetes deployment story. These are not part of Vole today.
189
70b70264
Keenan Nemetz
40d ago
190 CI isolation is a runner responsibility: every job names its OCI image in the
191 workflow, or references a definition under `.vole/images`, and the runner executes
192 it in a container. The runner pulls or builds the image and owns the container
193 runtime; the server only pins the image and definition and records what ran.
348a43c3
Keenan Nemetz
20d ago
194
de3eec16
Keenan Nemetz
2h ago
195 Where the steps run is behind one interface, `ci/execute.Executor`. The container is
196 one implementation; a job that needs a guest of its own — a macOS or Windows machine,
197 or a Linux microVM — is another, and the runner, the queue, the log, the cache, and
198 the record do not change for it. An executor states what it can honour (a network, a
199 service beside the job, resource limits) and the runner refuses a job that asks for
200 more, so a workflow is never quietly given less than it declared.
201
348a43c3
Keenan Nemetz
20d ago
202 ## Next
203
d1f44d83
Keenan Nemetz
21h ago
204 - [Backup and restore](docs/backup-and-restore.md) — protect the authoritative state
205 described above.
34a6094a
Keenan Nemetz
20d ago
206 - [Accounts and access](docs/accounts-and-access.md) — apply the credential and
207 role model.