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

claim-issue: decompose an epic instead of ending the run with nothing done

[._.]/ Adam Eivy4a5733d386a9
diff --git a/client/src/components/apps/WorkItemPicker.jsx b/client/src/components/apps/WorkItemPicker.jsx
index 4e23d1f48d..bc839f2acf 100644
--- a/client/src/components/apps/WorkItemPicker.jsx
+++ b/client/src/components/apps/WorkItemPicker.jsx
@@ -17,7 +17,7 @@ const EMPTY_REASONS = {
'no-actionable-plan-items': 'Every PLAN.md item is checked, blocked, or already claimed.',
'no-open-issues': 'The tracker has no open issues.',
'no-authored-issues': 'Open issues exist, but none match the author filter — widen it to see them.',
- 'no-actionable-issues': 'Every open issue is assigned, blocked, in flight, or an epic.',
+ 'no-actionable-issues': 'Every open issue is assigned, blocked, in flight, or an already-decomposed epic.',
'owner-is-org': 'The repo owner is an organization, which never authors issues — switch the filter to "Any author".',
'owner-is-group': 'The project namespace is a group, which never authors issues — switch the filter to "Any author".',
'jira-not-configured': 'JIRA is not configured for this app.',
diff --git a/server/lib/README.md b/server/lib/README.md
index 5cb8e29efd..6e0e6fb587 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -400,7 +400,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub
| `assetRoutePrefixes.js` | Import-free leaf holding the URL prefixes the server owns: `ASSET_ROUTE_PREFIXES` (every `/data/**` static mount) and `SERVER_OWNED_PREFIXES` (what must never reach the SPA fallback, each with the exact `spaPaths` that ARE client routes). `scripts/dev-proxy-drift.test.js` checks the dev proxy's `^/data/` wildcard against the mounts, pins the route-registration order in `server/index.js` (a router added below the terminators is shadowed), and fails if a client route — from `NAV_COMMANDS` or `App.jsx`'s nested `<Route>` tree — is ever added under a server-owned prefix without being declared. |
| `asyncMutex.js` | Promise-based async mutex. |
| `concurrencyGate.js` | `createConcurrencyGate(limit)` → `run(fn)` — cap on simultaneous async work for ONE module-scoped budget, released FIFO. Sibling to `mapWithConcurrency.js`, which caps in-flight work *within one array map*; a gate is shared state, so several call sites fanning out at the same remote respect one budget instead of each respecting its own while the host sees the sum. `createMutex` (`asyncMutex.js`) is this with `limit` fixed at 1 — prefer it for mutual exclusion. Note the budget is per-MODULE, not per-host: two modules calling one host each get their own gate. Used by `huggingFaceCatalog.js` (4) and `ollamaRegistryCatalog.js` (16), whose cold catalog-enrichment bursts otherwise arrive at a free public API as a thundering herd — which the Hub answers with an HTTP/2 GOAWAY that surfaces as a bare `fetch failed`. |
-| `dispatchLabels.js` | slashdo dispatch-hint contract: `model:light/medium/heavy` + `effort:low/medium/high/xhigh/max` vocabulary, prescribed forge colors, validation (`normalizeDispatchModel` / `normalizeDispatchEffort`), GitHub/GitLab vs Jira label formatting, optional contributor labels (`good first issue` / `help wanted`, never implied by `model:light`), lazy-create command text, and shared dispatch plus issue-quality guidance (`ISSUE_QUALITY_GUIDANCE`, `DISPATCH_HINT_GUIDANCE`, `JIRA_DISPATCH_HINT_GUIDANCE`). Omit an unjustified axis; never invent `medium`; reject future-only/speculative work while keeping useful current refactors claimable. Consumed by work-tracker instructions, quota-burn audits, Layered Intelligence filing, and claim follow-up prompts. |
+| `dispatchLabels.js` | slashdo dispatch-hint contract: `model:light/medium/heavy` + `effort:low/medium/high/xhigh/max` vocabulary, prescribed forge colors, validation (`normalizeDispatchModel` / `normalizeDispatchEffort`), GitHub/GitLab vs Jira label formatting, optional contributor labels (`good first issue` / `help wanted`, never implied by `model:light`), the `decomposed` epic workflow marker (`EPIC_DECOMPOSED_LABEL`, shared with perpetualWork.js#isActionableIssue and the claim prompts), lazy-create command text, and shared dispatch plus issue-quality guidance (`ISSUE_QUALITY_GUIDANCE`, `DISPATCH_HINT_GUIDANCE`, `JIRA_DISPATCH_HINT_GUIDANCE`). Omit an unjustified axis; never invent `medium`; reject future-only/speculative work while keeping useful current refactors claimable. Consumed by work-tracker instructions, quota-burn audits, Layered Intelligence filing, and claim follow-up prompts. |
| `domainAutonomy.js` | Per-domain autonomy guardrails (pure). `AUTONOMY_DOMAINS`/`DOMAIN_IDS`/`DOMAIN_MODES` (`off`/`dry-run`/`execute`), `getDomainMode(config, id)`, and `normalizeDomainAutonomy(raw)` to coerce a hand-edited/partial map. Default per domain is `execute` (reproduces pre-#711 behavior, so no migration needed). Also `CREATIVE_DOMAIN`/`getCreativeAutonomyMode(config)` (#2183) — the Creative Director orchestrator domain, kept out of `DOMAIN_IDS` and defaulting to mirror the `cos` mode. |
| `domainBudgets.js` | Per-domain daily autonomy budgets (pure). `BUDGET_LIMIT_FIELDS` (`maxActionsPerDay`/`maxMinutesPerDay`), `getDomainBudget(config, id)`, `normalizeDomainBudgets(raw)`, `hasBudget(budget)`, and `evaluateBudget(budget, usage)` → `{ withinBudget, exceeded }`. A `null`/non-positive cap means unlimited (default per domain, so no migration needed). Token/$ caps are intentionally absent — CLI subscription providers expose no per-run metering. Usage ledger + gate wiring live in `services/domainUsage.js`. |
| `errorHandler.js` | `ServerError` + `asyncHandler` middleware, plus `sendErrorResponse`/`buildErrorEnvelope` for the standard `{ error, code, timestamp }` body outside a handler's catch. |
diff --git a/server/lib/dispatchLabels.js b/server/lib/dispatchLabels.js
index 9c0f174f7c..c8e6369285 100644
--- a/server/lib/dispatchLabels.js
+++ b/server/lib/dispatchLabels.js
@@ -60,6 +60,25 @@ export const CONTRIBUTOR_LABEL_DESCRIPTIONS = Object.freeze({
[HELP_WANTED_LABEL]: 'Extra hands welcome — scoped enough to pick up cold',
});
+/**
+ * Workflow marker the claim flow stamps on a tracking epic once it has filed
+ * that epic's per-slice child issues (claim-issue Phase 1b). Not a dispatch
+ * hint — it is how the live agent and the programmatic work detector
+ * (`perpetualWork.js#isActionableIssue`) agree that an epic has stopped being
+ * claimable: undecomposed ⇒ splitting it IS the work, decomposed ⇒ its children
+ * carry the work. It lives here so the label's name, color, and `label create`
+ * idiom have one definition shared by the detector and the prompt bodies.
+ */
+export const EPIC_DECOMPOSED_LABEL = 'decomposed';
+
+export const WORKFLOW_LABEL_COLORS = Object.freeze({
+ [EPIC_DECOMPOSED_LABEL]: 'BFD4F2',
+});
+
+export const WORKFLOW_LABEL_DESCRIPTIONS = Object.freeze({
+ [EPIC_DECOMPOSED_LABEL]: 'Epic already split into per-slice child issues',
+});
+
const MODEL_SET = new Set(DISPATCH_MODEL_TIERS);
const EFFORT_SET = new Set(DISPATCH_EFFORT_LEVELS);
@@ -157,7 +176,7 @@ export function jiraIssueLabels({ model, effort, goodFirstIssue, helpWanted } =
];
}
-/** `{ name, color, description }` for a forge dispatch or contributor label, or null. */
+/** `{ name, color, description }` for a forge dispatch, contributor, or workflow label, or null. */
export function dispatchLabelSpec(name) {
if (typeof name !== 'string') return null;
if (DISPATCH_LABEL_COLORS[name]) {
@@ -174,6 +193,13 @@ export function dispatchLabelSpec(name) {
description: CONTRIBUTOR_LABEL_DESCRIPTIONS[name],
};
}
+ if (WORKFLOW_LABEL_COLORS[name]) {
+ return {
+ name,
+ color: WORKFLOW_LABEL_COLORS[name],
+ description: WORKFLOW_LABEL_DESCRIPTIONS[name],
+ };
+ }
return null;
}
diff --git a/server/services/appIssues.js b/server/services/appIssues.js
index 46bbd5bf1b..46435bb033 100644
--- a/server/services/appIssues.js
+++ b/server/services/appIssues.js
@@ -2,7 +2,7 @@
* Open-issue listing for a managed app's Issues tab.
*
* Distinct from `workItems.js`, which answers "what could `/do:next` CLAIM?" —
- * that list is deliberately narrowed (assigned / blocked / in-flight / epic
+ * that list is deliberately narrowed (assigned / blocked / in-flight / decomposed-epic
* issues are filtered out) and carries only `{ ref, title }`. The Issues tab
* shows the tracker as it actually is: EVERY open issue, with the labels,
* assignees, and body the user reads before deciding to claim one.
diff --git a/server/services/cosTaskPrompts.js b/server/services/cosTaskPrompts.js
index eb84a3fd40..a0b319e62a 100644
--- a/server/services/cosTaskPrompts.js
+++ b/server/services/cosTaskPrompts.js
@@ -23,7 +23,7 @@ const forgeIssueConstraint = (forge) => (ref, excludeLabelsBlock) => {
const labels = excludeLabelsBlock || '`in-progress`, `blocked`, `needs-input`';
return `## Target Issue Constraint
-The user explicitly selected ${forge} issue #${ref}. Override Phase 1 ("Pick the target issue"): do NOT pick a different issue and do NOT scan for the next eligible one — claim exactly #${ref}, ignore the author filter above, and ignore its current assignee (an explicit selection overrides both filters). Still honor the safety checks: if #${ref} is already closed, already carries any of ${labels}, is already on a \`claim/issue-${ref}\` (or \`cos/.../issue-${ref}/...\`) branch, is a tracking epic, or is stale (Phase 3), exit cleanly rather than forcing it. Otherwise run Phases 2–7 against #${ref}.`;
+The user explicitly selected ${forge} issue #${ref}. Override Phase 1 ("Pick the target issue"): do NOT pick a different issue and do NOT scan for the next eligible one — claim exactly #${ref}, ignore the author filter above, and ignore its current assignee (an explicit selection overrides both filters). Still honor the safety checks: if #${ref} is already closed, already carries any of ${labels}, is already on a \`claim/issue-${ref}\` (or \`cos/.../issue-${ref}/...\`) branch, or is stale (Phase 3), exit cleanly rather than forcing it. **If #${ref} is a tracking epic, do NOT exit** — run Phase 1b against it: claim the next eligible issue already linked from it, or, when it has none, decompose it into per-slice issues first and then claim the first slice. That is the one case where this run legitimately ships an issue other than #${ref}. Otherwise run Phases 2–7 against #${ref}.`;
};
const TARGET_ITEM_BLOCKS = {
@@ -34,7 +34,7 @@ PLAN.md item \`[${ref}]\` is reserved for this run. You MUST work on that exact
'claim-issue-gitlab': forgeIssueConstraint('GitLab'),
'claim-issue-jira': (ref) => `## Target Ticket Constraint
-The user explicitly selected JIRA ticket \`${ref}\` from the board. Override Phase 1 ("Pick the target ticket"): do NOT pick a different ticket and do NOT scan for the next-ready one — claim exactly \`${ref}\`. Still honor the safety checks: if \`${ref}\` is already In Progress / In Review / Done / closed, is already on a \`claim/${ref}\` (or \`cos/.../${ref}/...\`) branch, or its requirements are too ambiguous or too large to implement in a single PR, exit cleanly (file a Review Hub todo for ambiguous requirements) rather than forcing it. Otherwise run Phases 2–7 against \`${ref}\`.`
+The user explicitly selected JIRA ticket \`${ref}\` from the board. Override Phase 1 ("Pick the target ticket"): do NOT pick a different ticket and do NOT scan for the next-ready one — claim exactly \`${ref}\`. Still honor the safety checks: if \`${ref}\` is already In Progress / In Review / Done / closed, is already on a \`claim/${ref}\` (or \`cos/.../${ref}/...\`) branch, or its requirements are too vague to slice against the code at all, exit cleanly (file a Review Hub todo for that last case) rather than forcing it. **Being an Epic — or simply too large for one PR — is NOT an exit**: run Phase 1b against \`${ref}\` instead, claiming the next eligible ticket already linked to it, or decomposing it into per-slice child tickets first and then claiming the first slice. That is the one case where this run legitimately ships a ticket other than \`${ref}\`. Otherwise run Phases 2–7 against \`${ref}\`.`
};
export function buildTargetWorkItemBlock(promptTaskType, ref, excludeLabelsBlock = '') {
diff --git a/server/services/perpetualWork.js b/server/services/perpetualWork.js
index 5d33153412..4633a66002 100644
--- a/server/services/perpetualWork.js
+++ b/server/services/perpetualWork.js
@@ -30,6 +30,12 @@ import { parsePlanItems, extractAllIds, findInProgressIds, pickFirstAvailable, e
import { readOriginRemoteUrl } from '../lib/gitRemote.js';
import { withGlabJson } from '../lib/glabArgs.js';
import { githubApiHost, hostFromOriginUrl } from '../lib/workTracker.js';
+// The epic marker lives with the forge label vocabulary (name + color + the
+// `label create` idiom the prompt bodies interpolate), so the detector and the
+// live claim agent cannot drift on what "already decomposed" is spelled.
+import { EPIC_DECOMPOSED_LABEL } from '../lib/dispatchLabels.js';
+
+export { EPIC_DECOMPOSED_LABEL };
// Labels that make a GitHub issue non-actionable for autonomous claiming. MUST
// stay in sync with the claim-issue prompt's Phase 1 skip-list
@@ -166,33 +172,49 @@ async function inFlightIssueNumbers(repoPath, forge = 'github') {
/**
* Recognize a tracking/umbrella EPIC from its title alone — the programmatic
- * half of the claim-issue prompt's Phase 1 epic skip. An epic needs a human to
- * split it per-slice, so the claim agent always skips one; the detector MUST
- * skip it too or a perpetual drain re-picks it every tick and never parks.
- * Matches the epic-title conventions the prompt names and the agent honors:
+ * half of the claim-issue prompt's epic handling (`isActionableIssue` decides
+ * what that means for claimability). Matches the epic-title conventions the
+ * prompt names and the agent honors:
* - a trailing `(epic)` tag — e.g. "Redesign nav (epic)"
* - a leading `[epic]` bracket or `Epic:` colon tag — e.g. "[Epic] Billing
* revamp", "[epic: theme] …", "Epic: Redesign nav" (case-insensitive)
- * The leading-tag branch is what closes the real-world non-convergence bug: an
- * epic titled "[Epic] …" that carries NO `epic` label kept reading as actionable
- * (label check missed it, and it doesn't END in "(epic)"), so the drain spawned
- * a claim agent that correctly skipped it, completed with nothing shipped, and
- * re-fired back-to-back. The `\b` + `[:\]]` terminator keeps a bare adjective
- * ("Epic rework of nav") and near-words ("[epicenter] …") from matching — only a
- * real bracketed/colon-delimited `epic` tag counts.
+ * The leading-tag branch is what makes an "[Epic] …" issue with no `epic` label
+ * read as an epic at all (label check misses it, and it doesn't END in
+ * "(epic)"). The `\b` + `[:\]]` terminator keeps a bare adjective ("Epic rework
+ * of nav") and near-words ("[epicenter] …") from matching — only a real
+ * bracketed/colon-delimited `epic` tag counts.
*/
export function titleMarksEpic(title) {
const t = (title || '').trim().toLowerCase();
return t.endsWith('(epic)') || /^\[?\s*epic\b\s*[:\]]/.test(t);
}
+// True when an issue is a tracking/umbrella epic — by `epic` label or by the
+// title conventions above. `labels` is the caller's already-lowercased list.
+const isEpicIssue = (title, labels) => labels.includes('epic') || titleMarksEpic(title);
+
+const normalizeLogin = (value) => (value == null ? '' : String(value)).trim().toLowerCase();
+
+const assigneeLogin = (assignee) => normalizeLogin(
+ typeof assignee === 'string' ? assignee : assignee?.login || assignee?.username
+);
+
/**
* Decide whether a single forge issue (as returned by `gh`/`glab` issue list)
* is autonomously claimable. Mirrors the claim-issue prompt's Phase 1 step 4
* predicate: no in-flight claim ref, no assignee belonging to another
- * account, no blocking label, not an epic. An issue assigned to the current
- * authenticated account remains claimable so a previous self-claim can be
- * retried. Exported for direct unit testing.
+ * account, no blocking label, and — for an epic — not already decomposed. An
+ * issue assigned to the current authenticated account remains claimable so a
+ * previous self-claim can be retried. Exported for direct unit testing.
+ *
+ * An UNdecomposed epic counts as actionable: the claim agent's Phase 1b splits
+ * it into per-slice issues (and then claims the first slice), which is real work
+ * and the only way the queue moves when every remaining item is an epic. Once
+ * that agent stamps `EPIC_DECOMPOSED_LABEL` on the parent, the epic drops out and
+ * its children are ordinary claimable issues. A user who does not want a
+ * particular epic auto-split puts a blocking label on it (`future`, `blocked`,
+ * `needs-input`) — that works whether the epic is marked by label or only by its
+ * title, which `epic` in `issueExcludeLabels` would not.
*
* `excludeLabels` is the app's configured `issueExcludeLabels`
* (`taskMetadata.issueExcludeLabels`) — extra labels a user wants left for
@@ -200,12 +222,6 @@ export function titleMarksEpic(title) {
* `NON_ACTIONABLE_ISSUE_LABELS`, never replacing it: the base set is
* structural (in-progress/blocked/etc.), not user-configurable.
*/
-const normalizeLogin = (value) => (value == null ? '' : String(value)).trim().toLowerCase();
-
-const assigneeLogin = (assignee) => normalizeLogin(
- typeof assignee === 'string' ? assignee : assignee?.login || assignee?.username
-);
-
export function isActionableIssue(issue, inFlight = new Set(), excludeLabels = null, currentLogin = null) {
if (!issue || typeof issue.number !== 'number') return false;
if (inFlight.has(issue.number)) return false;
@@ -220,8 +236,11 @@ export function isActionableIssue(issue, inFlight = new Set(), excludeLabels = n
.map((s) => s.toLowerCase());
if (labels.some((l) => NON_ACTIONABLE_ISSUE_LABELS.has(l))) return false;
if (excludeLabels && labels.some((l) => excludeLabels.has(l))) return false;
- if (labels.includes('epic')) return false;
- if (titleMarksEpic(issue.title)) return false;
+ // Marker first: the label scan is a 2–5 element array walk, while isEpicIssue
+ // lowercases and regex-tests the title. Only a decomposed issue needs the
+ // epic check, so this skips that work for essentially every issue in a
+ // 500-issue fetch.
+ if (labels.includes(EPIC_DECOMPOSED_LABEL) && isEpicIssue(issue.title, labels)) return false;
return true;
}
@@ -321,9 +340,9 @@ const FORGE_ISSUE_CONFIG = {
// NON_ACTIONABLE_ISSUE_LABELS plus any configured `issueExcludeLabels`)
// runs client-side AFTER this fetch, so a small fetch cap risks the
// detector parking on a false "no actionable issues" when the first page
- // happens to be full of excluded/in-flight/epic issues even though real
- // work exists further down the queue. Matches the same tradeoff the
- // /do:next auto-pick walk already makes for the identical reason.
+ // happens to be full of excluded/in-flight/decomposed-epic issues even
+ // though real work exists further down the queue. Matches the same
+ // tradeoff the /do:next auto-pick walk already makes for the same reason.
listArgs: ['issue', 'list', '--state', 'open', '--search', 'sort:created-asc', '--json', 'number,assignees,labels,title,author', '--limit', '500'],
listFail: 'gh-list-failed',
parseFail: 'gh-parse-failed',
@@ -368,9 +387,9 @@ const FORGE_ISSUE_CONFIG = {
// `--per-page` maxes out at 100 (GitLab's own per-call ceiling; unlike
// gh's `--limit`, there's no single-call "give me more" here) — same
// residual gap the /do:next auto-pick walk documents for GitLab: a busy
- // tracker whose first page is dominated by excluded/in-flight/epic issues
- // can still park on a false "no actionable issues" despite real work
- // further down the queue. `--issues-label`-style curation is the
+ // tracker whose first page is dominated by excluded/in-flight/
+ // decomposed-epic issues can still park on a false "no actionable issues"
+ // despite real work further down the queue. `--issues-label`-style curation is the
// practical mitigation there; this detector has no equivalent knob yet.
listArgs: withGlabJson(['issue', 'list', '--per-page', '100']),
listFail: 'glab-list-failed',
@@ -595,8 +614,8 @@ async function detectForgeIssues(forgeKey, app, { issueAuthorFilter = 'self', is
// count so the user is told to widen the filter, not that there is nothing
// to do. The count is raw open issues (any author), not claimable ones —
// best effort: switching to `any` may still yield `no-actionable-issues`
- // when the other-authored issues are all blocked/assigned/epics. Counting
- // claimable ones would cost the full skip-list scan here.
+ // when the other-authored issues are all blocked/assigned/decomposed
+ // epics. Counting claimable ones would cost the full skip-list scan here.
if (authorApplied) {
const openCount = await countOpenIssuesUnfiltered(cfg, repoPath);
if (openCount > 0) return parked('no-authored-issues', openCount);
@@ -616,8 +635,8 @@ async function detectForgeIssues(forgeKey, app, { issueAuthorFilter = 'self', is
const total = issues.length;
// How many of the OPEN issues were skipped only because a claim/PR is already
// in flight for them (stale post-merge branches count here). Surfacing this
- // separately from the label/assignee/epic filter tells the user WHY an
- // apparently-non-empty queue yields zero claimable work — the exact confusion
+ // separately from the label/assignee/decomposed-epic filter tells the user
+ // WHY an apparently-non-empty queue yields zero claimable work — the exact confusion
// behind "40 open issues but it parked."
const inFlightCount = issues.filter((i) => typeof i.number === 'number' && inFlight.has(i.number)).length;
const excludeSet = Array.isArray(issueExcludeLabels) && issueExcludeLabels.length > 0
diff --git a/server/services/perpetualWork.test.js b/server/services/perpetualWork.test.js
index 373a008bf5..c3ed3281b1 100644
--- a/server/services/perpetualWork.test.js
+++ b/server/services/perpetualWork.test.js
@@ -22,7 +22,8 @@ import {
registerWorkDetector,
getWorkDetector,
hasWorkDetector,
- NON_ACTIONABLE_ISSUE_LABELS
+ NON_ACTIONABLE_ISSUE_LABELS,
+ EPIC_DECOMPOSED_LABEL
} from './perpetualWork.js';
// A fake child process that emits canned stdout then closes — enough for the
@@ -78,19 +79,43 @@ describe('perpetualWork', () => {
expect(isActionableIssue({ ...base, labels: [{ name: 'needs-input' }] })).toBe(false);
});
- it('rejects an epic by label, by "(epic)" title suffix, or by "[epic]" title prefix', () => {
- expect(isActionableIssue({ ...base, labels: [{ name: 'epic' }] })).toBe(false);
- expect(isActionableIssue({ ...base, title: 'Big rollup (epic)' })).toBe(false);
- // The non-convergence case: an epic titled "[Epic] …" with NO `epic`
- // label kept reading as actionable, so the drain re-spawned a claim agent
- // that always skips it — never parking.
+ it('rejects an epic ONLY once it is decomposed — by label, by "(epic)" title suffix, or by "[epic]" title prefix', () => {
+ const decomposed = { name: EPIC_DECOMPOSED_LABEL };
+ expect(isActionableIssue({ ...base, labels: [{ name: 'epic' }, decomposed] })).toBe(false);
+ expect(isActionableIssue({ ...base, title: 'Big rollup (epic)', labels: [decomposed] })).toBe(false);
+ // An epic titled "[Epic] …" with NO `epic` label is still an epic: the
+ // title convention alone has to reach the decomposed skip, or the drain
+ // re-splits it every tick.
expect(isActionableIssue({
...base,
- labels: [{ name: 'enhancement' }, { name: 'roadmap' }],
+ labels: [{ name: 'enhancement' }, decomposed],
title: '[Epic] Redesign the billing dashboard'
})).toBe(false);
});
+ it('accepts an UNdecomposed epic — decomposing it is the claim agent\'s Phase 1b work', () => {
+ expect(isActionableIssue({ ...base, labels: [{ name: 'epic' }] })).toBe(true);
+ expect(isActionableIssue({ ...base, title: 'Big rollup (epic)' })).toBe(true);
+ expect(isActionableIssue({
+ ...base,
+ labels: [{ name: 'enhancement' }],
+ title: '[Epic] Redesign the billing dashboard'
+ })).toBe(true);
+ });
+
+ it('still rejects an undecomposed epic that carries a blocking label', () => {
+ expect(isActionableIssue({ ...base, labels: [{ name: 'epic' }, { name: 'blocked' }] })).toBe(false);
+ expect(isActionableIssue(
+ { ...base, labels: [{ name: 'epic' }] },
+ new Set(),
+ new Set(['epic'])
+ )).toBe(false);
+ });
+
+ it('does not let the decomposed label block an ordinary (non-epic) issue', () => {
+ expect(isActionableIssue({ ...base, labels: [{ name: EPIC_DECOMPOSED_LABEL }] })).toBe(true);
+ });
+
it('accepts a plan-labelled issue (plan is the claimable queue, not a skip)', () => {
expect(isActionableIssue({ ...base, labels: [{ name: 'plan' }] })).toBe(true);
});
@@ -227,14 +252,32 @@ describe('perpetualWork', () => {
]);
});
- it('converges (0 actionable) on a queue whose only unblocked issue is a "[Epic]"-prefixed one with no epic label', async () => {
- // Regression for the perpetual-swarm churn: every open issue is either
- // needs-input/blocked OR a "[Epic] …" umbrella with no `epic` label. The
- // claim agent skips the epic; the detector MUST too, or the drain
- // re-spawns a no-op agent every tick and never parks.
+ it('reports the "[Epic]"-prefixed issue as actionable while it is still undecomposed', async () => {
+ // The queue holds nothing but needs-input/blocked issues plus one "[Epic]
+ // …" umbrella with no `epic` label. Parking here is what left epics to rot
+ // and reported an empty queue: decomposing that epic IS work, so the
+ // detector must dispatch a claim agent (which runs Phase 1b) for it.
+ routeSpawn({
+ 'gh issue': { stdout: JSON.stringify([
+ { number: 1, title: '[Epic] Redesign the billing dashboard', assignees: [], labels: [{ name: 'enhancement' }] },
+ { number: 2, title: 'Add a dark-mode toggle', assignees: [], labels: [{ name: 'needs-input' }] },
+ { number: 3, title: 'Document the export API', assignees: [], labels: [{ name: 'blocked' }] }
+ ]) },
+ 'git branch': { stdout: 'main\n' },
+ 'gh pr': { stdout: '' }
+ });
+ const out = await detectGithubIssues(app, { issueAuthorFilter: 'any' });
+ expect(out).toMatchObject({ actionable: true, count: 1, reason: 'actionable-issues', sample: [1] });
+ expect(out.filteredCount).toBe(2);
+ });
+
+ it('converges (0 actionable) once that epic carries the decomposed label', async () => {
+ // The convergence marker: the claim agent stamps `decomposed` on an epic
+ // after filing its slices, so the drain stops re-picking the parent and
+ // works the children instead. Without it the drain would re-split forever.
routeSpawn({
'gh issue': { stdout: JSON.stringify([
- { number: 1, title: '[Epic] Redesign the billing dashboard', assignees: [], labels: [{ name: 'enhancement' }, { name: 'roadmap' }] },
+ { number: 1, title: '[Epic] Redesign the billing dashboard', assignees: [], labels: [{ name: 'enhancement' }, { name: EPIC_DECOMPOSED_LABEL }] },
{ number: 2, title: 'Add a dark-mode toggle', assignees: [], labels: [{ name: 'needs-input' }] },
{ number: 3, title: 'Document the export API', assignees: [], labels: [{ name: 'needs-input' }] },
{ number: 4, title: 'Record the onboarding walkthrough', assignees: [], labels: [{ name: 'needs-input' }] },
diff --git a/server/services/taskPromptDefaults.test.js b/server/services/taskPromptDefaults.test.js
index 20380a66bc..c17008eb80 100644
--- a/server/services/taskPromptDefaults.test.js
+++ b/server/services/taskPromptDefaults.test.js
@@ -9,6 +9,7 @@ import {
PREVIOUS_DEFAULT_PROMPTS,
} from './taskPromptDefaults.js';
import { hashPromptBody, buildPromptIntegritySnapshot } from './taskPromptDefaults/integrityHash.js';
+import { EPIC_DECOMPOSED_LABEL } from './perpetualWork.js';
// Hash snapshot of every exported prompt body and version. This pins the
// cross-install prompt-upgrade contract (see AGENTS.md "Distribution model"):
@@ -616,8 +617,10 @@ describe('taskPromptDefaults integrity snapshot', () => {
const github = DEFAULT_TASK_PROMPTS['claim-issue'];
const gitlab = DEFAULT_TASK_PROMPTS['claim-issue-gitlab'];
- expect(PROMPT_VERSIONS['claim-issue']).toBe(20);
- expect(PROMPT_VERSIONS['claim-issue-gitlab']).toBe(18);
+ // Floors, not equalities: this pins that the assignee-retry revision shipped
+ // WITH its version bump, and later revisions keep bumping past it.
+ expect(PROMPT_VERSIONS['claim-issue']).toBeGreaterThanOrEqual(20);
+ expect(PROMPT_VERSIONS['claim-issue-gitlab']).toBeGreaterThanOrEqual(18);
expect(github).toContain('gh api --hostname "$GH_HOST" user -q .login');
expect(github).toContain('git remote get-url origin');
expect(github).toContain('if [ "$GH_HOST" = "ssh.github.com" ]');
@@ -632,6 +635,43 @@ describe('taskPromptDefaults integrity snapshot', () => {
expect(PREVIOUS_DEFAULT_PROMPTS['claim-issue'].some((prompt) => prompt.includes('It has NO assignees'))).toBe(true);
expect(PREVIOUS_DEFAULT_PROMPTS['claim-issue-gitlab'].some((prompt) => prompt.includes('It has NO assignees'))).toBe(true);
});
+
+ // Epic decomposition. Every claim flow used to skip an epic outright ("leave
+ // it for a human to split"), so a tracker whose remaining work was all epics
+ // ended each run with nothing done and reported an empty queue. Phase 1b makes
+ // splitting the epic the work: file per-slice children, stamp the parent
+ // `decomposed`, claim the first slice. The marker label is the convergence
+ // signal perpetualWork.js#isActionableIssue reads, so the live agent and the
+ // drain agree on when an epic stops being claimable.
+ it('claim flows decompose an undecomposed epic instead of skipping it, preserving the outgoing defaults', () => {
+ const keys = ['claim-issue', 'claim-issue-gitlab', 'claim-issue-jira'];
+ const floors = { 'claim-issue': 21, 'claim-issue-gitlab': 19, 'claim-issue-jira': 14 };
+
+ for (const key of keys) {
+ const current = DEFAULT_TASK_PROMPTS[key];
+ expect(PROMPT_VERSIONS[key]).toBeGreaterThanOrEqual(floors[key]);
+ expect(current).toContain('Phase 1b');
+ // The literal the prompt stamps must be the label the detector reads.
+ expect(current).toContain(EPIC_DECOMPOSED_LABEL);
+ expect(current).not.toContain('Leave epics for a human to split');
+ expect(current).not.toContain("don't claim it wholesale here");
+
+ // The outgoing body stays recognizable so an install storing it auto-upgrades
+ // rather than being pinned to the skip-the-epic flow forever. One entry per
+ // shipped version, in ship order, is what makes .at(-1) the outgoing one.
+ const previous = PREVIOUS_DEFAULT_PROMPTS[key];
+ expect(previous).toHaveLength(PROMPT_VERSIONS[key] - 1);
+ expect(previous.at(-1)).not.toBe(current);
+ expect(previous.at(-1)).not.toContain('Phase 1b');
+ }
+
+ // A slice references its parent without closing it, and the parent keeps the
+ // checklist a later claim follows to the next available child.
+ expect(DEFAULT_TASK_PROMPTS['claim-issue']).toContain('Part of #${EPIC}');
+ expect(DEFAULT_TASK_PROMPTS['claim-issue']).toContain('## Decomposed into');
+ expect(DEFAULT_TASK_PROMPTS['claim-issue-jira']).toContain('"epicKey": "<EPIC>"');
+ });
+
// #4685: `glab issue list -F json` is accepted, IGNORED, and answers with the
// human table at exit 0 (`-F` is `--output-format` there, a different flag from
// `--output`), and `glab mr list --state <x>` does not exist at all. The tree
@@ -660,9 +700,10 @@ describe('taskPromptDefaults integrity snapshot', () => {
(prompt) => prompt.includes('glab issue list --per-page 100 -F json') && prompt.includes('{issueExcludeLabels}'),
);
expect(withBoth).toHaveLength(1);
- // …and it was appended after every body that predates v15, so it sits in the
- // newest third of the list even once later revisions append behind it.
- expect(previous.indexOf(withBoth[0])).toBeGreaterThan(previous.length - 4);
+ // …at the position its version number implies. PREVIOUS_DEFAULT_PROMPTS holds
+ // exactly one entry per shipped version in ship order, so the v15 body lives at
+ // index 14 forever — later revisions append behind it and cannot move it.
+ expect(previous.indexOf(withBoth[0])).toBe(14);
expect(withBoth[0]).not.toBe(current);
});
diff --git a/server/services/taskPromptDefaults/integrity.snapshot.json b/server/services/taskPromptDefaults/integrity.snapshot.json
index d01279fdb7..34a5b66c7a 100644
--- a/server/services/taskPromptDefaults/integrity.snapshot.json
+++ b/server/services/taskPromptDefaults/integrity.snapshot.json
@@ -16,9 +16,9 @@
"feature-ideas": "d3282f16da29efe2d53595b3b34778bc",
"plan-feature": "b20980c8eda2256060d09d4bca397244",
"plan-task": "b85fe92999aa4ee4a8910320457c4242",
- "claim-issue": "6a9bebb3f31b7c1b0a0728def0fe5b3c",
- "claim-issue-gitlab": "1f9ec476dce71d04e588d17e72cd46c9",
- "claim-issue-jira": "c66170bfcdee911f03e60261c4f503db",
+ "claim-issue": "e54b568d0db816457ad00c9aba330d49",
+ "claim-issue-gitlab": "37a6aea663c4b52b6d33368467bec60d",
+ "claim-issue-jira": "c7548b7ae22fec055d64ec6a2ebbd32d",
"code-reviewer-review": "27ded42013f28e7d327d8f1cc624aac1",
"code-reviewer-implement": "2e10cac7c1e1cd021d06bfddb5c1eaf2",
"error-handling": "9afba2e99b90a8d5771c75e7f0615d96",
@@ -42,9 +42,9 @@
"do-replan": 2,
"feature-ideas": 10,
"plan-task": 18,
- "claim-issue": 20,
- "claim-issue-gitlab": 18,
- "claim-issue-jira": 13,
+ "claim-issue": 21,
+ "claim-issue-gitlab": 19,
+ "claim-issue-jira": 14,
"pr-reviewer": 3,
"code-reviewer-a": 1,
"code-reviewer-b": 1,
@@ -122,7 +122,8 @@
"927766326e492e4c9c2566534f465512",
"364ecf5feb38ec1f7ada50a7bcbf3199",
"52fd3506aad0b283be7234b608cf31ca",
- "9d782972b20d6b721eb44d0673315cad"
+ "9d782972b20d6b721eb44d0673315cad",
+ "c66170bfcdee911f03e60261c4f503db"
],
"claim-issue-gitlab": [
"fae92c45c89c65455930b4b06a1b88c4",
@@ -141,7 +142,8 @@
"7ff928b2560ed6bb1a96dbbc80142ed9",
"eed428fc96a8a58ee94d38e6e4896932",
"ed2c2c9c8cd6297340b3a92666cb2c5a",
- "348ed6348b90dcc6eead03e06df049e9"
+ "348ed6348b90dcc6eead03e06df049e9",
+ "1f9ec476dce71d04e588d17e72cd46c9"
],
"claim-issue": [
"37949d1b1fa8d461a15658f8f4192d97",
@@ -162,7 +164,8 @@
"5bcaf3230a7a46ee039404943feab187",
"542ce3673abbdee93e895f9df660aaf7",
"a91b3df45864cf1aeaea7b326a7717ae",
- "a6f069d7276c9f31fdca3b50666324e2"
+ "a6f069d7276c9f31fdca3b50666324e2",
+ "6a9bebb3f31b7c1b0a0728def0fe5b3c"
],
"security": [
"d0f54c1fbe62d067b1a23ee0a9f3528c"
diff --git a/server/services/taskPromptDefaults/previousDefaults.js b/server/services/taskPromptDefaults/previousDefaults.js
index b3de189732..d6f7d2fe7f 100644
--- a/server/services/taskPromptDefaults/previousDefaults.js
+++ b/server/services/taskPromptDefaults/previousDefaults.js
@@ -11028,3 +11028,420 @@ if (
throw new Error('plan-task v17 history could not be derived from v16');
}
PREVIOUS_DEFAULT_PROMPTS['plan-task'].push(planTaskV17);
+
+// The claim-flow bodies shipped BEFORE epic decomposition (claim-issue v20,
+// claim-issue-gitlab v18, claim-issue-jira v13). In those, Phase 1 skipped every
+// epic outright, so a queue holding only epics ended the run with nothing done.
+// Preserved verbatim so an install still storing one auto-upgrades to the
+// decomposing body instead of being flagged promptCustomized.
+//
+// The host-probe snippet is inlined here rather than imported from prompts.js: a
+// preserved historical body must be frozen, and sharing the live const would let
+// a future edit there rewrite this shipped text.
+const GITHUB_HOST_SETUP = `GH_HOST="$(git remote get-url origin 2>/dev/null | sed -E -e 's#^[^:]+://([^@/]+@)?([^/:]+)(:[0-9]+)?/.*#\\2#' -e 's#^([^@]+@)?([^:]+):.*#\\2#')"
+if [ "$GH_HOST" = "ssh.github.com" ]; then GH_HOST="github.com"; fi`;
+
+PREVIOUS_DEFAULT_PROMPTS['claim-issue'].push(`[Claim Issue: {appName}] Claim and ship the next open GitHub issue
+
+Pick the next available unclaimed open GitHub issue, **create your own worktree at \`claim/issue-<num>\`**, implement the fix, ship a PR that closes the issue, and clean up. This is the \`/claim --issues\` flow — same in-flight scan, same branch naming, same no-local-merge cleanup, but the work source is the repo's GitHub issue tracker instead of PLAN.md. **YOU pick the issue in Phase 1 — the scheduler does not reserve one for you.** Picking at execution time and immediately claiming (worktree + assignee + label) **narrows** the window for two concurrent runs to collide on the same issue — it does NOT eliminate it. Do NOT modify files in the source repo directly; ALL editing happens inside the worktree you create.
+
+{issueAuthorFilter}
+
+**How claiming works.** An issue is "in flight" when its number appears as the issue-position segment in either a \`claim/issue-<num>\` ref (the human/TUI pattern) or a \`cos/<task>/issue-<num>/<agent>\` ref (the CoS sub-agent pattern) across local branches, remote branches, or open PR head refs — OR the issue is assigned to another account OR carries an \`in-progress\` label. An issue already assigned to the authenticated account remains eligible for a retry. The \`claim/issue-<num>\` branch + the assignee/\`in-progress\` markers you set ARE the claim, visible to every other agent (including parallel machines) and to the human running \`/claim --issues\` in a TUI.
+
+## Phase 1 — Pick the target issue
+
+Run steps 1–5 in order.
+
+1. cd into the repo root ({repoPath}) and confirm GitHub is the forge: \`gh repo view --json nameWithOwner -q .nameWithOwner\`. If \`gh\` is not authenticated or the remote is not GitHub, exit cleanly — this task only works against GitHub issue trackers.
+2. List candidate open issues **oldest-first**, honoring the author filter described above. \`gh issue list\` defaults to newest-first, so order on the SERVER with \`--search "sort:created-asc"\` — a client-side \`jq\` sort would only reorder the already-truncated newest page, dropping the true oldest issues on repos with more than \`--limit\` open issues:
+ \`\`\`bash
+ git fetch --prune 2>/dev/null
+ # Author filter (see the block above). Pass --author as a QUOTED single token —
+ # do NOT pack flag+value into one variable: a bare \`$VAR\` holding "--author x"
+ # is a single argv token in zsh (no word-splitting) and gh rejects it.
+ # Owner-only mode (default): resolve the owner, then add --author "$OWNER"
+ # --limit 500 (not 100): the blocking-label filter below runs on this
+ # fetched page, so a small cap risks missing eligible work further down
+ # a busy queue when the first page is full of excluded/in-flight issues.
+ # Keep an issue assigned to this authenticated account eligible for retry;
+ # if this lookup fails, leave ME empty and skip all assigned issues.
+ ${GITHUB_HOST_SETUP}
+ ME="$(gh api --hostname "$GH_HOST" user -q .login 2>/dev/null || true)"
+ OWNER="$(gh repo view --json owner -q .owner.login)"
+ gh issue list --state open --author "$OWNER" --search "sort:created-asc" --json number,title,author,assignees,labels,createdAt --limit 500
+ # Any-author mode: run the SAME command WITHOUT the --author "$OWNER" flag.
+ \`\`\`
+3. Build the in-flight set. Collect every branch/PR ref:
+ \`\`\`bash
+ git branch -a --no-color --format='%(refname:short)'
+ gh pr list --state open --json headRefName -q '.[].headRefName' 2>/dev/null
+ \`\`\`
+ For each ref (after stripping any leading \`origin/\` / \`upstream/\` prefix), extract the issue number **only when the ref matches** \`claim/issue-<num>\` (number after \`claim/issue-\`) or \`cos/<task>/issue-<num>/<agent>\` (the \`issue-<num>\` third segment). Do NOT flag an issue just because its bare number appears elsewhere in a ref.
+4. **Pick the target issue:** walk the candidate list oldest-first and pick the FIRST issue where ALL of the following are true:
+ - Its number is NOT in the in-flight set.
+ - It has no assignees, or at least one assignee's login matches \`$ME\` (an issue assigned only to another account is already claimed). If \`$ME\` is empty, skip every assigned issue.
+ - It does NOT carry any of these blocking labels: {issueExcludeLabels}.
+ - It is NOT a tracking/umbrella **epic** — recognized by an \`epic\` label, a title ending in "(epic)", OR a title beginning with an \`[epic]\` bracket or \`Epic:\` tag (e.g. "[Epic] …" / "Epic: …", case-insensitive). An epic needs per-slice partial-ship (each slice its own PR, \`Refs\` not \`Closes\`), so leave it for a human or \`/claim --issues\` to split — don't claim it wholesale here. **The bare \`plan\` label is NOT a skip signal.** \`do-replan --issues\` (and \`/do:replan --issues\`) labels EVERY migrated backlog item \`plan\` — atomic bug-fixes included — so \`plan\` marks the *claimable* queue exactly as \`/do:next --issues\` treats it (it is that flow's required candidate label). Skipping all \`plan\` issues would discard the entire actionable backlog and falsely report an empty queue.
+5. **If no eligible issue exists**, exit cleanly — an empty actionable queue is a healthy state, not a failure.
+
+Capture the issue number as \`NUM\`, its title, and its full body — you'll reuse them in the PR and the \`Closes #<num>\` trailer.
+
+## Phase 2 — Claim (worktree + markers)
+
+Create the worktree on a branch named \`claim/issue-<num>\`, then set the cross-machine claim markers. Do all editing inside the worktree, NEVER in the source repo's working tree.
+
+\`\`\`bash
+NUM=<picked-number>
+WORKTREE="{worktreesRoot}/claim-issue-\${NUM}"
+mkdir -p {worktreesRoot}
+git fetch origin main
+git worktree add --no-track -b "claim/issue-\${NUM}" "\${WORKTREE}" origin/main
+# Cross-machine claim markers (best-effort — do not abort the run if these fail):
+gh issue edit "\${NUM}" --add-assignee @me 2>/dev/null
+gh issue edit "\${NUM}" --add-label in-progress 2>/dev/null
+cd "\${WORKTREE}"
+\`\`\`
+
+(If the repo's default branch is not \`main\`, detect it with \`gh repo view --json defaultBranchRef -q .defaultBranchRef.name\` and substitute it for \`main\` above.)
+
+**If \`git worktree add\` fails because the \`claim/issue-<num>\` branch already exists** (a concurrent run won the race, or a remote claim branch is now visible), do NOT force or reuse it — that branch IS another run's claim. Treat the issue as in-flight, return to Phase 1, and pick the next eligible issue; if nothing else is eligible, exit cleanly. Stash \`WORKTREE\` — you'll need it for Phase 7 cleanup.
+
+## Phase 3 — Verify still valid
+
+Read the full issue (\`gh issue view "\${NUM}" --comments\`) before writing any code. **Every exit from this phase must leave a CONVERGING outcome on the issue — closed, or labeled \`needs-input\`.** Phase 1 step 4 skips both, so an autonomous drain stops re-picking the item. Releasing an issue OPEN and unlabeled is NOT an exit: the work detector still reports it actionable, so the next pass re-picks it and burns another no-op agent — every pass, forever.
+
+- **Already fixed, superseded, or closed-then-reopened-for-tracking** — a comment says so, or the change it asks for is already on the default branch. **Close it:** post a comment naming the PR/commit (or issue) that already delivered it (\`gh issue comment "\${NUM}" --body "..."\`), then \`gh issue close "\${NUM}" --reason completed\` (use \`--reason "not planned"\` when it was superseded rather than delivered) and clear the markers (\`gh issue edit "\${NUM}" --remove-assignee @me --remove-label in-progress\`). Remove the worktree and return to Phase 1. **Evidence gate: if you cannot name the PR, commit, or issue that delivered it, this branch does NOT apply** — closing on a hunch destroys live work, which is far worse than one wasted pass. Treat the issue as real work and continue to Phase 4.
+- **Stale reference** — the request names a function, file, or component that no longer exists (\`grep -rn\` the named identifiers; if they're gone, the issue is stale). Post a comment naming what you searched for and what you found instead, **tag it \`needs-input\`** (\`gh issue edit "\${NUM}" --add-label needs-input\`), release the claim markers (\`gh issue edit "\${NUM}" --remove-assignee @me --remove-label in-progress\`), remove the worktree, and return to Phase 1. Re-scoping a stale issue against today's code is a human call — and the label is what keeps the drain off it in the meantime.
+
+(A too-large scope is NOT in this list — it has its own park path below.)
+
+**A genuinely too-large issue needs parking so the drain converges.** If the work is bigger than one coherent claim — it would touch files far outside the issue's scope (>5 unrelated files) — and you can't carve a valuable standalone slice to partial-ship via Phase 6's \`Refs\` path, post a brief comment naming the split you'd suggest, **tag it \`needs-input\`** (\`gh issue edit "\${NUM}" --add-label needs-input\`), release the claim markers (\`gh issue edit "\${NUM}" --remove-assignee @me --remove-label in-progress\`), remove the worktree, and exit — splitting an omnibus issue is a human call, and parking it is what stops a perpetual drain from re-picking the same un-shippable issue every pass (Phase 1 step 4 skips \`needs-input\`).
+
+**Ambiguity is NOT a release trigger — decide, don't defer.** If the issue is merely open to more than one reasonable reading, or leaves a design choice unstated, do NOT bail to \`needs-input\`. Pick the most reasonable interpretation, record the approach you chose in a brief issue comment (\`gh issue comment "\${NUM}" --body "..."\`) so the decision is on the record, and implement it. The user would rather iterate on top of a shipped best-guess than have the issue parked waiting on a decision they didn't ask to make. Reserve \`needs-input\` — which pulls the issue out of the autonomous queue — for the narrow cases where proceeding would be **destructive or irreversible**, or genuinely requires the human: specific hardware/credentials you don't have, or a judgment only they can make. In those cases only, post the explaining comment, **tag it \`needs-input\`** (\`gh issue edit "\${NUM}" --add-label needs-input\`), release the claim markers (\`gh issue edit "\${NUM}" --remove-assignee @me --remove-label in-progress\`), remove the worktree, and exit cleanly. **That label is what lets an autonomous drain converge** — Phase 1 step 4 skips \`needs-input\` issues. Never leave a half-claimed issue.
+
+## Phase 4 — Implement
+
+Write the code, tests, and any docs the issue requires. Follow the repo conventions in AGENTS.md / CLAUDE.md (no try/catch in route handlers, functional programming, Zod validation, Tailwind tokens, reactive UI updates). Run the relevant test suite as you go.
+
+**Roll discovered backbone work INTO this PR** — small supporting helpers, refactors, and tests that the fix depends on belong here, not a follow-up. Only defer genuinely-large adjacent work; when you do, file a NEW issue (\`gh issue create\`) tagged \`plan\` that references this one (\`Related to #<num>\`) rather than appending to PLAN.md. Choose independent dispatch hints (\`model:light|medium|heavy\`, \`effort:low|medium|high|xhigh|max\`) and contributor labels (\`good first issue\`, \`help wanted\`) only when justified; omit an axis rather than guessing; create each missing label immediately before applying it; use repeated \`--label\` flags; do not prefix the title with \`[category]\` / \`[model:…]\`.
+
+Commit with a conventional message referencing the issue so the trail is grep-able:
+
+\`\`\`
+<type>: <one-line description> (#<num>)
+\`\`\`
+
+## Phase 5 — Review locally (BEFORE any PR exists)
+
+**Every reviewer that can read the working tree runs HERE, while there is still no PR.** Open the PR only once the branch is already review-clean: the PR then carries the finished diff, and the only things left to satisfy are CI and the reviewers that genuinely cannot start until a PR is open.
+
+The configured reviewers for this task, in order, are \`{reviewers}\`. Split that list in two, preserving its order:
+
+- **LOCAL reviewers — every token that is NOT an \`@<login>\`.** \`claude\` / \`codex\` / \`antigravity\` (CLI binary: \`agy\`) / \`grok\` / \`cursor\` invoke a local-CLI critique; \`lmstudio\` / \`ollama\` use the appended Local Reviewer Procedure. They read this branch's own diff and need no PR — run them in THIS phase.
+- **PR-SIDE reviewers — every \`@<login>\` token**, plus any review bot the repo requests automatically when a PR opens. They review cloud-side and cannot start before the PR exists — they run in Phase 6.
+
+1. **Write the changelog entry now, not after the reviewers run** — every commit the reviewers are about to read must already be on the branch, or the PR carries work nobody reviewed. If the repo maintains a changelog, record a one-line entry **following the convention that repo documents** — read its \`AGENTS.md\` (or \`CLAUDE.md\`) and changelog README (e.g. \`.changelog/README.md\`) first. Some repos collect per-branch fragments in a directory (e.g. \`.changelog/next/\`) via a helper script rather than appending to one shared file, precisely so parallel agents don't conflict on every merge; use that flow when it's documented. Fall back to appending to the unreleased section (\`.changelog/NEXT.md\`, or \`## Unreleased\` in \`CHANGELOG.md\`) in the repo's existing prose style only when no convention is documented. If the repo has no changelog, skip this — the PR + commit history is the record.
+2. **Self-review your diff for reuse, quality, and efficiency** (DRY, dead code, naming, simpler equivalents, missed edge cases) and fix the findings in the same diff, before any reviewer runs. Claude Code runs this as the three-agent \`/simplify\` pass; on other CLIs, do the equivalent review by hand.
+3. **Run each LOCAL reviewer in the listed order against the BRANCH diff, not a PR diff.** No PR exists yet, so \`gh pr diff\` has nothing to read — use the CLI's own base-diff mode or \`git diff origin/main...HEAD\` (substitute the repo's default branch when it isn't \`main\`). Apply the findings, run the tests, and commit the fixes — capped at 3 rounds per reviewer — then advance to the next reviewer. A missing CLI, timeout, transport failure, malformed response, or empty response is UNSATISFIED, not clean. Do NOT substitute your own self-review, and do NOT open a PR on the strength of it.
+4. **If the branch cannot be brought to a shippable state here, do NOT open a PR** — that is a local reviewer still unsatisfied after 3 rounds, or fixes that leave the build/tests red. Comment on the ISSUE naming the reviewer and the failure (\`gh issue comment "\${NUM}" --body "..."\`), leave the assignee and the \`in-progress\` label in place, remove ONLY the worktree (\`cd {repoPath} && git worktree remove "\${WORKTREE}"\`), and stop. The branch stays for a human to pick up cold. Do NOT run Phase 7.
+
+## Phase 6 — Open the PR, satisfy PR-side review + CI, and merge
+
+Every local reviewer's fixes are already committed, so the PR opens against finished work. This flow ships GitHub issues — it does NOT touch PLAN.md. The audit trail is the merged PR + \`git log\`.
+
+1. Push the branch: \`git push -u origin "claim/issue-\${NUM}"\`. Then confirm \`git log --oneline @{u}..HEAD\` is empty — if it isn't, a Phase 5 review fix never left the machine and the PR would be opened against a stale diff; push again before continuing.
+2. Open the PR with \`gh pr create\`. Summarize what shipped + a short test plan. **Choose the issue trailer deliberately:** if this PR FULLY satisfies the issue's scope, the body MUST contain \`Closes #\${NUM}\` so the merge auto-closes it. If you deliberately shipped only PART of the issue (a valuable slice, with real scope still remaining), use \`Refs #\${NUM}\` instead (NOT \`Closes\`) and add a \`## Remaining\` section listing what's left — Phase 7 reconciles the issue so it is never stranded.
+3. **Satisfy the PR-SIDE reviewers.** For each \`@<login>\` from the Phase 5 split, request the review now (\`gh pr edit <pr-number> --add-reviewer <login>\`, drop the \`@\`), poll every 5–15s for it, and address the findings — push fixes, capped at 3 rounds per reviewer. Their approval gates the merge. If the repo auto-requests a review bot when the PR opens, wait that round out and address it the same way. With no \`@<login>\` configured and no bot review appearing, this step is a no-op.
+
+ **Review-stuck cleanup** (a PR-side reviewer still unsatisfied after 3 rounds): post one summarizing PR comment (\`gh pr comment\`), then run the worktree-only cleanup (\`cd {repoPath} && git worktree remove "\${WORKTREE}"\`). Leave the local branch, the open PR, the assignee, and the \`in-progress\` label in place so the human picks up cold. Do NOT run Phase 7.
+4. **Let required CI finish and go green** — \`gh pr checks <pr-number> --required --watch --fail-fast\` (scope the wait to REQUIRED checks so an optional job can't stall a merge branch protection would allow). A red required check is not merge-eligible: fix it and re-push (same 3-round cap), or, if it stays red, stop exactly as the review-stuck cleanup above does.
+5. **Merge immediately via \`gh pr merge\`** — NEVER a local \`git merge\` and NEVER \`--auto\`, which can return successfully while leaving the PR queued and OPEN. Prefer a true merge commit, with squash/rebase fallbacks for repositories that disallow it:
+ \`\`\`bash
+ PR_URL=$(gh pr view --json url -q .url) # no number: resolves the PR from the checked-out branch
+ gh pr merge "$PR_URL" --merge --delete-branch || {
+ [ "$(gh pr view "$PR_URL" --json state -q .state)" = "MERGED" ] || \
+ gh pr merge "$PR_URL" --squash --delete-branch || \
+ gh pr merge "$PR_URL" --rebase --delete-branch
+ }
+ STATE=$(gh pr view "$PR_URL" --json state -q .state)
+ [ "$STATE" = "MERGED" ] || { echo "Expected MERGED, got $STATE" >&2; exit 1; }
+ \`\`\`
+ The exact comparison MUST succeed. \`OPEN\` means CI, review, or branch protection still blocks the merge; investigate, fix, and retry. \`CLOSED\` is also not success. Do not enter Phase 7 until remote GitHub state is exactly \`MERGED\`.
+
+## Phase 7 — Clean up (post-merge ONLY)
+
+This phase runs only after the PR merged via Phase 6. From the **source repo** (cd back to {repoPath} first):
+
+\`\`\`bash
+cd {repoPath}
+git worktree remove "\${WORKTREE}"
+git branch -d "claim/issue-\${NUM}"
+\`\`\`
+
+If \`git branch -d\` refuses, fetch the default branch and re-check the PR's remote \`MERGED\` state. Retry \`-d\` only when Git can prove the branch is integrated; otherwise leave the local branch for the reconciliation task. Never force-delete with \`-D\`.
+
+**Reconcile the issue — did this PR FULLY satisfy its scope?**
+- **Yes (full)** — the \`Closes #\${NUM}\` trailer already auto-closed it; if it's somehow still open, close it (\`gh issue close "\${NUM}"\`) and remove the label (\`gh issue edit "\${NUM}" --remove-label in-progress\`).
+- **No — the remainder is a clean, separable chunk** — close THIS issue with a summarizing comment (shipped ✓ / moved to #NEW), remove \`in-progress\`, and file ONE tightly-scoped follow-up for the remainder: \`gh issue create --title "…" --label plan [--label model:<tier>] [--label effort:<level>] [--label "good first issue"] [--label "help wanted"] --body "…\\n\\nRefs #\${NUM}"\` (carry over any \`area:*\` labels the issue had; choose the optional labels independently and only when justified — a leftover mechanical sweep is not a good first issue).
+- **No — the remainder is a continuation of the same scope** — keep the issue OPEN, post a \`Done ✓ / Remaining ▢\` comment, and release the claim so the queue re-picks it. Remove the label and every current assignee, not only the authenticated account:
+ \`ASSIGNEES="$(gh issue view "\${NUM}" --json assignees -q '[.assignees[].login] | join(",")')"\`
+ \`gh issue edit "\${NUM}" --remove-label in-progress --remove-assignee "\${ASSIGNEES:-@me}"\`.
+
+NEVER leave the issue OPEN with \`in-progress\` still on it — that strands it as a zombie (the claim queue skips \`in-progress\`, so the remaining scope is never re-picked). **Do NOT \`git pull\`** from inside this phase — the work is already integrated on GitHub via \`gh pr merge\`; leave the user's working tree alone.`);
+
+PREVIOUS_DEFAULT_PROMPTS['claim-issue-gitlab'].push(`[Claim Issue: {appName}] Claim and ship the next open GitLab issue
+
+Pick the next available unclaimed open GitLab issue, **create your own worktree at \`claim/issue-<num>\`**, implement the fix, ship a merge request (MR) that closes the issue, and clean up. This is the \`/claim --issues\` flow for GitLab — same in-flight scan, same branch naming, same no-local-merge cleanup, but the work source is the repo's **GitLab** issue tracker and the forge CLI is \`glab\` (not \`gh\`). **YOU pick the issue in Phase 1 — the scheduler does not reserve one for you.** Picking at execution time and immediately claiming (worktree + assignee + label) **narrows** the window for two concurrent runs to collide on the same issue — it does NOT eliminate it. Do NOT modify files in the source repo directly; ALL editing happens inside the worktree you create.
+
+{issueAuthorFilter}
+
+**How claiming works.** An issue is "in flight" when its number appears as the issue-position segment in either a \`claim/issue-<num>\` ref (the human/TUI pattern) or a \`cos/<task>/issue-<num>/<agent>\` ref (the CoS sub-agent pattern) across local branches, remote branches, or open MR source-branch refs — OR the issue is assigned to another account OR carries an \`in-progress\` label. An issue already assigned to the authenticated account remains eligible for a retry. The \`claim/issue-<num>\` branch + the assignee/\`in-progress\` markers you set ARE the claim, visible to every other agent (including parallel machines).
+
+## Phase 1 — Pick the target issue
+
+Run steps 1–5 in order.
+
+1. cd into the repo root ({repoPath}) and confirm GitLab is the forge and \`glab\` is authenticated: \`glab auth status\` and \`glab repo view\`. If \`glab\` is not authenticated or the remote is not GitLab, exit cleanly — this task only works against GitLab issue trackers.
+2. List candidate open issues, honoring the author filter described above. Fetch a JSON page and order **oldest-first** (GitLab returns newest-first by default; sort client-side by \`created_at\` since the page is bounded):
+ \`\`\`bash
+ git fetch --prune 2>/dev/null
+ # Owner-only mode (default): add --author <owner> (resolve <owner> from the project namespace).
+ # Keep an issue assigned to this authenticated account eligible for retry;
+ # if this lookup fails, leave ME empty and skip all assigned issues.
+ ME="$(glab api user -q .username 2>/dev/null || true)"
+ glab issue list --per-page 100 --output json
+ # Any-author mode: run the SAME command WITHOUT --author.
+ \`\`\`
+3. Build the in-flight set. Collect every branch/MR source ref:
+ \`\`\`bash
+ git branch -a --no-color --format='%(refname:short)'
+ glab mr list --per-page 100 --output json # read each MR's source_branch
+ \`\`\`
+ For each ref (after stripping any leading \`origin/\` prefix), extract the issue number **only when the ref matches** \`claim/issue-<num>\` (number after \`claim/issue-\`) or \`cos/<task>/issue-<num>/<agent>\` (the \`issue-<num>\` third segment). Do NOT flag an issue just because its bare number appears elsewhere in a ref.
+4. **Pick the target issue:** walk the candidate list oldest-first and pick the FIRST issue where ALL of the following are true:
+ - Its number (\`iid\`) is NOT in the in-flight set.
+ - It has no assignees, or at least one assignee's username matches \`$ME\` (an issue assigned only to another account is already claimed). If \`$ME\` is empty, skip every assigned issue.
+ - It does NOT carry any of these blocking labels: {issueExcludeLabels}.
+ - It is NOT a tracking/umbrella **epic** — recognized by an \`epic\` label, a title ending in "(epic)", OR a title beginning with an \`[epic]\` bracket or \`Epic:\` tag (e.g. "[Epic] …" / "Epic: …", case-insensitive). Leave epics for a human to split. **The bare \`plan\` label is NOT a skip signal** — it marks the claimable queue, not a blocker.
+5. **If no eligible issue exists**, exit cleanly — an empty actionable queue is a healthy state, not a failure.
+
+Capture the issue number (GitLab \`iid\`) as \`NUM\`, its title, and its full description — you'll reuse them in the MR and the \`Closes #<num>\` line.
+
+## Phase 2 — Claim (worktree + markers)
+
+Detect the default branch first (forge-agnostic), then create the worktree on \`claim/issue-<num>\` and set the cross-machine claim markers. Do all editing inside the worktree, NEVER in the source repo's working tree.
+
+\`\`\`bash
+NUM=<picked-number>
+DEFAULT_BRANCH="$(git symbolic-ref --short refs/remotes/origin/HEAD 2>/dev/null | sed 's@^origin/@@')"
+DEFAULT_BRANCH="\${DEFAULT_BRANCH:-main}"
+WORKTREE="{worktreesRoot}/claim-issue-\${NUM}"
+mkdir -p {worktreesRoot}
+git fetch origin "\${DEFAULT_BRANCH}"
+git worktree add --no-track -b "claim/issue-\${NUM}" "\${WORKTREE}" "origin/\${DEFAULT_BRANCH}"
+# Cross-machine claim markers (best-effort — do not abort the run if these fail).
+# Resolve your own username first — glab's --assignee wants a username (the
+# \`@me\` gh-ism isn't universally supported), falling back to @me if the lookup fails:
+ME="$(glab api user 2>/dev/null | sed -n 's/.*"username":"\\([^"]*\\)".*/\\1/p')"
+glab issue update "\${NUM}" --assignee "\${ME:-@me}" 2>/dev/null
+glab issue update "\${NUM}" --label in-progress 2>/dev/null
+cd "\${WORKTREE}"
+\`\`\`
+
+**If \`git worktree add\` fails because the \`claim/issue-<num>\` branch already exists** (a concurrent run won the race), do NOT force or reuse it — that branch IS another run's claim. Treat the issue as in-flight, return to Phase 1, and pick the next eligible issue; if nothing else is eligible, exit cleanly. Stash \`WORKTREE\` — you'll need it for Phase 7 cleanup.
+
+## Phase 3 — Verify still valid
+
+Read the full issue (\`glab issue view "\${NUM}"\`) before writing any code. **Every exit from this phase must leave a CONVERGING outcome on the issue — closed, or labeled \`needs-input\`.** Phase 1 step 4 skips both, so an autonomous drain stops re-picking the item. Releasing an issue OPEN and unlabeled is NOT an exit: the work detector still reports it actionable, so the next pass re-picks it and burns another no-op agent — every pass, forever.
+
+- **Already fixed, superseded, or closed-then-reopened-for-tracking** — a note says so, or the change it asks for is already on the default branch. **Close it:** post a note naming the MR/commit (or issue) that already delivered it (\`glab issue note "\${NUM}" -m "..."\`), then \`glab issue close "\${NUM}"\` and clear the markers (\`glab issue update "\${NUM}" --unassign --unlabel in-progress\`). Remove the worktree and return to Phase 1. **Evidence gate: if you cannot name the MR, commit, or issue that delivered it, this branch does NOT apply** — closing on a hunch destroys live work, which is far worse than one wasted pass. Treat the issue as real work and continue to Phase 4.
+- **Stale reference** — the request names a function, file, or component that no longer exists (\`grep -rn\` the named identifiers; if they're gone, the issue is stale). Post a note naming what you searched for and what you found instead, **tag it \`needs-input\`** (\`glab issue update "\${NUM}" --label needs-input\`), release the claim markers (\`glab issue update "\${NUM}" --unassign --unlabel in-progress\`), remove the worktree, and return to Phase 1. Re-scoping a stale issue against today's code is a human call — and the label is what keeps the drain off it in the meantime.
+
+(A too-large scope is NOT in this list — it has its own park path below.)
+
+**A genuinely too-large issue needs parking so the drain converges.** If the work is bigger than one coherent claim — it would touch files far outside the issue's scope (>5 unrelated files) — and you can't carve a valuable standalone slice to partial-ship via Phase 6's \`Refs\` path, post a brief note naming the split you'd suggest, **tag it \`needs-input\`** (\`glab issue update "\${NUM}" --label needs-input\`), release the claim markers (\`glab issue update "\${NUM}" --unassign --unlabel in-progress\`), remove the worktree, and exit — splitting an omnibus issue is a human call, and parking it stops a perpetual drain from re-picking the same un-shippable issue every pass (Phase 1 step 4 skips \`needs-input\`).
+
+**Ambiguity is NOT a release trigger — decide, don't defer.** If the issue is merely open to more than one reasonable reading, or leaves a design choice unstated, do NOT bail to \`needs-input\`. Pick the most reasonable interpretation, record the approach you chose in a brief issue note (\`glab issue note "\${NUM}" -m "..."\`) so the decision is on the record, and implement it. The user would rather iterate on top of a shipped best-guess than have the issue parked waiting on a decision they didn't ask to make. Reserve \`needs-input\` — which pulls the issue out of the autonomous queue — for the narrow cases where proceeding would be **destructive or irreversible**, or genuinely requires the human: specific hardware/credentials you don't have, or a judgment only they can make. In those cases only, post the explaining note, **tag it \`needs-input\`** (\`glab issue update "\${NUM}" --label needs-input\`), release the claim markers (\`glab issue update "\${NUM}" --unassign --unlabel in-progress\`), remove the worktree, and exit cleanly. **That label is what lets an autonomous drain converge** — Phase 1 step 4 skips \`needs-input\` issues. Never leave a half-claimed issue.
+
+## Phase 4 — Implement
+
+Write the code, tests, and any docs the issue requires. Follow the repo conventions in AGENTS.md (or CLAUDE.md). Run the relevant test suite as you go.
+
+**Roll discovered backbone work INTO this MR** — small supporting helpers, refactors, and tests that the fix depends on belong here, not a follow-up. Only defer genuinely-large adjacent work; when you do, file a NEW issue (\`glab issue create\`) tagged \`plan\` that references this one (\`Related to #<num>\`). Choose independent dispatch hints (\`model:light|medium|heavy\`, \`effort:low|medium|high|xhigh|max\`) and contributor labels (\`good first issue\`, \`help wanted\`) only when justified; omit an axis rather than guessing; create each missing label immediately before applying it; use repeated \`--label\` flags; do not prefix the title with \`[category]\` / \`[model:…]\`.
+
+Commit with a conventional message referencing the issue:
+
+\`\`\`
+<type>: <one-line description> (#<num>)
+\`\`\`
+
+## Phase 5 — Review locally (BEFORE any MR exists)
+
+**Every reviewer that can read the working tree runs HERE, while there is still no MR.** Open the MR only once the branch is already review-clean: the MR then carries the finished diff, and the only things left to satisfy are CI and the reviewers that genuinely cannot start until an MR is open.
+
+The configured reviewers for this task, in order, are \`{reviewers}\`. Split that list in two, preserving its order:
+
+- **LOCAL reviewers — every token that is NOT an \`@<login>\`.** \`claude\` / \`codex\` / \`antigravity\` (CLI binary: \`agy\`) / \`grok\` / \`cursor\` invoke a local-CLI critique; \`lmstudio\` / \`ollama\` use the appended Local Reviewer Procedure. They read this branch's own diff and need no MR — run them in THIS phase.
+- **MR-SIDE reviewers — every \`@<login>\` token**, plus any review bot the project requests automatically when an MR opens. They review server-side and cannot start before the MR exists — they run in Phase 6.
+
+1. **Write the changelog entry now, not after the reviewers run** — every commit the reviewers are about to read must already be on the branch, or the MR carries work nobody reviewed. If the repo maintains a changelog, record a one-line entry **following the convention that repo documents** — read its \`AGENTS.md\` (or \`CLAUDE.md\`) and changelog README (e.g. \`.changelog/README.md\`) first. Some repos collect per-branch fragments in a directory (e.g. \`.changelog/next/\`) via a helper script rather than appending to one shared file, precisely so parallel agents don't conflict on every merge; use that flow when it's documented. Fall back to appending to the unreleased section (\`.changelog/NEXT.md\`, or \`## Unreleased\` in \`CHANGELOG.md\`) in the repo's existing prose style only when no convention is documented. If the repo has no changelog, skip this.
+2. **Self-review your diff for reuse, quality, and efficiency** (DRY, dead code, naming, simpler equivalents, missed edge cases) and fix the findings in the same diff, before any reviewer runs. Claude Code runs this as the three-agent \`/simplify\` pass; on other CLIs, do the equivalent review by hand.
+3. **Run each LOCAL reviewer in the listed order against the BRANCH diff, not an MR diff.** No MR exists yet, so \`glab mr diff\` has nothing to read — use the CLI's own base-diff mode or \`git diff "origin/\${DEFAULT_BRANCH}...HEAD"\`. Apply the findings, run the tests, and commit the fixes — capped at 3 rounds per reviewer — then advance to the next reviewer. A missing CLI, timeout, transport failure, malformed response, or empty response is UNSATISFIED, not clean. Do NOT substitute your own self-review, and do NOT open an MR on the strength of it.
+4. **If the branch cannot be brought to a shippable state here, do NOT open an MR** — that is a local reviewer still unsatisfied after 3 rounds, or fixes that leave the build/tests red. Post a note on the ISSUE naming the reviewer and the failure (\`glab issue note "\${NUM}" -m "..."\`), leave the assignee and the \`in-progress\` label in place, remove ONLY the worktree (\`cd {repoPath} && git worktree remove "\${WORKTREE}"\`), and stop. The branch stays for a human to pick up cold. Do NOT run Phase 7.
+
+## Phase 6 — Open the merge request, satisfy MR-side review + CI, and merge
+
+Every local reviewer's fixes are already committed, so the MR opens against finished work. This flow ships GitLab issues — it does NOT touch PLAN.md. The audit trail is the merged MR + \`git log\`.
+
+1. Push the branch: \`git push -u origin "claim/issue-\${NUM}"\`. Then confirm \`git log --oneline @{u}..HEAD\` is empty — if it isn't, a Phase 5 review fix never left the machine and the MR would be opened against a stale diff; push again before continuing.
+2. Open the MR with \`glab mr create --fill --source-branch "claim/issue-\${NUM}" --target-branch "\${DEFAULT_BRANCH}" --yes\`. **Choose the issue trailer deliberately:** if this MR FULLY satisfies the issue's scope, the description MUST contain \`Closes #\${NUM}\` so the merge auto-closes it; if you deliberately shipped only PART of the issue (a valuable slice with real scope remaining), use \`Refs #\${NUM}\` instead (NOT \`Closes\`) and add a \`## Remaining\` section listing what's left — Phase 7 reconciles the issue so it is never stranded. Summarize what shipped + a short test plan (pass \`--description\` if \`--fill\` didn't capture it).
+3. **Satisfy the MR-SIDE reviewers.** For each \`@<login>\` from the Phase 5 split, request the review now (resolve \`MR_IID\` from the source branch exactly as step 5 does, then \`glab mr update "\${MR_IID}" --reviewer <login>\`, dropping the \`@\`; if glab rejects the flag, run \`glab mr update --help\` rather than guessing), poll every 5–15s, and address the findings — push fixes, capped at 3 rounds per reviewer. Their approval gates the merge. If the project auto-requests a review bot when the MR opens, wait that round out and address it the same way. With no \`@<login>\` configured and no bot review appearing, this step is a no-op.
+
+ **Review-stuck cleanup** (an MR-side reviewer still unsatisfied after 3 rounds): post one summarizing MR note (\`glab mr note\`), then run the worktree-only cleanup (\`cd {repoPath} && git worktree remove "\${WORKTREE}"\`). Leave the local branch, the open MR, the assignee, and the \`in-progress\` label in place so the human picks up cold. Do NOT run Phase 7.
+4. **Let required CI finish and go green** — inspect the MR's pipeline (\`glab ci status\` on the branch, or \`glab mr view "\${MR_IID}"\`). A red required pipeline is not merge-eligible: fix it and re-push (same 3-round cap), or, if it stays red, stop exactly as the review-stuck cleanup above does.
+5. **Merge immediately via \`glab mr merge\`** — NEVER a local \`git merge\`. \`glab mr merge\` takes the **MR IID**, which is NOT the issue number — resolve it from the source branch first, merge, then verify remote state:
+ \`\`\`bash
+ MR_IID="$(glab mr list --source-branch "claim/issue-\${NUM}" --output json | sed -n 's/.*"iid":\\([0-9]\\{1,\\}\\).*/\\1/p' | head -1)"
+ glab mr merge "\${MR_IID}" --yes --remove-source-branch || {
+ glab mr view "\${MR_IID}" --output json | jq -e 'select((.state | ascii_downcase) == "merged")' >/dev/null || \
+ glab mr merge "\${MR_IID}" --yes --squash --remove-source-branch
+ }
+ glab mr view "\${MR_IID}" --output json | jq -er 'select((.state | ascii_downcase) == "merged") | .state'
+ \`\`\`
+ The verification command must succeed and print a merged state. An opened/closed state or missing value is not success; investigate CI, review, and branch protection, then retry. Do not enter Phase 7 until the forge confirms the MR is merged.
+
+## Phase 7 — Clean up (post-merge ONLY)
+
+This phase runs only after the MR merged via Phase 6. From the **source repo** (cd back to {repoPath} first):
+
+\`\`\`bash
+cd {repoPath}
+git worktree remove "\${WORKTREE}"
+git branch -d "claim/issue-\${NUM}"
+\`\`\`
+
+If \`git branch -d\` refuses, fetch the default branch and re-check the MR's merged state. Retry \`-d\` only when Git proves the branch integrated; otherwise leave it for reconciliation. Never force-delete with \`-D\`.
+
+**Reconcile the issue — did this MR FULLY satisfy its scope?**
+- **Yes (full)** — the \`Closes #\${NUM}\` line already auto-closed it on merge to the default branch; if it's somehow still open, close it (\`glab issue close "\${NUM}"\`) and remove the label (\`glab issue update "\${NUM}" --unlabel in-progress\`).
+- **No — the remainder is a clean, separable chunk** — close THIS issue with a summarizing note (shipped ✓ / moved to #NEW), remove \`in-progress\`, and file ONE tightly-scoped follow-up for the remainder: \`glab issue create --title "…" --label plan [--label model:<tier>] [--label effort:<level>] [--label "good first issue"] [--label "help wanted"] --description "…\\n\\nRefs #\${NUM}"\` (carry over any \`area:*\` labels the issue had; choose the optional labels independently and only when justified — a leftover mechanical sweep is not a good first issue).
++ **No — the remainder is a continuation of the same scope** — keep the issue OPEN, post a \`Done ✓ / Remaining ▢\` note, and release the claim so the queue re-picks it: \`glab issue update "\${NUM}" --unassign --unlabel in-progress\` (\`--unassign\` clears every current assignee).
+
+NEVER leave the issue OPEN with \`in-progress\` still on it — that strands it as a zombie (the claim queue skips \`in-progress\`, so the remaining scope is never re-picked). **Do NOT \`git pull\`** from inside this phase — the work is already integrated on GitLab via \`glab mr merge\`; leave the user's working tree alone.`);
+
+PREVIOUS_DEFAULT_PROMPTS['claim-issue-jira'].push(`[Claim Issue: {appName}] Claim and ship the next ready JIRA ticket
+
+Pick the next ready JIRA ticket assigned to me in the current sprint, move it to **In Progress**, **create your own worktree at \`claim/<KEY>\`**, implement it, open a merge/pull request that references the ticket, move the ticket to **In Review**, and clean up. This is the \`/claim --issues\` flow for JIRA: same self-managed worktree and no-local-merge cleanup, but the work source is the app's **JIRA** project (via the PortOS JIRA API) and the ticket *status* — not an assignee/label — is the claim. **YOU pick the ticket in Phase 1.** Do NOT modify files in the source repo directly; ALL editing happens inside the worktree you create.
+
+All PortOS API calls below are relative to this base URL: ${PORTOS_API_URL}
+
+**How claiming works.** A ticket is "in flight" when (a) a \`claim/<KEY>\` or \`cos/<task>/<KEY>/<agent>\` ref exists across local branches, remote branches, or open MR/PR source refs, OR (b) its JIRA status is anything other than a not-started status (so "In Progress", "In Review", "Done", etc. are already taken). Moving the ticket to **In Progress** + the \`claim/<KEY>\` branch ARE the claim, visible to every other agent and to the human looking at the sprint board.
+
+## Phase 1 — Pick the target ticket
+
+Run steps 1–5 in order.
+
+1. Resolve the app's JIRA config: GET ${PORTOS_API_URL}/api/apps and find the app whose \`id\` is \`{appId}\`. Read \`jira.enabled\`, \`jira.instanceId\`, and \`jira.projectKey\`. If \`jira.enabled\` is not true or either id is missing, exit cleanly — this task only works against JIRA-configured apps.
+2. Fetch my current-sprint tickets: GET ${PORTOS_API_URL}/api/jira/instances/<instanceId>/my-sprint-tickets/<projectKey>. This returns the tickets assigned to me in the active sprint.
+3. Build the in-flight set from git refs:
+ \`\`\`bash
+ cd {repoPath}
+ git fetch --prune 2>/dev/null
+ git branch -a --no-color --format='%(refname:short)'
+ \`\`\`
+ For each ref (after stripping any leading \`origin/\` / \`upstream/\` prefix), extract the ticket KEY **only when the ref matches** \`claim/<KEY>\` (the segment after \`claim/\`) or \`cos/<task>/<KEY>/<agent>\` (the \`<KEY>\` third segment). A KEY looks like \`PROJ-1234\`.
+4. **Pick the target ticket:** walk the sprint tickets and pick the FIRST where ALL of the following are true (prefer higher priority — Blocker/Highest/High — then oldest):
+ - Its status is a not-started status (e.g. "To Do", "Open", "Backlog", "Selected for Development", "Ready"). Skip tickets already "In Progress", "In Review", "Done", or any closed/resolved status — those are claimed or finished.
+ - Its KEY is NOT in the in-flight set from step 3.
+ - It has enough of a summary/description to act on. A ticket that merely leaves a design choice unstated is still eligible — you'll decide the reading in Phase 3, not skip it here. Skip only a ticket with essentially no actionable content (bare title, no description or acceptance criteria).
+ - It is NOT an Epic (issue type "Epic", or a title ending in "(epic)"). Leave epics for a human to split.
+5. **If no eligible ticket exists**, exit cleanly — an empty actionable queue is a healthy state, not a failure. If a ticket is in the sprint but too vague or blocked to start, create a Review Hub todo (POST ${PORTOS_API_URL}/api/review/todo with title "[<KEY>] Needs clarification" or "[<KEY>] Blocked" and a description of what's missing) instead of claiming it.
+
+Capture the ticket KEY as \`KEY\`, its summary, and its full description — you'll reuse them in the branch, the MR/PR, and the commit trailer.
+
+## Phase 2 — Claim (In Progress + worktree)
+
+First move the ticket to **In Progress** (this is the claim, and it must happen BEFORE you start coding), then create the worktree. Transition names vary per project workflow, so resolve the id dynamically:
+
+1. GET ${PORTOS_API_URL}/api/jira/instances/<instanceId>/tickets/<KEY>/transitions to list available transitions.
+2. Pick the transition whose target status best matches "In Progress" (e.g. "In Progress", "Start Progress", "Start Work"); match case-insensitively. If none clearly matches, pick the transition that moves the ticket out of the To Do / Backlog column.
+3. POST ${PORTOS_API_URL}/api/jira/instances/<instanceId>/tickets/<KEY>/transition with body {"transitionId": "<id>"}. If this fails (the status is unreachable), the ticket may have been claimed concurrently — return to Phase 1 and pick the next eligible ticket.
+
+Then create the worktree on a branch named \`claim/<KEY>\`. Do all editing inside the worktree, NEVER in the source repo's working tree:
+
+\`\`\`bash
+KEY=<picked-key>
+DEFAULT_BRANCH="$(git -C {repoPath} symbolic-ref --short refs/remotes/origin/HEAD 2>/dev/null | sed 's@^origin/@@')"
+DEFAULT_BRANCH="\${DEFAULT_BRANCH:-main}"
+WORKTREE="{worktreesRoot}/claim-\${KEY}"
+mkdir -p "{worktreesRoot}"
+git -C {repoPath} fetch origin "\${DEFAULT_BRANCH}"
+git -C {repoPath} worktree add --no-track -b "claim/\${KEY}" "\${WORKTREE}" "origin/\${DEFAULT_BRANCH}"
+cd "\${WORKTREE}"
+\`\`\`
+
+**If \`git worktree add\` fails because the \`claim/<KEY>\` branch already exists** (a concurrent run won the race), do NOT force or reuse it — that branch IS another run's claim. Move the ticket back to its prior status if you transitioned it, treat the ticket as in-flight, return to Phase 1, and pick the next eligible ticket. Stash \`WORKTREE\` — you'll need it for Phase 6 cleanup.
+
+## Phase 3 — Verify still valid
+
+Re-read the ticket (GET ${PORTOS_API_URL}/api/jira/instances/<instanceId>/tickets/<KEY>) before writing any code. **Every exit from this phase must leave a CONVERGING status on the ticket — Done/Closed, or a held status backed by a Review Hub todo.** Transitioning back to a not-started status is NOT an exit: Phase 1's not-started-only filter makes the ticket immediately re-eligible again, so the next pass re-picks it and burns another no-op run — every pass, forever.
+
+- **Already fixed, superseded, or duplicated by another ticket** — a comment says so, or the change it asks for is already on the default branch. Post a ticket comment naming the PR/MR, commit, or ticket that already delivered it (POST ${PORTOS_API_URL}/api/jira/instances/<instanceId>/tickets/<KEY>/comments), transition the ticket to **Done/Closed**, remove the worktree, and return to Phase 1. **Evidence gate: if you cannot name the PR/MR, commit, or ticket that delivered it, this branch does NOT apply** — closing on a hunch destroys live work, which is far worse than one wasted pass. Treat the ticket as real work and continue to Phase 4.
+- **Stale reference** — the ticket names a function, file, or component that no longer exists (\`grep -rn\` the named identifiers; if they're gone, it's stale). Post a ticket comment naming what you searched for and what you found instead, create a Review Hub todo (POST ${PORTOS_API_URL}/api/review/todo with title "[<KEY>] Stale reference" and what a human must re-scope), and transition the ticket to a **Blocked/On Hold status if the workflow has one — NOT back to a not-started status**; if the workflow has no held status, leave it **In Progress** so Phase 1's filter excludes it. Then remove the worktree and return to Phase 1.
+
+(A too-large scope is NOT in this list — it has its own park path below.)
+
+**A genuinely too-large ticket needs parking so the queue converges.** If the work is bigger than one coherent claim — it would touch files far outside the ticket's scope (>5 unrelated files) — and you can't carve a valuable standalone slice to ship first, splitting the omnibus is a human call: create a Review Hub todo (POST ${PORTOS_API_URL}/api/review/todo with title "[<KEY>] Needs clarification" and the split you'd suggest), transition the ticket to a **Blocked/On Hold status if the workflow has one — NOT back to a not-started status**, which would re-queue it under Phase 1 (ticket selection never consults Review Hub todos, so a not-started ticket is immediately re-eligible and the run would re-park it every pass); if the workflow has no held status, leave it **In Progress**. Phase 1's not-started-only filter keeps a non-not-started ticket out of the ready queue, and the Review Hub todo is the durable human signal — together they let the claim run converge. Then remove the worktree and exit.
+
+**Ambiguity is NOT a release trigger — decide, don't defer.** If the ticket is merely open to more than one reasonable reading, or leaves a design choice unstated, do NOT bail to a "Needs clarification" todo. Pick the most reasonable interpretation, record the approach you chose in a ticket comment (POST ${PORTOS_API_URL}/api/jira/instances/<instanceId>/tickets/<KEY>/comments) so the decision is on the record, and implement it. The user would rather iterate on top of a shipped best-guess than have the ticket parked waiting on a decision they didn't ask to make. Reserve the "Needs clarification" todo for cases where proceeding would be **destructive or irreversible**, or genuinely requires the human: specific hardware/credentials you don't have, or a judgment only they can make. In those cases only, create the todo (POST ${PORTOS_API_URL}/api/review/todo with title "[<KEY>] Needs clarification" and what a human must resolve), transition the ticket to a **Blocked/On Hold status if the workflow has one — NOT back to a not-started status** (which would re-queue it under Phase 1, since ticket selection never consults Review Hub todos); if the workflow has no held status, leave it **In Progress** so Phase 1's not-started-only filter excludes it. Then remove the worktree and **exit — do NOT proceed to Phase 4**.
+
+Do NOT leave an *unexplained* ticket in "In Progress" with no branch — that is the zombie to avoid. A deliberate park above is different: it always carries a Review Hub todo saying why (and a Blocked/On Hold status where the workflow supports one), so it reads as intentionally held, not abandoned.
+
+## Phase 4 — Implement
+
+Write the code, tests, and any docs the ticket requires. Follow the repo conventions in AGENTS.md / CLAUDE.md (no try/catch in route handlers, functional programming, Zod validation, Tailwind tokens, reactive UI updates). Run the relevant test suite as you go.
+
+**Roll discovered backbone work INTO this MR/PR** — small supporting helpers, refactors, and tests the fix depends on belong here, not a follow-up. Only defer genuinely-large adjacent work.
+
+Commit with a conventional message referencing the ticket so the trail is grep-able:
+
+\`\`\`
+<type>: <one-line description> (<KEY>)
+\`\`\`
+
+## Phase 5 — Review locally, then open the MR/PR and move to In Review
+
+The audit trail is the merged MR/PR + \`git log\`. Detect the forge from the git origin and use the matching CLI (\`gh\` for GitHub, \`glab\` for GitLab).
+
+The configured reviewers for this task, in order, are \`{reviewers}\`. Split them by where they can run, preserving order: **LOCAL reviewers** — every token that is NOT an \`@<login>\` (\`claude\` / \`codex\` / \`antigravity\` (CLI binary: \`agy\`) / \`grok\` / \`cursor\` invoke a local-CLI critique; \`lmstudio\` / \`ollama\` use the appended Local Reviewer Procedure) read the working tree and need no MR/PR, so they run in steps 1–2 below, BEFORE it is opened. **PR-SIDE reviewers** — every \`@<login>\` token, plus any review bot the repo requests automatically on open — review cloud-side and run in Phase 6, once the MR/PR exists.
+
+1. **Write the changelog entry now, not after the reviewers run** — every commit the reviewers are about to read must already be on the branch, or the MR/PR carries work nobody reviewed. If the repo maintains a changelog, record a one-line entry **following the convention that repo documents** — read its \`AGENTS.md\` (or \`CLAUDE.md\`) and changelog README (e.g. \`.changelog/README.md\`) first. Some repos collect per-branch fragments in a directory (e.g. \`.changelog/next/\`) via a helper script rather than appending to one shared file, precisely so parallel agents don't conflict on every merge; use that flow when it's documented. Fall back to appending to the unreleased section (\`.changelog/NEXT.md\`, or \`## Unreleased\` in \`CHANGELOG.md\`) in the repo's existing prose style only when no convention is documented. Otherwise skip it.
+2. **Self-review your diff for reuse, quality, and efficiency** (DRY, dead code, naming, simpler equivalents, missed edge cases) and fix the findings in the same diff. Claude Code runs this as the three-agent \`/simplify\` pass; on other CLIs, do the equivalent by hand.
+3. **Run each LOCAL reviewer in the listed order against the BRANCH diff, not an MR/PR diff.** Nothing is open yet, so use the CLI's own base-diff mode or \`git diff "origin/\${DEFAULT_BRANCH}...HEAD"\`; local LLM reviewers go through the appended endpoint procedure. Apply the findings, run the tests, and commit the fixes — capped at 3 rounds per reviewer — then advance. A missing CLI, timeout, transport failure, malformed response, or empty response is UNSATISFIED, not clean. Do NOT substitute your own self-review, and do NOT open an MR/PR on the strength of it. If a local reviewer stays unsatisfied after 3 rounds, or its fixes leave the build/tests red, do NOT open one — leave the branch and worktree in place, comment the failure on the ticket (POST ${PORTOS_API_URL}/api/jira/instances/<instanceId>/tickets/<KEY>/comments), and stop.
+4. Push the branch: \`git push -u origin "claim/\${KEY}"\`, then confirm \`git log --oneline @{u}..HEAD\` is empty so every review fix from step 3 is in the MR/PR's diff.
+5. Open the MR/PR. Reference the JIRA \`KEY\` in the title and description (there is NO \`Closes\` auto-close for JIRA). Summarize what shipped + a short test plan.
+ - GitHub: \`gh pr create --fill --head "claim/\${KEY}"\` (then edit the body to mention \`KEY\` if \`--fill\` didn't).
+ - GitLab: \`glab mr create --fill --source-branch "claim/\${KEY}" --target-branch "\${DEFAULT_BRANCH}" --yes\`.
+ Capture the MR/PR URL as \`PR_URL\`.
+6. **Move the ticket to "In Review" — REQUIRED, not optional. Do not finish while it is still "In Progress":**
+ - GET ${PORTOS_API_URL}/api/jira/instances/<instanceId>/tickets/<KEY>/transitions again (transitions change once In Progress).
+ - Pick the transition whose target status best matches "In Review" (e.g. "In Review", "Code Review", "Review", "Ready for Review"); match case-insensitively.
+ - POST ${PORTOS_API_URL}/api/jira/instances/<instanceId>/tickets/<KEY>/transition with body {"transitionId": "<id>"}.
+7. Add the MR/PR link to the ticket: POST ${PORTOS_API_URL}/api/jira/instances/<instanceId>/tickets/<KEY>/comments with body {"comment": "Implementation complete. MR/PR: \${PR_URL}\\n\\nReady for code review."}. **If you shipped only PART of the ticket's scope** (a valuable slice with real work remaining), make the comment a \`Done ✓ / Remaining ▢\` summary so the remaining scope is not lost when a human lands the MR/PR; when that remainder is a clean, separable chunk, ALSO file a new follow-up ticket for it (POST ${PORTOS_API_URL}/api/jira/instances/<instanceId>/tickets with a summary + a description referencing \`KEY\`, plus equivalent labels \`model-light|model-medium|model-heavy\`, \`effort-low|effort-medium|effort-high|effort-xhigh|effort-max\`, \`good-first-issue\`, \`help-wanted\` when independently justified) so it re-enters the sprint queue. If a transition in step 6 failed (status unreachable), say so in this comment AND in the Phase 7 summary — do not silently drop it.
+
+## Phase 6 — PR-side review and clean up
+
+The local reviewers already ran in Phase 5, so only the reviewers that need an open MR/PR remain.
+
+1. **Satisfy the PR-SIDE reviewers.** For each \`@<login>\` from the Phase 5 split, request the review on the open MR/PR (GitHub: \`gh pr edit <pr-number> --add-reviewer <login>\`, dropping the \`@\`; GitLab: \`glab mr update <MR_IID> --reviewer <login>\`), poll every 5–15s, and address the findings — push fixes, capped at 3 rounds per reviewer. Wait out any auto-requested review bot the same way. A missing reviewer, timeout, or unresolvable finding is UNSATISFIED, not clean: comment on the MR/PR naming the failure and stop. With no \`@<login>\` configured and no bot review appearing, this step is a no-op.
+2. **Leave the MR/PR open for a human to land.** Unlike the GitHub/GitLab issue flows, this flow does NOT auto-merge — the ticket is "In Review" and a human reviews + merges. After the reviewers finish, run the worktree-only cleanup so the source checkout is left clean:
+ \`\`\`bash
+ cd {repoPath}
+ git worktree remove "\${WORKTREE}"
+ \`\`\`
+ Leave the local \`claim/<KEY>\` branch and the open MR/PR in place. **Do NOT \`git merge\`, \`gh pr merge\`, \`glab mr merge\`, or \`git pull\`** — landing the change and moving the ticket to Done is the human's call.
+
+## Phase 7 — Report
+
+Generate a short summary: the ticket KEY + summary worked, the MR/PR URL, the ticket's FINAL JIRA status (confirm it is "In Review"), reviewers run, and any status transition that failed and why.`);
diff --git a/server/services/taskPromptDefaults/prompts.js b/server/services/taskPromptDefaults/prompts.js
index d1489ee7a8..660b8583c0 100644
--- a/server/services/taskPromptDefaults/prompts.js
+++ b/server/services/taskPromptDefaults/prompts.js
@@ -11,7 +11,14 @@
// PORTOS_API_URL is interpolated into the jira-status-report default prompt below.
import { PORTOS_API_URL } from '../../lib/ports.js';
-import { ISSUE_QUALITY_GUIDANCE } from '../../lib/dispatchLabels.js';
+import { EPIC_DECOMPOSED_LABEL, ISSUE_QUALITY_GUIDANCE, formatLabelCreateCommand } from '../../lib/dispatchLabels.js';
+
+// The epic marker and its idempotent `label create` line come from the shared
+// label registry, so the label the claim agent stamps is by construction the one
+// perpetualWork.js#isActionableIssue reads, and the create is `|| true` — a
+// second decomposition must not abort Phase 1b just because the label exists.
+const EPIC_LABEL_CREATE_GH = formatLabelCreateCommand(EPIC_DECOMPOSED_LABEL);
+const EPIC_LABEL_CREATE_GLAB = formatLabelCreateCommand(EPIC_DECOMPOSED_LABEL, { cli: 'glab' });
const SCHEDULED_ISSUE_QUALITY_GATE = `## Scheduled issue-quality gate
@@ -883,11 +890,57 @@ Run steps 1–5 in order.
- Its number is NOT in the in-flight set.
- It has no assignees, or at least one assignee's login matches \`$ME\` (an issue assigned only to another account is already claimed). If \`$ME\` is empty, skip every assigned issue.
- It does NOT carry any of these blocking labels: {issueExcludeLabels}.
- - It is NOT a tracking/umbrella **epic** — recognized by an \`epic\` label, a title ending in "(epic)", OR a title beginning with an \`[epic]\` bracket or \`Epic:\` tag (e.g. "[Epic] …" / "Epic: …", case-insensitive). An epic needs per-slice partial-ship (each slice its own PR, \`Refs\` not \`Closes\`), so leave it for a human or \`/claim --issues\` to split — don't claim it wholesale here. **The bare \`plan\` label is NOT a skip signal.** \`do-replan --issues\` (and \`/do:replan --issues\`) labels EVERY migrated backlog item \`plan\` — atomic bug-fixes included — so \`plan\` marks the *claimable* queue exactly as \`/do:next --issues\` treats it (it is that flow's required candidate label). Skipping all \`plan\` issues would discard the entire actionable backlog and falsely report an empty queue.
-5. **If no eligible issue exists**, exit cleanly — an empty actionable queue is a healthy state, not a failure.
+ - It is NOT an ALREADY-DECOMPOSED tracking/umbrella **epic**. An epic is recognized by an \`epic\` label, a title ending in "(epic)", OR a title beginning with an \`[epic]\` bracket or \`Epic:\` tag (e.g. "[Epic] …" / "Epic: …", case-insensitive); it counts as decomposed once it carries the \`decomposed\` label. Skip a decomposed epic — its child slices are ordinary claimable issues in this very list, so claiming the parent would duplicate them. An epic that is NOT yet decomposed IS eligible, but only as a **last resort**: it can't ship as one PR, so prefer every eligible non-epic issue first and fall through to an epic only when the walk finds no atomic work. An epic you pick goes to **Phase 1b**, not Phase 2. **The bare \`plan\` label is NOT a skip signal.** \`do-replan --issues\` (and \`/do:replan --issues\`) labels EVERY migrated backlog item \`plan\` — atomic bug-fixes included — so \`plan\` marks the *claimable* queue exactly as \`/do:next --issues\` treats it (it is that flow's required candidate label). Skipping all \`plan\` issues would discard the entire actionable backlog and falsely report an empty queue.
+5. **If no eligible issue exists**, exit cleanly — an empty actionable queue is a healthy state, not a failure. **But an open, undecomposed epic is NOT an empty queue**: never report "no work available" while one is unclaimed. Splitting it is the work — go to Phase 1b.
Capture the issue number as \`NUM\`, its title, and its full body — you'll reuse them in the PR and the \`Closes #<num>\` trailer.
+## Phase 1b — Decompose an epic (only when Phase 1 landed on one)
+
+You reach this phase two ways: Phase 1 found no eligible atomic issue and fell through to an undecomposed epic, or the user pinned this run to an epic. **Never end a run reporting "nothing to do" while an undecomposed epic is open** — turning it into shippable slices IS this round's work, and it is what refills the queue for every later run.
+
+Capture the epic's number as \`EPIC\`. This phase writes ONLY to the issue tracker: no worktree, no branch, no PR, no edits in the source repo.
+
+1. Read it in full, comments included: \`gh issue view "\${EPIC}" --comments\`.
+2. **Find the children it already has** — an epic a human (or an earlier run) already split must never be re-split:
+ \`\`\`bash
+ gh issue view "\${EPIC}" --json body -q .body
+ gh issue list --state all --search "in:body \\"Part of #\${EPIC}\\"" --json number,title,state,labels,assignees --limit 200
+ \`\`\`
+ Union that with every \`#<num>\` the epic's own body checklist references.
+3. **If children already exist, do NOT file more.**
+ - **Some child still OPEN** → the epic is already decomposed. Make sure it carries the \`${EPIC_DECOMPOSED_LABEL}\` label and that its body checklist lists every child (step 6), then set \`NUM\` to the FIRST open child that passes Phase 1 step 4's eligibility rules (oldest-first) and continue at **Phase 2** with that child. If every open child is in flight, assigned elsewhere, or blocked, exit cleanly — that queue is busy, not empty.
+ - **Every child CLOSED** → the epic's work is done. Post a comment naming the children that delivered it, close it (\`gh issue close "\${EPIC}" --reason completed\`), and return to Phase 1 to look for other work.
+ - **Labeled \`${EPIC_DECOMPOSED_LABEL}\` but NO children exist** → an earlier split claimed the epic and died before filing anything. Treat it as undecomposed and continue at step 4; the marker is already in place, so nothing needs re-claiming.
+4. **Otherwise, plan the split.** Read the code the epic actually names before slicing — a split that never met the repo is worthless. Produce 2–8 slices, each of them independently shippable in ONE PR, valuable on its own, and written with concrete scope + acceptance criteria + the files/areas involved. Slice by user-visible behavior or subsystem; never one-issue-per-file, and never invent scope the epic doesn't ask for. Decide the boundaries yourself — an ambiguous epic is decided, not deferred (same rule as Phase 3). Only an epic so vague that no split survives contact with the code is a \`needs-input\` case: comment what is missing, \`gh issue edit "\${EPIC}" --add-label needs-input\`, and exit.
+5. **Claim the epic, THEN file the slices.** Stamp the marker before the first \`gh issue create\` — the label IS this phase's claim (Phase 1 skips a \`${EPIC_DECOMPOSED_LABEL}\` epic), so two concurrent runs can't both file a full slice set, and a run that dies mid-split can't be re-split from scratch on the next tick. Marking last would instead leave the epic actionable forever whenever that final edit failed:
+ \`\`\`bash
+ ${EPIC_LABEL_CREATE_GH}
+ gh issue edit "\${EPIC}" --add-label ${EPIC_DECOMPOSED_LABEL}
+ gh issue comment "\${EPIC}" --body "Decomposing into per-slice issues — <one line on how you sliced it>"
+ # The queue label the slices carry must exist before the first create, or every
+ # \`gh issue create\` below fails on a repo that has never used it.
+ gh label create plan --color 0E8A16 --description "Claimable backlog item" 2>/dev/null || true
+ \`\`\`
+ Then file each slice, in the order you want them worked:
+ \`\`\`bash
+ gh issue create --title "<specific, human-readable>" --label plan \\
+ --body "<what + why + acceptance criteria + files/areas>
+
+Part of #\${EPIC}"
+ \`\`\`
+ Use \`Part of #\${EPIC}\` — NEVER \`Closes #\${EPIC}\`, which would close the whole epic on the first slice that merges. Carry over the epic's \`area:*\` labels, and add dispatch hints (\`model:light|medium|heavy\`, \`effort:low|medium|high|xhigh|max\`) or contributor labels (\`good first issue\`, \`help wanted\`) only where that slice genuinely justifies them; create a missing label immediately before applying it.
+6. **Write the checklist back to the epic** so the next run can follow it — keep the original body and append a \`## Decomposed into\` list naming every child:
+ \`\`\`bash
+ EPIC_BODY=$(mktemp)
+ gh issue view "\${EPIC}" --json body -q .body > "\${EPIC_BODY}"
+ printf '\\n\\n## Decomposed into\\n\\n- [ ] #<a> — <title>\\n- [ ] #<b> — <title>\\n' >> "\${EPIC_BODY}"
+ gh issue edit "\${EPIC}" --body-file "\${EPIC_BODY}"
+ rm -f "\${EPIC_BODY}"
+ \`\`\`
+ The marker from step 5 is what stops the next run from splitting the same epic again; this checklist is what lets a claim aimed at the epic resolve the next available child. Leave the epic OPEN, unassigned, and WITHOUT \`in-progress\` — it closes when its last child closes.
+7. **Then claim the first slice you filed** — set \`NUM\` to it and continue at **Phase 2**, shipping that ONE slice normally (its PR closes the slice, never the epic). If claiming it fails because another run won the race, exit cleanly: the decomposition alone is a successful round, and the next claim run picks up the next linked child.
+
## Phase 2 — Claim (worktree + markers)
Create the worktree on a branch named \`claim/issue-<num>\`, then set the cross-machine claim markers. Do all editing inside the worktree, NEVER in the source repo's working tree.
@@ -917,7 +970,7 @@ Read the full issue (\`gh issue view "\${NUM}" --comments\`) before writing any
(A too-large scope is NOT in this list — it has its own park path below.)
-**A genuinely too-large issue needs parking so the drain converges.** If the work is bigger than one coherent claim — it would touch files far outside the issue's scope (>5 unrelated files) — and you can't carve a valuable standalone slice to partial-ship via Phase 6's \`Refs\` path, post a brief comment naming the split you'd suggest, **tag it \`needs-input\`** (\`gh issue edit "\${NUM}" --add-label needs-input\`), release the claim markers (\`gh issue edit "\${NUM}" --remove-assignee @me --remove-label in-progress\`), remove the worktree, and exit — splitting an omnibus issue is a human call, and parking it is what stops a perpetual drain from re-picking the same un-shippable issue every pass (Phase 1 step 4 skips \`needs-input\`).
+**A genuinely too-large issue gets SPLIT, not parked.** If the work is bigger than one coherent claim — it would touch files far outside the issue's scope (>5 unrelated files) — and you can't carve a valuable standalone slice to partial-ship via Phase 6's \`Refs\` path, promote it to an epic and decompose it: file the slices and rewrite the parent exactly as **Phase 1b** steps 4–6 describe (each slice carrying \`Part of #\${NUM}\`; add \`epic\` and \`decomposed\` to THIS issue), release its claim markers (\`gh issue edit "\${NUM}" --remove-assignee @me --remove-label in-progress\`), remove the worktree, then continue at Phase 2 with the first slice you filed. Splitting an omnibus issue is work you do, not a hand-off. Park to \`needs-input\` (\`gh issue edit "\${NUM}" --add-label needs-input\`, release the markers, remove the worktree, exit) ONLY when the issue is too vague to slice against the code at all — that park is what stops a perpetual drain from re-picking an un-shippable issue every pass (Phase 1 step 4 skips \`needs-input\`).
**Ambiguity is NOT a release trigger — decide, don't defer.** If the issue is merely open to more than one reasonable reading, or leaves a design choice unstated, do NOT bail to \`needs-input\`. Pick the most reasonable interpretation, record the approach you chose in a brief issue comment (\`gh issue comment "\${NUM}" --body "..."\`) so the decision is on the record, and implement it. The user would rather iterate on top of a shipped best-guess than have the issue parked waiting on a decision they didn't ask to make. Reserve \`needs-input\` — which pulls the issue out of the autonomous queue — for the narrow cases where proceeding would be **destructive or irreversible**, or genuinely requires the human: specific hardware/credentials you don't have, or a judgment only they can make. In those cases only, post the explaining comment, **tag it \`needs-input\`** (\`gh issue edit "\${NUM}" --add-label needs-input\`), release the claim markers (\`gh issue edit "\${NUM}" --remove-assignee @me --remove-label in-progress\`), remove the worktree, and exit cleanly. **That label is what lets an autonomous drain converge** — Phase 1 step 4 skips \`needs-input\` issues. Never leave a half-claimed issue.
@@ -1031,11 +1084,25 @@ Run steps 1–5 in order.
- Its number (\`iid\`) is NOT in the in-flight set.
- It has no assignees, or at least one assignee's username matches \`$ME\` (an issue assigned only to another account is already claimed). If \`$ME\` is empty, skip every assigned issue.
- It does NOT carry any of these blocking labels: {issueExcludeLabels}.
- - It is NOT a tracking/umbrella **epic** — recognized by an \`epic\` label, a title ending in "(epic)", OR a title beginning with an \`[epic]\` bracket or \`Epic:\` tag (e.g. "[Epic] …" / "Epic: …", case-insensitive). Leave epics for a human to split. **The bare \`plan\` label is NOT a skip signal** — it marks the claimable queue, not a blocker.
-5. **If no eligible issue exists**, exit cleanly — an empty actionable queue is a healthy state, not a failure.
+ - It is NOT an ALREADY-DECOMPOSED tracking/umbrella **epic**. An epic is recognized by an \`epic\` label, a title ending in "(epic)", OR a title beginning with an \`[epic]\` bracket or \`Epic:\` tag (e.g. "[Epic] …" / "Epic: …", case-insensitive); it counts as decomposed once it carries the \`decomposed\` label. Skip a decomposed epic — its child slices are ordinary claimable issues in this very list. An epic that is NOT yet decomposed IS eligible, but only as a **last resort**: prefer every eligible non-epic issue first, and an epic you pick goes to **Phase 1b**, not Phase 2. **The bare \`plan\` label is NOT a skip signal** — it marks the claimable queue, not a blocker.
+5. **If no eligible issue exists**, exit cleanly — an empty actionable queue is a healthy state, not a failure. **But an open, undecomposed epic is NOT an empty queue** — go to Phase 1b instead of reporting "no work available".
Capture the issue number (GitLab \`iid\`) as \`NUM\`, its title, and its full description — you'll reuse them in the MR and the \`Closes #<num>\` line.
+## Phase 1b — Decompose an epic (only when Phase 1 landed on one)
+
+Same contract as the GitHub flow: an undecomposed epic is work, not a dead end. Capture its \`iid\` as \`EPIC\`. This phase writes ONLY to the issue tracker — no worktree, no branch, no MR.
+
+1. Read it in full: \`glab issue view "\${EPIC}" --comments\`.
+2. **Find the children it already has** — never re-split an epic somebody already split. Union the \`#<num>\` refs in its own description checklist with \`glab issue list --all --search "Part of #\${EPIC}" --output json --per-page 100\`.
+3. **If children already exist, do NOT file more.** Some child still OPEN → make sure the epic carries the \`decomposed\` label and a complete checklist (step 6), set \`NUM\` to the FIRST open child passing Phase 1 step 4's rules (oldest-first), and continue at **Phase 2** with that child; if every open child is in flight/assigned/blocked, exit cleanly. Every child CLOSED → comment naming what delivered it, \`glab issue close "\${EPIC}"\`, and return to Phase 1.
+4. **Otherwise, plan the split** against the actual code the epic names: 2–8 slices, each independently shippable in ONE MR, valuable on its own, each with concrete scope + acceptance criteria + the files/areas involved. Slice by user-visible behavior, never one-issue-per-file, never invent scope. Decide the boundaries yourself; only an epic too vague to slice against the code is a \`needs-input\` case (comment why, \`glab issue update "\${EPIC}" --label needs-input\`, exit).
+5. **Claim the epic, THEN file the slices.** Stamp the marker before the first create — the label IS this phase's claim, so two concurrent runs can't both file a full slice set and a run that dies mid-split can't be re-split from scratch: \`${EPIC_LABEL_CREATE_GLAB}\`, then \`glab issue update "\${EPIC}" --label ${EPIC_DECOMPOSED_LABEL}\`, then post a comment saying a split is under way. Create the \`plan\` queue label the same way if the project lacks it, or every create below fails. Then file each slice in the order you want them worked: \`glab issue create --title "<specific>" --label plan --description "<what + why + acceptance criteria + files/areas>
+
+Part of #\${EPIC}"\`. Use \`Part of #\${EPIC}\`, NEVER \`Closes #\${EPIC}\`. Carry over the epic's \`area:*\` labels; add \`model:*\`/\`effort:*\` or contributor labels only where justified.
+6. **Write the checklist back to the epic**: keep its description and append a \`## Decomposed into\` checklist (\`- [ ] #<num> — <title>\`) via \`glab issue update "\${EPIC}" --description "<full text>"\`. Leave the epic OPEN, unassigned, and without \`in-progress\` — it closes when its last child closes. The step-5 marker is what stops the next run from re-splitting it; the checklist is what lets a claim aimed at the epic resolve the next available child. An epic already labeled \`${EPIC_DECOMPOSED_LABEL}\` with NO children is a split that died before filing — treat it as undecomposed and resume at step 4.
+7. **Then claim the first slice you filed** — set \`NUM\` to it and continue at **Phase 2**. If another run won the race, exit cleanly: the decomposition itself is a successful round.
+
## Phase 2 — Claim (worktree + markers)
Detect the default branch first (forge-agnostic), then create the worktree on \`claim/issue-<num>\` and set the cross-machine claim markers. Do all editing inside the worktree, NEVER in the source repo's working tree.
@@ -1068,7 +1135,7 @@ Read the full issue (\`glab issue view "\${NUM}"\`) before writing any code. **E
(A too-large scope is NOT in this list — it has its own park path below.)
-**A genuinely too-large issue needs parking so the drain converges.** If the work is bigger than one coherent claim — it would touch files far outside the issue's scope (>5 unrelated files) — and you can't carve a valuable standalone slice to partial-ship via Phase 6's \`Refs\` path, post a brief note naming the split you'd suggest, **tag it \`needs-input\`** (\`glab issue update "\${NUM}" --label needs-input\`), release the claim markers (\`glab issue update "\${NUM}" --unassign --unlabel in-progress\`), remove the worktree, and exit — splitting an omnibus issue is a human call, and parking it stops a perpetual drain from re-picking the same un-shippable issue every pass (Phase 1 step 4 skips \`needs-input\`).
+**A genuinely too-large issue gets SPLIT, not parked.** If the work is bigger than one coherent claim — it would touch files far outside the issue's scope (>5 unrelated files) — and you can't carve a valuable standalone slice to partial-ship via Phase 6's \`Refs\` path, promote it to an epic and decompose it exactly as **Phase 1b** steps 4–6 describe (each slice carrying \`Part of #\${NUM}\`; add \`epic\` and \`decomposed\` to THIS issue), release its claim markers (\`glab issue update "\${NUM}" --unassign --unlabel in-progress\`), remove the worktree, then continue at Phase 2 with the first slice you filed. Splitting an omnibus issue is work you do, not a hand-off. Park to \`needs-input\` (\`glab issue update "\${NUM}" --label needs-input\`, release the markers, remove the worktree, exit) ONLY when the issue is too vague to slice against the code at all — that park stops a perpetual drain from re-picking an un-shippable issue every pass (Phase 1 step 4 skips \`needs-input\`).
**Ambiguity is NOT a release trigger — decide, don't defer.** If the issue is merely open to more than one reasonable reading, or leaves a design choice unstated, do NOT bail to \`needs-input\`. Pick the most reasonable interpretation, record the approach you chose in a brief issue note (\`glab issue note "\${NUM}" -m "..."\`) so the decision is on the record, and implement it. The user would rather iterate on top of a shipped best-guess than have the issue parked waiting on a decision they didn't ask to make. Reserve \`needs-input\` — which pulls the issue out of the autonomous queue — for the narrow cases where proceeding would be **destructive or irreversible**, or genuinely requires the human: specific hardware/credentials you don't have, or a judgment only they can make. In those cases only, post the explaining note, **tag it \`needs-input\`** (\`glab issue update "\${NUM}" --label needs-input\`), release the claim markers (\`glab issue update "\${NUM}" --unassign --unlabel in-progress\`), remove the worktree, and exit cleanly. **That label is what lets an autonomous drain converge** — Phase 1 step 4 skips \`needs-input\` issues. Never leave a half-claimed issue.
@@ -1174,11 +1241,23 @@ Run steps 1–5 in order.
- Its status is a not-started status (e.g. "To Do", "Open", "Backlog", "Selected for Development", "Ready"). Skip tickets already "In Progress", "In Review", "Done", or any closed/resolved status — those are claimed or finished.
- Its KEY is NOT in the in-flight set from step 3.
- It has enough of a summary/description to act on. A ticket that merely leaves a design choice unstated is still eligible — you'll decide the reading in Phase 3, not skip it here. Skip only a ticket with essentially no actionable content (bare title, no description or acceptance criteria).
- - It is NOT an Epic (issue type "Epic", or a title ending in "(epic)"). Leave epics for a human to split.
-5. **If no eligible ticket exists**, exit cleanly — an empty actionable queue is a healthy state, not a failure. If a ticket is in the sprint but too vague or blocked to start, create a Review Hub todo (POST ${PORTOS_API_URL}/api/review/todo with title "[<KEY>] Needs clarification" or "[<KEY>] Blocked" and a description of what's missing) instead of claiming it.
+ - It is NOT an ALREADY-DECOMPOSED Epic (issue type "Epic", or a title ending in "(epic)"; decomposed once it carries the \`decomposed\` label). Skip a decomposed epic — its child tickets are ordinary claimable work. An epic that is NOT yet decomposed IS eligible, but only as a **last resort**: prefer every non-epic ticket first, and an epic you pick goes to **Phase 1b**, not Phase 2.
+5. **If no eligible ticket exists**, exit cleanly — an empty actionable queue is a healthy state, not a failure. **But an open, undecomposed Epic is NOT an empty queue** — go to Phase 1b rather than reporting "no work available". If a ticket is in the sprint but too vague or blocked to start, create a Review Hub todo (POST ${PORTOS_API_URL}/api/review/todo with title "[<KEY>] Needs clarification" or "[<KEY>] Blocked" and a description of what's missing) instead of claiming it.
Capture the ticket KEY as \`KEY\`, its summary, and its full description — you'll reuse them in the branch, the MR/PR, and the commit trailer.
+## Phase 1b — Decompose an Epic (only when Phase 1 landed on one)
+
+Same contract as the GitHub/GitLab flows: an undecomposed epic is work, not a dead end. Capture its key as \`EPIC\`. This phase writes ONLY to JIRA — no worktree, no branch, no MR/PR.
+
+1. Read it: GET ${PORTOS_API_URL}/api/jira/instances/<instanceId>/issues/<EPIC>.
+2. **Find the children it already has** — never re-split an epic somebody already split. Re-read the sprint list from Phase 1 step 2 for tickets whose epic link is \`EPIC\`, and union that with every \`<PROJ-nnn>\` key its description checklist names.
+3. **If children already exist, do NOT file more.** Any child still in a not-started status → set \`KEY\` to the first that passes Phase 1 step 4's rules and continue at **Phase 2** with it (first ensure the epic carries the \`decomposed\` label and a complete checklist, per step 6). Every child Done/closed → comment naming what delivered it, transition the epic to **Done**, and return to Phase 1.
+4. **Otherwise, plan the split** against the actual code the epic names: 2–8 slices, each independently shippable in ONE MR/PR, valuable on its own, each with concrete scope + acceptance criteria + the files/areas involved. Slice by user-visible behavior, never one-ticket-per-file, never invent scope. Decide the boundaries yourself; only an epic too vague to slice against the code becomes a Review Hub todo (POST ${PORTOS_API_URL}/api/review/todo with title "[<EPIC>] Needs clarification") — then exit.
+5. **Claim the Epic, THEN file the slices.** First PUT the parent's \`labels\` with \`${EPIC_DECOMPOSED_LABEL}\` added (step 6's shape) and POST a comment saying a split is under way — that marker IS this phase's claim, so two concurrent runs can't both file a full slice set and a run that dies mid-split can't be re-split from scratch. Then file each slice in the order you want it worked: POST ${PORTOS_API_URL}/api/jira/instances/<instanceId>/tickets with body {"projectKey": "<projectKey>", "summary": "<specific>", "description": "<what + why + acceptance criteria + files/areas>\\n\\nPart of <EPIC>", "issueType": "Task", "epicKey": "<EPIC>", "labels": ["plan"]}. The \`epicKey\` link is what keeps the slice attached to its parent on the board. Add independently justified labels (\`model-light\`/\`model-medium\`/\`model-heavy\`, \`effort-low\`…\`effort-max\`, \`good-first-issue\`, \`help-wanted\`) only where the slice warrants them.
+6. **Write the checklist back to the Epic so the next run can follow it.** PUT ${PORTOS_API_URL}/api/jira/instances/<instanceId>/tickets/<EPIC> with a \`description\` that keeps the original text and appends a "Decomposed into" checklist naming every child key, and a \`labels\` array containing the ticket's EXISTING labels plus \`${EPIC_DECOMPOSED_LABEL}\` (send the full list — the update replaces it). Leave the Epic OPEN in its current status — it moves to Done when its last child is done. The step-5 marker is what stops the next run from re-splitting it; the checklist is what lets a claim aimed at the Epic resolve the next available child. A ticket already labeled \`${EPIC_DECOMPOSED_LABEL}\` with NO children is a split that died before filing — treat it as undecomposed and resume at step 4.
+7. **Then claim the first slice you filed** — set \`KEY\` to it and continue at **Phase 2**. If another run won the race, exit cleanly: the decomposition itself is a successful round.
+
## Phase 2 — Claim (In Progress + worktree)
First move the ticket to **In Progress** (this is the claim, and it must happen BEFORE you start coding), then create the worktree. Transition names vary per project workflow, so resolve the id dynamically:
@@ -1211,7 +1290,7 @@ Re-read the ticket (GET ${PORTOS_API_URL}/api/jira/instances/<instanceId>/ticket
(A too-large scope is NOT in this list — it has its own park path below.)
-**A genuinely too-large ticket needs parking so the queue converges.** If the work is bigger than one coherent claim — it would touch files far outside the ticket's scope (>5 unrelated files) — and you can't carve a valuable standalone slice to ship first, splitting the omnibus is a human call: create a Review Hub todo (POST ${PORTOS_API_URL}/api/review/todo with title "[<KEY>] Needs clarification" and the split you'd suggest), transition the ticket to a **Blocked/On Hold status if the workflow has one — NOT back to a not-started status**, which would re-queue it under Phase 1 (ticket selection never consults Review Hub todos, so a not-started ticket is immediately re-eligible and the run would re-park it every pass); if the workflow has no held status, leave it **In Progress**. Phase 1's not-started-only filter keeps a non-not-started ticket out of the ready queue, and the Review Hub todo is the durable human signal — together they let the claim run converge. Then remove the worktree and exit.
+**A genuinely too-large ticket gets SPLIT, not parked.** If the work is bigger than one coherent claim — it would touch files far outside the ticket's scope (>5 unrelated files) — and you can't carve a valuable standalone slice to ship first, decompose it exactly as **Phase 1b** steps 4–6 describe (each slice linked with \`"epicKey": "<KEY>"\` and carrying \`Part of <KEY>\`), then continue at Phase 2 with the first slice you filed. Phase 1 skips a parent only when it is BOTH epic-shaped AND marked, so promote this ticket on both axes: add \`${EPIC_DECOMPOSED_LABEL}\` to its labels, and make it epic-shaped — change its issue type to Epic where the project allows it, otherwise append " (epic)" to its summary, which is the title convention Phase 1 recognizes. A ticket marked but still typed Task stays eligible and gets re-split every pass. Splitting an omnibus ticket is work you do, not a hand-off. Only when the ticket is too vague to slice against the code at all is it a human call: create a Review Hub todo (POST ${PORTOS_API_URL}/api/review/todo with title "[<KEY>] Needs clarification" and the split you'd suggest), transition the ticket to a **Blocked/On Hold status if the workflow has one — NOT back to a not-started status**, which would re-queue it under Phase 1 (ticket selection never consults Review Hub todos, so a not-started ticket is immediately re-eligible and the run would re-park it every pass); if the workflow has no held status, leave it **In Progress**. Phase 1's not-started-only filter keeps a non-not-started ticket out of the ready queue, and the Review Hub todo is the durable human signal — together they let the claim run converge. Then remove the worktree and exit.
**Ambiguity is NOT a release trigger — decide, don't defer.** If the ticket is merely open to more than one reasonable reading, or leaves a design choice unstated, do NOT bail to a "Needs clarification" todo. Pick the most reasonable interpretation, record the approach you chose in a ticket comment (POST ${PORTOS_API_URL}/api/jira/instances/<instanceId>/tickets/<KEY>/comments) so the decision is on the record, and implement it. The user would rather iterate on top of a shipped best-guess than have the ticket parked waiting on a decision they didn't ask to make. Reserve the "Needs clarification" todo for cases where proceeding would be **destructive or irreversible**, or genuinely requires the human: specific hardware/credentials you don't have, or a judgment only they can make. In those cases only, create the todo (POST ${PORTOS_API_URL}/api/review/todo with title "[<KEY>] Needs clarification" and what a human must resolve), transition the ticket to a **Blocked/On Hold status if the workflow has one — NOT back to a not-started status** (which would re-queue it under Phase 1, since ticket selection never consults Review Hub todos); if the workflow has no held status, leave it **In Progress** so Phase 1's not-started-only filter excludes it. Then remove the worktree and **exit — do NOT proceed to Phase 4**.
diff --git a/server/services/taskPromptDefaults/versions.js b/server/services/taskPromptDefaults/versions.js
index fe1d4e155c..ec9fde413d 100644
--- a/server/services/taskPromptDefaults/versions.js
+++ b/server/services/taskPromptDefaults/versions.js
@@ -12,9 +12,9 @@ export const PROMPT_VERSIONS = {
'do-replan': 2, // v2: scheduled issue-quality gate rejects speculative/future-only work and keeps valid current refactors claimable
'feature-ideas': 10, // v10: Phase 4 (Brainstorm) consults the repo's REJECTED.md and recently closed-unmerged PRs before proposing, so ideas the user already declined aren't re-proposed (mirrors idle-review's REJECTED.md contract). v9: drop DONE.md reads — use `.changelog/` + `git log` (last 50) as the completed-work signal
'plan-task': 18, // v18: scheduled plan-task no longer instructs a code-review loop; v17: the implement + changelog steps name `AGENTS.md` (or `CLAUDE.md`) as the repo-conventions file (#4852 made AGENTS.md canonical; the dual naming keeps a managed app that still carries only the old name discoverable). v16: every reviewer that can read the working tree runs BEFORE the PR is opened — Phase 6 splits the configured list into LOCAL reviewers (every non-`@<login>` token, reviewed against `git diff origin/main...HEAD`) and PR-SIDE reviewers (`@<login>` plus any auto-requested review bot), opens the PR only once the branch is review-clean, and then waits on those PR-side reviewers plus required CI. Previously the PR was opened first and every reviewer ran against its diff, so each round of findings landed as follow-up commits on an already-public PR. v14: claim worktree creation passes `--no-track`, so a branch based on `origin/main` cannot inherit `main` as its upstream and make a config-derived push write directly to the default branch; the later `git push -u` sets the intended branch upstream. v13: Phase 5's changelog step reads the repo's documented convention FIRST (per-branch fragment directory + helper script, as PortOS now uses) and only falls back to detect-and-append when none is documented; the Phase 6 review-stuck note no longer names `.changelog/NEXT.md` as the file it wrote. v12: the reviewer bullets name the antigravity reviewer's actual PATH binary (`agy`) — the bare `antigravity` slug is a command that exists nowhere, and a review-loop agent that probed for it concluded no reviewer was available and merged on its own self-review. The same bump adds the missing-binary guard: a reviewer whose CLI is not on PATH is UNSATISFIED, never a clean review the agent substitutes its own self-review for. v11: worktree is created under PortOS's shared worktrees dir (`{worktreesRoot}` → data/cos/worktrees) instead of a repo-relative `data/cos/worktrees/` path, so the agent's checkout no longer lands inside the managed app's working tree. v10: Phase 3 "decide, don't defer" — an *ambiguous* PLAN.md item no longer jumps to the Phase 3b clarification PR; the agent picks the most reasonable reading, notes it, and implements. Phase 3b is reserved for destructive/irreversible or genuinely-human-gated items. Mirrors claim-issue v7 + CLAUDE.md. v9: per-kind reviewer bullets name `grok` alongside `claude`/`codex`/`antigravity` as a local-CLI reviewer (grok is now a selectable Review Loop reviewer). v8: Phase-6 merge fallback prefers --merge over --squash (after --auto), matching the /do:pr + review-loop default and PortOS's merge-only policy
- 'claim-issue': 20, // v20: canonicalize GitHub's ssh.github.com SSH-over-443 alias before host-aware identity probes. v19: host-aware GitHub identity probes use the repository origin, and probe failures stay transient instead of parking an assigned-only queue. v18: explicit issue-page claims ignore existing assignees; auto-pick resolves the authenticated login so self-assigned issues remain retryable; open continuation handoffs clear in-progress and all assignees. v17: mirrors plan-task v17 — Phase 4 and Phase 5 name `AGENTS.md` (or `CLAUDE.md`) as the repo-conventions file (#4852). v16: Phase 1 step 4's blocking-label check is now the `{issueExcludeLabels}` placeholder (resolveIssueExcludeLabelsBlock, cosTaskGenerator.js) — the fixed NON_ACTIONABLE_ISSUE_LABELS set plus any app-configured `taskMetadata.issueExcludeLabels` extras (e.g. `good first issue`), so the live claim agent honors the same per-app exclusions the perpetual-drain detector applies, not just the hardcoded set. The pinned-target constraint (`/do:next <num>` / the work-item picker) also re-checks that resolved list, not just the fixed 3, so a target that gained an excluded label after the picker snapshot still isn't force-claimed. Phase 1's candidate fetch widened to `--limit 500` (was 100), matching perpetualWork.js's detector — the label filter runs on the fetched page, so a small cap risked missing eligible work further down a busy queue. v15: Phase 5 is now the pre-PR local review (LOCAL reviewers = every non-`@<login>` token, run against the branch diff; an unsatisfied one blocks PR creation entirely) and Phase 6 opens the PR, satisfies the PR-SIDE reviewers (`@<login>` plus any auto-requested review bot) and required CI, then merges. v13: follow-up issue recipes choose independent slashdo dispatch hints (`model:`/`effort:`) and contributor labels (`good first issue`/`help wanted`) instead of only `plan`. v12: claim worktree creation passes `--no-track`, so a branch based on `origin/main` cannot inherit `main` as its upstream and make a config-derived push write directly to the default branch; the later `git push -u` sets the intended branch upstream. v11: EVERY Phase-3 release now converges — the "already fixed / superseded" case CLOSES the issue (with a comment naming what delivered it) and the "stale reference" case tags `needs-input`, instead of both releasing the issue open and unlabeled. `isActionableIssue` (perpetualWork.js) can only see labels/assignees/epic/in-flight, so a body-or-comment-driven release left the issue looking actionable and the perpetual drain re-spawned a no-op agent on it every tick. v10: Phase 5's changelog step defers to the convention the repo documents (per-branch fragment directory + helper script when present) instead of prescribing an append to `.changelog/NEXT.md`. v9: reviewer bullets name the antigravity reviewer's actual PATH binary (`agy`) — mirrors plan-task v12. The same bump adds the missing-binary guard: a reviewer whose CLI is not on PATH is UNSATISFIED, never a clean review the agent substitutes its own self-review for. v8: worktree is created under PortOS's shared worktrees dir (`{worktreesRoot}` → data/cos/worktrees) instead of a repo-relative `data/cos/worktrees/` path, so the agent's checkout no longer lands inside the managed app's working tree. v7: Phase 3 no longer releases/parks an *ambiguous* issue to `needs-input` — the agent decides (picks the most reasonable reading, records it in an issue comment, ships) rather than punting the choice back to a human; `needs-input` is reserved for destructive/irreversible or genuinely-human-gated (hardware/credentials) cases. Mirrors the "Decide, don't defer" policy in CLAUDE.md. v6: Phase 1 epic skip also recognizes a leading `[epic]` bracket or `Epic:` colon title tag (e.g. "[Epic] …" / "Epic: …"), not just an `epic` label or a "(epic)" suffix — mirrors the perpetualWork detector so a `[Epic]`-titled issue with no `epic` label stops re-spawning a claim agent that always skips it (perpetual drain now converges/parks). v5: per-kind reviewer bullets name `grok` alongside `claude`/`codex`/`antigravity` as a local-CLI reviewer (grok is now a selectable Review Loop reviewer). v4: Phase 5 chooses the issue trailer deliberately (Closes for a full ship, Refs + a `## Remaining` section for a partial one) and Phase 7 reconciles the issue with the partial-ship hybrid — close + file a scoped follow-up when the remainder is separable, else comment "done/remaining" + release the `in-progress` claim — so a partial ship is never left OPEN + `in-progress` (a zombie the claim queue skips forever). v3: Phase 3 tags an ambiguous/too-large issue `needs-input` (not just a comment) so it's excluded from future autonomous claims — required for `perpetual` (drain-until-done) mode to converge instead of re-picking the same un-actionable issue. v2: stop treating the bare `plan` label as a skip — `plan` is the claimable-queue label (do-replan --issues labels every migrated backlog item `plan`), so v1's exclusion emptied the whole actionable queue; now skip only true epics (`epic` label or "(epic)" title)
- 'claim-issue-gitlab': 18, // v18: explicit issue-page claims ignore existing assignees; auto-pick resolves the authenticated login so self-assigned issues remain retryable; open continuation handoffs clear in-progress and all assignees. v17: mirrors claim-issue v17 — the repo-conventions file is named `AGENTS.md` (or `CLAUDE.md`) (#4852). v16: the Phase 1 and Phase 6 glab recipes use `--output json` instead of `-F json`. On `glab issue list`, `-F` is `--output-format` (details|ids|urls) — a DIFFERENT flag from `--output` (text|json) — so that spelling was accepted, ignored, and answered with the human table at exit 0; an agent piping that to `jq` got nothing and could not distinguish it from "no issues". `--output json` is correct on every glab subcommand, so the mr recipes are normalized to the same spelling in this bump. v15: mirrors claim-issue v16 — Phase 1 step 4's blocking-label check is now the `{issueExcludeLabels}` placeholder. v14: mirrors claim-issue v15 — Phase 5 runs the LOCAL reviewers against the branch diff before any MR exists, Phase 6 opens the MR and satisfies the MR-SIDE reviewers + pipeline before merging. v12: follow-up issue recipes choose independent slashdo dispatch hints (`model:`/`effort:`) and contributor labels (`good first issue`/`help wanted`) instead of only `plan`. v11: claim worktree creation passes `--no-track`, so a branch based on the default-branch remote ref does not inherit it as an upstream; the later `git push -u` sets the intended branch upstream. v10: mirrors claim-issue v11 — every Phase-3 release converges (close the already-fixed/superseded issue, tag the stale-reference one `needs-input`) so the perpetual drain stops re-picking it. v9: mirrors claim-issue v10 — Phase 5's changelog step defers to the repo's documented convention (per-branch fragments) rather than prescribing a `.changelog/NEXT.md` append. v8: reviewer bullets name the antigravity reviewer's actual PATH binary (`agy`) — mirrors plan-task v12. The same bump adds the missing-binary guard: a reviewer whose CLI is not on PATH is UNSATISFIED, never a clean review the agent substitutes its own self-review for. v7: worktree is created under PortOS's shared worktrees dir (`{worktreesRoot}` → data/cos/worktrees) instead of a repo-relative `data/cos/worktrees/` path, so the agent's checkout no longer lands inside the managed app's working tree (mirrors claim-issue v8). v6: mirrors claim-issue v7 — Phase 3 decides an *ambiguous* issue (record the chosen reading in an issue note, ship) instead of parking it to `needs-input`, which is reserved for destructive/irreversible or genuinely-human-gated (hardware/credentials) cases. v5: mirrors claim-issue v6 — Phase 1 epic skip also recognizes a leading `[epic]` bracket or `Epic:` colon title tag (e.g. "[Epic] …" / "Epic: …"), not just an `epic` label or a "(epic)" suffix, so the GitLab detector/agent converge on epic-titled issues too. v4: per-kind reviewer bullets name `grok` alongside `claude`/`codex`/`antigravity` as a local-CLI reviewer (grok is now a selectable Review Loop reviewer). v3: mirrors claim-issue v4 — Phase 5 chooses Closes-vs-Refs deliberately and Phase 7 reconciles the issue with the partial-ship hybrid (close + scoped follow-up when separable, else "done/remaining" note + release the `in-progress` claim) so a partial ship is never stranded. v2: Phase 3 tags an ambiguous/too-large issue `needs-input` (mirrors claim-issue v3) so it's excluded from future autonomous claims — required for `perpetual` (drain-until-done) mode to converge. v1: GitLab sibling of claim-issue — same 7-phase /claim --issues flow over `glab` issues + merge requests. Reached via the claim-work router when an app's resolved workTracker is 'gitlab'.
- 'claim-issue-jira': 13, // v13: mirrors claim-issue v17 — the repo-conventions file is named `AGENTS.md` (or `CLAUDE.md`) (#4852). v12: mirrors claim-issue v15 in the JIRA flow — Phase 5 runs the LOCAL reviewers against the branch diff before the MR/PR is opened (and before the In Review transition), Phase 6 keeps only the PR-side reviewers plus the worktree cleanup. v10: follow-up tickets receive equivalent hyphenated dispatch (`model-*`/`effort-*`) and contributor (`good-first-issue`/`help-wanted`) labels when independently justified. v9: claim worktree creation passes `--no-track`, so a branch based on the default-branch remote ref does not inherit it as an upstream; the later `git push -u` sets the intended branch upstream. v8: mirrors claim-issue v11 in JIRA's status vocabulary — an already-fixed/superseded ticket transitions to Done/Closed and a stale-reference ticket parks on a Blocked/On Hold status behind a Review Hub todo, instead of transitioning back to a not-started status that Phase 1 immediately re-picks. v7: mirrors claim-issue v10 — Phase 5's changelog step defers to the repo's documented convention (per-branch fragments) rather than prescribing a `.changelog/NEXT.md` append. v6: reviewer bullets name the antigravity reviewer's actual PATH binary (`agy`) — mirrors plan-task v12. The same bump adds the missing-binary guard: a reviewer whose CLI is not on PATH is UNSATISFIED, never a clean review the agent substitutes its own self-review for. v5: worktree is created under PortOS's shared worktrees dir (`{worktreesRoot}` → data/cos/worktrees) instead of `{repoPath}/data/cos/worktrees/`, so the agent's checkout no longer lands inside the managed app's working tree (mirrors claim-issue v8). v4: mirrors claim-issue v7 — Phase 3 decides an *ambiguous* ticket (record the chosen reading in a ticket comment, ship) instead of parking it to a "Needs clarification" Review Hub todo, and Phase 1 no longer skips a merely-underspecified ticket; the todo is reserved for destructive/irreversible or genuinely-human-gated cases. v3: per-kind reviewer bullets name `grok` alongside `claude`/`codex`/`antigravity` as a local-CLI reviewer (grok is now a selectable Review Loop reviewer). v2: Phase 5 records remaining scope in the ticket (Done/Remaining comment) and files a follow-up ticket when a partial ship's remainder is separable, so remaining work isn't lost when a human lands the MR/PR. v1: JIRA sibling of claim-issue — claim ONE ready sprint ticket, move it To Do→In Progress→In Review around a self-managed worktree + MR/PR. Reached via the claim-work router when an app's resolved workTracker is 'jira' (replaces the prior jira→jira-sprint-manager route).
+ 'claim-issue': 21, // v21: an epic is no longer a dead end — Phase 1 treats an UNdecomposed epic as eligible (last-resort, after every atomic issue) and routes it to the new Phase 1b, which reuses an existing child split or files one (2–8 independently shippable slices, each `Part of #<epic>`), rewrites the epic body with a `## Decomposed into` checklist, stamps the `decomposed` label, and then claims the first slice. Phase 3's too-large branch decomposes instead of parking to `needs-input`. Before this, a queue holding only epics ended every run with nothing done. `decomposed` is the convergence marker the perpetualWork detector reads (isActionableIssue). v20: canonicalize GitHub's ssh.github.com SSH-over-443 alias before host-aware identity probes. v19: host-aware GitHub identity probes use the repository origin, and probe failures stay transient instead of parking an assigned-only queue. v18: explicit issue-page claims ignore existing assignees; auto-pick resolves the authenticated login so self-assigned issues remain retryable; open continuation handoffs clear in-progress and all assignees. v17: mirrors plan-task v17 — Phase 4 and Phase 5 name `AGENTS.md` (or `CLAUDE.md`) as the repo-conventions file (#4852). v16: Phase 1 step 4's blocking-label check is now the `{issueExcludeLabels}` placeholder (resolveIssueExcludeLabelsBlock, cosTaskGenerator.js) — the fixed NON_ACTIONABLE_ISSUE_LABELS set plus any app-configured `taskMetadata.issueExcludeLabels` extras (e.g. `good first issue`), so the live claim agent honors the same per-app exclusions the perpetual-drain detector applies, not just the hardcoded set. The pinned-target constraint (`/do:next <num>` / the work-item picker) also re-checks that resolved list, not just the fixed 3, so a target that gained an excluded label after the picker snapshot still isn't force-claimed. Phase 1's candidate fetch widened to `--limit 500` (was 100), matching perpetualWork.js's detector — the label filter runs on the fetched page, so a small cap risked missing eligible work further down a busy queue. v15: Phase 5 is now the pre-PR local review (LOCAL reviewers = every non-`@<login>` token, run against the branch diff; an unsatisfied one blocks PR creation entirely) and Phase 6 opens the PR, satisfies the PR-SIDE reviewers (`@<login>` plus any auto-requested review bot) and required CI, then merges. v13: follow-up issue recipes choose independent slashdo dispatch hints (`model:`/`effort:`) and contributor labels (`good first issue`/`help wanted`) instead of only `plan`. v12: claim worktree creation passes `--no-track`, so a branch based on `origin/main` cannot inherit `main` as its upstream and make a config-derived push write directly to the default branch; the later `git push -u` sets the intended branch upstream. v11: EVERY Phase-3 release now converges — the "already fixed / superseded" case CLOSES the issue (with a comment naming what delivered it) and the "stale reference" case tags `needs-input`, instead of both releasing the issue open and unlabeled. `isActionableIssue` (perpetualWork.js) can only see labels/assignees/epic/in-flight, so a body-or-comment-driven release left the issue looking actionable and the perpetual drain re-spawned a no-op agent on it every tick. v10: Phase 5's changelog step defers to the convention the repo documents (per-branch fragment directory + helper script when present) instead of prescribing an append to `.changelog/NEXT.md`. v9: reviewer bullets name the antigravity reviewer's actual PATH binary (`agy`) — mirrors plan-task v12. The same bump adds the missing-binary guard: a reviewer whose CLI is not on PATH is UNSATISFIED, never a clean review the agent substitutes its own self-review for. v8: worktree is created under PortOS's shared worktrees dir (`{worktreesRoot}` → data/cos/worktrees) instead of a repo-relative `data/cos/worktrees/` path, so the agent's checkout no longer lands inside the managed app's working tree. v7: Phase 3 no longer releases/parks an *ambiguous* issue to `needs-input` — the agent decides (picks the most reasonable reading, records it in an issue comment, ships) rather than punting the choice back to a human; `needs-input` is reserved for destructive/irreversible or genuinely-human-gated (hardware/credentials) cases. Mirrors the "Decide, don't defer" policy in CLAUDE.md. v6: Phase 1 epic skip also recognizes a leading `[epic]` bracket or `Epic:` colon title tag (e.g. "[Epic] …" / "Epic: …"), not just an `epic` label or a "(epic)" suffix — mirrors the perpetualWork detector so a `[Epic]`-titled issue with no `epic` label stops re-spawning a claim agent that always skips it (perpetual drain now converges/parks). v5: per-kind reviewer bullets name `grok` alongside `claude`/`codex`/`antigravity` as a local-CLI reviewer (grok is now a selectable Review Loop reviewer). v4: Phase 5 chooses the issue trailer deliberately (Closes for a full ship, Refs + a `## Remaining` section for a partial one) and Phase 7 reconciles the issue with the partial-ship hybrid — close + file a scoped follow-up when the remainder is separable, else comment "done/remaining" + release the `in-progress` claim — so a partial ship is never left OPEN + `in-progress` (a zombie the claim queue skips forever). v3: Phase 3 tags an ambiguous/too-large issue `needs-input` (not just a comment) so it's excluded from future autonomous claims — required for `perpetual` (drain-until-done) mode to converge instead of re-picking the same un-actionable issue. v2: stop treating the bare `plan` label as a skip — `plan` is the claimable-queue label (do-replan --issues labels every migrated backlog item `plan`), so v1's exclusion emptied the whole actionable queue; now skip only true epics (`epic` label or "(epic)" title)
+ 'claim-issue-gitlab': 19, // v19: mirrors claim-issue v21 — Phase 1b decomposes an undecomposed epic into per-slice issues (`Part of #<epic>`, `decomposed` marker label on the parent) and claims the first slice, and the too-large branch splits rather than parking. v18: explicit issue-page claims ignore existing assignees; auto-pick resolves the authenticated login so self-assigned issues remain retryable; open continuation handoffs clear in-progress and all assignees. v17: mirrors claim-issue v17 — the repo-conventions file is named `AGENTS.md` (or `CLAUDE.md`) (#4852). v16: the Phase 1 and Phase 6 glab recipes use `--output json` instead of `-F json`. On `glab issue list`, `-F` is `--output-format` (details|ids|urls) — a DIFFERENT flag from `--output` (text|json) — so that spelling was accepted, ignored, and answered with the human table at exit 0; an agent piping that to `jq` got nothing and could not distinguish it from "no issues". `--output json` is correct on every glab subcommand, so the mr recipes are normalized to the same spelling in this bump. v15: mirrors claim-issue v16 — Phase 1 step 4's blocking-label check is now the `{issueExcludeLabels}` placeholder. v14: mirrors claim-issue v15 — Phase 5 runs the LOCAL reviewers against the branch diff before any MR exists, Phase 6 opens the MR and satisfies the MR-SIDE reviewers + pipeline before merging. v12: follow-up issue recipes choose independent slashdo dispatch hints (`model:`/`effort:`) and contributor labels (`good first issue`/`help wanted`) instead of only `plan`. v11: claim worktree creation passes `--no-track`, so a branch based on the default-branch remote ref does not inherit it as an upstream; the later `git push -u` sets the intended branch upstream. v10: mirrors claim-issue v11 — every Phase-3 release converges (close the already-fixed/superseded issue, tag the stale-reference one `needs-input`) so the perpetual drain stops re-picking it. v9: mirrors claim-issue v10 — Phase 5's changelog step defers to the repo's documented convention (per-branch fragments) rather than prescribing a `.changelog/NEXT.md` append. v8: reviewer bullets name the antigravity reviewer's actual PATH binary (`agy`) — mirrors plan-task v12. The same bump adds the missing-binary guard: a reviewer whose CLI is not on PATH is UNSATISFIED, never a clean review the agent substitutes its own self-review for. v7: worktree is created under PortOS's shared worktrees dir (`{worktreesRoot}` → data/cos/worktrees) instead of a repo-relative `data/cos/worktrees/` path, so the agent's checkout no longer lands inside the managed app's working tree (mirrors claim-issue v8). v6: mirrors claim-issue v7 — Phase 3 decides an *ambiguous* issue (record the chosen reading in an issue note, ship) instead of parking it to `needs-input`, which is reserved for destructive/irreversible or genuinely-human-gated (hardware/credentials) cases. v5: mirrors claim-issue v6 — Phase 1 epic skip also recognizes a leading `[epic]` bracket or `Epic:` colon title tag (e.g. "[Epic] …" / "Epic: …"), not just an `epic` label or a "(epic)" suffix, so the GitLab detector/agent converge on epic-titled issues too. v4: per-kind reviewer bullets name `grok` alongside `claude`/`codex`/`antigravity` as a local-CLI reviewer (grok is now a selectable Review Loop reviewer). v3: mirrors claim-issue v4 — Phase 5 chooses Closes-vs-Refs deliberately and Phase 7 reconciles the issue with the partial-ship hybrid (close + scoped follow-up when separable, else "done/remaining" note + release the `in-progress` claim) so a partial ship is never stranded. v2: Phase 3 tags an ambiguous/too-large issue `needs-input` (mirrors claim-issue v3) so it's excluded from future autonomous claims — required for `perpetual` (drain-until-done) mode to converge. v1: GitLab sibling of claim-issue — same 7-phase /claim --issues flow over `glab` issues + merge requests. Reached via the claim-work router when an app's resolved workTracker is 'gitlab'.
+ 'claim-issue-jira': 14, // v14: mirrors claim-issue v21 in JIRA's vocabulary — Phase 1b splits an undecomposed Epic into child tickets linked with `epicKey`, stamps the `decomposed` label on the parent, and claims the first slice; the too-large branch decomposes instead of parking behind a Review Hub todo. v13: mirrors claim-issue v17 — the repo-conventions file is named `AGENTS.md` (or `CLAUDE.md`) (#4852). v12: mirrors claim-issue v15 in the JIRA flow — Phase 5 runs the LOCAL reviewers against the branch diff before the MR/PR is opened (and before the In Review transition), Phase 6 keeps only the PR-side reviewers plus the worktree cleanup. v10: follow-up tickets receive equivalent hyphenated dispatch (`model-*`/`effort-*`) and contributor (`good-first-issue`/`help-wanted`) labels when independently justified. v9: claim worktree creation passes `--no-track`, so a branch based on the default-branch remote ref does not inherit it as an upstream; the later `git push -u` sets the intended branch upstream. v8: mirrors claim-issue v11 in JIRA's status vocabulary — an already-fixed/superseded ticket transitions to Done/Closed and a stale-reference ticket parks on a Blocked/On Hold status behind a Review Hub todo, instead of transitioning back to a not-started status that Phase 1 immediately re-picks. v7: mirrors claim-issue v10 — Phase 5's changelog step defers to the repo's documented convention (per-branch fragments) rather than prescribing a `.changelog/NEXT.md` append. v6: reviewer bullets name the antigravity reviewer's actual PATH binary (`agy`) — mirrors plan-task v12. The same bump adds the missing-binary guard: a reviewer whose CLI is not on PATH is UNSATISFIED, never a clean review the agent substitutes its own self-review for. v5: worktree is created under PortOS's shared worktrees dir (`{worktreesRoot}` → data/cos/worktrees) instead of `{repoPath}/data/cos/worktrees/`, so the agent's checkout no longer lands inside the managed app's working tree (mirrors claim-issue v8). v4: mirrors claim-issue v7 — Phase 3 decides an *ambiguous* ticket (record the chosen reading in a ticket comment, ship) instead of parking it to a "Needs clarification" Review Hub todo, and Phase 1 no longer skips a merely-underspecified ticket; the todo is reserved for destructive/irreversible or genuinely-human-gated cases. v3: per-kind reviewer bullets name `grok` alongside `claude`/`codex`/`antigravity` as a local-CLI reviewer (grok is now a selectable Review Loop reviewer). v2: Phase 5 records remaining scope in the ticket (Done/Remaining comment) and files a follow-up ticket when a partial ship's remainder is separable, so remaining work isn't lost when a human lands the MR/PR. v1: JIRA sibling of claim-issue — claim ONE ready sprint ticket, move it To Do→In Progress→In Review around a self-managed worktree + MR/PR. Reached via the claim-work router when an app's resolved workTracker is 'jira' (replaces the prior jira→jira-sprint-manager route).
'pr-reviewer': 3, // v3: multi-stage pipeline (security scan → code review + merge)
'code-reviewer-a': 1, // v1: 2-stage pipeline (codebase review → triage & implement)
'code-reviewer-b': 1, // v1: 2-stage pipeline (codebase review → triage & implement)