Repository navigation
Commit 55823dd
feat(cli): guard canvas set with --expected (#9945)
## Summary
`buzz canvas set` replaced the canvas with no version check, so two
writers doing read → edit → write could silently drop each other's
edits. It now takes an optional `--expected <rev|none>`. The write lands
only if `<rev>` is still the head, or with `none` only if the channel
has no canvas. A moved head, or a write that loses the race at the
relay, exits 5 (conflict) without changing the canvas.
The submit, conflict reconciliation and post-write survival check are
now shared with `restore` as `submit_checked_canvas_write`. One behavior
change for `restore`: a lost race now exits 5 instead of passing the
relay's 409 through as exit 2. Without `--expected`, `set` is still an
unconditional replace, so existing scripts keep working. The desktop
agent tool got the same guard in block/buzz-app#4365.
### Related issue
None found.
### Testing
- `cargo test -p buzz-cli canvas` (23 tests)
- Ran on a live relay, 10 parallel writers with the same `--expected
<head>` for 5 rounds. Each round had exactly one exit 0 and nine exit 5,
and history grew by exactly one revision per round.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Signed-off-by: Sepehr Karimi <sepehr@squareup.com>
Co-authored-by: Porcupine <2306086b18f2ceee6760d2725859c7e03ce63a19299623a99dfab5ba2ac49938@buzz.block.builderlab.xyz>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent ddc3585 commit 55823dd
5 files changed
Lines changed: 233 additions & 49 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
150 | 153 | | |
151 | 154 | | |
152 | 155 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
197 | 204 | | |
198 | 205 | | |
199 | 206 | | |
| |||
599 | 606 | | |
600 | 607 | | |
601 | 608 | | |
602 | | - | |
| 609 | + | |
603 | 610 | | |
604 | 611 | | |
605 | 612 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
219 | 226 | | |
220 | 227 | | |
221 | 228 | | |
| |||
1361 | 1368 | | |
1362 | 1369 | | |
1363 | 1370 | | |
1364 | | - | |
| 1371 | + | |
1365 | 1372 | | |
1366 | 1373 | | |
1367 | 1374 | | |
| |||
0 commit comments