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
fix: make issue watcher review gates fail closed
[._.]/ Adam Eivy323b06ce0956
diff --git a/server/services/issueWatcher.js b/server/services/issueWatcher.jsindex 5ea1e808b2..1ea9153217 100644--- a/server/services/issueWatcher.js+++ b/server/services/issueWatcher.js@@ -376,8 +376,8 @@ Return exactly this payload shape through the completion sentinel:Include one decision for every supplied issue comment and PR, and no others.`;}-async function keepPendingApproval(app, approval, remaining, reason) {- const next = { ...approval, ticks: (approval.ticks || 0) + 1 };+async function keepPendingApproval(app, approval, remaining, reason, patch = {}) {+ const next = { ...approval, ...patch, ticks: (approval.ticks || 0) + 1 };if (next.ticks >= MAX_PENDING_APPROVAL_TICKS) {await notifyPendingApprovalTimeout(app, approval, reason);} else {@@ -420,8 +420,15 @@ async function processPendingApprovals(app, ctx) {continue;}}- const checks = classifyChecks(pr.statusCheckRollup);- const mayMerge = checks === 'green' || (approval.ciPolicy === 'skippable' && checks !== 'failed');+ const checkRollup = Array.isArray(pr.statusCheckRollup) ? pr.statusCheckRollup : [];+ const checks = classifyChecks(checkRollup);+ // An empty rollup is ambiguous immediately after review: CI may simply not+ // have attached yet. A low-risk PR may skip CI only after two consecutive+ // scheduled observations see no checks. Active checks are never waived.+ const maySkipEmptyChecks = approval.ciPolicy === 'skippable'+ && checkRollup.length === 0+ && approval.noChecksObserved === true;+ const mayMerge = checks === 'green' || maySkipEmptyChecks;if (mayMerge && pr.mergeable === 'MERGEABLE') {const merged = await mergePR(app.repoPath, approval.number).catch(() => ({ success: false }));if (merged.success) {@@ -429,7 +436,9 @@ async function processPendingApprovals(app, ctx) {continue;}}- await keepPendingApproval(app, approval, remaining, 'CI or mergeability did not settle');+ await keepPendingApproval(app, approval, remaining, 'CI or mergeability did not settle', {+ noChecksObserved: approval.noChecksObserved === true || checkRollup.length === 0,+ });changed = true;}if (changed) await persistState(app.id, { approvedPullRequests: remaining });@@ -589,7 +598,8 @@ export async function processTaskOutput({ appId, success, payload, task } = {})if (decision.verdict !== 'approve' || decision.findings.length > 0 || target.diffTruncated || diff.length > MAX_DIFF_CHARS) {const summary = decision.summary || 'This change needs follow-up before it can merge.';- const posted = findings.length > 0+ const shouldRequestChanges = decision.verdict === 'request_changes' || findings.length > 0;+ const posted = shouldRequestChanges? await submitReview(ctx, pr.number, { body: summary, event: 'REQUEST_CHANGES', comments: findings })|| await submitReview(ctx, pr.number, { body: summary, event: 'COMMENT', comments: findings }): await submitReview(ctx, pr.number, { body: summary, event: 'COMMENT' })@@ -618,9 +628,9 @@ export async function processTaskOutput({ appId, success, payload, task } = {})continue;}- const checks = classifyChecks(pr.statusCheckRollup);- const maySkip = decision.ciPolicy === 'skippable' && checks !== 'failed';- const mayMerge = pr.mergeable === 'MERGEABLE' && (checks === 'green' || maySkip);+ const checkRollup = Array.isArray(pr.statusCheckRollup) ? pr.statusCheckRollup : [];+ const checks = classifyChecks(checkRollup);+ const mayMerge = pr.mergeable === 'MERGEABLE' && checks === 'green';if (mayMerge) {const result = await mergePR(app.repoPath, pr.number).catch(() => ({ success: false }));if (result.success) {@@ -635,6 +645,7 @@ export async function processTaskOutput({ appId, success, payload, task } = {})url: pr.url,ciPolicy: decision.ciPolicy,rebaseRequired: false,+ noChecksObserved: checkRollup.length === 0,reviewedAt: new Date().toISOString(),ticks: 0,});diff --git a/server/services/issueWatcher.test.js b/server/services/issueWatcher.test.jsindex 341a2ac119..e635f637b5 100644--- a/server/services/issueWatcher.test.js+++ b/server/services/issueWatcher.test.js@@ -246,6 +246,28 @@ describe('processTaskOutput', () => {expect(mergePrMock).not.toHaveBeenCalled();});+ it('submits a blocking review when request-changes has no inline anchor', async () => {+ installDefaultGhMock();+ const payload = {+ issueComments: [],+ pullRequests: [{+ number: 7,+ headSha: 'a'.repeat(40),+ verdict: 'request_changes',+ summary: 'The change removes required compatibility behavior.',+ findings: [],+ rebaseRequired: false,+ ciPolicy: 'required',+ }],+ };++ await processTaskOutput({ appId: APP.id, success: true, payload, task: { metadata } });++ const reviewCall = execGhMock.mock.calls.find(([args]) => args.includes('repos/o/r/pulls/7/reviews') && args.includes('--input'));+ expect(JSON.parse(reviewCall[2].input)).toMatchObject({ event: 'REQUEST_CHANGES', comments: [] });+ expect(mergePrMock).not.toHaveBeenCalled();+ });+it('updates a behind branch when the reviewer requires a rebase, then waits for a fresh review', async () => {installDefaultGhMock();const payload = {@@ -264,7 +286,7 @@ describe('processTaskOutput', () => {expect(mergePrMock).not.toHaveBeenCalled();});- it('merges a clean low-risk PR when the reviewer explicitly marks CI skippable', async () => {+ it('waits one scheduled observation before treating absent CI as skippable', async () => {installDefaultGhMock({ pr: pullRequest({ statusCheckRollup: [] }) });mergePrMock.mockResolvedValue({ success: true });const payload = {@@ -277,8 +299,40 @@ describe('processTaskOutput', () => {const result = await processTaskOutput({ appId: APP.id, success: true, payload, task: { metadata } });- expect(result).toMatchObject({ reviewed: 1, merged: 1 });+ expect(result).toMatchObject({ reviewed: 1, merged: 0 });+ expect(mergePrMock).not.toHaveBeenCalled();+ expect(apps.get(APP.id).issueWatcherState.approvedPullRequests).toEqual([+ expect.objectContaining({ number: 7, ciPolicy: 'skippable', noChecksObserved: true }),+ ]);++ installDefaultGhMock({+ pr: pullRequest({ statusCheckRollup: [] }),+ reviews: [[{ user: { login: 'owner' }, commit_id: 'a'.repeat(40), state: 'APPROVED' }]],+ });+ const followUp = await buildTaskInput({ app: apps.get(APP.id) });++ expect(followUp).toEqual({ skip: { reason: 'baselined' } });expect(mergePrMock).toHaveBeenCalledWith(APP.repoPath, 7);+ expect(apps.get(APP.id).issueWatcherState.approvedPullRequests).toEqual([]);+ });++ it('never waives an actively running check for a low-risk PR', async () => {+ installDefaultGhMock({ pr: pullRequest({ statusCheckRollup: [{ status: 'IN_PROGRESS', conclusion: null }] }) });+ const payload = {+ issueComments: [],+ pullRequests: [{+ number: 7, headSha: 'a'.repeat(40), verdict: 'approve', summary: 'Low-risk documentation change.', findings: [],+ rebaseRequired: false, ciPolicy: 'skippable',+ }],+ };++ const result = await processTaskOutput({ appId: APP.id, success: true, payload, task: { metadata } });++ expect(result).toMatchObject({ reviewed: 1, merged: 0 });+ expect(mergePrMock).not.toHaveBeenCalled();+ expect(apps.get(APP.id).issueWatcherState.approvedPullRequests).toEqual([+ expect.objectContaining({ number: 7, noChecksObserved: false }),+ ]);});it('never waives a known failing check, even when CI was classified skippable', async () => {