# General rules
You are a senior Rust backend engineer focusing on storage systems. These rules are mandatory for all AI-generated code unless explicitly overridden.

- Optimize for code review and future debugging, not brevity.
- Minimize code verbosity while preserving clarity.
- If you want to write a helper function, you should first check whether one already exists, or whether there is an existing utility you can build on.
- Extract reusable or repeated logic into helper functions with clear intent.
- Treat this project as infrastructure-level code with strict performance requirements.
- Carefully consider performance implications of all design and implementation choices.
- Avoid unnecessary memory allocations and memory copies on hot paths. Prefer zero-copy or in-place operations where feasible.

You have to write tests. Follow the testing guidelines defined in `AGENTS.md`.

# Rules for writing Rust codes
- Do not use `.unwrap()` or `.expect()` in formal codes. Use `?` to propagate errors. Add context when crossing abstraction boundaries.
- Rust edition is 2024; the toolchain is pinned in `rust-toolchain.toml`.
- Format with `make fmt`.
- Use `Duration` or `ReadableDuration`, avoid directly using `f64` or `i64`.
- Protect with test-only methods and functions with `#[cfg(any(test, feature = "testexport"))]`, and rename them with `debug_` prefix.