Coding standards, design invariants, and verification workflow for Yen.
This file is generated from docs/examples/contributing/page.nix.
Edit that file instead of CONTRIBUTING.md, then run nix run ./docs#write-files.
- Refs, never strings. Every tag, enum, kind, field, sink, aspect, kit, role, and relation is a typed Nix reference (
yen.gpu.nvidia, never"nvidia"). - Zero external dependencies in core,
std, andagent. Pure Nix builtins only. - One engine for
atand Datalog. Everyatselector,yen.relations, andyen.invariantsruns in one Tupu-inspired stratified Datalog solver. - One reactive pipeline for sinks. Declarative emissions,
cycle = sources: sinks, kind walls, and middleware run in one Cycle.js-inspiredsources -> sinksfixpoint. - Fail closed. Return structured error records (
yen.errWith) instead of crashing withthrow,abort, orassert.
Every .nix file under lib/, tests/, std/, agent/, docs/, and templates/ must follow these rules:
- At most one
letper file, at the top. Do not nestlet ... ininside expressions. Put small helper functions in the topletblock. - Bind
b = builtins;and qualify every builtin (b.mapAttrs,b.foldl',b.elem). - Zero
rec,with,throw,abort, orassert.
Documentation and lint rules:
- Zero
importinsidelib/,std/modules/,std/kits/,agent/lib/, anddocs/examples/. The root loader (default.nix) injectsself._meta.importFilewhere module loading needs it. - Document every public export in
lib/api.nixwith a#:comment directly above it. - Document every engine error code in
docs/examples/errors-reference/page.nix. - Format with
nixfmtand keepstatix check -c statix.toml .at zero warnings.
- Kits declare
settings,roles, optionalexports, and optionalpartsfor sub-kits. - A kit sets no fleet-global names, evaluates no external flake, reads no host paths, and leaks nothing between separate assemblies (
peers.<role>stays isolated per assembly). - Every role binding uses typed refs (
yen.host.nas,yen.kits.sshd.roles.server), never strings.
- Write the test or doc example first and see it fail.
- Make the smallest fix and see it pass.
- For every new check or invariant, arm a mutant. Break the invariant on purpose, see the check fail, then restore the fix and see it pass.
- Run the devshell checks before committing:
nix develop ./docs -c fmt-check
nix develop ./docs -c lint
nix develop ./docs -c engine-test
nix develop ./docs -c std-test
nix develop ./docs -c agent-test
nix develop ./docs -c template-test # every template, or: template-test minimal fleet
nix develop ./docs -c lean-test
nix develop ./docs -c docs-test
nix develop ./docs -c docs-check- Regenerate committed docs, workflows, and issue templates whenever
docs/changes:
nix run ./docs#write-files- Keep one logical change per pull request.
- Add review fixes as commits on top instead of force-pushing.
- Include the exact verification commands you ran and their outputs.