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: let Dependabot in a thread pass Resolve with agent's commenter check

Adam Eivyc1cf3bd7d503
diff --git a/server/services/githubNotificationAutopilot.js b/server/services/githubNotificationAutopilot.js
index 12e3673fa2..22541f01fc 100644
--- a/server/services/githubNotificationAutopilot.js
+++ b/server/services/githubNotificationAutopilot.js
@@ -122,8 +122,11 @@ async function recordHandoff(account, row, handoff, actor = 'automation') {
* thread is tried once per activity: a refusal is recorded with its reason and
* the thread stays with you until new activity re-triages it.
*/
-export async function autopilotAccountNotifications(account) {
- if (account.mode !== 'autopilot') return { handedOff: 0, agentRuns: 0 };
+/**
+ * The threads an Autopilot run considers, newest first: the SQL mirror of
+ * `autopilotHandoff`, so each must agree with it on every row.
+ */
+async function listAutopilotCandidates(account) {
const rules = account.agentRules;
const { rows } = await query(
`SELECT * FROM github_notifications WHERE account_id = $1 AND state = 'open' AND NOT suspect
@@ -137,6 +140,15 @@ export async function autopilotAccountNotifications(account) {
...scopeParams(agentRuleScope(rules, 'security-alert')),
],
);
+ return rows;
+}
+
+// The DB suite checks the SQL prefilter against `autopilotHandoff` row by row.
+export const __testing = { listAutopilotCandidates };
+
+export async function autopilotAccountNotifications(account) {
+ if (account.mode !== 'autopilot') return { handedOff: 0, agentRuns: 0 };
+ const rows = await listAutopilotCandidates(account);
const plans = rows.map((row) => ({ row, plan: withRunPin(account, autopilotHandoff({ account, row })) })).filter((entry) => entry.plan);
if (!plans.length) return { handedOff: 0, agentRuns: 0 };
const apps = await managedAppsByRepoKey();
diff --git a/server/services/githubNotificationTriage.js b/server/services/githubNotificationTriage.js
index f719a2bfbf..27c666401c 100644
--- a/server/services/githubNotificationTriage.js
+++ b/server/services/githubNotificationTriage.js
@@ -145,21 +145,23 @@ export async function threadDiscussionVouched(account, env, row) {
const [, kind, number] = match;
const paths = [`repos/${repo}/issues/${number}/comments`];
if (kind === 'pulls') paths.push(`repos/${repo}/pulls/${number}/comments`, `repos/${repo}/pulls/${number}/reviews`);
- const logins = new Set();
+ // login → the forge's user.type (Bot/User), which GitHub-native bot trust needs.
+ const actors = new Map();
for (const path of paths) {
- const out = await execGh(['api', '--hostname', account.host, '--method', 'GET', path, '--paginate', '--jq', '.[].user.login'], GH_TIMEOUT_MS, { env })
+ const out = await execGh(['api', '--hostname', account.host, '--method', 'GET', path, '--paginate', '--jq', '.[] | "\\(.user.login)\\t\\(.user.type)"'], GH_TIMEOUT_MS, { env })
.catch(() => null);
if (out === null) return false;
for (const line of out.split('\n').map((entry) => entry.trim()).filter(Boolean)) {
- if (!loginOrNull(line)) return false;
- logins.add(line);
+ const [login, type] = line.split('\t');
+ if (!loginOrNull(login)) return false;
+ actors.set(login, type === 'Bot' || type === 'User' ? type : null);
}
}
- if (!logins.size) return true;
+ if (!actors.size) return true;
const reader = createReader(account, env);
const ctx = { account, reader, ownLogins: await ownLoginsFor(account, reader), repo, repoOwned: row.evidence?.repoOwned === true, repoOwner: row.repo_owner };
- for (const login of logins) {
- if (!VOUCHED_TRUST.has(await rateActor(ctx, login))) return false;
+ for (const [login, type] of actors) {
+ if (!VOUCHED_TRUST.has(await rateActor(ctx, login, type))) return false;
}
return true;
}
diff --git a/server/services/githubNotifications.db.test.js b/server/services/githubNotifications.db.test.js
index 48da344257..0ef1614621 100644
--- a/server/services/githubNotifications.db.test.js
+++ b/server/services/githubNotifications.db.test.js
@@ -44,6 +44,8 @@ const { addNotification } = await import('./notifications.js');
const { addTask } = await import('./cosTaskStore.js');
const { runUntrustedContentAnalysis } = await import('./untrustedContent.js');
const { createAccount, updateAccount } = await import('./githubAccounts.js');
+const { __testing: { listAutopilotCandidates } } = await import('./githubNotificationAutopilot.js');
+const { autopilotHandoff } = await import('../lib/githubNotificationTriage.js');
const {
syncAccountNotifications, syncAllNotifications, listNotifications, applyNotificationAction, clearFinishedNotifications, getNotification, runScheduledNotificationCheck, describeScheduledCheck,
listAutomationActivity, undoAutomationAction, listLearnedRules, resolveWithAgent, getAutomationsOverview, setNotificationCadence,
@@ -817,6 +819,60 @@ describe.skipIf(!runDb)('GitHub notifications inbox against Postgres', () => {
expect(actions).not.toContainEqual(['DELETE', 'notifications/threads/1505']);
});
+ it('vouches for GitHub\'s own bots in a thread at the tap, but not a look-alike user', async () => {
+ let taskCount = 0;
+ vi.mocked(addTask).mockReset().mockImplementation(async (task) => ({ id: `task-bot-${++taskCount}`, description: task.description }));
+ const login = account.login;
+ const ownPr = (id) => ({ [`repos/${login}/tool/pulls/${id}`]: { author: login, association: 'OWNER', state: 'open', merged: false } });
+ mockGh(() => listing([
+ thread('1601', { owner: login, repo: 'tool', reason: 'author' }),
+ thread('1602', { owner: login, repo: 'tool', reason: 'author' }),
+ ]), {
+ ...ownPr('1601'), ...ownPr('1602'),
+ [`repos/${login}/tool/issues/1601/comments`]: 'dependabot[bot]\tBot\n',
+ [`repos/${login}/tool/pulls/1601/comments`]: '',
+ [`repos/${login}/tool/pulls/1601/reviews`]: '',
+ [`repos/${login}/tool/issues/1602/comments`]: 'dependabot[bot]\tUser\n',
+ [`repos/${login}/tool/pulls/1602/comments`]: '',
+ [`repos/${login}/tool/pulls/1602/reviews`]: '',
+ });
+ await syncAccountNotifications(account.id);
+ expect(await resolveWithAgent(account.id, '1601')).toMatchObject({ decision: 'handed-off' });
+ await expect(resolveWithAgent(account.id, '1602')).rejects.toMatchObject({ code: 'GITHUB_NOTIFICATION_HANDOFF_REFUSED' });
+ expect(addTask).toHaveBeenCalledTimes(1);
+ });
+
+ it('keeps Autopilot\'s SQL prefilter in agreement with its planner on every open row', async () => {
+ const issue = (id, commentId) => thread(id, {
+ owner: 'acme', repo: 'app', reason: 'subscribed', type: 'Issue', url: `https://api.github.com/repos/acme/app/issues/${id}`,
+ commentUrl: commentId ? `https://api.github.com/repos/acme/app/issues/comments/${commentId}` : null,
+ });
+ vi.mocked(getAllApps).mockResolvedValue([{ id: 'app-acme', name: 'Acme App', repoPath: '/example/acme-app' }]);
+ mockGh(() => listing([
+ issue('2501', 91), issue('2502', 92), issue('2503'),
+ thread('2504', { owner: 'acme', repo: 'app', reason: 'review_requested' }),
+ thread('2505', { owner: 'acme', repo: 'app', reason: 'security_alert', type: 'RepositoryVulnerabilityAlert', url: null }),
+ ]), {
+ 'repos/acme/app/issues/2501': { author: 'teammate', association: 'MEMBER', state: 'open', merged: false },
+ 'repos/acme/app/issues/2502': { author: 'teammate', association: 'MEMBER', state: 'open', merged: false },
+ 'repos/acme/app/issues/2503': { author: 'visitor', association: 'NONE', state: 'open', merged: false },
+ 'repos/acme/app/pulls/2504': { author: 'visitor', association: 'NONE', state: 'open', merged: false },
+ 'repos/acme/app/issues/comments/91': { author: 'colleague', association: 'MEMBER', mentions: 0 },
+ 'repos/acme/app/issues/comments/92': { author: 'visitor', association: 'NONE', mentions: 0 },
+ 'repos/acme/app/collaborators/teammate/permission': { user: { login: 'teammate' }, permission: 'write' },
+ 'repos/acme/app/collaborators/colleague/permission': { user: { login: 'colleague' }, permission: 'write' },
+ 'repos/acme/app/collaborators/visitor/permission': { user: { login: 'visitor' }, permission: 'read' },
+ });
+ await syncAccountNotifications(account.id);
+ const autopilotAccount = { ...account, mode: 'autopilot' };
+ const rows = (await query("SELECT * FROM github_notifications WHERE account_id = $1 AND state = 'open' AND NOT suspect AND NOT (evidence ? 'handoff')", [account.id])).rows;
+ const candidates = new Set((await listAutopilotCandidates(autopilotAccount)).map((row) => row.thread_id));
+ for (const row of rows) {
+ expect([row.thread_id, candidates.has(row.thread_id)]).toEqual([row.thread_id, Boolean(autopilotHandoff({ account: autopilotAccount, row }))]);
+ }
+ vi.mocked(getAllApps).mockResolvedValue([]);
+ });
+
it('gives a security alert outside your apps one security fix task per repo, and one for global advisories', async () => {
await updateAccount(account.id, { mode: 'autopilot' });
let taskCount = 0;