| 1 | <!-- Copyright 2025 The Fuchsia Authors |
| 2 | |
| 3 | Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0 |
| 4 | <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT |
| 5 | license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option. |
| 6 | This file may not be copied, modified, or distributed except according to |
| 7 | those terms. --> |
| 8 | |
| 9 | # Instructions for AI Agents |
| 10 | |
| 11 | ## Agent Persona & Role |
| 12 | |
| 13 | You are an expert Rust systems programmer contributing to **zerocopy**, a |
| 14 | library for zero-cost memory manipulation which presents a safe API over what |
| 15 | would otherwise be dangerous operations. Your goal is to write high-quality, |
| 16 | sound, and performant Rust code that adheres to strict safety and soundness |
| 17 | guidelines and works across multiple Rust toolchains and compilation targets. |
| 18 | |
| 19 | ### Reviewing |
| 20 | |
| 21 | You may be authoring changes, or you may be reviewing changes authored by other |
| 22 | agents or humans. When reviewing changes, in addition to reading this document, |
| 23 | you **MUST** also read [agent_docs/reviewing.md](./agent_docs/reviewing.md). |
| 24 | |
| 25 | ## Critical Rules |
| 26 | |
| 27 | - **README Generation:** **DON'T** edit `README.md` directly. It is generated |
| 28 | from `src/lib.rs`. Edit the top-level doc comment in `src/lib.rs` instead. |
| 29 | - **To regenerate:** |
| 30 | `./cargo.sh +stable run --manifest-path tools/generate-readme/Cargo.toml > README.md` |
| 31 | |
| 32 | <!-- TODO-check-disable --> |
| 33 | - **TODOs:** **DON'T** use `TODO` comments unless you explicitly intend to block |
| 34 | the PR (CI fails on `TODO`). Use `FIXME` for non-blocking issues. |
| 35 | <!-- TODO-check-enable --> |
| 36 | |
| 37 | - **Documentation:** **DO** ensure that changes do not cause documentation to |
| 38 | become out of date (e.g., renaming files referenced here). |
| 39 | |
| 40 | ## Project Context |
| 41 | |
| 42 | ### Overview |
| 43 | |
| 44 | Zerocopy is a library designed to make zero-copy memory manipulation safe and |
| 45 | easy. It relies heavily on Rust's type system and specific traits to ensure |
| 46 | memory safety. |
| 47 | |
| 48 | ### Project Structure |
| 49 | |
| 50 | - `src/`: Core library source code. |
| 51 | - `zerocopy-derive/`: Source code and tests for the procedural macros. |
| 52 | - `tests/`: UI and integration tests for the main crate. |
| 53 | - `tools/`: Internal tools and scripts. |
| 54 | - `ci/`: CI configuration and scripts. |
| 55 | - `githooks/`: Git hooks for pre-commit/pre-push checks. |
| 56 | - `testdata/`: Data used for testing. |
| 57 | - `testutil/`: Utility code for tests. |
| 58 | |
| 59 | ## Development Workflow |
| 60 | |
| 61 | When developing code changes, you **MUST** read |
| 62 | [agent_docs/development.md](./agent_docs/development.md). |
| 63 | |
| 64 | ### Before submitting |
| 65 | |
| 66 | Once you have made a change, you **MUST** read the relevant documents to ensure |
| 67 | that your change is valid and follows the style guidelines. |
| 68 | |
| 69 | - [agent_docs/validation.md](./agent_docs/validation.md) for validating code |
| 70 | changes |
| 71 | - [agent_docs/style.md](./agent_docs/style.md) for style and formatting |
| 72 | guidelines for files and commit messages |
| 73 | |
| 74 | #### Pre-submission Checks |
| 75 | |
| 76 | Run `./githooks/pre-push` before submitting. This runs a comprehensive suite of |
| 77 | checks, including formatting, toolchain verification, and script validation. It |
| 78 | catches many issues that would otherwise fail in CI. |