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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
Take GitHub notification trust from the PR author and count same-batch threads as repo history
Claudef9c8849cb90e
diff --git a/client/src/components/github/GitHubThreadDrawer.jsx b/client/src/components/github/GitHubThreadDrawer.jsxindex 7a054b16c3..6528f7ac04 100644--- a/client/src/components/github/GitHubThreadDrawer.jsx+++ b/client/src/components/github/GitHubThreadDrawer.jsx@@ -77,6 +77,7 @@ export default function GitHubThreadDrawer({ accountId, threadId }) {<h3 className="text-xs font-semibold uppercase tracking-wide text-gray-500">Why</h3><p className="text-gray-300">{RULE_LABELS[evidence.rule] || evidence.rule}</p>{evidence.actor && <p className="text-xs text-gray-400">Actor <span className="font-mono">@{evidence.actor}</span></p>}+ {evidence.commenter && <p className="text-xs text-gray-400">Latest comment by <span className="font-mono">@{evidence.commenter}</span></p>}{evidence.subjectState && <p className="text-xs text-gray-400">Thread is {evidence.subjectState}</p>}{evidence.foldedInto && <p className="text-xs text-gray-400">Same failure as a newer notice</p>}{evidence.metadataMissing && <p className="text-xs text-port-warning">GitHub did not return the thread's details; decided from the notification alone.</p>}diff --git a/server/services/githubNotificationTriage.js b/server/services/githubNotificationTriage.jsindex 82ab3260ec..8cdc3684ff 100644--- a/server/services/githubNotificationTriage.js+++ b/server/services/githubNotificationTriage.js@@ -90,33 +90,49 @@ async function triageThread(row, ctx) {const commentPath = repoApiPath(row.latest_comment_api_url, account.host);const subject = await reader.subject(subjectPath);const comment = commentPath && commentPath !== subjectPath ? await reader.comment(commentPath) : null;- const actorLogin = loginOrNull(comment?.author) || loginOrNull(subject?.author);- const actorAssociation = comment?.author ? comment.association : subject?.association;+ const subjectAuthor = loginOrNull(subject?.author);+ const commenter = loginOrNull(comment?.author);+ // Trust attaches to the subject's author; a later commenter can only add+ // suspicion, never lift an outside PR into the trusted lane.+ const actorLogin = subjectAuthor || commenter;- const isOwn = actorLogin && ownLogins.some((login) => login.toLowerCase() === actorLogin.toLowerCase());- const actorHasWriteAccess = Boolean(actorLogin && !isOwn && repoOwned && repo)- && await (await reader.repoTrust(repo)).isTrusted(actorLogin);- const actorIsOrgMember = Boolean(actorLogin && !isOwn && account.trust === 'private' && repo)- && await reader.orgMember(row.repo_owner, actorLogin);- const trust = computeThreadTrust({ actorLogin, ownLogins, repoOwned, actorHasWriteAccess, actorIsOrgMember, accountTrust: account.trust });+ const trustOf = async (login) => {+ const isOwn = ownLogins.some((own) => own.toLowerCase() === login.toLowerCase());+ const actorHasWriteAccess = Boolean(!isOwn && repoOwned && repo) && await (await reader.repoTrust(repo)).isTrusted(login);+ const actorIsOrgMember = Boolean(!isOwn && account.trust === 'private' && repo) && await reader.orgMember(row.repo_owner, login);+ return computeThreadTrust({ actorLogin: login, ownLogins, repoOwned, actorHasWriteAccess, actorIsOrgMember, accountTrust: account.trust });+ };+ // Any other thread from this repo counts as history, whatever its age: rows+ // from one sync share a created_at, so an age comparison would see none.+ let priorThreadsInRepo = null;+ const priorThreads = async () => {+ priorThreadsInRepo ??= Number((await query(+ 'SELECT COUNT(*)::int AS n FROM github_notifications WHERE account_id = $1 AND repo_full_name = $2 AND thread_id <> $3',+ [account.id, row.repo_full_name, row.thread_id],+ )).rows[0].n);+ return priorThreadsInRepo;+ };+ const signalsFor = async (login, loginTrust, association, mentionCount) => (loginTrust === 'outside'+ ? spamSignals({+ trust: loginTrust,+ actorCreatedAt: await reader.userCreatedAt(login),+ actorAssociation: association,+ mentionCount,+ repoOwned,+ priorThreadsInRepo: await priorThreads(),+ reason: row.reason,+ now,+ })+ : []);- const outsider = trust === 'outside';- const priorThreadsInRepo = outsider- ? Number((await query(- 'SELECT COUNT(*)::int AS n FROM github_notifications WHERE account_id = $1 AND repo_full_name = $2 AND thread_id <> $3 AND created_at < $4',- [account.id, row.repo_full_name, row.thread_id, row.created_at],- )).rows[0].n)- : 0;- const signals = spamSignals({- trust,- actorCreatedAt: outsider && actorLogin ? await reader.userCreatedAt(actorLogin) : null,- actorAssociation,- mentionCount: comment?.mentions ?? 0,- repoOwned,- priorThreadsInRepo,- reason: row.reason,- now,- });+ const trust = actorLogin ? await trustOf(actorLogin) : computeThreadTrust({ actorLogin: null });+ const signalSet = new Set(actorLogin+ ? await signalsFor(actorLogin, trust, subjectAuthor ? subject.association : comment?.association, subjectAuthor ? 0 : comment?.mentions ?? 0)+ : []);+ if (commenter && subjectAuthor && commenter.toLowerCase() !== subjectAuthor.toLowerCase()) {+ for (const signal of await signalsFor(commenter, await trustOf(commenter), comment.association, comment.mentions ?? 0)) signalSet.add(signal);+ }+ const signals = [...signalSet];const isCi = row.reason === 'ci_activity' || row.subject_type === 'CheckSuite';const ciBranch = isCi ? parseCiBranch(row.subject_title) : null;@@ -141,6 +157,7 @@ async function triageThread(row, ctx) {rule,signals,actor: actorLogin,+ commenter: commenter && commenter !== actorLogin ? commenter : null,repoOwned,repoManaged,subjectState: subject ? (subject.merged === true ? 'merged' : subject.state || null) : null,diff --git a/server/services/githubNotifications.db.test.js b/server/services/githubNotifications.db.test.jsindex 8affc869bb..4900df058c 100644--- a/server/services/githubNotifications.db.test.js+++ b/server/services/githubNotifications.db.test.js@@ -42,12 +42,12 @@ const runDb = requireDbOrSkip('services/githubNotifications.db.test', dbReady, sconst accountIds = [];-const thread = (id, { updatedAt = '2026-10-01T10:00:00Z', owner = 'octocat', repo = 'hello', title = `Thread ${id}`, reason = 'author', type = 'PullRequest', url } = {}) => ({+const thread = (id, { updatedAt = '2026-10-01T10:00:00Z', owner = 'octocat', repo = 'hello', title = `Thread ${id}`, reason = 'author', type = 'PullRequest', url, commentUrl = null } = {}) => ({id,unread: true,reason,updated_at: updatedAt,- subject: { title, type, url: url === undefined ? `https://api.github.com/repos/${owner}/${repo}/pulls/${id}` : url },+ subject: { title, type, url: url === undefined ? `https://api.github.com/repos/${owner}/${repo}/pulls/${id}` : url, latest_comment_url: commentUrl },repository: { full_name: `${owner}/${repo}`, private: false, owner: { login: owner } },});@@ -216,6 +216,35 @@ describe.skipIf(!runDb)('GitHub notifications inbox against Postgres', () => {expect(detail.events.map((event) => [event.actor, event.kind])).toEqual([['operator', 'mute'], ['automation', 'triaged']]);});+ it('takes trust from the PR author, so a later comment by you leaves an outside PR in the untrusted lane', async () => {+ const login = account.login;+ mockGh(() => listing([+ thread('651', { owner: login, reason: 'review_requested', commentUrl: `https://api.github.com/repos/${login}/hello/issues/comments/9001` }),+ ]), {+ [`repos/${login}/hello/pulls/651`]: { author: 'mallory', association: 'NONE', state: 'open', merged: false },+ [`repos/${login}/hello/collaborators/mallory/permission`]: { user: { login: 'mallory' }, permission: 'read' },+ [`repos/${login}/hello/issues/comments/9001`]: { author: login, association: 'OWNER', mentions: 0 },+ });+ await syncAccountNotifications(account.id);+ const detail = await getNotification(account.id, '651');+ expect(detail).toMatchObject({ trust: 'outside', decision: 'suggest-untrusted-review' });+ expect(detail.evidence).toMatchObject({ actor: 'mallory', commenter: login });+ });++ it('counts sibling threads from one listing as history for the unrelated-repo check', async () => {+ mockGh(() => listing([+ thread('661', { owner: 'workorg', repo: 'service', reason: 'mention' }),+ thread('662', { owner: 'workorg', repo: 'service', reason: 'mention' }),+ ]), {+ 'repos/workorg/service/pulls/661': { author: 'colleague', association: 'MEMBER', state: 'open', merged: false },+ 'repos/workorg/service/pulls/662': { author: 'colleague', association: 'MEMBER', state: 'open', merged: false },+ 'users/colleague': '2019-01-01T00:00:00Z',+ });+ await syncAccountNotifications(account.id);+ const rows = (await listNotifications({ accountId: account.id })).notifications;+ expect(rows.map((row) => [row.threadId, row.suspect, row.decision]).sort()).toEqual([['661', false, 'surface'], ['662', false, 'surface']]);+ });+it('folds repeat default-branch CI notices into the newest one', async () => {const login = account.login;const ci = (id, updatedAt) => thread(id, { owner: login, reason: 'ci_activity', type: 'CheckSuite', url: null, updatedAt, title: 'CI workflow run failed for main branch' });