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
address review (codex): state the live-owner-beats-claim precedence and pin it (#4668)
[._.]/ Adam Eivy2cc58a3a8039
diff --git a/server/services/branchReconcile.js b/server/services/branchReconcile.jsindex 6759608e3f..9a63ca46b0 100644--- a/server/services/branchReconcile.js+++ b/server/services/branchReconcile.js@@ -340,7 +340,11 @@ export function isAbandonedAgentWorktree({ path, locked, activeAgentIds }) {* finish. So this side passes `allowLiveClaim`, while cleanup keeps the hold* through `worktreeProtectionReason` until the claim is stale or provably* shipped. A lock still outranks it: the gate tests the lock BEFORE the- * claim, so a locked claim tree reports `worktree-locked` on its own.+ * claim, so a locked claim tree reports `worktree-locked` on its own — and+ * so does a live agent, on the same ordering. `activeAgentIds` holds+ * `agent-<id>` keys (case 2 above reads them as such), so a claim basename+ * can only appear there out of contract; if one ever did, holding the branch+ * is the fail-safe answer and the intended precedence.* A branch with no worktree at all and no live owner is simply free (null).** @param {{ branch?:string|null, path:string|null, locked?:boolean, activeAgentIds?:Set<string> }} inputdiff --git a/server/services/branchReconcile.test.js b/server/services/branchReconcile.test.jsindex 6a6bc743a8..ad02b54347 100644--- a/server/services/branchReconcile.test.js+++ b/server/services/branchReconcile.test.js@@ -458,6 +458,16 @@ describe('resolveLiveOwnerReason', () => {expect(resolveLiveOwnerReason({ path: '/wt/claim-fix-thing', locked: true, activeAgentIds: live })).toBe('worktree-locked');});+ it('lets a LIVE owner outrank the claim exception, not the other way round', () => {+ // activeAgentIds holds `agent-<id>` keys, so a claim basename can only land+ // there out of contract — but the gate tests liveness BEFORE the claim, so+ // if one ever did, the branch is held rather than dispatched. That is the+ // intended direction: never hand a branch to an agent while something says+ // a process still owns it.+ expect(resolveLiveOwnerReason({ path: '/wt/claim-fix-thing', activeAgentIds: new Set(['claim-fix-thing']) }))+ .toBe('worktree-active-agent');+ });+it('is null for a free worktree, a dead agent, and no worktree at all', () => {expect(resolveLiveOwnerReason({ path: '/wt/agent-bbbbbbbb', activeAgentIds: live })).toBeNull();expect(resolveLiveOwnerReason({ path: '/wt/next-issue-42', activeAgentIds: live })).toBeNull();