envoy.code.check: per-entry changelog filename and content validation (PR 4)#4502
Draft
Copilot wants to merge 2 commits into
Draft
envoy.code.check: per-entry changelog filename and content validation (PR 4)#4502Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
✅ Deploy Preview for nifty-bassi-e26446 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Agent-Logs-Url: https://github.com/envoyproxy/toolshed/sessions/260f7319-48f2-479a-8d53-f401c4abddd6 Co-authored-by: phlax <454682+phlax@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add filename and section validation for per-entry changelog layout
envoy.code.check: per-entry changelog filename and content validation (PR 4)
May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds validation for the per-entry changelog layout (
changelogs/current/<section>/<area>__<slug>.rst) toenvoy.code.check. Only runs on the current changelog; historical<version>.yamlfiles are unaffected.New methods on
AChangelogChangesCheckercheck_entry_filename(path)— validates in order: section name ∈self.sections, extension is.rst, stem contains exactly one__, both area and slug are non-emptycheck_entry_content(path)— rejects empty or whitespace-only filescheck_entry_files(paths)— runs both checks over a list of paths, returns all errors as a tuple (for executor dispatch)Wired into
AChangelogStatusentry_dirproperty — resolves the per-entry directory viachangelog_path(version).with_suffix(""); returnsNonefor non-current changelogscheck_entry_files()— globs*/*.rstunderentry_dir, dispatcheschecker.check_entry_filesviaproject.executeerrors— extended toawait self.check_entry_files()alongside existing checksInterface
IChangelogChangesCheckergains the three new abstract methods so mypy remains clean.Constants
Tests
14 new test functions in
test_abstract_changelog.pycovering all filename/content validation paths;test_changelogstatus_errorsupdated to includecheck_entry_files.abstract/changelog.pyremains at 100% coverage.Original prompt
Toolshed PR 4 — Per-entry filename and section validation in
envoy.code.checkThis is the fourth PR in the implementation plan for per-entry changelog layout support (see issue #4498, plan at
plans/per-entry-changelog-4498.md, investigation PR #4499). It can be developed in parallel with PRs 1–3; it lives in a different package (envoy.code.check) and only depends on the relaxed typing from PR 1 and the constants introduced in PR 2.Background
Envoy is migrating from a single monolithic
changelogs/current.yamlto a per-entry layout:Validation rules:
<section>: must be a key inchangelogs/sections.yaml(the existingself.sectionsset on the checker already provides this).<area>: must not contain__. May contain-and_.<slug>: must not contain__. May contain-and_.__between area and slug..rst.The checker should surface clear, actionable errors when these rules are violated.
Required changes
Primary file:
py/envoy.code.check/envoy/code/check/abstract/changelog.py1. Add
check_entry_filenametoAChangelogChangesCheckerAround the existing
check_entry()(lines ~40–58) andcheck_section()(lines ~60–73), add:Behaviour — return
Noneon success, or a single human-readable error string describing the first failure found:path.parent.namemust be inself.sections(the existing set sourced fromsections.yaml). If not, return an error naming the file and the invalid section, and listing valid sections (or hinting at the source of truth).path.suffixmust be.rst. If not, return an error.path.stemmust contain exactly one__. If zero or more than one, return an error naming the file and explaining the<area>__<slug>rule.area, slug = path.stem.split("__", 1), bothareaandslugmust be non-empty. If either is empty, return an error.Use the existing constants from
envoy.base.utilsif/when PR 2 lands them (ENTRY_SEPARATOR,CHANGELOG_ENTRY_GLOB,CHANGELOG_CURRENT_DIR_PATH). If PR 2 hasn't merged yet, define local constants matching those names/values and add a TODO comment to swap to the imports once PR 2 lands. Do not import from a not-yet-existing module path; prefer a small local fallback.2. Add a content non-emptiness check
Either:
check_entry()(lines ~40–58) so it also flags empty / whitespace-only RST bodies for per-entry files, orcheck_entry_content(self, path: pathlib.Path) -> str | Nonethat returns an error if the file is empty or whitespace-only.Pick whichever fits the existing style of the class better. Either way, an empty
.rstentry must produce an error.3. Wire the new checks into
AChangelogStatus/AChangelogCheckAChangelogStatus(lines ~99–232) orchestrates per-version/date/section checks. Add iteration over the per-entry files of the current changelog (the per-entry directory) so thatcheck_entry_filenameand the content non-emptiness check run on every*.rstunderchangelogs/current/<section>/.AChangelogCheck(lines ~235–267) iterates over all changelogs. Make sure the new checks are surfaced via the same error-collection mechanism the existing checks use (look at howcheck_entry/check_sectionresults are collected and reported — match that pattern exactly so CI output stays consistent).<version>.yamlfiles must not be touched — they continue to be validated by the existing checks.4. Treat
duplicate_currentandis_pendingcorrectly with the slimcurrent.yamlThe plan flags these as open considerations, but the safe behaviour for this PR is:
duplicate_current(lines ~132–137): currently checksself.project.changelogs.changelog_path(self.version).exists(). With the per-entry layout, the slimcurrent.yamlstill exists alongside the directory, so the existing check should still work without modification. If you find it would now produce a false positive, leave the logic as-is and add a TODO comment referencing the plan's open question; do not change behaviour as part of this PR.is_pendingcheck (lines ~250–254 ofenvoy.base.utils/.../changelog.py): out of scope for this PR — leave it alone.Tests
Add unit tests in
py/envoy.code.check/tests/test_abstract_changelog.pycovering:This pull request was created from Copilot chat.