---
quick_id: 260517-wpf
slug: fix-changelog-md-ordering-and-tighten-de
type: execute
files_modified:
  - CHANGELOG.md
  - docs/DEPLOY.ps1
autonomous: true
---

# Quick Task 260517-wpf: Fix CHANGELOG ordering + tighten DEPLOY.ps1 curation gate

## Objective

v1.7.1 milestone audit flagged that CHANGELOG.md entries `## [1.10.11]`, `## [1.10.12]`, `## [1.10.13]` are appended at the BOTTOM (lines 271/282/297) after the oldest entry `## [1.5.4]` (line 267), breaking newest-first Keep-a-Changelog convention. Root cause: `DEPLOY.ps1` curation-gate stub-append uses `TrimEnd + stub` (line 293-294), so every TODO stub lands at end-of-file.

Two fixes, one commit:

1. **CHANGELOG.md** — move 1.10.11, 1.10.12, 1.10.13 entries to top (between line 6 header and current line 7 `## [1.10.10]`). Order: 1.10.13 newest, then 12, then 11, then 10. Also repair UTF-8 mojibake on line 281 (`Ã¢â‚¬â€` → `—`) and line 292 (`â€` → `—`).
2. **DEPLOY.ps1** — change curation-gate stub insertion from append-at-bottom to insert-at-top. Find the FIRST `## [` H2 in CHANGELOG.md; insert the stub immediately above it.

## Task 1: CHANGELOG.md reorder + mojibake fix

- Read current 1.10.11/12/13 bodies (lines 271–end).
- Reinsert them between header (line 6) and `## [1.10.10]` (line 7), in order: 1.10.13, 1.10.12, 1.10.11 (newest-first).
- Delete the trailing copies at lines 271–end.
- Replace `Ã¢â‚¬â€` and `â€` with `—` (em-dash).
- Verify with `grep -n "^## \[" CHANGELOG.md` — output should show monotonically descending semver from line 7 down.

## Task 2: DEPLOY.ps1 insert-at-top

Current (lines 284-294):
```powershell
$h2Header = "## [$NewVersion]"
$ChangelogRawForH2 = Get-Content $ChangelogPath -Raw
if ($ChangelogRawForH2 -notmatch [regex]::Escape($h2Header)) {
    if ($DryRun) {
        ...
    } else {
        $today = Get-Date -Format 'yyyy-MM-dd'
        $stub = "`n## [$NewVersion] - $today`n`n- TODO: changelog entry`n"
        $newRaw = $ChangelogRawForH2.TrimEnd("`r","`n") + $stub
        [System.IO.File]::WriteAllText($ChangelogPath, $newRaw)
        ...
```

New:
- Find first `## [` H2 line via regex `(?m)^## \[`.
- If found: split file at that index; new content = `prefix + stub + "`n" + h2-and-after`.
- If not found (first ever entry): keep current append behavior as fallback.
- Stub block unchanged.

## Done

- `grep -n "^## \[" CHANGELOG.md` shows 1.10.13 / 1.10.12 / 1.10.11 / 1.10.10 / 1.10.9 ... at the top.
- No mojibake remains in CHANGELOG.md.
- `Select-String '## \[' docs/DEPLOY.ps1` shows the new insert-at-top branch.
- Manual sanity: dry-run DEPLOY.ps1 with a fake next-version that lacks an H2 → would insert stub at TOP not bottom (verified by reading the modified code path; no actual run needed since DEPLOY.ps1 has real side effects).
