|
1 | 1 | # Review Instructions for AI Code Reviewers |
2 | 2 |
|
3 | | -These instructions are meta-guidance for AI code review tools (CodeRabbit, etc.). |
4 | | -They define review priorities and anti-patterns specific to this repository. |
| 3 | +Meta-guidance for AI code review tools (CodeRabbit, etc.). Repo-specific patterns. |
5 | 4 |
|
6 | | -## Review Priority Order |
| 5 | +## Priority Order |
7 | 6 |
|
8 | | -When multiple findings exist, prioritize in this order: |
| 7 | +1. Security vulnerabilities (CWE/CVE, severity, exploit scenario, remediation) |
| 8 | +2. RBAC gaps — trace `client.Client` calls to the relevant `kubebuilder_rbac.go`. For component controllers under `internal/controller/components/` (which have no RBAC markers), trace to the top-level controller (`datasciencecluster`, `dscinitialization`, `gateway`, `cloudmanager/*`) whose `kubebuilder_rbac.go` covers those operations |
| 9 | +3. Architectural anti-patterns |
| 10 | +4. Bug-prone patterns, error handling gaps |
| 11 | +5. Performance |
9 | 12 |
|
10 | | -1. Security vulnerabilities (provide CWE/CVE IDs, severity, exploit scenario, and remediation code) |
11 | | -2. RBAC permission gaps — trace `client.Client` calls to the calling controller's `kubebuilder_rbac.go` |
12 | | -3. Architectural issues and anti-patterns |
13 | | -4. Bug-prone patterns and error handling gaps |
14 | | -5. Performance problems |
| 13 | +## Anti-Patterns (DO NOT flag) |
15 | 14 |
|
16 | | -## Anti-Patterns to Avoid |
| 15 | +- **Tautological test oracles**: E2E tests intentionally use independent oracles. DO NOT suggest mirroring production code path. |
| 16 | +- **Removing fallback logic**: Three-way branch (success / IsNotFound|IsNoMatchError / other) for OpenShift resources is intentional. Fallback IS the primary path on non-OpenShift clusters. |
| 17 | +- **Missing `kubebuilder_rbac.go` in component controllers**: Components under `internal/controller/components/` use codegen. Only top-level controllers (`dscinitialization`, `datasciencecluster`, `gateway`, `cloudmanager/*`) have hand-maintained RBAC. |
| 18 | +- **Suggesting manual OwnerReferences**: Reconciler builder handles these. Only flag for cross-namespace ownership. |
| 19 | +- **PR description format**: Template enforces this. Only flag if completely empty. |
17 | 20 |
|
18 | | -DO NOT suggest the following — these are common false positives in this codebase: |
| 21 | +## Must Always Flag |
19 | 22 |
|
20 | | -- **Tautological test oracles**: DO NOT suggest that e2e tests call the same production helper or API resource they are validating. Independent oracles are intentional. See `AGENTS.md` "Test Oracle Independence" section. |
21 | | -- **Removing fallback logic**: DO NOT flag OpenShift-to-vanilla-K8s fallback paths as dead code or suggest simplifying the three-way error branch (`success / IsNotFound|IsNoMatchError / other error`). The fallback is the primary path on non-OpenShift clusters. |
22 | | -- **Missing `kubebuilder_rbac.go` in component controllers**: Component controllers under `internal/controller/components/` use codegen for RBAC. Only top-level controllers (`dscinitialization`, `datasciencecluster`, `gateway`, `cloudmanager/*`) have hand-maintained `kubebuilder_rbac.go` files. |
23 | | -- **Suggesting `OwnerReferences` be set manually**: The reconciler builder pattern handles OwnerReferences. DO NOT suggest adding them in action code unless there is a cross-namespace ownership scenario. |
24 | | -- **PR description format comments**: The PR template already enforces description requirements. DO NOT comment on PR description format unless it is completely empty. |
25 | | - |
26 | | -## Patterns That Must Always Be Flagged |
27 | | - |
28 | | -Always flag these regardless of context: |
29 | | - |
30 | | -- Any `+kubebuilder:rbac` change without a corresponding `make manifests` regeneration |
31 | | -- New `client.Client` operations in `pkg/` without RBAC coverage in all calling controllers |
32 | | -- Status conditions that don't update during deletion or error transitions |
| 23 | +- New `client.Client` ops in `pkg/` without RBAC coverage in all calling controllers |
| 24 | +- Status conditions not updated during deletion or error transitions |
33 | 25 | - `InsecureSkipVerify: true` in non-test code |
34 | | -- Wildcard verbs or resources in RBAC rules |
35 | | -- Secrets, tokens, or credentials logged at any verbosity level |
36 | | -- User-facing component configuration added only to an internal component CRD spec (`XxxSpec`) |
37 | | - without a corresponding field in `DSCXxx` (via `XxxCommonSpec`). Any field a user must set to |
38 | | - configure component behaviour belongs in `CommonSpec` so it is reachable through the DSC API. |
39 | | - The only legitimate use of internal-only spec fields (those in `XxxSpec` but NOT in |
40 | | - `XxxCommonSpec`) is for values written exclusively by the operator itself (e.g. the gateway |
41 | | - domain stamped from `GatewayConfig.Status.Domain`). See `docs/COMPONENT_INTEGRATION.md` for |
42 | | - the correct pattern. |
| 26 | +- Wildcard verbs/resources in RBAC rules |
| 27 | +- Secrets/tokens/credentials logged at any verbosity |
| 28 | +- User-facing config in `XxxSpec` only (not in `XxxCommonSpec`/`DSCXxx`). Internal-only spec fields are for operator-written values only. See `docs/COMPONENT_INTEGRATION.md`. |
0 commit comments