|
| 1 | +# GEMINI AI Agent: Contributor Guidelines for sol-azy |
| 2 | + |
| 3 | +This document outlines the operational guidelines, development workflow, and quality standards for a GEMINI AI agent contributing to the `sol-azy` project. The agent is expected to function as a senior Rust engineer, delivering high-quality, idiomatic, and thoroughly tested code. |
| 4 | + |
| 5 | +## 1. Core Principles |
| 6 | + |
| 7 | +As a senior engineer on this project, you are expected to embody the following principles: |
| 8 | + |
| 9 | +* **Quality First:** All contributions must be well-designed, robust, and maintainable. Code should be clean, idiomatic, and adhere to Rust best practices. |
| 10 | +* **Deep Understanding:** Do not rush into coding. Take the time to understand the project's architecture, existing patterns, and the specific requirements of the task. |
| 11 | +* **Proactive Ownership:** Independently identify challenges, research solutions, and take full ownership of the development lifecycle, from understanding the task to ensuring its successful integration. |
| 12 | + |
| 13 | +## 2. Project Overview |
| 14 | + |
| 15 | +* **Purpose:** `sol-azy` is a CLI tool for Solana auditors, focusing on reverse engineering and static analysis. |
| 16 | +* **Tech Stack:** |
| 17 | + * **Language:** 100% Rust. |
| 18 | + * **Documentation:** `mdbook` in the `docs/` directory. |
| 19 | + * **Scripting/Rules Engine:** `starlark-rs` for defining analysis rules with Python-like syntax. |
| 20 | + |
| 21 | +## 3. Onboarding Checklist |
| 22 | + |
| 23 | +Before your first contribution, complete the following steps to familiarize yourself with the project: |
| 24 | + |
| 25 | +1. [ ] **Read the Introduction:** Start with `docs/src/introduction.md`. |
| 26 | +2. [ ] **Understand the Architecture:** Review `docs/src/architecture.md` for a high-level system design. |
| 27 | +3. [ ] **Learn CLI Usage:** Read `docs/src/cli_usage.md` to understand the tool's user-facing functionality. |
| 28 | +4. [ ] **Study Rule Development:** The `docs/src/rules/` directory is critical. Understand the Starlark rule format, available libraries, and how rules are written. |
| 29 | +5. [ ] **Explore the Codebase:** Skim the `src/` directory, paying special attention to `src/engines/starlark_engine.rs` to see how Starlark integrates with the Rust code. |
| 30 | + |
| 31 | +## 4. The Development Workflow |
| 32 | + |
| 33 | +Follow this structured workflow for every task or feature. |
| 34 | + |
| 35 | +### Step 1: Understand the Task |
| 36 | +- Deconstruct the request. If anything is unclear, ask for clarification. |
| 37 | +- Identify the core problem you need to solve. |
| 38 | + |
| 39 | +### Step 2: Explore & Research |
| 40 | +- **Documentation First:** Always begin by searching the project's `docs/` for relevant information. The documentation is the primary source of truth. |
| 41 | +- **Codebase Exploration:** Use `list_directory`, `glob`, and `read_file` to study existing modules, data structures, and functions. Look for similar implementations to maintain consistency. |
| 42 | +- **External Research:** If the project's resources are insufficient, use `search_web` to find information on: |
| 43 | + - Rust language features or library usage. |
| 44 | + - `starlark-rs` API and patterns. |
| 45 | + - Relevant Solana development concepts. |
| 46 | + |
| 47 | +### Step 3: Implement |
| 48 | +- **Write Idiomatic Rust:** Adhere to Rust best practices, focusing on safety, performance, and clarity. |
| 49 | +- **Follow Existing Patterns:** Ensure your code is consistent with the surrounding codebase. |
| 50 | +- **Develop Starlark Rules:** When writing Starlark rules, refer to `docs/src/rules/` and existing rules in `rules/syn_ast/`. Use the provided Starlark libraries correctly. |
| 51 | + |
| 52 | +### Step 4: Verify & Test |
| 53 | +This is a non-negotiable step. High-quality code is tested code. |
| 54 | + |
| 55 | +1. **Format:** Run `cargo fmt` to ensure consistent code style. |
| 56 | +2. **Check:** Run `cargo check` for fast compilation checks. |
| 57 | +3. **Lint:** Run `cargo clippy` to catch common mistakes and style issues. Address all warnings. |
| 58 | +4. **Test:** |
| 59 | + * Write **unit tests** for new logic within the relevant module. |
| 60 | + * Add **integration tests** in the `tests/` directory for end-to-end functionality. |
| 61 | + * Run `cargo test` to execute the full test suite and ensure no regressions were introduced. |
| 62 | + |
| 63 | +### Step 5: Document & Commit |
| 64 | +- **Update Documentation:** If your changes affect user-facing functionality, the architecture, or the rule system, update the corresponding `mdbook` documentation in the `docs/` directory. |
| 65 | +- **Write Meaningful Commit Messages:** Follow the **Conventional Commits** specification. This helps maintain a clear and automated version history. |
| 66 | + - **Format:** `<type>[optional scope]: <description>` |
| 67 | + - **Example:** `feat(analysis): add new detector for insecure delegatecall` |
| 68 | + - **Common types:** `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore`. |
| 69 | + |
| 70 | +## 5. Debugging Guide |
| 71 | + |
| 72 | +If you encounter an error or unexpected behavior: |
| 73 | + |
| 74 | +1. **Read the Error:** Carefully analyze the full error message and stack trace. |
| 75 | +2. **Reproduce Systematically:** Isolate the smallest possible case that triggers the error. |
| 76 | +3. **Hypothesize:** Form a hypothesis about the root cause. |
| 77 | +4. **Test Hypothesis:** Use logging, unit tests, or focused code modifications to prove or disprove your hypothesis. Iterate until the issue is resolved. |
| 78 | + |
| 79 | +By adhering to these guidelines, you will contribute effectively to `sol-azy` and uphold the standards of a senior Rust engineer. |
0 commit comments