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

address review (codex): resolve nested GitLab subgroup namespaces before the group probe

[._.]/ Adam Eivyd771295cdaef
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 727cfc6a28..779eed5f54 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -6,7 +6,7 @@
## Changed
-- `[issue-2651]` The CoS `claim-issue-gitlab` work detector now short-circuits the group-owner filter trap the same way `claim-issue` handles a GitHub org owner. A GitLab group-owned project's namespace is the group, which never authors issues, so `owner` author-filter mode previously found nothing and parked with the vague `no-authored-issues` reason. GitLab's owner resolver now probes `glab api groups/<namespace>` (200 = group, 404 = user namespace) and, for a group, skips the guaranteed-empty `--author <group>` query and parks with a distinct `owner-is-group` reason carrying the real open count. The on-demand toast reads *"the \"owner\" filter matches a group, which can't author issues — set it to \"self\" or \"any\""* — GitLab-appropriate wording ("group", not "org"). A probe failure degrades to the pre-existing behavior, so no new transient park appears.
+- `[issue-2651]` The CoS `claim-issue-gitlab` work detector now short-circuits the group-owner filter trap the same way `claim-issue` handles a GitHub org owner. A GitLab group-owned project's namespace is the group, which never authors issues, so `owner` author-filter mode previously found nothing and parked with the vague `no-authored-issues` reason. GitLab's owner resolver now resolves the full project namespace (including nested subgroups like `parent/subgroup`) and probes `glab api groups/<url-encoded-namespace>` (200 = group, 404 = user namespace); for a group it skips the guaranteed-empty `--author <group>` query and parks with a distinct `owner-is-group` reason carrying the real open count. The on-demand toast reads *"the \"owner\" filter matches a group, which can't author issues — set it to \"self\" or \"any\""* — GitLab-appropriate wording ("group", not "org"). A probe failure degrades to the pre-existing behavior, so no new transient park appears.
- Agent triage policy is now "decide, don't defer": when a follow-up's only obstacle is an undecided design choice, agents make the call themselves (state it as the decision in the issue body) and file it ready-to-work rather than parking it as a decision-blocked `future`/`needs-input` issue. `future` is reserved for work a human must personally drive — a real validation run or a step needing specific hardware/credentials — which is now marked `blocked`, not `future`. Encoded in CLAUDE.md ("Decide, don't defer"), the Layered Intelligence proposal playbook, and every claim-work scheduled-task prompt — `claim-issue` (v7), `claim-issue-gitlab` (v6), `claim-issue-jira` (v4), and `plan-task` (v10): the verify phase no longer parks an *ambiguous* item (a `needs-input` label, a "Needs clarification" JIRA todo, or a `.plan-questions.md` clarification PR) and re-picks — it decides on the most reasonable reading, records it in a comment/note/commit, and ships; the park is now reserved for destructive/irreversible or genuinely human-gated cases (a genuinely too-large item still parks so the autonomous drain converges).
diff --git a/server/services/perpetualWork.js b/server/services/perpetualWork.js
index 42676668d8..20192c0c48 100644
--- a/server/services/perpetualWork.js
+++ b/server/services/perpetualWork.js
@@ -27,7 +27,7 @@ import { readFile } from 'fs/promises';
import { join } from 'path';
import { emitLog } from './cosEvents.js';
import { parsePlanItems, extractAllIds, findInProgressIds, pickFirstAvailable, extractSlugFromRef } from '../lib/planIds.js';
-import { readOriginRemoteUrl, parseGitRemoteUrl } from '../lib/gitRemote.js';
+import { readOriginRemoteUrl } from '../lib/gitRemote.js';
// 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
@@ -73,16 +73,36 @@ export function issueNumberFromRef(ref) {
}
/**
- * Resolve the repo owner from the git origin remote (host-agnostic — works for
- * GitHub and GitLab). For a personal repo the owner segment is the user; for an
- * org/group it's the org/group name. The GitHub detector prefers the
- * authoritative `gh repo view` owner instead; this is used for GitLab, whose
- * claim prompt resolves the author filter from the project namespace.
+ * Resolve the FULL GitLab project namespace (every path segment before the final
+ * repo segment) from the git origin remote — INCLUDING nested subgroups. The
+ * shared `parseGitRemoteUrl` only accepts a two-segment `owner/repo`, so a
+ * subgroup-nested project (`parent/subgroup/project`) resolves to null there and
+ * never reaches the group probe below; parse the raw path here so nested subgroups
+ * get the same owner-is-group short-circuit as a top-level group. GitLab subgroups
+ * are the common layout, so this is the difference between the short-circuit
+ * working and silently never firing for real GitLab projects. Returns null when
+ * there's no origin remote or the URL has no namespace segment (a bare `repo`).
+ * For a single-owner remote (`alice/repo`) this returns just `alice`, so the
+ * user-namespace `--author` path keeps its old value.
*/
-async function resolveRemoteOwner(repoPath) {
+async function resolveGitlabNamespace(repoPath) {
const url = await readOriginRemoteUrl(repoPath).catch(() => null);
- const parsed = url ? parseGitRemoteUrl(url) : null;
- return parsed?.owner || null;
+ if (typeof url !== 'string' || !url.trim()) return null;
+ // Strip `scheme://`, an optional `user@`, and a trailing `.git`, then split off
+ // the host (the segment before the first ':' or '/') to leave the repo path.
+ const afterHostPrefix = url.trim()
+ .replace(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//, '')
+ .replace(/^[^@/]+@/, '')
+ .replace(/\.git$/i, '');
+ const sepIdx = afterHostPrefix.search(/[:/]/);
+ if (sepIdx === -1) return null;
+ const rawPath = afterHostPrefix.slice(sepIdx + 1)
+ .replace(/^\/+/, '') // strip leading slash(es) after `host:` / `host/`
+ .replace(/^\d+\//, ''); // strip an SSH `host:443/owner/repo` port hop
+ const segments = rawPath.split('/').filter(Boolean);
+ if (segments.length < 2) return null; // need at least namespace + repo
+ segments.pop(); // drop the repo segment; the rest is the (possibly nested) namespace
+ return segments.join('/');
}
/**
@@ -214,17 +234,20 @@ const FORGE_ISSUE_CONFIG = {
// GitLab has no authoritative `gh repo view` equivalent here; resolve the
// author filter from the project namespace (git remote owner), matching the
// claim-issue-gitlab prompt. GitLab can't tell a user namespace from a GROUP
- // namespace from the remote URL alone, so probe: `glab api groups/<namespace>`
- // returns 200 for a group and 404 for a user namespace. A group is never an
- // issue author, so populate `isOrg: true` for groups and let detectForgeIssues
- // fire the same owner-filter short-circuit GitHub uses — no new branch logic.
- // A probe failure (network/unauth/non-200) degrades to isOrg:false → the
- // pre-existing `--author <owner>` behavior, so no new transient park appears.
+ // (or nested subgroup) from the remote URL alone, so probe:
+ // `glab api groups/<url-encoded-namespace>` returns 200 for a group/subgroup
+ // and 404 for a user namespace. A group is never an issue author, so populate
+ // `isOrg: true` for groups and let detectForgeIssues fire the same owner-filter
+ // short-circuit GitHub uses — no new branch logic. The namespace is URL-encoded
+ // so a nested subgroup path (`parent/subgroup`) hits the group endpoint as
+ // `groups/parent%2Fsubgroup`. A probe failure (network/unauth/non-200) degrades
+ // to isOrg:false → the pre-existing `--author <owner>` behavior, so no new
+ // transient park appears.
resolveOwner: async (repoPath) => {
- const owner = await resolveRemoteOwner(repoPath);
- if (!owner) return { error: 'glab-owner-unresolved' };
- const probe = await runCli('glab', ['api', `groups/${owner}`], repoPath);
- return { owner, isOrg: probe.code === 0 };
+ const namespace = await resolveGitlabNamespace(repoPath);
+ if (!namespace) return { error: 'glab-owner-unresolved' };
+ const probe = await runCli('glab', ['api', `groups/${encodeURIComponent(namespace)}`], repoPath);
+ 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
diff --git a/server/services/perpetualWork.test.js b/server/services/perpetualWork.test.js
index 099c1a1cb5..9657d0f352 100644
--- a/server/services/perpetualWork.test.js
+++ b/server/services/perpetualWork.test.js
@@ -461,6 +461,25 @@ describe('perpetualWork', () => {
expect(issueCalls.every(([, a]) => !a.includes('--author'))).toBe(true);
});
+ it('owner filter on a nested SUBGROUP project resolves the full namespace and reports owner-is-group', async () => {
+ // Nested subgroups are the common GitLab layout: parseGitRemoteUrl rejects a
+ // >2-segment remote, so the namespace must be resolved from the raw path and
+ // URL-encoded (`parent/subgroup` → `parent%2Fsubgroup`) before the group probe.
+ spawn.mockImplementation((cmd, args = []) => {
+ if (cmd === 'git' && args[0] === 'remote') return fakeChild('[email protected]:parent/subgroup/widget.git\n');
+ if (cmd === 'glab' && args[0] === 'api' && String(args[1]).startsWith('groups/')) return fakeChild('{"kind":"group"}');
+ if (cmd === 'glab' && args[0] === 'issue') return fakeChild(JSON.stringify([{ iid: 9, title: 'x', assignees: [], labels: [] }]));
+ return fakeChild('');
+ });
+ const out = await detectGitlabIssues(app, { issueAuthorFilter: 'owner' });
+ expect(out).toMatchObject({ reason: 'owner-is-group', total: 1, count: 0 });
+ const probeCall = spawn.mock.calls.find(([cmd, a]) => cmd === 'glab' && a[0] === 'api' && String(a[1]).startsWith('groups/'));
+ expect(probeCall[1][1]).toBe('groups/parent%2Fsubgroup');
+ // Never issues the guaranteed-empty `--author <group>` query.
+ const issueCalls = spawn.mock.calls.filter(([cmd, a]) => cmd === 'glab' && a[0] === 'issue');
+ expect(issueCalls.every(([, a]) => !a.includes('--author'))).toBe(true);
+ });
+
it('owner filter on a USER-owned project passes --author <namespace> (groups probe 404)', async () => {
// A user namespace: `glab api groups/<namespace>` 404s (non-zero exit) → not
// a group, so owner-mode filters by the namespace login as before.