Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
Skip fix references in repos the write-back cannot read (#3033)
Andrew Mikofalvy9839254f32ba
diff --git a/.github/scripts/write-back.mjs b/.github/scripts/write-back.mjsindex 9b06d25df..d5be964a7 100644--- a/.github/scripts/write-back.mjs+++ b/.github/scripts/write-back.mjs@@ -133,6 +133,30 @@ export function notificationMarkerUrl({ version, originUrl }) {* Any reference that has not shipped makes the whole answer null. Part of a fix* being out is not the fix being out.*/+/**+ * Whether a fix reference names a repository this workflow can actually read.+ *+ * Two, and only two: this repo, and the private monorepo the mirror flows from.+ * The cross-repo token is an App installation scoped to the latter, so a fix+ * reference pointing anywhere else — and the Linear backlog is full of them,+ * from products that predate this one — is unreadable and always will be.+ *+ * Distinguishing that from an unreadable `agents-private` matters more than it+ * looks. Both surface as a bare 404, but one is a permanent fact about a stale+ * ticket and the other is the missing-permission bug this whole path was built+ * to fix. Suppressing 404s wholesale would have hidden the latter, so the test+ * is repo identity rather than the response.+ */+export function isFixRepoInRemit({ kind, owner, repo }, { defaultRepo = DEFAULT_PRIVATE_REPO, selfRepo } = {}) {+ // A raw commit SHA is resolved against local git history, not a repo API.+ if (kind === 'sha') return true;+ const target = `${owner}/${repo}`.toLowerCase();+ const reachable = [defaultRepo, selfRepo]+ .map((r) => String(r ?? '').trim().toLowerCase())+ .filter(Boolean);+ return reachable.includes(target);+}+export function deriveVersionForFixRefs({fixReferences = [],stableTags,@@ -140,6 +164,7 @@ export function deriveVersionForFixRefs({contains,resolvePrMergeSha,defaultRepo = DEFAULT_PRIVATE_REPO,+ selfRepo = process.env.GITHUB_REPOSITORY,log = () => {},}) {const usable = fixReferences.filter((ref) => ref.channel !== 'commit' || FULL_SHA_RE.test(ref.sha ?? ''));@@ -148,6 +173,13 @@ export function deriveVersionForFixRefs({let highest = null;for (const ref of usable) {const parsed = parseFixRef(ref.channel === 'commit' ? ref.sha : ref.url, { defaultRepo });+ if (!isFixRepoInRemit(parsed, { defaultRepo, selfRepo })) {+ log(+ `::notice::write-back: ${ref.url} lives in ${parsed.owner}/${parsed.repo}, which is outside this ` ++ 'workflow\'s reach; no version can be derived for it.',+ );+ return null;+ }const privateSha = resolvePrivateSha(parsed, { resolvePrMergeSha });if (!privateSha) {log(`::notice::write-back: ${ref.url} was closed without merging, so it carries no fix commit.`);diff --git a/.github/scripts/write-back.test.mjs b/.github/scripts/write-back.test.mjsindex 7c0596119..58e7ec999 100644--- a/.github/scripts/write-back.test.mjs+++ b/.github/scripts/write-back.test.mjs@@ -6,6 +6,7 @@ import {DEFAULT_RELEASE_LOOKBACK,deriveVersionForFixRefs,findChangesetPath,+ isFixRepoInRemit,makeReleaseWindow,notificationMarkerUrl,parseChangeset,@@ -180,6 +181,58 @@ describe('version derivation', () => {expect(() => parseMergeShaOutput('2026-07-23T14:19:56Z\nnot-a-sha', at)).toThrow(/merge_commit_sha/);});+ test('a fix reference in a repo this workflow cannot reach is skipped, not attempted', () => {+ // The Linear backlog carries pre-Open-Knowledge tickets whose fix references+ // point at other products' private repos. The cross-repo token is scoped to+ // agents-private, so those reads 404 permanently — attempting them turned+ // every run red on 39 candidates that will never resolve.+ const logs = [];+ expect(+ derive({+ fixReferences: [{ channel: 'pull-request', url: 'https://github.com/inkeep/management/pull/272' }],+ selfRepo: 'inkeep/open-knowledge',+ resolvePrMergeSha: () => {+ throw new Error('must not be attempted: this repo is out of remit');+ },+ log: (m) => logs.push(m),+ }),+ ).toBeNull();+ expect(logs.join(' ')).toContain('outside');+ });++ test('the two repos it CAN read are still attempted, so the 404 bug cannot come back', () => {+ // A blanket 404 suppression would have masked the missing-permission bug on+ // agents-private. These two must always reach the API.+ for (const url of [+ 'https://github.com/inkeep/agents-private/pull/2864',+ 'https://github.com/inkeep/open-knowledge/pull/12',+ ]) {+ let attempted = false;+ expect(+ derive({+ fixReferences: [{ channel: 'pull-request', url }],+ selfRepo: 'inkeep/open-knowledge',+ resolvePrMergeSha: () => {+ attempted = true;+ return PRIVATE_SHA;+ },+ }),+ ).toBe('0.36.0');+ expect(attempted, `${url} must be attempted`).toBe(true);+ }+ });++ test('remit is decided by repo identity, and a bare commit SHA needs no repo at all', () => {+ const at = { defaultRepo: 'inkeep/agents-private', selfRepo: 'inkeep/open-knowledge' };+ expect(isFixRepoInRemit({ kind: 'pr', owner: 'inkeep', repo: 'agents-private' }, at)).toBe(true);+ expect(isFixRepoInRemit({ kind: 'pr', owner: 'InKeep', repo: 'Agents-Private' }, at)).toBe(true);+ expect(isFixRepoInRemit({ kind: 'pr', owner: 'inkeep', repo: 'open-knowledge' }, at)).toBe(true);+ expect(isFixRepoInRemit({ kind: 'pr', owner: 'inkeep', repo: 'management' }, at)).toBe(false);+ expect(isFixRepoInRemit({ kind: 'pr', owner: 'inkeep', repo: 'open-knowledge-legacy' }, at)).toBe(false);+ // Resolved against local git history rather than a repo API.+ expect(isFixRepoInRemit({ kind: 'sha', sha: PRIVATE_SHA }, at)).toBe(true);+ });+test('an unreadable pull request still throws, because that one is not an answer', () => {// The 404 that broke the first live run was authorisation, not data. It// must stay loud; folding it in with the stale-attachment case would make