Skip to content

Commit 2f3ffea

Browse files
committed
agents: add operational guide for repository contributions
Consolidate agent workflow, routing, validation, and safety rules in one place so AI changes align with repository structure and CI behavior. Signed-off-by: vadik likholetov <vadikas@gmail.com>
1 parent d85657c commit 2f3ffea

File tree

1 file changed

+127
-0
lines changed

1 file changed

+127
-0
lines changed

AGENTS.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<!--
2+
SPDX-FileCopyrightText: 2022-2026 TII (SSRC) and the Ghaf contributors
3+
SPDX-License-Identifier: CC-BY-SA-4.0
4+
-->
5+
6+
# AGENTS Guide
7+
8+
This file is the operational guide for AI coding agents working in the Ghaf repository.
9+
10+
## Purpose
11+
12+
- Ship correct, minimal, reviewable changes that follow Ghaf architecture and policy
13+
- Prefer existing patterns over invention, especially in modules, targets, and flake exports
14+
- Keep security, licensing, and reproducibility constraints intact
15+
16+
## Source Priority
17+
18+
When instructions conflict, follow this priority order:
19+
20+
1. Current task prompt from the user
21+
2. Repository code and CI workflows (actual behavior)
22+
3. `CONTRIBUTING.md`, `README.md`, `SECURITY.md`, PR template
23+
4. Additional guidance docs under `docs/` and `.github/`
24+
25+
If documentation conflicts with code or workflows, follow code and note the mismatch in your response.
26+
27+
## Repository Map
28+
29+
- `flake.nix`: top-level inputs, systems, and imported flake modules
30+
- `nix/`: devshell, treefmt, pre-commit hook wiring, and shared Nix settings
31+
- `modules/`: NixOS modules (`common`, `hardware`, `microvm`, `profiles`, `reference`, and others)
32+
- `targets/`: exported hardware and VM targets, plus cross-build variants
33+
- `packages/`: custom packages and overlays, mostly under `pkgs-by-name`
34+
- `lib/`: reusable library code, including global config and builder APIs
35+
- `tests/`: flake checks and test packages
36+
- `docs/`: Starlight/Astro documentation source
37+
- `.github/workflows/`: CI truth source for checks, eval, build, docs deploy
38+
39+
## Standard Agent Workflow
40+
41+
1. Inspect the relevant target/module/package paths before editing
42+
2. Make the smallest coherent change that matches local patterns
43+
3. Run the narrowest meaningful validation for the touched area
44+
4. Report what changed, what was validated, and what was not validated
45+
46+
Do not refactor unrelated areas in the same change unless requested.
47+
48+
## Change Routing
49+
50+
Use these rules to place changes correctly:
51+
52+
- New or changed host or VM behavior: `modules/`
53+
- Device-specific behavior: `modules/reference/hardware/` and `targets/`
54+
- New exported build target or variant: `targets/*/flake-module.nix`
55+
- Ghaf package additions: `packages/pkgs-by-name/*` and package overlay wiring
56+
- Shared build/config plumbing: `nix/`, `lib/`, `flake.nix`
57+
- Documentation pages/navigation: `docs/src/content/docs/` and `docs/astro.config.mjs`
58+
59+
## Nix Module Conventions
60+
61+
- Add SPDX headers to new files
62+
- Keep options under `ghaf.*` namespace unless extending external module options intentionally
63+
- Use `lib.mkEnableOption` for feature flags
64+
- Use typed `lib.mkOption` with clear descriptions
65+
- Use `lib.mkIf` for conditional config
66+
- Prefer `lib.mkDefault` for overridable defaults; avoid `lib.mkForce` unless required
67+
- Include `_file = ./<filename>.nix;` in Nix modules for better evaluation traces
68+
- Reuse `globalConfig` and `hostConfig` patterns already used by VM/base composition
69+
70+
## Build and Validation Matrix
71+
72+
Select checks by scope. Run the smallest set that can catch regressions in your change.
73+
74+
- Docs only:
75+
- `nix build .#doc`
76+
- Nix/module/target/package changes (minimum):
77+
- `nix fmt -- --fail-on-change`
78+
- `nix develop --command reuse lint`
79+
- Broader evaluation confidence:
80+
- `nix flake show --all-systems --accept-flake-config`
81+
- `make-checks` (if available in devshell)
82+
- CI-parity checks for pre-commit hooks:
83+
- `nix build .#checks.x86_64-linux.pre-commit`
84+
85+
For long builds or hardware-dependent paths, state clearly if validation was not run locally.
86+
87+
## Commit and PR Policy
88+
89+
Follow Linux-kernel-style commit message structure (project policy):
90+
91+
- Subject line in imperative mood, concise, no trailing period
92+
- Optional body explains what and why, wrapped for readability
93+
- Keep commits logically scoped
94+
95+
PRs should include:
96+
97+
- Clear change description and rationale
98+
- Explicit verification steps
99+
- Any skipped checks and why
100+
101+
## Security and Safety Guardrails
102+
103+
- Never commit secrets, credentials, tokens, private keys, or local machine paths
104+
- Treat flashing operations as destructive
105+
- Never guess block devices
106+
- Require explicit device path from user context before flash commands
107+
- Be careful around secure boot key material under `modules/secureboot/keys/`
108+
- Prefer reversible, auditable edits over broad rewrites
109+
110+
## Documentation and Style Expectations
111+
112+
- Keep docs in plain US English and active voice
113+
- Use title case for headings
114+
- Keep instructions explicit and step-based for operational tasks
115+
- Update docs when behavior changes
116+
117+
## Known Drift to Watch
118+
119+
- Some documentation pages may lag behind current code exports or script paths
120+
- If you find stale references, align implementation-first and include docs fixes in the same change when practical
121+
122+
## Agent Output Expectations
123+
124+
- Be explicit about files touched and why
125+
- Distinguish facts from assumptions
126+
- Call out risk, impact, and validation status
127+
- Offer next concrete steps only when useful

0 commit comments

Comments
 (0)