From 8239bd36522774d68b1d26447de8c01b92c7ca2e Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Thu, 19 Nov 2026 15:55:19 +0100 Subject: [PATCH 1/6] :bug: Upload large imports from the kept File on the main thread (#13183) Chrome fails Continue on a large .penpot when the worker re-fetches the blob: URL. Keep the dropped File on the entry and upload it from the main thread instead. Closes #13165 AI-assisted-by: composer --- frontend/src/app/main/data/imports.cljs | 124 ++++++++++++++++++ .../src/app/main/ui/dashboard/import.cljs | 51 ++++--- .../src/app/main/ui/onboarding/templates.cljs | 4 +- frontend/src/app/worker/import.cljs | 103 --------------- .../frontend_tests/data/imports_test.cljs | 76 +++++++++++ frontend/test/frontend_tests/runner.cljs | 2 + 6 files changed, 236 insertions(+), 124 deletions(-) create mode 100644 frontend/src/app/main/data/imports.cljs create mode 100644 frontend/test/frontend_tests/data/imports_test.cljs diff --git a/frontend/src/app/main/data/imports.cljs b/frontend/src/app/main/data/imports.cljs new file mode 100644 index 0000000000..cbfac91143 --- /dev/null +++ b/frontend/src/app/main/data/imports.cljs @@ -0,0 +1,124 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) KALEIDOS SUBSIDIARY SL + +(ns app.main.data.imports + "Upload and import-binfile on the main thread from the dropped File." + (:require + [app.common.logging :as log] + [app.main.data.uploads :as uploads] + [app.main.repo :as rp] + [app.util.i18n :as i18n :refer [tr]] + [app.util.sse :as sse] + [beicon.v2.core :as rx] + [cuerdas.core :as str])) + +(log/set-level! :warn) + +(defn- import-cause-message + [cause default-msg] + (let [data (ex-data cause) + hint (some-> data :hint str/trim) + explain (some-> data :explain str/trim)] + (cond + (not (str/blank? hint)) hint + (not (str/blank? explain)) explain + :else + (let [msg (some-> (ex-message cause) str/trim)] + (if (or (str/blank? msg) (= msg "stream exception")) + default-msg + msg))))) + +(defn- import-blob + [blob {:keys [name version project-id]}] + (->> (uploads/upload-blob-chunked blob) + (rx/mapcat + (fn [{:keys [session-id]}] + (rp/cmd! ::sse/import-binfile + {:name name + :upload-id session-id + :version version + :project-id project-id}))) + (rx/tap (fn [event] + (let [payload (sse/get-payload event) + type (sse/get-type event)] + (if (= type "progress") + (log/dbg :hint "import-binfile: progress" + :section (:section payload) + :name (:name payload)) + (log/dbg :hint "import-binfile: end"))))) + (rx/filter sse/end-of-stream?))) + +(defn- entry-blob + [entry] + (or (:blob entry) + (throw (ex-info "import entry is missing the dropped file" + {:type :internal + :code :missing-import-blob + :uri (:uri entry) + :name (:name entry)})))) + +(defn import-files + "Upload and import analyzed entries. Emits per-file `:finish`/`:error`, + then `{:libraries-resolution …}`." + [{:keys [project-id files]}] + (let [binfile-v1 (filter #(= :binfile-v1 (:type %)) files) + binfile-v3 (filter #(= :binfile-v3 (:type %)) files) + resolutions (volatile! {})] + + (rx/merge + (->> (rx/from binfile-v1) + (rx/merge-map + (fn [data] + (->> (import-blob (entry-blob data) + {:name (str/replace (:name data) #".penpot$" "") + :version 1 + :project-id project-id}) + (rx/map (fn [_] + {:status :finish + :file-id (:file-id data)})) + (rx/catch + (fn [cause] + (log/error :hint "unexpected error on import process" + :project-id project-id + :cause cause) + (rx/of {:status :error + :error (import-cause-message cause (tr "labels.error")) + :file-id (:file-id data)}))))))) + + (rx/concat + (->> (rx/from binfile-v3) + (rx/reduce (fn [result file] + (update result (:uri file) (fnil conj []) file)) + {}) + (rx/mapcat identity) + (rx/merge-map + (fn [[_uri entries]] + (->> (import-blob (entry-blob (first entries)) + {:name (-> entries first :name) + :version 3 + :project-id project-id}) + (rx/mapcat (fn [message] + (let [{:keys [resolution]} (sse/get-payload message)] + (when (seq resolution) + (vswap! resolutions merge resolution)) + (->> (rx/from entries) + (rx/map (fn [entry] + {:status :finish + :file-id (:file-id entry)})))))) + (rx/catch (fn [cause] + (log/error :hint "import-binfile: unexpected error on importing" + :project-id project-id + ::log/sync? true + :cause cause) + (let [err (import-cause-message cause (tr "labels.error"))] + (->> (rx/from entries) + (rx/map (fn [entry] + {:status :error + :error err + :file-id (:file-id entry)})))))))))) + (->> (rx/defer #(rx/of @resolutions)) + (rx/map (fn [resolutions] + {:libraries-resolution resolutions}))))))) diff --git a/frontend/src/app/main/ui/dashboard/import.cljs b/frontend/src/app/main/ui/dashboard/import.cljs index dd459da077..ea6c2f4ba7 100644 --- a/frontend/src/app/main/ui/dashboard/import.cljs +++ b/frontend/src/app/main/ui/dashboard/import.cljs @@ -13,6 +13,7 @@ [app.common.logging :as log] [app.main.data.dashboard :as dd] [app.main.data.event :as ev] + [app.main.data.imports :as imports] [app.main.data.modal :as modal] [app.main.data.notifications :as ntf] [app.main.repo :as rp] @@ -50,7 +51,8 @@ (let [entries (->> entries (mapv (fn [file] {:name (.-name file) - :uri (wapi/create-uri file)})) + :uri (wapi/create-uri file) + :blob file})) (not-empty))] (when entries (st/emit! (modal/show @@ -87,13 +89,25 @@ (assoc :deleted true))) entries)) +(defn- blobs-by-uri + [entries] + (into {} + (keep (fn [{:keys [uri blob]}] + (when (and uri blob) [uri blob]))) + entries)) + (defn- update-with-analyze-result [entries {:keys [file-id status] :as updated}] - (let [entries (filterv (comp uuid? :file-id) entries) + ;; Analyze replies have no :blob (transit); copy it back by :uri. + (let [blobs (blobs-by-uri entries) + entries (filterv (comp uuid? :file-id) entries) status (case status :success :import-ready :error :analyze-error) - updated (assoc updated :status status)] + updated (-> updated + (assoc :status status) + (cond-> (contains? blobs (:uri updated)) + (assoc :blob (get blobs (:uri updated)))))] (if (some #(= file-id (:file-id %)) entries) (mapv (fn [entry] (if (= (:file-id entry) file-id) @@ -180,10 +194,11 @@ (defn- analyze-entries [state entries] - (let [features (get @st/state :features)] + (let [features (get @st/state :features) + files (mapv #(dissoc % :blob) entries)] (->> (mw/ask-many! {:cmd :analyze-import - :files entries + :files files :features features}) (rx/mapcat #(rx/delay emit-delay (rx/of %))) (rx/filter some?) @@ -199,21 +214,17 @@ (st/emit! (ev/event {::ev/name "import-files" :num-files (count entries)})) - (let [features (get @st/state :features)] - (->> (mw/ask-many! - {:cmd :import-files - :project-id project-id - :files entries - :features features}) - (rx/filter some?) - (rx/subs! - (fn [message] - ;; Capture library-resolution data if present (same for all - ;; entries from the same zip, so first one wins) - (if-let [resolution (-> (:libraries-resolution message) - (not-empty))] - (reset! library-resolution-data* resolution) - (swap! state update-entry-status message))))))) + (->> (imports/import-files {:project-id project-id + :files entries}) + (rx/filter some?) + (rx/subs! + (fn [message] + ;; Capture library-resolution data if present (same for all + ;; entries from the same zip, so first one wins) + (if-let [resolution (-> (:libraries-resolution message) + (not-empty))] + (reset! library-resolution-data* resolution) + (swap! state update-entry-status message)))))) (mf/defc import-entry* {::mf/memo true diff --git a/frontend/src/app/main/ui/onboarding/templates.cljs b/frontend/src/app/main/ui/onboarding/templates.cljs index 5ef15a2546..77943cda8a 100644 --- a/frontend/src/app/main/ui/onboarding/templates.cljs +++ b/frontend/src/app/main/ui/onboarding/templates.cljs @@ -40,7 +40,9 @@ (reset! downloading? true) (->> (http/send! {:method :get :uri link :response-type :blob :mode :no-cors}) (rx/subs! (fn [{:keys [body] :as response}] - (open-import-modal {:name name :uri (wapi/create-uri body)})) + (open-import-modal {:name name + :uri (wapi/create-uri body) + :blob body})) (fn [error] (reset! downloading? false) (js/console.error "error" error)) diff --git a/frontend/src/app/worker/import.cljs b/frontend/src/app/worker/import.cljs index e8310efa89..389c0a16f2 100644 --- a/frontend/src/app/worker/import.cljs +++ b/frontend/src/app/worker/import.cljs @@ -12,11 +12,8 @@ [app.common.logging :as log] [app.common.schema :as sm] [app.common.uuid :as uuid] - [app.main.data.uploads :as uploads] - [app.main.repo :as rp] [app.util.http :as http] [app.util.i18n :as i18n :refer [tr]] - [app.util.sse :as sse] [app.util.zip :as uz] [app.worker.impl :as impl] [beicon.v2.core :as rx] @@ -151,103 +148,3 @@ [{:keys [files]}] (->> (rx/from files) (rx/merge-map analyze-file))) - -(defn- import-blob-via-upload - "Fetches `uri` as a Blob, uploads it using the generic chunked-upload - session API and calls `import-binfile` with the resulting upload-id. - Returns an observable of SSE events from the import stream." - [uri {:keys [name version project-id]}] - (->> (slurp-uri uri :blob) - (rx/mapcat - (fn [blob] - (->> (uploads/upload-blob-chunked blob) - (rx/mapcat - (fn [{:keys [session-id]}] - (rp/cmd! ::sse/import-binfile - {:name name - :upload-id session-id - :version version - :project-id project-id})))))))) - -(defmethod impl/handler :import-files - [{:keys [project-id files]}] - (let [binfile-v1 (filter #(= :binfile-v1 (:type %)) files) - binfile-v3 (filter #(= :binfile-v3 (:type %)) files) - resolutions (volatile! {})] - - (rx/merge - (->> (rx/from binfile-v1) - (rx/merge-map - (fn [data] - (->> (import-blob-via-upload (:uri data) - {:name (str/replace (:name data) #".penpot$" "") - :version 1 - :project-id project-id}) - (rx/tap (fn [event] - (let [payload (sse/get-payload event) - type (sse/get-type event)] - (if (= type "progress") - (log/dbg :hint "import-binfile: progress" - :section (:section payload) - :name (:name payload)) - (log/dbg :hint "import-binfile: end"))))) - (rx/filter sse/end-of-stream?) - (rx/map (fn [_] - {:status :finish - :file-id (:file-id data)})) - (rx/catch - (fn [cause] - (log/error :hint "unexpected error on import process" - :project-id project-id - :cause cause) - (rx/of {:status :error - :error (import-cause-message cause (tr "labels.error")) - :file-id (:file-id data)}))))))) - - - (rx/concat - (->> (rx/from binfile-v3) - (rx/reduce (fn [result file] - (update result (:uri file) (fnil conj []) file)) - {}) - (rx/mapcat identity) - (rx/merge-map - (fn [[uri entries]] - (->> (import-blob-via-upload uri - {:name (-> entries first :name) - :version 3 - :project-id project-id}) - (rx/tap (fn [event] - (let [payload (sse/get-payload event) - type (sse/get-type event)] - (cond - (= type "progress") - (log/dbg :hint "import-binfile: progress" - :section (:section payload) - :name (:name payload)) - - :else - (log/dbg :hint "import-binfile: end"))))) - (rx/filter sse/end-of-stream?) - (rx/mapcat (fn [message] - (let [{:keys [resolution]} (sse/get-payload message)] - (when (seq resolution) - (vswap! resolutions merge resolution)) - (->> (rx/from entries) - (rx/map (fn [entry] - {:status :finish - :file-id (:file-id entry)})))))) - (rx/catch (fn [cause] - (log/error :hint "import-binfile: unexpected error on importing" - :project-id project-id - ::log/sync? true - :cause cause) - (let [err (import-cause-message cause (tr "labels.error"))] - (->> (rx/from entries) - (rx/map (fn [entry] - {:status :error - :error err - :file-id (:file-id entry)})))))))))) - (->> (rx/defer #(rx/of @resolutions)) - (rx/map (fn [resolutions] - {:libraries-resolution resolutions}))))))) diff --git a/frontend/test/frontend_tests/data/imports_test.cljs b/frontend/test/frontend_tests/data/imports_test.cljs new file mode 100644 index 0000000000..c322ddea5a --- /dev/null +++ b/frontend/test/frontend_tests/data/imports_test.cljs @@ -0,0 +1,76 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) KALEIDOS SUBSIDIARY SL + +(ns frontend-tests.data.imports-test + (:require + [app.common.uuid :as uuid] + [app.main.data.imports :as imports] + [app.main.repo :as rp] + [app.util.sse :as sse] + [beicon.v2.core :as rx] + [cljs.test :as t :include-macros true] + [frontend-tests.helpers.async :as hva] + [frontend-tests.helpers.mock :as mock])) + +(defn- make-blob + [size] + (js/Blob. #js [(js/Uint8Array. size)] #js {:type "application/octet-stream"})) + +(t/deftest ^:async import-files-uses-kept-blob + (let [session-id (uuid/next) + file-id (uuid/next) + project-id (uuid/next) + blob (make-blob 30) + uri "blob:https://localhost/test-import" + seen-cmds (atom []) + fetch-uris (atom []) + seen (atom []) + orig-fetch (.-fetch js/globalThis)] + + (set! (.-fetch js/globalThis) + (fn [url _opts] + (swap! fetch-uris conj (str url)) + (js/Promise.reject (js/Error. "fetch must not run for import")))) + + (await + (mock/with-mocks* + {rp/cmd! + (mock/stub + (fn [cmd params] + (swap! seen-cmds conj [cmd (dissoc params :content)]) + (cond + (= cmd :create-upload-session) + (rx/of {:session-id session-id}) + + (= cmd :upload-chunk) + (rx/of {:session-id session-id :index (:index params)}) + + (= cmd ::sse/import-binfile) + (rx/of #js {:type "end" :data {:resolution {}}}) + + :else + (rx/throw (ex-info "unexpected cmd" {:cmd cmd})))))} + + (await + (hva/observe + (imports/import-files + {:project-id project-id + :files [{:type :binfile-v3 + :uri uri + :blob blob + :name "Package" + :file-id file-id}]}) + {:on-next #(swap! seen conj %)})))) + + (set! (.-fetch js/globalThis) orig-fetch) + + (t/is (= [:create-upload-session :upload-chunk ::sse/import-binfile] + (mapv first @seen-cmds))) + (t/is (= session-id (-> @seen-cmds (nth 2) second :upload-id))) + (t/is (= [{:status :finish :file-id file-id} + {:libraries-resolution {}}] + @seen)) + (t/is (empty? @fetch-uris)))) diff --git a/frontend/test/frontend_tests/runner.cljs b/frontend/test/frontend_tests/runner.cljs index 3bea068a6b..ca8bf3586e 100644 --- a/frontend/test/frontend_tests/runner.cljs +++ b/frontend/test/frontend_tests/runner.cljs @@ -17,6 +17,7 @@ [frontend-tests.data.exports-assets-test] [frontend-tests.data.exports-files-test] [frontend-tests.data.fix-deleted-fonts-test] + [frontend-tests.data.imports-test] [frontend-tests.data.modal-test] [frontend-tests.data.nitrate-test] [frontend-tests.data.persistence-retry-test] @@ -183,6 +184,7 @@ 'frontend-tests.data.exports-files-test 'frontend-tests.data.svg-upload-test 'frontend-tests.data.team-test + 'frontend-tests.data.imports-test 'frontend-tests.data.uploads-test 'frontend-tests.data.viewer-test 'frontend-tests.data.workspace-colors-test From f089c86a71f6275e2ed4c67ea47c262aaba8fe82 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 23 Nov 2026 08:27:28 +0000 Subject: [PATCH 2/6] :bug: Fix changelog generation and advisory pagination Use GitHub's cursor pagination for repository advisories and flatten the returned pages. Remove empty breaking-change sections and document the changelog contract. AI-assisted-by: gpt-6-luna --- .serena/memories/scripts/changelog.md | 4 +-- .serena/memories/scripts/gh.md | 4 ++- .../memories/workflow/updating-changelog.md | 10 +++--- CHANGES.md | 7 ++++ scripts/changelog.py | 16 +++++++--- scripts/gh.py | 32 ++++++++++--------- scripts/test_changelog.py | 22 +++++++++---- scripts/test_gh.py | 12 +++++++ 8 files changed, 74 insertions(+), 33 deletions(-) diff --git a/.serena/memories/scripts/changelog.md b/.serena/memories/scripts/changelog.md index d8ea1b7d84..45bdf8d700 100644 --- a/.serena/memories/scripts/changelog.md +++ b/.serena/memories/scripts/changelog.md @@ -5,7 +5,7 @@ ## Subcommands - `check-merged ` (`--file`, `--stdin` accepted) — warn on any non-merged PR, exit 1 when found; run before writing changelog entries. -- `boom [--changes CHANGES.md --write]` — generate `### :boom: Breaking changes & Deprecations` from the closed, non-excluded milestone issues labelled `breaking change`, sorted by issue number. Each issue becomes a `#### ` block: content = body of the issue's last `## Breaking change note` comment (whole markdown, headings demoted to `#####` outside code fences; fallback = heading plus refs with a stderr warning), refs = issue link plus merged closing PRs on their own line, with `(by @author)` for `community contribution`. `--write` replaces only that subsection of the version (inserts it after the version header when missing, keeps the heading when there are no entries; idempotent). Print-only by default. Uses `gh.py comments`. +- `boom [--changes CHANGES.md --write]` — generate `### :boom: Breaking changes & Deprecations` from the closed, non-excluded milestone issues labelled `breaking change`, sorted by issue number. Each issue becomes a `#### ` block: content = body of the issue's last `## Breaking change note` comment (whole markdown, headings demoted to `#####` outside code fences; fallback = heading plus refs with a stderr warning), refs = issue link plus merged closing PRs on their own line, with `(by @author)` for `community contribution`. `--write` replaces only that subsection of the version, inserts it after the version header when needed, and removes it when there are no entries. Print-only by default. Uses `gh.py comments`. - `security [--changes CHANGES.md --write]` — generate `### :lock: Security fixes` from the advisories whose `patched_versions` include the version (via `gh.py advisories --patched-version`), sorted by GHSA id. Entry: `- Fix () (PR: [#N](...))`; description = `Fix` + advisory summary, first word decapitalized unless it starts with an acronym; PRs = merged milestone PRs labelled `pr pt` whose body contains the GHSA id, comma-separated, and no PR is legal. Warns on stderr when a `pr pt` PR references an advisory with no matching `patched_versions`. `--write` replaces only that subsection, placed after `:rocket:` (or `:boom:`, or the version header when neither exists); empty entries remove the subsection; idempotent. Print-only by default. - `cross-ref [--changes CHANGES.md]` — fetch milestone PRs with `--state all` once, report merged PRs missing from the version section plus CLOSED (unmerged) warnings. PR links inside `:lock:` entries count as referenced; advisory URLs never appear here by design. - `dev-only-bugs [--apply]` — list closed milestone bugs that never reached production, without `no changelog`. Sure: parent issue is a `Feature`/`Enhancement` of the same milestone; `--apply` adds `no changelog` to these only. Candidates (never labelled automatically): parent is an epic of the milestone, `regression` label, or the "Affected versions" / "Environment" body field names only hourly, develop, staging, PRE or the milestone version itself (`only_unreleased_envs`; any production hint or other version keeps the bug in — versions compare as full semver with missing patch = 0, so for milestone 2.19.2 the released 2.19.0 keeps the bug in). Reads `body` and `parent` from one batched `gh.py issue` lookup. @@ -19,4 +19,4 @@ - PR/issue reference parsing covers standard `[#N](.../pull/N)` / `[#N](.../issues/N)` links plus legacy `PR:[N]` / `[Github #N]` forms. - Shared parsing helpers (`extract_version_section`, `extract_subsection`, `collect_changelog_prs/issues`) live at module top so future subcommands reuse them instead of duplicating regexes. - Report anomaly types: A/B milestone mismatches, E `:boom:` entry whose issue lacks the `breaking change` label (counted, entries preserved — human labels the issue or moves the entry), G `breaking change` issue missing from `:boom:` (counted, same contract as F); C/D are `:rocket:` gaps (warnings, never counted). -- `issue_excluded` (closed, non-Task, non-Rejected, no `release blocker`/`no changelog` label) is module-level and shared by `report` and `boom` so the exclusions cannot drift. +- `issue_excluded` (closed, non-Task, non-Rejected, no `no changelog` label) is module-level and shared by `report` and `boom` so the exclusions cannot drift. `release blocker` is not a changelog exclusion. diff --git a/.serena/memories/scripts/gh.md b/.serena/memories/scripts/gh.md index 6b546e578c..8eccba6b61 100644 --- a/.serena/memories/scripts/gh.md +++ b/.serena/memories/scripts/gh.md @@ -40,7 +40,7 @@ python3 scripts/gh.py issues "2.16.0" --label "bug" python3 scripts/gh.py issues "2.16.0" --label "bug,regression" # Exclude by label -python3 scripts/gh.py issues "2.16.0" --exclude "release blocker,no changelog" +python3 scripts/gh.py issues "2.16.0" --exclude "no changelog" # Show only issues NOT yet in CHANGES.md python3 scripts/gh.py issues "2.16.0" --compare CHANGES.md @@ -131,6 +131,8 @@ python3 scripts/gh.py advisories GHSA-xvj6-fh9w-gjw7 `--patched-version` filters the raw advisories before formatting: the match is an exact token of `vulnerabilities[*].patched_versions` (split on `,`/`;`), so `2.19.1` never matches `2.19.10`. Every state is included (`triage`, `draft`, `published`, `closed`, `withdrawn`). The raw `vulnerabilities` stay internal to the filter: the list output keeps the summary schema. +The repository security-advisories endpoint uses cursor pagination (`before`/`after`), not numeric `page` pagination. Observed failure: `page=1` and `page=2` both returned the same 100 advisories, so a length-based loop never ended. `fetch_advisories` must use `gh api --paginate --slurp` so the GitHub CLI follows the response `Link` headers and returns page arrays for flattening. Do not hand-increment `page`. + **Output**: JSON to stdout; progress to stderr. ## Key principles diff --git a/.serena/memories/workflow/updating-changelog.md b/.serena/memories/workflow/updating-changelog.md index 008e0fc8df..f245a4e0b4 100644 --- a/.serena/memories/workflow/updating-changelog.md +++ b/.serena/memories/workflow/updating-changelog.md @@ -28,9 +28,9 @@ Editing `CHANGES.md` happens only on explicit request or as part of the release - **Security fixes come from advisories**: an advisory whose `patched_versions` include the version becomes a `:lock:` entry (section 7). `triage`, `draft` and `published` are all valid states; the advisory may still be unpublished when the changelog is written. A security fix may also carry a regular bug issue; both entries are legal and independent (the issue lives in `:bug:` as any other bug). - **Two labels override the Issue Type**: `breaking change` → an entry only under `:boom:`, never in its regular section; `release highlight` → an extra entry under `:rocket:` on top of its regular entry. - **Only closed issues**. An open issue in the milestone is not generated, even if someone added a provisional entry by hand before the merge. -- **Excluded issues**: `no changelog`, `release blocker`, `Task` issue type, `Rejected` project status. +- **Excluded issues**: `no changelog`, `Task` issue type, `Rejected` project status. `release blocker` is not a changelog filter. - **Bugs that never reached production** stay out: a bug found and fixed while building a feature of the same, unreleased version never affected users. The team rarely labels them, so the flow finds them with `dev-only-bugs` and labels them `no changelog` (section 8, step 3). -- **Excluded PRs**: a PR with `release blocker` or `no issue required` does not bring an entry of its own. +- **Excluded PRs**: a PR with `no issue required` does not bring an entry of its own. - **An issue with no milestone** belongs to another (probably private) project: it is neither changelog candidate nor anomaly. ## 3. Layout of `CHANGES.md` @@ -74,7 +74,7 @@ The newest version goes at the top, right after the `# CHANGELOG` header. Inside - `:boom:` first, then `:rocket:`, `:lock:`, `:tada:`, `:sparkles:`, `:bug:`. Features come before enhancements so they stand out to readers deciding whether to update. - **This layout applies from 2.20.0.** Versions up to 2.19.x use the old one: `:bug: Bugs fixed` before `:sparkles: New features & Enhancements`, which mixes features and enhancements. Keep the old layout in those sections, including new 2.19.x patches, so a minor line reads the same. The in-app update dialog only reads `:rocket:`, so the change does not affect it. - Other headings exist in old versions (`:heart:` community contributions); do not add them to new versions. -- Include a section only when it has entries. Historical versions may have an empty `:boom:` or `:rocket:` heading; `boom --write` keeps the `:boom:` heading even when there are no entries. `:lock:` is omitted (and removed on `--write`) when the version has no security advisories. +- Include a section only when it has entries. `boom --write` removes an empty `:boom:` subsection and does not insert one when there are no breaking changes. `:lock:` is omitted (and removed on `--write`) when the version has no security advisories. - One blank line between the last entry of a section and the next heading. - No manual line wrapping: one line per bullet or paragraph, however long. @@ -158,7 +158,7 @@ Generated from the advisories that declare the version in `patched_versions`; ne ## 8. Flow 1. **Confirm the version** (a semver string such as `2.19.0`) with the user when it is not obvious. -2. **Fetch the milestone issues**: `python3 scripts/gh.py issues "" --exclude "release blocker,no changelog"` (closed by default; add `--state all` only to inspect open issues). `gh.py` already drops `Task` and `Rejected`; pass `--include-tasks` / `--include-rejected` only to inspect them. To find what is missing from an existing section, add `--compare CHANGES.md`. +2. **Fetch the milestone issues**: `python3 scripts/gh.py issues "" --exclude "no changelog"` (closed by default; add `--state all` only to inspect open issues). `gh.py` already drops `Task` and `Rejected`; pass `--include-tasks` / `--include-rejected` only to inspect them. To find what is missing from an existing section, add `--compare CHANGES.md`. 3. **Keep out bugs that never reached production**: `python3 scripts/changelog.py dev-only-bugs ""` lists them; add `--apply` to label the sure ones `no changelog` on GitHub, then re-fetch step 2. The label puts the decision on the issue, so it survives a regeneration. - **Sure**: a bug whose parent issue is a `Feature` or `Enhancement` of the same milestone. `--apply` labels these. - **Candidates**: a bug whose parent is an epic of the same milestone, that carries the `regression` label, or whose "Affected versions" / "Environment" field names only hourly, develop, staging, PRE or the milestone version itself. `regression` also marks regressions users hit in production, and the field says where the bug was seen, not since when it exists, so never label these yourself: show them to the user, who labels the ones they confirm. The anomaly report lists them too (section 10). @@ -178,7 +178,7 @@ Re-fetch the milestone (do not trust cached data) and fix these in `CHANGES.md` 1. **Duplicate across versions** → remove it from the current section; the earlier version wins for backports. 2. **Stale milestone assignment** (the issue moved out of this milestone) → remove the entry. -3. **Newly applied exclusion labels** (`no changelog`, `release blocker`) → remove the entry. +3. **Newly applied exclusion label** (`no changelog`) → remove the entry. 4. **Issue no longer closed, deleted, or now `Rejected`** → remove the entry. 5. **Unmerged or moved PR reference** → fix the reference or remove the entry. A PR merged in a different milestone is an anomaly (section 10); do not remove it silently. 6. **Issue Type changed** → to `Task`: remove the entry; to another type: move the entry to that type's section. diff --git a/CHANGES.md b/CHANGES.md index 639cace0b2..667be70bf0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,12 @@ # CHANGELOG +## 2.19.3 + +### :bug: Bugs fixed + +- Fix app startup failure on Chromium browsers with Tampermonkey user scripts enabled [#12924](https://github.com/penpot/penpot/issues/12924) (PR: [#13085](https://github.com/penpot/penpot/pull/13085)) +- Size frontend nginx workers from the container CPU limit to prevent OOM kills on large nodes [#13103](https://github.com/penpot/penpot/issues/13103) (PR: [#13110](https://github.com/penpot/penpot/pull/13110)) + ## 2.19.2 ### :bug: Bugs fixed diff --git a/scripts/changelog.py b/scripts/changelog.py index fab0018199..154f1792b9 100644 --- a/scripts/changelog.py +++ b/scripts/changelog.py @@ -45,7 +45,7 @@ GH_PY = Path(__file__).resolve().parent / "gh.py" BOOM_HEADING = "### :boom: Breaking changes & Deprecations" SECURITY_HEADING = "### :lock: Security fixes" BREAKING_LABEL = "breaking change" -EXCLUDED_LABELS = {"release blocker", "no changelog"} +EXCLUDED_LABELS = {"no changelog"} # PR label carried by the security fixes that reference their advisory in the # PR body, and the GHSA id pattern used to find that reference. @@ -290,8 +290,9 @@ def entry_list_body(entries: list[str]) -> str: def replace_boom_section(content: str, milestone: str, entries: list[str]) -> str: """Return ``content`` with its ``:boom:`` subsection replaced. - The subsection is inserted right after the version header when missing, - which keeps ``:boom:`` as the first section. + The subsection is inserted right after the version header when needed, + which keeps ``:boom:`` as the first section. Empty subsections are removed + and are not inserted. """ bounds = version_section_bounds(content, milestone) if bounds is None: @@ -299,6 +300,13 @@ def replace_boom_section(content: str, milestone: str, entries: list[str]) -> st start, end = bounds section = content[start:end] heading = re.search(rf"(?m)^{re.escape(BOOM_HEADING)}[ \t]*$", section) + if not entries: + if heading is None: + return content + body_start = start + heading.end() + next_heading = re.search(r"(?m)^### ", content[body_start:end]) + body_end = body_start + next_heading.start() if next_heading else end + return content[: start + heading.start()] + content[body_end:] if heading: body_start = start + heading.end() next_heading = re.search(r"(?m)^### ", content[body_start:end]) @@ -674,7 +682,7 @@ def find_dev_only_bugs(milestone: str, issues: list[dict]) -> tuple[list[dict], for issue in issues: if issue.get("issue_type") != "Bug" or issue.get("state") != "CLOSED": continue - if {"no changelog", "release blocker"} & set(issue.get("labels", [])): + if "no changelog" in issue.get("labels", []): continue parent = issue.get("parent") or {} entry = {"issue": issue["number"], "issue_title": issue.get("title", "")} diff --git a/scripts/gh.py b/scripts/gh.py index 30c12e58f2..60766b3228 100755 --- a/scripts/gh.py +++ b/scripts/gh.py @@ -15,7 +15,7 @@ Subcommands: Usage: python3 scripts/gh.py issues (default: state=closed) python3 scripts/gh.py issues "2.16.0" --state all - python3 scripts/gh.py issues "2.16.0" --exclude "release blocker,no changelog" + python3 scripts/gh.py issues "2.16.0" --exclude "no changelog" python3 scripts/gh.py issues "2.16.0" --label "bug" (include only issues with label) python3 scripts/gh.py issues "2.16.0" --label "bug,regression" --exclude "no changelog" python3 scripts/gh.py issues "2.16.0" --compare CHANGES.md @@ -952,21 +952,23 @@ def cmd_comments(args: argparse.Namespace) -> None: def fetch_advisories() -> list[dict]: - """Fetch all security advisories for the repository via REST API.""" - all_advisories: list[dict] = [] - page = 1 - - while True: - advisories = run_gh_rest( - f"repos/{REPO}/security-advisories?per_page=100&page={page}" + """Fetch all security advisories using GitHub's cursor-based pagination.""" + try: + pages = json.loads( + run_gh_command( + [ + "gh", + "api", + "--paginate", + "--slurp", + f"repos/{REPO}/security-advisories?per_page=100", + ] + ) ) - all_advisories.extend(advisories) + except GhCommandFailed as err: + fail_gh(err.stderr) - if len(advisories) < 100: - break - page += 1 - - return all_advisories + return [advisory for page in pages for advisory in page] def fetch_advisory(ghsa_id: str) -> dict: @@ -1092,7 +1094,7 @@ def main() -> None: ) p_issues.add_argument( "--exclude", "--exclude-labels", - help="Comma-separated labels to exclude, e.g. 'release blocker,no changelog'" + help="Comma-separated labels to exclude, e.g. 'no changelog'" ) p_issues.add_argument( "--label", "--labels", diff --git a/scripts/test_changelog.py b/scripts/test_changelog.py index fba2c541c0..5238df2a36 100644 --- a/scripts/test_changelog.py +++ b/scripts/test_changelog.py @@ -126,13 +126,13 @@ class IssueExcludedTests(unittest.TestCase): def test_keeps_a_valid_closed_issue(self): self.assertFalse(ch.issue_excluded(self.issue())) - def test_excludes_open_task_rejected_and_labelled(self): + def test_excludes_open_task_rejected_and_no_changelog(self): self.assertTrue(ch.issue_excluded(None)) self.assertTrue(ch.issue_excluded(self.issue(state="OPEN"))) self.assertTrue(ch.issue_excluded(self.issue(issue_type="Task"))) self.assertTrue(ch.issue_excluded(self.issue(project_status="Rejected"))) - self.assertTrue(ch.issue_excluded(self.issue(labels=["release blocker"]))) self.assertTrue(ch.issue_excluded(self.issue(labels=["no changelog"]))) + self.assertFalse(ch.issue_excluded(self.issue(labels=["release blocker"]))) class RenderBoomEntryTests(unittest.TestCase): @@ -180,10 +180,18 @@ class ReplaceBoomSectionTests(unittest.TestCase): once = ch.replace_boom_section(CHANGES, "2.19.0", [entry]) self.assertEqual(once, ch.replace_boom_section(once, "2.19.0", [entry])) - def test_empty_section_keeps_the_heading(self): + def test_empty_section_removes_the_heading(self): updated = ch.replace_boom_section(CHANGES, "2.19.0", []) - self.assertIn( - "### :boom: Breaking changes & Deprecations\n\n### :rocket:", updated + self.assertNotIn("### :boom: Breaking changes & Deprecations", updated) + self.assertIn("### :rocket:", updated) + + def test_empty_entries_do_not_insert_the_subsection(self): + without = CHANGES.replace( + "### :boom: Breaking changes & Deprecations\n\n- Old entry.\n\n", "" + ) + self.assertEqual( + without, + ch.replace_boom_section(without, "2.19.0", []), ) def test_inserts_the_subsection_when_missing(self): @@ -719,9 +727,11 @@ class FindDevOnlyBugsTests(unittest.TestCase): {**bug(8, parent={"number": 10, "issue_type": "Feature", "milestone": "2.19.0"}), "issue_type": "Enhancement"}, bug(9, body="### Affected versions\n\n2.18.2\n", labels=["regression"]), + bug(10, parent={"number": 10, "issue_type": "Feature", "milestone": "2.19.0"}, + labels=["release blocker"]), ] auto, suggested = ch.find_dev_only_bugs("2.19.0", issues) - self.assertEqual([e["issue"] for e in auto], [1, 2]) + self.assertEqual([e["issue"] for e in auto], [1, 2, 10]) self.assertEqual([e["issue"] for e in suggested], [3, 5, 9]) diff --git a/scripts/test_gh.py b/scripts/test_gh.py index b703b389eb..96771c8966 100644 --- a/scripts/test_gh.py +++ b/scripts/test_gh.py @@ -191,6 +191,18 @@ class AdvisoriesTests(unittest.TestCase): gh.advisory_fixed_in_version(self.advisory(" 2.19.1 "), "2.19.1") ) + @patch.object(gh, "run_gh_command") + def test_fetch_advisories_uses_cursor_pagination(self, run_gh_command): + first_page = [{"ghsa_id": "GHSA-first"}] + second_page = [{"ghsa_id": "GHSA-second"}] + run_gh_command.return_value = json.dumps([first_page, second_page]) + + self.assertEqual(gh.fetch_advisories(), first_page + second_page) + + command = run_gh_command.call_args.args[0] + self.assertIn("--paginate", command) + self.assertIn("--slurp", command) + @patch.object(gh, "fetch_advisories") def test_cmd_advisories_filters_by_patched_version(self, fetch_advisories): matching = self.advisory("2.19.1", "GHSA-j4vc-cmf6-jhr7") From b822b38279a91ac75a70c8c7ec5004a7ac0b26be Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 23 Nov 2026 09:39:45 +0100 Subject: [PATCH 3/6] :arrow_up: Update docker images --- docker/images/Dockerfile.backend | 4 ++-- docker/images/Dockerfile.exporter | 2 +- docker/images/Dockerfile.frontend | 2 +- docker/images/Dockerfile.mcp | 4 ++-- docker/images/Dockerfile.media-processor | 2 +- docker/images/Dockerfile.storybook | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docker/images/Dockerfile.backend b/docker/images/Dockerfile.backend index c2f4c5e6b7..7ab6bc5acd 100644 --- a/docker/images/Dockerfile.backend +++ b/docker/images/Dockerfile.backend @@ -1,4 +1,4 @@ -FROM dhi.io/debian-base:trixie-debian13-dev@sha256:f90fd43cdf3dd94840b4dc3a2a39fd2a08578e40e7895535e2e20a1275ba6013 AS build +FROM dhi.io/debian-base:trixie-debian13-dev@sha256:1aa0a2307eea88ae00d07c7b3c8e804187ee272ccc89cde7b51667b3b065fb1d AS build LABEL maintainer="Penpot " ENV LANG='C.UTF-8' \ @@ -53,7 +53,7 @@ RUN set -eux; \ --output /opt/jre; -FROM dhi.io/debian-base:trixie-debian13-dev@sha256:f90fd43cdf3dd94840b4dc3a2a39fd2a08578e40e7895535e2e20a1275ba6013 AS image +FROM dhi.io/debian-base:trixie-debian13-dev@sha256:1aa0a2307eea88ae00d07c7b3c8e804187ee272ccc89cde7b51667b3b065fb1d AS image LABEL maintainer="Penpot " ENV LANG='C.UTF-8' \ diff --git a/docker/images/Dockerfile.exporter b/docker/images/Dockerfile.exporter index 3d3b97b3de..7f6efd6d85 100644 --- a/docker/images/Dockerfile.exporter +++ b/docker/images/Dockerfile.exporter @@ -1,4 +1,4 @@ -FROM dhi.io/node:24.22.3-debian13-dev@sha256:dee4bb11f4cb32ad31000287af8795f772ac801338a166a0e9fbbadd9674a2f8 +FROM dhi.io/node:24.22.3-debian13-dev@sha256:d1dc20bbf685bcd5d318043b705d98a89360e576fb46f9e5c14cbf6ed77f3481 LABEL maintainer="Penpot " ENV LANG=en_US.UTF-8 \ diff --git a/docker/images/Dockerfile.frontend b/docker/images/Dockerfile.frontend index 1be6ee9680..dffc255e1b 100644 --- a/docker/images/Dockerfile.frontend +++ b/docker/images/Dockerfile.frontend @@ -1,4 +1,4 @@ -FROM dhi.io/nginx:1.31.8-debian13-dev@sha256:5f75855fe078ae96027706da06716fbe1c3dbb618fc603e61894e1b41adc56d7 +FROM dhi.io/nginx:1.31.9-debian13-dev@sha256:5ea1ac7fcb18e8112b9ea76fde3d9e0e555d8cea95aa6b618bcd1454b6194a3c LABEL maintainer="Penpot " ENV DEBIAN_FRONTEND=noninteractive diff --git a/docker/images/Dockerfile.mcp b/docker/images/Dockerfile.mcp index 7d2d5987cf..3a0ee43d47 100644 --- a/docker/images/Dockerfile.mcp +++ b/docker/images/Dockerfile.mcp @@ -1,4 +1,4 @@ -FROM dhi.io/node:24.22.3-debian13-dev@sha256:dee4bb11f4cb32ad31000287af8795f772ac801338a166a0e9fbbadd9674a2f8 AS build +FROM dhi.io/node:24.22.3-debian13-dev@sha256:d1dc20bbf685bcd5d318043b705d98a89360e576fb46f9e5c14cbf6ed77f3481 AS build LABEL maintainer="Penpot " ENV DEBIAN_FRONTEND=noninteractive @@ -42,7 +42,7 @@ RUN set -eux; \ RUN ./setup -FROM dhi.io/node:24.22.3-debian13@sha256:84adaf3bdd9fa350e753078db2928a1584e481e11225d14f96014b17ffc96c5a AS image +FROM dhi.io/node:24.22.3-debian13@sha256:5a303252e5e7570d9cb47268a840259b73f76970b89b122cc12614f06266936d AS image LABEL maintainer="Penpot " ENV LANG=en_US.UTF-8 \ diff --git a/docker/images/Dockerfile.media-processor b/docker/images/Dockerfile.media-processor index f81a983399..9341530f5e 100644 --- a/docker/images/Dockerfile.media-processor +++ b/docker/images/Dockerfile.media-processor @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1 -FROM dhi.io/node:24.22.3-debian13-dev@sha256:dee4bb11f4cb32ad31000287af8795f772ac801338a166a0e9fbbadd9674a2f8 +FROM dhi.io/node:24.22.3-debian13-dev@sha256:d1dc20bbf685bcd5d318043b705d98a89360e576fb46f9e5c14cbf6ed77f3481 LABEL maintainer="Penpot " ENV LANG=en_US.UTF-8 \ diff --git a/docker/images/Dockerfile.storybook b/docker/images/Dockerfile.storybook index 25a007a82a..8321a2a4c7 100644 --- a/docker/images/Dockerfile.storybook +++ b/docker/images/Dockerfile.storybook @@ -1,4 +1,4 @@ -FROM dhi.io/nginx:1.31.8-alpine3.24@sha256:ad079e1004e4ec4ec14dfc29612d542161a80bc4bf9735b8f6303dc45e588ce0 +FROM dhi.io/nginx:1.31.9-alpine3.24@sha256:8e4ef1b2f3042abcdc65a1cea82f66692fac50eb2e5643d9a54a4178b732f788 LABEL maintainer="Penpot " ARG BUNDLE_PATH="./bundle-storybook/" From 5e1e0bef345e84a9b45b5917dbd7969f74bd4f03 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 23 Nov 2026 08:40:20 +0000 Subject: [PATCH 4/6] :sparkles: Collect changelog inputs in one command Gather milestone issues, pull requests, advisories, and changelog checks into one JSON snapshot. Reuse it across the release workflow to avoid repeating GitHub queries while keeping write actions separate. AI-assisted-by: gpt-6.2-sol --- .agents/skills/update-changelog/SKILL.md | 30 +-- .serena/memories/scripts/changelog.md | 2 + .../memories/workflow/updating-changelog.md | 20 +- scripts/changelog.py | 202 ++++++++++++++++-- scripts/test_changelog.py | 109 ++++++++++ 5 files changed, 320 insertions(+), 43 deletions(-) diff --git a/.agents/skills/update-changelog/SKILL.md b/.agents/skills/update-changelog/SKILL.md index 87c493e7c4..97ba1bcd20 100644 --- a/.agents/skills/update-changelog/SKILL.md +++ b/.agents/skills/update-changelog/SKILL.md @@ -30,26 +30,32 @@ memory; it does not repeat it. 1. `mem:workflow/updating-changelog` — the canonical flow: sources of truth, layout, entry rules, the `## Breaking change note` comment contract, the advisory (`:lock:`) contract, pre-flight checks, anomaly types, and pitfalls. -2. `mem:scripts/changelog` — `boom`, `security`, `check-merged`, `cross-ref`, +2. `mem:scripts/changelog` — `collect`, `boom`, `security`, `check-merged`, `cross-ref`, `dev-only-bugs`, `report`. 3. `mem:scripts/gh` — `issues`, `issue`, `comments`, `prs`, `advisories`. ## Commands ```bash -python3 scripts/gh.py issues "" --exclude "release blocker,no changelog" -python3 scripts/gh.py advisories --patched-version "" -python3 scripts/changelog.py dev-only-bugs "" # list bugs that never reached production -python3 scripts/changelog.py dev-only-bugs "" --apply # label the sure ones `no changelog` -python3 scripts/changelog.py check-merged -python3 scripts/changelog.py boom "" # print the :boom: section -python3 scripts/changelog.py boom "" --write # replace it in CHANGES.md -python3 scripts/changelog.py security "" # print the :lock: section -python3 scripts/changelog.py security "" --write # replace it in CHANGES.md -python3 scripts/changelog.py cross-ref "" -python3 scripts/changelog.py report "" +snapshot=$(mktemp) +python3 scripts/changelog.py collect "" > "$snapshot" ``` +Review the JSON before running any of these commands: + +```bash +python3 scripts/changelog.py dev-only-bugs "" --snapshot "$snapshot" --apply +python3 scripts/changelog.py boom "" --snapshot "$snapshot" --write +python3 scripts/changelog.py security "" --snapshot "$snapshot" --write +python3 scripts/changelog.py cross-ref "" --snapshot "$snapshot" +python3 scripts/changelog.py report "" --snapshot "$snapshot" +``` + +Keep the snapshot private: it can contain unpublished advisories and PR text. +Run `collect` first and use the JSON for review and +merge-state checks. Run `collect` again after any GitHub change, including +`dev-only-bugs --apply`. Use `--apply` only when there are sure cases. + ## Hard Rules - `CHANGES.md` is edited only on explicit request or during the release process. diff --git a/.serena/memories/scripts/changelog.md b/.serena/memories/scripts/changelog.md index 45bdf8d700..382cd983ce 100644 --- a/.serena/memories/scripts/changelog.md +++ b/.serena/memories/scripts/changelog.md @@ -4,6 +4,8 @@ ## Subcommands +- `collect [--changes CHANGES.md]` — read-only. Prints JSON to stdout with all milestone `issues` and `prs`, `eligible_issues` (issue numbers), `related_issues` and `related_prs` resolved in batches, `breaking_notes` keyed by issue number, `advisories`, `security_prs` keyed by GHSA, `dev_only_bugs` (`auto` and `suggested`), and `comparison` against the current changelog (references, missing and ineligible issues, cross-version duplicates, unlisted merged PRs). A missing version section is valid. Keep the snapshot private; it can contain unpublished advisories and PR text. See `mem:workflow/updating-changelog` for when to refresh it. +- `boom`, `security`, `cross-ref`, `dev-only-bugs` and `report` accept `--snapshot ` to reuse GitHub data from `collect` for the same milestone. `cross-ref` and `report` still read the current changelog; `--write`, `--apply` and `report` retain their existing write behavior. Without a snapshot, commands query GitHub as before. - `check-merged ` (`--file`, `--stdin` accepted) — warn on any non-merged PR, exit 1 when found; run before writing changelog entries. - `boom [--changes CHANGES.md --write]` — generate `### :boom: Breaking changes & Deprecations` from the closed, non-excluded milestone issues labelled `breaking change`, sorted by issue number. Each issue becomes a `#### ` block: content = body of the issue's last `## Breaking change note` comment (whole markdown, headings demoted to `#####` outside code fences; fallback = heading plus refs with a stderr warning), refs = issue link plus merged closing PRs on their own line, with `(by @author)` for `community contribution`. `--write` replaces only that subsection of the version, inserts it after the version header when needed, and removes it when there are no entries. Print-only by default. Uses `gh.py comments`. - `security [--changes CHANGES.md --write]` — generate `### :lock: Security fixes` from the advisories whose `patched_versions` include the version (via `gh.py advisories --patched-version`), sorted by GHSA id. Entry: `- Fix () (PR: [#N](...))`; description = `Fix` + advisory summary, first word decapitalized unless it starts with an acronym; PRs = merged milestone PRs labelled `pr pt` whose body contains the GHSA id, comma-separated, and no PR is legal. Warns on stderr when a `pr pt` PR references an advisory with no matching `patched_versions`. `--write` replaces only that subsection, placed after `:rocket:` (or `:boom:`, or the version header when neither exists); empty entries remove the subsection; idempotent. Print-only by default. diff --git a/.serena/memories/workflow/updating-changelog.md b/.serena/memories/workflow/updating-changelog.md index f245a4e0b4..fcb8245761 100644 --- a/.serena/memories/workflow/updating-changelog.md +++ b/.serena/memories/workflow/updating-changelog.md @@ -158,23 +158,23 @@ Generated from the advisories that declare the version in `patched_versions`; ne ## 8. Flow 1. **Confirm the version** (a semver string such as `2.19.0`) with the user when it is not obvious. -2. **Fetch the milestone issues**: `python3 scripts/gh.py issues "" --exclude "no changelog"` (closed by default; add `--state all` only to inspect open issues). `gh.py` already drops `Task` and `Rejected`; pass `--include-tasks` / `--include-rejected` only to inspect them. To find what is missing from an existing section, add `--compare CHANGES.md`. -3. **Keep out bugs that never reached production**: `python3 scripts/changelog.py dev-only-bugs ""` lists them; add `--apply` to label the sure ones `no changelog` on GitHub, then re-fetch step 2. The label puts the decision on the issue, so it survives a regeneration. +2. **Collect the release inputs**: `python3 scripts/changelog.py collect "" > "$snapshot"`. Use a private temporary file because the JSON can contain unpublished advisories and PR text. It contains the milestone issues and PRs, batched related records, generated-section inputs, dev-only bug candidates and a comparison with the current changelog. Use `eligible_issues` for changelog candidates and `comparison` for pre-flight. Collection does not write to the changelog or GitHub. +3. **Keep out bugs that never reached production**: review `dev_only_bugs` in the snapshot. If `auto` has entries, run `python3 scripts/changelog.py dev-only-bugs "" --snapshot "$snapshot" --apply` to label the sure ones `no changelog` on GitHub, then repeat step 2. The label puts the decision on the issue, so it survives a regeneration. - **Sure**: a bug whose parent issue is a `Feature` or `Enhancement` of the same milestone. `--apply` labels these. - **Candidates**: a bug whose parent is an epic of the same milestone, that carries the `regression` label, or whose "Affected versions" / "Environment" field names only hourly, develop, staging, PRE or the milestone version itself. `regression` also marks regressions users hit in production, and the field says where the bug was seen, not since when it exists, so never label these yourself: show them to the user, who labels the ones they confirm. The anomaly report lists them too (section 10). -4. **Fetch PR details when needed**: `python3 scripts/gh.py prs ` (also `--milestone`). Use it for the PR author, labels and merge state. +4. **Resolve PR links** using `prs` and `related_prs` in the snapshot. Look up a PR separately only if you discover a candidate not already in the snapshot. 5. **Categorize** by Issue Type and the two labels (section 2), and **build the descriptions** (section 4). -6. **Verify PR merge status** before writing: `python3 scripts/changelog.py check-merged `. Only merged PRs go in the changelog; if a closing PR was closed unmerged, look for the PR that superseded it. +6. **Verify PR merge status** before writing: only include PRs with state `MERGED` in the snapshot or verified by `check-merged` if looked up separately. If a closing PR was closed unmerged, look for the PR that superseded it. 7. **Reconcile the existing text** (section 9). -8. **Generate `:boom:`**: `python3 scripts/changelog.py boom ""` prints the section; add `--write` to replace it in `CHANGES.md`. The write replaces only that subsection, inserts it after the version header when missing, keeps the heading when there are no entries, and is idempotent. +8. **Generate `:boom:`**: `python3 scripts/changelog.py boom "" --snapshot "$snapshot"` prints the section; add `--write` to update just that subsection in `CHANGES.md`. If there are no entries, `--write` removes the subsection or leaves it absent. 9. **Generate `:rocket:`** from the `release highlight` label (section 6). -10. **Generate `:lock:`**: `python3 scripts/changelog.py security ""` prints the section; add `--write` to replace it in `CHANGES.md`. The contract lives in section 7. -11. **Cross-check PRs**: `python3 scripts/changelog.py cross-ref ""`. It lists merged milestone PRs missing from the section and warns about closed (unmerged) PRs. PRs linked from `:lock:` count as referenced; an advisory with no PR is invisible here by design. -12. **Generate the anomaly report**: `python3 scripts/changelog.py report ""`. It overwrites `CHANGES-ISSUES.md` with the current state (section 10). +10. **Generate `:lock:`**: `python3 scripts/changelog.py security "" --snapshot "$snapshot"` prints the section; add `--write` to replace it in `CHANGES.md`. The contract lives in section 7. +11. **Cross-check PRs**: `python3 scripts/changelog.py cross-ref "" --snapshot "$snapshot"`. It compares the snapshot against the updated changelog, lists missing merged PRs and warns about closed (unmerged) PRs. PRs linked from `:lock:` count as referenced; an advisory with no PR is invisible here by design. +12. **Generate the anomaly report**: `python3 scripts/changelog.py report "" --snapshot "$snapshot"`. It reads the updated changelog and overwrites `CHANGES-ISSUES.md` (section 10). If you need the report to resolve a new reference not known to the snapshot, collect again first. ## 9. Pre-flight: reconcile before writing -Re-fetch the milestone (do not trust cached data) and fix these in `CHANGES.md` before adding the new section: +Start from a fresh `collect` snapshot. Refresh it if GitHub changes during review (labels, notes, advisories, or PRs). Fix these in `CHANGES.md` before adding the new section: 1. **Duplicate across versions** → remove it from the current section; the earlier version wins for backports. 2. **Stale milestone assignment** (the issue moved out of this milestone) → remove the entry. @@ -214,6 +214,6 @@ Anything else is a rule violation, not a report item: fix it in the pre-flight a ## 12. Where the code is - `scripts/gh.py`: `issues`, `issue`, `comments`, `prs`, `link-issue`, `advisories` (with `--patched-version`). Details: `mem:scripts/gh`. -- `scripts/changelog.py`: `check-merged`, `boom`, `security`, `cross-ref`, `dev-only-bugs`, `report`. Details: `mem:scripts/changelog`. +- `scripts/changelog.py`: `collect`, `check-merged`, `boom`, `security`, `cross-ref`, `dev-only-bugs`, `report`. Details: `mem:scripts/changelog`. - Tests: `scripts/test_gh.py`, `scripts/test_changelog.py`. - The note contract for issue authors: `mem:workflow/creating-issues`, section **Breaking changes**. diff --git a/scripts/changelog.py b/scripts/changelog.py index 154f1792b9..6c7dc84952 100644 --- a/scripts/changelog.py +++ b/scripts/changelog.py @@ -6,6 +6,7 @@ Uses ``scripts/gh.py`` (via subprocess) and the local ``CHANGES.md`` so the flow memory (`mem:workflow/updating-changelog`) stays free of inline programs. Subcommands: + collect Collect the release inputs and changelog comparison as JSON check-merged Verify that every given PR is merged (warns otherwise) boom Generate the :boom: section from `breaking change` issues security Generate the :lock: section from advisories fixed in a version @@ -14,6 +15,7 @@ Subcommands: report Generate the anomaly report (CHANGES-ISSUES.md) Usage: + python3 scripts/changelog.py collect "2.19.0" python3 scripts/changelog.py check-merged 9179 9204 9311 cat prs.txt | python3 scripts/changelog.py check-merged --stdin python3 scripts/changelog.py boom "2.19.0" @@ -111,6 +113,19 @@ def fetch_milestone_prs(milestone: str, state: str) -> list[dict]: return json.loads(stdout) +def load_snapshot(args: argparse.Namespace) -> dict | None: + path = getattr(args, "snapshot", None) + if path is None: + return None + try: + snapshot = json.loads(Path(path).read_text(encoding="utf-8")) + if snapshot["milestone"] != args.milestone: + raise ValueError(f"expected milestone {args.milestone}") + except (OSError, ValueError, KeyError, TypeError) as err: + sys.exit(f"ERROR: invalid changelog snapshot {path}: {err}") + return snapshot + + def extract_version_section(content: str, milestone: str) -> str: """Return the changelog body of a ``## `` section (or "").""" match = re.search( @@ -351,24 +366,30 @@ def fetch_breaking_notes(issues: list[dict]) -> dict[int, str]: return notes -def cmd_boom(args: argparse.Namespace) -> None: - """Generate the ``:boom:`` section from ``breaking change`` issues.""" - all_issues = json.loads(run_gh_py("issues", args.milestone, "--state", "all")) - labelled = sorted( +def breaking_issues(issues: list[dict]) -> list[dict]: + return sorted( ( issue - for issue in all_issues - if BREAKING_LABEL in issue.get("labels", []) - and not issue_excluded(issue) + for issue in issues + if BREAKING_LABEL in issue.get("labels", []) and not issue_excluded(issue) ), key=lambda issue: issue["number"], ) - notes: dict[int, str] = {} - prs: dict[int, dict] = {} - if labelled: + +def cmd_boom(args: argparse.Namespace) -> None: + """Generate the ``:boom:`` section from ``breaking change`` issues.""" + snapshot = load_snapshot(args) + if snapshot is None: + labelled = breaking_issues( + json.loads(run_gh_py("issues", args.milestone, "--state", "all")) + ) notes = fetch_breaking_notes(labelled) prs = fetch_prs_by_issue(labelled) + else: + labelled = breaking_issues(snapshot["issues"]) + notes = {int(n): note for n, note in snapshot["breaking_notes"].items()} + prs = {pr["number"]: pr for pr in snapshot["prs"] + snapshot["related_prs"]} entries: list[str] = [] for issue in labelled: @@ -462,8 +483,12 @@ def fetch_security_advisories(milestone: str) -> list[dict]: def fetch_security_prs(milestone: str) -> dict[str, list[int]]: """Map each GHSA id to the merged ``pr pt`` PRs in a milestone referencing it.""" + return security_prs_by_advisory(fetch_milestone_prs(milestone, "all")) + + +def security_prs_by_advisory(prs: list[dict]) -> dict[str, list[int]]: by_ghsa: dict[str, list[int]] = {} - for pr in fetch_milestone_prs(milestone, "all"): + for pr in prs: if pr.get("state") != "MERGED": continue if SECURITY_PR_LABEL not in pr.get("labels", []): @@ -541,8 +566,13 @@ def replace_security_section( def cmd_security(args: argparse.Namespace) -> None: """Generate the ``:lock:`` section from advisories fixed in the version.""" milestone = args.milestone - advisories = fetch_security_advisories(milestone) - prs_by_ghsa = fetch_security_prs(milestone) + snapshot = load_snapshot(args) + if snapshot is None: + advisories = fetch_security_advisories(milestone) + prs_by_ghsa = fetch_security_prs(milestone) + else: + advisories = snapshot["advisories"] + prs_by_ghsa = snapshot["security_prs"] matched = { advisory["ghsa_id"].upper() @@ -606,7 +636,12 @@ def cmd_cross_ref(args: argparse.Namespace) -> None: sys.exit(1) changelog_refs = collect_changelog_prs(section) - milestone_prs = fetch_milestone_prs(args.milestone, "all") + snapshot = load_snapshot(args) + milestone_prs = ( + fetch_milestone_prs(args.milestone, "all") + if snapshot is None + else snapshot["prs"] + ) merged = {pr["number"] for pr in milestone_prs if pr.get("state") == "MERGED"} closed = [pr for pr in milestone_prs if pr.get("state") == "CLOSED"] @@ -712,7 +747,14 @@ def fetch_milestone_bugs(milestone: str) -> list[dict]: def cmd_dev_only_bugs(args: argparse.Namespace) -> None: """List bugs that never reached production; --apply labels the sure ones.""" - auto, suggested = find_dev_only_bugs(args.milestone, fetch_milestone_bugs(args.milestone)) + snapshot = load_snapshot(args) + if snapshot is None: + auto, suggested = find_dev_only_bugs( + args.milestone, fetch_milestone_bugs(args.milestone) + ) + else: + auto = snapshot["dev_only_bugs"]["auto"] + suggested = snapshot["dev_only_bugs"]["suggested"] print(f"Label `no changelog` ({len(auto)}):") for e in auto: @@ -731,6 +773,94 @@ def cmd_dev_only_bugs(args: argparse.Namespace) -> None: print(f"Labelled {len(auto)} issues `no changelog`", file=sys.stderr) +def cmd_collect(args: argparse.Namespace) -> None: + """Collect release inputs without changing the changelog or GitHub.""" + milestone = args.milestone + content = Path(args.changes).read_text(encoding="utf-8") + section = extract_version_section(content, milestone) + issue_refs = collect_changelog_issues(section) + pr_refs = collect_changelog_prs(section) + + issues = json.loads( + run_gh_py( + "issues", + milestone, + "--state", + "all", + "--include-tasks", + "--include-rejected", + ) + ) + prs = fetch_milestone_prs(milestone, "all") + eligible = {issue["number"] for issue in issues if not issue_excluded(issue)} + issue_numbers = {issue["number"] for issue in issues} + pr_numbers = {pr["number"] for pr in prs} + bugs = { + issue["number"] + for issue in issues + if issue["number"] in eligible and issue.get("issue_type") == "Bug" + } + related_issue_numbers = ( + issue_refs | {n for pr in prs for n in pr.get("closing_issues", [])} + ) - issue_numbers + detail_numbers = sorted(bugs | related_issue_numbers) + details = ( + json.loads(run_gh_py("issue", *map(str, detail_numbers))) + if detail_numbers + else [] + ) + related_pr_numbers = ( + pr_refs | {n for issue in issues for n in closing_pr_numbers(issue)} + ) - pr_numbers + related_prs = ( + fetch_prs_by_numbers(sorted(related_pr_numbers)) if related_pr_numbers else [] + ) + auto, suggested = find_dev_only_bugs( + milestone, [issue for issue in details if issue["number"] in bugs] + ) + notes = fetch_breaking_notes(breaking_issues(issues)) + advisories = fetch_security_advisories(milestone) + + other_versions: dict[int, list[str]] = {} + for version_section in re.split(r"(?m)(?=^## \d+\.\d+\.\d+)", content): + header = re.match(r"^## (\d+\.\d+\.\d+)\b", version_section) + if header is None or header[1] == milestone: + continue + for number in sorted( + collect_changelog_issues(version_section) & (eligible | issue_refs) + ): + other_versions.setdefault(number, []).append(header[1]) + + snapshot = { + "milestone": milestone, + "issues": issues, + "eligible_issues": sorted(eligible), + "prs": prs, + "related_issues": [ + issue for issue in details if issue["number"] in related_issue_numbers + ], + "related_prs": related_prs, + "breaking_notes": notes, + "advisories": advisories, + "security_prs": security_prs_by_advisory(prs), + "dev_only_bugs": {"auto": auto, "suggested": suggested}, + "comparison": { + "section_exists": version_section_bounds(content, milestone) is not None, + "issue_refs": sorted(issue_refs), + "pr_refs": sorted(pr_refs), + "missing_issues": sorted(eligible - issue_refs - other_versions.keys()), + "ineligible_references": sorted(issue_refs - eligible), + "issues_in_other_versions": other_versions, + "unlisted_merged_prs": sorted( + pr["number"] + for pr in prs + if pr.get("state") == "MERGED" and pr["number"] not in pr_refs + ), + }, + } + print(json.dumps(snapshot, indent=2)) + + # ───────────────────────────────────────────── # Subcommand: report # ───────────────────────────────────────────── @@ -770,10 +900,14 @@ def cmd_report(args: argparse.Namespace) -> None: """Generate the changelog anomaly report and write it to a file.""" milestone = args.milestone - all_issues = json.loads(run_gh_py("issues", milestone, "--state", "all")) + snapshot = load_snapshot(args) + if snapshot is None: + all_issues = json.loads(run_gh_py("issues", milestone, "--state", "all")) + all_prs = fetch_milestone_prs(milestone, "all") + else: + all_issues = snapshot["issues"] + all_prs = snapshot["prs"] issue_by_num = {i["number"]: i for i in all_issues} - - all_prs = fetch_milestone_prs(milestone, "all") pr_by_num = {p["number"]: p for p in all_prs} with open(args.changes) as f: @@ -792,7 +926,10 @@ def cmd_report(args: argparse.Namespace) -> None: for issue in issue_by_num.values(): unknown_prs.update(issue.get("closing_prs", [])) unknown_prs -= set(pr_milestone_cache) - if unknown_prs: + if snapshot is not None: + for pr in snapshot["related_prs"]: + pr_milestone_cache[pr["number"]] = pr.get("milestone") + elif unknown_prs: print( f"Resolving milestones for {len(unknown_prs)} PRs outside {milestone}...", file=sys.stderr, @@ -807,7 +944,12 @@ def cmd_report(args: argparse.Namespace) -> None: unknown_issues |= collect_changelog_issues(extract_subsection(section, r"### :rocket:")) unknown_issues -= set(issue_milestone_cache) external_issues: dict[int, dict] = {} - if unknown_issues: + if snapshot is not None: + for issue in snapshot["related_issues"]: + issue_milestone_cache[issue["number"]] = issue.get("milestone") + if "error" not in issue: + external_issues[issue["number"]] = issue + elif unknown_issues: print( f"Resolving milestones for {len(unknown_issues)} issues outside {milestone}...", file=sys.stderr, @@ -989,7 +1131,13 @@ def cmd_report(args: argparse.Namespace) -> None: anomalies_d.append({"version": ver, "line": line[:100]}) # Bugs that may never have reached production: warnings, not anomalies. - dev_auto, dev_suggested = find_dev_only_bugs(milestone, fetch_milestone_bugs(milestone)) + if snapshot is None: + dev_auto, dev_suggested = find_dev_only_bugs( + milestone, fetch_milestone_bugs(milestone) + ) + else: + dev_auto = snapshot["dev_only_bugs"]["auto"] + dev_suggested = snapshot["dev_only_bugs"]["suggested"] def fmt_ms(ms: str | None) -> str: return ms if ms else "_none_" @@ -1199,6 +1347,13 @@ def main() -> None: ) sub = parser.add_subparsers(dest="command", required=True, title="subcommands") + p_collect = sub.add_parser("collect", help="Collect changelog inputs as JSON") + p_collect.add_argument("milestone", help="Milestone title (e.g. '2.19.0')") + p_collect.add_argument( + "--changes", default="CHANGES.md", help="Path to the changelog" + ) + p_collect.set_defaults(func=cmd_collect) + p_check = sub.add_parser( "check-merged", help="Verify that every given PR is merged" ) @@ -1258,6 +1413,11 @@ def main() -> None: help="Report output path (default: CHANGES-ISSUES.md)") p_report.set_defaults(func=cmd_report) + for command in (p_boom, p_security, p_cross, p_dev, p_report): + command.add_argument( + "--snapshot", help="Use JSON from collect instead of GitHub" + ) + args = parser.parse_args() args.func(args) diff --git a/scripts/test_changelog.py b/scripts/test_changelog.py index 5238df2a36..6c6d2aaab9 100644 --- a/scripts/test_changelog.py +++ b/scripts/test_changelog.py @@ -335,6 +335,115 @@ class CmdBoomTests(unittest.TestCase): self.assertIn("Deploy the new service.", out) +class CollectTests(unittest.TestCase): + def test_collect_batches_extra_details_and_reuses_them_for_local_checks(self): + issues = [ + { + "number": 1, + "state": "CLOSED", + "issue_type": "Bug", + "title": "Change a default", + "labels": ["breaking change"], + "closing_prs": [10, 11], + }, + {"number": 2, "state": "OPEN", "issue_type": "Task"}, + ] + prs = [ + { + "number": 10, + "title": "Change a default", + "state": "MERGED", + "closing_issues": [1, 3], + } + ] + responses = { + ( + "issues", + "2.19.0", + "--state", + "all", + "--include-tasks", + "--include-rejected", + ): issues, + ("prs", "--milestone", "2.19.0", "--state", "all"): prs, + ("issue", "1", "3", "4"): [ + {**issues[0], "body": "", "parent": None}, + {"number": 3, "milestone": "2.18.0"}, + {"number": 4, "error": "not_found"}, + ], + ("prs", "11"): [{"number": 11, "state": "OPEN"}], + ("comments", "1"): [ + {"issue": 1, "body": "## Breaking change note\n\nNote."} + ], + ("advisories", "--patched-version", "2.19.0"): [], + } + content = ( + "## 2.19.0\n\n[#4](https://github.com/penpot/penpot/issues/4)\n\n" + "## 2.18.0\n\n[#1](https://github.com/penpot/penpot/issues/1)\n" + ) + with tempfile.TemporaryDirectory() as tmp: + changes = pathlib.Path(tmp) / "CHANGES.md" + changes.write_text(content) + snapshot_path = pathlib.Path(tmp) / "snapshot.json" + args = argparse.Namespace(milestone="2.19.0", changes=str(changes)) + out = io.StringIO() + with ( + patch.object( + ch, "run_gh_py", side_effect=lambda *a: json.dumps(responses[a]) + ) as gh, + contextlib.redirect_stdout(out), + ): + ch.cmd_collect(args) + snapshot = json.loads(out.getvalue()) + self.assertCountEqual([call.args for call in gh.call_args_list], responses) + self.assertEqual(changes.read_text(), content) + self.assertEqual(snapshot["eligible_issues"], [1]) + self.assertEqual(snapshot["comparison"]["missing_issues"], []) + self.assertEqual( + snapshot["comparison"]["issues_in_other_versions"], {"1": ["2.18.0"]} + ) + self.assertEqual(snapshot["comparison"]["ineligible_references"], [4]) + self.assertEqual(snapshot["comparison"]["unlisted_merged_prs"], [10]) + + snapshot_path.write_text(out.getvalue()) + changes.write_text( + content.replace( + "## 2.19.0\n\n", + "## 2.19.0\n\n[#10](https://github.com/penpot/penpot/pull/10)\n\n", + ) + ) + args.snapshot = str(snapshot_path) + args.write = False + args.output = str(pathlib.Path(tmp) / "report.md") + out = io.StringIO() + with ( + patch.object( + ch, + "run_gh_py", + side_effect=AssertionError("unexpected GitHub lookup"), + ), + contextlib.redirect_stdout(out), + ): + ch.cmd_boom(args) + ch.cmd_security(args) + ch.cmd_dev_only_bugs(argparse.Namespace(**vars(args), apply=False)) + ch.cmd_cross_ref(args) + ch.cmd_report(args) + self.assertIn("Note.", out.getvalue()) + self.assertIn("pull/10", out.getvalue()) + self.assertNotIn("pull/11", out.getvalue()) + self.assertIn("PRs in milestone but NOT in changelog: 0", out.getvalue()) + self.assertTrue(pathlib.Path(args.output).is_file()) + + def test_snapshot_for_another_milestone_is_rejected(self): + with tempfile.TemporaryDirectory() as tmp: + snapshot = pathlib.Path(tmp) / "snapshot.json" + snapshot.write_text('{"milestone": "2.18.0"}') + args = argparse.Namespace(milestone="2.19.0", snapshot=str(snapshot)) + with self.assertRaisesRegex(SystemExit, "expected milestone 2.19.0"): + ch.load_snapshot(args) + + class ReportTests(unittest.TestCase): """Focused check of the `:boom:` sync anomaly (type G) in the report.""" From eb0106e6fb100da60089129f77da7c84681ef708 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 23 Nov 2026 08:45:48 +0000 Subject: [PATCH 5/6] :sparkles: Simplify changelog review and report label edits Keep the release procedure in one place and separate review from GitHub writes. Clarify how to prepare and verify release highlights. Report each successful label edit so earlier changes remain visible if a later edit fails. AI-assisted-by: gpt-6.2-sol --- .agents/skills/update-changelog/SKILL.md | 64 ++----------------- .serena/memories/scripts/changelog.md | 2 +- .../memories/workflow/updating-changelog.md | 57 +++++++++++------ scripts/changelog.py | 28 ++++++-- scripts/test_changelog.py | 40 ++++++++++++ 5 files changed, 111 insertions(+), 80 deletions(-) diff --git a/.agents/skills/update-changelog/SKILL.md b/.agents/skills/update-changelog/SKILL.md index 97ba1bcd20..db876798f9 100644 --- a/.agents/skills/update-changelog/SKILL.md +++ b/.agents/skills/update-changelog/SKILL.md @@ -5,62 +5,12 @@ description: Update the project CHANGES.md with issues from a given GitHub miles # Skill: update-changelog -Entry point for all changelog work. All rules — sections, exclusions, entry -format, the `:boom:`, `:rocket:` and `:lock:` contracts, pre-flight, and the -anomaly report — live in `mem:workflow/updating-changelog` (file: -`.serena/memories/workflow/updating-changelog.md`). This skill routes to that -memory; it does not repeat it. +Use this skill to prepare, refresh, or audit a changelog version. -## When to Use +Read `mem:workflow/updating-changelog` for the rules and follow its **Flow**: +collect, review, write, verify. Start with `collect ` and keep its +JSON snapshot in a private temporary file. Reuse it for the review and checks; +collect again if the GitHub data changes. -- Before a new release, to populate the changelog with all fixed issues -- When new issues are added to an existing milestone and the changelog needs - to be refreshed -- To audit or repair an existing version section - -## Prerequisites - -- `gh` CLI authenticated (`gh auth status`) -- Python 3.8+ -- `scripts/gh.py` for GitHub queries, `scripts/changelog.py` for changelog - checks (run `python3 scripts/changelog.py --help` for usage) - -## What to Read - -1. `mem:workflow/updating-changelog` — the canonical flow: sources of truth, - layout, entry rules, the `## Breaking change note` comment contract, the - advisory (`:lock:`) contract, pre-flight checks, anomaly types, and pitfalls. -2. `mem:scripts/changelog` — `collect`, `boom`, `security`, `check-merged`, `cross-ref`, - `dev-only-bugs`, `report`. -3. `mem:scripts/gh` — `issues`, `issue`, `comments`, `prs`, `advisories`. - -## Commands - -```bash -snapshot=$(mktemp) -python3 scripts/changelog.py collect "" > "$snapshot" -``` - -Review the JSON before running any of these commands: - -```bash -python3 scripts/changelog.py dev-only-bugs "" --snapshot "$snapshot" --apply -python3 scripts/changelog.py boom "" --snapshot "$snapshot" --write -python3 scripts/changelog.py security "" --snapshot "$snapshot" --write -python3 scripts/changelog.py cross-ref "" --snapshot "$snapshot" -python3 scripts/changelog.py report "" --snapshot "$snapshot" -``` - -Keep the snapshot private: it can contain unpublished advisories and PR text. -Run `collect` first and use the JSON for review and -merge-state checks. Run `collect` again after any GitHub change, including -`dev-only-bugs --apply`. Use `--apply` only when there are sure cases. - -## Hard Rules - -- `CHANGES.md` is edited only on explicit request or during the release process. -- Only closed, non-excluded milestone issues are included; the issue is the changelog unit and the PR is inline. -- `:boom:` and `:rocket:` are label-generated and `:lock:` is advisory-generated: never hand-edit them; edit the label, the `## Breaking change note` comment or the advisory and re-run the command. -- Verify PR merge status before writing; only merged PRs are referenced. -- Bugs that never reached production stay out: `dev-only-bugs --apply` labels the sure ones; candidates are the user's call, never label them yourself. -- Fill `patched_versions` in the advisories before running `security`; unpublished advisories are valid. +Keep review read-only. Follow the separate `--apply` branch only when the +workflow calls for it. diff --git a/.serena/memories/scripts/changelog.md b/.serena/memories/scripts/changelog.md index 382cd983ce..d4a185d210 100644 --- a/.serena/memories/scripts/changelog.md +++ b/.serena/memories/scripts/changelog.md @@ -10,7 +10,7 @@ - `boom [--changes CHANGES.md --write]` — generate `### :boom: Breaking changes & Deprecations` from the closed, non-excluded milestone issues labelled `breaking change`, sorted by issue number. Each issue becomes a `#### ` block: content = body of the issue's last `## Breaking change note` comment (whole markdown, headings demoted to `#####` outside code fences; fallback = heading plus refs with a stderr warning), refs = issue link plus merged closing PRs on their own line, with `(by @author)` for `community contribution`. `--write` replaces only that subsection of the version, inserts it after the version header when needed, and removes it when there are no entries. Print-only by default. Uses `gh.py comments`. - `security [--changes CHANGES.md --write]` — generate `### :lock: Security fixes` from the advisories whose `patched_versions` include the version (via `gh.py advisories --patched-version`), sorted by GHSA id. Entry: `- Fix () (PR: [#N](...))`; description = `Fix` + advisory summary, first word decapitalized unless it starts with an acronym; PRs = merged milestone PRs labelled `pr pt` whose body contains the GHSA id, comma-separated, and no PR is legal. Warns on stderr when a `pr pt` PR references an advisory with no matching `patched_versions`. `--write` replaces only that subsection, placed after `:rocket:` (or `:boom:`, or the version header when neither exists); empty entries remove the subsection; idempotent. Print-only by default. - `cross-ref [--changes CHANGES.md]` — fetch milestone PRs with `--state all` once, report merged PRs missing from the version section plus CLOSED (unmerged) warnings. PR links inside `:lock:` entries count as referenced; advisory URLs never appear here by design. -- `dev-only-bugs [--apply]` — list closed milestone bugs that never reached production, without `no changelog`. Sure: parent issue is a `Feature`/`Enhancement` of the same milestone; `--apply` adds `no changelog` to these only. Candidates (never labelled automatically): parent is an epic of the milestone, `regression` label, or the "Affected versions" / "Environment" body field names only hourly, develop, staging, PRE or the milestone version itself (`only_unreleased_envs`; any production hint or other version keeps the bug in — versions compare as full semver with missing patch = 0, so for milestone 2.19.2 the released 2.19.0 keeps the bug in). Reads `body` and `parent` from one batched `gh.py issue` lookup. +- `dev-only-bugs [--apply]` — list closed milestone bugs that never reached production, without `no changelog`. Sure: parent issue is a `Feature`/`Enhancement` of the same milestone; `--apply` adds `no changelog` to these only and prints each successful edit to stdout with its issue URL and reason. On failure it exits nonzero and names the failed issue on stderr; earlier confirmations remain visible. Candidates (never labelled automatically): parent is an epic of the milestone, `regression` label, or the "Affected versions" / "Environment" body field names only hourly, develop, staging, PRE or the milestone version itself (`only_unreleased_envs`; any production hint or other version keeps the bug in — versions compare as full semver with missing patch = 0, so for milestone 2.19.2 the released 2.19.0 keeps the bug in). Reads `body` and `parent` from one batched `gh.py issue` lookup. - `report [--changes CHANGES.md --output CHANGES-ISSUES.md]` — overwrite the anomaly report: A/B milestone mismatches, E `:boom:` entry without the label, F `:rocket:` sync, G `:boom:` sync, plus the C/D `:rocket:` gaps and the `dev-only-bugs` lists (warnings). `:boom:`/`:rocket:` rule violations are fixed by regenerating or relabelling, not by editing entries in place. ## Conventions diff --git a/.serena/memories/workflow/updating-changelog.md b/.serena/memories/workflow/updating-changelog.md index fcb8245761..c8b48b29b8 100644 --- a/.serena/memories/workflow/updating-changelog.md +++ b/.serena/memories/workflow/updating-changelog.md @@ -29,7 +29,7 @@ Editing `CHANGES.md` happens only on explicit request or as part of the release - **Two labels override the Issue Type**: `breaking change` → an entry only under `:boom:`, never in its regular section; `release highlight` → an extra entry under `:rocket:` on top of its regular entry. - **Only closed issues**. An open issue in the milestone is not generated, even if someone added a provisional entry by hand before the merge. - **Excluded issues**: `no changelog`, `Task` issue type, `Rejected` project status. `release blocker` is not a changelog filter. -- **Bugs that never reached production** stay out: a bug found and fixed while building a feature of the same, unreleased version never affected users. The team rarely labels them, so the flow finds them with `dev-only-bugs` and labels them `no changelog` (section 8, step 3). +- **Bugs that never reached production** stay out: a bug found and fixed while building a feature of the same, unreleased version never affected users. The flow finds these bugs and labels the sure cases `no changelog` (section 8, Review). - **Excluded PRs**: a PR with `no issue required` does not bring an entry of its own. - **An issue with no milestone** belongs to another (probably private) project: it is neither changelog candidate nor anomaly. @@ -140,7 +140,7 @@ Rules for the note: - Lists exactly the milestone issues with the `release highlight` label, and nothing else. Product decides highlights by labelling issues; a regeneration cannot undo that choice. - Every entry copies the text and references of the issue's regular entry and MUST carry both an issue link and a PR reference. - If no issue is labelled, leave the section out; do not pick highlights yourself. -- Never edit `:rocket:` by hand: add or remove the label and regenerate. +- No command generates `:rocket:` today. Build it from the eligible labelled issues in the snapshot, using their regular entries, and verify it with `report`. Change the label on GitHub to change which issues appear; do not pick highlights in the changelog. ## 7. `:lock:`: security fixes @@ -157,20 +157,41 @@ Generated from the advisories that declare the version in `patched_versions`; ne ## 8. Flow -1. **Confirm the version** (a semver string such as `2.19.0`) with the user when it is not obvious. -2. **Collect the release inputs**: `python3 scripts/changelog.py collect "" > "$snapshot"`. Use a private temporary file because the JSON can contain unpublished advisories and PR text. It contains the milestone issues and PRs, batched related records, generated-section inputs, dev-only bug candidates and a comparison with the current changelog. Use `eligible_issues` for changelog candidates and `comparison` for pre-flight. Collection does not write to the changelog or GitHub. -3. **Keep out bugs that never reached production**: review `dev_only_bugs` in the snapshot. If `auto` has entries, run `python3 scripts/changelog.py dev-only-bugs "" --snapshot "$snapshot" --apply` to label the sure ones `no changelog` on GitHub, then repeat step 2. The label puts the decision on the issue, so it survives a regeneration. - - **Sure**: a bug whose parent issue is a `Feature` or `Enhancement` of the same milestone. `--apply` labels these. - - **Candidates**: a bug whose parent is an epic of the same milestone, that carries the `regression` label, or whose "Affected versions" / "Environment" field names only hourly, develop, staging, PRE or the milestone version itself. `regression` also marks regressions users hit in production, and the field says where the bug was seen, not since when it exists, so never label these yourself: show them to the user, who labels the ones they confirm. The anomaly report lists them too (section 10). -4. **Resolve PR links** using `prs` and `related_prs` in the snapshot. Look up a PR separately only if you discover a candidate not already in the snapshot. -5. **Categorize** by Issue Type and the two labels (section 2), and **build the descriptions** (section 4). -6. **Verify PR merge status** before writing: only include PRs with state `MERGED` in the snapshot or verified by `check-merged` if looked up separately. If a closing PR was closed unmerged, look for the PR that superseded it. -7. **Reconcile the existing text** (section 9). -8. **Generate `:boom:`**: `python3 scripts/changelog.py boom "" --snapshot "$snapshot"` prints the section; add `--write` to update just that subsection in `CHANGES.md`. If there are no entries, `--write` removes the subsection or leaves it absent. -9. **Generate `:rocket:`** from the `release highlight` label (section 6). -10. **Generate `:lock:`**: `python3 scripts/changelog.py security "" --snapshot "$snapshot"` prints the section; add `--write` to replace it in `CHANGES.md`. The contract lives in section 7. -11. **Cross-check PRs**: `python3 scripts/changelog.py cross-ref "" --snapshot "$snapshot"`. It compares the snapshot against the updated changelog, lists missing merged PRs and warns about closed (unmerged) PRs. PRs linked from `:lock:` count as referenced; an advisory with no PR is invisible here by design. -12. **Generate the anomaly report**: `python3 scripts/changelog.py report "" --snapshot "$snapshot"`. It reads the updated changelog and overwrites `CHANGES-ISSUES.md` (section 10). If you need the report to resolve a new reference not known to the snapshot, collect again first. +### Collect + +- Confirm the version if unclear. Use an authenticated `gh` CLI and a private temporary file: the snapshot can contain unpublished advisories and PR text. + +```bash +snapshot=$(mktemp) +python3 scripts/changelog.py collect "" > "$snapshot" +``` + +- Use the same snapshot throughout. Collect again if GitHub data changes or if the final report needs to resolve a new reference absent from the snapshot. + +### Review + +- Use `eligible_issues` to select entries, `comparison` to reconcile the current text (section 9), and `prs` and `related_prs` to verify links. Reference only `MERGED` PRs. If a closing PR was closed unmerged, look for its replacement; use `check-merged` for PRs looked up outside the snapshot. +- Review `dev_only_bugs`. A bug with a `Feature` or `Enhancement` parent in the same milestone is a sure case (`auto`). An epic parent in the same milestone, a `regression` label, or an unreleased-only environment is only a hint (`suggested`). Show candidates to the user, who labels the ones they confirm. +- **Separate GitHub write, only if there are sure cases:** `python3 scripts/changelog.py dev-only-bugs "" --snapshot "$snapshot" --apply` adds `no changelog` to `auto` issues and prints each successful edit to stdout. If a later edit fails, earlier edits still stand. Collect again after applying labels before proceeding. + +### Write + +- Update only on explicit request or during a release. Categorize and draft entries using sections 2–4. Build `:rocket:` from `release highlight` as described in section 6. +- Use the generators for `:boom:` and `:lock:` (sections 5 and 7). Omit `--write` to preview; use it only after the version header exists. + +```bash +python3 scripts/changelog.py boom "" --snapshot "$snapshot" --write +python3 scripts/changelog.py security "" --snapshot "$snapshot" --write +``` + +### Verify + +- `cross-ref` shows missing merged PRs and warns about closed, unmerged PRs. `report` checks the updated changelog and overwrites `CHANGES-ISSUES.md` (section 10). + +```bash +python3 scripts/changelog.py cross-ref "" --snapshot "$snapshot" +python3 scripts/changelog.py report "" --snapshot "$snapshot" +``` ## 9. Pre-flight: reconcile before writing @@ -198,7 +219,7 @@ Start from a fresh `collect` snapshot. Refresh it if GitHub changes during revie - **C — released X.Y.0 version without a `:rocket:` section** (gap; patches never carry highlights). - **D — `:rocket:` entry without issue AND PR references** (gap). -**Bugs that may never have reached production** are warnings too (section 8, step 3): sub-issues of a milestone feature still unlabelled (run `dev-only-bugs --apply`) and candidates for the user to confirm. They never count toward the total. +**Bugs that may never have reached production** are warnings too (section 8, Review): sure cases still unlabelled and candidates for the user to confirm. They never count toward the total. Anything else is a rule violation, not a report item: fix it in the pre-flight and re-run. @@ -208,7 +229,7 @@ Anything else is a rule violation, not a report item: fix it in the pre-flight a - **Labels, not emoji**: title prefixes are cosmetic and often missing; the section comes from Issue Type and the two labels. - **Taiga references**: old entries link to Taiga. Resolve them to the GitHub issue via the description text or the PRs that mention the Taiga URL, then link issue and PR. - **Long-lived links only**: runbooks and docs referenced from a note must point to `staging` or `main`, never to a feature branch that will be deleted. -- **Generated sections**: `:boom:`, `:rocket:` and `:lock:` are generated. Never patch them by hand; edit the label, the note comment or the advisory and re-run. +- **Generated sections**: use `boom` and `security` for `:boom:` and `:lock:`. Change the label, note or advisory on GitHub rather than patching their output. For `:rocket:`, follow the label-driven workflow in section 6. - **Deleted or transferred issues**: an issue referenced in the changelog that returns 410/404 (deleted or moved out of the repo) must lose its entry in the pre-flight. Its security fixes, if any, stay in `:lock:` through the advisory. ## 12. Where the code is diff --git a/scripts/changelog.py b/scripts/changelog.py index 6c7dc84952..dd3ccd9560 100644 --- a/scripts/changelog.py +++ b/scripts/changelog.py @@ -765,10 +765,30 @@ def cmd_dev_only_bugs(args: argparse.Namespace) -> None: if args.apply: for e in auto: - subprocess.run( - ["gh", "issue", "edit", str(e["issue"]), "--repo", REPO, - "--add-label", "no changelog"], - check=True, capture_output=True, + url = issue_url(e["issue"]) + try: + subprocess.run( + [ + "gh", + "issue", + "edit", + str(e["issue"]), + "--repo", + REPO, + "--add-label", + "no changelog", + ], + check=True, + capture_output=True, + text=True, + ) + except subprocess.CalledProcessError as err: + detail = (err.stderr or "").strip() + detail = detail or f"gh exited with status {err.returncode}" + sys.exit(f"ERROR: could not apply `no changelog` to {url}: {detail}") + print( + f"Applied `no changelog`: {url} ({e['reason']})", + flush=True, ) print(f"Labelled {len(auto)} issues `no changelog`", file=sys.stderr) diff --git a/scripts/test_changelog.py b/scripts/test_changelog.py index 6c6d2aaab9..2d31e6e8ec 100644 --- a/scripts/test_changelog.py +++ b/scripts/test_changelog.py @@ -844,5 +844,45 @@ class FindDevOnlyBugsTests(unittest.TestCase): self.assertEqual([e["issue"] for e in suggested], [3, 5, 9]) +class DevOnlyBugsApplyTests(unittest.TestCase): + def test_reports_only_successful_edits_if_a_later_edit_fails(self): + snapshot = { + "dev_only_bugs": { + "auto": [ + { + "issue": 1, + "issue_title": "First bug", + "reason": "Same milestone", + }, + { + "issue": 2, + "issue_title": "Second bug", + "reason": "Same milestone", + }, + ], + "suggested": [], + } + } + args = argparse.Namespace(milestone="2.19.0", apply=True) + out = io.StringIO() + with ( + patch.object(ch, "load_snapshot", return_value=snapshot), + patch.object( + ch.subprocess, + "run", + side_effect=[None, ch.subprocess.CalledProcessError(1, "gh")], + ), + contextlib.redirect_stdout(out), + self.assertRaisesRegex(SystemExit, r"could not apply .*issues/2"), + ): + ch.cmd_dev_only_bugs(args) + + self.assertIn( + "Applied `no changelog`: https://github.com/penpot/penpot/issues/1", + out.getvalue(), + ) + self.assertNotIn("https://github.com/penpot/penpot/issues/2", out.getvalue()) + + if __name__ == "__main__": unittest.main(verbosity=2) From 1177a817ed10f95d3df5ce33d0aa67eba16f863b Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 23 Nov 2026 08:50:58 +0000 Subject: [PATCH 6/6] :books: Update the changelog for 2.19.4 Document the fix for importing large .penpot files in Chrome. AI-assisted-by: gpt-6.2-sol --- CHANGES.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 667be70bf0..5d0b4cb3aa 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,11 @@ # CHANGELOG +## 2.19.4 + +### :bug: Bugs fixed + +- Fix importing large `.penpot` files in Chrome [#13165](https://github.com/penpot/penpot/issues/13165) (PR: [#13183](https://github.com/penpot/penpot/pull/13183)) + ## 2.19.3 ### :bug: Bugs fixed