|
| 1 | +# Repository Guidelines |
| 2 | + |
| 3 | +## Project Structure & Module Organization |
| 4 | + |
| 5 | +Lambda is organized as a Cargo workspace with multiple crates. |
| 6 | + |
| 7 | +- Core engine code lives in `crates/lambda-rs`. |
| 8 | +- Platform and dependency abstractions live in |
| 9 | + `crates/lambda-rs-platform`. |
| 10 | +- CLI parsing utilities live in `crates/lambda-rs-args`. |
| 11 | +- Logging utilities live in `crates/lambda-rs-logging`. |
| 12 | + |
| 13 | +Shared tooling lives under `lambda-sh/` and `scripts/`. |
| 14 | + |
| 15 | +- Shader and logo assets are versioned in `crates/lambda-rs/assets/`. |
| 16 | +- Integration tests live in `crates/lambda-rs/tests/`. |
| 17 | + |
| 18 | +Run `scripts/setup.sh` once to install git hooks and `git-lfs`. |
| 19 | +Use `cargo build --workspace` for a full Rust build and |
| 20 | +`cargo test --workspace` to exercise unit and integration suites. |
| 21 | +Example binaries can be launched with `cargo run --example minimal` |
| 22 | +while iterating. |
| 23 | + |
| 24 | +## Project Architecture & Structure |
| 25 | + |
| 26 | +### General Architecture Rules |
| 27 | + |
| 28 | +- `lambda-rs` is the primary API exposed to end users and MUST NOT leak |
| 29 | + internal platform or dependency details. |
| 30 | +- `lambda-rs-platform` contains lower-level abstractions and dependency |
| 31 | + wrappers and SHOULD be designed to support the needs of the higher-level |
| 32 | + framework. |
| 33 | +- Use the builder pattern where appropriate to expose resources provided by |
| 34 | + the APIs, such as windows, GPUs, shaders, and audio streams. |
| 35 | +- In libraries exposed by this repository, avoid panics unless absolutely |
| 36 | + necessary and allow the caller to handle errors whenever possible. |
| 37 | +- Errors SHOULD be actionable and descriptive, including context about the |
| 38 | + cause of the failure. |
| 39 | + |
| 40 | +### `lambda-rs` |
| 41 | + |
| 42 | +`lambda-rs`, located in `crates/lambda-rs`, is the primary API offered by |
| 43 | +this repository. It is a high-level framework for building desktop |
| 44 | +applications, games, and other GPU-backed software. |
| 45 | + |
| 46 | +- Do not expose dependency code to end users unless absolutely necessary. |
| 47 | + Lower-level dependency or vendor code SHOULD be abstracted in |
| 48 | + `lambda-rs-platform` and consumed from there. |
| 49 | + |
| 50 | +### `lambda-rs-platform` |
| 51 | + |
| 52 | +`lambda-rs-platform`, located in `crates/lambda-rs-platform`, is the |
| 53 | +platform and dependency abstraction layer. This library provides wrappers |
| 54 | +around dependency code used by `lambda-rs`, allowing the primary API to stay |
| 55 | +focused on higher-level abstractions. |
| 56 | + |
| 57 | +- APIs in this crate SHOULD aim for stable interfaces for `lambda-rs`, but |
| 58 | + this crate is still treated as an internal support layer. |
| 59 | + Non-backward-compatible changes are acceptable when they are required to |
| 60 | + support the primary framework. |
| 61 | + |
| 62 | +## Coding Practices, Style, & Naming Conventions |
| 63 | + |
| 64 | +- Follow Rust 2021 idioms with 2-space indentation and `max_width = 80`, |
| 65 | + as enforced by `rustfmt.toml`. |
| 66 | +- Always run `cargo +nightly fmt --all` and |
| 67 | + `cargo clippy --workspace --all-targets -- -D warnings` before sending |
| 68 | + changes. |
| 69 | +- Module and file names MUST remain `snake_case`. |
| 70 | +- Public types MUST use `UpperCamelCase`. |
| 71 | +- Constants MUST use `SCREAMING_SNAKE_CASE`. |
| 72 | +- Use explicit return statements. |
| 73 | +- Do not use abbreviations or acronyms for variable names. |
| 74 | +- Maintain readable spacing in new statements: keep spaces after keywords, |
| 75 | + around operators, and after commas and semicolons instead of tightly packed |
| 76 | + tokens. |
| 77 | +- Add comprehensive documentation to all code and tests. |
| 78 | +- Add documentation to code that is complex or not immediately clear. |
| 79 | + |
| 80 | +### Rustdoc Requirements |
| 81 | + |
| 82 | +- All public functions, methods, and types MUST have Rustdoc comments. |
| 83 | +- Non-trivial private helper functions SHOULD have Rustdoc comments. |
| 84 | +- Rustdoc for new or changed APIs MUST follow this structure: |
| 85 | + - One-line summary sentence describing behavior. |
| 86 | + - Optional paragraph describing nuances, constraints, or invariants. |
| 87 | + - `# Arguments` section documenting each parameter. |
| 88 | + - `# Returns` section describing the return value. |
| 89 | + - `# Errors` section for `Result`-returning APIs describing failure cases. |
| 90 | + - `# Panics` section only if the implementation can panic. Prefer avoiding |
| 91 | + panics in library code. |
| 92 | + - `# Safety` section for `unsafe` APIs describing required invariants. |
| 93 | + |
| 94 | +- Do not add comments explaining why code was removed where that code used to |
| 95 | + be. |
| 96 | + |
| 97 | +### Feature Flags & Documentation |
| 98 | + |
| 99 | +- Non-essential code with production runtime cost, such as validation or |
| 100 | + extra logging, MUST be disabled by default in release builds and guarded |
| 101 | + behind explicit Cargo features. Debug builds MAY enable such checks via |
| 102 | + `debug_assertions`. |
| 103 | +- Add features in the crate that owns the behavior. For example, rendering |
| 104 | + validation features belong in `lambda-rs`. |
| 105 | +- Prefer narrowly scoped feature flags over broad umbrella flags. Umbrella |
| 106 | + bundles MAY exist for convenience but MUST NOT be enabled by default. |
| 107 | +- Umbrella Cargo features, such as `render-validation`, |
| 108 | + `render-validation-strict`, and `render-validation-all`, MUST only compose |
| 109 | + granular feature flags. |
| 110 | +- Code and documentation MUST gate behavior using granular feature names, such |
| 111 | + as `render-validation-encoder` and `render-validation-instancing`, together |
| 112 | + with `debug_assertions`, never umbrella names. |
| 113 | +- Every granular feature that toggles behavior MUST be included in at least |
| 114 | + one umbrella feature for discoverability and consistency. |
| 115 | +- Public `lambda-rs` features MUST NOT leak platform or vendor details. Map |
| 116 | + high-level features to `lambda-rs-platform` internals as needed. |
| 117 | +- Specifications that add or change behavior MUST list the exact Cargo |
| 118 | + features they introduce or rely on. The same change MUST also update |
| 119 | + `docs/features.md` with the feature name, owning crate, default state |
| 120 | + (debug or release), summary, and expected runtime cost. |
| 121 | +- Do not include performance-impacting features in a crate's `default` |
| 122 | + feature set. |
| 123 | + |
| 124 | +## Testing Guidelines |
| 125 | + |
| 126 | +Unit tests live alongside the code. Integration test coverage lives under |
| 127 | +`crates/lambda-rs/tests/`, with runnable scenarios defined in |
| 128 | +`crates/lambda-rs/tests/runnables.rs`. |
| 129 | + |
| 130 | +- Add focused tests for new render paths or platform shims, grouped by |
| 131 | + feature. |
| 132 | +- Run `cargo test -p lambda-rs -- --nocapture` when debugging rendering |
| 133 | + output. |
| 134 | +- Maintain coverage by updating or extending runnable scenarios and examples. |
| 135 | +- Document non-trivial manual verification steps in the pull request body. |
| 136 | + |
| 137 | +## Commit & Pull Request Guidelines |
| 138 | + |
| 139 | +Commit messages follow the `[scope] message` style used in `git log`, such as |
| 140 | +`[add] logging crate to packages.` Each commit SHOULD remain narrowly scoped |
| 141 | +and buildable. |
| 142 | + |
| 143 | +Pull requests MUST: |
| 144 | + |
| 145 | +- Describe the intent of the change. |
| 146 | +- List the test commands that were run. |
| 147 | +- Link any tracking issues. |
| 148 | +- Include screenshots or clips for visual changes. |
| 149 | +- Note any required platform checks so reviewers can reproduce the change. |
| 150 | + |
| 151 | +## Setup & Tooling Tips |
| 152 | + |
| 153 | +- Run `scripts/setup.sh`, then enable the bundled hooks with |
| 154 | + `pre-commit install`. |
| 155 | +- When working with the C++ engine archive, respect the `lambda_args_*` |
| 156 | + options exposed by `lambda-sh/lambda.sh` for consistent builds. |
| 157 | +- Store large assets through `git-lfs` to keep history lean. |
| 158 | + |
| 159 | +## Documentation Skills |
| 160 | + |
| 161 | +Use the repo-local Codex skills for detailed documentation workflows. |
| 162 | + |
| 163 | +- Use `.codex/skills/long-lived-docs-authoring/SKILL.md` for specs, roadmaps, |
| 164 | + guides, plans, and other long-lived Markdown documents. |
| 165 | +- Use `.codex/skills/tutorial-authoring/SKILL.md` for step-by-step tutorials |
| 166 | + in `docs/tutorials/`. |
| 167 | +- Keep repo-wide policy in this file and keep detailed documentation authoring |
| 168 | + workflow in those skills. |
| 169 | + |
| 170 | +## Documentation Requirements |
| 171 | + |
| 172 | +- Long-lived docs MUST include YAML front matter with `title`, |
| 173 | + `document_id`, `status`, `created`, `last_updated`, `version`, |
| 174 | + `engine_workspace_version`, `wgpu_version`, `shader_backend_default`, |
| 175 | + `winit_version`, `repo_commit`, `owners`, `reviewers`, and `tags`. |
| 176 | +- New specifications MUST be created from `docs/specs/_spec-template.md`. |
| 177 | +- Specifications and tutorials MUST include a table of contents. |
| 178 | +- Substantive documentation edits MUST update `last_updated`, `version`, |
| 179 | + `repo_commit`, and the `Changelog`. |
| 180 | +- Long-lived docs MUST use a professional, precise tone with active voice, |
| 181 | + consistent terminology, American English spelling, and RFC-2119 keywords |
| 182 | + where appropriate. |
| 183 | +- Tutorials MUST live in `docs/tutorials/`, use kebab-case filenames, include |
| 184 | + the `tutorial` tag, and include `Goals`, `Overview`, `Prerequisites`, |
| 185 | + `Implementation Steps`, `Validation`, `Notes`, `Conclusion`, `Exercises`, |
| 186 | + and `Changelog`. |
0 commit comments