Enable Check Includes Strict enable-check-includes-strict

Enable and migrate Chromium targets and directories to check_includes_strict = true, diagnosing and resolving header include violations as part of the check_includes_strict LSC.

Use it when adding directories to the allowlist, enabling strict header checks on targets, or resolving CHECK_INCLUDES_STRICT_UNTRIAGED targets.

Works in Claude, ChatGPT, Codex and more
Our test
—
not tested yet
GitHub stars
26k
chromium/chromium
Added by
0
members
Updated
Dec 6
commit 8cf236c
Content
13 files
2 scripts · 30 KB
License
BSD 3-Clause
free to use

What our test found

Not tested yet. Our model tries every skill on a realistic request and scores the result, the most popular skills first. Until then, the safety checks on the right still apply.

View on GitHub ↗
name: enable-check-includes-strict
description: >-
  Enable and migrate Chromium targets and directories to check_includes_strict =
  true, diagnosing and resolving header include violations as part of the
  check_includes_strict LSC. Use when adding directories to the allowlist,
  enabling strict header checks on targets, or resolving
  CHECK_INCLUDES_STRICT_UNTRIAGED targets.

Enable check_includes_strict

This skill guides the process of enabling check_includes_strict = true across Chromium targets and directories, following the Enable check_includes_strict by default LSC (go/check-includes-strict-lsc, tracking bug: crbug.com/555455099).

check_includes_strict is a GN target configuration that prevents including headers declared in transitive dependencies unless they are forwarded through explicit public_deps.

Note that all VCS operations have been written with jj, but that if jj is unavailable, you may instead run equivalent git commands.

Commit message

The following will be added at the end of all commit messages created for check_includes_strict.

This is part of the check_includes_strict LSC (https://docs.google.com/document/d/1zYUC_zuFrZozo9ogFHcf0Rzkiw9W7RVnaY-1fzfQ0AM/edit?usp=sharing)

Bug: 555455099

Preparing checkout

Symlink .gclient (next to src/) to src/agents/skills/enable-check-includes-strict/args/.gclient and run gclient sync.

The add_exceptions.py script mentioned later will create the output directories on-demand.

Phase 1: Reject new failures

For each glob entry in the allowlist (eg. //base/*), we will

Start working

jj new $BASE_COMMIT -m $MESSAGE ($BASE_COMMIT is probably main@origin).

Message will be:

[strict-deps] Make $ENTRY exception fine-grained

This is part of the check_includes_strict LSC (https://docs.google.com/document/d/1zYUC_zuFrZozo9ogFHcf0Rzkiw9W7RVnaY-1fzfQ0AM/edit?usp=sharing)

Bug: 555455099
Populate existing exceptions
  • Remove $ENTRY from
  • Run python3 agents/skills/enable-check-includes-strict/add_exceptions.py
  • If it exits with status 2 (exceptions applied), run it again to verify it passes now (exit 0)
Upload commit
  • Run jj fix && jj gerrit upload --reviewer $reviewer --label=Auto-Submit --label=Commit-Queue, where reviewer is assigned randomly between:
  • jwata@google.com
  • rysk@google.com
  • tikuta@google.com

We intentionally do not use Mega-CQ for a few reasons:

  • This will require submitting hundreds of commits, and running mega-CQ for all of them would be prohibitively time-consuming and consume a lot of resources.
  • The longer these commits take to land, the more likely we are to end up with race conditions as mentioned below.
  • These CLs are trivial to identify as the cause of a failure and revert
Handling potential failures

For CQ failures, you first need to identify whether the failure was a flake or actually caused by this CL. But assuming it was caused by this CL, treat it the same as a CL being reverted.

Roughly speaking, we can categorise failures into three categories (they can also fit multiple)

Race conditions

Someone else tries to add a commit that breaks check includes strict within //foo/bar:baz right as you shard //foo/* into individual entries.

In this case, rather than trying to keep up with the race, we simply assume that this is a high-frequency update directory, and thus add //foo/bar/* to the allowlist (in sorted order). Note that this can end up with an entry such as the following, where we have both a glob and an individual entry matching something. Such a case is perfectly fine:

{
  includer = "//foo/bar/*"
},
{
  includer = "//foo/bar:blah"
  included = "//:included"
},

Then we can retry uploading and submitting it (or for a revert, creating a reland in gerrit, download it, edit it, then re-upload it)

Missed check-generated failures

We have yet to come up with a way to actually solve this reliably other than running autoninja -C out/$name <targets> && gn check --check-generated --error-limit=-1 out/$name. It's inherently very difficult to check this in a computationally cheap way. Depending on how frequently (and in what way) this comes up, we will decide to either check this in add_exceptions.py or just minimize occurrences of it.

Insufficient coverage

Our set of args.gn was insufficient to catch the failures. In this case, we will try to come up with an args.gn that can successfully reproduce the failure locally, and modify the set of configurations so that it is now covered.

Phase 2: Fix failures

Start working
  • jj new $BASE_COMMIT ($BASE_COMMIT is probably main@origin).
Create empty commit
  • jj commit -m $COMMIT_MSG (yes, this commit is intentionally empty, we'll squash into it later)
  • The message's first line should be Fix violations in making //base/* use check_includes_strict
Remove entries from allowlist
  • Edit and remove the exceptions for that directory from check_includes_strict_exceptions
  • jj commit -m $COMMIT_MSG
  • The message's first line will be Enable check_includes_strict for //base/*
Fix failures
  • Run gn check --fix --error-limit=-1 $OUT_DIR on each output directory
  • Run it iteratively until there are no failures for that output directory, then move on to the next output directory.
  • It may produce errors that require manual intervention or decisions to be made. If there is an obviously correct way to do it, do it. Otherwise, ask what to do. While you are waiting for an answer, continue working.
  • Note that if gn suggests to put it behind a condition, we should ALWAYS do so.
  • For simple conditions, either add it to an existing block with deps/public_deps in it, or create a new block with either deps or public_deps as required.
  • For more complex conditions, you are allowed to merge it into the existing conditional where the sources are added. You may need to add deps = [] above the conditional.
  • Do not inspect .cc files for include errors: GN's suggestion output already gives you the destination target, the exact condition, and the dependency to add.
  • Run jj diff and:
  • Find any TODOs added and resolve them
  • Perform a once-over to verify that the changes look reasonable
  • Downstream churn across the repo is expected. For example, when enabling check_includes_strict on //base, downstream targets across the entire repo may find that they need to explicitly declare a dependency on //third_party/abseil-cpp:absl, which was previously implicitly allowed through //base.
  • Run jj squash --to @--
  • Once it passes for all output directories, run it once more for each output directory without --fix to verify that the fixes for the later output directories did not break the former ones.
Upload change
  • Run jj fix
  • Run jj gerrit upload --label=Owners-Override --label=Commit-Queue