# Cosmic Code Review Guidelines

> Self-review checklist and acceptance criteria for Cosmic Java code.

---

## Self-Review Checklist (Before Requesting Review)

- [ ] Code compiles (`mvn compile` / `gradle build`)
- [ ] All existing tests pass
- [ ] No `printStackTrace()` — use `logger.error("description", e)` instead
- [ ] No `RuntimeException` — use `KDBizException` with original `cause`
- [ ] No string-concatenated SQL/KSQL — use parameterized queries
- [ ] No loops containing DB queries, Redis access, or `view.updateView()`
- [ ] Field/entity references verified against actual metadata, not guessed
- [ ] No methods that don't exist (check against anti-patterns list)
- [ ] Base class chosen correctly (`Ext` preferred for new code)
- [ ] No unused imports
- [ ] No placeholder TODOs that mask incomplete logic

---

## Review Priority (in order)

| Priority | What to check |
|----------|--------------|
| P0 | Behavioral regressions — does the code do what the PRD requires? |
| P0 | Hard constraint violations (A-level: security, resource leaks, N+1, metadata corruption) |
| P1 | Spec/platform contract violations |
| P1 | Missing or weak tests for logic changes |
| P2 | Coding standard deviations (B-level: style, naming, helper usage) |
| P2 | Cross-platform path, command, or encoding assumptions |

---

## Error Severity Levels

| Level | Meaning | Action |
|-------|---------|--------|
| ERROR (A) | Hard constraint — will cause runtime failure or data corruption | Must fix. Blocks delivery. |
| WARNING (B) | Recommended pattern — existing code is maintainable, new code should follow preferred approach | Fix for new code. Historical code: evaluate context. |
| INFO (C) | Governance item — suitable for batch refactoring or template upgrade | Record as suggestion. Non-blocking. |

**Fix retry limit**: Maximum 3 rounds of "fix → recheck" per file. If ERRORs remain after 3 rounds, stop auto-fix and report remaining issues for manual intervention.

