Skip to content

Commit 95991b3

Browse files
Merge pull request openshift-eng#666 from jatinsu/agentic-docs-review
OKD-399: Generate REVIEW.md and coderabibit.yaml for Agentic docs
2 parents d5b3b5b + fa998e9 commit 95991b3

7 files changed

Lines changed: 381 additions & 3 deletions

File tree

.claude-plugin/marketplace.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@
540540
"name": "agentic-docs",
541541
"source": "./plugins/agentic-docs",
542542
"description": "Create and maintain AI-optimized documentation for OpenShift",
543-
"version": "1.4.0"
543+
"version": "1.5.0"
544544
},
545545
{
546546
"name": "metrics",

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ <h1>ai-helpers</h1>
415415
{
416416
"name": "agentic-docs",
417417
"description": "Create and maintain AI-optimized documentation for OpenShift",
418-
"version": "1.4.0",
418+
"version": "1.5.0",
419419
"has_readme": true,
420420
"commands": [
421421
{

plugins/agentic-docs/.claude-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "agentic-docs",
33
"description": "Create and maintain AI-optimized documentation for OpenShift",
4-
"version": "1.4.0",
4+
"version": "1.5.0",
55
"author": {
66
"name": "github.com/openshift-eng"
77
}

plugins/agentic-docs/skills/component-docs/SKILL.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Creates lean component agentic documentation for OpenShift component repositorie
2727
```text
2828
component-repo/
2929
├── AGENTS.md # Master entry point (80-100 lines)
30+
├── REVIEW.md # Review instructions (Claude Code Review + CodeRabbit)
31+
├── .coderabbit.yaml # CodeRabbit config (points at REVIEW.md)
3032
└── ai-docs/
3133
├── domain/ # Component APIs/types
3234
├── architecture/ # Component internals
@@ -223,13 +225,97 @@ Jira key, PR number) so I can trace it."
223225
- [ ] Link to Platform for generic practices
224226
- [ ] Document ONLY verified component-specific details (target: 100-200 lines each)
225227

228+
### Phase 9.5: Generate REVIEW.md + .coderabbit.yaml
229+
230+
Generates review instructions for code review tools (Claude Code Review, CodeRabbit). REVIEW.md is the single source of truth; .coderabbit.yaml is a structured sidecar that translates skip/path rules into CodeRabbit's native format. Target: 60-80 lines (soft cap 100).
231+
232+
**Step 1 — Clone enhancements repo** (if not already present from Phase 4):
233+
```bash
234+
[ ! -d "/tmp/openshift-enhancements" ] && git clone --depth 1 https://github.com/openshift/enhancements.git /tmp/openshift-enhancements
235+
```
236+
237+
**Step 2 — Read applicable dev-guide files** based on repo type detected in Phase 5:
238+
239+
| Repo Type | Files to Read |
240+
|-----------|---------------|
241+
| **Operator** | `dev-guide/api-conventions.md`, `dev-guide/breaking-changes.md`, `dev-guide/operators.md`, `CONVENTIONS.md`, `guidelines/supportability.md`, `dev-guide/cluster-version-operator/dev/clusteroperator.md` |
242+
| **Library** | `dev-guide/api-conventions.md`, `CONVENTIONS.md`, `dev-guide/breaking-changes.md` |
243+
| **CLI** | `CONVENTIONS.md`, `dev-guide/breaking-changes.md` |
244+
245+
Extract ONLY diff-enforceable rules — rules that can be checked by looking at a code diff. Discard vague guidance ("should consider...") and retain imperative rules ("Flag X as must-fix", "Never allow Y").
246+
247+
**Step 3 — Chai-bot verification** (optional, requires chai-bot MCP server):
248+
249+
Verify extracted platform rules are still current. If chai-bot is unavailable, skip — include all extracted rules (err on side of inclusion).
250+
251+
```
252+
mcp__chai-bot__ask_persona:
253+
"I'm generating REVIEW.md for {component} (github.com/openshift/{component}).
254+
I extracted these enforceable review rules from openshift/enhancements dev-guide.
255+
Are these still current? Have any been superseded, relaxed, or tightened?
256+
257+
1. [Rule 1 from Step 2]
258+
2. [Rule 2 from Step 2]
259+
...
260+
(list top 5-8 most critical rules for the detected repo type)
261+
262+
For each rule: confirm current, superseded (by what), or unknown."
263+
```
264+
265+
**Filtering**: Discard rules chai-bot confirms are superseded. Keep confirmed + unverified (err on side of inclusion). DISCARD any claims about repo internals — chai-bot fabricates these.
266+
267+
**Step 4 — Collect skip patterns** from Phase 5 discoveries:
268+
- [ ] Generated code inventory (zz_generated*, clientset, informers, listers, bindata, protobuf, payload-manifests)
269+
- [ ] Vendored dependencies (vendor/**)
270+
- [ ] CI-enforced checks (from Phase 5 CI enforcement discovery)
271+
- [ ] Lockfiles (go.sum, go.mod)
272+
- [ ] Generated dashboards/assets if present
273+
274+
**Step 5 — Extract path-specific rules** from Phase 5 discoveries:
275+
- [ ] Framework split table (which controllers use which apply method)
276+
- [ ] Anti-patterns per package/directory
277+
- [ ] Naming conventions per area
278+
- [ ] Test conventions (Jira annotations, JUnit output, scoping)
279+
280+
**Step 6 — Calibrate severity** by repo type:
281+
282+
| Repo Type | Must-Fix Categories |
283+
|-----------|-------------------|
284+
| **Operator** | Incorrect reconciliation logic, unscoped queries crossing tenant boundaries, resource leaks, upgrade/downgrade safety violations, breaking changes to GA openshift.io APIs, security vulnerabilities, `Available=False` or `Degraded=True` during normal upgrade, premature version bump in ClusterOperator status, tolerating `node.kubernetes.io/unschedulable` |
285+
| **Library** | API convention violations (bool fields, annotation-based APIs, missing validation markers, pointer misuse in CRDs), breaking changes to stable APIs, functions added to openshift/api |
286+
| **CLI** | Breaking changes to CLI behavior, security vulnerabilities, incorrect error codes |
287+
288+
Style and naming issues are minor at most for all repo types.
289+
290+
**Step 7 — Generate REVIEW.md**:
291+
- [ ] Use `templates/REVIEW-template.md` for structure
292+
- [ ] Fill each section from Steps 2-6, stripping template comments from output
293+
- [ ] Use tool-agnostic severity language ("must fix before merge" / "worth fixing, not blocking" / "suggestion only")
294+
- [ ] Use glob patterns for skip rules, not prose descriptions
295+
- [ ] Cite the dev-guide source for each "Always check" rule (parenthetical at end of line)
296+
- [ ] Include "Verification bar" section — require file:line citations for every comment
297+
- [ ] Include "Re-review" section — suppress new nits on unchanged code during re-reviews
298+
- [ ] Validate line count: target 60-80 lines, soft cap 100
299+
- [ ] **Do NOT** copy CLAUDE.md content — different purposes
300+
301+
**Step 8 — Generate/merge .coderabbit.yaml**:
302+
- [ ] Use `templates/coderabbit-template.yaml` for structure — always set `inheritance: true` (inherits org-wide config from `openshift/coderabbit` which already excludes `vendor/**`, `zz_generated*`, `node_modules/**`)
303+
- [ ] Only add repo-specific exclusions to `path_filters` — skip patterns already covered by org config (vendor, zz_generated, boilerplate)
304+
- [ ] Translate "Path-specific rules" subsections to `path_instructions` entries
305+
- [ ] Set `knowledge_base.filePatterns` to `["REVIEW.md", "AGENTS.md"]`**NEVER add CLAUDE.md** (auto-detected separately)
306+
- [ ] `tone_instructions` is optional — only add if the repo has a distinct review culture; org default applies otherwise
307+
- [ ] If a `.coderabbit.yaml` already exists in the repo, merge: preserve existing settings (profile, auto_review, pre_merge_checks, tools, slop_detection), add/update `knowledge_base`, `path_filters`, and `path_instructions`
308+
- [ ] Validate YAML syntax: `python3 -c "import yaml; yaml.safe_load(open('.coderabbit.yaml'))"`
309+
226310
### Phase 10: Validation & Verification
227311

228312
- [ ] Run `bash "$SKILL_DIR/scripts/validate.sh" "$REPO_PATH"` (includes link validation)
229313
- [ ] Verify AGENTS.md ≤100 lines, no generic duplication, ecosystem.md exists
230314
- [ ] **Verify specificity**: Repo structure only in components.md (not duplicated in DEVELOPMENT.md), pattern claims backed by code evidence
231315
- [ ] **Anti-hallucination checks**: Spot-check type fields if applicable, verify branch names in examples match repo, confirm pattern claims reference actual code
232316
- [ ] **Operator-specific checks** (if operator repo): Verify apply method claims per-controller (`grep -r "client.Apply\|r.Update\|resourceapply" pkg/controller/<name>/`). Verify feature gate claims trace to actual runtime code. Verify image env var names match Makefile/CSV.
317+
- [ ] **REVIEW.md checks** (if generated): exists at repo root, ≤100 lines (`wc -l REVIEW.md`), skip paths reference real directories (`test -d`), platform citations present (grep for "dev-guide" or "CONVENTIONS"), no content overlap with CLAUDE.md
318+
- [ ] **.coderabbit.yaml checks** (if generated): valid YAML (`python3 -c "import yaml; yaml.safe_load(open('.coderabbit.yaml'))"`), `filePatterns` contains "REVIEW.md" but NOT "CLAUDE.md", `path_filters` match "Do not report" globs, `path_instructions` match "Path-specific rules"
233319
- [ ] Verify all domain/*.md files link to actual type definitions
234320
- [ ] Cross-check with openshift-docs if time permits
235321
- [ ] **Flag discovery gaps**: At the end of components.md and DEVELOPMENT.md, add a brief "SME Review Recommended" note listing areas where automated discovery may be incomplete — typically: implementation recipes for adding new components, anti-patterns from institutional knowledge, and rationale behind pattern choices. This sets expectations that the docs are a verified foundation, not a complete implementation guide
@@ -272,6 +358,9 @@ Use this checklist during Phase 5 when exploring the codebase. These patterns pr
272358
| **Naming conventions** | Grep for patterns in env vars, labels, file names, package names | Exact format with examples |
273359
| **Feature toggles** | Are there feature gates, flags, or config-driven enablement? | Definition → runtime check → wiring chain |
274360
| **Anti-patterns** | Search for "DO NOT", "NEVER", "MUST", "HACK" in code comments. Study 2-3 existing implementations to identify shared patterns and things they avoid | Numbered "DO NOT" list with brief explanation |
361+
| **CI enforcement** | `grep -E "^(lint\|fmt\|vet\|check\|verify):" Makefile` | CI-enforced checks → "Do not report" in REVIEW.md |
362+
| **High-risk areas** | `git log --since="1 year" --name-only --pretty=format: \| sort \| uniq -c \| sort -rn \| head -20` | High-churn files → severity tuning in REVIEW.md |
363+
| **Vendored API boundaries** | `ls vendor/github.com/openshift/api 2>/dev/null` | Vendored API types → "Always check" in REVIEW.md |
275364
276365
### Operator-Specific Discovery
277366
@@ -329,6 +418,8 @@ When the repo is a Kubernetes/OpenShift operator (detected via controller-runtim
329418
330419
✅ **Operator accuracy** (if operator repo): Apply method documented per-controller (not assumed uniform), feature gate runtime behavior traced, generated code inventory listed, image resolution mechanism documented
331420
421+
✅ **REVIEW.md** (if generated): At repo root, 60-80 lines (cap 100), skip paths valid, platform citations present, no CLAUDE.md overlap, .coderabbit.yaml in sync
422+
332423
## Anti-Patterns
333424
334425
### ❌ DON'T duplicate Platform content
@@ -379,6 +470,8 @@ Repository: [path]
379470
380471
Structure:
381472
✅ AGENTS.md (root): XX lines (target: 80-100)
473+
✅ REVIEW.md: XX lines (target: 60-80)
474+
✅ .coderabbit.yaml: valid, synced with REVIEW.md
382475
✅ Domain concepts: N files
383476
✅ Architecture: components.md
384477
✅ Component ADRs: N files

plugins/agentic-docs/skills/component-docs/scripts/validate.sh

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,75 @@ fi
273273

274274
echo ""
275275

276+
# Check REVIEW.md
277+
if [ -f "$REPO_PATH/REVIEW.md" ]; then
278+
echo " ✅ REVIEW.md exists"
279+
REVIEW_LINES=$(wc -l < "$REPO_PATH/REVIEW.md")
280+
if [ "$REVIEW_LINES" -gt 100 ]; then
281+
echo " ⚠️ REVIEW.md is $REVIEW_LINES lines (soft cap: 100)"
282+
else
283+
echo " $REVIEW_LINES lines (target: 60-80, cap: 100) ✅"
284+
fi
285+
# Check for platform citations
286+
if grep -qi "dev-guide\|CONVENTIONS\|enhancements" "$REPO_PATH/REVIEW.md"; then
287+
echo " ✅ Platform rule citations found"
288+
else
289+
echo " ⚠️ No platform rule citations found"
290+
fi
291+
# Check skip paths reference real directories
292+
while IFS= read -r skip_path; do
293+
clean_path=$(echo "$skip_path" | sed 's/[`*]//g' | xargs)
294+
if [ -n "$clean_path" ] && [[ "$clean_path" != vendor* ]] && [[ "$clean_path" != go.* ]]; then
295+
base_dir=$(echo "$clean_path" | cut -d'/' -f1)
296+
if [ -d "$REPO_PATH/$base_dir" ] || [ -f "$REPO_PATH/$base_dir" ]; then
297+
if [ "${VERBOSE:-false}" = "true" ]; then
298+
echo " ✅ Skip path base exists: $base_dir"
299+
fi
300+
else
301+
echo " ⚠️ Skip path base not found: $base_dir (from $skip_path)"
302+
fi
303+
fi
304+
done < <(grep -oP '`[^`]+\*\*[^`]*`' "$REPO_PATH/REVIEW.md" 2>/dev/null || true)
305+
# Check no overlap with CLAUDE.md
306+
if [ -f "$REPO_PATH/CLAUDE.md" ]; then
307+
overlap=$(comm -12 \
308+
<(grep -v '^$\|^#\|^-' "$REPO_PATH/REVIEW.md" 2>/dev/null | sort -u) \
309+
<(grep -v '^$\|^#\|^-' "$REPO_PATH/CLAUDE.md" 2>/dev/null | sort -u) \
310+
| wc -l)
311+
if [ "$overlap" -gt 3 ]; then
312+
echo " ⚠️ REVIEW.md has $overlap lines overlapping with CLAUDE.md"
313+
else
314+
echo " ✅ No significant CLAUDE.md overlap"
315+
fi
316+
fi
317+
else
318+
echo " ℹ️ REVIEW.md not found (optional — run Phase 9.5 to generate)"
319+
fi
320+
321+
echo ""
322+
323+
# Check .coderabbit.yaml
324+
if [ -f "$REPO_PATH/.coderabbit.yaml" ]; then
325+
echo " ✅ .coderabbit.yaml exists"
326+
if python3 -c "import yaml; yaml.safe_load(open('$REPO_PATH/.coderabbit.yaml'))" 2>/dev/null; then
327+
echo " ✅ Valid YAML syntax"
328+
else
329+
echo " ❌ Invalid YAML syntax"
330+
fi
331+
if grep -q "REVIEW.md" "$REPO_PATH/.coderabbit.yaml"; then
332+
echo " ✅ filePatterns includes REVIEW.md"
333+
else
334+
echo " ⚠️ filePatterns missing REVIEW.md"
335+
fi
336+
if grep -q "CLAUDE.md" "$REPO_PATH/.coderabbit.yaml" 2>/dev/null; then
337+
echo " ⚠️ filePatterns includes CLAUDE.md (auto-detected, remove)"
338+
fi
339+
else
340+
echo " ℹ️ .coderabbit.yaml not found (optional — run Phase 9.5 to generate)"
341+
fi
342+
343+
echo ""
344+
276345
# Check for forbidden patterns (generic content duplication)
277346
echo "Checking for generic duplication..."
278347

@@ -318,6 +387,20 @@ if [ -f "$REPO_PATH/AGENTS.md" ]; then
318387
echo ""
319388
fi
320389

390+
# Check links in REVIEW.md
391+
if [ -f "$REPO_PATH/REVIEW.md" ]; then
392+
echo "📄 Checking REVIEW.md:"
393+
echo " 🔗 External links:"
394+
if ! validate_links "$REPO_PATH/REVIEW.md"; then
395+
LINK_VALIDATION_FAILED=true
396+
fi
397+
echo " 🔗 Internal links:"
398+
if ! validate_internal_links "$REPO_PATH/REVIEW.md"; then
399+
LINK_VALIDATION_FAILED=true
400+
fi
401+
echo ""
402+
fi
403+
321404
# Check links in all ai-docs markdown files
322405
if [ -d "$REPO_PATH/ai-docs" ]; then
323406
while IFS= read -r -d '' file; do

0 commit comments

Comments
 (0)