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

fix: respect explicit issue claims

[._.]/ Adam Eivy32b4d05e08fc
diff --git a/server/services/cosTaskGenerator.test.js b/server/services/cosTaskGenerator.test.js
index 54c2c8123c..6873e3096f 100644
--- a/server/services/cosTaskGenerator.test.js
+++ b/server/services/cosTaskGenerator.test.js
@@ -579,6 +579,8 @@ describe('work-item target', () => {
it('falls back to the fixed 3-label text when no excludeLabelsBlock is passed', () => {
const block = buildTargetWorkItemBlock('claim-issue', '42');
expect(block).toContain('already carries any of `in-progress`, `blocked`, `needs-input`');
+ expect(block).toContain('ignore its current assignee');
+ expect(block).not.toContain('already assigned');
});
it('re-checks the SAME resolved exclude-labels list Phase 1 uses, not just the fixed 3, so a pinned target can\'t bypass a configured exclusion (e.g. a stale picker selection that gained the label after being selected)', () => {
diff --git a/server/services/cosTaskPrompts.js b/server/services/cosTaskPrompts.js
index bfb75abfcf..eb84a3fd40 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}, and ignore the author filter above (an explicit selection overrides it). Still honor the safety checks: if #${ref} is already closed, already assigned, 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, is a tracking epic, or is stale (Phase 3), exit cleanly rather than forcing it. Otherwise run Phases 2–7 against #${ref}.`;
};
const TARGET_ITEM_BLOCKS = {
diff --git a/server/services/perpetualWork.js b/server/services/perpetualWork.js
index e15219b996..9e76c13d98 100644
--- a/server/services/perpetualWork.js
+++ b/server/services/perpetualWork.js
@@ -186,10 +186,12 @@ export function titleMarksEpic(title) {
}
/**
- * Decide whether a single GitHub issue (as returned by `gh issue list --json`)
+ * 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 assignees, no blocking label, not an
- * epic. Exported for direct unit testing.
+ * 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.
*
* `excludeLabels` is the app's configured `issueExcludeLabels`
* (`taskMetadata.issueExcludeLabels`) — extra labels a user wants left for
@@ -197,10 +199,21 @@ export function titleMarksEpic(title) {
* `NON_ACTIONABLE_ISSUE_LABELS`, never replacing it: the base set is
* structural (in-progress/blocked/etc.), not user-configurable.
*/
-export function isActionableIssue(issue, inFlight = new Set(), excludeLabels = null) {
+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;
- if (Array.isArray(issue.assignees) && issue.assignees.length > 0) return false;
+ const assignees = Array.isArray(issue.assignees) ? issue.assignees : [];
+ const normalizedCurrentLogin = normalizeLogin(currentLogin);
+ const hasOtherAssignee = assignees.length > 0 && (
+ !normalizedCurrentLogin || !assignees.some((assignee) => assigneeLogin(assignee) === normalizedCurrentLogin)
+ );
+ if (hasOtherAssignee) return false;
const labels = (Array.isArray(issue.labels) ? issue.labels : [])
.map((l) => (typeof l === 'string' ? l : l?.name) || '')
.map((s) => s.toLowerCase());
@@ -314,7 +327,9 @@ const FORGE_ISSUE_CONFIG = {
return { owner, isOrg: parsed?.isInOrganization === true };
},
// `--self` mode: gh natively understands the `@me` token for `--author`, so
- // no extra lookup is needed — the API resolves it to the authenticated user.
+ // no author-filter lookup is needed — the API resolves it to the authenticated
+ // user. `selfLoginArgs` still resolves that account when assigned issues need
+ // the self-assignee retry check (and seeds collaborator mode).
resolveSelf: async () => ({ author: '@me' }),
// `collaborators` mode: you + everyone with repo access. `{owner}`/`{repo}`
// are gh's own placeholders, resolved from the checked-out remote. A 403 here
@@ -373,8 +388,9 @@ const FORGE_ISSUE_CONFIG = {
return { owner: namespace, isOrg: probe.code === 0 };
},
// `--self` mode: glab's `--author` expects a username (no `@me` token), so
- // resolve the authenticated account via the API; transient if glab is
- // unauthenticated / unreachable.
+ // resolve the authenticated account via the API; the same lookup also powers
+ // the self-assignee retry check. It is transient if glab is unauthenticated
+ // or unreachable.
resolveSelf: async (repoPath) => {
const { login, error } = await resolveAuthenticatedLogin('glab', GLAB_SELF_LOGIN_ARGS, repoPath);
return error ? { error } : { author: login };
@@ -567,7 +583,14 @@ async function detectForgeIssues(forgeKey, app, { issueAuthorFilter = 'self', is
return parked('no-open-issues');
}
- const inFlight = await inFlightIssueNumbers(repoPath, cfg.inFlightForge);
+ const hasAssignedIssue = issues.some((issue) => Array.isArray(issue.assignees) && issue.assignees.length > 0);
+ const [inFlight, currentLoginResult] = await Promise.all([
+ inFlightIssueNumbers(repoPath, cfg.inFlightForge),
+ hasAssignedIssue
+ ? resolveAuthenticatedLogin(cfg.cli, cfg.selfLoginArgs, repoPath)
+ : Promise.resolve({ login: null })
+ ]);
+ const currentLogin = currentLoginResult.login || null;
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
@@ -578,7 +601,7 @@ async function detectForgeIssues(forgeKey, app, { issueAuthorFilter = 'self', is
const excludeSet = Array.isArray(issueExcludeLabels) && issueExcludeLabels.length > 0
? new Set(issueExcludeLabels.map((l) => String(l).toLowerCase()))
: null;
- const actionable = issues.filter((issue) => isActionableIssue(issue, inFlight, excludeSet));
+ const actionable = issues.filter((issue) => isActionableIssue(issue, inFlight, excludeSet, currentLogin));
const filteredCount = Math.max(0, total - actionable.length - inFlightCount);
return {
actionable: actionable.length > 0,
diff --git a/server/services/perpetualWork.test.js b/server/services/perpetualWork.test.js
index bce2a1fe43..5483f7b85c 100644
--- a/server/services/perpetualWork.test.js
+++ b/server/services/perpetualWork.test.js
@@ -60,6 +60,12 @@ describe('perpetualWork', () => {
expect(isActionableIssue({ ...base, assignees: [{ login: 'someone' }] })).toBe(false);
});
+ it('accepts an issue assigned to the authenticated account', () => {
+ expect(isActionableIssue({ ...base, assignees: [{ login: 'Alice' }] }, new Set(), null, 'alice')).toBe(true);
+ expect(isActionableIssue({ ...base, assignees: [{ username: 'ALICE' }] }, new Set(), null, 'alice')).toBe(true);
+ expect(isActionableIssue({ ...base, assignees: [{ login: 'bob' }] }, new Set(), null, 'alice')).toBe(false);
+ });
+
it('rejects an in-flight issue number', () => {
expect(isActionableIssue(base, new Set([7]))).toBe(false);
});
@@ -246,6 +252,20 @@ describe('perpetualWork', () => {
expect(out.filteredCount).toBe(7); // the epic (#1) + 6 needs-input/blocked
});
+ it('keeps an issue assigned to the authenticated account claimable', async () => {
+ spawn.mockImplementation((cmd, args = []) => {
+ if (cmd === 'gh' && args[0] === 'api' && args.includes('user')) return fakeChild('alice\n');
+ if (cmd === 'gh' && args[0] === 'issue') return fakeChild(JSON.stringify([{
+ number: 3, title: 'retry my claim', assignees: [{ login: 'alice' }], labels: []
+ }]));
+ if (cmd === 'git' && args[0] === 'branch') return fakeChild('main\n');
+ if (cmd === 'gh' && args[0] === 'pr') return fakeChild('');
+ return fakeChild('');
+ });
+ const out = await detectGithubIssues(app, { issueAuthorFilter: 'any' });
+ expect(out).toMatchObject({ actionable: true, count: 1, sample: [3] });
+ });
+
it('reports the open/in-flight breakdown when nothing is claimable (the "40 open but parked" case)', async () => {
routeSpawn({
'gh issue': { stdout: JSON.stringify([
@@ -544,6 +564,17 @@ describe('perpetualWork', () => {
expect(out.sample).toEqual([10]);
});
+ it('keeps an issue assigned to the authenticated account claimable', async () => {
+ routeSpawn({
+ 'glab api': { stdout: 'octo\n' }, // glab api user -q .username
+ 'glab issue': { stdout: JSON.stringify([{ iid: 10, title: 'retry my claim', assignees: [{ username: 'octo' }], labels: [] }]) },
+ 'git branch': { stdout: 'main\n' },
+ 'glab mr': { stdout: '[]' }
+ });
+ const out = await detectGitlabIssues(app, { issueAuthorFilter: 'any' });
+ expect(out).toMatchObject({ actionable: true, count: 1, sample: [10] });
+ });
+
it('reports a transient failure when glab exits non-zero', async () => {
routeSpawn({ 'glab issue': { stdout: '', code: 1 } });
const out = await detectGitlabIssues(app, { issueAuthorFilter: 'any' });
diff --git a/server/services/taskPromptDefaults.test.js b/server/services/taskPromptDefaults.test.js
index 46d01be93a..84dc691952 100644
--- a/server/services/taskPromptDefaults.test.js
+++ b/server/services/taskPromptDefaults.test.js
@@ -598,6 +598,23 @@ describe('taskPromptDefaults integrity snapshot', () => {
expect(DEFAULT_TASK_PROMPTS['claim-issue']).toContain('--limit 500');
expect(DEFAULT_TASK_PROMPTS['claim-issue']).not.toContain('--limit 100');
});
+
+ it('claim flows retry self-assigned issues and release every open-claim marker', () => {
+ const github = DEFAULT_TASK_PROMPTS['claim-issue'];
+ const gitlab = DEFAULT_TASK_PROMPTS['claim-issue-gitlab'];
+
+ expect(PROMPT_VERSIONS['claim-issue']).toBe(18);
+ expect(PROMPT_VERSIONS['claim-issue-gitlab']).toBe(18);
+ expect(github).toContain('authenticated account remains eligible for a retry');
+ expect(github).toContain('at least one assignee\'s login matches `$ME`');
+ expect(github).toContain('--remove-assignee "${ASSIGNEES:-@me}"');
+ expect(gitlab).toContain('authenticated account remains eligible for a retry');
+ expect(gitlab).toContain('at least one assignee\'s username matches `$ME`');
+ expect(gitlab).toContain('--unassign --unlabel in-progress');
+ expect(gitlab).toContain('clears every current assignee');
+ expect(PREVIOUS_DEFAULT_PROMPTS['claim-issue'].at(-1)).toContain('It has NO assignees');
+ expect(PREVIOUS_DEFAULT_PROMPTS['claim-issue-gitlab'].at(-1)).toContain('It has NO assignees');
+ });
// #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
diff --git a/server/services/taskPromptDefaults/integrity.snapshot.json b/server/services/taskPromptDefaults/integrity.snapshot.json
index 540a49b6d9..88bb84bf1f 100644
--- a/server/services/taskPromptDefaults/integrity.snapshot.json
+++ b/server/services/taskPromptDefaults/integrity.snapshot.json
@@ -16,8 +16,8 @@
"feature-ideas": "d3282f16da29efe2d53595b3b34778bc",
"plan-feature": "b20980c8eda2256060d09d4bca397244",
"plan-task": "910802d67f3b5a785f068f4d90178543",
- "claim-issue": "542ce3673abbdee93e895f9df660aaf7",
- "claim-issue-gitlab": "348ed6348b90dcc6eead03e06df049e9",
+ "claim-issue": "a91b3df45864cf1aeaea7b326a7717ae",
+ "claim-issue-gitlab": "1f9ec476dce71d04e588d17e72cd46c9",
"claim-issue-jira": "c66170bfcdee911f03e60261c4f503db",
"code-reviewer-review": "27ded42013f28e7d327d8f1cc624aac1",
"code-reviewer-implement": "2e10cac7c1e1cd021d06bfddb5c1eaf2",
@@ -42,8 +42,8 @@
"do-replan": 2,
"feature-ideas": 10,
"plan-task": 17,
- "claim-issue": 17,
- "claim-issue-gitlab": 17,
+ "claim-issue": 18,
+ "claim-issue-gitlab": 18,
"claim-issue-jira": 13,
"pr-reviewer": 3,
"code-reviewer-a": 1,
@@ -139,7 +139,8 @@
"d8fe2bf614b465ca46108ea3295d2ec5",
"7ff928b2560ed6bb1a96dbbc80142ed9",
"eed428fc96a8a58ee94d38e6e4896932",
- "ed2c2c9c8cd6297340b3a92666cb2c5a"
+ "ed2c2c9c8cd6297340b3a92666cb2c5a",
+ "348ed6348b90dcc6eead03e06df049e9"
],
"claim-issue": [
"37949d1b1fa8d461a15658f8f4192d97",
@@ -157,7 +158,8 @@
"0ffd94e6c7966e5ce457effea63f71d3",
"dc47a602c96b0618e7bca87e6b21c397",
"50e21cbaece1875f118d3a0f1a25da81",
- "5bcaf3230a7a46ee039404943feab187"
+ "5bcaf3230a7a46ee039404943feab187",
+ "542ce3673abbdee93e895f9df660aaf7"
],
"security": [
"d0f54c1fbe62d067b1a23ee0a9f3528c"
diff --git a/server/services/taskPromptDefaults/previousDefaults.js b/server/services/taskPromptDefaults/previousDefaults.js
index 20a7b8da27..21246ac571 100644
--- a/server/services/taskPromptDefaults/previousDefaults.js
+++ b/server/services/taskPromptDefaults/previousDefaults.js
@@ -6487,6 +6487,142 @@ If \`git branch -d\` refuses, fetch the default branch and re-check the MR's mer
- **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\`.
+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.`,
+ // v17 default retained before the current assignee-claim change
+ `[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 already assigned to someone OR carries an \`in-progress\` label. 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).
+ 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 (an assignee means another machine/human already claimed it).
+ - 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\`.
+
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.`,
],
// claim-issue v1 default — excluded every `plan`-labelled issue (the entire
@@ -8526,6 +8662,147 @@ If \`git branch -d\` refuses, fetch the default branch and re-check the PR's rem
- **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: \`gh issue edit "\${NUM}" --remove-label in-progress --remove-assignee @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.`,
+ // v17 default retained before the current assignee-claim change
+ `[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 already assigned to someone OR carries an \`in-progress\` label. 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.
+ 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 (an assignee means another machine/human already claimed it).
+ - 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: \`gh issue edit "\${NUM}" --remove-label in-progress --remove-assignee @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.`,
],
// Basic self-improvement tasks: prior defaults that hardcoded the target app as
diff --git a/server/services/taskPromptDefaults/prompts.js b/server/services/taskPromptDefaults/prompts.js
index f619d50223..bada2a6905 100644
--- a/server/services/taskPromptDefaults/prompts.js
+++ b/server/services/taskPromptDefaults/prompts.js
@@ -847,7 +847,7 @@ Pick the next available unclaimed open GitHub issue, **create your own worktree
{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 already assigned to someone OR carries an \`in-progress\` label. 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.
+**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
@@ -864,6 +864,9 @@ Run steps 1–5 in order.
# --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.
+ ME="$(gh api 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.
@@ -876,7 +879,7 @@ Run steps 1–5 in order.
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 (an assignee means another machine/human already claimed it).
+ - 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.
@@ -980,7 +983,9 @@ If \`git branch -d\` refuses, fetch the default branch and re-check the PR's rem
**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: \`gh issue edit "\${NUM}" --remove-label in-progress --remove-assignee @me\`.
+- **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.`,
@@ -997,7 +1002,7 @@ Pick the next available unclaimed open GitLab issue, **create your own worktree
{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 already assigned to someone OR carries an \`in-progress\` label. The \`claim/issue-<num>\` branch + the assignee/\`in-progress\` markers you set ARE the claim, visible to every other agent (including parallel machines).
+**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
@@ -1008,6 +1013,9 @@ Run steps 1–5 in order.
\`\`\`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.
\`\`\`
@@ -1019,7 +1027,7 @@ Run steps 1–5 in order.
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 (an assignee means another machine/human already claimed it).
+ - 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.
@@ -1124,7 +1132,7 @@ If \`git branch -d\` refuses, fetch the default branch and re-check the MR's mer
**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\`.
++ **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.`,
diff --git a/server/services/taskPromptDefaults/versions.js b/server/services/taskPromptDefaults/versions.js
index 6d11dea57d..ec8bd61c61 100644
--- a/server/services/taskPromptDefaults/versions.js
+++ b/server/services/taskPromptDefaults/versions.js
@@ -12,8 +12,8 @@ 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': 17, // 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': 17, // 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': 17, // 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': 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 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).
'pr-reviewer': 3, // v3: multi-stage pipeline (security scan → code review + merge)
'code-reviewer-a': 1, // v1: 2-stage pipeline (codebase review → triage & implement)