Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

Reconcile reporter writeback across skipped and failed releases (#4982)

Andrew Mikofalvyfc441e2520a7
diff --git a/.github/scripts/published-release-tags.mjs b/.github/scripts/published-release-tags.mjs
index 1690b8803..18256b9f3 100644
--- a/.github/scripts/published-release-tags.mjs
+++ b/.github/scripts/published-release-tags.mjs
@@ -4,6 +4,13 @@ import { execFileSync } from 'node:child_process';
const STABLE_TAG_RE = /^v(\d+)\.(\d+)\.(\d+)$/;
const BETA_TAG_RE = /^v(\d+)\.(\d+)\.(\d+)-beta\.(\d+)$/;
+export function deriveChannel(raw) {
+ const tag = String(raw ?? '').trim();
+ if (STABLE_TAG_RE.test(tag)) return 'stable';
+ if (BETA_TAG_RE.test(tag)) return 'beta';
+ return null;
+}
+
function releaseTagKey(raw) {
const line = String(raw).trim();
const stable = STABLE_TAG_RE.exec(line);
diff --git a/.github/scripts/write-back-gate.mjs b/.github/scripts/write-back-gate.mjs
index 155dd41ac..739c375b5 100644
--- a/.github/scripts/write-back-gate.mjs
+++ b/.github/scripts/write-back-gate.mjs
@@ -1,6 +1,9 @@
-const GITHUB_ISSUE_RE = /^https?:\/\/(?:www\.)?github\.com\/([^/]+)\/([^/]+)\/issues\/(\d+)(?:[/?#].*)?$/i;
-const GITHUB_PULL_RE = /^https?:\/\/(?:www\.)?github\.com\/([^/]+)\/([^/]+)\/pull\/(\d+)(?:[/?#].*)?$/i;
-const GITHUB_COMMIT_RE = /^https?:\/\/(?:www\.)?github\.com\/([^/]+)\/([^/]+)\/commit\/([0-9a-f]{7,40})(?:[/?#].*)?$/i;
+const GITHUB_ISSUE_RE =
+ /^https?:\/\/(?:www\.)?github\.com\/([^/]+)\/([^/]+)\/issues\/(\d+)(?:[/?#].*)?$/i;
+const GITHUB_PULL_RE =
+ /^https?:\/\/(?:www\.)?github\.com\/([^/]+)\/([^/]+)\/pull\/(\d+)(?:[/?#].*)?$/i;
+const GITHUB_COMMIT_RE =
+ /^https?:\/\/(?:www\.)?github\.com\/([^/]+)\/([^/]+)\/commit\/([0-9a-f]{7,40})(?:[/?#].*)?$/i;
const DISCORD_THREAD_RE =
/^https?:\/\/(?:(?:canary|ptb)\.)?discord(?:app)?\.com\/channels\/(\d+|@me)\/(\d+)(?:\/(\d+))?(?:[/?#].*)?$/i;
const SLACK_ARCHIVE_RE = /^https?:\/\/[^/]*\.slack\.com\/archives\//i;
@@ -127,7 +130,8 @@ export function highestVersion(versions) {
export function evaluateFanIn({ ticket, descendants = [], resolveVersion, log = () => {} }) {
if (!ticket?.identifier) throw new Error('evaluateFanIn needs a ticket with an identifier');
- if (typeof resolveVersion !== 'function') throw new Error('evaluateFanIn needs a resolveVersion function');
+ if (typeof resolveVersion !== 'function')
+ throw new Error('evaluateFanIn needs a resolveVersion function');
const considered = descendants.length > 0 ? descendants : [ticket];
@@ -207,6 +211,7 @@ export function composeReply({
originChannel,
coverage = [],
channel = 'stable',
+ recoveryFrom = [],
}) {
const normalizedVersion = String(version ?? '')
.trim()
@@ -223,36 +228,41 @@ export function composeReply({
const prose = body || title;
if (!prose) return null;
- const lines = [openingLine(channel, normalizedVersion)];
+ const lines = [
+ ...(recoveryFrom.length > 0
+ ? [
+ `Correction to our earlier update: the release${recoveryFrom.length === 1 ? '' : 's'} we linked (${recoveryFrom.map((v) => `v${v}`).join(', ')}) ${recoveryFrom.length === 1 ? 'is' : 'are'} not available to download.`,
+ '',
+ ]
+ : []),
+ openingLine(channel, normalizedVersion),
+ ];
if (coverage.length > 0) {
lines.push('', `Covers ${[...coverage].sort().join(', ')}.`);
}
- lines.push('', updateInstruction(originChannel, channel));
+ lines.push('', updateInstruction(originChannel, channel, normalizedVersion));
return lines.join('\n');
}
-function updateInstruction(originChannel, channel = 'stable') {
+function updateInstruction(originChannel, channel, version) {
const lead =
channel === 'beta'
? 'Read the notes and download the beta on'
: 'To pick it up, update to the latest desktop app. The notes are on';
- const tail =
- channel === 'beta'
- ? " once the beta's installers have finished uploading."
- : ' once the release finishes publishing.';
+ const url = `${RELEASES_URL}/tag/v${version}`;
if (originChannel === 'discord-thread') {
- return `${lead} <${RELEASES_URL}>${tail}`;
+ return `${lead} <${url}>.`;
}
- return `${lead} [the releases page](${RELEASES_URL})${tail}`;
+ return `${lead} [the release page](${url}).`;
}
function openingLine(channel, version) {
if (channel === 'beta') {
return (
- `This is fixed, and it is going out now on the Open Knowledge beta channel as v${version}. ` +
+ `This fix is available in Open Knowledge beta v${version}. ` +
'Thanks for the report. It will reach the stable channel in an upcoming release, ' +
'and we will follow up here when it does.'
);
diff --git a/.github/scripts/write-back-gate.test.mjs b/.github/scripts/write-back-gate.test.mjs
index 92d5882bb..9d2e1e529 100644
--- a/.github/scripts/write-back-gate.test.mjs
+++ b/.github/scripts/write-back-gate.test.mjs
@@ -4,14 +4,15 @@ import {
compareVersions,
composeReply,
evaluateFanIn,
- isOriginRepliableFrom,
highestVersion,
+ isOriginRepliableFrom,
partitionAttachments,
} from './write-back-gate.mjs';
const GH_ISSUE = 'https://github.com/inkeep/open-knowledge/issues/769';
const GH_PULL = 'https://github.com/inkeep/agents-private/pull/2844';
-const GH_COMMIT = 'https://github.com/inkeep/agents-private/commit/da71f0c698ccaac11da915169ca6c7d585d5eb97';
+const GH_COMMIT =
+ 'https://github.com/inkeep/agents-private/commit/da71f0c698ccaac11da915169ca6c7d585d5eb97';
const DISCORD_THREAD = 'https://discord.com/channels/1234567890/9876543210/1122334455';
const SLACK_ARCHIVE = 'https://inkeep.slack.com/archives/C016VCYCL74/p1727122965001469';
const LINEAR_UPLOAD = 'https://uploads.linear.app/abc/def/diagnostics.zip';
@@ -259,7 +260,12 @@ describe('reply composition', () => {
const CHANGESET = changesetFrom(CHANGESET_BODY);
const compose = (overrides = {}) =>
- composeReply({ changeset: CHANGESET, version: 'v0.36.0', originChannel: 'github-issue', ...overrides });
+ composeReply({
+ changeset: CHANGESET,
+ version: 'v0.36.0',
+ originChannel: 'github-issue',
+ ...overrides,
+ });
test('the reply names the version', () => {
expect(compose()).toContain('v0.36.0');
@@ -274,17 +280,21 @@ describe('reply composition', () => {
test('a multi-paragraph changeset reaches the reader as a link, not as paragraphs', () => {
const text = compose({
changeset: changesetFrom(
- 'Messages you send now carry their own actions:\n\n- Resend to a different agent.\n- Copy and edit.'
+ 'Messages you send now carry their own actions:\n\n- Resend to a different agent.\n- Copy and edit.',
),
});
expect(text).not.toContain('Messages you send now carry their own actions:');
expect(text).not.toContain('Resend to a different agent.');
- expect(text).toContain('[the releases page](https://github.com/inkeep/open-knowledge/releases)');
+ expect(text).toContain(
+ '[the release page](https://github.com/inkeep/open-knowledge/releases/tag/v0.36.0)',
+ );
});
- test('the reply links the releases index, never a tag page still in draft when it posts', () => {
- expect(compose()).not.toContain('/releases/tag/');
- expect(compose({ channel: 'beta', version: 'v0.36.0-beta.1' })).not.toContain('/releases/tag/');
+ test('the reply links the verified published release instead of promising a pending upload', () => {
+ expect(compose()).toContain('/releases/tag/v0.36.0');
+ expect(compose({ channel: 'beta', version: 'v0.36.0-beta.1' })).toContain(
+ '/releases/tag/v0.36.0-beta.1',
+ );
});
test('the reply lists every contributing ticket in sorted order', () => {
@@ -296,18 +306,20 @@ describe('reply composition', () => {
expect(compose({ coverage: ['PRD-7539'] })).toContain('Covers PRD-7539.');
});
- test('the stable instruction hedges on the draft window the reply posts inside', () => {
- expect(compose()).toContain('once the release finishes publishing');
- expect(compose({ channel: 'beta', version: 'v0.36.0-beta.1' })).toContain(
- "once the beta's installers have finished uploading"
+ test('the publication boundary makes upload hedges obsolete', () => {
+ expect(compose()).not.toContain('once the release finishes publishing');
+ expect(compose({ channel: 'beta', version: 'v0.36.0-beta.1' })).not.toContain(
+ "once the beta's installers have finished uploading",
);
});
test('the update instruction is channel-appropriate', () => {
const gh = compose({ originChannel: 'github-issue' });
const discord = compose({ originChannel: 'discord-thread' });
- expect(gh).toContain('[the releases page](https://github.com/inkeep/open-knowledge/releases)');
- expect(discord).toContain('<https://github.com/inkeep/open-knowledge/releases>');
+ expect(gh).toContain(
+ '[the release page](https://github.com/inkeep/open-knowledge/releases/tag/v0.36.0)',
+ );
+ expect(discord).toContain('<https://github.com/inkeep/open-knowledge/releases/tag/v0.36.0>');
});
test('the update instruction names the desktop app and nothing else', () => {
@@ -449,12 +461,12 @@ describe('the two channels say different things', () => {
channel: 'beta',
});
expect(text).toContain('v0.59.0-beta.2');
- expect(text).toContain('going out now on the Open Knowledge beta channel');
+ expect(text).toContain('available in Open Knowledge beta');
expect(text).toContain('follow up here');
expect(text).not.toContain('update to the latest');
expect(text).toContain('download the beta');
expect(text).not.toMatch(/available now|download it now/i);
- expect(text).toContain('installers have finished uploading');
+ expect(text).not.toContain('installers have finished uploading');
});
test('a Discord beta reply wraps the URL so it does not expand into an embed', () => {
@@ -464,7 +476,9 @@ describe('the two channels say different things', () => {
originChannel: 'discord-thread',
channel: 'beta',
});
- expect(text).toMatch(/<https:\/\/github\.com\/inkeep\/open-knowledge\/releases>/);
+ expect(text).toContain(
+ '<https://github.com/inkeep/open-knowledge/releases/tag/v0.59.0-beta.2>',
+ );
});
test('a channel that is neither refuses rather than composing a reply in the wrong voice', () => {
diff --git a/.github/scripts/write-back-policy.json b/.github/scripts/write-back-policy.json
new file mode 100644
index 000000000..00eb918fb
--- /dev/null
+++ b/.github/scripts/write-back-policy.json
@@ -0,0 +1,6 @@
+{
+ "minimumVersion": {
+ "stable": "0.77.6",
+ "beta": "0.77.8-beta.0"
+ }
+}
diff --git a/.github/scripts/write-back-recovery.test.mjs b/.github/scripts/write-back-recovery.test.mjs
new file mode 100644
index 000000000..53abcf88b
--- /dev/null
+++ b/.github/scripts/write-back-recovery.test.mjs
@@ -0,0 +1,248 @@
+import { expect, test } from 'vitest';
+import {
+ createVersionFor,
+ makeReleaseWindow,
+ notificationMarkerUrl,
+ runWriteBack,
+ unavailableNotificationVersions,
+} from './write-back.mjs';
+
+const origin = 'https://github.com/inkeep/open-knowledge/issues/1428';
+const pull = 'https://github.com/inkeep/agents-private/pull/4879';
+const oldVersion = '0.78.0-beta.0';
+const version = '0.78.0-beta.6';
+const oldMarker = notificationMarkerUrl({ version: oldVersion, originUrl: origin });
+
+function recoveryHarness(overrides = {}) {
+ const attachments = [origin, pull, oldMarker];
+ const posts = [];
+ const marked = [];
+ const logs = [];
+ const deps = {
+ channel: 'beta',
+ selfRepo: 'inkeep/open-knowledge',
+ live: true,
+ listCandidates: async () => [
+ {
+ id: 'ticket',
+ identifier: 'PRD-8413',
+ stateType: 'completed',
+ attachmentUrls: [...attachments],
+ },
+ ],
+ listChildren: async () => [],
+ versionFor: async () => version,
+ stableVersionFor: async () => null,
+ isPublishedVersion: (v) => v === version,
+ classifyRelease: makeReleaseWindow({ releaseTag: 'v0.78.0-beta.99' }),
+ readChangesetProse: async () => ({ title: 'Fix the reported behavior' }),
+ recordNotification: async (marker) => {
+ attachments.push(marker.url);
+ marked.push(marker);
+ },
+ postReply: async (target, text) => posts.push({ target, text }),
+ log: (line) => logs.push(line),
+ ...overrides,
+ };
+ return { deps, attachments, posts, marked, logs, run: () => runWriteBack(deps) };
+}
+
+test('a failed or skipped release produces one correction when a containing build actually publishes', async () => {
+ const h = recoveryHarness();
+ const first = await h.run();
+ expect(first.errored).toEqual([]);
+ expect(h.posts).toHaveLength(1);
+ expect(h.posts[0].text).toContain('Correction to our earlier update');
+ expect(h.posts[0].text).toContain('v0.78.0-beta.0');
+ expect(h.posts[0].text).toContain('/releases/tag/v0.78.0-beta.6');
+ expect(h.posts[0].text).not.toContain('finished uploading');
+ expect(h.attachments).toContain(oldMarker);
+ expect(h.marked[0].url).toBe(notificationMarkerUrl({ version, originUrl: origin }));
+ const second = await h.run();
+ expect(second.skipped).toContainEqual({ identifier: 'PRD-8413', reason: 'already-notified' });
+ expect(h.posts).toHaveLength(1);
+});
+
+test('later corrective fixes do not repeat a recovery correction already delivered', async () => {
+ const later = '0.78.0-beta.9';
+ const h = recoveryHarness({ isPublishedVersion: (v) => [version, later].includes(v) });
+ await h.run();
+ h.deps.versionFor = async () => later;
+ await h.run();
+ expect(h.posts).toHaveLength(2);
+ expect(h.posts.filter((p) => p.text.includes('Correction to our earlier update'))).toHaveLength(
+ 1,
+ );
+ expect(h.posts[1].text).toContain(later);
+ expect(h.attachments).toContain(oldMarker);
+});
+
+test('one correction lists multiple unavailable announcements with plural wording', async () => {
+ const h = recoveryHarness();
+ h.attachments.push(notificationMarkerUrl({ version: '0.78.0-beta.1', originUrl: origin }));
+ await h.run();
+ expect(h.posts[0].text).toContain(
+ 'releases we linked (v0.78.0-beta.0, v0.78.0-beta.1) are not available',
+ );
+});
+
+test('both channels reuse successful PR, commit-message and mirrored-history lookups within a run', () => {
+ const counts = { pr: 0, message: 0, mirror: 0 };
+ const sha = 'a'.repeat(40);
+ const resolve = createVersionFor({
+ selfRepo: 'inkeep/open-knowledge',
+ stableTags: ['v0.78.0-beta.6', 'v0.78.0'],
+ resolvePrMergeSha: () => {
+ counts.pr++;
+ return 'b'.repeat(40);
+ },
+ readCommitMessage: () => {
+ counts.message++;
+ return `GitOrigin-RevId: ${sha}`;
+ },
+ findMirroredCommits: () => {
+ counts.mirror++;
+ return [{ sha: 'c'.repeat(40), message: `GitOrigin-RevId: ${sha}` }];
+ },
+ contains: () => true,
+ });
+ const node = { attachmentUrls: ['https://github.com/inkeep/open-knowledge/pull/1500'] };
+ expect(resolve(node, 'beta')).toBe('0.78.0-beta.6');
+ expect(resolve(node, 'stable')).toBe('0.78.0');
+ expect(resolve(node, 'beta')).toBe('0.78.0-beta.6');
+ expect(counts).toEqual({ pr: 1, message: 1, mirror: 1 });
+});
+
+test('a dry-run previews the correction without changing receipts or posting', async () => {
+ const h = recoveryHarness({ live: false });
+ await h.run();
+ expect(h.posts).toEqual([]);
+ expect(h.marked).toEqual([]);
+ expect(h.logs.some((l) => l.includes('[dry run] recovery correction:'))).toBe(true);
+});
+
+test('resolution caches keep distinct PR numbers and SHAs separate', () => {
+ const counts = { pr: 0, message: 0, mirror: 0 };
+ const resolve = createVersionFor({
+ selfRepo: 'inkeep/open-knowledge',
+ stableTags: ['v0.78.0-beta.6', 'v0.78.0-beta.9', 'v0.78.0'],
+ resolvePrMergeSha: ({ number }) => {
+ counts.pr++;
+ return (number === 1500 ? 'a' : 'b').repeat(40);
+ },
+ readCommitMessage: (sha) => {
+ counts.message++;
+ return `GitOrigin-RevId: ${sha}`;
+ },
+ findMirroredCommits: (sha) => {
+ counts.mirror++;
+ return [{ sha, message: `GitOrigin-RevId: ${sha}` }];
+ },
+ contains: (tag, sha) => sha === 'a'.repeat(40) || tag !== 'v0.78.0-beta.6',
+ });
+ const first = { attachmentUrls: ['https://github.com/inkeep/open-knowledge/pull/1500'] };
+ const second = { attachmentUrls: ['https://github.com/inkeep/open-knowledge/pull/1501'] };
+ expect(resolve(first, 'beta')).toBe('0.78.0-beta.6');
+ expect(resolve(second, 'beta')).toBe('0.78.0-beta.9');
+ expect(resolve(first, 'stable')).toBe('0.78.0');
+ expect(resolve(second, 'stable')).toBe('0.78.0');
+ expect(counts).toEqual({ pr: 2, message: 2, mirror: 2 });
+});
+
+test.each(['pr', 'message', 'mirror'])(
+ 'a failed %s lookup is retried, not cached as a result',
+ (failureAt) => {
+ const counts = { pr: 0, message: 0, mirror: 0 };
+ const sha = 'a'.repeat(40);
+ const read = (name, value) => {
+ counts[name]++;
+ if (name === failureAt && counts[name] === 1) throw new Error('transient ' + name);
+ return value;
+ };
+ const resolve = createVersionFor({
+ selfRepo: 'inkeep/open-knowledge',
+ stableTags: ['v0.78.0-beta.6', 'v0.78.0'],
+ resolvePrMergeSha: () => read('pr', sha),
+ readCommitMessage: () => read('message', `GitOrigin-RevId: ${sha}`),
+ findMirroredCommits: () => read('mirror', [{ sha, message: `GitOrigin-RevId: ${sha}` }]),
+ contains: () => true,
+ });
+ const node = { attachmentUrls: ['https://github.com/inkeep/open-knowledge/pull/1500'] };
+ expect(() => resolve(node, 'beta')).toThrow('transient ' + failureAt);
+ expect(resolve(node, 'beta')).toBe('0.78.0-beta.6');
+ expect(resolve(node, 'stable')).toBe('0.78.0');
+ expect(counts[failureAt]).toBe(2);
+ for (const name of ['pr', 'message', 'mirror'].filter((name) => name !== failureAt))
+ expect(counts[name]).toBe(1);
+ },
+);
+
+test('backfilling an older release does not notify an origin already told about a newer available build', async () => {
+ const h = recoveryHarness({ isPublishedVersion: () => true });
+ h.attachments.push(notificationMarkerUrl({ version: '0.78.0-beta.9', originUrl: origin }));
+ const r = await h.run();
+ expect(h.posts).toEqual([]);
+ expect(r.skipped).toContainEqual({ identifier: 'PRD-8413', reason: 'already-notified' });
+});
+
+test('a genuinely later corrective fix still gets an update after an earlier published notification', async () => {
+ const h = recoveryHarness({ isPublishedVersion: () => true });
+ await h.run();
+ expect(h.posts).toHaveLength(1);
+ expect(h.posts[0].text).not.toContain('Correction to our earlier update');
+});
+
+test('only unavailable receipts for this origin and channel trigger a correction', () => {
+ const other = notificationMarkerUrl({ version: oldVersion, originUrl: origin + '0' });
+ const stable = notificationMarkerUrl({ version: '0.77.9', originUrl: origin });
+ expect(
+ unavailableNotificationVersions({
+ attachmentUrls: [oldMarker, oldMarker, other, stable, 'invalid'],
+ originUrl: origin,
+ channel: 'beta',
+ isPublishedVersion: () => false,
+ }),
+ ).toEqual([oldVersion]);
+ expect(
+ unavailableNotificationVersions({
+ attachmentUrls: [oldMarker],
+ originUrl: origin,
+ channel: 'beta',
+ isPublishedVersion: () => true,
+ }),
+ ).toEqual([]);
+});
+
+test('a missed beta notice is suppressed once all required work is available in stable', async () => {
+ const h = recoveryHarness({ stableVersionFor: async () => '0.78.0' });
+ const r = await h.run();
+ expect(h.posts).toEqual([]);
+ expect(r.skipped).toContainEqual({ identifier: 'PRD-8413', reason: 'stable-covers-it' });
+});
+
+test('one stable child does not suppress beta availability for the remaining required work', async () => {
+ const h = recoveryHarness({
+ listChildren: async () =>
+ ['a', 'b'].map((id) => ({
+ id,
+ identifier: id,
+ stateType: 'completed',
+ attachmentUrls: [pull],
+ })),
+ stableVersionFor: async (node) => (node.id === 'a' ? '0.78.0' : null),
+ });
+ await h.run();
+ expect(h.posts).toHaveLength(1);
+});
+
+test('a corrected beta receipt does not suppress the later stable follow-up', async () => {
+ const h = recoveryHarness();
+ await h.run();
+ h.deps.channel = 'stable';
+ h.deps.versionFor = async () => '0.78.0';
+ h.deps.classifyRelease = makeReleaseWindow({ releaseTag: 'v0.78.0' });
+ await h.run();
+ expect(h.posts).toHaveLength(2);
+ expect(h.posts[1].text).toContain('This shipped in Open Knowledge v0.78.0');
+ expect(h.posts[1].text).not.toContain('Correction');
+});
diff --git a/.github/scripts/write-back-target.mjs b/.github/scripts/write-back-target.mjs
new file mode 100644
index 000000000..e77177ed6
--- /dev/null
+++ b/.github/scripts/write-back-target.mjs
@@ -0,0 +1,42 @@
+/* biome-ignore-all lint/suspicious/noUndeclaredEnvVars: GitHub Actions invokes this entrypoint outside Turbo. */
+import { appendFileSync } from 'node:fs';
+import { pathToFileURL } from 'node:url';
+import {
+ deriveChannel,
+ realPublishedReleaseTags,
+ requirePublishedRelease,
+ sortReleaseTagsAscending,
+} from './published-release-tags.mjs';
+
+export function resolveWriteBackTarget({ requestedTag, channel, publishedTags }) {
+ if (!['stable', 'beta'].includes(channel)) throw new Error('Unknown writeback channel');
+ const matches = (tag) => deriveChannel(tag) === channel;
+ if (requestedTag) {
+ if (!matches(requestedTag))
+ throw new Error(`Release tag ${requestedTag} does not match writeback channel ${channel}`);
+ requirePublishedRelease(requestedTag, publishedTags);
+ return requestedTag;
+ }
+ return sortReleaseTagsAscending(publishedTags).filter(matches).at(-1) ?? null;
+}
+
+if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
+ try {
+ const channel = process.env.WRITE_BACK_CHANNEL;
+ const tag = resolveWriteBackTarget({
+ requestedTag: process.env.RELEASE_TAG,
+ channel,
+ publishedTags: realPublishedReleaseTags(),
+ });
+ appendFileSync(process.env.GITHUB_OUTPUT, `channel=${tag ? channel : 'none'}\n`);
+ if (tag) appendFileSync(process.env.GITHUB_OUTPUT, `release_tag=${tag}\n`);
+ console.log(
+ tag ? `Reconciling published ${channel} through ${tag}` : `No published ${channel} release`,
+ );
+ } catch (error) {
+ console.error(
+ `::error::write-back-target: tag=${JSON.stringify(process.env.RELEASE_TAG)}, channel=${JSON.stringify(process.env.WRITE_BACK_CHANNEL)}: ${error.message}`,
+ );
+ process.exitCode = 1;
+ }
+}
diff --git a/.github/scripts/write-back-target.test.mjs b/.github/scripts/write-back-target.test.mjs
new file mode 100644
index 000000000..7e003f25c
--- /dev/null
+++ b/.github/scripts/write-back-target.test.mjs
@@ -0,0 +1,73 @@
+import { spawnSync } from 'node:child_process';
+import { chmodSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { expect, test } from 'vitest';
+import { resolveWriteBackTarget } from './write-back-target.mjs';
+
+test('scheduled reconciliation selects the newest published release of each channel', () => {
+ const publishedTags = ['v0.77.9', 'v0.78.0-beta.6', 'v0.78.0-beta.9'];
+ expect(resolveWriteBackTarget({ channel: 'stable', publishedTags })).toBe('v0.77.9');
+ expect(resolveWriteBackTarget({ channel: 'beta', publishedTags })).toBe('v0.78.0-beta.9');
+ expect(resolveWriteBackTarget({ channel: 'beta', publishedTags: ['v0.77.9'] })).toBeNull();
+ expect(() =>
+ resolveWriteBackTarget({ channel: 'beta', publishedTags, requestedTag: 'v0.78.0-beta.8' }),
+ ).toThrow('not a published');
+ expect(() =>
+ resolveWriteBackTarget({ channel: 'beta', publishedTags, requestedTag: 'v0.77.9' }),
+ ).toThrow('does not match');
+ expect(
+ resolveWriteBackTarget({ channel: 'beta', publishedTags, requestedTag: 'v0.78.0-beta.6' }),
+ ).toBe('v0.78.0-beta.6');
+});
+
+test('the workflow entrypoint resolves real gh output and refuses API failures before emitting a target', () => {
+ const cwd = mkdtempSync(join(tmpdir(), 'ok-writeback-target-'));
+ try {
+ const bin = join(cwd, 'bin');
+ mkdirSync(bin);
+ writeFileSync(
+ join(bin, 'gh'),
+ `#!/usr/bin/env node
+if (process.env.TEST_API_FAILURE) process.exit(1);
+for (const [tag_name,draft] of [['v0.78.0-beta.6',false],['v0.78.0-beta.7',true]]) console.log(JSON.stringify({tag_name,draft,published_at:draft?null:'2026-09-24T22:50:04Z',assets:[{name:'OpenKnowledge-arm64.dmg'},{name:'beta-mac.yml'}]}));
+`,
+ );
+ chmodSync(join(bin, 'gh'), 0o755);
+ const script = fileURLToPath(new URL('./write-back-target.mjs', import.meta.url));
+ const envFile = join(cwd, 'env');
+ const outputFile = join(cwd, 'output');
+ const run = (extra = {}) => {
+ writeFileSync(envFile, '');
+ writeFileSync(outputFile, '');
+ return spawnSync(process.execPath, [script], {
+ cwd,
+ encoding: 'utf8',
+ env: {
+ ...process.env,
+ PATH: `${bin}:${process.env.PATH}`,
+ GITHUB_ENV: envFile,
+ GITHUB_OUTPUT: outputFile,
+ WRITE_BACK_CHANNEL: 'beta',
+ RELEASE_TAG: '',
+ ...extra,
+ },
+ });
+ };
+ const success = run();
+ expect(success.status, success.stderr).toBe(0);
+ expect(readFileSync(envFile, 'utf8')).toBe('');
+ expect(readFileSync(outputFile, 'utf8')).toBe('channel=beta\nrelease_tag=v0.78.0-beta.6\n');
+ for (const extra of [{ TEST_API_FAILURE: 'true' }, { RELEASE_TAG: 'v0.78.0-beta.7' }]) {
+ const failed = run(extra);
+ expect(failed.status).not.toBe(0);
+ expect(failed.stderr).toContain('::error::write-back-target:');
+ expect(failed.stderr).toContain('channel="beta"');
+ expect(readFileSync(envFile, 'utf8')).toBe('');
+ expect(readFileSync(outputFile, 'utf8')).toBe('');
+ }
+ } finally {
+ rmSync(cwd, { recursive: true, force: true });
+ }
+});
diff --git a/.github/scripts/write-back.mjs b/.github/scripts/write-back.mjs
index 807a13a02..053468569 100644
--- a/.github/scripts/write-back.mjs
+++ b/.github/scripts/write-back.mjs
@@ -3,6 +3,7 @@
import { execFileSync, spawnSync } from 'node:child_process';
import { pathToFileURL } from 'node:url';
import {
+ deriveChannel,
realPublishedReleaseTags,
requirePublishedRelease,
sortReleaseTagsAscending,
@@ -24,12 +25,12 @@ import {
markerSuffixFor,
partitionAttachments,
} from './write-back-gate.mjs';
+import writeBackPolicy from './write-back-policy.json' with { type: 'json' };
const LINEAR_GRAPHQL_URL = 'https://api.linear.app/graphql';
const RELEASES_TAG_BASE = 'https://github.com/inkeep/open-knowledge/releases/tag';
const DEFAULT_PRIVATE_REPO = 'inkeep/agents-private';
const FULL_SHA_RE = /^[0-9a-f]{40}$/i;
-const STABLE_TAG_RE = /^v\d+\.\d+\.\d+$/;
const PAGE_SIZE = 50;
export const CANDIDATE_QUERY = `
@@ -194,17 +195,6 @@ export function deriveVersionForFixRefs({
return highest;
}
-export const DEFAULT_RELEASE_LOOKBACK = 3;
-
-export const DEFAULT_BETA_LOOKBACK = 10;
-
-export function deriveChannel(releaseTag) {
- const tag = String(releaseTag ?? '').trim();
- if (STABLE_TAG_RE.test(tag)) return 'stable';
- if (/^v\d+\.\d+\.\d+-beta\.\d+$/.test(tag)) return 'beta';
- return null;
-}
-
export function isStableVersion(raw) {
return /^\d+\.\d+\.\d+$/.test(
String(raw ?? '')
@@ -220,36 +210,77 @@ function normalizeVersion(raw) {
return /^\d+\.\d+\.\d+(?:-beta\.\d+)?$/.test(trimmed) ? trimmed : null;
}
-export function makeReleaseWindow({ releaseTag, stableTags = [], channel, lookback }) {
+export function makeReleaseWindow({ releaseTag, channel, minimumVersion }) {
const release = normalizeVersion(releaseTag);
- if (!release) {
- throw new Error(
- `RELEASE_TAG must be a release tag of this cadence, v0.36.0 or v0.36.0-beta.3 ` +
- `(got ${JSON.stringify(releaseTag)}). ` +
- 'Refusing to run: with no release to scope against, every shipped fix in history is a candidate.',
- );
- }
+ if (!release) throw new Error('RELEASE_TAG must be a release tag of this cadence');
const resolvedChannel = channel ?? (isStableVersion(release) ? 'stable' : 'beta');
- const resolvedLookback =
- lookback ?? (resolvedChannel === 'beta' ? DEFAULT_BETA_LOOKBACK : DEFAULT_RELEASE_LOOKBACK);
-
- const eligible = resolvedChannel === 'beta' ? () => true : (version) => isStableVersion(version);
- const known = [
- ...new Set(stableTags.map(normalizeVersion).filter(Boolean).filter(eligible)),
- ].sort(compareVersions);
- const atOrBelow = known.filter((v) => compareVersions(v, release) <= 0);
- const floorIndex = atOrBelow.length - (resolvedLookback + 1) - 1;
- const floor = floorIndex >= 0 ? atOrBelow[floorIndex] : null;
-
+ const minimum = normalizeVersion(
+ minimumVersion ?? writeBackPolicy.minimumVersion[resolvedChannel],
+ );
+ if (!minimum) throw new Error('Writeback requires a valid fixed minimum version');
return (version) => {
const shipped = normalizeVersion(version);
if (!shipped) return 'unversioned';
if (compareVersions(shipped, release) > 0) return 'not-yet-shipped';
- if (floor && compareVersions(shipped, floor) <= 0) return 'shipped-earlier';
+ if (compareVersions(shipped, minimum) < 0) return 'shipped-earlier';
return 'in-window';
};
}
+function notificationVersions({ attachmentUrls, originUrl, channel }) {
+ const versions = new Set();
+ for (const raw of attachmentUrls) {
+ let url;
+ try {
+ url = new URL(raw);
+ } catch {
+ continue;
+ }
+ if (url.searchParams.get('notified') !== originUrl) continue;
+ if (!url.href.startsWith(`${RELEASES_TAG_BASE}/v`)) continue;
+ const version = normalizeVersion(url.pathname.split('/').at(-1));
+ if (!version || (isStableVersion(version) ? 'stable' : 'beta') !== channel) continue;
+ versions.add(version);
+ }
+ return [...versions].sort(compareVersions);
+}
+
+export function unavailableNotificationVersions(options) {
+ const versions = notificationVersions(options);
+ const published = versions.filter(options.isPublishedVersion);
+ return versions.filter(
+ (version) =>
+ !options.isPublishedVersion(version) &&
+ !published.some((seen) => compareVersions(seen, version) > 0),
+ );
+}
+
+export function createVersionFor(deps) {
+ const memo = (fn, keyFor = (value) => value) => {
+ const cache = new Map();
+ return (value) => {
+ const key = keyFor(value);
+ if (!cache.has(key)) cache.set(key, fn(value));
+ return cache.get(key);
+ };
+ };
+ const shared = {
+ ...deps,
+ findMirroredCommits: memo(deps.findMirroredCommits),
+ resolvePrMergeSha: memo(
+ deps.resolvePrMergeSha,
+ ({ owner, repo, number }) => `${owner}/${repo}/${number}`,
+ ),
+ readCommitMessage: memo(deps.readCommitMessage),
+ };
+ return (node, channel) =>
+ deriveVersionForFixRefs({
+ ...shared,
+ fixReferences: partitionAttachments(node.attachmentUrls ?? []).fixReferences,
+ channel,
+ });
+}
+
export class NeedsHumanError extends Error {
constructor(message) {
super(message);
@@ -261,6 +292,8 @@ export async function runWriteBack({
listCandidates,
listChildren,
versionFor,
+ stableVersionFor,
+ isPublishedVersion,
readChangesetProse,
postReply,
recordNotification,
@@ -276,6 +309,12 @@ export async function runWriteBack({
if (channel !== 'stable' && channel !== 'beta') {
throw new Error(`runWriteBack requires channel 'stable' or 'beta', got '${channel}'`);
}
+ if (typeof isPublishedVersion !== 'function') {
+ throw new Error('runWriteBack requires published release availability');
+ }
+ if (channel === 'beta' && typeof stableVersionFor !== 'function') {
+ throw new Error('Beta reconciliation requires stable release containment');
+ }
if (!String(selfRepo ?? '').trim()) {
throw new Error(
'runWriteBack requires selfRepo (GITHUB_REPOSITORY): without it no GitHub origin can be ' +
@@ -360,6 +399,21 @@ export async function runWriteBack({
return;
}
+ if (channel === 'beta') {
+ const stableVersions = new Map();
+ for (const node of considered)
+ stableVersions.set(node.identifier, await stableVersionFor(node));
+ const stableGate = evaluateFanIn({
+ ticket: candidate,
+ descendants: children,
+ resolveVersion: (node) => stableVersions.get(node.identifier) ?? null,
+ });
+ if (stableGate.decision === 'notify') {
+ skip(candidate.identifier, 'stable-covers-it');
+ return;
+ }
+ }
+
if (origins.length === 0) {
const unreachable = [
...attachedOrigins
@@ -378,11 +432,29 @@ export async function runWriteBack({
for (const origin of origins) {
const attachmentUrls = candidate.attachmentUrls ?? [];
const marker = notificationMarkerUrl({ version: gate.version, originUrl: origin.url });
- if (attachmentUrls.includes(marker)) {
+ const notifiedVersions = notificationVersions({
+ attachmentUrls,
+ originUrl: origin.url,
+ channel,
+ });
+ if (
+ attachmentUrls.includes(marker) ||
+ notifiedVersions.some(
+ (version) =>
+ isPublishedVersion(version) &&
+ compareVersions(version, normalizeVersion(gate.version)) >= 0,
+ )
+ ) {
skip(candidate.identifier, 'already-notified');
continue;
}
const changeset = await readChangesetProse(candidate, { fixReferences });
+ const recoveryFrom = unavailableNotificationVersions({
+ attachmentUrls,
+ originUrl: origin.url,
+ channel,
+ isPublishedVersion,
+ });
const text =
changeset === null
? null
@@ -392,6 +464,7 @@ export async function runWriteBack({
originChannel: origin.channel,
coverage: gate.coverage,
channel,
+ recoveryFrom,
});
if (!text) {
@@ -408,6 +481,9 @@ export async function runWriteBack({
`::notice::write-back: [dry run] would reply to ${origin.url} for ${candidate.identifier} ` +
`(v${gate.version}, covers ${gate.coverage.join(', ')}).`,
);
+ log(
+ `::notice::write-back: [dry run] ${recoveryFrom.length ? 'recovery correction' : 'release announcement'}: ${text.replaceAll('\n', ' ')}`,
+ );
posted.push({
identifier: candidate.identifier,
origin: origin.url,
@@ -861,23 +937,18 @@ async function main() {
const stableTags = realPublishedReleaseTags();
requirePublishedRelease(releaseTag, stableTags);
const contains = createTagContainment();
- const versionFor = (node) =>
- deriveVersionForFixRefs({
- fixReferences: partitionAttachments(node.attachmentUrls ?? []).fixReferences,
- stableTags,
- findMirroredCommits: realFindMirroredCommits,
- contains,
- resolvePrMergeSha: realResolvePrMergeSha,
- readCommitMessage: realReadCommitMessage,
- channel,
- log,
- });
+ const versionFor = createVersionFor({
+ stableTags,
+ findMirroredCommits: realFindMirroredCommits,
+ contains,
+ resolvePrMergeSha: realResolvePrMergeSha,
+ readCommitMessage: realReadCommitMessage,
+ log,
+ });
- const classifyRelease = makeReleaseWindow({ releaseTag, stableTags, channel });
- const lookback = channel === 'beta' ? DEFAULT_BETA_LOOKBACK : DEFAULT_RELEASE_LOOKBACK;
+ const classifyRelease = makeReleaseWindow({ releaseTag, channel });
log(
- `::notice::write-back: ${channel} channel, scoped to ${releaseTag} and the ${lookback} ` +
- `${channel === 'beta' ? 'releases' : 'stable releases'} before it; anything shipped earlier is left alone.`,
+ `::notice::write-back: ${channel} reconciliation from ${writeBackPolicy.minimumVersion[channel]} through ${releaseTag}; unnotified releases do not expire.`,
);
if (!String(process.env.CROSS_REPO_TOKEN ?? '').trim()) {
@@ -891,7 +962,9 @@ async function main() {
listCandidates: () => paginate({ apiKey, query: CANDIDATE_QUERY, variables: {}, log }),
listChildren: (parentId) =>
paginate({ apiKey, query: CHILDREN_QUERY, variables: { parentId }, log }),
- versionFor,
+ versionFor: (node) => versionFor(node, channel),
+ stableVersionFor: (node) => versionFor(node, 'stable'),
+ isPublishedVersion: (version) => stableTags.includes(`v${version}`),
classifyRelease,
channel,
readChangesetProse: (candidate, ctx) => realReadChangesetProse(candidate, ctx),
diff --git a/.github/scripts/write-back.test.mjs b/.github/scripts/write-back.test.mjs
index 8743014a0..f76d71cca 100644
--- a/.github/scripts/write-back.test.mjs
+++ b/.github/scripts/write-back.test.mjs
@@ -3,12 +3,10 @@
import { readFileSync } from 'node:fs';
import { describe, expect, test } from 'vitest';
import { parse } from 'yaml';
+import { deriveChannel } from './published-release-tags.mjs';
import {
CANDIDATE_QUERY,
changesetDirFor,
- DEFAULT_BETA_LOOKBACK,
- DEFAULT_RELEASE_LOOKBACK,
- deriveChannel,
deriveVersionForFixRefs,
findChangesetPath,
isFixRepoInRemit,
@@ -60,10 +58,12 @@ function harness(overrides = {}) {
listCandidates: async () => [candidate()],
listChildren: async () => [],
versionFor: async () => 'v0.36.0',
+ stableVersionFor: async () => null,
+ isPublishedVersion: () => true,
readChangesetProse: async () => CHANGESET,
postReply: async (origin, text) => writes.push({ kind: 'post', origin: origin.url, text }),
recordNotification: async (marker) => writes.push({ kind: 'mark', url: marker.url }),
- classifyRelease: makeReleaseWindow({ releaseTag: 'v0.36.0', stableTags: STABLE_TAGS }),
+ classifyRelease: makeReleaseWindow({ releaseTag: 'v0.36.0', minimumVersion: '0.35.0' }),
selfRepo: 'inkeep/open-knowledge',
log: (m) => logs.push(m),
...overrides,
@@ -491,7 +491,7 @@ describe('write-back run', () => {
await h.run();
const post = h.writes.find((w) => w.kind === 'post');
expect(post.origin).toBe(DISCORD_THREAD);
- expect(post.text).toContain('<https://github.com/inkeep/open-knowledge/releases>');
+ expect(post.text).toContain('<https://github.com/inkeep/open-knowledge/releases/tag/v0.36.0>');
});
test('a failure while recording the marker leaves the reporter unmessaged', async () => {
@@ -668,7 +668,7 @@ describe('changeset parsing', () => {
expect(text).not.toContain(changeset.title);
expect(text).not.toContain(changeset.body);
expect(text).toContain(
- '[the releases page](https://github.com/inkeep/open-knowledge/releases)',
+ '[the release page](https://github.com/inkeep/open-knowledge/releases/tag/v0.36.0)',
);
}
});
@@ -1099,20 +1099,24 @@ describe('workflow shape', () => {
expect(workflow).not.toContain('types: [published]');
});
- test('both release channels run, and a tag of neither shape runs nothing', () => {
- expect(workflow).toContain('^v[0-9]+\\.[0-9]+\\.[0-9]+$');
- expect(workflow).toContain('^v[0-9]+\\.[0-9]+\\.[0-9]+-beta\\.[0-9]+$');
- expect(workflow).toContain('echo "channel=stable"');
- expect(workflow).toContain('echo "channel=beta"');
- expect(workflow).toContain('echo "channel=none"');
+ test('scheduled reconciliation covers both channels and serializes across release tags', () => {
+ const parsed = parse(workflow);
+ expect(parsed.on.schedule).toEqual([{ cron: '43 * * * *' }]);
+ expect(parsed.jobs.notify.strategy.matrix.channel).toBe(
+ "${{ fromJSON(github.event_name == 'schedule' && '[\"stable\",\"beta\"]' || contains(github.event.client_payload.release_tag || inputs.release_tag, '-beta.') && '[\"beta\"]' || '[\"stable\"]') }}",
+ );
+ expect(parsed.jobs.notify.concurrency).toEqual({
+ group: 'reporter-write-back-${{ matrix.channel }}',
+ 'cancel-in-progress': false,
+ });
expect(workflow).toMatch(/if:\s*steps\.tag\.outputs\.channel != 'none'/);
- expect(workflow).not.toMatch(/steps\.tag\.outputs\.stable/);
+ expect(workflow).toContain('run: node .github/scripts/write-back-target.mjs');
});
test('no working step is left outside the channel gate', () => {
const stepNames = [...workflow.matchAll(/^ {6}- (?:name:.*|uses:.*)$/gm)].length;
const gated = [...workflow.matchAll(/if: steps\.tag\.outputs\.channel != 'none'/g)].length;
- expect(gated).toBe(stepNames - 1);
+ expect(gated).toBe(stepNames - 3);
});
test('it carries its own concurrency group so a release can never queue behind it', () => {
@@ -1149,6 +1153,7 @@ describe('workflow shape', () => {
"${{ github.event_name == 'workflow_dispatch' && inputs.dry_run && 'dry-run' || vars.WRITE_BACK_MODE }}",
);
expect(workflow).toContain('WRITE_BACK_MODE');
+ expect(notify.env.RELEASE_TAG).toBe('${{ steps.tag.outputs.release_tag }}');
expect(workflow).toContain('LINEAR_API_KEY');
});
@@ -1175,85 +1180,33 @@ describe('workflow shape', () => {
});
});
-describe('release window', () => {
- const TAGS = ['v0.34.0', 'v0.35.0', 'v0.35.1', 'v0.35.2', 'v0.36.0', 'v0.37.0'];
- const windowFor = (releaseTag, lookback) =>
- makeReleaseWindow({ releaseTag, stableTags: TAGS, lookback });
-
- test('the release being processed is in window', () => {
- expect(windowFor('v0.36.0')('0.36.0')).toBe('in-window');
- });
-
- test('a version above the release has not reached anyone yet', () => {
- expect(windowFor('v0.36.0')('0.37.0')).toBe('not-yet-shipped');
- });
-
- test('the lookback keeps recent releases reachable so a missed run self-heals', () => {
- const classify = windowFor('v0.36.0', 3);
- for (const v of ['0.36.0', '0.35.2', '0.35.1', '0.35.0']) {
- expect(classify(v)).toBe('in-window');
+describe('fixed reconciliation window', () => {
+ const windowFor = (releaseTag, minimumVersion = '0.35.0') =>
+ makeReleaseWindow({ releaseTag, minimumVersion });
+ test('missed releases remain eligible however many later releases appear', () => {
+ for (const releaseTag of ['v0.36.0', 'v0.90.0', 'v2.0.0']) {
+ expect(windowFor(releaseTag)('0.35.0')).toBe('in-window');
+ expect(windowFor(releaseTag)('0.34.0')).toBe('shipped-earlier');
}
- });
-
- test('anything older than the lookback is left alone', () => {
- expect(windowFor('v0.36.0', 3)('0.34.0')).toBe('shipped-earlier');
- });
-
- test('a narrower lookback excludes more of the history', () => {
- const classify = windowFor('v0.36.0', 1);
- expect(classify('0.35.2')).toBe('in-window');
- expect(classify('0.35.1')).toBe('shipped-earlier');
- });
-
- test('a zero lookback degenerates to the exact release and nothing else', () => {
- const classify = windowFor('v0.36.0', 0);
- expect(classify('0.36.0')).toBe('in-window');
- expect(classify('0.35.2')).toBe('shipped-earlier');
- });
-
- test('too little history to reach back keeps everything at or below the release', () => {
- const classify = makeReleaseWindow({ releaseTag: 'v0.36.0', stableTags: ['v0.36.0'] });
- expect(classify('0.36.0')).toBe('in-window');
- expect(classify('0.35.0')).toBe('in-window');
- expect(classify('0.37.0')).toBe('not-yet-shipped');
- });
-
- test('the v prefix is accepted on both sides', () => {
- expect(windowFor('0.36.0')('v0.36.0')).toBe('in-window');
- });
-
- test('an underivable version is reported as such rather than silently admitted', () => {
+ expect(windowFor('v0.36.0')('0.37.0')).toBe('not-yet-shipped');
expect(windowFor('v0.36.0')(null)).toBe('unversioned');
+ expect(windowFor('0.36.0')('v0.36.0')).toBe('in-window');
});
-
- test('a missing or malformed release tag refuses rather than admitting all of history', () => {
- for (const bad of [undefined, '', ' ', 'latest', 'v0.36.0-rc.1', 'v0.36']) {
- expect(() => makeReleaseWindow({ releaseTag: bad, stableTags: TAGS })).toThrow(/RELEASE_TAG/);
+ test('invalid release or baseline refuses rather than enrolling all history', () => {
+ for (const releaseTag of [undefined, '', 'latest', 'v0.36.0-rc.1']) {
+ expect(() => makeReleaseWindow({ releaseTag })).toThrow('RELEASE_TAG');
}
+ expect(() => makeReleaseWindow({ releaseTag: 'v0.36.0', minimumVersion: 'garbage' })).toThrow(
+ 'minimum',
+ );
});
-
- test('a beta tag is a release this runs for, not a malformed one', () => {
- const window = makeReleaseWindow({
- releaseTag: 'v0.36.0-beta.1',
- stableTags: [...TAGS, 'v0.36.0-beta.0', 'v0.36.0-beta.1'],
- });
- expect(window('0.36.0-beta.0')).toBe('in-window');
- expect(window('0.36.0-beta.1')).toBe('in-window');
- expect(window('0.36.0')).toBe('not-yet-shipped');
- });
-
- test('a stable run counts stables, so the betas between them cannot eat the lookback', () => {
- const dense = ['v0.33.0', 'v0.34.0', 'v0.35.0', 'v0.36.0'].flatMap((tag) => [
- `${tag}-beta.0`,
- `${tag}-beta.1`,
- tag,
- ]);
- const window = makeReleaseWindow({ releaseTag: 'v0.36.0', stableTags: dense });
- expect(window('0.33.0')).toBe('in-window');
- });
-
- test('the default lookback is three', () => {
- expect(DEFAULT_RELEASE_LOOKBACK).toBe(3);
+ test('the rollout retains the formerly eligible scope without extending into old unnotified history', () => {
+ const stable = makeReleaseWindow({ releaseTag: 'v0.77.9' });
+ expect(stable('0.77.6')).toBe('in-window');
+ expect(stable('0.77.5')).toBe('shipped-earlier');
+ const beta = makeReleaseWindow({ releaseTag: 'v0.78.0-beta.9' });
+ expect(beta('0.77.8-beta.0')).toBe('in-window');
+ expect(beta('0.77.7-beta.9')).toBe('shipped-earlier');
});
});
@@ -1263,7 +1216,7 @@ describe('release window applied to a run', () => {
live: true,
classifyRelease: makeReleaseWindow({
releaseTag: 'v0.41.0',
- stableTags: ['v0.36.0', 'v0.38.0', 'v0.39.0', 'v0.40.0', 'v0.41.0'],
+ minimumVersion: '0.38.0',
}),
});
const result = await h.run();
@@ -1276,7 +1229,6 @@ describe('release window applied to a run', () => {
live: true,
classifyRelease: makeReleaseWindow({
releaseTag: 'v0.35.0',
- stableTags: ['v0.35.0', 'v0.36.0'],
}),
});
const result = await h.run();
@@ -1287,7 +1239,7 @@ describe('release window applied to a run', () => {
test('a candidate inside the window still gets its reply', async () => {
const h = harness({
live: true,
- classifyRelease: makeReleaseWindow({ releaseTag: 'v0.36.0', stableTags: STABLE_TAGS }),
+ classifyRelease: makeReleaseWindow({ releaseTag: 'v0.36.0', minimumVersion: '0.35.0' }),
});
await h.run();
expect(h.writes.filter((w) => w.kind === 'post')).toHaveLength(1);
@@ -1321,10 +1273,6 @@ describe('release channels', () => {
expect(isStableVersion('v0.36.0')).toBe(true);
expect(isStableVersion('0.36.0-beta.0')).toBe(false);
});
-
- test('the beta lookback is wider than the stable one, because betas cut far more often', () => {
- expect(DEFAULT_BETA_LOOKBACK).toBeGreaterThan(DEFAULT_RELEASE_LOOKBACK);
- });
});
describe('origin remit', () => {
@@ -1532,13 +1480,15 @@ describe('a linked pull request, not a label, is what a reply depends on', () =>
});
describe('the beta leg', () => {
- const BETA_TAGS = [...STABLE_TAGS, 'v0.37.0-beta.0', 'v0.37.0-beta.1'];
const betaHarness = (overrides = {}) =>
harness({
live: true,
channel: 'beta',
versionFor: async () => '0.37.0-beta.0',
- classifyRelease: makeReleaseWindow({ releaseTag: 'v0.37.0-beta.1', stableTags: BETA_TAGS }),
+ classifyRelease: makeReleaseWindow({
+ releaseTag: 'v0.37.0-beta.1',
+ minimumVersion: '0.37.0-beta.0',
+ }),
...overrides,
});
@@ -1547,7 +1497,7 @@ describe('the beta leg', () => {
await h.run();
const post = h.writes.find((w) => w.kind === 'post');
expect(post.text).toContain('v0.37.0-beta.0');
- expect(post.text).toContain('going out now on the Open Knowledge beta channel');
+ expect(post.text).toContain('available in Open Knowledge beta');
expect(post.text).toContain('follow up here');
expect(post.text).not.toContain('This shipped in');
expect(post.text).not.toContain(CHANGESET.body);
@@ -1571,7 +1521,7 @@ describe('the beta leg', () => {
listCandidates: async () => [candidate({ attachmentUrls: [GH_PULL, GH_ISSUE, marked] })],
classifyRelease: makeReleaseWindow({
releaseTag: 'v0.37.0-beta.5',
- stableTags: [...BETA_TAGS, 'v0.37.0-beta.5'],
+ minimumVersion: '0.37.0-beta.0',
}),
});
const result = await h.run();
@@ -1617,9 +1567,11 @@ describe('the beta leg', () => {
const forDiscord = posts.find((p) => p.origin === DISCORD_THREAD);
expect(forIssue.text).not.toContain(CHANGESET.body);
expect(forIssue.text).toContain(
- '[the releases page](https://github.com/inkeep/open-knowledge/releases)',
+ '[the release page](https://github.com/inkeep/open-knowledge/releases/tag/v0.36.0)',
);
expect(forDiscord.text).not.toContain(CHANGESET.body);
- expect(forDiscord.text).toContain('<https://github.com/inkeep/open-knowledge/releases>');
+ expect(forDiscord.text).toContain(
+ '<https://github.com/inkeep/open-knowledge/releases/tag/v0.36.0>',
+ );
});
});
diff --git a/.github/workflows/write-back.yml b/.github/workflows/write-back.yml
index 9dd1f422c..e316ec888 100644
--- a/.github/workflows/write-back.yml
+++ b/.github/workflows/write-back.yml
@@ -41,6 +41,8 @@ name: Reporter Write-Back
# reporter-facing posts by accident. Both steps are in RELEASES.md.
on:
+ schedule:
+ - cron: "43 * * * *"
repository_dispatch:
types: [desktop-release-published]
# Manual backfill / dry-run rehearsal against a specific tag.
@@ -61,52 +63,38 @@ permissions:
# Posting the reply onto a GitHub issue origin in this repo.
issues: write
-concurrency:
- # Its own group, deliberately not the release cadence group: a write-back run
- # must never be something a release cut can end up waiting on.
- group: reporter-write-back-${{ github.event.client_payload.release_tag || inputs.release_tag }}
- cancel-in-progress: false
-
jobs:
notify:
+ strategy:
+ fail-fast: false
+ matrix:
+ channel: ${{ fromJSON(github.event_name == 'schedule' && '["stable","beta"]' || contains(github.event.client_payload.release_tag || inputs.release_tag, '-beta.') && '["beta"]' || '["stable"]') }}
+ concurrency:
+ group: reporter-write-back-${{ matrix.channel }}
+ cancel-in-progress: false
runs-on: ubuntu-latest
timeout-minutes: 10
env:
+ WRITE_BACK_CHANNEL: ${{ matrix.channel }}
RELEASE_TAG: ${{ github.event.client_payload.release_tag || inputs.release_tag }}
steps:
- - name: Decide which release channel this tag belongs to
- id: tag
- run: |
- set -euo pipefail
- if [[ -z "${RELEASE_TAG}" ]]; then
- echo "::error::No release tag (neither client_payload.release_tag nor inputs.release_tag)."
- exit 1
- fi
- if [[ "${RELEASE_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
- echo "channel=stable" >> "$GITHUB_OUTPUT"
- elif [[ "${RELEASE_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+-beta\.[0-9]+$ ]]; then
- echo "channel=beta" >> "$GITHUB_OUTPUT"
- else
- echo "channel=none" >> "$GITHUB_OUTPUT"
- echo "::notice::${RELEASE_TAG} is neither a stable nor a beta tag of this cadence; there is no build to tell anyone about."
- fi
-
- name: Checkout with full history and tags
- if: steps.tag.outputs.channel != 'none'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
- # Tag containment is how the shipped version is derived, so every
- # release tag of both channels and the full history behind them have
- # to be present.
fetch-depth: 0
fetch-tags: true
persist-credentials: false
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
- if: steps.tag.outputs.channel != 'none'
with:
node-version: "24"
+ - name: Resolve published release for reconciliation
+ id: tag
+ env:
+ GH_TOKEN: ${{ github.token }}
+ run: node .github/scripts/write-back-target.mjs
+
- name: Check whether the bridge App is configured
# Fix references point into the private monorepo, which this repo's own
# token cannot read at all. Secrets are unreadable in `if:` expressions,
@@ -143,6 +131,7 @@ jobs:
- name: Notify reporters whose fix reached this release
if: steps.tag.outputs.channel != 'none'
env:
+ RELEASE_TAG: ${{ steps.tag.outputs.release_tag }}
# Posting the reply, which happens against this repo.
GH_TOKEN: ${{ github.token }}
# Reading the fix pull request and its changeset, which happen against