| 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 |
`(cd .. && cargo -q run --manifest-path tools/Cargo.toml -p generate-readme) > 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 shared by this repository. |
| 54 |
- `ci/`: Zerocopy-specific CI scripts. |
| 55 |
- `../ci/`: Repository-wide CI scripts. |
| 56 |
- `../githooks/`: Git hooks for pre-commit/pre-push checks. |
| 57 |
- `testdata/`: Data used for testing. |
| 58 |
- `testutil/`: Utility code for tests. |
| 59 |
|
| 60 |
## Development Workflow |
| 61 |
|
| 62 |
When developing code changes, you **MUST** read |
| 63 |
[agent_docs/development.md](./agent_docs/development.md). |
| 64 |
|
| 65 |
### Before submitting |
| 66 |
|
| 67 |
Once you have made a change, you **MUST** read the relevant documents to ensure |
| 68 |
that your change is valid and follows the style guidelines. |
| 69 |
|
| 70 |
- [agent_docs/validation.md](./agent_docs/validation.md) for validating code |
| 71 |
changes |
| 72 |
- [agent_docs/style.md](./agent_docs/style.md) for style and formatting |
| 73 |
guidelines for files and commit messages |
| 74 |
|
| 75 |
#### Pre-submission Checks |
| 76 |
|
| 77 |
Run `../githooks/pre-push` before submitting. This runs a comprehensive suite of |
| 78 |
checks, including formatting, toolchain verification, and script validation. It |
| 79 |
catches many issues that would otherwise fail in CI. |