Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix([issue-13264]): preserve legacy notification delivery scope

[._.]/ Adam Eivyd9fec5a51ec9
diff --git a/server/services/agentPromptBuilder.js b/server/services/agentPromptBuilder.js
index 629a6fc9d1..82ccd9772c 100644
--- a/server/services/agentPromptBuilder.js
+++ b/server/services/agentPromptBuilder.js
@@ -672,10 +672,12 @@ function hasExternalRepositoryOutput(meta, worktreeInfo) {
const security = record(meta?.githubSecurityFix);
if (security?.host && (security.repo || security.advisories?.length)) return true;
const notification = record(meta?.githubNotificationResolve);
+ // Legacy PR records omitted the trust that distinguished own-pr from other;
+ // only a persisted kind can authorize code delivery for those threads.
return !!(notification?.host && notification.repo && (
- notification.reason === 'ci_activity' || notification.subjectType === 'CheckSuite'
- || notification.subjectType === 'Issue'
- || (notification.subjectType === 'PullRequest' && notification.reason !== 'review_requested')
+ notification.kind != null
+ ? ['own-pr', 'ci', 'issue'].includes(notification.kind)
+ : notification.reason === 'ci_activity' || notification.subjectType === 'CheckSuite' || notification.subjectType === 'Issue'
));
}
diff --git a/server/services/githubExternalRepositoryPrompt.test.js b/server/services/githubExternalRepositoryPrompt.test.js
index f3a738478b..2017dc6a50 100644
--- a/server/services/githubExternalRepositoryPrompt.test.js
+++ b/server/services/githubExternalRepositoryPrompt.test.js
@@ -92,6 +92,7 @@ for (const [path, render] of Object.entries(compose)) {
it.each([
['review', { ...row, reason: 'review_requested', trust: 'trusted' }],
['release', { ...row, subject_type: 'Release', reason: 'subscribed' }],
+ ['unknown subject', { ...row, subject_type: 'UnknownSubject', reason: 'subscribed' }],
])('retains no-code restrictions for a notification %s', async (_name, notification) => {
const prompt = await render(await queued(() => queueNotificationResolveTask({ account, row: notification })));
expect(prompt).toContain('## Completion (No Code Output)');
@@ -117,5 +118,24 @@ for (const [path, render] of Object.entries(compose)) {
expect(apiPrompt).not.toContain('## Simplify Step');
expect(apiPrompt).not.toContain('## Completion (External Repository)');
});
+
+ it.each([
+ ['non-own PR', { ...row, reason: 'mention', trust: 'trusted' }, false],
+ ['CI', { ...row, reason: 'ci_activity', subject_type: 'CheckSuite', subject_api_url: null }, true],
+ ['issue', { ...row, subject_type: 'Issue', subject_api_url: `https://api.github.com/repos/${repo}/issues/7` }, true],
+ ])('keeps legacy %s delivery scoped when provenance lacks a resolved kind', async (_name, notification, external) => {
+ const task = await queued(() => queueNotificationResolveTask({ account, row: notification }));
+ delete task.metadata.externalRepositoryOutput;
+ delete task.metadata.githubNotificationResolve.kind;
+ task.metadata.githubNotificationResolve = JSON.stringify(task.metadata.githubNotificationResolve);
+ const prompt = await render(task);
+ if (external) {
+ assertExternalContract(prompt);
+ return;
+ }
+ expect(prompt).toContain('Change nothing on GitHub');
+ expect(prompt).toContain('## Completion (No Code Output)');
+ expect(prompt).not.toContain('## Completion (External Repository)');
+ });
});
}
diff --git a/server/services/githubNotificationResolveTask.js b/server/services/githubNotificationResolveTask.js
index 844874ffdd..06eac17630 100644
--- a/server/services/githubNotificationResolveTask.js
+++ b/server/services/githubNotificationResolveTask.js
@@ -128,6 +128,8 @@ export async function queueNotificationResolveTask({ account, row, origin = 'use
const link = notificationHtmlUrl({ subjectApiUrl: row.subject_api_url, repoFullName: repo }, account.host);
if (!link) return { error: 'No link for this notification' };
const login = LOGIN_RE.test(account.login || '') ? account.login : null;
+ const kind = resolveKind(row);
+ const externalRepositoryOutput = ['own-pr', 'ci', 'issue'].includes(kind);
const task = await addTask({
description: buildResolvePrompt({
host: account.host, login, repo, threadId: row.thread_id, row, link, apiPath: repoApiPath(row.subject_api_url, account.host),
@@ -138,12 +140,12 @@ export async function queueNotificationResolveTask({ account, row, origin = 'use
// PortOS worktree, and a clean PortOS tree is success.
useWorktree: false,
openPR: false,
- noCodeOutput: ['review', 'other'].includes(resolveKind(row)),
+ noCodeOutput: !externalRepositoryOutput,
worktreeChangesExpected: false,
metadata: {
- externalRepositoryOutput: ['own-pr', 'ci', 'issue'].includes(resolveKind(row)),
+ externalRepositoryOutput,
githubNotificationResolve: {
- accountId: account.id, threadId: row.thread_id, host: account.host, repo, subjectType: row.subject_type, reason: row.reason, origin,
+ accountId: account.id, threadId: row.thread_id, host: account.host, repo, subjectType: row.subject_type, reason: row.reason, kind, origin,
},
},
}, 'user');