Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (codex): preserve JIRA isolation in claim-work + tolerate GitLab subgroup remotes
[._.]/ Adam Eivy7820be73bd80
diff --git a/server/lib/README.md b/server/lib/README.mdindex cd4a77b0a8..b772e586f6 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -227,7 +227,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `sseUtils.js` | Per-job SSE stream helpers (imageGen + others) plus `createSseRunner` — the shared batch-runner lifecycle (runs map, terminal-frame replay, cancel, fire-and-forget coordinator) used by the pipeline completeness/analysis/checks runners. || `streamBackpressure.js` | `awaitWritableDrain(res)` — park a streaming-response producer on the socket's next `drain` (or `close`) when `res.write()` returned false, so SSE/NDJSON writes stay bounded for a slow reader. Shared by `routes/ask.js` (SSE) and `routes/localLlm.js` (NDJSON). || `uuid.js` | `v4()` thin wrapper over `crypto.randomUUID()`. |-| `workTracker.js` | `WORK_TRACKERS`/`CONCRETE_WORK_TRACKERS`/`DEFAULT_WORK_TRACKER`, `workTrackerLabel`, `hostToWorkTracker`, `forgeCliForTracker`, `trackerToClaimTaskType`, pure `resolveWorkTracker({configured,host})`, async `resolveAppWorkTracker(app)` — resolves a managed app's autonomous work source (PLAN.md / GitHub / GitLab / JIRA), defaulting `'auto'` to the git origin host. Consumed by the `claim-work` router in `cosTaskGenerator.js` and `routes/apps.js`. |+| `workTracker.js` | `WORK_TRACKERS`/`CONCRETE_WORK_TRACKERS`/`DEFAULT_WORK_TRACKER`, `workTrackerLabel`, `hostToWorkTracker`, `forgeCliForTracker`, `trackerToClaimTaskType`, `hostFromOriginUrl` (subgroup-tolerant host parse), pure `resolveWorkTracker({configured,host})`, async `resolveAppWorkTracker(app)` — resolves a managed app's autonomous work source (PLAN.md / GitHub / GitLab / JIRA), defaulting `'auto'` to the git origin host. Consumed by the `claim-work` router in `cosTaskGenerator.js` and `routes/apps.js`. || `workspaceRoots.js` | Shared allow-list for routes that take a caller-supplied filesystem path. `ALLOWED_WORKSPACE_ROOTS` (defaults + `PORTOS_WORKSPACE_ROOTS`, symlink-resolved), `isWithinRoot(resolvedPath, root)` (separator-safe containment), `isWithinAllowedRoots(realPath)`, and `WORKSPACE_ROOTS_CONFIGURED` (true when the operator set the env var — lets a permissive-by-default route like `routes/detect.js` opt into confinement). Used by `routes/commands.js` (always scoped) and `routes/detect.js` (scoped only when configured). || `zodCompat.js` | Zod 4 compatibility helpers. `partialWithoutDefaults(objectSchema)` — like `.partial()` but strips inner field defaults first, so a PATCH/update schema doesn't inject (and clobber) the stored values of fields the caller didn't send. Use for any update schema derived from a defaulted base. |diff --git a/server/lib/workTracker.js b/server/lib/workTracker.jsindex e894e64bca..6887c6b5f2 100644--- a/server/lib/workTracker.js+++ b/server/lib/workTracker.js@@ -14,7 +14,8 @@// running `git`). See server/services/cosTaskGenerator.js for the claim-work// router that consumes trackerToClaimTaskType.-import { getOriginInfo } from './gitRemote.js';+import { readOriginRemoteUrl, parseGitRemoteUrl } from './gitRemote.js';+import { parseGitRemote } from './gitForge.js';// Every selectable value (UI + Zod enum). `'auto'` is the default; the rest are// concrete sources.@@ -102,6 +103,18 @@ export function resolveWorkTracker({ configured, host } = {}) {return { configured: 'auto', resolved: 'plan', source: 'fallback' };}+/**+ * Extract just the host from a git origin URL. Tries the strict+ * owner/repo parser first (handles ssh:// scheme + ports), then falls back to+ * the GitLab-subgroup-tolerant parser (`group/subgroup/repo`) — otherwise a+ * subgroup remote yields no host and `'auto'` wrongly falls back to PLAN.md+ * instead of GitLab. Returns null for unparseable input.+ */+export function hostFromOriginUrl(url) {+ if (!url) return null;+ return parseGitRemoteUrl(url)?.host || parseGitRemote(url)?.host || null;+}+/*** Resolve a managed app's effective work tracker, reading its git origin host* when needed. Returns `{ configured, resolved, host, forge, source }` where@@ -112,8 +125,8 @@ export async function resolveAppWorkTracker(app) {const configured = app?.workTracker;let host = null;if (app?.repoPath) {- const info = await getOriginInfo(app.repoPath).catch(() => null);- host = info?.host || null;+ const url = await readOriginRemoteUrl(app.repoPath).catch(() => null);+ host = hostFromOriginUrl(url);}const base = resolveWorkTracker({ configured, host });return { ...base, host, forge: forgeCliForTracker(base.resolved) };diff --git a/server/lib/workTracker.test.js b/server/lib/workTracker.test.jsindex 95d8bc5c8a..9ace5ad753 100644--- a/server/lib/workTracker.test.js+++ b/server/lib/workTracker.test.js@@ -8,6 +8,7 @@ import {forgeCliForTracker,trackerToClaimTaskType,resolveWorkTracker,+ hostFromOriginUrl,} from './workTracker.js';describe('workTracker constants', () => {@@ -88,6 +89,32 @@ describe('resolveWorkTracker (pure)', () => {});});+describe('hostFromOriginUrl', () => {+ it('extracts the host from standard owner/repo remotes (ssh, scp, https)', () => {+ expect(hostFromOriginUrl('[email protected]:atomantic/PortOS.git')).toBe('github.com');+ expect(hostFromOriginUrl('https://github.com/atomantic/PortOS.git')).toBe('github.com');+ expect(hostFromOriginUrl('ssh://[email protected]:22/atomantic/PortOS.git')).toBe('github.com');+ });++ it('resolves the host for GitLab subgroup remotes (>2 path segments)', () => {+ // The strict owner/repo parser rejects these; the subgroup-tolerant+ // fallback must still surface the host so auto → GitLab (not PLAN.md).+ expect(hostFromOriginUrl('[email protected]:group/subgroup/repo.git')).toBe('gitlab.com');+ expect(hostFromOriginUrl('https://gitlab.example.com/group/sub/deep/repo.git')).toBe('gitlab.example.com');+ });++ it('returns null for empty / unparseable input', () => {+ expect(hostFromOriginUrl('')).toBeNull();+ expect(hostFromOriginUrl(null)).toBeNull();+ expect(hostFromOriginUrl('not a url')).toBeNull();+ });++ it('a subgroup GitLab remote resolves to the gitlab tracker end-to-end', () => {+ const host = hostFromOriginUrl('[email protected]:group/subgroup/repo.git');+ expect(resolveWorkTracker({ configured: 'auto', host }).resolved).toBe('gitlab');+ });+});+describe('workTrackerLabel', () => {it('returns a human label for every value, falling back to the raw value', () => {for (const t of WORK_TRACKERS) {diff --git a/server/services/cosTaskGenerator.js b/server/services/cosTaskGenerator.jsindex 086c7296fe..6d70ac7f30 100644--- a/server/services/cosTaskGenerator.js+++ b/server/services/cosTaskGenerator.js@@ -1286,6 +1286,19 @@ export async function generateManagedAppImprovementTaskForType(taskType, app, stconst wt = await resolveAppWorkTracker(app);promptTaskType = trackerToClaimTaskType(wt.resolved) || 'plan-task';emitLog('info', `claim-work for ${app.name}: tracker=${wt.resolved} (${wt.source}) → ${promptTaskType}`, { appId: app.id, analysisType: taskType });+ // Inherit the resolved flow's isolation posture, overriding claim-work's+ // own useWorktree/openPR=false defaults. The plan/github/gitlab claim+ // prompts self-manage their worktree + PR (false/false is correct), but+ // jira-sprint-manager relies on CoS-MANAGED isolation (useWorktree/openPR+ // true) and implements directly in {repoPath} — so without this the JIRA+ // route would run against the live checkout. Pull the delegated type's+ // managed-agent defaults; a prompt-only type with no DEFAULT_TASK_INTERVALS+ // entry (e.g. claim-issue-gitlab) keeps claim-work's self-managed false.+ const delegatedMeta = taskSchedule.DEFAULT_TASK_INTERVALS[promptTaskType]?.taskMetadata;+ if (delegatedMeta) {+ if ('useWorktree' in delegatedMeta) metadata.useWorktree = delegatedMeta.useWorktree;+ if ('openPR' in delegatedMeta) metadata.openPR = delegatedMeta.openPR;+ }}// Honor a direct claim-work prompt customization if the user set one;// otherwise delegate to the resolved tracker's prompt body viadiff --git a/server/services/cosTaskGenerator.test.js b/server/services/cosTaskGenerator.test.jsindex b03a2f2090..7726a1be60 100644--- a/server/services/cosTaskGenerator.test.js+++ b/server/services/cosTaskGenerator.test.js@@ -110,6 +110,15 @@ describe('claim-work single-source routing', () => {expect(GEN_SRC).toContain("promptTaskType === 'claim-issue-gitlab' ? 'glab'");expect(GEN_SRC).toContain('glab issue list');});++ it('inherits the delegated flow isolation posture so the JIRA route keeps CoS worktree+PR', () => {+ // claim-work forces useWorktree/openPR=false (correct for the self-managing+ // plan/github/gitlab claim prompts) but jira-sprint-manager needs CoS-managed+ // isolation — pull the delegated type's DEFAULT_TASK_INTERVALS metadata.+ expect(GEN_SRC).toContain('taskSchedule.DEFAULT_TASK_INTERVALS[promptTaskType]?.taskMetadata');+ expect(GEN_SRC).toContain("'useWorktree' in delegatedMeta");+ expect(GEN_SRC).toContain("'openPR' in delegatedMeta");+ });});describe('exceedsMaxSpawns', () => {