Experimental code coverage cq debugger

From chromium/chromium · View interactive version

Experimental code coverage cq debugger is an AI agent skill from the GitHub repository chromium/chromium. Executes the phased, multi-skill code coverage debugging playbook for triaging underreported code coverage in the Gerrit Commit Queue (CQ).

How to use this skill

Skill file

State Management

Throughout the triage process, maintain a state file at

scratch/triage_state.json. In Step 1, you MUST load the existing state

file (initialized by the orchestrator) and initialize ALL variables defined in

templates/triage_state_template.json in

scratch/triage_state.json initially, even if many of them will initially be

null. Update these variables in scratch/triage_state.json as they are

resolved in subsequent steps.

Variables to Initialize:

When initializing variables in Step 1, reference

templates/triage_state_template.json for

the required variables and data contract. All variables from this schema MUST be

loaded into scratch/triage_state.json at the start of Phase 1.


Commit Queue (CQ) Coverage Debugging Playbook

This skill defines the end-to-end triaging and resolution process for Gerrit

Commit Queue (CQ) underreported coverage bugs. It guides the agent through Phase

1 (Information Gathering), Phase 2 (Audit Configuration), Phase 3 (Prepare

Experiment), and Phase 4 (Validation).

[!IMPORTANT] Sequential Execution & Status Updates:

1. Sequential Execution: You must execute each step in the workflow

sequentially. Do NOT skip any steps or proceed to a subsequent step until

the current step has fully completed, returned its outputs, and validated

its constraints.

2. Status Updates: You MUST update the status field in

scratch/triage_state.json whenever transferring to another step (i.e., at

the end of each step) to track progress. The status value should reflect

the step name or number just completed (e.g.,

"CQ Triage: Step 5 Completed"). The final terminal status values must be

set to either "FIXED" or "ESCALATED".


Phase 1: Information Gathering

Step 1: Initialize State File

variables defined in

templates/triage_state_template.json

in scratch/triage_state.json (setting unresolved variables to null or

empty dictionaries). Ensure all existing variables already defined in

scratch/triage_state.json (such as bug_id, status, bug_details, etc.,

initialized by the orchestrator) are preserved.

scratch/triage_state.json.

Step 2: Scrape Gerrit CL Details & Verify Repository

scratch/triage_state.json and store it in the original_cl variable in

scratch/triage_state.json. Then, verify the repository and retrieve modified

files for original_cl. (Note: You can use

tools/code_coverage/parse_gerrit_url.py to extract host, project,

change, and patchset details from any CL URL when needed).

skill.

modified_files. Update these variables in scratch/triage_state.json.

the chromium/src repository. If the CL targets recipe or infrastructure

repositories (e.g. infra/build), stop immediately and inform the user that

recipe triage is out of scope for this playbook.

scratch/triage_state.json.

provided, prompt the user to get it.

Step 3: Validate Against Bug Description & Filter Target Files

developer's bug report (found in bug_details in

scratch/triage_state.json).

.java, etc.) the developer is complaining about in bug_details. Set

target_files to only contain those specific files matching the bug

report. If the bug report does not specify files, keep all modified

application source files from modified_files.

complaining about in bug_details. Set metrics_of_concern to only

contain matching metrics from the standard options ("absolute_coverage",

"incremental_coverage", "absolute_unit_tests_coverage",

"incremental_unit_tests_coverage"). If the bug report does not specify,

keep all four standard coverage metrics.

metrics_of_concern list under investigation. Update both target_files and

metrics_of_concern in scratch/triage_state.json.

Step 4: Read Coverage Metrics

for target_files using a sub-agent.

experimental-read-code-coverage-metrics

skill. You MUST explicitly pass cl_url (read original_cl from

scratch/triage_state.json),

artifact_path: "scratch/original_metrics.json", and target_files (read

from scratch/triage_state.json) in the subagent prompt.

proceeding.

code lines strictly for target_files in scratch/original_metrics.json.

Step 5: Map Source Files to Test Suites

