Add per-entry RST directory reader to AChangelog (PR 2)#4501
Draft
Copilot wants to merge 2 commits into
Draft
Conversation
✅ Deploy Preview for nifty-bassi-e26446 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
- Add CHANGELOG_CURRENT_DIR_PATH, CHANGELOG_ENTRY_GLOB, ENTRY_SEPARATOR constants - Add AChangelog.get_data_from_entries() classmethod that reads date from current.yaml and walks <section>/<area>__<slug>.rst entries - Add unit tests covering happy path, arbitrary sections, missing/multiple separators, missing yaml, empty dir, and stable ordering Agent-Logs-Url: https://github.com/envoyproxy/toolshed/sessions/6f4aed80-8caf-4e9e-9155-6446a7a7d9bd Co-authored-by: phlax <454682+phlax@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add per-entry RST directory reader in AChangelog
Add per-entry RST directory reader to AChangelog (PR 2)
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.
Part of the migration from a monolithic
changelogs/current.yamlto a per-entry layout (changelogs/current/<section>/<area>__<slug>.rst) that eliminates merge conflicts. This PR is purely additive — no existing methods are modified.New constants
New classmethod:
AChangelog.get_data_from_entriesdatefromyaml_pathvia the sameutils.from_yaml/ error path asget_data()entry_dirwith*/*.rst;path.parent.name→ section,path.stem→area__slug__; raisesChangelogParseErrornaming the offending file otherwiseChangelogDictsections.yamlhere — that's deferred to PR 4Tests
Seven integration tests (using
tmp_path) cover: happy path across multiple sections, arbitrary/unknown section names (accepted), missing separator, multiple separators, missingcurrent.yaml, empty entry directory, and stable ordering across repeated calls.Original prompt
Toolshed PR 2 — Per-entry RST directory reader in
AChangelogThis is the second 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). PR 1 (typing relaxation) is in flight in parallel — see #4498/#4499 for the relaxedChangelogSourceDict/ChangelogChangeSectionsDictshape; rebase if/when PR 1 lands first.Background
Envoy is migrating from a single monolithic
changelogs/current.yamlto a per-entry layout to eliminate constant merge conflicts:<section>: must match a key inchangelogs/sections.yaml(e.g.bug_fixes,new_features,behavior_changes, …).<area>: arbitrary low-cardinality identifier (e.g.oauth2,jwt_authn); must not contain__.<slug>: arbitrary short description; must not contain__.__) cleanly splits area from slug; both sides may use-and_otherwise.Example:
changelogs/current/bug_fixes/oauth2__foo_fixed-critical-vuln.rstThe slim
current.yamlcontinues to exist but holds onlydate: Pending(or a real date once stamped bywrite_date).Required changes
File:
py/envoy.base.utils/envoy/base/utils/abstract/project/changelog.py1. Add module-level constants (around lines 27–34, alongside existing
CHANGELOG_CURRENT_PATH)Use existing naming conventions / module style.
2. Add new classmethod
AChangelog.get_data_from_entriesSignature (adjust to match existing style —
pathlib.Pathis already used in the file):Behaviour:
datefromyaml_path— the slimcurrent.yamlthat still holdsdate: Pending(or a stamped date). Use the same YAML loader pattern as the existingget_data()(line ~135) so quirks (e.g. envoy.base.utils' yaml utils) are preserved. If the file is missing, raise the same kind of errorget_data()raises today.entry_dirusingCHANGELOG_ENTRY_GLOB(i.e. one subdirectory per section,*.rstfiles within). Usepathlib.Path.globorrglobconsistently with the rest of the codebase..rstfile, parse and validate:path.parent.nameis the section name (no validation againstsections.yamlhere — that's PR 4's checker job; this method just groups by parent dir name).path.stemmust contain exactly oneENTRY_SEPARATOR(__). Split intoarea, slug = path.stem.split(ENTRY_SEPARATOR, 1). If the count of__inpath.stemis not exactly 1, raise a clearValueError(or the existing project exception type — check whatget_data()raises) naming the offending file.ChangelogChangeDictfor each entry. Inspect the existingChangelogChangeDictdefinition intyping.pyto populate the right keys (typicallyarea+changetext; if the dict has more keys today they become absent/empty per the new layout — only populate what's required and keep optional keys absent).{section_name: [ChangelogChangeDict, ...]}. Sort entries within a section deterministically (e.g. by(area, slug)) so output is stable across runs.ChangelogDictwith thedatefrom step 1 plus the section groupings. Cast toChangelogDict/ChangelogSourceDictasget_data()does today.3. Do NOT modify the existing
get_data()ordataproperty in this PRget_data()(lines ~133–149) and thedataasync property (lines ~163–168) stay untouched.write_version/write_current/write_date/changes_for_commit). This PR is purely additive.4. Tests
Add unit tests in
py/envoy.base.utils/tests/test_abstract_project_changelogs.pycovering:current.yaml(date: Pending) plus a few<section>/<area>__<slug>.rstfiles across multiple sections → returns a correctChangelogDict.weird_section/foo__bar.rst) — should be accepted by this reader (validation deferred to PR 4) and grouped under that key.__in stem (e.g.bug_fixes/no_separator.rst) → raises with a message that names the file.__in stem (e.g.bug_fixes/a__b__c.rst) → raises (the spec says exactly one separator; both area and slug must not contain__).current.yaml→ raises in the same way the existingget_data()does for a missing file.This pull request was created from Copilot chat.