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: limit the no-PR hold release to branches fully contained in the default branch (#12905)
Adam Eivyb140e1f7bb17
diff --git a/server/services/branchCompletionPolicy.js b/server/services/branchCompletionPolicy.jsindex 94d49a2d19..3b2f82a888 100644--- a/server/services/branchCompletionPolicy.js+++ b/server/services/branchCompletionPolicy.js@@ -239,22 +239,27 @@ export async function readBranchCompletionHold(input, deps = {}) {/** A review-then-merge run that never opened a PR and left no commit the default* branch lacks has nothing to review or merge, and no later receipt can name a- * PR to release it. Every other hold (leave-open, a recorded PR, unmerged- * commits, an unresolvable default branch) is kept.+ * PR to release it. Strict ancestry, not patch equivalence: a squash- or+ * rebase-merged tip had a PR whose legacy record may simply lack its URL, and+ * that case still needs the scoped operator review. Every other hold (leave-open,+ * a recorded PR, unmerged commits, an unresolvable default branch) is kept.*/async function isVacuousReviewObligation(input, decision, tip) {if (decision.reason !== 'pr-completion-review-required' || input.prUrl|| !/^[a-f0-9]{40,64}$/i.test(tip || '')|| decision.policies.some(policy => policy.completion === PR_COMPLETIONS.LEAVE_OPEN || retirementPr(policy))) return false;- const { getDefaultBranch, hasBranchMergeEvidence } = await import('./git.js');+ const { getDefaultBranch } = await import('./git.js');const base = await getDefaultBranch(input.repoPath, { strict: true }).catch(() => null);if (!base) return false;- // A stale origin/<default> only makes the ancestry check stricter: whatever it- // contains the current default contains too.const { execGit } = await import('../lib/execGit.js');- const remote = await execGit(['rev-parse', '--verify', `origin/${base}^{commit}`], input.repoPath, { ignoreExitCode: true })- .then(result => (result.exitCode === 0 ? `origin/${base}` : null), () => null);- return hasBranchMergeEvidence(input.repoPath, tip, remote || base).catch(() => false);+ // A stale origin/<default> only makes the check stricter: whatever it+ // contains the current default contains too.+ for (const target of [`origin/${base}`, base]) {+ const ancestor = await execGit(['merge-base', '--is-ancestor', tip, target], input.repoPath, { ignoreExitCode: true })+ .then(result => result.exitCode === 0, () => false);+ if (ancestor) return true;+ }+ return false;}/** Called with task policy and forge-observed identity, never provider prose.diff --git a/server/services/branchCompletionPolicy.test.js b/server/services/branchCompletionPolicy.test.jsindex 3cebc08918..06cde01714 100644--- a/server/services/branchCompletionPolicy.test.js+++ b/server/services/branchCompletionPolicy.test.js@@ -20,7 +20,7 @@ vi.mock('./cosAgentLifecycle.js', () => ({getAgentRecord: async id => runtime.agents[id],updateAgent: async (id, patch) => { runtime.agents[id].metadata = { ...runtime.agents[id].metadata, ...patch.metadata }; },}));-vi.mock('../lib/execGit.js', () => ({ execGit: vi.fn(async args => ({ exitCode: 0,+vi.mock('../lib/execGit.js', () => ({ execGit: vi.fn(async args => ({ exitCode: args[0] === 'merge-base' && !runtime.merged ? 1 : 0,stdout: args[0] === 'rev-parse' ? runtime.tip : args[0] === 'rev-list' ? '0\t1' : '',})) }));vi.mock('../lib/gitRemote.js', () => ({ getOriginInfo: async () => ({ hasOrigin: true, isGithub: true, host: 'github.com', fullName: 'example/repository' }) }));