compile the modified target files by calling test_suite_mapper.py directly.

```bash

vpython3 tools/code_coverage/test_suite_mapper.py <target_file>

```

*(For additional flags such as --build-dir or historical --revision

mapping, see vpython3 tools/code_coverage/test_suite_mapper.py --help).*

Update test_suites in scratch/triage_state.json.

Step 6: Identify Builders of Concern

file language:

android-desktop-x64-rel (android-internal-desktop-x64-rel for internal

developers), android-cronet-x64-dbg-14-tests

builders:

android-desktop-x64-rel (android-internal-desktop-x64-rel for internal

developers), android-cronet-x64-dbg-14-tests

android-internal-desktop-x64-rel both inherit their base build

configuration from

infra/config/subprojects/chromium/try/tryserver.chromium.android.desktop.star

(via the equivalent_builder property).

*.pyl files inside

https://chrome-internal.googlesource.com/clank/internal/apps/+/HEAD/build/bot.

builders_of_concern in scratch/triage_state.json.


Phase 2: Audit Configuration Patching

Step 7: Check & Patch Test Suite Execution on Builders

whether the test suite would be compatible to run with it. At your

discretion, if compatible:

1. Create a new branch from main (e.g., verify-coverage-fix) if

fix_branch_name is None, and update fix_branch_name in

scratch/triage_state.json. Check out fix_branch_name.

2. Add the test suite configuration to the builder in Starlark.

3. Regenerate the configuration files:

```bash

lucicfg generate infra/config/main.star

```

If fundamentally incompatible, stop or exclude the builder.

on all builders_of_concern, and update fix_branch_name in

scratch/triage_state.json (if created).

Step 8: Audit Builder Configurations (Parallel Audit)

parallel by invoking a specialized sub-agent for each builder.

builders_of_concern. Equip each sub-agent with the

experimental-code-coverage-config-validator skill and the

experimental-ci-only-validator skill. When launching each sub-agent,

instruct it to:

1. Pass builders_of_concern and language_context ("cpp", "objc",

"rust", "java", "js", or "ts", inferred from target_files) to

experimental-code-coverage-config-validator to validate GN arguments.

2. Run experimental-ci-only-validator to verify if any of the mapped

test_suites (from scratch/triage_state.json) are barred by

ci_only = True on that builder (checking all mapped test suites, not just

one).

before proceeding to Phase 3.

that any test suite is barred by ci_only = True:

1. Apply all suggested GN arg fixes to the Starlark files.

2. Remove the ci_only = True flag for any barred test suite on that builder

in Starlark.

3. Commit all configuration fixes together in a single commit to the

fix_branch_name branch (creating the branch from main if

fix_branch_name is None).

4. Regenerate the configuration files:

```bash

lucicfg generate infra/config/main.star

```

are valid across all builders_of_concern and all mapped test_suites. If

configuration fixes were applied, update fix_branch_name in

scratch/triage_state.json (if created).

Step 9: Compile Configuration Fixes Summary

in Step 7 and Step 8 across all builders_of_concern.

scratch/config_summary.md documenting whether any test suites were added or

patched, any GN arguments were corrected, or any ci_only flags were removed

(or confirming that existing builder configurations were valid without

changes).


Phase 3: Prepare Experiment

Step 10: Analyze Required CLs & Branches

1. An Experimental Branch (already exists as fix_branch_name).

2. A Baseline Branch (create a new branch from main, e.g.

verify-coverage-baseline, and set control_branch_name to this

branch).

1. A Baseline Branch (create a new branch from main, e.g.

verify-coverage-baseline, and set control_branch_name to this

branch).

already created, fix_branch_name. Update control_branch_name and

fix_branch_name in scratch/triage_state.json.

Step 11: Generate CLs (Parallel CL Generation)

parallel by invoking a specialized sub-agent for each CL.

for the baseline branch and one for the experimental fix branch if created).

Equip both sub-agents with the experimental-code-coverage-verification-prep

