Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,39 @@
- Final step: The WebTransport Protocol Framework (https://www.ietf.org/archive/id/draft-ietf-webtrans-overview-11.txt)


## Code style: TigerStyle, in part

We follow [TigerStyle](https://github.com/tigerbeetle/tigerbeetle/blob/main/docs/TIGER_STYLE.md)
for the rules below. Nothing enforces them in the build; they hold by review.

- **Functions end at 70 lines.** The parent keeps the control flow, helpers take
the straight-line work and carry the caller's name as a prefix
(`processFrame` → `processFrameAck`). Type-returning functions (generic
struct bodies) and `test` blocks are exempt; their methods are not.
- **Assert what our own code guarantees**: preconditions, postconditions,
invariants, relationships between constants (`comptime`). One property per
assert; `if (a) assert(b);` for implications.
- **Never assert what a peer, the network, a file or a caller of the public
API can make false.** That is a remote crash, and undefined behaviour in
ReleaseFast. Those stay error returns.
- **Every loop has a bound**, in its condition or as an asserted progress
step. A loop that must not end (an event loop) says so in a comment.
- **Every error is handled, or ignored on purpose** with a one-line comment
saying why. `catch unreachable` sits next to the invariant that makes it so.
- **Sized integers** (`u32`, `u64`) for protocol quantities, counters and
stored fields. `usize` only for slice indexes and lengths, and where std
asks for it.
- New code stays within 100 columns.

Where we deliberately differ:

- **camelCase functions**, as in std and libxev: the public API is camelCase
and renaming it breaks every user.
- **Memory is allocated per connection and per stream**, not all at startup.
- **libxev is a dependency** (see below), and tooling under `tools/` and
`interop/` is shell where it drives Docker and other implementations.
- Existing lines over 100 columns have not been reflowed.

## Checking the Zig stdlib

This repo targets Zig 0.17 (`minimum_zig_version` in `build.zig.zon`). Never
Expand Down
Loading
Loading