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
address review (claude): harden watcher review fallback
[._.]/ Adam Eivy81a9cc1d03da
diff --git a/server/services/agentManagement.js b/server/services/agentManagement.jsindex 95a9ed6e20..3526b4aec7 100644--- a/server/services/agentManagement.js+++ b/server/services/agentManagement.js@@ -491,8 +491,10 @@ const REPLACEMENT_RUNTIME_METADATA_KEYS = new Set(['blockedReason', 'blockedCategory', 'blockedAt', 'blocker', 'failureCount','lastErrorCategory', 'lastFailureAt', 'cooldownUntil', 'totalSpawnCount','orphanRetryCount', 'lastOrphanedAt', 'lastOrphanedAgentId', 'worktreeBusyAttempts',- 'lastSpawnedAt', 'interruptedByRestart', 'lastInterruptedAt', 'lastInterruptedAgentId',+ LAST_SPAWNED_AT_KEY, 'interruptedByRestart', 'lastInterruptedAt', 'lastInterruptedAgentId','outputHookDispatchedAt', 'existingBranch', 'resumedFromAgentId', 'resumeWorktreePath',+ 'autoRetryCount', 'autoRetriedByInvestigation', 'autoRetriedAt', 'autoRetryExhaustedAt',+ 'resolution', 'autoExpiredReason', 'autoExpiredAt',REQUEUED_AT_KEY, RETRY_HOLD_KEY, RETRY_HOLD_SINCE_KEY,...PAUSE_METADATA_KEYS, ...CLAIM_METADATA_KEYS,]);diff --git a/server/services/agentManagement.test.js b/server/services/agentManagement.test.jsindex e0a587c101..7e06b4914b 100644--- a/server/services/agentManagement.test.js+++ b/server/services/agentManagement.test.js@@ -911,6 +911,13 @@ describe('resumeAgent — requeues the paused agent\'s own task', () => {issueWatcher,outputHookDispatchedAt: '2026-08-30T00:00:00.000Z',totalSpawnCount: 3,+ autoRetryCount: 2,+ autoRetriedByInvestigation: 'sys-investigation',+ autoRetriedAt: '2026-08-29T00:00:00.000Z',+ autoRetryExhaustedAt: '2026-08-29T01:00:00.000Z',+ resolution: 'auto-expired',+ autoExpiredReason: 'investigation-resolved',+ autoExpiredAt: '2026-08-29T02:00:00.000Z',},});@@ -920,6 +927,10 @@ describe('resumeAgent — requeues the paused agent\'s own task', () => {expect(replacement.metadata).toMatchObject({ analysisType: 'issue-watcher', issueWatcher });expect(replacement.metadata).not.toHaveProperty('outputHookDispatchedAt');expect(replacement.metadata).not.toHaveProperty('totalSpawnCount');+ for (const key of [+ 'autoRetryCount', 'autoRetriedByInvestigation', 'autoRetriedAt', 'autoRetryExhaustedAt',+ 'resolution', 'autoExpiredReason', 'autoExpiredAt',+ ]) expect(replacement.metadata).not.toHaveProperty(key);});it('leaves a LATER agent\'s pause intact and creates nothing', async () => {diff --git a/server/services/issueWatcher.js b/server/services/issueWatcher.jsindex 0901ffdf97..5e66a0cabe 100644--- a/server/services/issueWatcher.js+++ b/server/services/issueWatcher.js@@ -667,7 +667,9 @@ export async function processTaskOutput({ appId, success, payload, task } = {})&& !diffInsufficient&& blockingFindings.length === 0;if (!canApprove) {- const summary = decision.summary || 'This change needs follow-up before it can merge.';+ const downgraded = hasInvalidFinding && decision.verdict !== 'request_changes';+ const summary = `${decision.summary || 'This change needs follow-up before it can merge.'}${+ downgraded ? '\n\nPortOS could not anchor one or more reported findings to this diff, so the review is blocking until they are restated against exact added lines.' : ''}`;const shouldRequestChanges = decision.verdict === 'request_changes'|| hasInvalidFinding|| blockingFindings.length > 0;@@ -680,11 +682,15 @@ export async function processTaskOutput({ appId, success, payload, task } = {})continue;}+ const approveBody = decision.summary || 'Reviewed: no material issues found.';const approved = await submitReview(ctx, pr.number, {- body: decision.summary || 'Reviewed: no material issues found.',+ body: approveBody,event: 'APPROVE',comments: findings,- });+ }) || (findings.length > 0 && await submitReview(ctx, pr.number, {+ body: approveBody,+ event: 'APPROVE',+ }));if (!approved) continue;reviewed += 1;diff --git a/server/services/issueWatcher.test.js b/server/services/issueWatcher.test.jsindex 02a1d9e283..4a77fe4411 100644--- a/server/services/issueWatcher.test.js+++ b/server/services/issueWatcher.test.js@@ -298,6 +298,32 @@ describe('processTaskOutput', () => {expect(mergePrMock).not.toHaveBeenCalled();});+ it('explains when an approval was blocked because a finding could not be anchored', async () => {+ installDefaultGhMock();+ const payload = {+ issueComments: [],+ pullRequests: [{+ number: 7,+ headSha: 'a'.repeat(40),+ verdict: 'approve',+ summary: 'Looks fine; one follow-up is noted.',+ findings: [{+ path: 'src/example.js', line: 99, side: 'RIGHT', blocking: false,+ body: 'This line is not in the supplied diff.',+ }],+ 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' });+ expect(JSON.parse(reviewCall[2].input).body).toContain('could not anchor one or more reported findings');+ 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 = {@@ -368,6 +394,63 @@ describe('processTaskOutput', () => {expect(mergePrMock).toHaveBeenCalledWith(APP.repoPath, 7);});+ it('approves without inline comments when GitHub rejects the comment anchors', async () => {+ installDefaultGhMock();+ const defaultGhImplementation = execGhMock.getMockImplementation();+ let reviewAttempts = 0;+ execGhMock.mockImplementation(async (args, ...rest) => {+ if (args[0] === 'api' && args.some((arg) => String(arg).endsWith('/pulls/7/reviews'))) {+ reviewAttempts += 1;+ if (reviewAttempts === 1) throw new Error('HTTP 422: invalid review comment');+ }+ return defaultGhImplementation(args, ...rest);+ });+ mergePrMock.mockResolvedValue({ success: true });+ const payload = {+ issueComments: [],+ pullRequests: [{+ number: 7,+ headSha: 'a'.repeat(40),+ verdict: 'approve',+ summary: 'Safe to merge; comment delivery was unavailable.',+ findings: [{+ path: 'src/example.js', line: 2, side: 'RIGHT', blocking: false,+ body: 'Track this small cleanup in a follow-up.',+ }],+ rebaseRequired: false,+ ciPolicy: 'required',+ }],+ };++ const result = await processTaskOutput({ appId: APP.id, success: true, payload, task: { metadata } });++ expect(result).toMatchObject({ reviewed: 1, merged: 1 });+ const reviewCalls = execGhMock.mock.calls.filter(([args]) => args.includes('repos/o/r/pulls/7/reviews') && args.includes('--input'));+ expect(reviewCalls).toHaveLength(2);+ expect(JSON.parse(reviewCalls[1][2].input)).toMatchObject({ event: 'APPROVE', comments: [] });+ expect(mergePrMock).toHaveBeenCalledWith(APP.repoPath, 7);+ });++ it('treats a finding with no explicit blocking flag as blocking and does not merge', async () => {+ installDefaultGhMock();+ const payload = {+ issueComments: [],+ pullRequests: [{+ number: 7, headSha: 'a'.repeat(40), verdict: 'approve',+ summary: 'Looks fine.',+ findings: [{ path: 'src/example.js', line: 2, side: 'RIGHT', body: 'Validate input before this call.' }],+ rebaseRequired: false, ciPolicy: 'required',+ }],+ };++ const result = await processTaskOutput({ appId: APP.id, success: true, payload, task: { metadata } });++ expect(result).toMatchObject({ reviewed: 1, merged: 0 });+ 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' });+ expect(mergePrMock).not.toHaveBeenCalled();+ });+it('does not review or merge when the PR head changed after cognition', async () => {installDefaultGhMock({ pr: pullRequest({ headRefOid: 'c'.repeat(40) }) });const payload = {