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(branch-reconcile): surface a dead agent's uncommitted work instead of reporting "nothing in flight"
[._.]/ Adam Eivy786e757a0d51
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 2f5606fdc3..4313cfc72c 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -1,5 +1,12 @@# Unreleased Changes+## Branch & PR Reconciliation++- **Work an agent left uncommitted is no longer invisible.** When a CoS agent exits before committing — it finished, crashed, or hit the idle reaper — the whole deliverable stays uncommitted in its worktree while its branch still points at the commit it started from. Branch Reconciliation read that branch as "already merged," correctly refused to delete a worktree with unsaved changes, and reported nothing further, so every run announced "no branches in flight" while real work sat there. Three such branches had accumulated on one install. These are now surfaced as in-flight and handed to the reconciliation agent, which reads the uncommitted changes, commits and ships them if the work is finished, and reports what's missing if it isn't — and never deletes them either way.+- A worktree whose agent is still running is untouched, as before. So is a human `/claim` worktree, a locked worktree, and anything outside the machine-owned `agent-*` namespace. If the running-agent list can't be determined, every worktree stays protected rather than being assumed abandoned.+- The new behavior can be turned off per app with the `finishAbandoned` action toggle, alongside the existing cleanup/PR/conflict/merge toggles.+- When Branch Reconciliation parks with nothing to do, the log now says whether branches were held back by a protection guard or skipped because one of those toggles is off, instead of a bare "nothing in-flight."+## Client linting- Client linting now uses ESLint 10 with the maintained ESLint React rule set, preserving PortOS's key React correctness checks without relying on the unmaintained `eslint-plugin-react` compatibility range.diff --git a/server/lib/cosValidation.js b/server/lib/cosValidation.jsindex 51b68db807..11ca316e5a 100644--- a/server/lib/cosValidation.js+++ b/server/lib/cosValidation.js@@ -612,8 +612,10 @@ export const PIPELINE_BEHAVIOR_FLAGS = ['useWorktree', 'openPR', 'prCompletion',// Absolute cap on total agent spawns per task (across all retry types)export const MAX_TOTAL_SPAWNS = 5;-// `cleanupMerged` / `openPr` / `resolveConflicts` / `autoMerge` are the-// per-app action toggles for the `branch-reconcile` task type; `autoClose` is+// `cleanupMerged` / `openPr` / `resolveConflicts` / `autoMerge` /+// `finishAbandoned` are the per-app action toggles for the `branch-reconcile`+// task type (`finishAbandoned` governs committing + shipping the uncommitted+// work left in a dead agent's worktree); `autoClose` is// the `issue-reconcile` toggle (ON unless explicitly false — OFF forbids the// coordinator from closing an issue or filing a follow-up, leaving it to only// comment + release the claim). Each lives in the shared task-metadata@@ -622,7 +624,7 @@ export const MAX_TOTAL_SPAWNS = 5;// sanitizeTaskMetadata.const ALLOWED_TASK_METADATA_KEYS = [...PIPELINE_BEHAVIOR_FLAGS, 'readOnly',- 'cleanupMerged', 'openPr', 'resolveConflicts', 'autoMerge', 'autoClose',+ 'cleanupMerged', 'openPr', 'resolveConflicts', 'autoMerge', 'finishAbandoned', 'autoClose',// Throwaway-worktree posture for programmatic-I/O reasoning tasks (layered-// intelligence): the worktree is discarded without a merge or PR so a reasoning// agent can't land code. See agentWorktreeCleanup.js.diff --git a/server/services/branchReconcile.js b/server/services/branchReconcile.jsindex 9bd6a97e83..c1995e1ac3 100644--- a/server/services/branchReconcile.js+++ b/server/services/branchReconcile.js@@ -56,16 +56,27 @@ const PR_LIST_LIMIT = 200;/*** Pure classifier: map one branch's git/PR facts to a reconcile state.* First match wins.+ * ABANDONED_WIP — dirty worktree of a DEAD CoS agent → agent finishes the work* MERGED — work is fully in the default branch → deterministic cleanup* CONFLICTED — open PR with merge conflicts → agent resolves* IN_REVIEW — open PR, otherwise → agent drives to merge* NEEDS_PR — pushed, not merged, no PR, clean → agent verifies + opens PR* WIP — local-only or dirty worktree → skip + report (never touch)*- * @param {{ hasUpstream:boolean, isMerged:boolean, worktreeDirty:boolean, openPr:({mergeable?:string}|null) }} input- * @returns {'MERGED'|'CONFLICTED'|'IN_REVIEW'|'NEEDS_PR'|'WIP'}+ * @param {{ hasUpstream:boolean, isMerged:boolean, worktreeDirty:boolean, abandonedAgentWorktree?:boolean, openPr:({mergeable?:string}|null) }} input+ * @returns {'ABANDONED_WIP'|'MERGED'|'CONFLICTED'|'IN_REVIEW'|'NEEDS_PR'|'WIP'}*/-export function classifyBranch({ hasUpstream, isMerged, worktreeDirty, openPr }) {+export function classifyBranch({ hasUpstream, isMerged, worktreeDirty, abandonedAgentWorktree, openPr }) {+ // A dead agent's worktree that still holds uncommitted work is the ONE dirty+ // case that must be driven rather than skipped — and it must be caught BEFORE+ // the `isMerged` test, because an agent that exited without committing leaves+ // its branch pointer parked on an old default-branch commit, which reads as+ // MERGED. That combination (merged pointer + dirty tree) is exactly what made+ // these branches invisible: MERGED sent them to `cleanupMerged`, which+ // correctly refused to delete a dirty worktree, so they were only ever+ // reported as `skipped` and never appeared in-flight. The work sat there+ // indefinitely while every run logged "nothing in-flight".+ if (worktreeDirty && abandonedAgentWorktree) return 'ABANDONED_WIP';if (isMerged) return 'MERGED';// A worktree with real uncommitted changes is NEVER handed to the coordinator// agent — even for a branch with an open PR. The agent's per-state actions@@ -151,6 +162,35 @@ export function worktreeProtectionReason({ path, locked, activeAgentIds, ageMs,return null;}+/**+ * Is this worktree a CoS agent workspace whose agent is no longer running?+ *+ * Pure. True only for a `agent-<id>` worktree (the CoS naming convention) that+ * is unlocked and absent from the live-agent set. Paired with a dirty working+ * tree in `classifyBranch`, that is the signature of an agent run that ended —+ * completed, crashed, or reaped — before committing its work.+ *+ * Deliberately narrow: a human `claim-*` worktree, a locked worktree, and the+ * primary checkout all return false, so this can never hand a person's live+ * editing session to an agent that might `git reset` over it. The `agent-*`+ * namespace is machine-owned — nothing but CoS writes there.+ *+ * `activeAgentIds` is a sentinel, not a plain collection: a Set (INCLUDING an+ * empty one — "no agents running", the common case) is an authoritative liveness+ * answer, while a missing/non-Set value means liveness is UNKNOWN and every agent+ * worktree stays protected. Same fail-safe posture as `worktreeProtectionReason`'s+ * unknown-age branch — never infer abandonment from an answer we didn't get.+ *+ * @param {{ path:string, locked?:boolean, activeAgentIds?:Set<string> }} input+ * @returns {boolean}+ */+export function isAbandonedAgentWorktree({ path, locked, activeAgentIds }) {+ if (!path || locked || !(activeAgentIds instanceof Set)) return false;+ const basename = path.split('/').pop() || '';+ if (!basename.startsWith('agent-') || isHumanClaimWorktree(basename)) return false;+ return !activeAgentIds.has(basename);+}+/*** Is a worktree's working tree carrying real (non-lockfile) uncommitted changes?* @param {string} worktreePath@@ -182,11 +222,13 @@ async function worktreeAgeMs(worktreePath) {* always-protected set. Effectful (git + gh).** @param {string} repoPath- * @param {{ defaultBranch:string }} ctx+ * @param {{ defaultBranch:string, activeAgentIds?:Set<string> }} ctx - `activeAgentIds`+ * distinguishes a live agent's worktree from an abandoned one (see+ * `isAbandonedAgentWorktree`); omitting it leaves every agent worktree protected.* @returns {Promise<object[]>} one entry per candidate branch:- * { branch, hasUpstream, isMerged, hasWorktree, worktreePath, worktreeDirty, openPr }+ * { branch, hasUpstream, isMerged, hasWorktree, worktreePath, worktreeDirty, abandonedAgentWorktree, openPr }*/-export async function gatherBranchState(repoPath, { defaultBranch }) {+export async function gatherBranchState(repoPath, { defaultBranch, activeAgentIds = null }) {const protectedSet = new Set([...PROTECTED_BRANCHES, defaultBranch]);const [branches, worktrees, prsByHead] = await Promise.all([@@ -226,6 +268,7 @@ export async function gatherBranchState(repoPath, { defaultBranch }) {worktreeLocked,worktreeAgeMs: worktreeAge,worktreeDirty,+ abandonedAgentWorktree: isAbandonedAgentWorktree({ path: worktreePath, locked: worktreeLocked, activeAgentIds }),openPr: prsByHead.get(b.name) || null});}@@ -300,11 +343,11 @@ export async function cleanupMerged(repoPath, defaultBranch, merged, { activeAge*/export async function reconcile(repoPath = PATHS.root, { cleanup = true, activeAgentIds = new Set() } = {}) {const defaultBranch = await getDefaultBranch(repoPath).catch(() => 'main') || 'main';- const inputs = await gatherBranchState(repoPath, { defaultBranch });+ const inputs = await gatherBranchState(repoPath, { defaultBranch, activeAgentIds });const classified = classifyBranches(inputs);const merged = classified.filter((c) => c.state === 'MERGED');- const inFlight = classified.filter((c) => ['CONFLICTED', 'IN_REVIEW', 'NEEDS_PR'].includes(c.state));+ const inFlight = classified.filter((c) => ['ABANDONED_WIP', 'CONFLICTED', 'IN_REVIEW', 'NEEDS_PR'].includes(c.state));const wip = classified.filter((c) => c.state === 'WIP');const { cleaned, skipped } = cleanup@@ -322,7 +365,8 @@ export async function reconcile(repoPath = PATHS.root, { cleanup = true, activeA// here (next to the classifier that produces their input) rather than in the// scheduler/generator so both the perpetual-drain gate and any prompt builder// share one source of truth. The `actions` object mirrors the per-app task-// metadata toggles (cleanupMerged / openPr / resolveConflicts / autoMerge).+// metadata toggles (cleanupMerged / openPr / resolveConflicts / autoMerge /+// finishAbandoned).// ============================================================/** An action is ON unless the config explicitly set it to false (opt-out). */@@ -336,6 +380,7 @@ export const actionOn = (actions, key) => actions?.[key] !== false;*/export function filterActionable(inFlight, actions) {return inFlight.filter((b) => {+ if (b.state === 'ABANDONED_WIP') return actionOn(actions, 'finishAbandoned');if (b.state === 'NEEDS_PR') return actionOn(actions, 'openPr');if (b.state === 'CONFLICTED') return actionOn(actions, 'resolveConflicts');if (b.state === 'IN_REVIEW') return actionOn(actions, 'resolveConflicts') || actionOn(actions, 'autoMerge');@@ -366,10 +411,28 @@ const driveToMerge = (pr) => [* Per-state instruction to the coordinator/sub-agent.* @param {string} state* @param {object} actions - per-app action toggles- * @param {{ prNumber?: number }} [ctx] - the branch's open PR number, when it has one+ * @param {{ prNumber?: number, worktreePath?: string }} [ctx] - the branch's open PR+ * number (when it has one) and its worktree path (ABANDONED_WIP needs it — the+ * uncommitted work only exists there, never in the primary checkout)*/-export function desiredEndState(state, actions, { prNumber } = {}) {+export function desiredEndState(state, actions, { prNumber, worktreePath } = {}) {const pr = prNumber ? String(prNumber) : '<num>';+ if (state === 'ABANDONED_WIP') {+ // The branch has NO commits of its own — the entire deliverable is the+ // uncommitted tree. So the first move is to READ it, and the loudest rule is+ // "don't commit a half-finished tree": an agent that died mid-edit can leave+ // a syntactically-broken file, and committing that is strictly worse than+ // leaving it for a human, since it converts recoverable scratch state into+ // branch history.+ const where = worktreePath ? `\`${worktreePath}\`` : 'the branch\'s worktree';+ const assess = `This branch has no commits of its own — its work is sitting UNCOMMITTED in ${where}, the worktree of a CoS agent that is no longer running (it exited, crashed, or was reaped before committing). Nothing is lost, but nothing lands either until someone finishes it. Working INSIDE that worktree, run \`git status\` and \`git diff\` (plus \`git diff\` against untracked files) and read the WHOLE change set before touching anything. Then judge whether it is coherent, finished work: the test suites for the touched workspaces pass, no stub/TODO/placeholder left mid-edit, no half-renamed symbol, and a \`.changelog/NEXT.md\` entry present.`;+ const bail = 'If it is NOT finished, do not commit it and do not delete it — leave every file exactly as it is and report what the work appears to be, how far it got, and what is missing, so a human can decide whether to finish or discard it.';+ const commit = 'If it IS finished, commit it on this branch (a message that states what changed and why — never a bare "wip"), then ship it with `/do:pr --no-merge` (by hand, if slash commands are unavailable: self-review the diff, `git push -u origin <branch>`, then `gh pr create` with a Summary + Test plan).';+ if (!actionOn(actions, 'autoMerge')) {+ return `${assess} ${bail} ${commit} Do NOT merge (auto-merge is disabled) — stop once the PR is open and report its URL.`;+ }+ return `${assess} ${bail} ${commit} ${driveToMerge(pr)}`;+ }if (state === 'NEEDS_PR') {const verify = 'Verify the branch\'s work is complete and ready (tests pass, no stubs/TODO markers, changelog present). If NOT ready, report it as incomplete and leave the branch untouched — do not open a half-baked PR.';// `--no-merge` is passed explicitly on BOTH paths — not to disable merging,@@ -431,8 +494,8 @@ export function formatInFlightForPrompt(inFlight, { defaultBranch, actions }) {for (const b of inFlight) {const pr = b.openPr ? ` — PR #${b.openPr.number} (${b.openPr.mergeable})${b.openPr.url ? ` ${b.openPr.url}` : ''}` : ' — no PR';lines.push(`### \`${b.branch}\` [${b.state}]${pr}`);- if (b.worktreePath) lines.push(`- Worktree: \`${b.worktreePath}\``);- lines.push(`- Do: ${desiredEndState(b.state, actions, { prNumber: b.openPr?.number })}`);+ if (b.worktreePath) lines.push(`- Worktree: \`${b.worktreePath}\`${b.state === 'ABANDONED_WIP' ? ' (holds UNCOMMITTED work — read it before doing anything)' : ''}`);+ lines.push(`- Do: ${desiredEndState(b.state, actions, { prNumber: b.openPr?.number, worktreePath: b.worktreePath })}`);lines.push('');}return lines.join('\n');diff --git a/server/services/branchReconcile.test.js b/server/services/branchReconcile.test.jsindex bfdb54b18b..fda3853d67 100644--- a/server/services/branchReconcile.test.js+++ b/server/services/branchReconcile.test.js@@ -39,6 +39,7 @@ vi.mock('../lib/fileUtils.js', () => ({import {classifyBranch, classifyBranches, cleanupMerged, reconcile, gatherBranchState, worktreeProtectionReason,+ isAbandonedAgentWorktree,actionOn, filterActionable, desiredEndState, formatInFlightForPrompt, actionableSignature} from './branchReconcile.js';import * as git from './git.js';@@ -78,6 +79,27 @@ describe('classifyBranch', () => {it('local-only (no upstream), no PR → WIP', () => {expect(classifyBranch({ isMerged: false, openPr: null, hasUpstream: false, worktreeDirty: false })).toBe('WIP');});++ // The exact shape of the three branches that went unreconciled for weeks: a CoS+ // agent exited without committing, so its branch pointer sat on an old `main`+ // commit (reads as MERGED) while the whole deliverable stayed uncommitted in the+ // worktree. MERGED routed it to cleanupMerged, which correctly refused to delete+ // a dirty worktree — so it was only ever `skipped`, never in-flight, and every+ // run logged "nothing in-flight".+ it('classifies a dead agent\'s dirty worktree as ABANDONED_WIP even when the branch reads merged', () => {+ expect(classifyBranch({+ isMerged: true, worktreeDirty: true, abandonedAgentWorktree: true, hasUpstream: true, openPr: null+ })).toBe('ABANDONED_WIP');+ });++ it('leaves a LIVE agent\'s dirty worktree alone (MERGED/WIP, never ABANDONED_WIP)', () => {+ expect(classifyBranch({+ isMerged: true, worktreeDirty: true, abandonedAgentWorktree: false, hasUpstream: true, openPr: null+ })).toBe('MERGED');+ expect(classifyBranch({+ isMerged: false, worktreeDirty: true, abandonedAgentWorktree: false, hasUpstream: true, openPr: null+ })).toBe('WIP');+ });});describe('classifyBranches', () => {@@ -255,6 +277,31 @@ describe('gatherBranchState', () => {});});+describe('isAbandonedAgentWorktree', () => {+ const live = new Set(['agent-aaaaaaaa']);++ it('is true only for an unlocked agent worktree whose agent is not running', () => {+ expect(isAbandonedAgentWorktree({ path: '/wt/agent-bbbbbbbb', activeAgentIds: live })).toBe(true);+ expect(isAbandonedAgentWorktree({ path: '/wt/agent-aaaaaaaa', activeAgentIds: live })).toBe(false);+ expect(isAbandonedAgentWorktree({ path: '/wt/agent-bbbbbbbb', locked: true, activeAgentIds: live })).toBe(false);+ });++ it('never claims a human /claim worktree, a non-agent sibling, or a missing path', () => {+ expect(isAbandonedAgentWorktree({ path: '/wt/claim-fix-thing', activeAgentIds: live })).toBe(false);+ expect(isAbandonedAgentWorktree({ path: '/wt/next-issue-42', activeAgentIds: live })).toBe(false);+ expect(isAbandonedAgentWorktree({ path: '', activeAgentIds: live })).toBe(false);+ });++ // Sentinel, not a plain collection: an empty Set is an authoritative "nothing is+ // running" (the common case), while an omitted/non-Set value means liveness is+ // unknown and must fail safe toward protecting the worktree.+ it('treats an empty Set as authoritative but an absent one as unknown', () => {+ expect(isAbandonedAgentWorktree({ path: '/wt/agent-bbbbbbbb', activeAgentIds: new Set() })).toBe(true);+ expect(isAbandonedAgentWorktree({ path: '/wt/agent-bbbbbbbb' })).toBe(false);+ expect(isAbandonedAgentWorktree({ path: '/wt/agent-bbbbbbbb', activeAgentIds: ['agent-cccccccc'] })).toBe(false);+ });+});+describe('reconcile', () => {it('cleans merged, returns in-flight + wip partitions', async () => {git.getBranches.mockResolvedValue([@@ -277,6 +324,43 @@ describe('reconcile', () => {expect(res.inFlight[0].state).toBe('IN_REVIEW');expect(res.wip.map((i) => i.branch)).toEqual(['wip-local']);});++ // Regression for the "3 orphan cos branches, no active agents, reconcile says+ // nothing in flight" report: surface the branch instead of silently skipping it,+ // and — critically — do NOT delete the worktree holding the only copy of the work.+ it('surfaces a dead agent\'s uncommitted work as in-flight instead of skipping it, and never deletes the worktree', async () => {+ git.getBranches.mockResolvedValue([+ { name: 'cos/task-x/agent-deadbeef', isDefault: false, current: false, tracking: 'origin/main', merged: true }+ ]);+ wt.listWorktrees.mockResolvedValue([+ { path: '/repo/data/cos/worktrees/agent-deadbeef', branch: 'refs/heads/cos/task-x/agent-deadbeef' }+ ]);+ git.isBranchMergedInto.mockResolvedValue(true);+ // Uncommitted work in the worktree.+ execGit.mockResolvedValue({ stdout: ' M server/services/thing.js\n?? server/services/newThing.js\n', exitCode: 0 });++ const res = await reconcile('/repo', { activeAgentIds: new Set() });+ expect(res.inFlight.map((i) => i.state)).toEqual(['ABANDONED_WIP']);+ expect(res.cleaned).toEqual([]);+ expect(wt.forceRemoveWorktreeDir).not.toHaveBeenCalled();+ expect(git.deleteBranch).not.toHaveBeenCalled();+ });++ it('still leaves that branch untouched while its agent is running', async () => {+ git.getBranches.mockResolvedValue([+ { name: 'cos/task-x/agent-deadbeef', isDefault: false, current: false, tracking: 'origin/main', merged: true }+ ]);+ wt.listWorktrees.mockResolvedValue([+ { path: '/repo/data/cos/worktrees/agent-deadbeef', branch: 'refs/heads/cos/task-x/agent-deadbeef' }+ ]);+ git.isBranchMergedInto.mockResolvedValue(true);+ execGit.mockResolvedValue({ stdout: ' M server/services/thing.js\n', exitCode: 0 });++ const res = await reconcile('/repo', { activeAgentIds: new Set(['agent-deadbeef']) });+ expect(res.inFlight).toEqual([]);+ expect(res.skipped.map((s) => s.reason)).toEqual(['worktree-active-agent']);+ expect(wt.forceRemoveWorktreeDir).not.toHaveBeenCalled();+ });});describe('actionOn', () => {@@ -311,6 +395,12 @@ describe('filterActionable', () => {it('never surfaces a non-actionable state (MERGED/WIP)', () => {expect(filterActionable([{ branch: 'm', state: 'MERGED' }, { branch: 'w', state: 'WIP' }], {})).toEqual([]);});++ it('keeps ABANDONED_WIP by default and drops it only when finishAbandoned is off', () => {+ const abandoned = [{ branch: 'z', state: 'ABANDONED_WIP' }];+ expect(filterActionable(abandoned, {}).map((b) => b.branch)).toEqual(['z']);+ expect(filterActionable(abandoned, { finishAbandoned: false })).toEqual([]);+ });});describe('desiredEndState', () => {@@ -319,6 +409,21 @@ describe('desiredEndState', () => {expect(desiredEndState('IN_REVIEW', { autoMerge: false })).toContain('Do NOT merge');});+ it('tells ABANDONED_WIP to read the worktree first, refuse a half-finished commit, then ship', () => {+ const instruction = desiredEndState('ABANDONED_WIP', {}, { worktreePath: '/wt/agent-deadbeef' });+ expect(instruction).toContain('/wt/agent-deadbeef');+ expect(instruction).toContain('UNCOMMITTED');+ expect(instruction).toContain('do not commit it and do not delete it');+ expect(instruction).toContain('/do:pr --no-merge');+ expect(instruction).toContain('gh pr merge <num> --merge --delete-branch');+ });++ it('stops ABANDONED_WIP at an open PR when autoMerge is off', () => {+ const instruction = desiredEndState('ABANDONED_WIP', { autoMerge: false }, { worktreePath: '/wt/agent-deadbeef' });+ expect(instruction).toContain('Do NOT merge');+ expect(instruction).not.toContain('gh pr merge');+ });+it('gives NEEDS_PR a completeness gate and CONFLICTED a rebase instruction', () => {expect(desiredEndState('NEEDS_PR', {})).toContain('/do:pr');expect(desiredEndState('CONFLICTED', {})).toContain('Rebase');diff --git a/server/services/cosTaskGenerator.js b/server/services/cosTaskGenerator.jsindex 4749f1a359..c462682351 100644--- a/server/services/cosTaskGenerator.js+++ b/server/services/cosTaskGenerator.js@@ -1878,7 +1878,8 @@ async function resolveBranchReconcileBlock(app, taskType, metadata, taskSchedulecleanupMerged: metadata.cleanupMerged,openPr: metadata.openPr,resolveConflicts: metadata.resolveConflicts,- autoMerge: metadata.autoMerge+ autoMerge: metadata.autoMerge,+ finishAbandoned: metadata.finishAbandoned};const result = await reconcile(app.repoPath, {cleanup: actions.cleanupMerged !== false,@@ -1904,7 +1905,15 @@ async function resolveBranchReconcileBlock(app, taskType, metadata, taskScheduleconst heldSuffix = heldBack.length? `, ${heldBack.length} merged branch(es) held back (${[...new Set(heldBack.map((s) => s.reason))].join(', ')})`: '';- emitLog('info', `🔀 branch-reconcile parked for ${app.name}: nothing in-flight (cleaned ${result.cleaned.length}${heldSuffix})`, { appId: app.id });+ // In-flight branches that exist but were filtered out by a disabled action+ // toggle are the OTHER way "nothing in-flight" can lie — say so, or the user+ // sees a park while real branches sit there (the same invisibility that hid+ // the abandoned-worktree case).+ const gatedOff = result.inFlight.length;+ const gatedSuffix = gatedOff+ ? `, ${gatedOff} in-flight branch(es) skipped by disabled action toggles (${[...new Set(result.inFlight.map((b) => b.state))].join(', ')})`+ : '';+ emitLog('info', `🔀 branch-reconcile parked for ${app.name}: nothing actionable (cleaned ${result.cleaned.length}${heldSuffix}${gatedSuffix})`, { appId: app.id });return { skip: true };}// Convergence guard — kills the back-to-back re-dispatch loop WITHOUT stallingdiff --git a/server/services/taskSchedule.js b/server/services/taskSchedule.jsindex 657043dc0a..aa46c90b97 100644--- a/server/services/taskSchedule.js+++ b/server/services/taskSchedule.js@@ -232,13 +232,15 @@ export const DEFAULT_TASK_INTERVALS = {// the generator runs the deterministic reconcile every dispatch, and dispatches// the coordinator agent only while actionable in-flight branches remain — then// PARKS on the daily recheckCron. The action toggles (cleanupMerged / openPr /- // resolveConflicts / autoMerge) are per-app taskMetadata booleans (each ON- // unless explicitly false). useWorktree/openPR are LOCKED off (MANAGED_AGENT_OPTIONS):+ // resolveConflicts / autoMerge / finishAbandoned) are per-app taskMetadata+ // booleans (each ON unless explicitly false); `finishAbandoned` covers the work+ // a dead agent left UNCOMMITTED in its worktree — commit + ship it, or report it+ // as unfinished. useWorktree/openPR are LOCKED off (MANAGED_AGENT_OPTIONS):// the coordinator runs in the app's live checkout so it can see + operate on the// sibling worktrees; a CoS-managed worktree would hide the branches and could// trigger cleanupAgentWorktree's auto-merge. Off by default — enabling it is the// user's explicit consent to let it drive PRs on a schedule.- 'branch-reconcile': { type: INTERVAL_TYPES.PERPETUAL, enabled: false, providerId: null, model: null, prompt: null, recheckCron: '0 3 * * *', taskMetadata: { useWorktree: false, openPR: false, cleanupMerged: true, openPr: true, resolveConflicts: true, autoMerge: true } },+ 'branch-reconcile': { type: INTERVAL_TYPES.PERPETUAL, enabled: false, providerId: null, model: null, prompt: null, recheckCron: '0 3 * * *', taskMetadata: { useWorktree: false, openPR: false, cleanupMerged: true, openPr: true, resolveConflicts: true, autoMerge: true, finishAbandoned: true } },// issue-reconcile heals ZOMBIE issues: open + `in-progress` (claimed) yet with// their PR already MERGED and no live claim anywhere — a partial ship left the// claim marker on, so the queue (which skips `in-progress`) never re-picks the