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(cos): retain uncertain final sweep observations (#12002)

Adam Eivy4066b6b7a964
diff --git a/server/services/branchReconcile.js b/server/services/branchReconcile.js
index 359363b25b..12fe5a34b2 100644
--- a/server/services/branchReconcile.js
+++ b/server/services/branchReconcile.js
@@ -1031,7 +1031,6 @@ export function describeIdleReconcilePark(skipped = [], heldLive = [], { wip = [
}
};
for (const entry of skipped) {
- if (entry.reason === 'not-merged-on-recheck') continue;
const cause = entry.reason?.startsWith('delete-failed') ? 'branch-delete-failed' : entry.reason || 'cleanup-failed';
add(entry, cause);
}
diff --git a/server/services/branchReconcile.test.js b/server/services/branchReconcile.test.js
index 1042c30a40..0199bf8b1c 100644
--- a/server/services/branchReconcile.test.js
+++ b/server/services/branchReconcile.test.js
@@ -2661,14 +2661,14 @@ describe('describeIdleReconcilePark', () => {
});
it('reports disabled cleanup and deletion failure as blockers', () => {
- // A branch no longer merged is reclassified next pass. Disabled cleanup
- // and a failed deletion still leave concrete work that must remain visible.
+ // A failed merge recheck leaves a surviving branch, just like disabled
+ // cleanup and a failed deletion. A one-shot sweep must report all three.
const out = describeIdleReconcilePark([
{ branch: 'a', reason: 'cleanup-disabled' },
{ branch: 'b', reason: 'not-merged-on-recheck' },
{ branch: 'c', reason: 'delete-failed: boom' }
], []);
- expect(out).toEqual({ reason: 'branches-blocked', heldBackMerged: [], counts: { heldBranches: 2, heldDetached: 0 }, skipCauses: { 'cleanup-disabled': 1, 'branch-delete-failed': 1 }, remaining: [{ branch: 'a', reason: 'cleanup-disabled' }, { branch: 'c', reason: 'branch-delete-failed' }], notLaterThan: null });
+ expect(out).toEqual({ reason: 'branches-blocked', heldBackMerged: [], counts: { heldBranches: 3, heldDetached: 0 }, skipCauses: { 'cleanup-disabled': 1, 'not-merged-on-recheck': 1, 'branch-delete-failed': 1 }, remaining: [{ branch: 'a', reason: 'cleanup-disabled' }, { branch: 'b', reason: 'not-merged-on-recheck' }, { branch: 'c', reason: 'branch-delete-failed' }], notLaterThan: null });
});
it('ignores an unreadable retryAt rather than parking on NaN', () => {
diff --git a/server/services/branchReconcileSweep.test.js b/server/services/branchReconcileSweep.test.js
index a8f11227ef..23556a988a 100644
--- a/server/services/branchReconcileSweep.test.js
+++ b/server/services/branchReconcileSweep.test.js
@@ -84,6 +84,15 @@ describe('manual branch reconciliation sweep', () => {
] });
});
+ it.each([
+ [{ skipped: [{ branch: 'moved', reason: 'not-merged-on-recheck' }] }, { branch: 'moved', reason: 'not-merged-on-recheck' }],
+ [{ orphanRemotes: { remoteUnavailable: true, reported: [] } }, { reason: 'remote-state-unavailable' }],
+ ])('does not report drained when the final scan has incomplete evidence (%j)', async (extra, remaining) => {
+ reconcile.mockResolvedValue(scan([], extra));
+ expect(await run()).toEqual({ skip: true });
+ expect(outcome()).toMatchObject({ status: 'incomplete', remaining: [remaining] });
+ });
+
it('preserves the last observation across a failed scan or unavailable ownership state', async () => {
reconcile.mockResolvedValueOnce(scan([branch('a')])).mockRejectedValueOnce(new Error('git unavailable'));
await run();
diff --git a/server/services/cosTaskPreStepBlocks.js b/server/services/cosTaskPreStepBlocks.js
index 35be7a347a..aa47897963 100644
--- a/server/services/cosTaskPreStepBlocks.js
+++ b/server/services/cosTaskPreStepBlocks.js
@@ -518,6 +518,7 @@ export async function resolveBranchReconcileBlock(app, taskType, metadata, taskS
remaining: [
...idlePark.remaining,
...allActionable.map(b => ({ branch: b.branch, reason: 'actionable' })),
+ ...(result.orphanRemotes?.remoteUnavailable ? [{ reason: 'remote-state-unavailable' }] : []),
...(result.orphanRemotes?.reported || []).map(b => ({ branch: typeof b === 'string' ? b : b.branch, reason: 'remote-branch-held' })),
],
nextAction: 'Continue the bounded sweep and rescan after the final batch.',