Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Spec-driven workflow

Vix is developed specification-first. Each member crate’s spec/index.md describes that crate’s intended behavior and is the source of truth; the code implements it. Cross-cutting / app-level specs live at the repo-root spec/.

The loop

  1. Read the spec. Find the owning crate’s spec/index.md (or the relevant root spec/ topic — see the map below). If the change alters intended behavior, edit the spec first so it stays authoritative.
  2. Implement in the smallest fitting module. Keep editing/state logic in the library; keep rendering in tui/src/ui.rs.
  3. Internationalize any new user-facing text: add the key(s) to the right crates/vix-i18n/locales/*.yml file (English at minimum; other locales fall back to English) and render with t!.
  4. Document every new public item (the build denies missing docs).
  5. Test: extend tui/tests/integration/main.rs (its mods: common.rs for shared fixtures, plus one file per area — ai, catalog, compare, cowork, db, editing, find, git, ide_parity, im, keybindings, keymaps, large_file, lsp, mcp, menu, modal, org, palette, panels, save, scripting, themes, workspace, and others; ls tui/tests/integration/) or a module’s unit tests. Remote editing has its own top-level suites (tui/tests/authority_*.rs, remote_agent.rs, remote_ui.rs). A pure transform gets unit tests next to it; a fuzz target if it parses untrusted text; a Criterion benchmark if it runs per keystroke or per frame.
  6. Verify: run the whole scripts/check gate (fmt, build, clippy at pedantic with -D warnings, tests, feature combinations, headless examples, cargo doc with warnings denied, generated reference docs and man page current, semver, scripts/check-docs with CSpell, per-binary licenses). It ends with OK (scope changed, …) by default, because locally cargo doc and semver cover only the crates changed since main plus their dependents (a root, toolchain or lint file change widens this to the whole workspace; --scope all forces it, and CI and the attestation use it), or with OK: … all passed for the whole workspace. It runs in a clean room (T764): no kache/sccache wrapper on PATH or in RUSTC_WRAPPER, HOST_CC=cc, HOST_CXX=c++, set by scripts/check itself (opt out with VIX_CLEAN_ROOM=0), so do not strip them by hand. Give every gate that runs at the same time its own CARGO_TARGET_DIR (one per worktree, never one shared; cargo’s lock serializes a shared directory), and read the ==> environment: line in the log to see what it ran in. While iterating, scripts/check --tier fast (fmt, clippy and tests of the crates changed since main) or --tier push is quicker, but only the default full tier counts as the landing gate; the shorter tiers end in OK (tier …), never the full pass line. Run all of it right before every commit you intend to land, not a hand-picked subset: cargo doc, the reference-docs diff and check-docs catch things clippy and the tests never see.
  7. Record user-visible changes in CHANGELOG.md.

Landing a change

  • One branch per change, off main; merge with git merge --no-ff so the feature boundary stays in history, then delete the branch. Push only when the maintainer asks (git push origin main reaches GitHub, GitLab and Codeberg at once).
  • Attest before pushing (T761). scripts/attest runs the full gate on a clean checkout and records a signed note (refs/notes/vix-gate) bound to the tree. make hooks installs a pre-push hook that refuses to push main or a tag without a valid attestation (scripts/attest --verify); a non-main branch may use VIX_ALLOW_UNATTESTED=1 (the hook then runs the fast tier), main and tags never. Its pre-commit hook checks staged files only (format, secrets, new files over 1 MiB, code lints; T833). Push the notes beside main with git push origin refs/notes/vix-gate. Commit signing is never bypassed. See spec/local-ci.
  • Several agents share one checkout. Work in your own git worktree (.claude/worktrees/<name>), and merge large branches in a separate worktree rather than switching the shared checkout’s branch under another session. Check git status and git log fresh before starting: another session may already have landed the task.
  • Never use a bare git stash/git stash pop: the stash stack is shared by every worktree. Prefer a temporary WIP commit.
  • Commits are SSH-signed (commit.gpgsign). The first signature in a session can wait on the key’s passphrase; run git commit under a timeout (for example timeout 90 git commit …) and stop to ask if it hangs, rather than disabling signing.
  • AI-assisted commits end with a Co-Authored-By: trailer naming the model; the git author and committer stay human. See AI_STATEMENT.md for what an agent may do without asking (it may run cargo publish; it may not tag or cut a release).

Reviewing a change

Review against the same rules the change had to follow; the pull-request template (.github/pull_request_template.md, with an identical .forgejo/pull_request_template.md that tui/tests/code_lints.rs keeps in step) is the author’s half of this list.

  1. Read the spec diff first. The owning spec should say what the code now does. A behavior change with no spec change, or a spec that describes something the code does not do, is drift: ask for the missing half rather than approving one side.
  2. Read the whole diff, tests included. git diff main...<branch> (three dots: only what the branch added). A changed snapshot under tui/tests/snapshots/ is read line by line; an unexplained moved line is a regression until shown otherwise.
  3. Check what the tools cannot. clippy, the tests and scripts/check-docs catch most mechanical slips. A reviewer looks for what they miss: a user-facing string outside t!, or a key missing from a locale its neighbors have; a new action id without exactly one run_action arm and a menu leaf, palette entry or vix-action-catalog row; an #[allow] without a reason; unwrap/expect on a runtime path; unchecked arithmetic in new code (spec/rust-checked-arithmetic); a new child process or print that went into an allowlist without a convincing reason (tui/tests/spawn_sites.rs, tui/tests/code_lints.rs); a public API break in a published crate (cargo semver-checks, run by the full gate).
  4. Check the bookkeeping. A user-visible change has a CHANGELOG.md line under [Unreleased]; a task is ticked in tasks.md with its (Done: …) note; regenerated files (docs/reference/) match their generator.
  5. Check provenance. git log --show-signature main..<branch> shows every commit signed, and an AI-assisted commit ends with its Co-Authored-By: trailer. scripts/attest --verify <rev> says whether that tree passed the full gate; without an attestation, run scripts/check yourself before merging.
  6. Prefer a question to a guess. Comment on the line, say what you expected and why (a spec section, a rule, a failing case). Approving means you would be willing to land it yourself; merging is git merge --no-ff, as above.

Writing a spec

A spec says what the feature is, not how the code happens to be arranged today. Keep them in this shape:

  • One page per crate at crates/<crate>/spec/index.md; a crate with several distinct features adds spec/<topic>/index.md sub-specs and links them.
  • Open with the contract: the action ids, the menu path, and the one-sentence behavior. A reader should be able to stop after the first paragraph.
  • Tables for enumerable things — items, actions, keys, settings, formats. Prose for the rules that are not a list.
  • Say why, where it is surprising. A spec that records the reason for a decision survives the next refactor; one that restates the code does not.
  • Name the code that implements it (module, function, host method) at the end, so drift is visible from either side.
  • Point at neighbors with relative links, and keep them resolvable — scripts/check-docs fails on a broken one.

Some documentation directories carry index.md and a byte-identical README.md — the doc map links the first, a forge renders the second when you browse to the directory. Where both exist they must match: make README.md a symlink (ln -s index.md README.md) and edit only index.md. scripts/check-docs fails if they drift.

Auditing for drift

Drift is when code, spec, and docs disagree. scripts/check-docs catches the mechanical half — broken links and paths, a crate with no spec, a crate missing from the crate map, a README.md that no longer matches its twin. The rest is a reading job:

  • Compare each crate’s spec/index.md against the crate it describes (and the root spec/ topics against the app shell).
  • Compare README.md / index.md / docs/* against current features, crate names, and key bindings — bindings rot fastest.
  • Check that every action id used by a menu or the palette has a run_action arm and an i18n label key, and that no run_action arm is unreachable.
  • Check that user-facing strings go through t!, that every t! key exists in crates/vix-i18n/locales/, and that each call fills exactly the %{name} placeholders its string declares — tui/tests/i18n_keys.rs now gates all three, because all three shipped broken at least once. (locale is reserved by t!: it selects the target locale, so it can never be a placeholder name.)
  • Check that every menu item has a <label>.help tooltip key; show_menu_tooltips is on by default, so a missing one is a blank hover.
  • Run scripts/docs-coverage after adding a user-facing crate: it lists crates with no docs/ page (docs/coverage.md); give the crate a page or add a reasoned EXCLUDE entry.
  • Watch for counts and versions in prose (crate count, keymap count, language count, toolchain floor) — they are the first thing to go stale.

Fix drift by aligning all three (code, spec, docs).

Spec map

Feature specs live at crates/<crate>/spec/index.md; cross-cutting ones stay at the repo-root spec/. Notable ones:

SpecCovers
spec/indexOverview, dependencies, architecture, status
spec/navigationPosition history, go-to-definition/symbol
spec/overlay-priorityOne table orders overlay drawing and keys
spec/toolsThe Tools menu and which crate owns each item
spec/testTest strategy: unit, integration, fuzz, bench
spec/ciThe gate, and the three forges that run it
spec/rust-clippy-pedanticclippy::pedantic on all targets
spec/rust-msrv-n-minus-2The MSRV policy: current stable minus two
spec/agents-directory-name-is-lowercaseWhy the guidance lives in agents/, lowercase
spec/dependabotDependabot: security updates + scheduled PRs
spec/comparisons, spec/emacs-menusEditor comparisons; Emacs menu parity
spec/cargo-featuresCapability features (full, net, opt-in cowork)
spec/remote-editing, crates/vix-authority/specRemote editing over SSH; the authority slot
spec/cowork, spec/instant-messageReal-time co-editing; the IM menu
spec/mcp-server, spec/jupytervix --mcp; the Jupyter design (spike only)
spec/ide-parity, spec/open-containerIDE-parity features; the OC container menu
spec/worldwideNo feature may favor one country or region
spec/llms-json-and-llms-txt, spec/monorepo-github-pagesAI maps; the website subproject
crates/vix-menu/specMenu bar structure and every item
crates/vix-keymap-model/specThe fourteen keymaps and how keys dispatch
crates/vix-palette/specPalette modes and behavior
crates/vix-editor/specThe editor host: tabs, splits, per-action specs
crates/vix-editor-core/specThe editor widget: buffer, wrap, brackets, history
spec/find-and-replace, crates/vix-find-panel/specFind/replace, workspace search, query-replace
crates/vix-fileops/spec, crates/vix-left-dock/specExplorer tree and file operations
crates/vix-lsp/spec, crates/vix-dap/specLanguage Server Protocol; DAP debugger
crates/vix-git/specGit status/diff/staging/conflicts
spec/git-monoreposLarge-repository costs, measured (T800)
crates/vix-db/specThe database workbench
crates/vix-org/spec, crates/vix-org-table/spec, crates/vix-org-capture/specOrg editing, tables, capture
crates/vix-theme/spec, crates/vix-i18n/specThemes; internationalization
crates/vix-settings/spec, crates/vix-session/specSettings keys; session/workspace restore
crates/vix-clipboard/specClipboard access and its test isolation