OXYGENHUB
# 5cde7882d767 oxygen / docs / revset_query_language.md
7.5 KiB · Markdown · last changed Revsets: trust predicates, and -r on show, verify and abandon 1 month ago renderedsource blame history raw
1
# Oxygen (`oxy`): Revsets Specification
2
3
| | |
4
|---|---|
5
| **Status** | Draft 1.2: the core is implemented (`oxy log -r`), trust predicates and `-r` on other commands are next |
6
| **Date** | 2026-10-04 |
7
| **Audience** | Implementers and tooling developers |
8
| **Depends on** | spec.md §6 (changes), §8 (dependencies), §9 (conflicts), §10 (states), §11 (checkpoints), §14 (identity, attestations), §22 (profiles) |
9
10
## 1. Overview
11
12
A **revset** is an expression that selects a set of changes. Mercurial
13
and Jujutsu users know the idea, so Oxygen keeps the name and much of
14
the syntax. People should not have to learn a new language to ask
15
familiar questions.
16
17
Oxygen's model makes revsets more natural than in Git:
18
- History is a set of changes, and a state is itself a set: the
19
  dependency closure of its heads. Revsets are set algebra over the
20
  dependency graph.
21
- Changes keep their identity across rebases and transport, so a saved
22
  revset means the same thing tomorrow.
