| 1 | // The event vocabulary of a valley host: what its bus carries. Phase 1 |
| 2 | // (design/roadmap.md) defines exactly one event; later phases add an event |
| 3 | // or a field at a time, never more. |
| 4 | // |
| 5 | // Events are a projection of git, never a second source of truth. Every |
| 6 | // field here is derivable from the repository alone, so replaying a repo's |
| 7 | // refs reproduces the same events โ the phase's determinism criterion. |
| 8 | // Wall-clock time, hostnames, and other machine facts are deliberately |
| 9 | // absent: any of them would make replay produce different events. |
| 10 | // |
| 11 | // Like the host schema, this file is not Nix. The NixOS module's hook is |
| 12 | // one publisher; any other publisher or consumer reads the same file. |
| 13 | // |
| 14 | // Validate a payload: cue vet -d '#RefUpdated' schema/events.cue <payload>.json |
| 15 | package valley |
| 16 | |
| 17 | // #RefUpdated is published once per ref a push updates, on the subject |
| 18 | // valley.git.<repo>.ref-updated: the ref's name and its object id before |
| 19 | // and after. Creation and deletion carry the all-zero id on the |
| 20 | // corresponding side โ git's own convention. A replay of a repo's current |
| 21 | // refs emits one event per existing ref with the all-zero id as `old`, |
| 22 | // because a ref's prior value is not derivable from the repository. |
| 23 | #RefUpdated: { |
| 24 | // The event's type, and its subject's last token. |
| 25 | event: "ref-updated" |
| 26 | |
| 27 | // The project name on the publishing host โ the same name |
| 28 | // #Host.projects keys on, and the <repo> token of the subject. |
| 29 | repo: =~"^[a-zA-Z0-9][a-zA-Z0-9._-]*$" |
| 30 | |
| 31 | // The full ref name, e.g. "refs/heads/main". |
| 32 | ref: =~"^refs/" |
| 33 | |
| 34 | // Object ids: lowercase hex, 40 (sha1) or 64 (sha256) digits, |
| 35 | // all-zero for "no value on this side". |
| 36 | old: #ObjectId |
| 37 | new: #ObjectId |
| 38 | } |
| 39 | |
| 40 | #ObjectId: =~"^([0-9a-f]{40}|[0-9a-f]{64})$" |