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
fix: honor an app's forge pin in the issue-reconcile scan, not just its Issues tab (#3767)
[._.]/ Adam Eivy02d401e87a7e
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 77f8b719d8..7425d75f58 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -42,3 +42,5 @@- **Arc verification now banks the fixes that worked instead of discarding a whole round for one bad edit.** The gate resolved its blocking findings as a single rewrite: every finding went to the resolver in one call, and the next check kept or reverted that candidate as a unit. So a rewrite that cleanly closed two problems and broke a third was thrown away in full, and the gate ended up holding nothing — on the observed run it reached a verified best of 2 blockers, watched the next pass come back with 5 and the corrective retry with 3, correctly preserved the 2-blocker draft both times, and then paused for review with seven of its twelve permitted rounds unspent. The rollback guard is unchanged and still refuses any candidate that grows the blocking set or worsens its severity mix. What is new is what happens after the corrective retry is spent: when the residual has more than one finding, the gate now takes it apart and tries the findings one at a time from the best verified plan. Each attempt is its own transaction — snapshot, resolve that one finding, re-run the same verification the gate uses, and keep the edit only when the finding it targeted is actually gone and what it left behind is not a regression by the same count-then-severity rule the whole-round guard applies — so which trades survive no longer depends on which tier judged them. Anything else is restored on the spot, so a poisoned finding now costs only its own attempt instead of its neighbours' repairs, and the surviving fixes are re-verified together before the gate is allowed to clear. Closure is judged the same way the rollback guard judges identity, so a verifier that merely restates a standing problem in fresh words can't pass as a fix. The pass is bounded by a spend budget counted in provider calls — so a wide series, whose every check costs one call per volume, gets fewer attempts rather than a proportionally larger bill — skipped when only one finding is left (that is the corrective retry again, at twice the price), never run without a round left to verify what it kept, capped per run by `maxArcIsolationAttempts`, and switched off entirely by that or by `maxArcResolveRetries: 0`. The dry-run plan now includes its worst case, so the estimate you approve a run from still bounds the gate. The live status line reports each isolated attempt and whether it was kept.- **The rollback comparison now ignores write-path-owned fields on every kind of canon entry, not just characters.** The fix that stopped a faithful foundation rollback from reporting itself as a corrupted checkpoint stripped the server-owned per-entry fields (the LWW timestamp and the sheet/render pointers) from `characters` only, which happened to be the sole canon array the foundation snapshot tracked. The universe write path stamps those fields across characters, places, and objects alike, so extending the snapshot to worldbuilding canon would have quietly brought the same bogus "restored foundation fields did not match the checkpoint" pause back with no test to catch it. The comparison now walks every canon array the story bible defines, and the universe write path's three separate hardcoded copies of that list were collapsed onto the shared one so a future canon kind flows through instead of being silently skipped by the timestamp stamper.++- **A managed app pinned to a self-hosted GitHub/GitLab is now reconciled the same way its Issues tab lists it.** When an app's work tracker is explicitly set to GitHub or GitLab, that pin lets PortOS query a forge whose hostname spells out neither `github.` nor `gitlab.` — a self-hosted Enterprise/GitLab instance can live on any domain the operator picked. The app's Issues tab honored the pin, but the background zombie/park reconciler that feeds scheduled CoS tasks still classified the origin from its hostname alone, so it silently treated the very same repo as "not a forge" and skipped every scan. Both paths now go through one composed resolver that carries the pin, so the tab and the scan can't drift again: threading it by hand is invisible on an ordinary github.com/gitlab.com origin and only fails on exactly the hosts that need it.diff --git a/server/lib/README.md b/server/lib/README.mdindex 552e534906..5b123c0c66 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -343,7 +343,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `uploadLimits.js` | Single source of truth for upload size caps — `JSON_BODY_LIMIT`/`JSON_BODY_LIMIT_BYTES` (the express.json limit applied in `index.js`), `MAX_BASE64_UPLOAD_BYTES` derived from it (base64 ×4/3, so a bigger per-route cap is unreachable), `MAX_SCREENSHOT_BYTES`. Mirrored client-side as `JSON_UPLOAD_MAX_FILE_SIZE`. || `uuid.js` | `v4()` thin wrapper over `crypto.randomUUID()`. || `versionUtils.js` | `compareSemver(a, b)` — semver ordering (-1/0/1) with pre-release precedence and build-metadata stripping. Shared by the self-update checker (`updateChecker.js`) and the local-LLM Ollama update detector (`localLlm.js`). Inputs must be `v`-stripped. |-| `workTracker.js` | `WORK_TRACKERS`/`CONCRETE_WORK_TRACKERS`/`DEFAULT_WORK_TRACKER`, `workTrackerLabel`, `hostToWorkTracker`, `isGithubHost` (GitHub-family host test — github.com + enterprise github.*; enterprise-aware replacement for the github.com-only `isGithub` gate), `githubRepoSpec(origin)` (host-qualified `HOST/OWNER/REPO` selector for `gh --repo`, or null for a non-GitHub origin — pairs the isGithubHost gate with the selector so prWatcher/branchReconcile/issueReconcile share one "resolvable GitHub repo" definition), `forgeCliForTracker`, `isFileTracker` (true when the tracker records work as repo files — PLAN.md — so an agent's proposal necessarily dirties the worktree; false for github/gitlab/jira), `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. Async `resolveRepoForgeTarget(repoPath)` — the ONE definition of "which forge can we query for this checkout", returning `{ forge, fullName, repoSpec, apiHost }` (enterprise-aware `gh --repo` selector for GitHub; `repoSpec: null` for GitLab, which `glab` resolves from its cwd) or null for a non-forge origin; shared by `issueReconcile.js` and `appIssues.js`. Also owns the `{trackerInstructions}` prompt block shared by the TRACKER-FILING task types (types that read the app read-only and deliver findings as tracker items, not a commit): `TRACKER_FILING_PRESETS` (per-task-type slug prefix / label / body requirements — `reference-watch`, `ux`, `repo-study`), `TRACKER_FILING_TASK_TYPES` (derived from the presets, so a gated type always has wording), and `formatTrackerInstructions(tracker, options)` which renders the plan/github/gitlab/jira block (reference-watch is the default option set, so a bare call stays byte-identical for it). Consumed by the `claim-work` router in `cosTaskGenerator.js`, `referenceRepos.js`, and `routes/apps.js`. |+| `workTracker.js` | `WORK_TRACKERS`/`CONCRETE_WORK_TRACKERS`/`DEFAULT_WORK_TRACKER`, `workTrackerLabel`, `hostToWorkTracker`, `isGithubHost` (GitHub-family host test — github.com + enterprise github.*; enterprise-aware replacement for the github.com-only `isGithub` gate), `githubRepoSpec(origin)` (host-qualified `HOST/OWNER/REPO` selector for `gh --repo`, or null for a non-GitHub origin — pairs the isGithubHost gate with the selector so prWatcher/branchReconcile/issueReconcile share one "resolvable GitHub repo" definition), `forgeCliForTracker`, `isFileTracker` (true when the tracker records work as repo files — PLAN.md — so an agent's proposal necessarily dirties the worktree; false for github/gitlab/jira), `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. Async `resolveRepoForgeTarget(repoPath)` — the ONE definition of "which forge can we query for this checkout", returning `{ forge, fullName, repoSpec, apiHost }` (enterprise-aware `gh --repo` selector for GitHub; `repoSpec: null` for GitLab, which `glab` resolves from its cwd) or null for a non-forge origin; shared by `issueReconcile.js` and `appIssues.js`. Async `resolveAppForgeTarget(app, {repoPath})` — the composed `resolveAppWorkTracker` + `resolveRepoForgeTarget` for callers holding the managed-app record, returning `{ tracker, workTracker, target }` with the app's github/gitlab pin threaded in as `preferredForge` (so a self-hosted forge on a hostname matching neither pattern still resolves); use this instead of re-threading the pin by hand. Also owns the `{trackerInstructions}` prompt block shared by the TRACKER-FILING task types (types that read the app read-only and deliver findings as tracker items, not a commit): `TRACKER_FILING_PRESETS` (per-task-type slug prefix / label / body requirements — `reference-watch`, `ux`, `repo-study`), `TRACKER_FILING_TASK_TYPES` (derived from the presets, so a gated type always has wording), and `formatTrackerInstructions(tracker, options)` which renders the plan/github/gitlab/jira block (reference-watch is the default option set, so a bare call stays byte-identical for it). Consumed by the `claim-work` router in `cosTaskGenerator.js`, `referenceRepos.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 5c996e1832..52a1418b1d 100644--- a/server/lib/workTracker.js+++ b/server/lib/workTracker.js@@ -488,3 +488,36 @@ export async function resolveRepoForgeTarget(repoPath, { preferredForge = null }}return null;}++/**+ * Composed `resolveAppWorkTracker` + `resolveRepoForgeTarget` for callers that+ * hold the managed-app record (not just a bare `repoPath`): resolve the app's+ * work tracker, then resolve its forge target with that tracker supplied as the+ * `preferredForge` pin.+ *+ * This composition exists so a feature can't accidentally drop the pin. Threading+ * it by hand is what left the issue-reconcile scan blind to a self-hosted forge+ * whose hostname doesn't spell out "github."/"gitlab." while the app's Issues tab+ * listed it fine (issue #3767) — the pin only matters for exactly those hosts, so+ * a missing one fails silently on every ordinary github.com/gitlab.com app.+ *+ * `preferredForge` is passed ONLY for a github/gitlab tracker: a plan/jira app has+ * no forge pin to honor, and passing its tracker through would be meaningless.+ * `target` is still resolved for those apps (the origin may well be a forge) so a+ * caller that only wants the queryable repo doesn't have to special-case them —+ * callers that must gate on the tracker read `tracker` and decide.+ *+ * Never throws — both halves degrade to null rather than rejecting.+ * @param {object} app - managed app record (needs `repoPath`, `workTracker`)+ * @param {{repoPath?: string}} [options] - `repoPath` override for a caller that+ * scans a checkout other than `app.repoPath` (the app record supplies the pin,+ * the override supplies the checkout).+ * @returns {Promise<{tracker:string, workTracker:object, target:object|null}>}+ */+export async function resolveAppForgeTarget(app, { repoPath = null } = {}) {+ const workTracker = await resolveAppWorkTracker(app).catch(() => ({ resolved: 'plan', host: null, forge: null }));+ const tracker = workTracker.resolved;+ const preferredForge = (tracker === 'github' || tracker === 'gitlab') ? tracker : null;+ const target = await resolveRepoForgeTarget(repoPath || app?.repoPath, { preferredForge });+ return { tracker, workTracker, target };+}diff --git a/server/lib/workTracker.test.js b/server/lib/workTracker.test.jsindex 2c0417b07d..3948b31c96 100644--- a/server/lib/workTracker.test.js+++ b/server/lib/workTracker.test.js@@ -1,4 +1,15 @@-import { describe, it, expect } from 'vitest';+import { describe, it, expect, vi, beforeEach } from 'vitest';++// gitRemote is the ONLY effectful dependency of the async resolvers below, so+// mocking it lets `resolveAppForgeTarget` run its real composition (tracker+// resolution + forge-target pin) rather than a re-implementation.+vi.mock('./gitRemote.js', () => ({+ getOriginInfo: vi.fn(async () => null),+ readOriginRemoteUrl: vi.fn(async () => null),+}));++import { getOriginInfo, readOriginRemoteUrl } from './gitRemote.js';+import { resolveAppForgeTarget } from './workTracker.js';import {WORK_TRACKERS,CONCRETE_WORK_TRACKERS,@@ -228,3 +239,76 @@ describe('workTrackerLabel', () => {expect(workTrackerLabel('unmapped-value')).toBe('unmapped-value');});});++// The composed helper exists so no caller has to remember to thread the pin+// through by hand — the failure mode it prevents (issue #3767) is invisible on+// an ordinary github.com/gitlab.com origin and only bites self-hosted hosts.+describe('resolveAppForgeTarget', () => {+ const CUSTOM = { host: 'git.example-corp.com', fullName: 'acme/widget', url: '[email protected]:acme/widget.git' };++ const useOrigin = ({ host, fullName, url, isGithub = false }) => {+ getOriginInfo.mockResolvedValue({ isGithub, host, fullName });+ readOriginRemoteUrl.mockResolvedValue(url);+ };++ beforeEach(() => {+ vi.clearAllMocks();+ useOrigin({ host: 'github.com', fullName: 'acme/widget', url: '[email protected]:acme/widget.git', isGithub: true });+ });++ it('resolves an auto-tracked github.com app the same as the two-step call', async () => {+ const { tracker, target } = await resolveAppForgeTarget({ repoPath: '/repo', workTracker: 'auto' });+ expect(tracker).toBe('github');+ expect(target).toMatchObject({ forge: 'github', fullName: 'acme/widget', repoSpec: 'github.com/acme/widget' });+ });++ it('honors a github pin on a custom-hostname enterprise origin the host regex misses', async () => {+ useOrigin(CUSTOM);+ // Without the pin this origin is "not a forge" — the whole point of the helper.+ const { tracker, target } = await resolveAppForgeTarget({ repoPath: '/repo', workTracker: 'github' });+ expect(tracker).toBe('github');+ expect(target).toMatchObject({+ forge: 'github',+ fullName: 'acme/widget',+ repoSpec: 'git.example-corp.com/acme/widget',+ apiHost: 'git.example-corp.com',+ });+ });++ it('honors a gitlab pin on a custom-hostname self-hosted origin', async () => {+ useOrigin(CUSTOM);+ const { tracker, target } = await resolveAppForgeTarget({ repoPath: '/repo', workTracker: 'gitlab' });+ expect(tracker).toBe('gitlab');+ // `glab` targets the project from its cwd, so there is no repoSpec.+ expect(target).toMatchObject({ forge: 'gitlab', repoSpec: null });+ });++ it('passes NO pin for a plan/jira tracker, so a custom host stays unresolved', async () => {+ useOrigin(CUSTOM);+ for (const workTracker of ['plan', 'jira']) {+ const { tracker, target } = await resolveAppForgeTarget({ repoPath: '/repo', workTracker });+ expect(tracker).toBe(workTracker);+ expect(target).toBeNull();+ }+ });++ it('still resolves the forge target for a plan/jira app on a real forge origin (caller gates on tracker)', async () => {+ const { tracker, target } = await resolveAppForgeTarget({ repoPath: '/repo', workTracker: 'jira' });+ expect(tracker).toBe('jira');+ expect(target).toMatchObject({ forge: 'github' });+ });++ it('takes the pin from the app but scans the repoPath override', async () => {+ useOrigin(CUSTOM);+ await resolveAppForgeTarget({ repoPath: '/app-repo', workTracker: 'github' }, { repoPath: '/scanned-repo' });+ expect(getOriginInfo).toHaveBeenCalledWith('/scanned-repo');+ // The tracker read still comes from the app record's own checkout.+ expect(readOriginRemoteUrl).toHaveBeenCalledWith('/app-repo');+ });++ it('degrades to plan + null target when the app has no repo at all', async () => {+ const { tracker, target } = await resolveAppForgeTarget({});+ expect(tracker).toBe('plan');+ expect(target).toBeNull();+ });+});diff --git a/server/services/appIssues.js b/server/services/appIssues.jsindex 8fc7001b94..fd7dca47d7 100644--- a/server/services/appIssues.js+++ b/server/services/appIssues.js@@ -24,7 +24,7 @@import { execGh, ensureForgeReachable } from './github.js';import { execGlab } from './gitlab.js';-import { resolveAppWorkTracker, resolveRepoForgeTarget } from '../lib/workTracker.js';+import { resolveAppForgeTarget } from '../lib/workTracker.js';import { safeJSONParse } from '../lib/fileUtils.js';// Single-user repos never realistically exceed this; `glab` caps a page at 100.@@ -155,8 +155,12 @@ async function fetchGitlabIssues(repoPath) {* The forge-target probe needs the RESOLVED tracker first (see* `resolveRepoForgeTarget`'s `preferredForge`, which lets an explicitly-pinned* github/gitlab tracker reach a self-hosted forge whose hostname doesn't spell- * out "github."/"gitlab."), so the two reads run sequentially rather than- * overlapping — and are skipped entirely for a plan/jira-tracked app.+ * out "github."/"gitlab."), so both reads run through the composed+ * `resolveAppForgeTarget` rather than being threaded by hand here — the same+ * helper `issueReconcile.js` uses, so the tab and the zombie scan can't drift on+ * which forge a pinned custom-host app resolves to. It resolves the target even+ * for a plan/jira tracker (one extra origin read); the tracker gate below still+ * refuses to list anything for those, since a claim wouldn't touch it.** @param {object} app - managed app record (needs `repoPath`, `workTracker`)* @returns {Promise<{forge:'github'|'gitlab'|null, tracker:string|null, fullName:string|null, issues:object[], reason:string, transient:boolean, remedy:string|null}>}@@ -165,14 +169,12 @@ export async function listAppIssues(app) {const base = { forge: null, tracker: null, fullName: null, issues: [], transient: false, remedy: null };if (!app?.repoPath) return { ...base, reason: 'no-repo-path' };- const wt = await resolveAppWorkTracker(app);- const tracker = wt.resolved;+ const { tracker, target } = await resolveAppForgeTarget(app);// PLAN.md / JIRA apps have no forge issue list — and, more importantly, no// claim this tab could honestly offer.if (tracker !== 'github' && tracker !== 'gitlab') return { ...base, tracker, reason: 'tracker-not-a-forge' };- const target = await resolveRepoForgeTarget(app.repoPath, { preferredForge: tracker });if (!target) return { ...base, tracker, reason: 'unsupported-forge' };// Explicitly tracking one forge from the other's remote: we can't query the// configured tracker (no selector for it) and must not silently list thediff --git a/server/services/cosTaskGenerator.js b/server/services/cosTaskGenerator.jsindex 73b8bf96e9..4861897715 100644--- a/server/services/cosTaskGenerator.js+++ b/server/services/cosTaskGenerator.js@@ -2309,7 +2309,10 @@ async function resolveIssueReconcileBlock(app, taskType, metadata, taskSchedule)const jira = (wt?.resolved === 'jira' && app.jira?.enabled && app.jira?.instanceId && app.jira?.projectKey)? { instanceId: app.jira.instanceId, projectKey: app.jira.projectKey }: null;- const result = await reconcile(app.repoPath, { jira }).catch((err) => {+ // Pass the app itself, not just `jira`: the forge scan needs its `workTracker`+ // pin to reach a self-hosted github/gitlab whose hostname matches neither+ // auto-detection pattern (issue #3767).+ const result = await reconcile(app.repoPath, { jira, app }).catch((err) => {emitLog('warn', `issue-reconcile pre-step failed for ${app.name}: ${err.message}`, { appId: app.id });return null;});diff --git a/server/services/issueReconcile.js b/server/services/issueReconcile.jsindex db00255040..2c67250351 100644--- a/server/services/issueReconcile.js+++ b/server/services/issueReconcile.js@@ -54,7 +54,7 @@ import { execGit } from '../lib/execGit.js';import { execGh, ensureForgeReachable } from './github.js';import { execGlab } from './gitlab.js';import { fetchMyCurrentSprintTickets } from './jira.js';-import { resolveRepoForgeTarget } from '../lib/workTracker.js';+import { resolveAppForgeTarget, resolveRepoForgeTarget } from '../lib/workTracker.js';import { safeJSONParse, PATHS } from '../lib/fileUtils.js';// Bound the forge queries (single-user repos never realistically truncate at 200).@@ -392,11 +392,24 @@ async function getGitlabState(repoPath, fullName) {* selector, subgroup-safe GitLab host match) lives in `resolveRepoForgeTarget`* so this scan and the app Issues tab can't drift on what counts as a queryable* repo; only the state-fetching differs here.+ *+ * When the caller has the managed-app record it passes it as `app`, which routes+ * through the composed `resolveAppForgeTarget` — the SAME entry point the Issues+ * tab uses — so an app explicitly pinned to github/gitlab on a self-hosted host+ * whose name matches neither pattern (`git.example-corp.com`) is scanned here+ * exactly as it is listed there. Without the app (a bare-`repoPath` caller, e.g.+ * a direct `reconcile()` on the PortOS checkout) there is no pin to honor and+ * host detection alone decides.* @param {string} repoPath+ * @param {object|null} [app] - managed app record supplying the forge pin* @returns {Promise<object|null>}*/-async function getForgeState(repoPath) {- const target = await resolveRepoForgeTarget(repoPath);+async function getForgeState(repoPath, app = null) {+ // repoPath stays authoritative over app.repoPath — the app record is here for+ // its `workTracker` pin, not to redirect the scan at a different checkout.+ const target = app+ ? (await resolveAppForgeTarget(app, { repoPath })).target+ : await resolveRepoForgeTarget(repoPath);if (!target) return null;if (target.forge === 'github') return getGithubState(target.repoSpec, target.fullName, target.apiHost);// `glab` is cwd-based, so `fullName` here is only a display path.@@ -454,16 +467,18 @@ async function getJiraState(_repoPath, jira) {* is passed in. Otherwise the GitHub/GitLab forge is resolved from the origin host.** @param {string} repoPath- * @param {{ activeAgentIssueNums?: Set<number|string>, jira?: { instanceId:string, projectKey:string } }} [ctx]+ * @param {{ activeAgentIssueNums?: Set<number|string>, jira?: { instanceId:string, projectKey:string }, app?: object }} [ctx]* `activeAgentIssueNums` — issue numbers / ticket KEYs an active CoS agent is* currently claiming (from agent metadata); suppresses zombie classification for* one whose agent is still running. `jira` — routes to the JIRA gatherer.+ * `app` — the managed-app record, whose `workTracker` pin lets a self-hosted+ * forge on a non-matching hostname still resolve (see `getForgeState`).* @returns {Promise<{forge:string, fullName:string, issues:object[]}|null>}*/-export async function gatherIssueState(repoPath, { activeAgentIssueNums = new Set(), jira = null } = {}) {+export async function gatherIssueState(repoPath, { activeAgentIssueNums = new Set(), jira = null, app = null } = {}) {const isJira = Boolean(jira?.instanceId && jira?.projectKey);const [state, liveClaimIds] = await Promise.all([- isJira ? getJiraState(repoPath, jira) : getForgeState(repoPath),+ isJira ? getJiraState(repoPath, jira) : getForgeState(repoPath, app),isJira ? getLiveClaimTicketKeys(repoPath) : getLiveClaimIssueNums(repoPath),]);if (!state) return null;@@ -504,13 +519,13 @@ export async function gatherIssueState(repoPath, { activeAgentIssueNums = new Se* I/O to gatherIssueState).** @param {string} [repoPath=PATHS.root]- * @param {{ activeAgentIssueNums?: Set<number|string>, jira?: { instanceId:string, projectKey:string } }} [opts]+ * @param {{ activeAgentIssueNums?: Set<number|string>, jira?: { instanceId:string, projectKey:string }, app?: object }} [opts]* @returns {Promise<{ forge:string, fullName:string, zombies:object[], stalled:object[], live:object[] }|null>}* null on unsupported remote (not GitHub/GitLab, no JIRA config) / transient* failure (skip, don't park).*/-export async function reconcile(repoPath = PATHS.root, { activeAgentIssueNums = new Set(), jira = null } = {}) {- const gathered = await gatherIssueState(repoPath, { activeAgentIssueNums, jira });+export async function reconcile(repoPath = PATHS.root, { activeAgentIssueNums = new Set(), jira = null, app = null } = {}) {+ const gathered = await gatherIssueState(repoPath, { activeAgentIssueNums, jira, app });if (!gathered) return null;const classified = classifyIssues(gathered.issues);return {diff --git a/server/services/issueReconcile.test.js b/server/services/issueReconcile.test.jsindex 6040ce06eb..dbb0392b52 100644--- a/server/services/issueReconcile.test.js+++ b/server/services/issueReconcile.test.js@@ -293,6 +293,45 @@ describe('reconcile', () => {expect(repoArgs.every((r) => r === 'github.acme.example/acme/app')).toBe(true);});+ it('scans a custom-hostname self-hosted forge when the app pins workTracker (issue #3767)', async () => {+ // Neither `github.*` nor `gitlab.*` — no hostname heuristic can classify a+ // self-hosted forge, so the app's own pin is the only signal. Without the+ // `app` handoff this repo reads as "not a forge" and the zombie scan skips+ // silently, while the app's Issues tab lists the very same issues.+ getOriginInfo.mockResolvedValue({ isGithub: false, host: 'git.example-corp.com', fullName: 'acme/widget' });+ readOriginRemoteUrl.mockResolvedValue('[email protected]:acme/widget.git');+ mockGh({+ issues: [{ number: 42, title: 't', labels: [{ name: 'in-progress' }], assignees: [], url: 'u' }],+ merged: [{ number: 50, headRefName: 'x', body: 'Refs #42' }],+ open: [],+ });++ // Same repo, no pin → skip (the pre-fix behavior, kept honest here).+ expect(await reconcile('/repo')).toBeNull();++ const result = await reconcile('/repo', { app: { repoPath: '/repo', workTracker: 'github' } });+ expect(result.forge).toBe('github');+ expect(result.zombies.map((z) => z.number)).toEqual([42]);+ const repoArgs = execGh.mock.calls.map((c) => c[0][c[0].indexOf('--repo') + 1]);+ expect(repoArgs.every((r) => r === 'git.example-corp.com/acme/widget')).toBe(true);+ });++ it('scans a custom-hostname self-hosted GitLab when the app pins workTracker (issue #3767)', async () => {+ getOriginInfo.mockResolvedValue({ isGithub: false, host: 'git.example-corp.com', fullName: 'acme/widget' });+ readOriginRemoteUrl.mockResolvedValue('[email protected]:acme/widget.git');+ mockGlab({+ issues: [{ iid: 42, title: 't', labels: ['in-progress'], assignees: [], web_url: 'u' }],+ merged: [{ iid: 7, source_branch: 'claim/issue-42', description: 'Refs #42', web_url: 'm' }],+ open: [],+ });++ const result = await reconcile('/repo', { app: { repoPath: '/repo', workTracker: 'gitlab' } });+ expect(result.forge).toBe('gitlab');+ expect(result.zombies.map((z) => z.number)).toEqual([42]);+ // glab is cwd-routed — it must run in the scanned checkout.+ expect(execGlab.mock.calls[0][1]).toBe('/repo');+ });+it('returns null (transient) when the issue list query fails', async () => {execGh.mockImplementation(async (argv) => {if (argv[0] === 'issue') return null; // load-bearing query failed