23
24
Oxygen also has things no other system can query: signatures, delegates,
25
attestations and build receipts. Section 2.4 adds those.
26
27
**Implemented (2026-10-04, oxygen#65):** `oxy log -r`, `oxy show -r`,
28
`oxy verify -r` and `oxy abandon -r` with the symbols, relations,
29
operators, `author`, `description` (substring), `date`, `kind`,
30
`touches`, `latest` and the trust predicates of §2.4 below, saved
31
revsets, and a time budget. Not yet: `independent()`, `conflicts()`,
32
`description(re:…)`, `diff -r`, `push -r`, `fold`, and the hub's `?r=`.
33
Other commands take a single change (a ChangeId prefix, a `#hash`
34
prefix or `@`) or a bookmark or tag name; symbols in a revset resolve
35
exactly as they do there.
36
37
## 2. Syntax
38
39
```sh
40
oxy log -r 'main..feature & author(andy)'
41
oxy log -r 'touches("src/**") & date(-7d..)'
42
```
43
44
### 2.1 Symbols
45
46
Symbols resolve in today's order: bookmark names, then tag names, then
47
change prefixes.
48
49
| Symbol | Means |
50
|---|---|
51
| `main`, `v0.3.1` | the heads of that bookmark or tag |
52
| `origin/main` | the heads of a remote-tracking bookmark |
53
| `8c5ea12a` | the change with that ChangeId prefix |
54
| `#fc68459c` | the change with that hash prefix |
55
| `@` | the working copy's base heads |
56
| `all()`, `none()` | every stored change, no change |
57
58
### 2.2 Relations
59
60
Each function takes a set and returns a set.
61
62
| Expression | Returns |
63
|---|---|
64
| `deps(X)` | the immediate dependencies of X |
65
| `dependents(X)` | changes that immediately depend on X |
66
| `::X` | X and its whole dependency closure, which is the *state* X names |
67
| `X::` | X and everything that transitively depends on it |
68
| `X::Y` | changes that are both in `X::` and in `::Y` |
69
| `X..Y` | `::Y ~ ::X`: what state Y has that state X lacks. This is what a proposal from X to Y adds. |
70
| `heads(X)`, `roots(X)` | members of X that no other member depends on, and members that depend on no other member |
71
| `independent(X, IN)` | changes in IN that neither depend on X nor are depended on by X: what could ship without X. Only Oxygen can answer this, because changes commute. |
72
| `latest(X, n)` | the n most recent members of X, by hybrid logical clock |
73
74
### 2.3 Content and metadata
75
76
| Expression | Selects |
77
|---|---|
78
| `author(P)` | changes whose `author` identity matches name, email or KeyId P |
79
| `description(T)` | changes whose message contains T (`re:` for a regular expression) |
80
| `date(RANGE)` | changes by HLC wall time: `2026-10-01..`, `-7d..`, `..2026-09-30` |
81
| `kind(K)` | `normal`, `resolution` or `working-copy` |
82
| `touches(GLOB)` | changes that edit any node whose path matches GLOB in the evaluation state. Nodes keep their identity through renames, so this follows a file's whole history under any name. |
83
| `conflicts(S)` | changes that contributed atoms to a conflict in state S (default `@`). Conflicts belong to states, not changes. |
84
85
### 2.4 Trust: unique to Oxygen
86
87
| Expression | Selects |
88
|---|---|
89
| `signed_by(K)` | changes whose signature or seal is by key or identity K (a key prefix, a name, an email, or `me`), including a delegate such as an agent key |
90
| `delegated()` | changes signed by a delegate rather than their author |
91
| `unsigned()` | changes with no valid signature or seal |
92
| `revoked()` | changes signed by a key now revoked |
93
| `attested(KIND)` | changes in states carrying an attestation of that kind: `tag`, `receipt`, or `ref` (states a remote attested, as its tracking bookmarks hold them) |
94
| `built(JOB)` | changes in states with a valid receipt for Flow job JOB |
95
96
For example, `release..main & (unsigned() | revoked())` asks: "is
97
anything about to ship without a trustworthy signature?"
98
99
### 2.5 Operators and precedence
100
101
From tightest to loosest:
102
103
1. `::` and `..`
104
2. `~` (difference)
105
3. `&` (intersection)
106
4. `|` (union)
107
108
Parentheses group. Strings with spaces or operators are quoted.
109
`~` is difference, as in Jujutsu. There is no unary not: write `all() ~ X`.
110
`..Y` is `::Y`, and `X..` is everything the repository has beyond `X`.
111
A `date()` argument is taken as written, so `date(-7d..)` needs no quotes.
112
113
## 3. Where revsets are used
114
115
- **Commands that show history** take `-r`: `log`, `show` (several
116
  changes), `verify`, and `diff -r` (the combined edit of a set).
117
- **Commands that act on changes** take `-r` too: `abandon`, the agent
118
  workflow's `fold`, and `push -r` (push only these heads). Evaluating
119
  the revset never changes anything. A command that acts prints the
120
  selected set and refuses to act if it is empty. Above a threshold
121
  (five, for `abandon`) it refuses unless given `--yes`. `abandon -r`
122
  drops the newest first and finds each later member again by its
123
  ChangeId, since dropping a change rewrites what depended on it.
124
- **The hub API** takes `?r=` on history endpoints, evaluated only over
125
  what the caller can read.
126
- **Saved revsets:** `oxy config revset.mine 'author(me) & ::@'` lets
127
  you write `mine()`. `author(me)` is the configured identity.
128
129
## 4. Evaluation
130
131
- **Read-only.** Evaluation never mutates the graph or any reference.
132
- **On the state index.** Relations use the dependency index that
133
  `oxy log` already uses. Unions and intersections stream. Difference,
134
  `heads` and `roots` need their operands' sets, bounded by the
135
  closure being walked.
136
- **Checkpoints** stand for a state's bulk without visiting each change,
137
  so a closure walk stops at the newest checkpoint it reaches.
138
- **Budgets.** Evaluation has a time budget (10 s from the command
139
  line; `Repo::revset_with_budget` takes another), and a query that
140
  exceeds it fails with a message saying what to narrow. The hub
141
  enforces a stricter one, so a query cannot be used to load the
142
  server.
143
- **Predicates range over `all()`** (every change a bookmark, remote
144
  bookmark, tag or the working copy reaches), except that in `X & p()`
145
  the predicate is evaluated over `X` alone, so `main.. & touches("src/**")`
146
  reads only the changes beyond `main`.
147
- **Targets.** A first page of `oxy log -r` for a simple revset should
148
  appear in under 100 ms, in line with the existing log target.
149
  `touches()` and the trust predicates are slower and are cached by
150
  state hash, since a state never changes.
151
152
## 5. Profiles (§22)
153
154
- **Full and Lite** evaluate locally, within their memory targets.
155
- **Thin clients** (68000-class, 1 MiB RAM) hold no history. A Thin
156
  client sends the revset text to its trusted Full-profile proxy, which
157
  evaluates it against its graph and returns a page of ChangeIds and
158
  metadata.
159
  - The proxy applies the same budget as the hub.
160
  - Over **ZCT (§15.3) the query and its results travel in plaintext**,
161
    like everything else on that transport. ZCT stays off by default,
162
    and the client warns on every use.