skill to inject dummy comments, optimize Starlark configs, and upload CLs to

Gerrit. When launching each cl_generator sub-agent, instruct it to read its

primary inputs (target_files, builders_of_concern, test_suites,

bug_id) directly from scratch/triage_state.json. You MUST pass role

("Control" or "Fix"). For "Fix" runs, also pass in a summary of the

configuration and recipe fixes applied (e.g. from scratch/config_summary.md,

scratch/swarming_summary.md, or scratch/local_debugging.md) so the

sub-agent can generate a descriptive CL description.

before proceeding to Step 12.

applicable). Update control_cl and fix_cl in scratch/triage_state.json.

scratch/triage_state.json (such as during subsequent iterations or if

pre-populated), skip generating control_cl and do NOT launch a

cl_generator sub-agent for the control run. Only launch the sub-agent for

the experimental fix branch (role: "Fix").

Step 12: Trigger Try Jobs (Parallel Execution)

parallel using sub-agents.

for the control CL and one for the fix CL if created). Equip both sub-agents

with the experimental-code-coverage-build-invoker skill. When launching each

sub-agent, instruct it to:

1. For control_cl: pass builders_of_concern and the designated

control_cl URL (read from scratch/triage_state.json).

2. For fix_cl (if created): pass builders_of_concern and the designated

fix_cl URL (read from scratch/triage_state.json).

before proceeding to Phase 4.

jobs, mapped to their builder name inside control_builds (for control CL) or

fix_builds (for fix CL). Update control_builds and fix_builds in

scratch/triage_state.json.

scratch/triage_state.json (such as during subsequent iterations or if

pre-populated), skip triggering try jobs for control_cl and do NOT launch a

build_invoker sub-agent for the control run. Only trigger try jobs for

fix_cl.


Phase 4: Explore and Validate Experiment Results

Step 13: Inspect Builds (Parallel Inspection)

by invoking a specialized sub-agent for each builder.

in builders_of_concern. Equip each sub-agent with the

experimental-code-coverage-build-inspector skill. When launching each

sub-agent, the parent agent MUST pass builder_name (e.g., "linux-rel").

Instruct each sub-agent to:

1. Read control_builds[builder_name] and fix_builds[builder_name] (if

present) from scratch/triage_state.json.

2. Call experimental-code-coverage-build-inspector for the build link(s),

passing language_context ("cpp", "objc", "rust", "java", "js",

or "ts"), test_suites, metrics_of_concern, and target_files (read

from scratch/triage_state.json), to verify GN arguments, inspect merge

script logs for the specific target test suites, and check whether coverage

data is generated for target_files in the HTML report and downloaded JSON

coverage artifacts. (Note: It is also possible that we only have a control

build with no fix build. If fix_builds[builder_name] is omitted, inspect

only the control build).

3. Generate a comparative inspection artifact report at

scratch/inspection_<builder_name>.md documenting whether coverage

processing succeeded on the fix build compared to the control (or

documenting baseline results if no fix build exists).

the build_inspector sub-agent to invoke the schedule tool

(CronExpression="*/10 * * * *") to check back every 10 minutes until

terminal build completion before continuing to Step 14.

build stored in control_builds and fix_builds, and the generated

inspection artifacts (scratch/inspection_<builder_name>.md for each builder

of concern). Update control_builds and fix_builds in

scratch/triage_state.json.

Step 14: Compare Builder Inspection Artifacts

(scratch/inspection_<builder_name>.md generated in Step 13) across all

builders_of_concern.

generation, and merging succeeded on the experimental fix builds compared to

the baseline control builds across all target builders. (Note: It is also

possible that we only had a control build with no fix build. If no fix build

exists, evaluate whether the baseline control build alone successfully

generated coverage).

scratch/inspection_summary.md which summarizes all the information from all

the inspected scratch/inspection_<builder_name>.md files across all

builders_of_concern, confirming whether coverage generation changed/resolved

