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: let issue-reconcile run when the merged-PR window is full
[._.]/ Adam Eivy4c330c158d32
diff --git a/server/services/issueReconcile.js b/server/services/issueReconcile.jsindex fee1117713..0b5c42eafc 100644--- a/server/services/issueReconcile.js+++ b/server/services/issueReconcile.js@@ -308,6 +308,23 @@ function normalizeGithubIssue(issue) {};}+/**+ * Whether the three forge lists carry the full claim state. In-progress issues and+ * open PRs must be unsaturated. The merged-PR list is a rolling window that is+ * always full in an active repo, so saturation alone is not disqualifying: it is+ * complete enough when its oldest merge predates every in-progress issue's+ * creation (a PR cannot ship an issue that did not exist yet).+ */+function listsAreComplete(inProgress, merged, open) {+ if (inProgress.length >= GH_LIST_LIMIT || open.length >= GH_LIST_LIMIT) return false;+ if (merged.length < GH_LIST_LIMIT) return true;+ const oldestMerge = Math.min(...merged.map((pr) => Date.parse(pr.mergedAt)));+ const oldestIssue = Math.min(...inProgress.map((i) => Date.parse(i.createdAt)));+ if (!Number.isFinite(oldestMerge)) return false;+ if (inProgress.length === 0) return true;+ return Number.isFinite(oldestIssue) && oldestMerge <= oldestIssue;+}+/*** Fetch issue/PR facts from GitHub, normalized to the common shape. Returns null* on any gh failure (degrade: the caller treats null as "nothing to reconcile /@@ -335,7 +352,7 @@ async function getGithubState(repoSpec, fullName, apiHost = null) {const [issuesRaw, mergedRaw, openRaw] = await Promise.all([ghList(['issue', 'list', '--repo', repoSpec, '--state', 'open','--label', IN_PROGRESS_LABEL, '--limit', String(GH_LIST_LIMIT),- '--json', 'number,title,labels,assignees,url,updatedAt,author'], 'gh issue list'),+ '--json', 'number,title,labels,assignees,url,updatedAt,createdAt,author'], 'gh issue list'),ghList(['pr', 'list', '--repo', repoSpec, '--state', 'merged','--limit', String(GH_LIST_LIMIT),'--json', 'number,headRefName,body,url,mergedAt'], 'gh pr list --state merged'),@@ -357,7 +374,7 @@ async function getGithubState(repoSpec, fullName, apiHost = null) {const mergedPrs = safeJSONParse(mergedRaw, null);const openPrs = safeJSONParse(openRaw, null);if (!Array.isArray(mergedPrs) || !Array.isArray(openPrs)) return null;- if ([inProgressRaw, mergedPrs, openPrs].some(rows => rows.length >= GH_LIST_LIMIT)) {+ if (!listsAreComplete(inProgressRaw, mergedPrs, openPrs)) {console.warn('⚠️ issue-reconcile: forge lists reached the completeness limit; withholding cleanup until the full claim state is available');return null;}diff --git a/server/services/issueReconcile.test.js b/server/services/issueReconcile.test.jsindex e30bc86969..3c1d089c5c 100644--- a/server/services/issueReconcile.test.js+++ b/server/services/issueReconcile.test.js@@ -274,6 +274,23 @@ describe('reconcile', () => {expect(result.live).toHaveLength(0);});+ describe('saturated forge lists', () => {+ const fullMerged = (oldest) => Array.from({ length: 200 }, (_, i) => ({+ number: 5000 + i, headRefName: 'x', body: '', mergedAt: i === 199 ? oldest : daysAgo(1),+ }));+ const issue = { number: 2220, title: 't', labels: [{ name: 'in-progress' }], assignees: [], url: 'u', createdAt: daysAgo(10) };++ it('a full merged-PR window that reaches back past the oldest claim is still complete', async () => {+ mockGh({ issues: [issue], merged: fullMerged(daysAgo(30)) });+ expect(await reconcile('/repo', { now: NOW })).not.toBeNull();+ });++ it('a full merged-PR window that starts after the oldest claim withholds cleanup', async () => {+ mockGh({ issues: [issue], merged: fullMerged(daysAgo(2)) });+ expect(await reconcile('/repo', { now: NOW })).toBeNull();+ });+ });+it('a live open PR keeps the issue LIVE (not a zombie)', async () => {mockGh({issues: [{ number: 2220, title: 't', labels: [{ name: 'in-progress' }], assignees: [], url: 'u' }],