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

fix: preserve issue claims owned by other accounts (#8774)

[._.]/ Adam Eivye5ee97bfa695
diff --git a/server/services/branchReconcile.js b/server/services/branchReconcile.js
index 7704a4a9a2..2a8b21c53c 100644
--- a/server/services/branchReconcile.js
+++ b/server/services/branchReconcile.js
@@ -935,15 +935,24 @@ export function describeIdleReconcilePark(skipped = [], heldLive = []) {
* enterprise hosts. A forge outage must never undo or block local cleanup.
* The in-progress marker keeps the issue ineligible for a new claim until this
* edit: deleting the local branch alone does not release it to the claim queue.
- * Only our own assignment is removed; other assignees are left untouched.
+ * A fresh assignee read preserves claims now held by another account.
*/
async function releaseRetiredClaim(repoPath, branch, { origin, forgeExec, forgeAccount = null } = {}) {
const issue = /^claim\/issue-([1-9]\d*)$/.exec(branch)?.[1];
if (!issue) return;
await (async () => {
- const repoSpec = githubRepoSpec(origin === undefined ? await getOriginInfo(repoPath) : origin);
+ const target = origin === undefined ? await getOriginInfo(repoPath) : origin;
+ const repoSpec = githubRepoSpec(target);
if (!repoSpec) return;
const { cwd, env } = forgeExec || await resolveForgeExecOptions(repoPath, { forgeAccount });
+ const login = (await execGh([
+ 'api', 'user', '--hostname', githubApiHost(target.host), '--jq', '.login'
+ ], undefined, { cwd, env })).trim();
+ const current = safeJSONParse(await execGh([
+ 'issue', 'view', issue, '--repo', repoSpec, '--json', 'assignees'
+ ], undefined, { cwd, env }), null);
+ if (!login || !Array.isArray(current?.assignees)) throw new Error('claim ownership unavailable');
+ if (current.assignees.length !== 1 || current.assignees[0]?.login !== login) return;
await execGh([
'issue', 'edit', issue, '--repo', repoSpec,
'--remove-assignee', '@me', '--remove-label', 'in-progress'
diff --git a/server/services/branchReconcile.test.js b/server/services/branchReconcile.test.js
index bb3a411a5d..3de1465cb7 100644
--- a/server/services/branchReconcile.test.js
+++ b/server/services/branchReconcile.test.js
@@ -287,8 +287,15 @@ describe('classifyBranches', () => {
});
});
+const mockOwnedClaim = () => execGh.mockImplementation(async (args) => {
+ if (args[0] === 'api') return 'example-owner';
+ if (args[0] === 'issue' && args[1] === 'view') return JSON.stringify({ assignees: [{ login: 'example-owner' }] });
+ return '[]';
+});
+
describe('retired claim markers in reconcile', () => {
it('releases early-reaped claims on the enterprise host with the pinned account', async () => {
+ mockOwnedClaim();
getOriginInfo.mockResolvedValue({ hasOrigin: true, host: 'github.example.com', fullName: 'example/app' });
wt.reapMergedWorktrees.mockResolvedValue({ reaped: [{ branch: 'claim/issue-42', branchDeleted: true }], skipped: [] });
git.getBranches.mockResolvedValue([]);
@@ -297,6 +304,7 @@ describe('retired claim markers in reconcile', () => {
'issue', 'edit', '42', '--repo', 'github.example.com/example/app',
'--remove-assignee', '@me', '--remove-label', 'in-progress'
], undefined, { cwd: '/repo', env: PINNED_ENV });
+ expect(execGh).toHaveBeenCalledWith(['api', 'user', '--hostname', 'github.example.com', '--jq', '.login'], undefined, { cwd: '/repo', env: PINNED_ENV });
expect(resolveForgeExecOptionsMock).toHaveBeenCalledWith('/repo', { forgeAccount: 'app-account' });
expect(resolveForgeExecOptionsMock).toHaveBeenCalledOnce();
});
@@ -395,6 +403,7 @@ describe('cleanupMerged', () => {
});
it('releases a retired issue claim with the repository credential after deletion', async () => {
+ mockOwnedClaim();
git.hasBranchMergeEvidence.mockResolvedValue(true);
await cleanupMerged('/repo', 'main', [{ branch: 'claim/issue-42', worktreePath: '/wt/retired' }]);
expect(execGh).toHaveBeenCalledWith([
@@ -404,6 +413,20 @@ describe('cleanupMerged', () => {
expect(execGh.mock.invocationCallOrder[0]).toBeGreaterThan(git.deleteBranch.mock.invocationCallOrder[0]);
});
+ it.each([
+ { assignees: [] },
+ { assignees: [{ login: 'other-owner' }] },
+ { assignees: [{ login: 'example-owner' }, { login: 'other-owner' }] }
+ ])('preserves claim markers when the assignees are not solely ours: %j', async ({ assignees }) => {
+ git.hasBranchMergeEvidence.mockResolvedValue(true);
+ execGh.mockImplementation(async (args) => args[0] === 'api'
+ ? 'example-owner'
+ : JSON.stringify({ assignees }));
+ const result = await cleanupMerged('/repo', 'main', [{ branch: 'claim/issue-42' }]);
+ expect(result.cleaned).toEqual(['claim/issue-42']);
+ expect(execGh.mock.calls.some(([args]) => args[0] === 'issue' && args[1] === 'edit')).toBe(false);
+ });
+
it('leaves markers intact for a live owner or a failed branch deletion', async () => {
git.hasBranchMergeEvidence.mockResolvedValue(true);
const branch = { branch: 'claim/issue-42', worktreePath: '/wt/claim-issue-42', worktreeAgeMs: 10 * 24 * 60 * 60 * 1000 };