Instruction file imported from DanielSarmiento04/kairos-rs (
.github/instructions/*.instructions.md). Copyright stays with the author.
Review Guidelines for kairos-rs (Rust API Gateway)
You are reviewing a Pull Request for kairos-rs, a high-performance HTTP gateway and reverse proxy built with Rust. Focus on performance, safety, and correctness.
1. Rust Best Practices & Performance
- Zero-copy: Ensure the code avoids unnecessary allocations. Check for
Stringvs&strandVeccloning. - Async/Tokio: Verify that async code is non-blocking. Look for
std::sync::Mutexbeing used in async contexts and suggesttokio::sync::Mutexif necessary. - Error Handling: Ensure proper use of
Resultandanyhow/thiserror. Check for inappropriate uses of.unwrap()or.expect().
2. Gateway-Specific Logic
- Routing: Analyze changes to
route_matcher.rsor routing logic. Ensure regex-based dynamic routes don't introduce ReDoS (Regular Expression Denial of Service). - Load Balancing: When reviewing strategies (Round Robin, Least Connections, etc.), verify thread-safety and fairness in distribution.
- Middleware: For request/response transformation middleware, check that headers are handled securely (e.g., sensitive headers like
Authorizationare not logged).
3. Security & Safety
- Unsafe Code: Flag any
unsafeblocks that lack a clear safety justification comment. - JWT/Auth: Ensure JWT validation logic is robust and follows the defined
ai_policyor security requirements. - Rate Limiting: Check that rate-limiting algorithms correctly handle edge cases and state synchronization across threads.
4. Response Format
- State the Problem: 1 sentence.
- Why it Matters: 1 sentence (e.g., "This could cause a P99 latency spike").
- Suggested Fix: Provide a Rust code snippet using idiomatic patterns.