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.
Merge release channels into the account database and rename it instance.db
3047be84e9bce79372051c09854ce9b05f12a9bf · Keenan Nemetz · 17d ago · parent 262e516e
Merge release channels into the account database and rename it instance.db The instance keeps four SQLite files instead of five. Release channels were in a file of their own only because they were added beside the derived index; they are authoritative source state, like the roster, so they belong in the file an operator restores. Nothing has to be migrated: channels.db never shipped in a release, so only an instance tracking main can have one. The account database is now data/instance.db. The package comments already called it that; only the filename disagreed. Moving an existing instance is an operator step, by decision: a rename under a live server can lose the -wal file a hook subprocess still has open. Vole refuses to start while data/users.db is still in place, and says what to move, rather than creating an empty database beside it that would look like a successful upgrade. The list of databases now lives in Config.Databases, which TightenSecrets, the hook plumbing, and the admin commands read, so a missed -wal file is no longer a nine-file change. `vole admin account backup <path>` becomes `vole admin db backup <dir>` and covers every authoritative database; `db list` and `db check` answer what to back up and whether it is intact.
forge/config/config.go +45−10
| @@ -247,17 +247,31 @@ func fileExists(path string) bool { | |||
| 247 | 247 | ||
| 248 | 248 | func (c *Config) ReposDir() string { return filepath.Join(c.DataDir, "repos") } | |
| 249 | 249 | ||
| 250 | // UsersDB is the authoritative user roster: accounts, the names they have ever | ||
| 251 | // held, and their SSH keys. It is not derived and not rebuildable. | ||
| 252 | func (c *Config) UsersDB() string { return filepath.Join(c.DataDir, "users.db") } | ||
| 250 | // InstanceDB is the one database of authoritative instance state: accounts and | ||
| 251 | // the names they have ever held, SSH keys, passkeys, browser sessions, access | ||
| 252 | // rules, LFS locks, page-view counters, and release channels. None of it is | ||
| 253 | // derived from Git and none of it is rebuilt by an index rebuild, which is why | ||
| 254 | // it is one file: everything here has to survive a restore together. | ||
| 255 | func (c *Config) InstanceDB() string { return filepath.Join(c.DataDir, "instance.db") } | ||
| 256 | |||
| 257 | // LegacyInstanceDB is where the roster lived before release channels joined it. | ||
| 258 | // It is named only by the startup check that refuses a data directory which has | ||
| 259 | // not been moved to instance.db. | ||
| 260 | func (c *Config) LegacyInstanceDB() string { return filepath.Join(c.DataDir, "users.db") } | ||
| 261 | |||
| 262 | // LegacyChannelsDB is the file release channels lived in before they joined the | ||
| 263 | // instance database. No release shipped it; it exists only on an instance that | ||
| 264 | // tracked main, and the startup check names it so a stray file is not left | ||
| 265 | // behind. | ||
| 266 | func (c *Config) LegacyChannelsDB() string { return filepath.Join(c.DataDir, "channels.db") } | ||
| 253 | 267 | ||
| 254 | 268 | // AuditLog records privileged operations, including every roster change. | |
| 255 | 269 | func (c *Config) AuditLog() string { return filepath.Join(c.DataDir, "audit.log") } | |
| 256 | 270 | func (c *Config) IndexDB() string { return filepath.Join(c.DataDir, "index.db") } | |
| 257 | 271 | ||
| 258 | 272 | // SecretsDB holds each repository's sealed secrets. It is a separate file from | |
| 259 | // the roster because it is the one database whose contents are encrypted, and a | ||
| 260 | // copy of it without SecretsKeyPath is ciphertext. | ||
| 273 | // the instance database because it is the one database whose contents are | ||
| 274 | // encrypted, and a copy of it without SecretsKeyPath is ciphertext. | ||
| 261 | 275 | func (c *Config) SecretsDB() string { return filepath.Join(c.DataDir, "secrets.db") } | |
| 262 | 276 | ||
| 263 | 277 | // SecretsKeyPath is the AES-256 key that seals those values. It is created on | |
| @@ -279,11 +293,32 @@ func (c *Config) SecretsKeyPath() string { | |||
| 279 | 293 | // restores the finished history. | |
| 280 | 294 | func (c *Config) RunsDB() string { return filepath.Join(c.DataDir, "runs.db") } | |
| 281 | 295 | ||
| 282 | // ChannelsDB holds release channels: mutable server-side aliases for immutable | ||
| 283 | // releases. It is authoritative and separate from the derived index, so an index | ||
| 284 | // rebuild cannot discard a channel and a channel move has no Git worktree to | ||
| 285 | // touch. Back it up with the other authoritative databases. | ||
| 286 | func (c *Config) ChannelsDB() string { return filepath.Join(c.DataDir, "channels.db") } | ||
| 296 | // Database is one SQLite file the instance owns. The list it belongs to is what | ||
| 297 | // `vole admin db` reports and backs up, so it is also the one place a new file | ||
| 298 | // has to be declared. | ||
| 299 | type Database struct { | ||
| 300 | Name string | ||
| 301 | Path string | ||
| 302 | // Rebuildable is true for a database Vole can recreate from the repositories | ||
| 303 | // on disk. A backup may skip it, and losing it costs time, not history. | ||
| 304 | Rebuildable bool | ||
| 305 | // Sealed is true for a database whose contents are ciphertext without | ||
| 306 | // Config.SecretsKeyPath. It still belongs in a backup, next to the key. | ||
| 307 | Sealed bool | ||
| 308 | } | ||
| 309 | |||
| 310 | // Databases lists every SQLite file in the data directory, authoritative ones | ||
| 311 | // first. Backup, hardening, and the admin commands walk this list rather than | ||
| 312 | // naming files themselves: a missed -wal file is otherwise a silent, and only | ||
| 313 | // sometimes visible, gap. | ||
| 314 | func (c *Config) Databases() []Database { | ||
| 315 | return []Database{ | ||
| 316 | {Name: "instance.db", Path: c.InstanceDB()}, | ||
| 317 | {Name: "runs.db", Path: c.RunsDB()}, | ||
| 318 | {Name: "secrets.db", Path: c.SecretsDB(), Sealed: true}, | ||
| 319 | {Name: "index.db", Path: c.IndexDB(), Rebuildable: true}, | ||
| 320 | } | ||
| 321 | } | ||
| 287 | 322 | ||
| 288 | 323 | // SpoolDir receives accepted push events from post-receive hooks. | |
| 289 | 324 | func (c *Config) SpoolDir() string { return filepath.Join(c.DataDir, "queue", "spool") } | |