due to our configuration fixes (or confirming baseline coverage generation if

no fix build was triggered).

Step 15: Read Verification Coverage (Parallel Execution)

applicable, the Experimental/Fix CL in parallel using sub-agents.

for the control CL and one for the fix CL if created). Equip both sub-agents

with the

experimental-read-code-coverage-metrics

skill. When launching each sub-agent, you MUST explicitly pass:

1. For control CL: pass cl_url (control_cl),

artifact_path: "scratch/control_metrics.json", and target_files (read

from scratch/triage_state.json).

2. For fix CL (if created): pass cl_url (fix_cl),

artifact_path: "scratch/fix_metrics.json", and target_files (read from

scratch/triage_state.json).

proceeding.

scratch/control_metrics.json (for baseline control CL) and

scratch/fix_metrics.json (for experimental fix CL).

iteration 2 or 3), skip launching the metrics_reader subagent for the

control CL and only launch one for scratch/fix_metrics.json.

Step 16: Artifact Analysis & Comparison

available CL states (Original, Baseline/Control, and

Experimental/Fix).

scratch/metrics_summary.json.

low-coverage code areas identified in scratch/original_metrics.json against

the coverage data in scratch/control_metrics.json and

scratch/fix_metrics.json.

Gerrit as underreported are now covered (in either the baseline control or

experimental fix run), mark status as "FIXED" in

scratch/triage_state.json and jump directly to Step 20 to formulate

Root Cause Analysis.

Step 17: Swarming Output Validation (Fast Remote Audit)

experimental-code-coverage-swarming-output-validator skill. You MUST pass

test_suites and build_url (read from scratch/triage_state.json).

Instruct the subagent to create a summary document of all steps taken and

insights gained at scratch/swarming_summary.md.

Step 18: Local Debugging (Workstation & Universal Test Runner)

experimental-code-coverage-local-debugger skill. Instruct the subagent to

create a summary document of all steps taken and insights gained at

scratch/local_debugging.md.

Step 19: Evaluate Additional Repairs & Iterative Experiment Loop

scratch/local_debugging.md to evaluate whether findings indicate that an

additional fix (such as a Starlark recipe fix, GN argument change, or test

harness patch) is required.

scratch/triage_state.json under "iteration", defaulting to 1) is less

than 3:

1. Increment "iteration" by 1 in scratch/triage_state.json.

2. Make the required Starlark/GN/code repairs directly on the same branch

(fix_branch_name) and commit them so subsequent uploads append new

patchsets to the same experimental CL (fix_cl).

3. Archive the current iteration's scratch verification artifacts

(scratch/fix_metrics.json, scratch/metrics_summary.json,

scratch/inspection_*.md, scratch/swarming_summary.md,

scratch/local_debugging.md) by moving them into

scratch/iteration_<N-1>/. Do NOT archive scratch/control_metrics.json

as it is preserved across iterations. Also copy

scratch/triage_state.json to

scratch/iteration_<N-1>/triage_state.json to snapshot prior build URLs.

Then, in the active scratch/triage_state.json file, reset fix-related

variables ("fix_builds": {}) while preserving Phase 1 metadata and

control baseline variables ("control_builds", "control_cl").

4. Jump back to Step 10 to generate/update CL patchsets and run the new

verification experiment.

reached), proceed to Step 20.

Step 20: Generate Final Hypothesis & Resolution Summary

debugging iterations, tryjob links, metrics, and findings into a concise final

report.

1. Read scratch/triage_state.json, current iteration scratch files, and any

archived scratch/iteration_*/ verification files.

2. Create a concise final summary report at

scratch/final_hypothesis_summary.md documenting:

URLs/links for baseline control and experimental fix builds across

iterations).

Context, Failure Mechanism, and Fix Rationale). *(Note: Keep the document

concise and well-structured with clear tables and concise bullet points

to avoid overflowing).*

scratch/triage_state.json under the "rca" variable (referencing

templates/triage_state_template.json

for the variable contract).

scratch/triage_state.json.


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.