3.2 KiB
Agent notes
Guidance for AI agents (and humans) working on this repo.
Rust style
-
Prefer top-level
useimports over inline fully-qualified paths. Write:use std::fs; ... fs::write(&path, data)?;not:
std::fs::write(&path, data)?;This applies even to single call sites and to imports inside a function body (
use std::os::unix::fs::PermissionsExt;inside afnshould be hoisted to the top of the file instead). -
If an import is only needed under a
#[cfg(...)]-gated function or block, gate theusewith the same#[cfg(...)]rather than importing it unconditionally (which would produce an unused-import warning on other platforms). Example:main.rs's Linux-onlyWEBKIT_DISABLE_DMABUF_RENDERERworkaround uses#[cfg(target_os = "linux")] use std::env;. -
Run
cargo fmtafter adding/moving imports — rustfmt reorders and groupsusestatements (including#[cfg(...)]-gated ones) and CI enforces this viacargo fmt --check(nix flake check→stahl-fmt). -
cargo clippy --all-targets -- --deny warningsmust be clean (also enforced bynix flake check→stahl-clippy).
Nix flake maintenance
flake.nix builds the frontend hermetically via pkgs.fetchPnpmDeps, which
is a fixed-output derivation pinned to frontendDepsHash. Any change to
frontend/package.json or frontend/pnpm-lock.yaml invalidates that hash.
To regenerate it:
- Set
frontendDepsHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";(nix'slib.fakeHash) inflake.nix. - Run
nix build .#stahl -Land copy thegot: sha256-...value from the hash-mismatch error back intofrontendDepsHash. - Rebuild to confirm it succeeds.
This hash is the same across x86_64-linux, aarch64-linux, x86_64-darwin,
and aarch64-darwin — fetchPnpmDeps fetches every optional dependency
listed in the lockfile (all os/cpu native-binary variants), not just the ones
matching the host, so there's no need for a per-system hash.
Do not remove the pnpmForFetch (nodejs-slim_26) override in flake.nix.
It works around a real, reproducible V8/libc++ ODR-violation bug in
nixpkgs' default Node 24
(NixOS/nixpkgs#536039)
that can hard-kill pnpm install mid-fetch under load. Confirmed locally:
removing the override lets the fd-tracking warnings spam through, and the
fetch gets Killed: 9 under load; restoring it fixes it.
Frontend tooling
Linting/formatting use Oxlint and Oxfmt, not ESLint/Prettier:
pnpm --dir frontend lint # oxlint
pnpm --dir frontend fmt # oxfmt (writes)
pnpm --dir frontend fmt:check # oxfmt --check
CI
.github/workflows/ci.yml uses cachix/install-nix-action (not
DeterminateSystems' installer/FlakeHub — keep this on plain, non-proprietary
Nix tooling) and runs nix flake check + nix build .#stahl on Linux and
macOS. It reads from the public cache.nixos.org and
nix-community.cachix.org substituters already declared in flake.nix's
nixConfig; there is no project-specific push cache configured.