Files
buzz/crates
Sepehr Karimi 55823dd54f 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>
2026-11-25 21:24:29 -08:00
..