Skip to content

Latest commit

 

History

History
69 lines (49 loc) · 3.31 KB

CONTRIBUTING.md

File metadata and controls

69 lines (49 loc) · 3.31 KB

Contributing to Yen

Coding standards, design invariants, and verification workflow for Yen.

Contributing to 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.

Core design principles

  1. Refs, never strings. Every tag, enum, kind, field, sink, aspect, kit, role, and relation is a typed Nix reference (yen.gpu.nvidia, never "nvidia").
  2. Zero external dependencies in core, std, and agent. Pure Nix builtins only.
  3. One engine for at and Datalog. Every at selector, yen.relations, and yen.invariants runs in one Tupu-inspired stratified Datalog solver.
  4. One reactive pipeline for sinks. Declarative emissions, cycle = sources: sinks, kind walls, and middleware run in one Cycle.js-inspired sources -> sinks fixpoint.
  5. Fail closed. Return structured error records (yen.errWith) instead of crashing with throw, abort, or assert.

Nix coding standards (checked by tests/style.nix)

Every .nix file under lib/, tests/, std/, agent/, docs/, and templates/ must follow these rules:

  • At most one let per file, at the top. Do not nest let ... in inside expressions. Put small helper functions in the top let block.
  • Bind b = builtins; and qualify every builtin (b.mapAttrs, b.foldl', b.elem).
  • Zero rec, with, throw, abort, or assert.

Documentation and lint rules:

  • Zero import inside lib/, std/modules/, std/kits/, agent/lib/, and docs/examples/. The root loader (default.nix) injects self._meta.importFile where module loading needs it.
  • Document every public export in lib/api.nix with a #: comment directly above it.
  • Document every engine error code in docs/examples/errors-reference/page.nix.
  • Format with nixfmt and keep statix check -c statix.toml . at zero warnings.

Kits and assemblies rules

  • Kits declare settings, roles, optional exports, and optional parts for 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.

Verification and mutants

  1. Write the test or doc example first and see it fail.
  2. Make the smallest fix and see it pass.
  3. 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.
  4. 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
  1. Regenerate committed docs, workflows, and issue templates whenever docs/ changes:
nix run ./docs#write-files

Pull requests

  • 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.