Patch validation
Patch validation is the preflight gate for the patch set. It checks that the ordered series names a complete set of usable patches, that build inputs have a valid shape, and that the full series still fits the selected Chromium source before build or release work starts.
Validation role
Validation protects the boundary between patch maintenance and patch assembly. It checks the inputs and their source context, while patch assembly uses the accepted series to change the source tree.
The gate covers four related risks:
- A listed patch is missing, unreadable, malformed, repeated, or left outside the series.
- Build metadata has an invalid order or schema.
- The series no longer matches the selected Chromium source.
- The patch command needed for later dry runs or application is not usable.
These checks are intentionally separate from the final build. A patch can be valid text but still target source that has moved. Early checks expose the input problem first, then source checks test the complete ordered change.
Validation stages
The stages move from repository-owned data to source-dependent behavior. Fix an earlier failure before using a later failure to diagnose a source conflict.
Patch inventory
The patch inventory treats patches/series as the ordered contract for the assembled set. It ignores blank lines and comments, then checks that each listed path exists and is a valid unified diff. It also reports repeated entries and patch files in the patch area that are not listed.
The series now places the core component-update patch at line 219, followed by its related core fixes. The page-zoom indicator remains in the UI group at line 388. These entries keep the changed behavior inside the same ordered contract that inventory and later assembly inspect. A path move, deletion, or reorder can therefore change both what assembly applies and when it applies it.
References: devutils/check_patch_files.py• L7-17 devutils/check_patch_files.py• L34-112 utils/_common.py• L123-137 patches/series• L168-222 patches/series• L381-395 patches/…/component-updates.patch• L1-222 patches/…/page-zoom-indicator.patch• L1-412
Configuration integrity
Configuration validation checks the static inputs that control source retrieval and build setup. It combines patch inventory checks with checks for unique and correctly ordered flags.gn keys and valid downloads.ini data.
This stage confirms that the tools can read their inputs. It does not prove that Chromium accepts the resulting build. That question belongs to source applicability, which must use the same source revision selected by the dependency and download data.
References: devutils/validate_config.py• L7-23 devutils/validate_config.py• L34-55 devutils/check_gn_flags.py• L28-57 devutils/check_downloads_ini.py• L28-40
Source applicability
Source applicability checks whether the complete ordered series can match the expected Chromium files. It models added files, verifies the context named by each hunk, and stops when a required line is absent or a source path cannot support the change.
The check can use a local source tree or obtain the files selected by the recorded Chromium and dependency data. CI runs it after the matching source inputs are prepared. It is a preflight check rather than the final patch application, so it finds source drift before build work changes the tree.
References: devutils/validate_patches.py• L7-11 devutils/validate_patches.py• L146-160 devutils/validate_patches.py• L318-383 devutils/validate_patches.py• L486-607 devutils/validate_patches.py• L623-705
Validation flow
The flow combines repository checks before it tests the series against a matching source tree. This diagram shows how a patch update becomes a build or release gate.
flowchart LR
A[Patch files and patches/series] --> B[Inventory checks]
C[flags.gn and downloads.ini] --> D[Configuration checks]
B --> E{Static checks pass?}
D --> E
E -- No --> F[Stop and report errors]
E -- Yes --> G[Matching Chromium source]
G --> H[Ordered applicability check]
H --> I{All hunks match?}
I -- No --> F
I -- Yes --> J[Build or release work may proceed]
The Chromium version is part of the applicability contract. A dependency or source-version change can invalidate a patch even when the patch file itself is unchanged.
References: .github/…/ci.yml• L45-57 .github/…/ci.yml• L59-103 devutils/validate_config.py• L34-55 devutils/validate_patches.py• L643-705
Tool boundary
Validation and patch application answer different questions. validate_patches.py asks whether patch meaning fits source content. utils/patches.py owns the later forward application and can reverse the series when needed. Both tools consume the series format, so a series change affects both the gate and assembly.
The patch executable is a second boundary. A configured PATCH_BIN takes priority when it resolves to a command or path. Otherwise the tools require a working patch command on PATH that can report its version before dry-run or application work begins.
References: utils/patches.py• L18-78 utils/patches.py• L81-110 utils/patches.py• L113-159 utils/patches.py• L200-243
Related knowledge pages
Validation results connect to the systems that consume the patch set:
- Patch assembly explains how the accepted series is selected and applied.
- Helium core browser behavior explains the browser behavior carried by the core patch group.
- Helium browser interface explains the UI behavior carried by the later interface patch groups.
- Helium settings experience explains the settings behavior carried by the settings patch group.
- Privacy and upstream patches explains the earlier privacy and upstream patch groups.
- Platform patch maintenance explains how platform-specific series changes interact with shared patches.
Change checklist
When these files or sections are changed, remember to consider these:
- A patch path, filename, or directory move requires the matching
patches/seriesentry to change while keeping its intended position. - A series reorder can change source dependencies between patches. Recheck the complete series against the matching Chromium source.
- A patch that changes its target source files can change the files needed by source applicability validation.
- A Chromium version, dependency record, or download metadata change can change source content. Rerun configuration and applicability checks.
- A
flags.gnchange must preserve unique keys and the order required by configuration validation. - A platform patch merge or split must leave each resulting series and patch directory pair complete.
- Related patches that add a service or user setting must remain in an order that keeps their feature gate, preference, settings surface, and consumer changes applicable to one source revision.
- A change to a producer, consumer, or build target contract must keep all related patches applicable to the same source revision.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A series entry names a missing or malformed patch | The static gate fails before source validation can give useful results. | Run patch inventory validation after every series or patch-file change. |
| A patch exists in a patch directory but is absent from the series | Assembly skips the change and inventory validation reports an unused patch. | Keep patches/series and patch directories synchronized. |
| A patch appears twice in the series | The same change is scheduled more than once and the gate fails. | Check for duplicate series entries. |
| A patch hunk no longer matches the selected Chromium source | Applicability validation stops and build work cannot proceed safely. | Validate the complete series against an unmodified source tree for the recorded version. |
| A later patch expects a source contract that an earlier patch does not provide | Ordered application fails even though every patch file is present. | Preserve the order of patches that add and consume shared types, flags, or interfaces. |
flags.gn contains a repeated or out-of-order key | Configuration validation fails before build work starts. | Keep flag keys unique and in the required order. |
| downloads.ini does not match its schema | Source retrieval or build input selection can be invalid. | Run combined configuration validation after download metadata changes. |
| The patch executable is missing or cannot report its version | Dry-run diagnostics and patch application cannot start. | Provide a working PATCH_BIN or patch command on PATH. |
Key files
| File | Why to read it |
|---|---|
patches/series | Defines the ordered patch contract consumed by inventory, applicability, and assembly. |
| devutils/check_patch_files.py | Defines presence, readability, unused-entry, and duplicate-entry checks. |
| devutils/validate_config.py | Combines patch, GN flag, and download metadata checks into the static gate. |
| devutils/validate_patches.py | Defines the source-based applicability check and its local or remote source modes. |
| utils/_common.py | Defines how series files treat comments and blank lines. |
| utils/patches.py | Defines the patch executable check, dry run, and forward or reverse application boundary. |
| .github/…/ci.yml | Shows where configuration and source applicability validation run in CI. |
flags.gn | Provides the GN flag data whose order and uniqueness are checked. |
| downloads.ini | Provides download metadata whose schema is checked before source retrieval. |