Voyager7 style
Adapted from TigerStyle on 2026-11-05 for a Rust terminal emulator. Where a TigerBeetle rule is changed, the change and its reason are stated. Tools enforce what they can; the rest is review.
Priorities
Safety, then performance, then developer experience. A change that improves the third at the cost of the first two is rejected. Readability is a means to safety, not a goal on its own.
Simplicity and debt
- Spend design time before code. The simple design is usually the last revision; be willing to throw a draft away.
- No known showstoppers ship: no unbounded loop, no exponential algorithm, no allocation in a hot path "for now". Missing features are fine; shipped features meet the goals.
- Do the work once. A "fix later" comment is a defect.
Control flow
- Simple, explicit control flow. No recursion. No clever iterator chains where a loop with a bound reads better.
- Every loop and queue has a fixed upper bound. A loop that is meant to run forever (the message loop, the Backend read loop) says so with an assertion on each iteration's invariants, and does bounded work per iteration.
- Split compound conditions into nested branches. Consider whether every
ifneeds anelse, and state invariants positively (if index < count). - Push
ifs up and loops down: the parent holds control flow and state, helpers compute without applying. - Functions run to completion. No function suspends with preconditions half-checked.
Limits
Everything that can grow has a cap, and the cap is named. Columns, rows, scrollback bytes, fonts loaded, fallback chain length, VT bytes consumed per tick, input events per batch, atlas size, image memory, config file size, config line length. Caps come from config with a default or from a constant with a comment saying why that number.
Assertions
- Assertions catch programmer errors. On corrupt state the correct response is to stop, write a state dump next to the config file, and exit. They stay on in release builds.
- Assert arguments, return values, preconditions, postconditions, and invariants. Aim for two per function on average.
- One condition per assertion:
assert!(a); assert!(b);notassert!(a && b). Implications readif a { assert!(b) }. - Assert the same property on two paths: before a frame is uploaded and when it is read back in a test; before VT bytes are sent and when the Scraper's oracle checks the result.
- Assert the negative space too. Tests feed invalid data and data that becomes invalid.
- A true but surprising assertion may replace a comment.
Change from TigerStyle: Rust debug_assert! is not used except in a measured
hot loop where the release assertion is shown to cost, with a comment giving the
measurement.
Memory
See ADR 0005. Allocate at initialization and at explicit reconfiguration (resize, font change, config reload). Never allocate in the per-byte, per-frame, or per-event paths. Per-frame scratch comes from one arena reset each frame. Buffers are fully used and padding is zeroed.
Change from TigerStyle: "static at startup" became "at initialization and reconfiguration", because a terminal's scrollback, fonts, and images are bounded but not known at startup.
Errors
- Every error is handled.
unwrap,expect, andpanic!are denied outside tests. - An error from the OS or a child process is a normal event, not a programmer error: the Backend ending, a font failing to parse, a GPU device being lost. These are handled, logged, and surfaced; they are never asserted.
- Slice indexing without a prior bounds check is denied; use
getor assert the bound first.
Types and arithmetic
- Stored data uses explicitly sized integers (
u16,u32,i32).usizeappears only at the indexing boundary. Change from TigerStyle: Rust requiresusizefor indexing, so the rule is narrowed rather than dropped. - Index, count, and size are different things. Add one to turn an index into a
count; multiply by the unit to turn a count into a size. Name them so the reader
can tell (
row_index,row_count,size_bytes). - Make rounding explicit:
div_ceil,div_floor, or a named helper. Pixel rounding follows terminal-rendering.md: round both edges, then subtract.
Functions
- At most 70 lines. Few parameters, a simple return type. Prefer
()overbooloveru32overOptionoverResultwhen the simpler one is honest. - Hot loops are standalone functions that take primitives, not
&self, so the compiler and the reader see exactly what is touched. - Declare variables in the smallest scope. Compute a value where it is used.
- No duplicate state. One owner per fact; derive, do not copy.
External events
Run at your own pace. Backend bytes, input events, and timers are collected and processed in batches on the program's schedule: one tick consumes at most N VT bytes and M input events, then one frame is built. The UI thread blocks when there is nothing to do; idle CPU is zero.
Naming
snake_casefor functions, variables, modules, and files. TypesCamelCase. Acronyms keep their capitalization in types (ConPtyis the one exception, for readability against Microsoft's spelling).- No abbreviations except conventional loop indices.
- Units and qualifiers last, most significant first:
latency_ms_max,scrollback_bytes_limit. - Related names have equal length where possible:
source/target. - Helpers are prefixed with their caller's name.
- Nouns over adjectives. Long flags in scripts (
--force). - Use the vocabulary in GLOSSARY.md; the words under Avoid do not appear in code.
Comments and commits
- Comments say why, in full sentences with a period. End-of-line comments may be phrases.
- Commit messages are for readers and stand alone; one logical change per commit.
- Every
unsafeblock has a// SAFETY:comment stating the invariant that makes it sound.
Formatting and lints
Enforced by tools, failing the build:
rustfmtwithmax_width = 100, four-space indentation.clippy::pedanticwith warnings denied, plusclippy::unwrap_used,clippy::expect_used,clippy::panic,clippy::indexing_slicing,clippy::too_many_linesat a 70-line threshold.#![forbid(unsafe_code)]in every portable crate.unsafeis allowed only inv7-platform-windows,v7-gpu-d3d11,v7-vt,v7-backend-conpty,v7-backend-scraper,v7-hook,voyager7-console, andvoyager7-setup(the crates that call Win32 or C directly).#![no_std]in every crate that ships on Windows (ADR 0004).- The Windows import checker runs on every Windows artifact and fails on any import newer than Windows 7 SP1 and on any Universal CRT import.
Dependencies and scripts
- Dependencies are an allowlist with a reason per entry: dependencies.md. Change from TigerStyle: zero dependencies is not practical with cosmic-text and the OS bindings; the allowlist keeps the intent.
- New tooling is a Rust
cargo xtask, not shell. Existing Python and Zig scripts stay until they need changing.
Testing
See testing.md. Tests are written before the code they test. Every golden image is approved by a person. The Windows 7 VM is the release gate.