Hub 2.23.0: release requirements carry forward

A release needs what every earlier release of its product needed (the
highest version per product), so "requires accounts 1.7.0" is written
once in WHATS-NEW.md. Fixes New install -> Website 1.0.1 sending a
Website-only install job: its heading didn't repeat 1.0.0's requirement,
so Accounts wasn't installed first and the agent refused the job.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-26 15:08:48 +02:00
co-authored by Claude Opus 5.5
parent 5ed8cad6a1
commit d5fa11f50f
7 changed files with 84 additions and 10 deletions
+27 -3
View File
@@ -3,7 +3,7 @@
* (Releases page): a repository, a tag prefix and a notes file. Every tag `<prefix>1.2.3` is a
* release of that product, dated by its commit; the notes come from the notes file on the
* repository's default branch ("## 1.2.3" sections; "urgent" or "security" in the heading marks an
* urgent release, "requires accounts 1.2.0" a requirement). Notes only attach to tagged versions,
* urgent release, "requires accounts 1.2.0" a requirement, which every later release keeps). Notes only attach to tagged versions,
* so a section written ahead of a release stays hidden until it's tagged, and a note can be
* corrected after release without a new version. Runs every 15 minutes and from "Sync now".
*
@@ -18,6 +18,7 @@
const prisma = require('../config/db');
const { getSettings, setSettings, releaseRepoToken } = require('./settings');
const { syncLatestVersion } = require('./releases');
const { compareVersions } = require('./alerts');
const { PRODUCTS, PRODUCT_NAMES, isProduct } = require('./products');
const TIMEOUT_MS = 20000;
@@ -188,6 +189,27 @@ async function fetchTags(repo, token) {
return tags;
}
/**
* Hub 2.23.0: requirements carry forward. A release needs what every earlier release of the product
* needed (the highest version per product), as well as what its own heading says, so "— requires
* accounts 1.7.0" is written once, on the release that first needs it. A later heading can raise a
* requirement but never lower or drop one. `tagged` is Map(version → { requires }); returns
* Map(version → requires) in the same order as `tagged`.
*/
function inheritRequirements(tagged) {
const byVersion = [...tagged.keys()].sort(compareVersions);
const carried = new Map();
const out = new Map();
for (const version of byVersion) {
for (const r of tagged.get(version).requires || []) {
const had = carried.get(r.product);
if (!had || compareVersions(r.version, had) > 0) carried.set(r.product, r.version);
}
out.set(version, [...carried].map(([product, v]) => ({ product, version: v })));
}
return new Map([...tagged.keys()].map(v => [v, out.get(v)]));
}
const sameRequires = (a, b) => JSON.stringify(a || []) === JSON.stringify(b || []);
const sourceLabel = s => `${targetName(s.product)} (${parseRepoUrl(s.repo)?.repo || s.repo}, ${s.tagPrefix || 'no prefix'}1.2.3)`;
@@ -259,7 +281,9 @@ async function syncReleases() {
const table = agentOnly ? prisma.agentRelease : prisma.release;
const tagged = found[product] || new Map();
const existing = new Map((await table.findMany(agentOnly ? {} : { where: { product } })).map(r => [r.version, r]));
for (const [version, t] of tagged) {
const inherited = agentOnly ? null : inheritRequirements(tagged);
for (const [version, tag] of tagged) {
const t = agentOnly ? tag : { ...tag, requires: inherited.get(version) };
const had = existing.get(version);
const requires = agentOnly ? {} : { requires: t.requires };
if (!had) {
@@ -290,4 +314,4 @@ async function syncReleases() {
return { sources: counts, added, updated, removed, latest, problems };
}
module.exports = { PLATFORM_REPO, AGENT, agentSource, targetName, gitGet: get, parseRepoUrl, parseNotes, parseRequirements, plainNotes, tagPattern, defaultSources, cleanSources, releaseSources, syncReleases };
module.exports = { PLATFORM_REPO, AGENT, agentSource, targetName, gitGet: get, parseRepoUrl, parseNotes, parseRequirements, inheritRequirements, plainNotes, tagPattern, defaultSources, cleanSources, releaseSources, syncReleases };