OXYGENHUB
# 67a4fe1aa2d5 oxygen / docs / revset_query_language.md
7.7 KiB · Markdown · last changed bookmark: show a bookmark's heads; bookmark() in revsets 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
| `bookmark(main)`, `bookmark(origin/main)` | the heads of that bookmark only; an error if there is none (a bare name falls through to tags and change prefixes) |
53
| `origin/main` | the heads of a remote-tracking bookmark |
54
| `8c5ea12a` | the change with that ChangeId prefix |
55
| `#fc68459c` | the change with that hash prefix |
56
| `@` | the working copy's base heads |
57
| `all()`, `none()` | every stored change, no change |
58
59
### 2.2 Relations
60
61
Each function takes a set and returns a set.
62
63
| Expression | Returns |
64
|---|---|
65
| `deps(X)` | the immediate dependencies of X |
66
| `dependents(X)` | changes that immediately depend on X |
67
| `::X` | X and its whole dependency closure, which is the *state* X names |
68
| `X::` | X and everything that transitively depends on it |
69
| `X::Y` | changes that are both in `X::` and in `::Y` |
70
| `X..Y` | `::Y ~ ::X`: what state Y has that state X lacks. This is what a proposal from X to Y adds. |
71
| `heads(X)`, `roots(X)` | members of X that no other member depends on, and members that depend on no other member |
72
| `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. |
73
| `latest(X, n)` | the n most recent members of X, by hybrid logical clock |
74
75
### 2.3 Content and metadata
76
77
| Expression | Selects |
78
|---|---|
79
| `author(P)` | changes whose `author` identity matches name, email or KeyId P |
80
| `description(T)` | changes whose message contains T (`re:` for a regular expression) |
81
| `date(RANGE)` | changes by HLC wall time: `2026-10-01..`, `-7d..`, `..2026-09-30` |
82
| `kind(K)` | `normal`, `resolution` or `working-copy` |
83
| `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. |
84
| `conflicts(S)` | changes that contributed atoms to a conflict in state S (default `@`). Conflicts belong to states, not changes. |
85
86
### 2.4 Trust: unique to Oxygen
87
88
| Expression | Selects |
89
|---|---|
90
| `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 |
91
| `delegated()` | changes signed by a delegate rather than their author |
92
| `unsigned()` | changes with no valid signature or seal |
93
| `revoked()` | changes signed by a key now revoked |
94
| `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) |
95
| `built(JOB)` | changes in states with a valid receipt for Flow job JOB |
96
97
For example, `release..main & (unsigned() | revoked())` asks: "is
98
anything about to ship without a trustworthy signature?"
99
100
### 2.5 Operators and precedence
101
102
From tightest to loosest:
103
104
1. `::` and `..`
105
2. `~` (difference)
106
3. `&` (intersection)
107
4. `|` (union)
108
109
Parentheses group. Strings with spaces or operators are quoted.
110
`~` is difference, as in Jujutsu. There is no unary not: write `all() ~ X`.
111
`..Y` is `::Y`, and `X..` is everything the repository has beyond `X`.
112
A `date()` argument is taken as written, so `date(-7d..)` needs no quotes.
113
114
## 3. Where revsets are used
115
116
- **Commands that show history** take `-r`: `log`, `show` (several
117
  changes), `verify`, and `diff -r` (the combined edit of a set).
118
- **Commands that act on changes** take `-r` too: `abandon`, the agent
119
  workflow's `fold`, and `push -r` (push only these heads). Evaluating
120
  the revset never changes anything. A command that acts prints the
121
  selected set and refuses to act if it is empty. Above a threshold
122
  (five, for `abandon`) it refuses unless given `--yes`. `abandon -r`
123
  drops the newest first and finds each later member again by its
124
  ChangeId, since dropping a change rewrites what depended on it.
125
- **The hub API** takes `?r=` on history endpoints, evaluated only over
126
  what the caller can read.
127
- **Saved revsets:** `oxy config revset.mine 'author(me) & ::@'` lets
128
  you write `mine()`. `author(me)` is the configured identity.
129
130
## 4. Evaluation
131
132
- **Read-only.** Evaluation never mutates the graph or any reference.
133
- **On the state index.** Relations use the dependency index that
134
  `oxy log` already uses. Unions and intersections stream. Difference,
135
  `heads` and `roots` need their operands' sets, bounded by the
136
  closure being walked.
137
- **Checkpoints** stand for a state's bulk without visiting each change,
138
  so a closure walk stops at the newest checkpoint it reaches.
139
- **Budgets.** Evaluation has a time budget (10 s from the command
140
  line; `Repo::revset_with_budget` takes another), and a query that
141
  exceeds it fails with a message saying what to narrow. The hub
142
  enforces a stricter one, so a query cannot be used to load the
143
  server.
144
- **Predicates range over `all()`** (every change a bookmark, remote
145
  bookmark, tag or the working copy reaches), except that in `X & p()`
146
  the predicate is evaluated over `X` alone, so `main.. & touches("src/**")`
147
  reads only the changes beyond `main`.
148
- **Targets.** A first page of `oxy log -r` for a simple revset should
149
  appear in under 100 ms, in line with the existing log target.
150
  `touches()` and the trust predicates are slower and are cached by
151
  state hash, since a state never changes.
152
153
## 5. Profiles (§22)
154
155
- **Full and Lite** evaluate locally, within their memory targets.
156
- **Thin clients** (68000-class, 1 MiB RAM) hold no history. A Thin
157
  client sends the revset text to its trusted Full-profile proxy, which
158
  evaluates it against its graph and returns a page of ChangeIds and
159
  metadata.
160
  - The proxy applies the same budget as the hub.
161
  - Over **ZCT (§15.3) the query and its results travel in plaintext**,
162
    like everything else on that transport. ZCT stays off by default,
163
    and the client warns on every use.