Skip to content

Commit 7b1a802

Browse files
committed
Update AGENTS.md
1 parent cd2724a commit 7b1a802

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

AGENTS.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ All kubebuilder validation markers must be documented in the field's comment. Fo
117117

118118
**Good:**
119119
```go
120-
// internalDNSRecords is an optional field that determines whether we deploy
120+
// internalDNSRecords is an optional field that determines whether we deploy
121121
// with internal records enabled for api, api-int, and ingress.
122122
// Valid values are "Enabled" and "Disabled".
123123
// When set to Enabled, in cluster DNS resolution will be enabled for the api, api-int, and ingress endpoints.
@@ -136,6 +136,43 @@ InternalDNSRecords InternalDNSRecordsType `json:"internalDNSRecords"`
136136
InternalDNSRecords InternalDNSRecordsType `json:"internalDNSRecords"`
137137
```
138138

139+
#### Systematic Validation Marker Documentation Checklist
140+
141+
**MANDATORY**: For each field with validation markers, verify the comment documents ALL of the following that apply:
142+
143+
**Field Optionality:**
144+
- [ ] `+optional` - explain behavior when field is omitted
145+
- [ ] `+required` - explain that the field is required
146+
147+
**String/Array Length Constraints:**
148+
- [ ] `+kubebuilder:validation:MinLength` and `+kubebuilder:validation:MaxLength` - document character length constraints
149+
- [ ] `+kubebuilder:validation:MinItems` and `+kubebuilder:validation:MaxItems` - document item count ranges
150+
151+
**Value Constraints:**
152+
- [ ] `+kubebuilder:validation:Enum` - list all valid enum values and their meanings
153+
- [ ] `+kubebuilder:validation:Pattern` - explain the pattern requirement in human-readable terms
154+
- [ ] `+kubebuilder:validation:Minimum` and `+kubebuilder:validation:Maximum` - document numeric ranges
155+
156+
**Advanced Validation:**
157+
- [ ] `+kubebuilder:validation:XValidation` - explain cross-field validation rules in detail
158+
- [ ] Any custom validation logic - document the validation behavior
159+
160+
#### API Review Process
161+
162+
**CRITICAL PROCESS**: Follow this exact order to ensure comprehensive validation:
163+
164+
1. **Linting Check**: Run `make lint` and fix all kubeapilinter errors first
165+
2. **Extract Validation Markers**: Use systematic search to find all markers
166+
3. **Systematic Documentation Review**: For each marker found, verify corresponding documentation exists
167+
4. **Optional Fields Review**: Ensure every `+optional` field explains omitted behavior
168+
5. **Cross-field Validation**: Verify any documented field relationships have corresponding `XValidation` rules
169+
170+
**FAILURE CONDITIONS**: The review MUST fail if any of these are found:
171+
- Any validation marker without corresponding documentation
172+
- Any `+optional` field without omitted behavior explanation
173+
- Any documented field constraint without enforcement via validation rules
174+
- Any `make lint` failures
175+
139176
The comment must explicitly state:
140177
- When a field is optional (for `+kubebuilder:validation:Optional` or `+optional`)
141178
- Valid enum values (for `+kubebuilder:validation:Enum`)

0 commit comments

Comments
 (0)