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

feat: add GitLab zombie-scan sibling to issue-reconcile (#2249)

Adam Eivyf4116cee89f8
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index d38bcb797b..ce0878a6eb 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -125,6 +125,8 @@
## Internal
+- **[issue-2249] The `issue-reconcile` zombie-scan is now forge-aware — it heals stranded issues on GitLab (`glab`) as well as GitHub (`gh`).** The v1 deterministic scan resolved the repo via `getOriginInfo().isGithub` and queried `gh` only, so enabling `issue-reconcile` on a GitLab-tracked app was a silent no-op. `server/services/issueReconcile.js` now resolves the forge from the app's git `origin` host inside `reconcile()` (github.* → GitHub, gitlab.* → GitLab, anything else → skip/park) and delegates to a per-forge state gatherer. Both gatherers normalize into ONE common issue shape (`{ number, title, url, labels, assignees }`) + change shape (`{ number, headRefName, body, url }`), so the pure classifier (`classifyIssue`), the boundary-safe ref matchers, and the `zombieSignature` convergence guard stay shared and unit-testable with zero forge branching — GitLab maps `iid`→number, MR `source_branch`→head ref (carries `claim/issue-<iid>`), MR `description`→body (carries `Refs #<iid>`). It remains a SINGLE task type (not three): the coordinator prompt is shared and simply gets the resolved forge + the matching `gh`/`glab` command table injected via `{zombieIssues}` (prompt bumped to v2, v1 preserved in `PREVIOUS_DEFAULT_PROMPTS` per the cross-install upgrade contract). A cwd-aware `glab` exec helper was added at `server/services/gitlab.js` (mirrors `execGh`). The JIRA sibling — a status-based "In Review with remaining scope" analog healed through the PortOS JIRA API rather than a forge CLI — is deferred to a follow-up (`Refs #2249`). (`server/services/issueReconcile.js`, `server/services/gitlab.js`, `server/services/cosTaskGenerator.js`, `server/services/taskPromptDefaults/`)
+
- **[issue-2183] Creative Tool Registry + gated dispatch (CDO Phase 1).** Foundation for the Creative Director orchestrator (epic #2182): a single registry (`server/services/creative/toolRegistry.js` + per-domain modules under `creative/tools/`) of creative-suite tools an orchestrating agent can call — universe, story builder, writers room, pipeline, media, catalog — each a thin conductor wrapper over an existing service entry point (`createUniverse`, `generateStep`, `startSeriesAutopilot`, `enqueueJob`, …), never a re-implementation. All orchestrator calls flow through one governed chokepoint, `dispatchCreativeTool(name, args, ctx)`, which validates args (Zod), enforces a new `creative` autonomy mode, charges the daily action budget for `llm`/`render` tools, and appends a `{tool, argsDigest, outcome, timing}` entry to the calling project's run ledger. The `creative` autonomy domain (`server/lib/domainAutonomy.js` `getCreativeAutonomyMode`) is kept separate from the four core domains and defaults to mirror the `cos` mode, so existing autopilot users get consistent behavior with no migration, while an explicit `domainAutonomy.creative` value can override it later. Direct user actions through the existing routes are unchanged — the gate lives only on the orchestrator path. No user-facing surface yet; the directive composer and plan board arrive in later CDO phases.
- **[issue-2220] Creative render tools with route-level persistence (CDO Phase 2 slice).** The Creative Director orchestrator can now render comic-issue and volume (season) covers — `pipeline_renderComicCover`, `pipeline_renderComicBackCover`, `pipeline_renderVolumeCover`, `pipeline_renderVolumeBackCover` are registered creative tools. These render jobs need more than a bare enqueue: the media-job filename hook attaches the finished image only if the target cover slot already carries the returned `jobId`, and that slot write used to live in the route factory (`routes/pipeline/covers.js#makeCoverRenderHandler`), so wrapping the bare `enqueueComicCover`-style service in a tool would silently drop orchestrated covers. The enqueue+persist flow (build the in-flight render slot, script-gate, write it onto the record) now lives in shared service entry points — `renderComicCover` / `renderComicBackCover` (→ `stages.comicPages.{cover|backCover}` via the serialized `updateStageWithLatest` series write tail) and `renderVolumeCover` / `renderVolumeBackCover` (→ `series.seasons[].{cover|backCover}` via `updateSeasonOnSeries`) in `visualStages.js` — so the four cover-render routes and the four orchestrator tools share ONE code path. The persist keeps the script-gate semantics (absent `coverScript` preserves the persisted concept, empty string clears it) and serializes against a concurrent blur-save on the same record. Tools charge as `render` against the daily action budget. Cover render is the primary deliverable; wrapping the remaining route-persisted render actions (comic page render / refine-render) as tools stays tracked on #2220.
diff --git a/docs/plans/2026-07-06-issue-reconcile.md b/docs/plans/2026-07-06-issue-reconcile.md
index d883d4d4c0..381fa152be 100644
--- a/docs/plans/2026-07-06-issue-reconcile.md
+++ b/docs/plans/2026-07-06-issue-reconcile.md
@@ -77,6 +77,30 @@ from two machines*, so the coordinator dedupes by searching for an existing
follow-up (`Refs #orig` marker) before filing. v1 pre-step is `gh`-only and parks
on non-GitHub apps; GitLab/JIRA siblings are deferred (see PLAN.md).
+## Part D — forge siblings (#2249)
+
+- **GitLab (shipped #2249).** `issueReconcile.js` is now forge-aware: it resolves
+ the forge from the app's git `origin` host inside `reconcile()` (github.* →
+ GitHub via `gh`, gitlab.* → GitLab via `glab`, anything else → null/skip) and
+ delegates to a per-forge state gatherer. Both gatherers normalize into ONE common
+ issue shape (`{ number, title, url, labels, assignees }`) + change shape
+ (`{ number, headRefName, body, url }`), so the pure classifier, ref matchers, and
+ `zombieSignature` are shared — no forge branching in the classify/merge logic.
+ GitLab maps `iid`→number, MR `source_branch`→head ref (carries `claim/issue-<iid>`),
+ MR `description`→body (carries `Refs #<iid>`). Routing decision: **one task type**,
+ not three — `issue-reconcile` resolves the forge internally (the `claim-work`
+ router splits by tracker only because each tracker has a distinct multi-phase
+ claim *prompt*; here the coordinator prompt is shared and just gets the forge +
+ gh/glab command table injected via `{zombieIssues}`). Coordinator prompt bumped to
+ v2 (forge-aware gh/glab commands); v1 preserved in `PREVIOUS_DEFAULT_PROMPTS`.
+ `glab` exec helper added at `server/services/gitlab.js` (mirrors `execGh`, cwd-aware).
+- **JIRA (deferred → follow-up #NEW).** 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.
+
## Part C — heal the three current zombies (done)
- **#2220** — separable remainder → **closed**, follow-up **#2241** filed.
diff --git a/server/services/cosTaskGenerator.js b/server/services/cosTaskGenerator.js
index 78b27196a2..8dc21f2bf0 100644
--- a/server/services/cosTaskGenerator.js
+++ b/server/services/cosTaskGenerator.js
@@ -1684,13 +1684,15 @@ export async function generateManagedAppImprovementTaskForType(taskType, app, st
emitLog('info', `🔀 branch-reconcile dispatching for ${app.name}: ${actionable.length} in-flight branch(es)`, { appId: app.id, analysisType: taskType });
}
- // issue-reconcile: deterministic pre-step — scan the app's GitHub repo for
- // ZOMBIE issues (open + `in-progress` yet with their PR merged and no live
- // claim anywhere) and hand the set to the coordinator agent. Same perpetual
- // drain shape as branch-reconcile: the scan IS the work-detector (gh/git only,
- // no LLM), and the coordinator dispatches only while zombies remain — else it
- // PARKS on the daily recheckCron. `{zombieIssues}` carries the set into the
- // prompt. No worktree: the coordinator mutates issue state over `gh` only.
+ // issue-reconcile: deterministic pre-step — scan the app's forge repo (GitHub
+ // via `gh` OR GitLab via `glab`, resolved from the origin host inside reconcile)
+ // for ZOMBIE issues (open + `in-progress` yet with their PR/MR merged and no
+ // live claim anywhere) and hand the set to the coordinator agent. Same perpetual
+ // drain shape as branch-reconcile: the scan IS the work-detector (gh/glab/git
+ // only, no LLM), and the coordinator dispatches only while zombies remain — else
+ // it PARKS on the daily recheckCron. `{zombieIssues}` carries the set (with the
+ // resolved forge) into the prompt. No worktree: the coordinator mutates issue
+ // state over `gh`/`glab` only.
let zombieIssuesBlock = '';
if (taskType === 'issue-reconcile') {
const { reconcile, zombieSignature, formatZombiesForPrompt } = await import('./issueReconcile.js');
@@ -1704,8 +1706,9 @@ export async function generateManagedAppImprovementTaskForType(taskType, app, st
emitLog('warn', `issue-reconcile pre-step failed for ${app.name}: ${err.message}`, { appId: app.id });
return null;
});
- // null = non-GitHub remote OR transient gh failure → skip WITHOUT parking so
- // the next tick retries (gh/git-only cost), mirroring branch-reconcile.
+ // 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.
if (!result) return null;
if (result.stalled.length) {
// In-progress issues with NO merged PR and NO live claim — a different stuck
@@ -1733,8 +1736,8 @@ export async function generateManagedAppImprovementTaskForType(taskType, app, st
await taskSchedule.clearPerpetualPark(taskType, app.id);
await taskSchedule.setPerpetualSignature(taskType, app.id, signature);
metadata.perpetual = true;
- zombieIssuesBlock = formatZombiesForPrompt(result.zombies, { fullName: result.fullName, autoClose });
- emitLog('info', `🧟 issue-reconcile dispatching for ${app.name}: ${result.zombies.length} zombie issue(s)`, { appId: app.id, analysisType: taskType });
+ zombieIssuesBlock = formatZombiesForPrompt(result.zombies, { fullName: result.fullName, forge: result.forge, autoClose });
+ emitLog('info', `🧟 issue-reconcile dispatching for ${app.name}: ${result.zombies.length} zombie issue(s) on ${result.forge}`, { appId: app.id, analysisType: taskType });
}
// Honor a direct claim-work prompt customization if the user set one;
diff --git a/server/services/gitlab.js b/server/services/gitlab.js
new file mode 100644
index 0000000000..3bfffd5701
--- /dev/null
+++ b/server/services/gitlab.js
@@ -0,0 +1,27 @@
+import { spawn } from 'child_process';
+
+/**
+ * Execute a `glab` CLI command safely using spawn (no shell — injection-proof).
+ *
+ * Unlike `execGh` (github.js), this takes an explicit `cwd`: `glab` resolves the
+ * target project from the repo's git `origin` remote in the working directory, so
+ * it MUST run inside the repo checkout. Resolves to trimmed stdout on success and
+ * `null` on ANY failure (non-zero exit, spawn error, glab not installed) — callers
+ * treat null as "unavailable / transient", mirroring the `.catch(() => null)`
+ * pattern used around `execGh`.
+ *
+ * @param {string[]} args - glab arguments (e.g. ['issue', 'list', '-F', 'json'])
+ * @param {string} cwd - repo root the glab command runs in
+ * @returns {Promise<string|null>}
+ */
+export function execGlab(args, cwd) {
+ return new Promise((resolve) => {
+ const child = spawn('glab', args, { cwd, shell: false, windowsHide: true });
+ let stdout = '';
+ child.stdout.on('data', (d) => { stdout += d.toString(); });
+ // stderr is intentionally ignored — a failed glab call resolves to null via
+ // the exit code, and we never surface glab's stderr to the caller.
+ child.on('close', (code) => resolve(code === 0 ? stdout.trim() : null));
+ child.on('error', () => resolve(null));
+ });
+}
diff --git a/server/services/issueReconcile.js b/server/services/issueReconcile.js
index 802a759a5d..468f222f75 100644
--- a/server/services/issueReconcile.js
+++ b/server/services/issueReconcile.js
@@ -2,23 +2,32 @@
* Issue Reconciler — deterministic core.
*
* Finds ZOMBIE issues: open + `in-progress` (claimed-and-being-worked) yet with
- * their linked PR already MERGED and NO live claim anywhere (no open PR, no
+ * their linked PR/MR already MERGED and NO live claim anywhere (no open PR/MR, no
* local/remote/CoS claim branch, no active CoS agent). A zombie is an issue a
* partial ship left stranded — the claim queue skips `in-progress`, so its
* remaining scope is never re-picked and never finished.
*
- * The scheduler runs the deterministic scan here (gh + git only — no LLM), then
- * hands the zombie set to a coordinator CoS agent that reads each issue + its
- * merged PR and applies the partial-ship hybrid (close + file a scoped follow-up
- * when the remainder is separable, or comment "done/remaining" + release the
- * claim when it's a continuation). This module never spawns an agent, so it
+ * 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.
+ *
+ * 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
+ * merged PR/MR and applies the partial-ship hybrid (close + file a scoped
+ * follow-up when the remainder is separable, or comment "done/remaining" + release
+ * the claim when it's a continuation). This module never spawns an agent, so it
* stays pure enough to unit-test — mirroring `branchReconcile.js`.
*
* PEER SAFETY differs from branch-reconcile. Branch-reconcile only ever touches
* LOCAL refs, so a peer's branch is structurally invisible. Issue state, by
- * contrast, is SHARED GitHub state across every federated peer. So the live-claim
- * guard deliberately consults REMOTE refs and OPEN PRs too — a claim in flight on
- * another machine shows up here as an `origin/*` ref or an open PR, and must
+ * contrast, is SHARED forge state across every federated peer. So the live-claim
+ * guard deliberately consults REMOTE refs and OPEN PRs/MRs too — a claim in flight
+ * on another machine shows up here as an `origin/*` ref or an open PR/MR, and must
* suppress the zombie classification. Close/unlabel are idempotent across peers;
* the one real race (two machines filing a duplicate follow-up) is deduped by the
* coordinator, not here.
@@ -26,11 +35,15 @@
import { execGit } from '../lib/execGit.js';
import { execGh } from './github.js';
+import { execGlab } from './gitlab.js';
import { getOriginInfo } from '../lib/gitRemote.js';
+import { hostToWorkTracker } from '../lib/workTracker.js';
import { safeJSONParse, PATHS } from '../lib/fileUtils.js';
-// Bound the gh queries (single-user repos never realistically truncate at 200).
+// Bound the forge queries (single-user repos never realistically truncate at 200).
const GH_LIST_LIMIT = 200;
+// glab paginates via `--per-page`; its practical max page is 100.
+const GL_PER_PAGE = 100;
// The `in-progress` label = "claimed and being worked". Kept as a constant so
// the scan, the classifier docs, and any future config share one spelling.
@@ -44,7 +57,8 @@ export const IN_PROGRESS_LABEL = 'in-progress';
* The number must be a whole path segment (terminated by `/` or end-of-ref), so
* `issue-222` never matches inside `issue-2220`. Remote-tracking refs
* (`origin/claim/issue-<num>`) match the same way — the `refs/remotes/origin/`
- * prefix is just more leading segments.
+ * prefix is just more leading segments. Forge-agnostic: GitLab MR source
+ * branches use the identical `claim/issue-<iid>` convention.
* @param {string} refName
* @returns {number|null}
*/
@@ -54,7 +68,7 @@ export function issueNumberFromRef(refName) {
}
/**
- * Does a PR body reference issue #num as a whole token? `#222` must not match
+ * 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
* plain `#num` as well as `Closes/Fixes/Resolves/Refs #num`.
* @param {string} body
@@ -67,7 +81,7 @@ export function bodyReferencesIssue(body, num) {
}
/**
- * Does a PR (by head ref OR body) reference issue #num?
+ * Does a PR/MR (by head ref OR body) reference issue #num?
* @param {{headRefName?:string, body?:string}} pr
* @param {number} num
* @returns {boolean}
@@ -80,9 +94,9 @@ export function prReferencesIssue(pr, num) {
/**
* Pure classifier: map one issue's facts to a reconcile state. First match wins.
- * ZOMBIE — merged PR shipped for it, no live claim, no active agent → heal
- * LIVE — an open PR / claim branch / active agent still owns it → leave
- * STALLED — no merged PR and no live claim (claimed but nothing shipped)→ report
+ * ZOMBIE — merged PR/MR shipped for it, no live claim, no active agent → heal
+ * LIVE — an open PR/MR / claim branch / active agent still owns it → leave
+ * STALLED — no merged PR/MR and no live claim (claimed but nothing shipped)→ report
* Only issues that already carry `in-progress` are ever passed in.
* @param {{ hasMergedPr:boolean, hasLiveClaim:boolean, hasActiveAgent:boolean }} input
* @returns {'ZOMBIE'|'LIVE'|'STALLED'}
@@ -105,7 +119,8 @@ export function classifyIssues(inputs) {
/**
* Every issue number that has a LIVE claim ref (local OR remote). A live ref
* means some machine (this one or a peer) is mid-claim, so the issue is NOT a
- * zombie even if a different PR already merged.
+ * zombie even if a different PR/MR already merged. Forge-agnostic — both GitHub
+ * and GitLab claim branches share the `claim/issue-<num>` naming.
* @param {string} repoPath
* @returns {Promise<Set<number>>}
*/
@@ -124,16 +139,28 @@ async function getLiveClaimIssueNums(repoPath) {
}
/**
- * Fetch issue/PR facts from GitHub. Returns null on any gh failure or non-GitHub
- * remote (degrade: the caller treats null as "nothing to reconcile / transient").
- * @param {string} repoPath
- * @returns {Promise<{fullName:string, inProgress:object[], mergedPrs:object[], openPrs:object[]}|null>}
+ * Normalize a raw GitHub issue (from `gh issue list --json`) into the common
+ * shape the forge-agnostic gatherer consumes.
*/
-async function getGithubState(repoPath) {
- const origin = await getOriginInfo(repoPath).catch(() => null);
- if (!origin?.isGithub || !origin.fullName) return null;
- const { fullName } = origin;
+function normalizeGithubIssue(issue) {
+ return {
+ number: issue.number,
+ title: issue.title || '',
+ url: issue.url || '',
+ labels: Array.isArray(issue.labels) ? issue.labels.map((l) => l.name) : [],
+ assignees: Array.isArray(issue.assignees) ? issue.assignees.map((a) => a.login) : [],
+ };
+}
+/**
+ * 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 /
+ * transient"). `fullName` is resolved by the dispatcher, not re-queried here.
+ * @param {string} repoPath
+ * @param {string} fullName
+ * @returns {Promise<{forge:'github', fullName:string, inProgress:object[], mergedPrs:object[], openPrs:object[]}|null>}
+ */
+async function getGithubState(repoPath, fullName) {
const [issuesRaw, mergedRaw, openRaw] = await Promise.all([
execGh(['issue', 'list', '--repo', fullName, '--state', 'open',
'--label', IN_PROGRESS_LABEL, '--limit', String(GH_LIST_LIMIT),
@@ -146,56 +173,141 @@ async function getGithubState(repoPath) {
'--json', 'number,headRefName,body']).catch(() => null),
]);
- const inProgress = safeJSONParse(issuesRaw, null);
+ const inProgressRaw = safeJSONParse(issuesRaw, null);
// A failed ISSUE list is the load-bearing query — treat the whole scan as a
// transient blip (return null → skip without parking). Empty is a valid,
// different answer (no in-progress issues) and returns [].
- if (!Array.isArray(inProgress)) return null;
+ if (!Array.isArray(inProgressRaw)) return null;
return {
+ forge: 'github',
fullName,
- inProgress,
+ inProgress: inProgressRaw.map(normalizeGithubIssue),
mergedPrs: safeJSONParse(mergedRaw, []) || [],
openPrs: safeJSONParse(openRaw, []) || [],
};
}
/**
- * Gather the raw facts for every open `in-progress` issue in `repoPath`'s GitHub
- * repo. Effectful (gh + git). Returns null on a non-GitHub remote or a transient
- * gh failure so the scheduler can skip without parking.
+ * Normalize a raw GitLab issue (from `glab issue list -F json`) into the common
+ * shape. GitLab keys the number on `iid`, exposes labels as plain strings, and
+ * assignees as `{ username }` objects.
+ */
+function normalizeGitlabIssue(issue) {
+ return {
+ number: issue.iid,
+ title: issue.title || '',
+ url: issue.web_url || '',
+ labels: Array.isArray(issue.labels)
+ ? issue.labels.map((l) => (typeof l === 'string' ? l : l?.name)).filter(Boolean)
+ : [],
+ assignees: Array.isArray(issue.assignees)
+ ? issue.assignees.map((a) => a?.username).filter(Boolean)
+ : [],
+ };
+}
+
+/**
+ * Normalize a raw GitLab merge request into the common `{ number, headRefName,
+ * body, url }` change shape `prReferencesIssue` expects. The MR's source branch
+ * is the head ref (carries `claim/issue-<iid>`); the description is the body
+ * (carries `Refs #<iid>`).
+ */
+function normalizeGitlabMr(mr) {
+ return {
+ number: mr.iid,
+ headRefName: mr.source_branch || '',
+ body: mr.description || '',
+ url: mr.web_url || '',
+ };
+}
+
+/**
+ * Fetch issue/MR facts from GitLab via `glab`, normalized to the common shape.
+ * Mirrors getGithubState: the in-progress ISSUE list is load-bearing (null → skip
+ * without parking); merged/open MR lists degrade to []. `glab` resolves the
+ * project from the repo's origin remote, so every call runs in `repoPath`.
+ * @param {string} repoPath
+ * @param {string} fullName
+ * @returns {Promise<{forge:'gitlab', fullName:string, inProgress:object[], mergedPrs:object[], openPrs:object[]}|null>}
+ */
+async function getGitlabState(repoPath, fullName) {
+ const [issuesRaw, mergedRaw, openRaw] = await Promise.all([
+ // `glab issue list` defaults to OPEN issues; --label filters to in-progress.
+ execGlab(['issue', 'list', '--label', IN_PROGRESS_LABEL,
+ '--per-page', String(GL_PER_PAGE), '-F', 'json'], repoPath),
+ execGlab(['mr', 'list', '--state', 'merged',
+ '--per-page', String(GL_PER_PAGE), '-F', 'json'], repoPath),
+ execGlab(['mr', 'list', '--state', 'opened',
+ '--per-page', String(GL_PER_PAGE), '-F', 'json'], repoPath),
+ ]);
+
+ const inProgressRaw = safeJSONParse(issuesRaw, null);
+ if (!Array.isArray(inProgressRaw)) return null;
+ return {
+ forge: 'gitlab',
+ fullName,
+ inProgress: inProgressRaw.map(normalizeGitlabIssue),
+ mergedPrs: (safeJSONParse(mergedRaw, []) || []).map(normalizeGitlabMr),
+ openPrs: (safeJSONParse(openRaw, []) || []).map(normalizeGitlabMr),
+ };
+}
+
+/**
+ * Resolve the app's forge from its git origin host and fetch the corresponding
+ * state. github.* → GitHub, gitlab.* → GitLab; any other remote (or no origin)
+ * returns null so the caller skips without parking.
+ * @param {string} repoPath
+ * @returns {Promise<object|null>}
+ */
+async function getForgeState(repoPath) {
+ const origin = await getOriginInfo(repoPath).catch(() => null);
+ if (!origin?.fullName) return null;
+ // getOriginInfo already classifies GitHub authoritatively (older callers/tests
+ // may not carry a `host`), so trust isGithub first; fall back to the canonical
+ // host classifier for GitLab (and any future forges hostToWorkTracker adds).
+ if (origin.isGithub) return getGithubState(repoPath, origin.fullName);
+ if (hostToWorkTracker(origin.host) === 'gitlab') return getGitlabState(repoPath, origin.fullName);
+ return null;
+}
+
+/**
+ * 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.
*
* @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.
- * @returns {Promise<{fullName:string, issues:object[]}|null>}
+ * @returns {Promise<{forge:string, fullName:string, issues:object[]}|null>}
*/
export async function gatherIssueState(repoPath, { activeAgentIssueNums = new Set() } = {}) {
- const [gh, liveClaimNums] = await Promise.all([
- getGithubState(repoPath),
+ const [state, liveClaimNums] = await Promise.all([
+ getForgeState(repoPath),
getLiveClaimIssueNums(repoPath),
]);
- if (!gh) return null;
+ if (!state) return null;
- const issues = gh.inProgress.map((issue) => {
+ const issues = state.inProgress.map((issue) => {
const num = issue.number;
- const mergedPr = gh.mergedPrs.find((pr) => prReferencesIssue(pr, num)) || null;
- const openPr = gh.openPrs.find((pr) => prReferencesIssue(pr, num)) || null;
+ const mergedPr = state.mergedPrs.find((pr) => prReferencesIssue(pr, num)) || null;
+ const openPr = state.openPrs.find((pr) => prReferencesIssue(pr, num)) || null;
return {
number: num,
title: issue.title || '',
url: issue.url || '',
- labels: Array.isArray(issue.labels) ? issue.labels.map((l) => l.name) : [],
- assignees: Array.isArray(issue.assignees) ? issue.assignees.map((a) => a.login) : [],
+ labels: Array.isArray(issue.labels) ? issue.labels : [],
+ assignees: Array.isArray(issue.assignees) ? issue.assignees : [],
mergedPr,
hasMergedPr: Boolean(mergedPr),
- // Live claim = an OPEN PR for this issue, OR a local/remote claim branch,
+ // 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),
};
});
- return { fullName: gh.fullName, issues };
+ return { forge: state.forge, fullName: state.fullName, issues };
}
/**
@@ -205,14 +317,16 @@ export async function gatherIssueState(repoPath, { activeAgentIssueNums = new Se
*
* @param {string} [repoPath=PATHS.root]
* @param {{ activeAgentIssueNums?: Set<number> }} [opts]
- * @returns {Promise<{ fullName:string, zombies:object[], stalled:object[], live:object[] }|null>}
- * null on non-GitHub remote / transient gh failure (skip, don't park).
+ * @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).
*/
export async function reconcile(repoPath = PATHS.root, { activeAgentIssueNums = new Set() } = {}) {
const gathered = await gatherIssueState(repoPath, { activeAgentIssueNums });
if (!gathered) return null;
const classified = classifyIssues(gathered.issues);
return {
+ forge: gathered.forge,
fullName: gathered.fullName,
zombies: classified.filter((c) => c.state === 'ZOMBIE'),
stalled: classified.filter((c) => c.state === 'STALLED'),
@@ -227,7 +341,7 @@ 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).
+ * Order-independent (sorted). Forge-agnostic (issue numbers + merged change #).
* @param {object[]} zombies
* @returns {string}
*/
@@ -241,16 +355,18 @@ export function zombieSignature(zombies) {
/**
* Render the zombie set into the coordinator prompt body (injected as
* `{zombieIssues}`). The per-issue entries stay factual; the partial-ship
- * mechanics live once in the prompt template. Only the dynamic `autoClose`
- * directive is surfaced here (the template can't know it), as a single header
- * line rather than repeated per issue.
+ * 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.
* @param {object[]} zombies
- * @param {{ fullName:string, autoClose:boolean }} ctx
+ * @param {{ fullName:string, forge?:string, autoClose:boolean }} ctx
* @returns {string}
*/
-export function formatZombiesForPrompt(zombies, { fullName, autoClose }) {
+export function formatZombiesForPrompt(zombies, { fullName, forge = 'github', autoClose }) {
+ const isGitlab = forge === 'gitlab';
+ const change = isGitlab ? 'MR' : 'PR';
const lines = [
- `Repo: \`${fullName}\`. Zombie issues to reconcile (${zombies.length}):`,
+ `Forge: **${isGitlab ? 'GitLab (use `glab`)' : 'GitHub (use `gh`)'}**. Repo: \`${fullName}\`. Zombie issues to reconcile (${zombies.length}):`,
'',
autoClose
? '**autoClose is ON** — apply the full partial-ship hybrid below (close + file a scoped follow-up when the remainder is separable; otherwise comment + release the claim).'
@@ -258,7 +374,9 @@ export function formatZombiesForPrompt(zombies, { fullName, autoClose }) {
'',
];
for (const z of zombies) {
- const pr = z.mergedPr ? `merged PR #${z.mergedPr.number}${z.mergedPr.url ? ` (${z.mergedPr.url})` : ''}` : 'a merged PR';
+ const pr = z.mergedPr
+ ? `merged ${change} #${z.mergedPr.number}${z.mergedPr.url ? ` (${z.mergedPr.url})` : ''}`
+ : `a merged ${change}`;
lines.push(`### #${z.number} — ${z.title}`);
if (z.url) lines.push(`- Issue: ${z.url}`);
lines.push(`- Shipped by: ${pr}`);
diff --git a/server/services/issueReconcile.test.js b/server/services/issueReconcile.test.js
index 7f7ed6bc9d..57f2d15b85 100644
--- a/server/services/issueReconcile.test.js
+++ b/server/services/issueReconcile.test.js
@@ -4,11 +4,12 @@
* - issueNumberFromRef / bodyReferencesIssue / prReferencesIssue — the boundary-
* safe reference matchers (no `issue-222` matching inside `issue-2220`).
* - classifyIssue / classifyIssues — the pure ZOMBIE/LIVE/STALLED state machine.
- * - reconcile / gatherIssueState — end-to-end over mocked gh + git: an
- * in-progress issue with a merged PR and no live claim is a ZOMBIE; an open PR
- * or a live claim branch or an active agent keeps it LIVE.
+ * - reconcile / gatherIssueState — end-to-end over mocked gh/glab + git: an
+ * in-progress issue with a merged PR/MR and no live claim is a ZOMBIE; an open
+ * PR/MR or a live claim branch or an active agent keeps it LIVE. Runs the SAME
+ * assertions against both the GitHub (`gh`) and GitLab (`glab`) forge gatherers.
* - zombieSignature / formatZombiesForPrompt — the convergence signature and the
- * autoClose-aware prompt body.
+ * forge- + autoClose-aware prompt body.
*/
import { describe, it, expect, vi, beforeEach } from 'vitest';
@@ -17,8 +18,19 @@ vi.mock('../lib/execGit.js', () => ({
execGit: vi.fn(async () => ({ stdout: '', exitCode: 0 })),
}));
vi.mock('./github.js', () => ({ execGh: vi.fn(async () => '[]') }));
+vi.mock('./gitlab.js', () => ({ execGlab: vi.fn(async () => '[]') }));
vi.mock('../lib/gitRemote.js', () => ({
- getOriginInfo: vi.fn(async () => ({ isGithub: true, fullName: 'atomantic/PortOS' })),
+ getOriginInfo: vi.fn(async () => ({ isGithub: true, host: 'github.com', fullName: 'atomantic/PortOS' })),
+}));
+// hostToWorkTracker is the canonical host→forge classifier; use the real logic
+// so the GitLab branch is exercised through the same mapping production uses.
+vi.mock('../lib/workTracker.js', () => ({
+ hostToWorkTracker: (host) => {
+ if (!host) return null;
+ if (/(^|\.)gitlab\./.test(host) || host === 'gitlab.com') return 'gitlab';
+ if (/(^|\.)github\./.test(host) || host === 'github.com') return 'github';
+ return null;
+ },
}));
vi.mock('../lib/fileUtils.js', () => ({
PATHS: { root: '/repo' },
@@ -32,12 +44,13 @@ import {
} from './issueReconcile.js';
import { execGit } from '../lib/execGit.js';
import { execGh } from './github.js';
+import { execGlab } from './gitlab.js';
import { getOriginInfo } from '../lib/gitRemote.js';
beforeEach(() => {
vi.clearAllMocks();
execGit.mockResolvedValue({ stdout: '', exitCode: 0 });
- getOriginInfo.mockResolvedValue({ isGithub: true, fullName: 'atomantic/PortOS' });
+ getOriginInfo.mockResolvedValue({ isGithub: true, host: 'github.com', fullName: 'atomantic/PortOS' });
});
describe('issueNumberFromRef', () => {
@@ -136,6 +149,7 @@ describe('reconcile', () => {
execGit.mockResolvedValue({ stdout: '', exitCode: 0 }); // no claim refs
const result = await reconcile('/repo');
+ expect(result.forge).toBe('github');
expect(result.zombies.map((z) => z.number)).toEqual([2220]);
expect(result.zombies[0].mergedPr.number).toBe(2234);
expect(result.stalled).toHaveLength(0);
@@ -188,10 +202,20 @@ describe('reconcile', () => {
expect(result.stalled.map((s) => s.number)).toEqual([2220]);
});
- it('returns null (skip, do not park) on a non-GitHub remote', async () => {
- getOriginInfo.mockResolvedValue({ isGithub: false, fullName: null });
+ it('returns null (skip, do not park) when the origin has no fullName', async () => {
+ getOriginInfo.mockResolvedValue({ isGithub: false, host: null, fullName: null });
+ const result = await reconcile('/repo');
+ expect(result).toBeNull();
+ });
+
+ it('returns null (skip) on an unsupported forge (neither GitHub nor GitLab)', async () => {
+ // A parseable non-forge remote (e.g. bitbucket) — has a fullName but no
+ // gh/glab gatherer, so the scan skips without parking.
+ getOriginInfo.mockResolvedValue({ isGithub: false, host: 'bitbucket.org', fullName: 'team/proj' });
const result = await reconcile('/repo');
expect(result).toBeNull();
+ expect(execGh).not.toHaveBeenCalled();
+ expect(execGlab).not.toHaveBeenCalled();
});
it('returns null (transient) when the issue list query fails', async () => {
@@ -211,6 +235,108 @@ describe('reconcile', () => {
});
});
+// --- end-to-end gather/reconcile over mocked glab + git (GitLab forge) ---
+
+/** Point the origin at GitLab so getForgeState routes to the glab gatherer. */
+function useGitlabOrigin() {
+ getOriginInfo.mockResolvedValue({ isGithub: false, host: 'gitlab.com', fullName: 'group/proj' });
+}
+
+/**
+ * Wire execGlab's three list calls by argv shape. Inputs use the RAW GitLab JSON
+ * shape (iid / web_url / source_branch / description) so the test also exercises
+ * the GitLab→common normalizers.
+ */
+function mockGlab({ issues = [], merged = [], open = [] }) {
+ execGlab.mockImplementation(async (argv) => {
+ if (argv[0] === 'issue' && argv[1] === 'list') return JSON.stringify(issues);
+ if (argv[0] === 'mr' && argv.includes('merged')) return JSON.stringify(merged);
+ if (argv[0] === 'mr' && argv.includes('opened')) return JSON.stringify(open);
+ return '[]';
+ });
+}
+
+describe('reconcile (GitLab forge)', () => {
+ beforeEach(useGitlabOrigin);
+
+ it('flags an in-progress issue whose MR merged with no live claim as a ZOMBIE', async () => {
+ mockGlab({
+ issues: [{ iid: 42, title: 'GL zombie', labels: ['in-progress', 'area:api'], assignees: [{ username: 'adam' }], web_url: 'u' }],
+ merged: [{ iid: 7, source_branch: 'claim/issue-42', description: 'Refs #42', web_url: 'm' }],
+ open: [],
+ });
+ const result = await reconcile('/repo');
+ expect(result.forge).toBe('gitlab');
+ expect(result.zombies.map((z) => z.number)).toEqual([42]);
+ expect(result.zombies[0].mergedPr.number).toBe(7);
+ // GitLab labels/assignees normalize to plain strings.
+ expect(result.zombies[0].labels).toContain('area:api');
+ expect(result.zombies[0].assignees).toEqual(['adam']);
+ expect(execGh).not.toHaveBeenCalled();
+ });
+
+ it('matches the MR by its claim/issue-<iid> source branch (head ref)', async () => {
+ mockGlab({
+ issues: [{ iid: 42, title: 't', labels: ['in-progress'], assignees: [], web_url: 'u' }],
+ merged: [{ iid: 7, source_branch: 'claim/issue-42', description: 'no trailer here', web_url: 'm' }],
+ open: [],
+ });
+ const result = await reconcile('/repo');
+ expect(result.zombies.map((z) => z.number)).toEqual([42]);
+ });
+
+ it('a live open MR keeps the issue LIVE (not a zombie)', async () => {
+ mockGlab({
+ issues: [{ iid: 42, title: 't', labels: ['in-progress'], assignees: [], web_url: 'u' }],
+ merged: [{ iid: 7, source_branch: 'x', description: 'Refs #42' }],
+ open: [{ iid: 9, source_branch: 'claim/issue-42', description: '' }],
+ });
+ const result = await reconcile('/repo');
+ expect(result.zombies).toHaveLength(0);
+ expect(result.live.map((l) => l.number)).toEqual([42]);
+ });
+
+ it('a live LOCAL/REMOTE claim branch keeps the GitLab issue LIVE', async () => {
+ mockGlab({
+ issues: [{ iid: 42, title: 't', labels: ['in-progress'], assignees: [], web_url: 'u' }],
+ merged: [{ iid: 7, source_branch: 'x', description: 'Refs #42' }],
+ open: [],
+ });
+ execGit.mockResolvedValue({ stdout: 'refs/remotes/origin/claim/issue-42\nrefs/heads/main\n', exitCode: 0 });
+ const result = await reconcile('/repo');
+ expect(result.zombies).toHaveLength(0);
+ expect(result.live.map((l) => l.number)).toEqual([42]);
+ });
+
+ it('no merged MR and no live claim → STALLED', async () => {
+ mockGlab({
+ issues: [{ iid: 42, title: 't', labels: ['in-progress'], assignees: [], web_url: 'u' }],
+ merged: [],
+ open: [],
+ });
+ const result = await reconcile('/repo');
+ expect(result.zombies).toHaveLength(0);
+ expect(result.stalled.map((s) => s.number)).toEqual([42]);
+ });
+
+ it('returns null (transient) when the glab issue list query fails', async () => {
+ execGlab.mockImplementation(async (argv) => {
+ if (argv[0] === 'issue') return null; // load-bearing query failed / glab down
+ return '[]';
+ });
+ const result = await reconcile('/repo');
+ expect(result).toBeNull();
+ });
+
+ it('empty in-progress list is a valid answer (no zombies), not a skip', async () => {
+ mockGlab({ issues: [], merged: [], open: [] });
+ const result = await reconcile('/repo');
+ expect(result).not.toBeNull();
+ expect(result.forge).toBe('gitlab');
+ expect(result.zombies).toHaveLength(0);
+ });
+});
+
describe('gatherIssueState carries labels/assignees for the follow-up', () => {
it('surfaces area labels + assignees on the zombie record', async () => {
mockGh({
@@ -264,4 +390,21 @@ describe('formatZombiesForPrompt', () => {
expect(md).toContain('autoClose is OFF');
expect(md).toContain('never close an issue or file a follow-up');
});
+ it('defaults to the GitHub forge header (gh) when forge is omitted', () => {
+ const md = formatZombiesForPrompt(
+ [{ number: 2220, title: 'CDO', url: 'u', mergedPr: { number: 2234, url: 'p' } }],
+ { fullName: 'atomantic/PortOS', autoClose: true }
+ );
+ expect(md).toContain('GitHub (use `gh`)');
+ expect(md).toContain('merged PR #2234');
+ });
+ it('renders a GitLab header + "MR" wording when forge is gitlab', () => {
+ const md = formatZombiesForPrompt(
+ [{ number: 42, title: 'GL', url: 'u', mergedPr: { number: 7, url: 'm' } }],
+ { fullName: 'group/proj', forge: 'gitlab', autoClose: true }
+ );
+ expect(md).toContain('GitLab (use `glab`)');
+ expect(md).toContain('merged MR #7');
+ expect(md).not.toContain('merged PR');
+ });
});
diff --git a/server/services/taskPromptDefaults/integrity.snapshot.json b/server/services/taskPromptDefaults/integrity.snapshot.json
index 6852c071e6..1fc2fc965b 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": "c57a39aaa118173a496f030f5878bfc1",
+ "issue-reconcile": "c87d7adb57de208c069964760c9c6276",
"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": 1,
+ "issue-reconcile": 2,
"refresh-local-llm-catalog": 1,
"security": 2,
"code-quality": 2,
@@ -132,6 +132,9 @@
"133c221608545a26f328dead099a4d0a",
"609167c41331e6bbfc6d5f5edc452d4c",
"9c7508598ee772d1cee8f609f9ed7372"
+ ],
+ "issue-reconcile": [
+ "c57a39aaa118173a496f030f5878bfc1"
]
}
}
diff --git a/server/services/taskPromptDefaults/previousDefaults.js b/server/services/taskPromptDefaults/previousDefaults.js
index dba1e0fcf1..28b19b3a79 100644
--- a/server/services/taskPromptDefaults/previousDefaults.js
+++ b/server/services/taskPromptDefaults/previousDefaults.js
@@ -2859,4 +2859,31 @@ Summarize:
IMPORTANT: Always use \`git pull --rebase --autostash\` before pushing (dev branch gets auto-bumped by CI). Never use \`git push\` alone.`,
],
+ 'issue-reconcile': [
+ // v1 default (GitHub-only) — superseded by the forge-aware v2 body (gh/glab).
+ `[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 already MERGED and no live claim exists anywhere (no open PR, 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}
+
+Work through the issues above one at a time (they touch shared GitHub 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 (\`gh issue view <num> --comments\`) AND the merged PR (\`gh pr view <pr> \`) before touching anything. Confirm the merged PR actually shipped work FOR this issue (not just a coincidental \`#<num>\` mention) AND that real scope REMAINS. If the PR fully satisfied the issue, just close it (\`gh issue close <num>\`) and remove \`in-progress\` — it was mislabeled, not partial. If the PR 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: \`gh issue create --title "…" --label plan --body "…\\n\\nRefs #<num>"\`. Carry over any \`area:*\` labels the original had. Then remove the label: \`gh issue edit <num> --remove-label in-progress\` (closing already drops it from the queue, but be explicit).
+- **Continuation of the same scope** → keep the issue OPEN, post a \`Done ✓ / Remaining ▢\` comment, and release the claim so the queue re-picks it: \`gh issue edit <num> --remove-label in-progress --remove-assignee @me\`.
+
+## 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).`,
+ ],
};
diff --git a/server/services/taskPromptDefaults/prompts.js b/server/services/taskPromptDefaults/prompts.js
index 83ce56ec79..3437339388 100644
--- a/server/services/taskPromptDefaults/prompts.js
+++ b/server/services/taskPromptDefaults/prompts.js
@@ -1268,23 +1268,29 @@ 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 already MERGED and no live claim exists anywhere (no open PR, 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 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}
-Work through the issues above one at a time (they touch shared GitHub state — do NOT parallelize), applying the hybrid below to each and honoring the **autoClose** directive shown above the list.
+**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 (\`gh issue view <num> --comments\`) AND the merged PR (\`gh pr view <pr> \`) before touching anything. Confirm the merged PR actually shipped work FOR this issue (not just a coincidental \`#<num>\` mention) AND that real scope REMAINS. If the PR fully satisfied the issue, just close it (\`gh issue close <num>\`) and remove \`in-progress\` — it was mislabeled, not partial. If the PR did NOT address this issue at all, leave it untouched and note it in your summary — it is not a zombie.
+- 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: \`gh issue create --title "…" --label plan --body "…\\n\\nRefs #<num>"\`. Carry over any \`area:*\` labels the original had. Then remove the label: \`gh issue edit <num> --remove-label in-progress\` (closing already drops it from the queue, but be explicit).
-- **Continuation of the same scope** → keep the issue OPEN, post a \`Done ✓ / Remaining ▢\` comment, and release the claim so the queue re-picks it: \`gh issue edit <num> --remove-label in-progress --remove-assignee @me\`.
+- **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 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.
+{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.
diff --git a/server/services/taskPromptDefaults/versions.js b/server/services/taskPromptDefaults/versions.js
index f2f6557c59..d8b8f59d6f 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': 1, // 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': 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.
'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