Triage — Categorize changes and select relevant agents
Before launching agents, perform a quick triage pass over the diff to determine which review dimensions are actually relevant. This avoids wasting time on agents that have nothing meaningful to review.
1a: Categorize each changed file
Scan the diff and assign one or more categories to every changed file (production, test, and other):
| Category | Signals |
|---|
| storage-engine | Files in storage/, cache/, wal/, StorageComponent subclasses, page read/write logic, DiskStorage, WriteCache, ReadCache, LogSequenceNumber, double-write log |
| concurrency | synchronized, Lock, Atomic*, volatile, StampedLock, ReentrantLock, thread pools, ConcurrentHashMap, CompletableFuture, shared mutable state, @GuardedBy, ConcurrentTestHelper, CountDownLatch, CyclicBarrier |
| crash-durability | WAL operations, crash simulation, durable StorageComponent recovery, page corruption handling, transaction atomicity under failure, LogSequenceNumber manipulation, double-write log, Java assert statements in production code |
| index-data-structures | Files in index/, B-tree, hash index, SBTree, CellBTree, histogram, IndexEngine |
| network-server | Files in server/, driver/, Gremlin Server, protocol handling, TLS/SSL, authentication, session management |
| sql-query | Files in sql/ (excluding parser/), query execution, command handlers |
| gremlin | Files in gremlin/, traversal steps, YTDBGraph* classes, TinkerPop integration |
| public-api | Files in com.jetbrains.youtrackdb.api, YourTracks, YouTrackDB interface |
| serialization | Record serializers, binary format, property map encoding/decoding |
| configuration | GlobalConfiguration, config parameters, system properties |
| tests-only | Changes exclusively in test files with no production code changes |
| build-config | pom.xml, CI workflows, Maven profiles, Docker configs |
| docs-only | Markdown, documentation, comments-only changes |
A file can belong to multiple categories.
1b: Select code review agents based on categories
| Agent | Launch when ANY of these categories are present |
|---|
| review-code-quality | Always launched (unless docs-only is the ONLY category) |
| review-bugs | concurrency, storage-engine, index-data-structures, network-server, serialization, gremlin, sql-query |
| review-concurrency | concurrency is present on any changed file |
| review-crash-safety | crash-durability |
| review-security | network-server, public-api, sql-query, serialization, configuration, OR when new dependencies are added in pom.xml |
| review-performance | storage-engine, index-data-structures, concurrency, serialization, sql-query, gremlin |
review-bugs owns sequential-reasoning defects (logic, null safety, leaks, RID handling, state-machine / lifecycle); review-concurrency owns interleaving-reasoning defects (races, visibility / publication, lock-ordering / deadlock, compound-op atomicity) and fires only on the concurrency category.
1c: Select test quality agents based on categories
| Agent | When to launch |
|---|
| review-test-quality | Always (unless docs-only or build-config are the ONLY categories) — carries both the behavior and completeness sub-protocols, both the TB and TC prefixes |
| review-test-structure | Any test files are changed |
| review-test-concurrency | concurrency, OR production code touches shared mutable state / threading primitives even if no concurrency tests exist yet |
| review-test-crash-safety | crash-durability |
1d: Log your triage decision
Before launching agents, output a brief triage summary:
### Triage Summary
- **Categories detected**: storage-engine, concurrency
- **Code review agents selected**: review-code-quality, review-bugs, review-concurrency, review-performance
- **Code review agents skipped**: review-crash-safety (no crash-durability category), review-security (no network/API/SQL/config/dependency changes)
- **Test quality agents selected**: review-test-quality, review-test-structure, review-test-concurrency
- **Test quality agents skipped**: review-test-crash-safety (no crash-durability category)
1e: Edge cases
- If all categories are
docs-only: Skip all agents. Report that only documentation changed and no code review is needed.
- If all categories are
build-config: Launch review-code-quality (to check for misconfigurations) and review-security (to check for dependency changes).
- If all categories are
tests-only: Launch review-code-quality, review-bugs (plus review-concurrency if the concurrency category is present) for code agents, and review-test-quality, review-test-structure for test agents.
- If in doubt about whether an agent is relevant: launch it. False positives are better than false negatives.
Launch selected review agents in parallel (fresh sub-agents):
Each agent receives the same context:
## Review Target
CI fix: {brief description of the fix}
Reviewing: changes on current branch vs develop
## Changed Files
{git diff develop...HEAD --name-only}
## Skip These Files (generated code)
- core/.../sql/parser/*, generated-sources/*, Gremlin DSL
## Tooling
Use **mcp-steroid PSI find-usages / find-implementations / type-
hierarchy via `steroid_execute_code`, not grep**, for any reference-
accuracy question about a Java symbol in this fix (callers/overrides
/usages of a method, field, class, or annotation; whether the fix
leaves stale references; whether a new helper duplicates an existing
one; whether a test exercises the same code path the production fix
touches). Grep is acceptable for filename globs, unique string
literals, and orientation reads, but the load-bearing answer behind
a finding must be PSI-backed when the mcp-steroid MCP server is
reachable per the SessionStart hook (`steroid_list_projects` once at
the start confirms the open project matches the working tree). Fall
back to grep with an explicit reference-accuracy caveat in the
finding only when mcp-steroid is unreachable. See
`CLAUDE.md` § MCP Steroid → "Grep vs PSI — when to switch"
for the full routing rule.
## Diff
{git diff develop...HEAD}
Set subagent_type to the agent name and model to opus for each.