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
feat: JIRA zombie-scan sibling for issue-reconcile (#2259)
Adam Eivyc1fc66a4e4e5
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 9b3525df44..5d38f2625b 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -2,6 +2,8 @@## CoS Agents+- **[issue-2259] `issue-reconcile` now heals JIRA zombie tickets as well as GitHub/GitLab issues.** Following the GitLab sibling (#2249), the zombie-scan is now JIRA-aware. JIRA has no `in-progress` label to release, so the zombie is STATUS-based: a ticket left **In Review** (the claim-issue-jira success end-state) whose MR/PR shipped with remaining scope and NO live `claim/<KEY>` branch anywhere. Detection flows through the PortOS JIRA API (`fetchMyCurrentSprintTickets` — a new non-swallowing variant of `getMyCurrentSprintTickets` so a transient API blip skips-without-parking instead of being misread as an empty sprint) + git-ref scan for `claim/<KEY>` / `cos/…/<KEY>/…` claim branches — no `gh`/`glab` equivalent. JIRA tickets normalize into the SAME common `{ number, title, url, status, hasMergedPr, hasLiveClaim, hasActiveAgent }` shape the forges use, so the pure classifier/signature stay shared: In-Review → ZOMBIE, plain In-Progress → STALLED, To Do / Done → excluded so the scan converges. Routing mirrors `resolveAppWorkTracker` — JIRA is NEVER auto-selected from the git host; it's chosen only when the app's resolved `workTracker` is `'jira'` with enabled `jira.instanceId`/`projectKey`. The coordinator prompt gains a JIRA arm (heal via ticket transitions + `POST /api/jira/instances/:id/tickets` rather than close+relabel), bumped to v3 with the v2 body preserved in `PREVIOUS_DEFAULT_PROMPTS`. (`server/services/issueReconcile.js`, `server/services/jira.js`, `server/services/cosTaskGenerator.js`, `server/services/taskPromptDefaults/`)+- **Claude Code TUI agents no longer fail `paste-not-rendered` on every multi-line prompt.** The #2192 paste-verification guard confirmed a paste had landed by looking for the prompt's literal text in the TUI buffer — but Claude Code collapses a multi-line bracketed paste into a `[Pasted text #N]` chip and *hides* the pasted body text, and it reflows single lines with cursor-positioning escapes instead of literal space bytes between words. Both made the text check false-negative, so every `claude-code-tui` CoS agent retried 3× and died with `paste-not-rendered` despite the paste landing perfectly (100% reproduction across real runs, 2026-07-05). The gate now treats the TUI's own paste-commit **marker** as authoritative proof of delivery (checked first, via a new `isPasteConfirmed` helper), and only falls back to text matching for the markerless path — where the match is now whitespace-insensitive so a space-less reflowed line still matches. Captured transcripts from the real incident are pinned as regression tests. (`server/lib/tuiHandshake.js`, `server/services/agentTuiSpawning.js`)- **[issue-2228] A TUI-transcript-analysis prompt that itself embeds a `[Pasted text #N]` literal no longer false-fails the paste.** The marker-authoritative gate above subtracts the marker count the prompt itself carried, so an echoed `[Pasted text #N]` isn't mistaken for the TUI's own commit — correct for the inline (uncollapsed) path, but wrong when Claude Code *collapses* a multi-line self-marker-containing prompt into its own single chip and hides the body: the buffer then shows one marker while the prompt also carried one (`1 > 1` is false), and the hidden body also defeats the text fallback — so the agent died `paste-not-rendered` despite the paste landing. Paste confirmation now also recognizes Claude's collapsed-chip shape (a marker present alongside the "paste again to expand" affordance) as authoritative proof of delivery — chrome the TUI only renders on its own genuine commit, so it can't re-introduce the echoed-marker false-positive the subtraction guards. A misleading code comment claiming the collapsed transcript paste "simply falls back to the timer, which is safe" is corrected. (`server/lib/tuiHandshake.js`)diff --git a/docs/plans/2026-07-06-issue-reconcile.md b/docs/plans/2026-07-06-issue-reconcile.mdindex b183958f33..a31b4e33fb 100644--- a/docs/plans/2026-07-06-issue-reconcile.md+++ b/docs/plans/2026-07-06-issue-reconcile.md@@ -104,12 +104,28 @@ on non-GitHub apps; GitLab/JIRA siblings are deferred (see PLAN.md).drives, never destroys — but promoting open/merged list failures totransient-null (skip, don't misclassify) is a worthwhile cross-forge hardening.Not done here to keep the two forges behaviorally identical to the reviewed v1.-- **JIRA (deferred → follow-up #2259).** The JIRA "zombie" analog is status-based,- not label-based (a ticket left *In Review*/*Done* with remaining scope + no live- claim), and heals through the PortOS JIRA API (`my-sprint-tickets` + ticket status- + linked MR/PR → record remaining scope + `POST /api/jira/instances/:id/tickets`)- rather than a forge CLI — a materially different mechanic. Split out to keep the- GitLab slice mergeable and well-tested.+- **JIRA (shipped #2259).** The JIRA "zombie" analog is status-based, not+ label-based (a ticket left *In Review* with remaining scope + no live claim; JIRA+ has no `in-progress` label to release), and heals through the PortOS JIRA API+ (`my-sprint-tickets` + ticket status → record remaining scope + ticket+ transitions + `POST /api/jira/instances/:id/tickets`) rather than a forge CLI.+ Implemented by normalizing JIRA sprint tickets into the SAME common issue shape+ the forge gatherers produce (KEY → `number`, status carried for the convergence+ signature) so the pure classifier / signature stay shared: an **In-Progress**-+ category ticket whose status name matches *In Review* → ZOMBIE, a plain+ In-Progress → STALLED, **To Do** (not started) / **Done** (terminal) → excluded+ so the scan converges. The live-claim guard scans `claim/<KEY>` / `cos/…/<KEY>/…`+ refs (local AND remote) by ticket KEY — an MR still open under review keeps its+ branch, reading LIVE; a merged-and-deleted branch reads as a zombie. Routing+ mirrors `resolveAppWorkTracker`: JIRA is NEVER auto-selected from the git host —+ it's chosen only when the app's resolved `workTracker` is `'jira'` with enabled+ `jira.instanceId`/`projectKey`, threaded into `reconcile()` as a `jira` option+ (a JIRA-specific gatherer branch, not an origin-host lookup). Added a strict+ `fetchMyCurrentSprintTickets` (the existing `getMyCurrentSprintTickets` swallows+ errors to `[]` for the UI; the reconcile scan needs the throw so a transient+ failure skips-without-parking instead of being misread as an empty sprint).+ Coordinator prompt bumped to v3 (adds the JIRA arm — transitions + `POST+ tickets`); v2 preserved in `PREVIOUS_DEFAULT_PROMPTS`.## Part C — heal the three current zombies (done)diff --git a/server/services/cosTaskGenerator.js b/server/services/cosTaskGenerator.jsindex 8dc21f2bf0..7cf6d5204e 100644--- a/server/services/cosTaskGenerator.js+++ b/server/services/cosTaskGenerator.js@@ -1702,13 +1702,23 @@ export async function generateManagedAppImprovementTaskForType(taskType, app, st// The sub-minute pre-branch window is left to the coordinator's per-zombie// re-verification, so no separate active-agent set is threaded here.const autoClose = metadata.autoClose !== false;- const result = await reconcile(app.repoPath).catch((err) => {+ // Routing mirrors resolveAppWorkTracker: JIRA is NEVER auto-selected from the+ // git host — it needs explicit per-app config (workTracker 'jira' + enabled+ // jira.instanceId/projectKey). When resolved to JIRA, hand the gatherer the+ // JIRA coordinates so it scans status-based zombies via the PortOS JIRA API;+ // otherwise reconcile resolves GitHub/GitLab from the origin host as before.+ const { resolveAppWorkTracker } = await import('../lib/workTracker.js');+ const wt = await resolveAppWorkTracker(app).catch(() => null);+ const jira = (wt?.resolved === 'jira' && app.jira?.enabled && app.jira?.instanceId && app.jira?.projectKey)+ ? { instanceId: app.jira.instanceId, projectKey: app.jira.projectKey }+ : null;+ const result = await reconcile(app.repoPath, { jira }).catch((err) => {emitLog('warn', `issue-reconcile pre-step failed for ${app.name}: ${err.message}`, { appId: app.id });return null;});- // null = unsupported remote (not GitHub/GitLab) OR transient gh/glab failure →- // skip WITHOUT parking so the next tick retries (gh/glab/git-only cost),- // mirroring branch-reconcile.+ // null = unsupported remote (not GitHub/GitLab, no JIRA config) OR transient+ // gh/glab/JIRA failure → skip WITHOUT parking so the next tick retries+ // (gh/glab/git/JIRA-API-only cost), mirroring branch-reconcile.if (!result) return null;if (result.stalled.length) {// In-progress issues with NO merged PR and NO live claim — a different stuck@@ -1736,7 +1746,10 @@ export async function generateManagedAppImprovementTaskForType(taskType, app, stawait taskSchedule.clearPerpetualPark(taskType, app.id);await taskSchedule.setPerpetualSignature(taskType, app.id, signature);metadata.perpetual = true;- zombieIssuesBlock = formatZombiesForPrompt(result.zombies, { fullName: result.fullName, forge: result.forge, autoClose });+ zombieIssuesBlock = formatZombiesForPrompt(result.zombies, {+ fullName: result.fullName, forge: result.forge, autoClose,+ projectKey: jira?.projectKey, instanceId: jira?.instanceId,+ });emitLog('info', `🧟 issue-reconcile dispatching for ${app.name}: ${result.zombies.length} zombie issue(s) on ${result.forge}`, { appId: app.id, analysisType: taskType });}diff --git a/server/services/issueReconcile.js b/server/services/issueReconcile.jsindex c60f30f48d..15a87aaa54 100644--- a/server/services/issueReconcile.js+++ b/server/services/issueReconcile.js@@ -7,14 +7,31 @@* partial ship left stranded — the claim queue skips `in-progress`, so its* remaining scope is never re-picked and never finished.*- * Forge-agnostic: the same scan runs over GitHub (`gh` issues + PRs) and GitLab- * (`glab` issues + merge requests). The forge is resolved from the app's git- * `origin` host (github.* → GitHub, gitlab.* → GitLab); any other remote returns- * null (skip/park). The pure classifier, ref matchers, and convergence signature- * are shared — only the effectful state gatherer differs per forge, and each- * normalizes into one common `{ number, title, url, labels, assignees }` issue- * shape + `{ number, headRefName, body, url }` change shape so the merge/classify- * logic never branches on forge.+ * Forge-agnostic: the same scan runs over GitHub (`gh` issues + PRs), GitLab+ * (`glab` issues + merge requests), and JIRA (the PortOS JIRA API). The GitHub /+ * GitLab forge is resolved from the app's git `origin` host (github.* → GitHub,+ * gitlab.* → GitLab); any other remote returns null (skip/park). The pure+ * classifier, ref matchers, and convergence signature are shared — only the+ * effectful state gatherer differs per forge, and each normalizes into one common+ * `{ number, title, url, labels, assignees }` issue shape + `{ number,+ * headRefName, body, url }` change shape so the merge/classify logic never+ * branches on forge.+ *+ * JIRA is materially different and is NEVER auto-selected from the git host — it+ * requires explicit per-app config (`app.jira` + `workTracker: 'jira'`), so it is+ * routed in via the `jira` option (mirroring `resolveAppWorkTracker`) rather than+ * an origin-host lookup. Its "zombie" is STATUS-based, not label-based: JIRA has no+ * `in-progress` label to release, so a ticket left **In Review** with no live claim+ * is the shipped-but-stranded signal (the analog of a merged PR). Only In-Progress-+ * category tickets are scanned — **To Do** (not started) and **Done** (terminal,+ * the human closed it out) are excluded so the scan converges.+ * The live-claim guard is keyed on the ticket KEY (`claim/<KEY>` / `cos/…/<KEY>/…`+ * refs, local AND remote) so an open MR still under review — whose claim branch is+ * still present — reads as LIVE, while a merged-and-deleted branch reads as a+ * zombie. The deterministic scan is status + git-ref only (no forge CLI, no+ * dev-panel PR lookup); the coordinator reads the ticket + its linked MR/PR live to+ * confirm remaining scope before healing. JIRA tickets normalize into the SAME+ * common shape (KEY → `number`, `status` carried for the signature).** The scheduler runs the deterministic scan here (gh/glab + git only — no LLM),* then hands the zombie set to a coordinator CoS agent that reads each issue + its@@ -36,6 +53,7 @@import { execGit } from '../lib/execGit.js';import { execGh } from './github.js';import { execGlab } from './gitlab.js';+import { fetchMyCurrentSprintTickets } from './jira.js';import { getOriginInfo, readOriginRemoteUrl } from '../lib/gitRemote.js';import { hostToWorkTracker, hostFromOriginUrl } from '../lib/workTracker.js';import { safeJSONParse, PATHS } from '../lib/fileUtils.js';@@ -67,6 +85,57 @@ export function issueNumberFromRef(refName) {return m ? Number(m[1]) : null;}+/**+ * Extract the JIRA ticket KEY a git ref claims, or null. JIRA claim branches use+ * the ticket KEY directly (no `issue-` prefix), so both conventions carry the raw+ * key as a whole path segment:+ * - human / TUI: `claim/<KEY>` (KEY after `claim/`)+ * - CoS sub-agent: `cos/<task>/<KEY>/<agent>` (KEY as the 3rd segment)+ * A KEY looks like `PROJ-1234` (project code + `-` + number). Matching any whole+ * segment that IS a JIRA key covers both conventions and remote-tracking refs+ * (`refs/remotes/origin/claim/<KEY>`) in one pass — the KEY shape is distinctive+ * enough that a non-key segment (`main`, `claim`, `feat`) can't collide.+ * @param {string} refName+ * @returns {string|null}+ */+export function ticketKeyFromRef(refName) {+ const m = /(?:^|\/)([A-Z][A-Z0-9]+-\d+)(?=\/|$)/.exec(refName || '');+ return m ? m[1] : null;+}++/**+ * Which JIRA tickets the scan even considers: only the **In Progress** status+ * CATEGORY — the "actively in the pipeline" bucket. This is the JIRA analog of+ * "OPEN + carries `in-progress`" on GitHub/GitLab:+ * - **To Do** category = not started (never claimed) → never a candidate.+ * - **Done** category = terminal (the human closed it out, like a CLOSED issue)+ * → excluded so the scan CONVERGES; a Done ticket is not re-flagged forever.+ * The claim-issue-jira flow's success end-state is **In Review** (a sub-status of+ * the In Progress category — the human merges the MR + moves it to Done), so the+ * zombie lives entirely inside the In Progress category.+ * @param {{ statusCategory?:string }} ticket+ * @returns {boolean}+ */+export function isJiraStartedStatus({ statusCategory } = {}) {+ return statusCategory === 'In Progress';+}++/**+ * The JIRA "zombie" is STATUS-based, not label-based (JIRA has no `in-progress`+ * label to release). Within the In-Progress bucket, an **In Review** / **Code+ * Review** status is the shipped-but-not-closed signal — the analog of a merged PR+ * on an issue still carrying `in-progress`: the MR/PR shipped and moved the ticket+ * to review, but nobody closed it out and (per the live-claim guard) no branch+ * remains. A non-review In-Progress status (e.g. plain "In Progress") is NOT+ * shipped → it classifies STALLED, not ZOMBIE. Matched on the status NAME+ * (`isJiraStartedStatus` already constrained the category to In Progress).+ * @param {{ status?:string }} ticket+ * @returns {boolean}+ */+export function isJiraShippedStatus({ status } = {}) {+ return /review/i.test(status || '');+}+/*** Does a PR/MR body reference issue #num as a whole token? `#222` must not match* inside `#2220`, so the digits are followed by a non-digit boundary. Matches@@ -138,6 +207,31 @@ async function getLiveClaimIssueNums(repoPath) {return nums;}+/**+ * Every JIRA ticket KEY that has a LIVE claim ref (local OR remote). JIRA has no+ * PR/MR list in this deterministic scan (that's a live coordinator lookup), so the+ * git ref IS the live-claim signal: a `claim/<KEY>` branch (or `cos/…/<KEY>/…`)+ * still present means some machine is mid-claim OR an MR is still open under review+ * with its source branch intact — either way the ticket is NOT a zombie even though+ * its status is already "shipped". A merged-and-deleted branch leaves no ref, so a+ * genuinely stranded ticket surfaces. Returns a Set of uppercase KEY strings.+ * @param {string} repoPath+ * @returns {Promise<Set<string>>}+ */+async function getLiveClaimTicketKeys(repoPath) {+ const { stdout } = await execGit(+ ['for-each-ref', '--format=%(refname)', 'refs/heads/', 'refs/remotes/'],+ repoPath,+ { ignoreExitCode: true }+ ).catch(() => ({ stdout: '' }));+ const keys = new Set();+ for (const line of (stdout || '').split('\n')) {+ const key = ticketKeyFromRef(line.trim());+ if (key != null) keys.add(key);+ }+ return keys;+}+/*** Normalize a raw GitHub issue (from `gh issue list --json`) into the common* shape the forge-agnostic gatherer consumes.@@ -300,40 +394,95 @@ async function getForgeState(repoPath) {}/**- * Gather the raw facts for every open `in-progress` issue in `repoPath`'s forge- * repo. Effectful (gh/glab + git). Returns null on an unsupported remote (not- * GitHub/GitLab) or a transient forge failure so the scheduler can skip without- * parking.+ * Fetch the JIRA sprint tickets for the app's configured project, normalized to+ * the same intermediate `inProgress` shape the forge gatherers produce — so the+ * common gather/classify path below is forge-agnostic. Unlike the forge gatherers,+ * there is no separate merged/open change list: JIRA's "shipped" signal is the+ * ticket STATUS (In Review), so each ticket carries `shipped` (isJiraShippedStatus)+ * instead of matching against a PR/MR list. Only In-Progress-category tickets are+ * returned (the analog of the `in-progress`-labeled issue set).+ *+ * Returns null on a transient fetch failure (skip, don't park) — `fetchMy…`+ * (the strict variant) throws rather than swallowing to [], so a JIRA blip can't+ * be misread as "no tickets" and park.+ * @param {string} repoPath (unused — JIRA is app-config-routed, not cwd-routed)+ * @param {{ instanceId:string, projectKey:string }} jira+ * @returns {Promise<{forge:'jira', fullName:string, inProgress:object[]}|null>}+ */+async function getJiraState(_repoPath, jira) {+ const tickets = await fetchMyCurrentSprintTickets(jira.instanceId, jira.projectKey)+ .catch((err) => {+ console.warn(`⚠️ issue-reconcile JIRA fetch failed for ${jira.projectKey}: ${err.message}`);+ return null;+ });+ if (!Array.isArray(tickets)) return null;++ const inProgress = tickets+ .filter(isJiraStartedStatus)+ .map((t) => ({+ // KEY is the JIRA "number" — the whole shape stays common; it's a string here.+ number: t.key,+ title: t.summary || '',+ url: t.url || '',+ labels: [],+ assignees: [],+ status: t.status || '',+ shipped: isJiraShippedStatus(t),+ }));++ return { forge: 'jira', fullName: jira.projectKey, inProgress };+}++/**+ * Gather the raw facts for every actionable issue/ticket in the app's tracker.+ * Effectful (gh/glab/git for the forges; the PortOS JIRA API for JIRA). Returns+ * null on an unsupported remote (not GitHub/GitLab, no JIRA config) or a transient+ * failure so the scheduler can skip without parking.+ *+ * Routing mirrors `resolveAppWorkTracker`: JIRA is NEVER auto-selected from the git+ * host — it is chosen only when explicit `jira` config ({ instanceId, projectKey })+ * is passed in. Otherwise the GitHub/GitLab forge is resolved from the origin host.** @param {string} repoPath- * @param {{ activeAgentIssueNums?: Set<number> }} [ctx] - issue numbers an active- * CoS agent is currently claiming (from agent metadata); suppresses zombie- * classification for an issue whose agent is still running.+ * @param {{ activeAgentIssueNums?: Set<number|string>, jira?: { instanceId:string, projectKey:string } }} [ctx]+ * `activeAgentIssueNums` — issue numbers / ticket KEYs an active CoS agent is+ * currently claiming (from agent metadata); suppresses zombie classification for+ * one whose agent is still running. `jira` — routes to the JIRA gatherer.* @returns {Promise<{forge:string, fullName:string, issues:object[]}|null>}*/-export async function gatherIssueState(repoPath, { activeAgentIssueNums = new Set() } = {}) {- const [state, liveClaimNums] = await Promise.all([- getForgeState(repoPath),- getLiveClaimIssueNums(repoPath),+export async function gatherIssueState(repoPath, { activeAgentIssueNums = new Set(), jira = null } = {}) {+ const isJira = Boolean(jira?.instanceId && jira?.projectKey);+ const [state, liveClaimIds] = await Promise.all([+ isJira ? getJiraState(repoPath, jira) : getForgeState(repoPath),+ isJira ? getLiveClaimTicketKeys(repoPath) : getLiveClaimIssueNums(repoPath),]);if (!state) return null;const issues = state.inProgress.map((issue) => {- const num = issue.number;- const mergedPr = state.mergedPrs.find((pr) => prReferencesIssue(pr, num)) || null;- const openPr = state.openPrs.find((pr) => prReferencesIssue(pr, num)) || null;+ const id = issue.number;+ // "shipped" analog: a merged PR/MR (forges) OR an In-Review status (JIRA).+ const mergedPr = isJira+ ? null+ : (state.mergedPrs.find((pr) => prReferencesIssue(pr, id)) || null);+ const openPr = isJira+ ? null+ : (state.openPrs.find((pr) => prReferencesIssue(pr, id)) || null);+ const hasMergedPr = isJira ? Boolean(issue.shipped) : Boolean(mergedPr);return {- number: num,+ number: id,title: issue.title || '',url: issue.url || '',labels: Array.isArray(issue.labels) ? issue.labels : [],assignees: Array.isArray(issue.assignees) ? issue.assignees : [],+ // JIRA carries its status so the convergence signature (and the prompt) can+ // reflect it; forges leave it undefined.+ ...(isJira ? { status: issue.status || '' } : {}),mergedPr,- hasMergedPr: Boolean(mergedPr),- // Live claim = an OPEN PR/MR for this issue, OR a local/remote claim branch,- // OR an active CoS agent — any means "still being worked".- hasLiveClaim: Boolean(openPr) || liveClaimNums.has(num),- hasActiveAgent: activeAgentIssueNums.has(num),+ hasMergedPr,+ // Live claim = an OPEN PR/MR (forges) OR a local/remote claim branch (all+ // trackers), OR an active CoS agent — any means "still being worked".+ hasLiveClaim: Boolean(openPr) || liveClaimIds.has(id),+ hasActiveAgent: activeAgentIssueNums.has(id),};});return { forge: state.forge, fullName: state.fullName, issues };@@ -345,13 +494,13 @@ export async function gatherIssueState(repoPath, { activeAgentIssueNums = new Se* I/O to gatherIssueState).** @param {string} [repoPath=PATHS.root]- * @param {{ activeAgentIssueNums?: Set<number> }} [opts]+ * @param {{ activeAgentIssueNums?: Set<number|string>, jira?: { instanceId:string, projectKey:string } }} [opts]* @returns {Promise<{ forge:string, fullName:string, zombies:object[], stalled:object[], live:object[] }|null>}- * null on unsupported remote (not GitHub/GitLab) / transient forge failure- * (skip, don't park).+ * null on unsupported remote (not GitHub/GitLab, no JIRA config) / transient+ * failure (skip, don't park).*/-export async function reconcile(repoPath = PATHS.root, { activeAgentIssueNums = new Set() } = {}) {- const gathered = await gatherIssueState(repoPath, { activeAgentIssueNums });+export async function reconcile(repoPath = PATHS.root, { activeAgentIssueNums = new Set(), jira = null } = {}) {+ const gathered = await gatherIssueState(repoPath, { activeAgentIssueNums, jira });if (!gathered) return null;const classified = classifyIssues(gathered.issues);return {@@ -370,28 +519,64 @@ export async function reconcile(repoPath = PATHS.root, { activeAgentIssueNums =* signature. An unchanged signature means the last run left the same zombies in* the same state (coordinator errored, or the human hasn't acted on a case it* punted) → "no progress → park" instead of re-dispatching an identical run.- * Order-independent (sorted). Forge-agnostic (issue numbers + merged change #).+ * Order-independent (sorted). Forge-agnostic: keys each zombie on its id + its+ * "shipped by" fact — the merged PR/MR number on the forges, or the ticket STATUS+ * on JIRA (which has no PR number here; a status change IS the progress signal).* @param {object[]} zombies* @returns {string}*/export function zombieSignature(zombies) {return zombies- .map((z) => `${z.number}:${z.mergedPr?.number ?? 'none'}`)+ .map((z) => `${z.number}:${z.mergedPr?.number ?? (z.status || 'none')}`).sort().join('|');}+/**+ * Render the JIRA zombie set into the coordinator prompt body. JIRA is+ * status-based (no PR number here, no `in-progress` label): each zombie is a+ * ticket left In Review with no live claim, and healing moves through the PortOS+ * JIRA API (transitions + `POST tickets`) rather than a forge CLI.+ */+function formatJiraZombiesForPrompt(zombies, { fullName, projectKey, instanceId, autoClose }) {+ const lines = [+ `Tracker: **JIRA (use the PortOS JIRA API)**. Project: \`${projectKey || fullName}\`` ++ (instanceId ? ` on instance \`${instanceId}\`` : '') ++ `. Zombie tickets to reconcile (${zombies.length}):`,+ '',+ 'A JIRA zombie is a ticket left **In Review** whose MR/PR already merged (or was abandoned) with real scope REMAINING and NO live `claim/<KEY>` branch anywhere. JIRA has no `in-progress` label to release, so the ticket STATUS is the claim marker.',+ '',+ autoClose+ ? '**autoClose is ON** — apply the full partial-ship hybrid: when the remainder is SEPARABLE, transition the original to Done with a `Done ✓ / Remaining ▢` comment and file ONE scoped follow-up ticket (POST /api/jira/instances/<instanceId>/tickets) whose description carries `Refs <KEY>`; when it is a CONTINUATION, transition the ticket BACK to a not-started status (To Do / Selected for Development) with the same comment so the claim queue re-picks it.'+ : '**autoClose is OFF** — never transition a ticket to Done and never file a follow-up. Only post a `Done ✓ / Remaining ▢` comment and transition the ticket BACK to a not-started status so the queue re-picks it.',+ '',+ ];+ for (const z of zombies) {+ lines.push(`### ${z.number} — ${z.title}`);+ if (z.url) lines.push(`- Ticket: ${z.url}`);+ lines.push(`- Current status: ${z.status || 'In Review'} (shipped — verify the linked MR/PR live before acting)`);+ lines.push('');+ }+ return lines.join('\n');+}+/*** Render the zombie set into the coordinator prompt body (injected as* `{zombieIssues}`). The per-issue entries stay factual; the partial-ship* mechanics + per-forge CLI command table live once in the prompt template. Only* the dynamic `forge` + `autoClose` directives are surfaced here (the template* can't know them), as header lines rather than repeated per issue.+ *+ * JIRA delegates to `formatJiraZombiesForPrompt` — its heal path (status+ * transitions + `POST tickets`) is materially different from the gh/glab CLI table.* @param {object[]} zombies- * @param {{ fullName:string, forge?:string, autoClose:boolean }} ctx+ * @param {{ fullName:string, forge?:string, autoClose:boolean, projectKey?:string, instanceId?:string }} ctx* @returns {string}*/-export function formatZombiesForPrompt(zombies, { fullName, forge = 'github', autoClose }) {+export function formatZombiesForPrompt(zombies, { fullName, forge = 'github', autoClose, projectKey, instanceId }) {+ if (forge === 'jira') {+ return formatJiraZombiesForPrompt(zombies, { fullName, projectKey, instanceId, autoClose });+ }const isGitlab = forge === 'gitlab';const change = isGitlab ? 'MR' : 'PR';const lines = [diff --git a/server/services/issueReconcile.test.js b/server/services/issueReconcile.test.jsindex 734f4ad9f8..926378ec85 100644--- a/server/services/issueReconcile.test.js+++ b/server/services/issueReconcile.test.js@@ -19,6 +19,7 @@ vi.mock('../lib/execGit.js', () => ({}));vi.mock('./github.js', () => ({ execGh: vi.fn(async () => '[]') }));vi.mock('./gitlab.js', () => ({ execGlab: vi.fn(async () => '[]') }));+vi.mock('./jira.js', () => ({ fetchMyCurrentSprintTickets: vi.fn(async () => []) }));vi.mock('../lib/gitRemote.js', () => ({getOriginInfo: vi.fn(async () => ({ isGithub: true, host: 'github.com', fullName: 'atomantic/PortOS' })),readOriginRemoteUrl: vi.fn(async () => '[email protected]:atomantic/PortOS.git'),@@ -39,13 +40,15 @@ vi.mock('../lib/fileUtils.js', () => ({}));import {- issueNumberFromRef, bodyReferencesIssue, prReferencesIssue,+ issueNumberFromRef, ticketKeyFromRef, bodyReferencesIssue, prReferencesIssue,+ isJiraStartedStatus, isJiraShippedStatus,classifyIssue, classifyIssues, reconcile, gatherIssueState,zombieSignature, formatZombiesForPrompt,} from './issueReconcile.js';import { execGit } from '../lib/execGit.js';import { execGh } from './github.js';import { execGlab } from './gitlab.js';+import { fetchMyCurrentSprintTickets } from './jira.js';import { getOriginInfo, readOriginRemoteUrl } from '../lib/gitRemote.js';beforeEach(() => {@@ -76,6 +79,46 @@ describe('issueNumberFromRef', () => {});});+describe('ticketKeyFromRef', () => {+ it('matches the human claim convention (claim/<KEY>)', () => {+ expect(ticketKeyFromRef('claim/PROJ-1234')).toBe('PROJ-1234');+ });+ it('matches the CoS sub-agent convention (cos/<task>/<KEY>/<agent>)', () => {+ expect(ticketKeyFromRef('cos/issue-reconcile/PROJ-1234/agent-x')).toBe('PROJ-1234');+ });+ it('matches a remote-tracking ref', () => {+ expect(ticketKeyFromRef('refs/remotes/origin/claim/ABC-42')).toBe('ABC-42');+ });+ it('returns null for a non-JIRA ref', () => {+ expect(ticketKeyFromRef('claim/issue-2220')).toBeNull();+ expect(ticketKeyFromRef('refs/heads/main')).toBeNull();+ expect(ticketKeyFromRef('feat/some-feature')).toBeNull();+ expect(ticketKeyFromRef('')).toBeNull();+ });+});++describe('isJiraStartedStatus', () => {+ it('is true only for the In Progress category', () => {+ expect(isJiraStartedStatus({ statusCategory: 'In Progress' })).toBe(true);+ });+ it('is false for To Do (not started) and Done (terminal → converges)', () => {+ expect(isJiraStartedStatus({ statusCategory: 'To Do' })).toBe(false);+ expect(isJiraStartedStatus({ statusCategory: 'Done' })).toBe(false);+ expect(isJiraStartedStatus({})).toBe(false);+ });+});++describe('isJiraShippedStatus', () => {+ it('treats an In Review / Code Review status name as shipped', () => {+ expect(isJiraShippedStatus({ status: 'In Review' })).toBe(true);+ expect(isJiraShippedStatus({ status: 'Code Review' })).toBe(true);+ });+ it('a plain In Progress status is NOT shipped (→ stalled, not zombie)', () => {+ expect(isJiraShippedStatus({ status: 'In Progress' })).toBe(false);+ expect(isJiraShippedStatus({})).toBe(false);+ });+});+describe('bodyReferencesIssue', () => {it('matches a plain #num token', () => {expect(bodyReferencesIssue('Refs #2220 in the body', 2220)).toBe(true);@@ -361,6 +404,105 @@ describe('reconcile (GitLab forge)', () => {});});+// --- end-to-end gather/reconcile over mocked JIRA API + git (JIRA tracker) ---++const JIRA = { instanceId: 'inst1', projectKey: 'PROJ' };++/** Build a raw JIRA sprint ticket in the shape fetchMyCurrentSprintTickets returns. */+function jiraTicket({ key, status, statusCategory, summary = 't', url = 'u' }) {+ return { key, summary, status, statusCategory, url };+}++describe('reconcile (JIRA tracker)', () => {+ it('flags an In-Review ticket with no live claim branch as a ZOMBIE', async () => {+ fetchMyCurrentSprintTickets.mockResolvedValue([+ jiraTicket({ key: 'PROJ-42', status: 'In Review', statusCategory: 'In Progress', summary: 'JIRA zombie', url: 'https://j/PROJ-42' }),+ ]);+ execGit.mockResolvedValue({ stdout: '', exitCode: 0 }); // no claim refs+ const result = await reconcile('/repo', { jira: JIRA });+ expect(result.forge).toBe('jira');+ expect(result.fullName).toBe('PROJ');+ expect(result.zombies.map((z) => z.number)).toEqual(['PROJ-42']);+ expect(result.zombies[0].status).toBe('In Review');+ // JIRA never routes to gh/glab.+ expect(execGh).not.toHaveBeenCalled();+ expect(execGlab).not.toHaveBeenCalled();+ });++ it('a live claim/<KEY> branch keeps the In-Review ticket LIVE (not a zombie)', async () => {+ fetchMyCurrentSprintTickets.mockResolvedValue([+ jiraTicket({ key: 'PROJ-42', status: 'In Review', statusCategory: 'In Progress' }),+ ]);+ execGit.mockResolvedValue({ stdout: 'refs/remotes/origin/claim/PROJ-42\nrefs/heads/main\n', exitCode: 0 });+ const result = await reconcile('/repo', { jira: JIRA });+ expect(result.zombies).toHaveLength(0);+ expect(result.live.map((l) => l.number)).toEqual(['PROJ-42']);+ });++ it('an active CoS agent on the ticket keeps it LIVE', async () => {+ fetchMyCurrentSprintTickets.mockResolvedValue([+ jiraTicket({ key: 'PROJ-42', status: 'In Review', statusCategory: 'In Progress' }),+ ]);+ const result = await reconcile('/repo', { jira: JIRA, activeAgentIssueNums: new Set(['PROJ-42']) });+ expect(result.zombies).toHaveLength(0);+ expect(result.live.map((l) => l.number)).toEqual(['PROJ-42']);+ });++ it('a plain In-Progress ticket (not shipped) → STALLED, not a zombie', async () => {+ fetchMyCurrentSprintTickets.mockResolvedValue([+ jiraTicket({ key: 'PROJ-42', status: 'In Progress', statusCategory: 'In Progress' }),+ ]);+ const result = await reconcile('/repo', { jira: JIRA });+ expect(result.zombies).toHaveLength(0);+ expect(result.stalled.map((s) => s.number)).toEqual(['PROJ-42']);+ });++ it('a To Do (not started) ticket is excluded entirely', async () => {+ fetchMyCurrentSprintTickets.mockResolvedValue([+ jiraTicket({ key: 'PROJ-1', status: 'To Do', statusCategory: 'To Do' }),+ ]);+ const result = await reconcile('/repo', { jira: JIRA });+ expect(result.zombies).toHaveLength(0);+ expect(result.stalled).toHaveLength(0);+ expect(result.live).toHaveLength(0);+ });++ it('a Done (terminal) ticket is excluded so the scan converges', async () => {+ fetchMyCurrentSprintTickets.mockResolvedValue([+ jiraTicket({ key: 'PROJ-9', status: 'Done', statusCategory: 'Done' }),+ ]);+ const result = await reconcile('/repo', { jira: JIRA });+ expect(result.zombies).toHaveLength(0);+ expect(result.stalled).toHaveLength(0);+ });++ it('returns null (transient, skip) when the JIRA fetch throws', async () => {+ fetchMyCurrentSprintTickets.mockRejectedValue(new Error('JIRA down'));+ const result = await reconcile('/repo', { jira: JIRA });+ expect(result).toBeNull();+ });++ it('empty sprint is a valid answer (no zombies), not a skip', async () => {+ fetchMyCurrentSprintTickets.mockResolvedValue([]);+ const result = await reconcile('/repo', { jira: JIRA });+ expect(result).not.toBeNull();+ expect(result.forge).toBe('jira');+ expect(result.zombies).toHaveLength(0);+ });++ it('does NOT route to JIRA without explicit config (origin-host forge instead)', async () => {+ // No jira option → falls through to the GitHub forge resolved from the origin.+ mockGh({+ issues: [{ number: 2220, title: 't', labels: [{ name: 'in-progress' }], assignees: [], url: 'u' }],+ merged: [{ number: 2234, headRefName: 'x', body: 'Refs #2220' }],+ open: [],+ });+ const result = await reconcile('/repo');+ expect(result.forge).toBe('github');+ expect(fetchMyCurrentSprintTickets).not.toHaveBeenCalled();+ });+});+describe('gatherIssueState carries labels/assignees for the follow-up', () => {it('surfaces area labels + assignees on the zombie record', async () => {mockGh({@@ -386,6 +528,15 @@ describe('zombieSignature', () => {const after = zombieSignature([{ number: 2, mergedPr: { number: 20 } }]);expect(before).not.toBe(after);});+ it('keys a JIRA zombie on its KEY + status (no merged PR number)', () => {+ const sig = zombieSignature([{ number: 'PROJ-42', status: 'In Review' }]);+ expect(sig).toBe('PROJ-42:In Review');+ });+ it('a JIRA status change is progress (signature changes)', () => {+ const before = zombieSignature([{ number: 'PROJ-42', status: 'In Review' }]);+ const after = zombieSignature([{ number: 'PROJ-42', status: 'Done' }]);+ expect(before).not.toBe(after);+ });});describe('formatZombiesForPrompt', () => {@@ -431,4 +582,25 @@ describe('formatZombiesForPrompt', () => {expect(md).toContain('merged MR #7');expect(md).not.toContain('merged PR');});+ it('renders a JIRA header + status-based wording when forge is jira', () => {+ const md = formatZombiesForPrompt(+ [{ number: 'PROJ-42', title: 'JIRA zombie', url: 'https://j/PROJ-42', status: 'In Review' }],+ { fullName: 'PROJ', forge: 'jira', autoClose: true, projectKey: 'PROJ', instanceId: 'inst1' }+ );+ expect(md).toContain('JIRA (use the PortOS JIRA API)');+ expect(md).toContain('PROJ-42');+ expect(md).toContain('Current status: In Review');+ expect(md).toContain('inst1');+ // No forge-CLI PR/MR wording.+ expect(md).not.toContain('merged PR');+ expect(md).not.toContain('use `gh`');+ });+ it('JIRA autoClose:false forbids Done/follow-up — comment + move back only', () => {+ const md = formatZombiesForPrompt(+ [{ number: 'PROJ-42', title: 't', url: 'u', status: 'In Review' }],+ { fullName: 'PROJ', forge: 'jira', autoClose: false, projectKey: 'PROJ', instanceId: 'inst1' }+ );+ expect(md).toContain('autoClose is OFF');+ expect(md).toContain('never transition a ticket to Done');+ });});diff --git a/server/services/jira.js b/server/services/jira.jsindex d6bf8b4417..db53ce7856 100644--- a/server/services/jira.js+++ b/server/services/jira.js@@ -375,9 +375,13 @@ export async function transitionTicket(instanceId, ticketId, transitionId) {}/**- * Get tickets assigned to user in current sprint for a project+ * Fetch tickets assigned to the current user in the active sprint for a project —+ * STRICT variant that lets fetch errors bubble. Used by the issue-reconcile JIRA+ * gatherer, which must distinguish a transient API failure (skip, don't park) from+ * a legitimately empty sprint ([], a valid answer) — the sentinel rule in CLAUDE.md.+ * The UI-facing `getMyCurrentSprintTickets` wraps this and swallows to [] instead.*/-export async function getMyCurrentSprintTickets(instanceId, projectKey) {+export async function fetchMyCurrentSprintTickets(instanceId, projectKey) {const config = await getInstances();const instance = config.instances[instanceId];@@ -390,26 +394,34 @@ export async function getMyCurrentSprintTickets(instanceId, projectKey) {// JQL to find tickets assigned to current user in active sprint for the projectconst jql = `project = "${escapeJql(projectKey)}" AND assignee = currentUser() AND sprint in openSprints() ORDER BY priority DESC, updated DESC`;- try {- const response = await client.get('/rest/api/2/search', {- params: {- jql,- fields: 'summary,status,priority,issuetype,assignee,updated,customfield_10106',- maxResults: 50- }- });+ const response = await client.get('/rest/api/2/search', {+ params: {+ jql,+ fields: 'summary,status,priority,issuetype,assignee,updated,customfield_10106',+ maxResults: 50+ }+ });- return response.data.issues.map(issue => ({- key: issue.key,- summary: issue.fields.summary,- status: issue.fields.status.name,- statusCategory: issue.fields.status.statusCategory?.name,- priority: issue.fields.priority?.name,- issueType: issue.fields.issuetype?.name,- storyPoints: issue.fields.customfield_10106,- updated: issue.fields.updated,- url: `${instance.baseUrl}/browse/${issue.key}`- }));+ return response.data.issues.map(issue => ({+ key: issue.key,+ summary: issue.fields.summary,+ status: issue.fields.status.name,+ statusCategory: issue.fields.status.statusCategory?.name,+ priority: issue.fields.priority?.name,+ issueType: issue.fields.issuetype?.name,+ storyPoints: issue.fields.customfield_10106,+ updated: issue.fields.updated,+ url: `${instance.baseUrl}/browse/${issue.key}`+ }));+}++/**+ * Get tickets assigned to user in current sprint for a project.+ * Swallows fetch errors to [] so a JIRA blip never breaks the Kanban UI.+ */+export async function getMyCurrentSprintTickets(instanceId, projectKey) {+ try {+ return await fetchMyCurrentSprintTickets(instanceId, projectKey);} catch (error) {console.warn(`⚠️ JIRA sprint fetch failed for project ${projectKey}: ${error.message}`);// Return empty array on error to avoid breaking the UI@@ -661,6 +673,7 @@ export default {deleteTicket,transitionTicket,getMyCurrentSprintTickets,+ fetchMyCurrentSprintTickets,getBoardColumns,buildColumnsFromBoardConfig,buildColumnsFromStatuses,diff --git a/server/services/taskPromptDefaults/integrity.snapshot.json b/server/services/taskPromptDefaults/integrity.snapshot.jsonindex 1fc2fc965b..2b740b675b 100644--- a/server/services/taskPromptDefaults/integrity.snapshot.json+++ b/server/services/taskPromptDefaults/integrity.snapshot.json@@ -25,7 +25,7 @@"jira-status-report": "9d374a9d8ccb92c5c8fd0aa9899e79a5","branch-cleanup": "8fdeb4acc2749816a47ca318b6602721","branch-reconcile": "7ef2b5f7d8f05937d4912b26ad45f42e",- "issue-reconcile": "c87d7adb57de208c069964760c9c6276",+ "issue-reconcile": "a30f5d76b980bc9016f576047c9d5bb1","pr-reviewer": "add27b67daa6aa2c75717ac96a6bd625","pr-reviewer-security": "2050297d1cdb081a8576a781828ee44f","pr-reviewer-review": "21ccd5d3a6f3eea16c479db9ed9aedaa",@@ -45,7 +45,7 @@"reference-watch": 3,"pr-watcher": 1,"branch-reconcile": 1,- "issue-reconcile": 2,+ "issue-reconcile": 3,"refresh-local-llm-catalog": 1,"security": 2,"code-quality": 2,@@ -134,7 +134,8 @@"9c7508598ee772d1cee8f609f9ed7372"],"issue-reconcile": [- "c57a39aaa118173a496f030f5878bfc1"+ "c57a39aaa118173a496f030f5878bfc1",+ "c87d7adb57de208c069964760c9c6276"]}}diff --git a/server/services/taskPromptDefaults/previousDefaults.js b/server/services/taskPromptDefaults/previousDefaults.jsindex 28b19b3a79..c6314854d6 100644--- a/server/services/taskPromptDefaults/previousDefaults.js+++ b/server/services/taskPromptDefaults/previousDefaults.js@@ -2881,6 +2881,38 @@ Work through the issues above one at a time (they touch shared GitHub state —## Peer safety — avoid duplicate follow-ups{appName} may run on several federated machines that share one GitHub repo. Before filing a follow-up, search for one you (or a peer) may already have filed: \`gh issue list --state open --search "Refs #<num> in:body"\`. If a matching open follow-up already exists, do NOT file another — just close/relabel the original and reference the existing follow-up.+## Rules+- Work ONLY on the issues listed above. Never open, close, or relabel an issue that is not listed.+- Every follow-up you file MUST contain \`Refs #<num>\` in its body (the dedup key above) and be labeled \`plan\` so the claim queue can pick it up.+- Summarize what each issue ended up doing (closed + follow-up #NEW / released for re-claim / left as-is because it was not a zombie).`,+ // v2 default (GitHub + GitLab, forge CLI only) — superseded by the v3 body that+ // adds the JIRA arm (status-based zombies healed through the PortOS JIRA API).+ `[Improvement: {appName}] Zombie Issue Reconciliation++You are the coordinator for healing {appName}'s ZOMBIE issues. A zombie is an issue that is OPEN and still carries the \`in-progress\` label (which the claim queue reads as "claimed and being worked") — yet its pull request / merge request already MERGED and no live claim exists anywhere (no open PR/MR, no local/remote/CoS claim branch, no running agent). A partial ship left the claim marker on, so the queue skips it forever and the remaining scope is never finished. The scheduler already ran the deterministic scan and handed you ONLY the confirmed zombie set.++Repository: {repoPath}++{zombieIssues}++**Forge CLI.** The header above names the forge (GitHub or GitLab) and the CLI to use. Every command below is shown as \`gh\` (GitHub) / \`glab\` (GitLab) — run the one matching the header. The \`in-progress\` label, \`plan\` label, \`Refs #<num>\` dedup marker, and \`claim/issue-<num>\` branch convention are identical on both forges. On GitLab the "PR" is an MR and its number is an \`iid\`.++Work through the issues above one at a time (they touch shared forge state — do NOT parallelize), applying the hybrid below to each and honoring the **autoClose** directive shown above the list.++## Verify before you act+- Read the issue AND the merged PR/MR before touching anything — GitHub: \`gh issue view <num> --comments\` + \`gh pr view <pr>\`; GitLab: \`glab issue view <num> --comments\` + \`glab mr view <mr>\`. Confirm the merged PR/MR actually shipped work FOR this issue (not just a coincidental \`#<num>\` mention) AND that real scope REMAINS. If it fully satisfied the issue, just close it (GitHub: \`gh issue close <num>\`; GitLab: \`glab issue close <num>\`) and remove \`in-progress\` — it was mislabeled, not partial. If the PR/MR did NOT address this issue at all, leave it untouched and note it in your summary — it is not a zombie.++## The partial-ship hybrid (per the "Do:" line)+- **Separable remainder** → close the original with a comment summarizing what shipped (✓) and what moved out, then file ONE tightly-scoped follow-up issue for the remainder. Carry over any \`area:*\` labels the original had, then remove the claim label (closing already drops it from the queue, but be explicit).+ - GitHub: \`gh issue create --title "…" --label plan --body "…\\n\\nRefs #<num>"\` then \`gh issue edit <num> --remove-label in-progress\`.+ - GitLab: \`glab issue create --title "…" --label plan --description "…\\n\\nRefs #<num>"\` then \`glab issue update <num> --unlabel in-progress\`.+- **Continuation of the same scope** → keep the issue OPEN, post a \`Done ✓ / Remaining ▢\` comment, and release the claim so the queue re-picks it.+ - GitHub: \`gh issue edit <num> --remove-label in-progress --remove-assignee @me\`.+ - GitLab: \`glab issue update <num> --unlabel in-progress --unassign\`.++## Peer safety — avoid duplicate follow-ups+{appName} may run on several federated machines that share one forge repo. Before filing a follow-up, search for one you (or a peer) may already have filed — GitHub: \`gh issue list --state open --search "Refs #<num> in:body"\`; GitLab: \`glab issue list --search "Refs #<num>"\` (then confirm the match references \`#<num>\`). If a matching open follow-up already exists, do NOT file another — just close/relabel the original and reference the existing follow-up.+## Rules- Work ONLY on the issues listed above. Never open, close, or relabel an issue that is not listed.- Every follow-up you file MUST contain \`Refs #<num>\` in its body (the dedup key above) and be labeled \`plan\` so the claim queue can pick it up.diff --git a/server/services/taskPromptDefaults/prompts.js b/server/services/taskPromptDefaults/prompts.jsindex 3437339388..0c963594ab 100644--- a/server/services/taskPromptDefaults/prompts.js+++ b/server/services/taskPromptDefaults/prompts.js@@ -1268,15 +1268,17 @@ Spawn ONE sub-agent per branch (they are independent — run them in parallel) t'issue-reconcile': `[Improvement: {appName}] Zombie Issue Reconciliation-You are the coordinator for healing {appName}'s ZOMBIE issues. A zombie is an issue that is OPEN and still carries the \`in-progress\` label (which the claim queue reads as "claimed and being worked") — yet its pull request / merge request already MERGED and no live claim exists anywhere (no open PR/MR, no local/remote/CoS claim branch, no running agent). A partial ship left the claim marker on, so the queue skips it forever and the remaining scope is never finished. The scheduler already ran the deterministic scan and handed you ONLY the confirmed zombie set.+You are the coordinator for healing {appName}'s ZOMBIE issues. A zombie is a work item the claim queue reads as "claimed and being worked" yet that already SHIPPED with no live claim anywhere (no open PR/MR, no local/remote/CoS claim branch, no running agent) — a partial ship left the claim marker on, so the queue skips it forever and the remaining scope is never finished. On **GitHub/GitLab** the marker is the \`in-progress\` label on an OPEN issue whose PR/MR already MERGED. On **JIRA** there is no label — the marker is the ticket STATUS: a ticket left **In Review** whose MR/PR merged (or was abandoned). The scheduler already ran the deterministic scan and handed you ONLY the confirmed zombie set.Repository: {repoPath}{zombieIssues}-**Forge CLI.** The header above names the forge (GitHub or GitLab) and the CLI to use. Every command below is shown as \`gh\` (GitHub) / \`glab\` (GitLab) — run the one matching the header. The \`in-progress\` label, \`plan\` label, \`Refs #<num>\` dedup marker, and \`claim/issue-<num>\` branch convention are identical on both forges. On GitLab the "PR" is an MR and its number is an \`iid\`.+**Which tracker.** The header above names the tracker (GitHub, GitLab, or JIRA) and how to drive it. Follow the matching arm below — the GitHub/GitLab CLI arm, or the JIRA-API arm. Work through the items one at a time (they touch shared tracker state — do NOT parallelize), applying the hybrid and honoring the **autoClose** directive shown above the list.-Work through the issues above one at a time (they touch shared forge state — do NOT parallelize), applying the hybrid below to each and honoring the **autoClose** directive shown above the list.+━━━━━━━━━━ GitHub / GitLab arm (forge CLI) ━━━━━━━━━━++Every command is shown as \`gh\` (GitHub) / \`glab\` (GitLab) — run the one matching the header. The \`in-progress\` label, \`plan\` label, \`Refs #<num>\` dedup marker, and \`claim/issue-<num>\` branch convention are identical on both forges. On GitLab the "PR" is an MR and its number is an \`iid\`.## Verify before you act- Read the issue AND the merged PR/MR before touching anything — GitHub: \`gh issue view <num> --comments\` + \`gh pr view <pr>\`; GitLab: \`glab issue view <num> --comments\` + \`glab mr view <mr>\`. Confirm the merged PR/MR actually shipped work FOR this issue (not just a coincidental \`#<num>\` mention) AND that real scope REMAINS. If it fully satisfied the issue, just close it (GitHub: \`gh issue close <num>\`; GitLab: \`glab issue close <num>\`) and remove \`in-progress\` — it was mislabeled, not partial. If the PR/MR did NOT address this issue at all, leave it untouched and note it in your summary — it is not a zombie.@@ -1292,10 +1294,25 @@ Work through the issues above one at a time (they touch shared forge state — d## Peer safety — avoid duplicate follow-ups{appName} may run on several federated machines that share one forge repo. Before filing a follow-up, search for one you (or a peer) may already have filed — GitHub: \`gh issue list --state open --search "Refs #<num> in:body"\`; GitLab: \`glab issue list --search "Refs #<num>"\` (then confirm the match references \`#<num>\`). If a matching open follow-up already exists, do NOT file another — just close/relabel the original and reference the existing follow-up.-## Rules-- Work ONLY on the issues listed above. Never open, close, or relabel an issue that is not listed.-- Every follow-up you file MUST contain \`Refs #<num>\` in its body (the dedup key above) and be labeled \`plan\` so the claim queue can pick it up.-- Summarize what each issue ended up doing (closed + follow-up #NEW / released for re-claim / left as-is because it was not a zombie).`,+━━━━━━━━━━ JIRA arm (PortOS JIRA API) ━━━━━━━━━━++Use only if the header names JIRA. There is no forge CLI — every action is a PortOS JIRA API call. All calls are relative to this base URL: ${PORTOS_API_URL}. The header gives the \`<instanceId>\` and \`<projectKey>\`; each zombie's KEY is shown as \`PROJ-1234\`. The \`claim/<KEY>\` branch convention and the \`Refs <KEY>\` dedup marker are the JIRA analogs of \`claim/issue-<num>\` / \`Refs #<num>\`.++## Verify before you act+- Read the ticket AND its linked MR/PR before touching anything: GET ${PORTOS_API_URL}/api/jira/instances/<instanceId>/tickets/<KEY>. Find the linked MR/PR (its dev-panel link, or search the repo for a branch/PR referencing \`<KEY>\`) and confirm it actually shipped work FOR this ticket AND that real scope REMAINS. If it fully satisfied the ticket, just transition it to **Done** (no follow-up) — it was left in review, not partial. If nothing shipped for it at all, leave it untouched and note it in your summary — it is not a zombie.+- To transition: GET ${PORTOS_API_URL}/api/jira/instances/<instanceId>/tickets/<KEY>/transitions to list the available transitions, pick the one whose target status matches your intent (case-insensitive), then POST ${PORTOS_API_URL}/api/jira/instances/<instanceId>/tickets/<KEY>/transition with body {"transitionId": "<id>"}.++## The partial-ship hybrid (JIRA)+- **Separable remainder** → post a \`Done ✓ / Remaining ▢\` comment (POST ${PORTOS_API_URL}/api/jira/instances/<instanceId>/tickets/<KEY>/comments with body {"comment": "…"}), transition the original to **Done**, then file ONE tightly-scoped follow-up ticket for the remainder: POST ${PORTOS_API_URL}/api/jira/instances/<instanceId>/tickets with body {"projectKey": "<projectKey>", "summary": "…", "description": "…\\n\\nRefs <KEY>"}. Carry over the epic/labels where sensible.+- **Continuation of the same scope** → post the \`Done ✓ / Remaining ▢\` comment, then transition the ticket BACK to a not-started status (To Do / Selected for Development / Backlog — pick the transition that returns it to the To Do column) so the claim queue re-picks it. Do NOT file a follow-up.++## Peer safety — avoid duplicate follow-ups+{appName} may run on several federated machines that share one JIRA project. Before filing a follow-up ticket, list your sprint tickets (GET ${PORTOS_API_URL}/api/jira/instances/<instanceId>/my-sprint-tickets/<projectKey>) and check for one whose description already carries \`Refs <KEY>\`. If a matching follow-up already exists, do NOT file another — just transition the original and reference the existing follow-up.++━━━━━━━━━━ Rules (all trackers) ━━━━━━━━━━+- Work ONLY on the items listed above. Never open, close, transition, or relabel an item that is not listed.+- Every follow-up you file MUST carry the \`Refs #<num>\` / \`Refs <KEY>\` dedup marker in its body and (on the forges) be labeled \`plan\` so the claim queue can pick it up.+- Summarize what each item ended up doing (closed/Done + follow-up #NEW / released for re-claim / left as-is because it was not a zombie).`,// pr-reviewer is now a pipeline — this prompt is kept as fallback for non-pipeline mode'pr-reviewer': `[Improvement: {appName}] PR Review — Security Scan & Code Review Pipelinediff --git a/server/services/taskPromptDefaults/versions.js b/server/services/taskPromptDefaults/versions.jsindex d8b8f59d6f..9a59ccb65e 100644--- a/server/services/taskPromptDefaults/versions.js+++ b/server/services/taskPromptDefaults/versions.js@@ -18,7 +18,7 @@ export const PROMPT_VERSIONS = {'reference-watch': 3, // v3: record proposals in the app's RESOLVED work tracker (PLAN.md / GitHub / GitLab / JIRA) via the {trackerInstructions} block — no longer hardcodes PLAN.md, so an app configured for GitHub issues gets `gh issue create` proposals. v2: append slug-tagged checklist items to PLAN.md (Adopt + Maybe) instead of writing REFERENCE_REVIEW.md; security-flagged commits get no PLAN entry (mentioned only in final summary)'pr-watcher': 1, // v1: review-and-comment default for newly-opened PRs on the app's default branch'branch-reconcile': 1, // v1: per-app coordinator that finishes in-flight LOCAL branches (open PR / resolve conflicts / drive review / auto-merge) after the deterministic merged-branch cleanup pass. Peer-safe (local refs only). Replaced the PortOS-only branchReconcileScheduler.- 'issue-reconcile': 2, // v2: forge-aware — the scan + coordinator now cover GitLab (`glab` issues + MRs) as well as GitHub, resolved from the app's origin host; every heal command is shown as gh/glab and the injected header names the forge. v1: per-app coordinator that heals ZOMBIE issues (open + in-progress but their PR merged with no live claim) after the deterministic gh/git scan. Applies the partial-ship hybrid — close + file a scoped follow-up when the remainder is separable, else comment "done/remaining" + release the claim so the queue re-picks it.+ 'issue-reconcile': 3, // v3: adds a JIRA arm — status-based zombies (a ticket left In Review with remaining scope + no live claim; JIRA has no `in-progress` label) detected via the PortOS JIRA API and healed through ticket transitions + `POST tickets`, routed in via the app's resolved workTracker ('jira') rather than the git host. v2: forge-aware — the scan + coordinator now cover GitLab (`glab` issues + MRs) as well as GitHub, resolved from the app's origin host; every heal command is shown as gh/glab and the injected header names the forge. v1: per-app coordinator that heals ZOMBIE issues (open + in-progress but their PR merged with no live claim) after the deterministic gh/git scan. Applies the partial-ship hybrid — close + file a scoped follow-up when the remainder is separable, else comment "done/remaining" + release the claim so the queue re-picks it.'refresh-local-llm-catalog': 1, // v1: research current local models, refresh LOCAL_LLM_CATALOG + EDITORIAL_FAMILY_RANK, PR (PortOS repo only)// Basic self-improvement tasks — versioned so installs created before the