Skip to content

feat(release/auto-changelog): add clean-room changelog proofreader - #301

Merged
HowardBraham merged 1 commit into
merge-previous-releasesfrom
clean-room-proofreader
Oct 28, 2026
Merged

HowardBraham merged 1 commit into
merge-previous-releasesfrom
clean-room-proofreader

Conversation

@HowardBraham

@HowardBraham HowardBraham commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

References

Explanation

Current state

The release changelog generator (auto-changelog) produces a ## [version] section with an ### Uncategorized bucket, terse or implementation-level wording, and commits that were only labeled. Someone has to clean it up by hand before release.

Solution

A new clean-release-changelog.mts proofreads that section with an LLM, and writes it back only when the result passes validation. It does the following:

  • It gives the LLM only the section and each PR's title and body as evidence. Local git log evidence is used first, with GitHub as a fallback.
  • It keeps the generator's categories as input, removes ### Uncategorized, and rewrites entries in concise, user-facing, past tense. The prompt is .github/prompts/auto-changelog-clean-room.md.
  • It splits the section into chunks per category. It throws if one PR has two differing entries, so nothing is silently dropped.
  • It validates the rewrite before writing. Every entry must end with its PR reference. The set of PR numbers must match the input exactly, with none added, removed or invented. PR references are read from the first line of each entry the same way auto-changelog parses them.
  • If validation fails, it retries the request before giving up.
  • A model failure, a rejected key, a timeout, or a response that fails validation leaves the changelog untouched and is recorded in a report. It never fails the release.

Other changes

  • Shared helpers: release-section.mts, shared/environment.mts, shared/report.mts and shared/retry.mts hold the section extract/replace, PR parsing, environment, report and retry code. merge-previous-release-changelog.mts now imports the section helpers instead of repeating them. The oldest section now ends before the link references instead of swallowing them.
  • tsconfig: it allows .ts/.mts import extensions, which Node's native TypeScript support requires, and adds the DOM lib for fetch and AbortController.
  • apply-changes.ts: the DOM lib makes Document a global, so segment-schema-draft-pr/apply-changes.ts imports yaml's Document as YamlDocument.
  • ESLint: .github/scripts/**/*.mts are CLI scripts, so an override lets them read process.env.
  • Tests: clean-release-changelog.test.mts covers chunking, validation, evidence, retry and timeouts, and runs the script end to end in a subprocess with a throwaway git repo. release-section.test.mts and retry.test.mts cover the helpers.

Testing

  • Local: tsc, lint:eslint and node --test pass.
  • Real model: ran against a real generated metamask-extension 13.54.0/13.55.0 section (29 entries). Four of four runs passed validation after the retry change.
  • Not tested: nothing wires this script into a workflow in this PR. The updater PR does that. Jest has 3 failures in src/segment-schema-draft-pr/apply-changes.test.ts, which also fail on main.

Note

Medium Risk
Touches release changelog content via external LLM and GitHub/git evidence, but writes only after validation and preserves the file on failure; credential scrubbing for child processes reduces leak risk.

Overview
Adds an LLM-based clean-room proofreader for generated ## [version] changelog sections: clean-release-changelog.mts chunks entries, gathers PR evidence (local mainline squash commits first, then gh api), calls LiteLLM with .github/prompts/auto-changelog-clean-room.md, and only replaces the section when output passes strict validation (Keep a Changelog categories, no Uncategorized, exact PR reference set). Failures write a JSON report and leave CHANGELOG.md unchanged.

Shared release tooling: new release-section.mts (extract/replace sections, PR parsing) plus shared/environment.mts, report.mts, and retry.mts; merge-previous-release-changelog.mts now uses those helpers and stops oldest sections at link references.

Build/lint: tsconfig includes .github/scripts/**/*.mts, enables allowImportingTsExtensions and DOM lib for fetch; ESLint allows process.env on CLI scripts; apply-changes.ts aliases yaml Document as YamlDocument after DOM lib added.

Tests: large coverage for chunking, validation, evidence, retries, and end-to-end subprocess runs; shared git-test-environment.mts for git fixtures.

Workflow integration is not in this PR (script is standalone).

Reviewed by Cursor Bugbot for commit b8974d5. Bugbot is set up for automated code reviews on this repo. Configure here.

@mcmire mcmire left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not reviewed changes to scripts, but as far as the risk to other repos goes, this looks pretty safe to me. I don't believe other repos use the merge-previous-releases action (or at least, I don't recognize it).

Adds a script that proofreads the generated `## [version]` changelog section
with a model, given only each PR's title and body as evidence, and writes the
result back only if it passes validation. A model failure, a rejected key, or
a response that fails validation leaves the changelog untouched and is recorded
in a report.

The section helpers shared with `merge-previous-release-changelog.mts` live in
`release-section.mts`. The tsconfig allows `.ts`/`.mts` import extensions, which
Node's native TypeScript support requires, and adds the DOM lib for `fetch` and
`AbortController`. The DOM lib makes `Document` a global, so
`segment-schema-draft-pr/apply-changes.ts` imports yaml's `Document` as
`YamlDocument` to avoid shadowing it. `.github/scripts/**/*.mts` are CLI
scripts, so they may read `process.env`.
@HowardBraham
HowardBraham force-pushed the clean-room-proofreader branch from b8974d5 to d76f1b4 Compare October 27, 2026 21:14

@mcmire mcmire left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@HowardBraham
HowardBraham merged commit 42900bf into main Oct 28, 2026
10 checks passed
@HowardBraham
HowardBraham deleted the clean-room-proofreader branch October 28, 2026 19:00
JadeCong pushed a commit to CloudEngineHub/metamask-extension that referenced this pull request Oct 29, 2026
…MetaMask#47463)

## **Description**

This is the very last step in a chain of PRs to turn on fully-autonomous
CHANGELOG generation in Extension.

## **Changelog**

CHANGELOG entry: null

## **Related issues**

### Previous PRs in the chain

#### release-tools/auto-changelog
MetaMask/release-tools#127
MetaMask/release-tools#130

#### github-tools
MetaMask/github-tools#300
MetaMask/github-tools#301
MetaMask/github-tools#303

<!--## **Manual testing steps**
## **Screenshots/Recordings**
## **Pre-merge author checklist**
## **Pre-merge reviewer checklist**-->

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Workflow-only change that adds a CI secret env var and removes an
action input; no runtime extension code or user-facing behavior changes.
> 
> **Overview**
> Turns on the **AI changelog proofreader** for release changelog
automation by passing **`AI_ANALYZER_LITELLM_KEY`** into the
`update-release-changelog` GitHub Action (same LiteLLM secret pattern as
other AI workflows).
> 
> Also **drops the explicit `previous-version-ref: 'null'`** input so
previous-version resolution is handled by the updated action rather than
being hard-coded in this repo.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
c801241. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants