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

address review (claude): honor explicit-empty usernames override at schedule surface

Adam Eivyae2117180dc0
diff --git a/server/lib/cosValidation.js b/server/lib/cosValidation.js
index 9e7b19b92c..c1cc2495e6 100644
--- a/server/lib/cosValidation.js
+++ b/server/lib/cosValidation.js
@@ -466,10 +466,14 @@ export function sanitizeTaskMetadata(raw) {
if (list.length) { clean.reviewers = list; hasKeys = true; }
}
// `usernames` is the arbitrary GitHub reviewer-username list — normalize to
- // shell-safe, deduped, capped tokens (strips `@`, drops bogus entries).
+ // shell-safe, deduped, capped tokens (strips `@`, drops bogus entries). Unlike
+ // `reviewers` above, an explicitly empty array is KEPT (not dropped): for
+ // usernames, `[]` is a meaningful "no external gate for this task/type" choice
+ // that must override the Code Review Defaults, matching resolveReviewUsernames'
+ // `Array.isArray` override contract and the task-form/global-panel surfaces.
if (Array.isArray(raw.usernames)) {
- const usernames = normalizeReviewUsernames(raw.usernames);
- if (usernames.length) { clean.usernames = usernames; hasKeys = true; }
+ clean.usernames = normalizeReviewUsernames(raw.usernames);
+ hasKeys = true;
}
if (Object.prototype.hasOwnProperty.call(raw, 'reviewStopMode') && REVIEW_STOP_MODES.includes(raw.reviewStopMode)) {
clean.reviewStopMode = raw.reviewStopMode;
diff --git a/server/lib/validation.test.js b/server/lib/validation.test.js
index e114facb7c..67274828db 100644
--- a/server/lib/validation.test.js
+++ b/server/lib/validation.test.js
@@ -724,13 +724,15 @@ describe('validation.js', () => {
expect(sanitizeTaskMetadata({ reviewers: ['nope'] })).toBeNull();
});
- it('should normalize reviewer usernames and drop an all-invalid/empty list', () => {
+ it('should normalize reviewer usernames and keep an explicit empty override', () => {
expect(sanitizeTaskMetadata({ usernames: ['@CodeReviewbot', 'codereviewbot', 'bad token'] }))
.toEqual({ usernames: ['CodeReviewbot'] });
- // An all-invalid or empty usernames list contributes no keys → null.
- expect(sanitizeTaskMetadata({ usernames: ['bad token', '$(x)'] })).toBeNull();
- expect(sanitizeTaskMetadata({ usernames: [] })).toBeNull();
- // Keeps a valid sibling key when the usernames are dropped.
+ // An explicit array is KEPT even when it normalizes to empty — `[]` is a
+ // meaningful "no external gate" override of the Code Review Defaults.
+ expect(sanitizeTaskMetadata({ usernames: ['bad token', '$(x)'] })).toEqual({ usernames: [] });
+ expect(sanitizeTaskMetadata({ usernames: [] })).toEqual({ usernames: [] });
+ // A non-array usernames value contributes no keys (→ null with no siblings).
+ expect(sanitizeTaskMetadata({ usernames: 'nope' })).toBeNull();
expect(sanitizeTaskMetadata({ reviewLoop: true, usernames: ['@Bot'] }))
.toEqual({ reviewLoop: true, usernames: ['Bot'] });
});
diff --git a/server/services/cleanupAgentWorktree.test.js b/server/services/cleanupAgentWorktree.test.js
index 2b0e6141dc..1d02a48952 100644
--- a/server/services/cleanupAgentWorktree.test.js
+++ b/server/services/cleanupAgentWorktree.test.js
@@ -648,6 +648,46 @@ describe('cleanupAgentWorktree - openPR path', () => {
expect(followUp.metadata.reviewLoopReviewers).toEqual(['codex', 'antigravity', 'copilot']);
});
+ // --- arbitrary GitHub reviewer usernames (gate-merge) ---
+
+ it('stamps reviewLoopReviewerUsernames onto the follow-up (normalized, @-stripped)', async () => {
+ git.push.mockResolvedValue(undefined);
+ git.createPR.mockResolvedValue({ success: true, url: 'https://github.com/test/repo/pull/60' });
+ git.requestCopilotReview.mockResolvedValue({ success: true });
+ addTask.mockResolvedValue({ id: 'sys-rl-u' });
+
+ await cleanupAgentWorktree('agent-1', true, {
+ openPR: true, requestCopilotReview: true, reviewers: ['copilot'],
+ usernames: ['@CodeReviewbot', 'bad token', 'codereviewbot'], description: 'Build',
+ originalTask: { id: 'task-orig', priority: 'MEDIUM', metadata: { app: 'sparsetree' }, description: 'Build' }
+ });
+
+ expect(addTask).toHaveBeenCalledTimes(1);
+ const [followUp] = addTask.mock.calls[0];
+ expect(followUp.metadata.reviewLoopReviewers).toEqual(['copilot']);
+ expect(followUp.metadata.reviewLoopReviewerUsernames).toEqual(['CodeReviewbot']);
+ });
+
+ it('spawns a username-only follow-up on a non-GitHub forge (copilot stripped, username drives the loop)', async () => {
+ git.push.mockResolvedValue(undefined);
+ git.createPR.mockResolvedValue({ success: true, url: 'https://gitlab.com/group/proj/-/merge_requests/13' });
+ git.requestCopilotReview.mockResolvedValue({ success: true, skipped: true });
+ addTask.mockResolvedValue({ id: 'sys-rl-uonly' });
+
+ await cleanupAgentWorktree('agent-1', true, {
+ openPR: true, requestCopilotReview: true, reviewers: ['copilot'],
+ usernames: ['CodeReviewbot'], description: 'Build',
+ originalTask: { id: 'task-orig', metadata: {}, description: 'Build' }
+ });
+
+ // Copilot is GitHub-only and stripped on GitLab, but the username reviewer is
+ // forge-agnostic and keeps the follow-up alive with an empty keyed list.
+ expect(addTask).toHaveBeenCalledTimes(1);
+ const [followUp] = addTask.mock.calls[0];
+ expect(followUp.metadata.reviewLoopReviewers).toEqual([]);
+ expect(followUp.metadata.reviewLoopReviewerUsernames).toEqual(['CodeReviewbot']);
+ });
+
// --- skipMerge tests for review-loop follow-up cleanup ---
it('should pass merge: false in the auto-merge fallback when skipMerge is true (review-loop follow-up cleanup)', async () => {