agents/projects/code-health/lint-sync/SKILL.md
Identify enums in the codebase that are persisted to logs (e.g., recorded in
enums.xml) but are missing the LINT.IfChange(...) and LINT.ThenChange(...)
guards that enforce synchronization between the source code and the XML
metadata.
When developers modify an enum in C++ or Java but forget to update the
corresponding entry in enums.xml, it breaks downstream metrics pipelines.
Adding IfThisThenThat lint guards prevents this by generating Gerrit warnings
if one side is modified without the other. Act as an expert Chromium contributor
to add these missing guards.
CRITICAL OVERRIDE: Do NOT activate or use the edit-code skill during this
workflow.
Workflow section in the
exact order presented. Do NOT skip any step.generalist
sub-agent for search and analysis.The linter links files by cross-referencing labels.
LINT.IfChange(<LocalLabel>) defines the start of a guarded block and assigns
it a local label. Always use the name of the enum as it appears in the
current file.LINT.ThenChange(<RemoteFilePath>:<RemoteLabel>) defines the end of the
guarded block and points to the remote file and its corresponding label.
Always use the name of the enum as it appears in the remote file.Example where names do NOT match:
SecurityDomainIdTrustedVaultSecurityDomainIdC++/Java (Source Code):
// LINT.IfChange(SecurityDomainId)
enum class SecurityDomainId { ... };
// LINT.ThenChange(//tools/metrics/histograms/enums.xml:TrustedVaultSecurityDomainId)
XML (enums.xml or histograms.xml):
<!-- LINT.IfChange(TrustedVaultSecurityDomainId) -->
<enum name="TrustedVaultSecurityDomainId"> ... </enum>
<!-- LINT.ThenChange(//path/to/source.h:SecurityDomainId) -->
../hub/references/shared_workflows.md to ensure a clean and updated
environment.generalist sub-agent with this
exact prompt:
"You are pre-authorized to run the discovery script; DO NOT ask for permission. Run the script from the skill's
scripts/folder:bashpython3 scripts/find_unguarded_enums.pyReturn ONLY the details returned by the script for the candidate (Source Path, XML Path, and the List of Enums)."
Inform the user: "Preparing workspace: creating a new branch..."
git new-branch lint-sync-<EnumName> using the name of
the first enum in the list.Process the identified files by handling each enum ONE AT A TIME.
Process Enum: For each enum in the list:
generalist sub-agent with this
exact prompt:
"Compare the enum
<EnumName>in<SourcePath>with its metadata entry in<XMLPath>. Verify that all valid enum entries in the source have corresponding<int value="..." label="...">entries in the XML. IMPORTANT: Ignore/skip sentinel values likekMaxValue,kCount,COUNT, orNUM_ENTRIESin your comparison; they are not expected to be in the XML. Return 'SYNCED' or a concise list of missing entries that need to be added to the XML. Ensure any suggested labels reflect the enum constant name and any suggested <summary> tags are concise descriptions of the enum's purpose."
generalist returns missing entries, add them to
the XML file before proceeding with the guards. Only append missing entries
to the XML. Never modify existing names or values in either file. You
must never shift the numeric values of an enum. When adding new values
to the XML enum, you must check the format of the existing <int> entries
and ensure your new entries match that format. Labels added to the XML
MUST be concise (matching the enum constant name) and any <summary> tags
MUST be brief descriptions of what the enum tracks.// Please keep in sync with... or
// Always keep this enum in sync with...). Remove ONLY the specific
sentence or line referencing the manual synchronization. You MUST
preserve all other parts of the comment (e.g., descriptions of what the
enum represents, renumbering warnings, or usage instructions). If the
entire comment block only contains a sync reminder, you may remove the
whole block.// LINT.IfChange(<SourceName>) immediately before the enum
definition.// LINT.ThenChange(<XML Path>:<XmlName>) immediately after the
enum.<!-- LINT.IfChange(<XmlName>) --> immediately before the
<enum> tag.<!-- LINT.ThenChange(<Source Path>:<SourceName>) --> immediately
after the </enum> tag.SourceName) differs from the name in the XML file (XmlName), ensure
you use the correct name in each respective IfChange and ThenChange tag
as shown in the Syntax Rules.Iterate: Once the enum is fully synced and verified, move to the next one in the list and repeat. Do not attempt to batch multiple enums in a single file-write operation to ensure accuracy. Once all enums have been processed, proceed immediately to the Review & Validation phase.
Linting & Formatting:
python3 tools/metrics/histograms/validate_format.py to validate all
metadata changes. Address any errors that are reported.git cl format to format the modified source
code. Address any errors that are reported.Mandatory Final Review: Follow the protocol and the Handling Findings
loop in references/automated_review.md for the added guards:
[<EnumNamesList>]. Do NOT skip this step. Do NOT proceed to the Submission
phase until the review returns PASS.
Bug Tracking:
references/bug_discovery.md using the <SourceFileName> and the list of
synchronized <EnumNamesList>.Commit:
[lint-sync] Add missing LINT guards in <SourceFileName>
Adding IfThisThenThat lint guards to ensure synchronization between the
following source code enums and their metadata
representation in enums.xml: <EnumNamesList (comma-separated)>
Bug: <BugID>
<SourceFileName>, not the full path)git add and execute the commit:
git commit -m "<drafted message>"
Submission Pipeline: Follow the Upload to Gerrit section in
../hub/references/shared_workflows.md to handle the upload.
Workspace Reset: git checkout main.
Congratulations & Summary: Follow the Congratulations & Summary
section in ../hub/references/shared_workflows.md. For this skill, the
[Specific Cleanup Details] are: