-
Notifications
You must be signed in to change notification settings - Fork 586
Open
Description
Summary
The feature-dev:code-reviewer and pr-review-toolkit:silent-failure-hunter agents currently miss a class of bugs where methods return a failure status but leave the object in a stale/invalid state.
Example Bug Missed
In a recent PR review, both agents missed this issue (caught by Codex):
spawn(excludePositions, currentTick) {
// Try random positions...
// Fallback to exhaustive search...
if (validCells.length > 0) {
this.position = validCells[randomIndex];
this.spawnTick = currentTick;
return true;
}
// Bug: returns false but doesn't clear existing state
return false; // ← position and spawnTick still have old values!
}Impact: When spawn() fails (grid full), the old position/spawnTick persist, causing stale data to be rendered and collected.
Fix was:
// No valid position available (grid is full)
// Clear food state to prevent stale data
this.position = null;
this.spawnTick = null;
return false;Current Agent Coverage
code-reviewer checks:
- Logic errors, null handling, race conditions
- Security vulnerabilities, performance problems
- Project guideline compliance
silent-failure-hunter checks:
- Empty catch blocks
- Swallowed exceptions
- Fallback behavior without user awareness
- Missing error logging
Neither specifically checks: "When a method fails, is the object left in a valid/clean state?"
Suggested Enhancement
Add to code-reviewer.md Bug Detection section:
**State Consistency on Failure**: When methods can fail (return false, throw, etc.),
verify that partial state changes are reverted or cleaned up. Look for:
- Methods that modify `this.*` properties before a potential failure point
- Return statements that don't reset modified state
- Objects left in inconsistent states after errorsAnd/or add to silent-failure-hunter.md Hidden Failures section:
**Stale State on Failure**: Look for methods that:
- Return failure status without clearing previously-set properties
- Leave objects in partially-modified states after errors
- Could cause subsequent operations to use stale/invalid dataContext
- PR where this was missed: Add basic food system with apple visual design N3SSQwiK/Snake#33
- Codex review caught it; our internal code-reviewer agent did not
- This is a common pattern in stateful classes (game entities, caches, state machines)
Metadata
Metadata
Assignees
Labels
No labels