Phase 4 Worker
AI code review gate and audit trail management.
Queue: phase4
AI Review Processing
- Receive job when PR is opened or updated
- Load review config for the repository
- Fetch PR diff and changed files from GitHub
- Send to Claude with review instructions:
- Check logic, security, architecture, cost, tests
- Respect
ignore_patternsand file limits
- Parse findings and determine verdict
- Create GitHub Check Run (if
checks:writepermission available) - Optionally create PR Review with inline comments
- Record in
ai_reviewstable - Create audit trail entry
Audit Trail Processing
Every significant action creates an audit entry:
- Serialize the payload as JSON
- Compute SHA-256 hash
- Link to previous entry via
prev_hash - Insert immutable record (never updated/deleted)
Chain Verification
Verification checks prev_hash linkage between consecutive entries. PostgreSQL normalizes JSONB key order on storage, so verification checks the chain linkage rather than rehashing round-tripped payloads.
Check Run Fallback
If the GitHub App doesn't have checks:write permission:
- Gracefully falls back to PR Review comments only
- Logs a warning, doesn't fail the job
- Review still recorded in the database