Fix ci failure

From JetBrains/youtrackdb · View interactive version

Fix ci failure is an AI agent skill from the GitHub repository JetBrains/youtrackdb. Diagnose and fix a CI test failure from a GitHub PR or workflow run. Includes root cause analysis, dimensional code review, and PR creation.

How to use this skill

Skill file

Fix a CI test failure from a GitHub PR or workflow run.

The user will provide a URL to a failing check run, PR checks page, or workflow run.

Use $ARGUMENTS as the URL if provided.

Workflow

Step 0: Create progress tracker (MANDATORY — do this FIRST)

Before any investigation, create tasks for every workflow step using TaskCreate.

These tasks are your checklist — mark each in_progress when starting and

completed when done. Do NOT skip tasks. Complete them in order.

Create these tasks:

  1. Identify the failure
  2. Classify the failure type
  3. Locate and understand the failing test
  4. Trace the root cause
  5. Apply the fix
  6. Verify locally
  7. Dimensional code review + test quality review
  8. Summarize and wait for approval
  9. Commit and PR (only after approval)

Step 1: Identify the failure

  1. Use gh CLI to fetch PR and check run details. Prefer gh api and gh pr over WebFetch for GitHub URLs.
  2. If no URL is provided, detect the current branch and find its open PR:

```bash

gh pr list --head {branch} --json number,title,url,statusCheckRollup

```

  1. List non-passing checks to find failures:

```bash

gh pr view {number} --json statusCheckRollup --jq '.statusCheckRollup[] | select(.conclusion != "SUCCESS")'

```

  1. Get the failing check annotations to find the exact test name and error message:

```bash

gh api "repos/{owner}/{repo}/check-runs/{check_run_id}/annotations"

```

  1. For workflow run failures, get failed job logs:

```bash

gh run view --job {job_id} --log-failed

```

  1. Check PR comments for gate details: CI gates (coverage gate, test count gate) post detailed PR comments with tables explaining exactly what failed. Always fetch these:

```bash

gh api repos/{owner}/{repo}/issues/{pr_number}/comments --jq '.[] | select(.body | contains("gate")) | .body'

```

Step 2: Classify the failure type

Not all CI failures are test failures. Identify the category before diving into code:

Step 2a: Diagnose CI gate failures

CI gates enforce policies on PRs. When a gate fails:

  1. Read the gate's PR comment — it contains the specific data (uncovered lines, test count drops, surviving mutants).
  2. Understand the gate's threshold — check CLAUDE.md and the gate script for exact rules.
  3. Determine if the failure is expected or a bug:
  1. The fix is often in build configuration, not in test code: When a PR changes Maven profiles, CI pipeline config, or surefire/failsafe plugin settings, tests may silently stop running. Look for:

Step 3: Locate and understand the failing test

  1. Find the test file using Glob (e.g., **/{TestClassName}.java).
  2. Read the full test file to understand the test logic, especially the failing assertion.
  3. Read the error message carefully — identify whether this is:

Step 4: Trace the root cause

  1. Read the production code exercised by the failing test.
  2. Understand the full data flow from the code under test to the assertion.
  3. Determine whether the fix should be in the test or in the production code:
  1. For build config issues: Trace the chain — which Maven profile was removed? What did it activate? Which module's pom.xml depended on it? Read the module's pom.xml fully to find exclusions, profile overrides, and plugin configurations.
  2. Document your root cause analysis before making changes.

Step 5: Apply the fix

  1. Make the minimal change that fixes the root cause.
  2. Add or update comments explaining why the fix is correct (especially for tolerance values, timing adjustments, or non-obvious logic).
  3. Update any method/class Javadoc that describes behavior affected by the fix.
  4. Update CLAUDE.md if the fix changes documented behavior (e.g., which tests run by default, which profiles are needed).
  5. Add Java assert statements generously in production code touched by the fix or exercised by new/changed tests. These must have zero production overhead (disabled by default in production JVMs). Good candidates:

Do NOT add assertions that duplicate existing validation, have side effects, or are tautological.

If the assertion condition is complex, extract it to a package-private helper method to get full JaCoCo coverage (see .claude/docs/architecture.md § Codebase-specific tips → "JaCoCo and Java assert statements").

  1. Improve testability of internal classes when needed to write effective tests or add meaningful assertions. You may refactor classes under com.jetbrains.youtrackdb.internal (e.g., extract methods, increase visibility from private to package-private, add package-private accessors for state verification) but never modify the public API under com.jetbrains.youtrackdb.api. Any testability change must not alter the class's external behavior.
  2. Run ./mvnw -pl {module} spotless:apply to fix formatting.

Step 6: Verify locally

  1. Run the failing ordinary unit test only when its module contains changed files.

For a core Gremlin compliance wrapper, use the profile route in item 3 instead:

```bash

./mvnw -pl {module} clean test -Dtest={TestClass}

```

  1. For gate failures, run each test-gate set module to verify its counts.

The test-gate set contains only modules with changed files.

For a changed module:

```bash

./mvnw -pl {module} clean test

```

  1. The pull request build runs the whole unit suite.

Rely on it for tests outside the test-gate set.

A developer machine never runs integration tests.

Follow docs-internal/dev-workflow/track-development.md for scope and timing.

If a unit test needs a suite runner, select that runner within the test-gate set.

Core Gremlin compliance wrappers cannot use the plain -Dtest command in step 1.

Follow docs-internal/dev-workflow/coverage-verification.md § Core Gremlin compliance

runners for the explicit gremlin-compliance-suites profile route.

For a test-only run, omit coverage from the profile list.

Measure coverage only when core also belongs to the coverage set.

Check wrapped-test reports, not only the wrapper entry, for actual test execution.

  1. Run ./mvnw -pl {module} spotless:check to ensure formatting compliance.

Step 7: Dimensional code review + test quality review (MANDATORY GATE)

**BLOCKING: Do NOT proceed to Step 8 (summarize) until this step is fully

complete. Skipping this step is never acceptable — it exists to catch bugs

in the fix itself before presenting to the user.**

If you changed any code or added/fixed/changed any tests, run a

dimensional code review and test quality review. This step is mandatory

whenever code or tests were modified.

  1. 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

```

1e: Edge cases

  1. 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)

## 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.

  1. Synthesize findings: After all selected agents complete, deduplicate

across dimensions. Prioritize: blocker > should-fix > suggestion.

  1. Address all blocker and should-fix findings:
  1. After applying fixes, run ./mvnw -pl {module} spotless:apply and

re-run the affected tests to confirm they pass.

  1. Re-run only the agent(s) with open findings on the updated changes.
  1. Repeat steps 4-6 until no blocker/should-fix findings remain.

critical issues, present the remaining findings to the user and ask

for guidance.

Step 8: Summarize and wait for approval

Present to the user:

Do NOT commit or push until the user approves.

Step 9: Commit and PR (only after approval)

  1. Commit following the project's git conventions (YTDB-NNN prefix, imperative summary).
  2. Push and create a PR targeting develop with:

Important Rules

YouTrackDB-Specific Knowledge

CI Gates

Common Patterns

Useful Commands

# Check PR gate comments
gh api repos/JetBrains/youtrackdb/issues/{pr}/comments --jq '.[] | select(.body | contains("gate")) | .body'

# Run single module tests
./mvnw -pl {module} clean test -Dtest={TestClass}

# Run a targeted test class with disk storage
./mvnw -pl {module} clean test -Dtest={TestClass} \
  -Dyoutrackdb.test.env=ci
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.