Skip to content

Commit b6a95b7

Browse files
committed
[add] initial AGENTS.md
1 parent c84c44d commit b6a95b7

1 file changed

Lines changed: 225 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
# Repository Guidelines
2+
3+
## Project Structure & Module Organization
4+
5+
Lambda is organised as a Cargo workspace with multiple crates.
6+
7+
* Core engine code lives in `crates/lambda-rs`
8+
* Platform & dependency abstractions in `crates/lambda-rs-platform`
9+
* CLI parsing utilities in `crates/lambda-rs-args`
10+
* Logging in `crates/lambda-rs-logging`.
11+
12+
Shared tooling sits under `lambda-sh/` and `scripts/`,
13+
14+
* Shader and logo assets are versioned in `crates/lambda-rs/assets/`
15+
* Integration tests run from `crates/lambda-rs/tests/`.
16+
17+
Run `scripts/setup.sh` once to install git hooks and git-lfs.
18+
Use `cargo build --workspace` for a full Rust build and `cargo test --workspace`
19+
to exercise unit and integration suites. Example binaries can be launched
20+
with `cargo run --example minimal` while you iterate.
21+
22+
## Project Architecture & structure
23+
24+
### General architecture rules
25+
26+
* `lambda-rs` is the primary API exposed to end users and should not leak any
27+
internal platform or dependency details.
28+
* `lambda-rs-platform` is where lower level abstractions and dependency wrappers
29+
should be designed to support the needs of the higher level framework.
30+
* Use the builder pattern to expose resources provided by our APIs where
31+
necessary (I.E. for creating a window, gpu, shaders, audio streams, etc).
32+
* In libraries exposed by this repository, avoid using panic unless absolutely
33+
necessary and allow for the user handle errors whenever possible.
34+
* Errors should be as actionable & descriptive as possible, providing context
35+
on what caused the error to occur.
36+
37+
### lambda-rs
38+
39+
This module located in `crates/lambda-rs` is the primary API offered by this
40+
repository. It is a high level framework for building desktop applications,
41+
games, and anything that utilizes GPU resources.
42+
43+
* Do not expose dependency code to the end user unless absolutely necessary. All
44+
lower level dependency/vendor code should be abstracted in `lambda-rs-platform`
45+
and then those abstractions should be imported into this library.
46+
47+
### lambda-rs-platform
48+
49+
This module located in `crates/lambda-rs-platform` is our platform and
50+
dependency abstraction layer. This library provides wrappers for all of our
51+
dependency code for our primary API, `lambda-rs`, allowing users to only focus
52+
on the high level abstractions.
53+
54+
* While APIs here should aim to provide more stable interfaces for our
55+
`lambda-rs`, this should be treated more as an internal API that is meant to
56+
to support the needs of our primary framework, even if it means making non-backwards
57+
compatible changes.
58+
59+
## Coding Practices, Styles, & Naming Conventions
60+
61+
* Follow Rust 2021 idioms with 2-space indentation and `max_width = 80` as
62+
enforced by `rustfmt.toml`.
63+
* Always run `cargo +nightly fmt --all` and
64+
`cargo clippy --workspace --all-targets -- -D warnings` before sending changes.
65+
* Module and file names stay snake_case.
66+
* Public types use UpperCamelCase.
67+
* constants use SCREAMING_SNAKE_CASE.
68+
* Use explicit return statements.
69+
* Do not use abbreviations or acronyms for variable names.
70+
* Maintain readable spacing in new statements: keep spaces after keywords, around
71+
operators, and after commas/semicolons instead of tightly packed tokens.
72+
* Add comprehensive documentation to all code & tests.
73+
* Add documentation to any pieces of code that are not immediately clear/are
74+
very complex.
75+
* Rustdoc requirements for new/changed code:
76+
* All public functions, methods, and types MUST have Rustdoc comments.
77+
* Non-trivial private helper functions SHOULD have Rustdoc comments.
78+
* Rustdoc MUST follow this structure:
79+
* One-line summary sentence describing behavior.
80+
* Optional paragraph describing nuances, constraints, or invariants.
81+
* `# Arguments` section documenting each parameter.
82+
* `# Returns` section describing the return value.
83+
* `# Errors` section for `Result`-returning APIs describing failure cases.
84+
* `# Panics` section only if the implementation can panic (prefer avoiding
85+
panics in library code).
86+
* `# Safety` section for `unsafe` APIs describing required invariants.
87+
* Do not add comments explaining why you removed code where the code used to be.
88+
89+
* Feature flags and documentation (brief)
90+
* Non‑essential code with production runtime cost (e.g., validation, extra logging) MUST be disabled by default in release builds and guarded behind explicit Cargo features. Debug builds MAY enable such checks via `debug_assertions`.
91+
* Add features in the crate that owns the behavior (e.g., rendering validation features live in `lambda-rs`). Prefer narrowly scoped flags over broad umbrellas; umbrella bundles MAY exist for convenience but MUST NOT be enabled by default.
92+
* Umbrella Cargo features (for example, `render-validation`, `render-validation-strict`, `render-validation-all`) MUST only compose granular feature flags. Code and documentation MUST gate behavior using granular feature names (for example, `render-validation-encoder`, `render-validation-instancing`) plus `debug_assertions`, never umbrella names.
93+
* Every granular feature that toggles behavior MUST be included in at least one umbrella feature for discoverability and consistency.
94+
* Do not leak platform/vendor details into public `lambda-rs` features; map high‑level features to `lambda-rs-platform` internals as needed.
95+
* Specifications that add or change behavior MUST list the exact Cargo features they introduce or rely on, and the same PR MUST update `docs/features.md` with: name, owning crate, default state (debug/release), summary, and expected runtime cost.
96+
* Do not include perf‑impacting features in a crate’s `default` feature set.
97+
98+
## Testing Guidelines
99+
100+
Unit tests reside alongside code; integration tests live in `crates/lambda-rs/tests/runnables.rs`. Add focused tests for new render paths or platform shims, grouping by feature. Run `cargo test -p lambda-rs -- --nocapture` when debugging rendering output, and keep coverage steady by updating or extending the runnable scenarios and examples. Document non-trivial manual verification steps in the PR body.
101+
102+
## Commit & Pull Request Guidelines
103+
104+
We follow the `[scope] message` style seen in `git log` (e.g. `[add] logging crate to packages.`). Each commit should remain narrowly scoped and buildable. Pull requests must describe intent, list test commands, and link any tracking issues. Include screenshots or clips if the change affects visuals, and mention required platform checks so reviewers can reproduce confidently.
105+
106+
## Setup & Tooling Tips
107+
108+
New contributors should enable the bundled pre-commit hooks via `pre-commit install` after running `scripts/setup.sh`. When working with the C++ engine archive, respect the `lambda_args_*` options exposed by `lambda-sh/lambda.sh` for consistent builds. Store large assets through git-lfs to keep history lean.
109+
110+
## Documentation Metadata & Authoring
111+
112+
To keep long‑lived docs consistent and traceable, include a metadata header (YAML front matter) at the top of all roadmap/spec/guide docs and follow the structure rules below.
113+
114+
Metadata schema (paste at the top of a doc):
115+
116+
---
117+
118+
title: "<short, descriptive title>"
119+
document_id: "<stable-id, e.g., game-roadmap-YYYY-MM-DD>"
120+
status: "draft" # draft | living | frozen | deprecated
121+
created: "<UTC ISO-8601>" # e.g., 2025-09-24T00:00:00Z
122+
last_updated: "<UTC ISO-8601>"
123+
version: "0.x.y"
124+
engine_workspace_version: "2023.1.30"
125+
wgpu_version: "26.0.1"
126+
shader_backend_default: "naga"
127+
winit_version: "0.29.10"
128+
repo_commit: "<git sha at update>"
129+
owners: ["lambda-sh"]
130+
reviewers: ["engine", "rendering"]
131+
tags: ["roadmap", "games", "2d", "3d", "desktop"]
132+
---
133+
134+
Authoring guidance:
135+
136+
* Keep sections short and scannable; prefer bullets and code snippets.
137+
* Include ASCII diagrams where helpful; avoid embedded binaries in repo.
138+
* When proposing APIs, mirror existing builder/command patterns and show concise Rust sketches.
139+
* Update `last_updated`, `version`, and `repo_commit` when making material changes; append a “Changelog” section.
140+
* Prefer ISO‑8601 UTC timestamps. Use semantic versioning for the doc `version`.
141+
* Create new specifications by copying `docs/specs/_spec-template.md` and
142+
completing the placeholders; do not start from an existing spec.
143+
* Always create a table of contents for specs & tutorials.
144+
145+
### Documentation Tone & Style (Required)
146+
147+
All specs, and long‑lived docs must adopt a professional, precise tone:
148+
149+
* Voice and register
150+
* Use clear, direct, neutral language. Prefer active voice and present tense.
151+
* Avoid conversational phrasing, rhetorical questions, or tutorial chatter.
152+
* Do not use first‑person pronouns (“I”, “we”) or address the reader (“you”) unless the context requires an instruction; prefer “the API”, “the engine”, or “this document”.
153+
* Do not include meta commentary (e.g., “this aims to…”, “we want to…”). State requirements and behavior plainly.
154+
155+
* Normative language
156+
* Use RFC‑2119 keywords where appropriate: MUST, SHOULD, MAY, MUST NOT, SHOULD NOT.
157+
* When explaining decisions, use a short “Rationale” sub‑bullet rather than “Why” prose.
158+
159+
* Terminology and consistency
160+
* Define acronyms on first use in each document (e.g., “uniform buffer object (UBO)”), then use the acronym. Acronyms are permitted in docs (not in code).
161+
* Use consistent technical terms: `GPU`, `CPU`, `wgpu`, “bind group”, “pipeline layout”. Refer to code identifiers with backticks (e.g., `BindGroupLayout`).
162+
* Prefer American English spelling (e.g., “behavior”, “color”).
163+
* When describing implementation areas, refer to crates by name (for example, `lambda-rs`, `lambda-rs-platform`) instead of generic labels like “engine layer” or “platform layer”.
164+
165+
* Structure and formatting
166+
* Keep headings stable and diff‑friendly; avoid frequent renames.
167+
* Keep bullets to one line when possible; avoid filler sentences.
168+
* Include only minimal, buildable code snippets; match repository style.
169+
* Avoid marketing claims, subjective adjectives, and speculation.
170+
171+
* Metadata and changelog discipline
172+
* Update `last_updated`, bump `version` semantically, and set `repo_commit` to the current `HEAD` when making substantive edits.
173+
* Changelog entries use ISO‑8601 date, version, and a concise imperative summary of the changes (content, not process).
174+
175+
* Prohibitions
176+
* No emojis, exclamation marks for emphasis, or informal asides.
177+
* No references to AI authorship or generation.
178+
* No unscoped promises like “we will add…” without a linked tracking issue.
179+
* Do not add commentary about what you MUST or SHOULD do in the guidelines
180+
within specs or tutorials based on the AGENTS.md file.
181+
182+
### Tutorials Authoring (Required)
183+
184+
Tutorials are step‑by‑step instructional documents that teach a discrete task using the engine. They MUST follow the same metadata schema and tone rules as other docs, with the additions below.
185+
186+
* Location and naming
187+
* Place tutorials under `docs/tutorials/`.
188+
* Use kebab‑case filenames (e.g., `uniform-buffers.md`).
189+
* Include the `tutorial` tag in the metadata `tags` array.
190+
191+
* Tone and voice
192+
* Follow “Documentation Tone & Style (Required)” while adopting a book‑like instructional narrative.
193+
* Explain intent before each code block: what is about to be done and why it is necessary.
194+
* After each code block, include a short narrative paragraph that describes the outcome and what has been achieved.
195+
* Include a final Conclusion section that summarizes what was built and what outcomes were achieved across the tutorial.
196+
* Imperative instructions are preferred; limited second‑person (“you”) MAY be used to guide the reader when clarity improves.
197+
* Define acronyms on first use (e.g., “uniform buffer object (UBO)”) and then use the acronym consistently.
198+
199+
* Standard section structure
200+
* Goals: clearly state what will be built and what will be learned.
201+
* Overview: one short paragraph defining the task and constraints.
202+
* Prerequisites: version assumptions, build commands, and paths to examples.
203+
* Implementation Steps: numbered, with an explanation of intent and rationale preceding each code block, followed by a narrative paragraph after each code block that summarizes the resulting state and why it matters.
204+
* Validation: exact commands to build/run and expected visible behavior.
205+
* Notes: normative requirements and pitfalls using RFC‑2119 terms (MUST/SHOULD/MAY).
206+
* Conclusion: concise summary of accomplishments and the final state of the system built in the tutorial.
207+
* Exercises: 5–7 focused extensions that reuse concepts from the tutorial.
208+
* Changelog: ISO‑8601 date, version, and concise changes.
209+
210+
* Code and snippets
211+
* Match repository style: 2‑space indentation, line width ≈ 80, explicit `return` statements, and no abbreviations or acronyms in code identifiers.
212+
* Prefer minimal, buildable snippets; avoid large, redundant code blocks.
213+
* Reference files via workspace‑relative paths (e.g., `crates/lambda-rs/examples/uniform_buffer_triangle.rs`).
214+
* Use ASCII diagrams only; do not embed binaries.
215+
216+
* Metadata discipline
217+
* Update `last_updated`, bump `version` semantically, and set `repo_commit` to the current `HEAD` when making substantive edits.
218+
* Keep `document_id` stable across revisions; use semantic versioning in `version`.
219+
220+
* Consistency
221+
* Keep headings stable and diff‑friendly across tutorial revisions.
222+
* Use consistent terminology: `bind group`, `pipeline layout`, `GPU`, `CPU`, `wgpu`.
223+
224+
* Scope and process isolation
225+
* Do not reference internal process documents (e.g., this file) or include commentary about guideline updates within tutorials or specs.

0 commit comments

Comments
 (0)