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

Retry a skipped GitHub notification sort an hour later

Claudeeb4ee4541529
diff --git a/server/services/githubNotificationAssist.js b/server/services/githubNotificationAssist.js
index 6b095c5b62..abaff359a4 100644
--- a/server/services/githubNotificationAssist.js
+++ b/server/services/githubNotificationAssist.js
@@ -29,6 +29,10 @@ const MAX_SORTS_PER_RUN = 10;
const MAX_ACTIONS_PER_RUN = 50;
const ASSIST_MODES = new Set(['assist']);
const ACTIONABLE_DECISIONS = ['handled-by-pr-workflow', 'suggest-mark-read', 'suggest-done', 'suggest-mute'];
+// A skipped sort is retried an hour later (a provider added, a timeout), except
+// when the text itself was refused; new activity re-triages either way.
+const RETRY_SKIPPED_MS = 60 * 60 * 1000;
+const FINAL_SKIPS = new Set(['untrusted-content-blocked', 'untrusted-content-too-large']);
const SORT_PROMPT = `Sort one GitHub notification for its recipient's inbox. Answer "surface" when the recipient should read or act on it, "done" when it is purely informational and needs nothing from them, or "suggest-mute" when it is recurring noise from a thread they do not need to follow. When unsure, answer "surface". Return ONLY a JSON object: {"verdict":"surface|done|suggest-mute"}.`;
const sortSchema = z.object({ verdict: z.enum(ASSIST_VERDICTS) }).strict();
@@ -75,7 +79,8 @@ async function sortThread(account, env, row, selection) {
async function sortUndecided(account, env) {
const { rows } = await query(
`SELECT * FROM github_notifications WHERE account_id = $1 AND state = 'open' AND NOT suspect
- AND decision = 'needs-you' AND evidence->>'rule' = 'default' AND NOT (evidence ? 'ai')
+ AND decision = 'needs-you' AND evidence->>'rule' = 'default'
+ AND (NOT (evidence ? 'ai') OR (evidence->'ai'->>'retryAfter')::timestamptz <= NOW())
ORDER BY gh_updated_at DESC LIMIT ${MAX_SORTS_PER_RUN}`,
[account.id],
);
@@ -93,6 +98,7 @@ async function sortUndecided(account, env) {
return { skipped: 'untrusted-content-failed' };
});
const decided = outcome.verdict ? decisionFromVerdict(outcome.verdict) : null;
+ if (!decided && !FINAL_SKIPS.has(outcome.skipped)) outcome.retryAfter = new Date(Date.now() + RETRY_SKIPPED_MS).toISOString();
await withTransaction(async (client) => {
await client.query(
`UPDATE github_notifications SET decision = COALESCE($3, decision),
diff --git a/server/services/githubNotifications.db.test.js b/server/services/githubNotifications.db.test.js
index e0663211c3..de7ffce644 100644
--- a/server/services/githubNotifications.db.test.js
+++ b/server/services/githubNotifications.db.test.js
@@ -309,7 +309,7 @@ describe.skipIf(!runDb)('GitHub notifications inbox against Postgres', () => {
// The injected comment got a verdict but no action and no change of trust.
expect(byId['904']).toMatchObject({ decision: 'suggest-done', trust: 'outside', state: 'open', suspect: false });
expect(byId['905']).toMatchObject({ decision: 'needs-you', state: 'open' });
- expect((await getNotification(account.id, '905')).evidence.ai).toEqual({ skipped: 'untrusted-content-invalid-response' });
+ expect((await getNotification(account.id, '905')).evidence.ai).toMatchObject({ skipped: 'untrusted-content-invalid-response', retryAfter: expect.any(String) });
const activity = await listAutomationActivity();
const mine = activity.filter((entry) => entry.accountId === account.id);
@@ -321,10 +321,14 @@ describe.skipIf(!runDb)('GitHub notifications inbox against Postgres', () => {
expect.objectContaining({ repoFullName: `${login}/hello`.toLowerCase(), reason: 'mention', actor: 'alice', decision: 'surface', hits: 1 }),
]);
- // The next run leaves the undone thread alone.
+ // The next run leaves the undone thread alone, and retries the skipped
+ // sort once its retry time has passed.
+ await query(`UPDATE github_notifications SET evidence = jsonb_set(evidence, '{ai,retryAfter}', '"2000-01-01T00:00:00Z"') WHERE account_id = $1 AND thread_id = '905'`, [account.id]);
+ vi.mocked(runUntrustedContentAnalysis).mockResolvedValue({ ok: true, value: { verdict: 'surface' } });
actions.length = 0;
await syncAccountNotifications(account.id);
expect(actions).toEqual([]);
+ expect(await getNotification(account.id, '905')).toMatchObject({ decision: 'surface', rule: 'ai-surface' });
});
it('learns to quiet a repo, reason and actor after the same correction twice', async () => {