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
feat([issue-2322]): remove the dedicated Layered Intelligence page
[._.]/ Adam Eivy1ab2496303a6
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex b84d671e92..61e731ce81 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -3,6 +3,7 @@## Layered Intelligence- **[issue-2322] Layered Intelligence is now a per-app scheduled task, not a global sweep.** The self-improvement loop used to run as a single global "Layered Intelligence Loop" job that swept every enabled app on one daily fire, with a confusing split between a global on/off (CoS → System Tasks) and per-app config (Edit App → Intelligence) — a per-app card could read "Enabled · Due now" while nothing ran. It now runs like every other self-improvement automation: a per-app, deterministic, handler-backed task in CoS → Schedule with its own per-app enable, interval, provider/model, and "Run now". Enabling the `layered-intelligence` task in the Schedule (plus per app on the Intelligence tab) drives it; the reasoning model still only returns JSON and files one deduplicated tracker issue — no code, no agent. Per-app behavior (telemetry sources, allowed scopes, guidance rules, hand-off) still lives on the app's Intelligence tab. An install upgrade migrates each app's scheduling into its per-app task override and tombstones the old global job, preserving effective on/off state. Note: because it's now a self-improvement task, the loop runs only while CoS improvement is enabled.+ - The standalone `/layered-intelligence` page has been removed — with the loop now a per-app scheduled task, its status is seen and managed in CoS → Schedule like every other task, and per-app behavior stays on Edit App → Intelligence. (The dedicated cross-app overview/proposals page and its endpoints are gone; nothing else surfaced there.)## Fixeddiff --git a/client/src/App.jsx b/client/src/App.jsxindex 56e1781eca..64d5e9a35b 100644--- a/client/src/App.jsx+++ b/client/src/App.jsx@@ -38,7 +38,6 @@ const Submodules = lazyWithReload(() => import('./pages/Submodules'));const ImageClean = lazyWithReload(() => import('./pages/ImageClean'));const VideoDownloaderPage = lazyWithReload(() => import('./pages/VideoDownloaderPage'));const ChiefOfStaff = lazyWithReload(() => import('./pages/ChiefOfStaff'));-const LayeredIntelligence = lazyWithReload(() => import('./pages/LayeredIntelligence'));const Ask = lazyWithReload(() => import('./pages/Ask'));const MediaGen = lazyWithReload(() => import('./pages/MediaGen'));const ImageGen = lazyWithReload(() => import('./pages/ImageGen'));@@ -205,7 +204,6 @@ export default function App() {<Route path="/" element={<Layout />}><Route index element={<Dashboard />} /><Route path="apps" element={<Apps />} />- <Route path="layered-intelligence" element={<LayeredIntelligence />} /><Route path="devtools" element={<Navigate to="/devtools/runs" replace />} /><Route path="devtools/datadog" element={<DataDog />} /><Route path="devtools/flows" element={<FlowsDoc />} />diff --git a/client/src/components/Layout.jsx b/client/src/components/Layout.jsxindex 9ee78ef988..c72de9ec4b 100644--- a/client/src/components/Layout.jsx+++ b/client/src/components/Layout.jsx@@ -187,7 +187,6 @@ const navItems = [{ to: '/feature-agents', label: 'Feature Agents', icon: Wand2 },{ to: '/cos/gsd', label: 'GSD', icon: Compass },{ to: '/cos/health', label: 'Health', icon: Activity },- { to: '/layered-intelligence', label: 'Layered Intelligence', icon: Layers },{ to: '/cos/learning', label: 'Learning', icon: GraduationCap },{ to: '/cos/memory', label: 'Memory', icon: Brain },{ to: '/cos/schedule', label: 'Schedule', icon: Clock },diff --git a/client/src/pages/LayeredIntelligence.jsx b/client/src/pages/LayeredIntelligence.jsxdeleted file mode 100644index e2b8c5776b..0000000000--- a/client/src/pages/LayeredIntelligence.jsx+++ /dev/null@@ -1,304 +0,0 @@-import { useState, useEffect, useCallback } from 'react';-import { Link } from 'react-router-dom';-import { Brain, Settings, Clock, CheckCircle2, PauseCircle, Sparkles, FileText, ExternalLink, RefreshCw } from 'lucide-react';-import BrailleSpinner from '../components/BrailleSpinner';-import Banner from '../components/ui/Banner';-import * as api from '../services/api';-import { timeAgo, timeUntil } from '../utils/formatters';-import {- LI_SCOPES,- LI_SOURCE_FIELDS,- LI_INTERVAL_PRESETS-} from '../components/apps/LayeredIntelligenceTab';--// Label lookups reused from the per-app config tab so the page and the drawer-// never drift on scope/source/interval naming.-const SCOPE_LABEL = Object.fromEntries(LI_SCOPES.map(s => [s.id, s.label]));-const SOURCE_LABEL = Object.fromEntries(LI_SOURCE_FIELDS.map(s => [s.key, s.label]));-const INTERVAL_LABEL = Object.fromEntries(LI_INTERVAL_PRESETS.map(p => [p.ms, p.label]));--// Human interval: a known preset renders as its label ("Daily"), else "every N min".-function intervalLabel(ms) {- if (INTERVAL_LABEL[ms]) return INTERVAL_LABEL[ms];- if (!ms) return '-';- return `every ${Math.round(ms / 60000)} min`;-}--// The enabled telemetry sources for an app as short chip labels (+ custom count).-function sourceChips(sources = {}) {- const chips = LI_SOURCE_FIELDS.filter(f => sources[f.key]).map(f => SOURCE_LABEL[f.key]);- if (sources.customCount > 0) chips.push(`${sources.customCount} custom`);- return chips;-}--function Chip({ children, tone = 'default' }) {- const tones = {- default: 'bg-port-bg text-gray-300 border-port-border',- accent: 'bg-port-accent/15 text-port-accent border-port-accent/30',- success: 'bg-port-success/15 text-port-success border-port-success/30',- warning: 'bg-port-warning/15 text-port-warning border-port-warning/30'- };- return (- <span className={`inline-block px-2 py-0.5 rounded border text-xs ${tones[tone] || tones.default}`}>- {children}- </span>- );-}--// Human label for a resolved work tracker (matches server workTracker.js values).-const TRACKER_LABEL = {- github: 'GitHub Issues', gitlab: 'GitLab Issues', jira: 'Jira', plan: 'PLAN.md'-};--// Muted reason text for an app whose filed-proposal read didn't succeed.-const PROPOSAL_REASON_TEXT = {- 'read-failed': 'Couldn’t read the tracker',- 'jira-not-configured': 'Jira not configured for this app',- 'no-repo': 'No repo path set',- error: 'Couldn’t read filed proposals'-};--// Filed-proposal counts + links for one app (issue #2293). Rendered only after-// the user loads counts (the base overview stays I/O-free). `summary` is the-// per-app entry from GET /apps/layered-intelligence/proposals, or undefined-// before the counts are loaded.-function ProposalSummary({ summary, loading }) {- if (loading && !summary) {- return <div className="text-xs text-gray-500 flex items-center gap-1"><RefreshCw size={11} className="animate-spin" /> Reading filed proposals…</div>;- }- if (!summary) return null;- const trackerLabel = TRACKER_LABEL[summary.tracker] || summary.tracker;- if (!summary.ok) {- return <div className="text-xs text-gray-500 flex items-center gap-1"><FileText size={11} /> {PROPOSAL_REASON_TEXT[summary.reason] || 'No proposal data'}</div>;- }- if (summary.total === 0) {- return <div className="text-xs text-gray-500 flex items-center gap-1"><FileText size={11} /> No filed proposals yet ({trackerLabel})</div>;- }- const linked = (summary.issues || []).filter(i => i.url);- return (- <div className="flex flex-col gap-1.5">- <div className="text-xs text-gray-300 flex items-center gap-1.5 flex-wrap">- <FileText size={11} className="text-port-accent shrink-0" />- <span className="font-medium text-white">{summary.total}</span> filed proposal{summary.total === 1 ? '' : 's'}- <span className="text-gray-500">- ({summary.open} open{summary.closed > 0 ? `, ${summary.closed} closed` : ''} · {trackerLabel})- </span>- </div>- {linked.length > 0 && (- <div className="flex flex-wrap gap-1.5">- {linked.map(i => (- <a- key={i.number ?? i.url}- href={i.url}- target="_blank"- rel="noopener noreferrer"- title={i.title}- className={`inline-flex items-center gap-1 px-2 py-0.5 rounded border text-xs hover:border-port-accent/50 ${i.state === 'open' ? 'bg-port-accent/10 text-port-accent border-port-accent/30' : 'bg-port-bg text-gray-500 border-port-border line-through'}`}- >- {i.number != null ? `#${i.number}` : 'issue'}- <ExternalLink size={10} />- </a>- ))}- </div>- )}- </div>- );-}--function AppLoopCard({ app, proposals, proposalsLoading }) {- const scopes = (app.allowedScopes || []).map(id => SCOPE_LABEL[id] || id);- const chips = sourceChips(app.sources);- return (- <div className="bg-port-card border border-port-border rounded-lg p-4 flex flex-col gap-3">- <div className="flex items-start justify-between gap-2">- <div className="min-w-0">- <div className="flex items-center gap-2">- <Link to={`/apps/${app.id}`} className="font-medium text-white hover:underline truncate">- {app.name}- </Link>- {app.isPortos && <Chip tone="accent">PortOS</Chip>}- </div>- <div className="mt-1 flex items-center gap-2 text-xs">- {app.enabled- ? <span className="flex items-center gap-1 text-port-success"><CheckCircle2 size={13} /> Enabled</span>- : <span className="flex items-center gap-1 text-gray-500"><PauseCircle size={13} /> Disabled</span>}- {app.enabled && app.due && <Chip tone="warning">Due now</Chip>}- </div>- </div>- <Link- to={`/apps/${app.id}?edit=1&appTab=intelligence`}- className="flex items-center gap-1 text-xs px-2 py-1 bg-port-accent/20 text-port-accent hover:bg-port-accent/30 rounded shrink-0"- >- <Settings size={12} /> Configure- </Link>- </div>-- {app.enabled && (- <div className="grid grid-cols-2 sm:grid-cols-4 gap-2 text-xs">- <div>- <div className="text-gray-500">Interval</div>- <div className="text-gray-300 flex items-center gap-1"><Clock size={11} /> {intervalLabel(app.intervalMs)}</div>- </div>- <div>- <div className="text-gray-500">Last run</div>- <div className="text-gray-300">{timeAgo(app.lastRunAt)}</div>- </div>- <div>- <div className="text-gray-500">Next due</div>- <div className="text-gray-300">{app.due ? 'now' : (app.nextDueAt ? timeUntil(app.nextDueAt, 'soon') : 'first run')}</div>- </div>- <div>- <div className="text-gray-500">Provider</div>- <div className="text-gray-300 truncate">{app.providerId || 'default'}</div>- </div>- </div>- )}-- {app.enabled && (- <div className="flex flex-col gap-2">- {chips.length > 0 && (- <div className="flex flex-wrap gap-1.5">- {chips.map(c => <Chip key={c}>{c}</Chip>)}- </div>- )}- {scopes.length > 0 && (- <div className="flex flex-wrap gap-1.5">- {scopes.map(s => <Chip key={s} tone="accent">{s}</Chip>)}- </div>- )}- {app.hasRules && <div className="text-xs text-gray-500 flex items-center gap-1"><Sparkles size={11} /> Custom guidance rules set</div>}- <ProposalSummary summary={proposals} loading={proposalsLoading} />- </div>- )}- </div>- );-}--export default function LayeredIntelligence() {- const [data, setData] = useState(null);- const [loading, setLoading] = useState(true);- const [error, setError] = useState(false);- // Filed-proposal counts (issue #2293) — loaded on demand so the base overview- // stays I/O-free. `proposals` is a map of appId → summary once fetched.- const [proposals, setProposals] = useState(null);- const [proposalsLoading, setProposalsLoading] = useState(false);-- const load = useCallback(async () => {- setError(false);- const res = await api.getLayeredIntelligenceOverview({ silent: true }).catch(() => null);- if (!res) setError(true);- else setData(res);- setLoading(false);- }, []);-- const loadProposals = useCallback(async () => {- setProposalsLoading(true);- const res = await api.getLayeredIntelligenceProposals().catch(() => null);- if (res?.apps) {- setProposals(Object.fromEntries(res.apps.map(a => [a.id, a])));- }- setProposalsLoading(false);- }, []);-- useEffect(() => { load(); }, [load]);-- const apps = data?.apps || [];- const enabledApps = apps.filter(a => a.enabled);- const availableApps = apps.filter(a => !a.enabled);-- return (- <div className="max-w-5xl mx-auto space-y-4">- <div className="flex items-start gap-3">- <Brain size={24} className="text-port-accent mt-0.5 shrink-0" />- <div>- <h1 className="text-xl font-semibold text-white">Layered Intelligence</h1>- <p className="text-sm text-gray-400">- A perpetual, per-app self-improvement loop. On its schedule it reads each enabled app's goals and- telemetry, asks a reasoning model for the single highest-value improvement, and files one deduplicated- tracker issue for a coding agent — the model never touches code. Configure it per app on each app's- Intelligence tab.- </p>- </div>- </div>-- {loading ? (- <div className="flex items-center justify-center py-16"><BrailleSpinner text="Loading" /></div>- ) : error ? (- <div className="space-y-3">- <Banner tone="error" size="md">Couldn't load the Layered Intelligence overview.</Banner>- <button- type="button"- onClick={() => { setLoading(true); load(); }}- className="text-xs px-3 py-1.5 bg-port-accent/20 text-port-accent hover:bg-port-accent/30 rounded"- >- Retry- </button>- </div>- ) : (- <>- {!data.taskEnabled && (- <Banner tone="warning" size="md">- The <strong>Layered Intelligence</strong> scheduled task is off globally, so no app's loop will run even- when enabled below. Turn the task on under{' '}- <Link to="/cos/schedule" className="underline hover:text-white">Chief of Staff → Schedule</Link>.- </Banner>- )}- {data.taskEnabled && !data.improvementEnabled && (- <Banner tone="warning" size="md">- CoS <strong>improvement</strong> is disabled, so scheduled loops (including this one) won't run. Enable- it under <Link to="/cos" className="underline hover:text-white">Chief of Staff</Link>.- </Banner>- )}-- <div className="flex items-center justify-between gap-3 flex-wrap">- <div className="text-sm text-gray-400">- {enabledApps.length} of {apps.length} app{apps.length === 1 ? '' : 's'} have the loop enabled.- </div>- {enabledApps.length > 0 && (- <button- type="button"- onClick={loadProposals}- disabled={proposalsLoading}- title="Read each enabled app's tracker for the layered-intelligence proposals the loop has filed"- className="flex items-center gap-1.5 text-xs px-3 py-1.5 bg-port-accent/20 text-port-accent hover:bg-port-accent/30 rounded disabled:opacity-50"- >- <RefreshCw size={12} className={proposalsLoading ? 'animate-spin' : ''} />- {proposals ? 'Refresh filed counts' : 'Load filed-proposal counts'}- </button>- )}- </div>-- {enabledApps.length > 0 ? (- <div className="grid gap-3 md:grid-cols-2">- {enabledApps.map(app => (- <AppLoopCard key={app.id} app={app} proposals={proposals?.[app.id]} proposalsLoading={proposalsLoading} />- ))}- </div>- ) : (- <Banner tone="info" size="md">- No app has the loop enabled yet. Enable it per app on its Intelligence tab — it's off by default.- </Banner>- )}-- {availableApps.length > 0 && (- <div className="space-y-2 pt-2">- <h2 className="text-sm font-medium text-gray-400">Available apps ({availableApps.length})</h2>- <div className="grid gap-2 sm:grid-cols-2 md:grid-cols-3">- {availableApps.map(app => (- <Link- key={app.id}- to={`/apps/${app.id}?edit=1&appTab=intelligence`}- className="flex items-center justify-between gap-2 bg-port-card border border-port-border rounded-lg px-3 py-2 hover:border-port-accent/50"- >- <span className="text-sm text-gray-300 truncate">{app.name}</span>- <Settings size={13} className="text-gray-500 shrink-0" />- </Link>- ))}- </div>- </div>- )}- </>- )}- </div>- );-}diff --git a/client/src/pages/LayeredIntelligence.test.jsx b/client/src/pages/LayeredIntelligence.test.jsxdeleted file mode 100644index 0461dcac6a..0000000000--- a/client/src/pages/LayeredIntelligence.test.jsx+++ /dev/null@@ -1,103 +0,0 @@-import { describe, it, expect, vi, beforeEach } from 'vitest';-import { render, screen, waitFor } from '@testing-library/react';-import userEvent from '@testing-library/user-event';-import { MemoryRouter } from 'react-router-dom';-import LayeredIntelligence from './LayeredIntelligence';-import * as api from '../services/api';--vi.mock('../services/api', () => ({- getLayeredIntelligenceOverview: vi.fn(),- getLayeredIntelligenceProposals: vi.fn()-}));--const renderPage = () => render(- <MemoryRouter>- <LayeredIntelligence />- </MemoryRouter>-);--const overview = (extra = {}) => ({- taskEnabled: true,- improvementEnabled: true,- enabledCount: 1,- apps: [- {- id: 'app-on', name: 'Alpha', isPortos: false, enabled: true, intervalMs: 86400000,- providerId: null, model: null, hasRules: false,- lastRunAt: null, nextDueAt: null, due: true,- allowedScopes: ['app-improvement'],- sources: { goals: true, cosMetrics: false, healthReport: false, planMd: false, openIssues: true, customCount: 0 }- },- {- id: 'app-off', name: 'Zeta', isPortos: false, enabled: false, intervalMs: 86400000,- providerId: null, model: null, hasRules: false,- lastRunAt: null, nextDueAt: null, due: false,- allowedScopes: ['app-improvement'],- sources: { goals: true, cosMetrics: false, healthReport: false, planMd: false, openIssues: true, customCount: 0 }- }- ],- ...extra-});--describe('LayeredIntelligence page', () => {- beforeEach(() => vi.clearAllMocks());-- it('renders enabled apps with their status and available apps separately', async () => {- api.getLayeredIntelligenceOverview.mockResolvedValue(overview());- renderPage();-- await waitFor(() => expect(screen.getByText('Alpha')).toBeInTheDocument());- expect(screen.getByText('Enabled')).toBeInTheDocument();- expect(screen.getByText('Due now')).toBeInTheDocument();- // The disabled app appears under "Available apps".- expect(screen.getByText(/Available apps/)).toBeInTheDocument();- expect(screen.getByText('Zeta')).toBeInTheDocument();- expect(screen.getByText('1 of 2 apps have the loop enabled.')).toBeInTheDocument();- });-- it('warns when the scheduled task is disabled globally', async () => {- api.getLayeredIntelligenceOverview.mockResolvedValue(overview({ taskEnabled: false }));- renderPage();-- await waitFor(() => expect(screen.getByText(/scheduled task is off globally/i)).toBeInTheDocument());- expect(screen.getByText(/Schedule/)).toBeInTheDocument();- });-- it('warns when CoS improvement is disabled (task on)', async () => {- api.getLayeredIntelligenceOverview.mockResolvedValue(overview({ taskEnabled: true, improvementEnabled: false }));- renderPage();-- await waitFor(() => expect(screen.getByText(/improvement/i)).toBeInTheDocument());- });-- it('shows an error banner + retry when the overview fails to load', async () => {- api.getLayeredIntelligenceOverview.mockRejectedValue(new Error('boom'));- renderPage();-- await waitFor(() => expect(screen.getByText(/Couldn't load/)).toBeInTheDocument());- expect(screen.getByRole('button', { name: 'Retry' })).toBeInTheDocument();- });-- it('loads filed-proposal counts + links on demand and merges them into the enabled card', async () => {- api.getLayeredIntelligenceOverview.mockResolvedValue(overview());- api.getLayeredIntelligenceProposals.mockResolvedValue({- apps: [{- id: 'app-on', name: 'Alpha', ok: true, tracker: 'github', open: 2, closed: 1, total: 3,- issues: [{ number: 5, title: 'Add widget', state: 'open', url: 'https://github.com/o/r/issues/5' }]- }]- });- renderPage();-- await waitFor(() => expect(screen.getByText('Alpha')).toBeInTheDocument());- const btn = screen.getByRole('button', { name: /Load filed-proposal counts/ });- await userEvent.click(btn);-- await waitFor(() => expect(screen.getByText(/filed proposals/)).toBeInTheDocument());- expect(screen.getByText('3')).toBeInTheDocument();- expect(screen.getByText(/2 open, 1 closed · GitHub Issues/)).toBeInTheDocument();- const link = screen.getByRole('link', { name: /#5/ });- expect(link).toHaveAttribute('href', 'https://github.com/o/r/issues/5');- // Button flips to "Refresh" once counts are loaded.- expect(screen.getByRole('button', { name: /Refresh filed counts/ })).toBeInTheDocument();- });-});diff --git a/client/src/services/apiApps.js b/client/src/services/apiApps.jsindex 2bf895e335..27073713a9 100644--- a/client/src/services/apiApps.js+++ b/client/src/services/apiApps.js@@ -15,18 +15,6 @@ export const getAppWorkTracker = (id, options) =>// side). Caller owns its own .catch fallback, so default to silent.export const getAppLayeredIntelligence = (id, options) =>request(`/apps/${id}/layered-intelligence`, { silent: true, ...options });-// Cross-app Layered Intelligence Loop overview for the dedicated status page:-// { jobEnabled, jobExists, enabledCount, apps: [{ id, name, enabled, intervalMs,-// lastRunAt, nextDueAt, due, allowedScopes, sources, ... }] }. Read-only.-export const getLayeredIntelligenceOverview = (options) =>- request('/apps/layered-intelligence/overview', options);-// Opt-in filed-proposal counts + links for the overview page: does per-app-// forge/Jira/PLAN I/O (gh/glab shell-outs), so it's fired on demand rather than-// baked into the base overview. Returns { apps: [{ id, name, ok, tracker, open,-// closed, total, issues: [{ number, title, state, url }], reason? }] }. Caller-// owns its own error UI, so default to silent.-export const getLayeredIntelligenceProposals = (options) =>- request('/apps/layered-intelligence/proposals', { silent: true, ...options });export const createApp = (data) => request('/apps', {method: 'POST',body: JSON.stringify(data)diff --git a/server/lib/navManifest.js b/server/lib/navManifest.jsindex 3878d9a47d..d52522d997 100644--- a/server/lib/navManifest.js+++ b/server/lib/navManifest.js@@ -86,7 +86,6 @@ export const NAV_COMMANDS = [{ id: 'nav.feature-agents', path: '/feature-agents', label: 'Feature Agents', section: 'Chief of Staff', aliases: ['feature-agents'] },{ id: 'nav.cos.gsd', path: '/cos/gsd', label: 'GSD', section: 'Chief of Staff', aliases: ['gsd', 'cos-gsd'] },{ id: 'nav.cos.health', path: '/cos/health', label: 'Health', section: 'Chief of Staff', aliases: ['cos-health', 'health'] },- { id: 'nav.cos.layered-intelligence', path: '/layered-intelligence', label: 'Layered Intelligence', section: 'Chief of Staff', aliases: ['layered-intelligence', 'intelligence-loop', 'self-improvement', 'lil'], keywords: ['layered intelligence', 'self improvement loop', 'per-app improvement', 'proposals', 'autonomous improvement', 'loop status'] },{ id: 'nav.cos.learning', path: '/cos/learning', label: 'Learning', section: 'Chief of Staff', aliases: ['cos-learning'] },{ id: 'nav.cos.memory', path: '/cos/memory', label: 'Memory', section: 'Chief of Staff', aliases: ['cos-memory'] },{ id: 'nav.cos.schedule', path: '/cos/schedule', label: 'Schedule', section: 'Chief of Staff', aliases: ['schedule', 'cos-schedule'] },diff --git a/server/routes/apps.js b/server/routes/apps.jsindex 29b1e8ed0d..282951ffb6 100644--- a/server/routes/apps.js+++ b/server/routes/apps.js@@ -20,10 +20,7 @@ import { checkViteHost, findViteConfig, rewriteAllowedHosts } from '../lib/viteAimport { detectAppIcon, getIconContentType, isUsableSvg } from '../services/appIconDetect.js';import { hasDeployScript } from '../services/appDeployer.js';import { checkScripts, installScripts, XCODE_SCRIPT_NAMES } from '../services/xcodeScripts.js';-import { SELF_IMPROVEMENT_TASK_TYPES, loadSchedule } from '../services/taskSchedule.js';-import { loadState, isImprovementEnabled } from '../services/cosState.js';-import { summarizeLoopStatus, summarizeFiledProposals } from '../services/layeredIntelligence.js';-import { resolveAppWorkTracker } from '../lib/workTracker.js';+import { SELF_IMPROVEMENT_TASK_TYPES } from '../services/taskSchedule.js';import { certPaths } from '../../lib/certPaths.js';const router = Router();@@ -735,80 +732,6 @@ router.get('/:id/work-tracker', loadApp, asyncHandler(async (req, res) => {res.json({ appId: app.id, appName: app.name, ...info });}));-// GET /api/apps/layered-intelligence/overview - Cross-app Layered Intelligence-// Loop status for the dedicated page. Deterministic read only: each active app's-// effective config + scheduler bookkeeping (lastRunAt/nextDueAt/due) plus the-// global autonomous-job on/off state (a per-app config is inert while the job is-// disabled). NO LLM and NO forge I/O — filed-proposal counts stay off this-// surface deliberately (they'd require per-app `gh`/`glab` shell-outs); those-// are served by the separate opt-in `/layered-intelligence/proposals` endpoint-// below so this base overview stays fast. This two-segment static path can't-// collide with `/:id` (one segment) or `/:id/layered-intelligence` (literal-// second segment), so ordering is safe.-router.get('/layered-intelligence/overview', asyncHandler(async (req, res) => {- const [apps, schedule, state] = await Promise.all([- appsService.getActiveApps(),- loadSchedule().catch(() => null),- loadState().catch(() => null)- ]);- const now = Date.now();- // Scheduling (enabled/interval/provider/model) lives in each app's per-app task- // override now (#2322), not app.layeredIntelligence — pass it to the summarizer.- const summaries = (await Promise.all(apps.map(async (app) => {- const overrides = await appsService.getAppTaskTypeOverrides(app.id).catch(() => ({}));- return summarizeLoopStatus({ app, isPortos: app.id === PORTOS_APP_ID, override: overrides?.['layered-intelligence'], now });- })))- .sort((a, b) => {- // Enabled apps first, then the PortOS baseline, then alphabetical by name.- if (a.enabled !== b.enabled) return a.enabled ? -1 : 1;- if (a.isPortos !== b.isPortos) return a.isPortos ? -1 : 1;- return a.name.localeCompare(b.name);- });- // The loop is driven by the per-app `layered-intelligence` scheduled task, so- // "nothing will run" now depends on (a) the task type being enabled globally in- // CoS → Schedule and (b) CoS improvement being on — NOT a bespoke global job.- res.json({- taskEnabled: !!schedule?.tasks?.['layered-intelligence']?.enabled,- improvementEnabled: state ? isImprovementEnabled(state) : false,- enabledCount: summaries.filter(s => s.enabled).length,- apps: summaries- });-}));--// GET /api/apps/layered-intelligence/proposals - Cross-app filed-proposal counts-// + links for the overview page (issue #2293). Deliberately SPLIT from the base-// overview: this one DOES per-app forge/Jira/PLAN I/O (gh/glab shell-outs, Jira-// REST, PLAN.md scan) to count the layered-intelligence-labelled items the loop-// has actually filed, so it's an opt-in "refresh counts" action the client fires-// on demand rather than baking network/CLI latency into the base overview. Only-// enabled-loop apps are swept so the I/O fan-out is bounded. Each app resolves +-// summarizes concurrently and independently — one failing tracker read surfaces-// as that app's `ok:false` without aborting the batch. NO LLM calls (forge reads-// only), so it's outside the no-cold-bootstrap policy. Static two-segment path,-// registered before `/:id/...`, so no route collision.-router.get('/layered-intelligence/proposals', asyncHandler(async (req, res) => {- const apps = await appsService.getActiveApps();- // Bound the I/O fan-out to apps whose loop is actually enabled — a disabled- // app has filed nothing this config cares about, and sweeping every managed- // app would shell out `gh`/`glab` needlessly. Enablement lives in the per-app- // task override now (#2322).- const withOverrides = await Promise.all(apps.map(async (app) => ({- app,- override: (await appsService.getAppTaskTypeOverrides(app.id).catch(() => ({})))?.['layered-intelligence']- })));- const enabled = withOverrides- .filter(({ app, override }) => summarizeLoopStatus({ app, isPortos: app.id === PORTOS_APP_ID, override }).enabled)- .map(({ app }) => app);- const results = await Promise.all(enabled.map(async (app) => {- const tracker = await resolveAppWorkTracker(app).catch(() => ({ resolved: 'plan', forge: null }));- const summary = await summarizeFiledProposals({ app, tracker })- .catch(() => ({ ok: false, tracker: tracker?.resolved || 'plan', reason: 'error', open: 0, closed: 0, total: 0, issues: [] }));- return { id: app.id, name: app.name || app.id, ...summary };- }));- console.log(`🧠 Layered Intelligence: filed-proposal counts read for ${results.length} enabled app(s)`);- res.json({ apps: results });-}));-// GET /api/apps/:id/layered-intelligence - Effective Layered Intelligence config// for this app (the self-improvement loop). Merges the app's stored partial// config over the shipped defaults so the UI always renders a complete, safediff --git a/server/routes/apps.test.js b/server/routes/apps.test.jsindex fd158ae03b..cd7d47459c 100644--- a/server/routes/apps.test.js+++ b/server/routes/apps.test.js@@ -36,35 +36,6 @@ vi.mock('../services/history.js', () => ({logAction: vi.fn()}));-// The layered-intelligence overview route now reads the per-app task schedule +-// CoS improvement state (the global autonomous-job is retired, #2322). Stub-// loadSchedule (keeping the real SELF_IMPROVEMENT_TASK_TYPES the route imports)-// and cosState so the route tests stay deterministic + I/O-free.-vi.mock('../services/taskSchedule.js', async (importActual) => {- const actual = await importActual();- return { ...actual, loadSchedule: vi.fn().mockResolvedValue({ tasks: {} }) };-});-vi.mock('../services/cosState.js', () => ({- loadState: vi.fn().mockResolvedValue({}),- isImprovementEnabled: vi.fn().mockReturnValue(true)-}));--// Partial-mock layeredIntelligence: keep the real pure helpers (summarizeLoopStatus,-// LI_JOB_ID) the overview route relies on, but stub the I/O summarizeFiledProposals-// so the proposals route test never shells out to gh/glab.-vi.mock('../services/layeredIntelligence.js', async (importActual) => {- const actual = await importActual();- return { ...actual, summarizeFiledProposals: vi.fn() };-});--// Stub the git-shelling tracker resolver so the proposals route test is I/O-free,-// but keep the real pure exports (WORK_TRACKERS is consumed by validation.js at-// module load — dropping it would break the whole route module).-vi.mock('../lib/workTracker.js', async (importActual) => {- const actual = await importActual();- return { ...actual, resolveAppWorkTracker: vi.fn() };-});-vi.mock('../services/streamingDetect.js', () => ({parseEcosystemFromPath: vi.fn(),writeEcosystemPortEdits: vi.fn().mockResolvedValue({ file: 'ecosystem.config.cjs', changed: true, remapApplied: true, applied: [], unapplied: [] }),@@ -115,9 +86,6 @@ import * as pm2Service from '../services/pm2.js';import * as history from '../services/history.js';import * as streamingDetect from '../services/streamingDetect.js';import * as cos from '../services/cos.js';-import { loadSchedule } from '../services/taskSchedule.js';-import { summarizeFiledProposals } from '../services/layeredIntelligence.js';-import { resolveAppWorkTracker } from '../lib/workTracker.js';import { detectAppIcon, getIconContentType, isUsableSvg } from '../services/appIconDetect.js';import { installScripts } from '../services/xcodeScripts.js';import { writeFileSync, readFileSync, mkdirSync, rmSync } from 'fs';@@ -343,91 +311,6 @@ describe('Apps Routes', () => {expect(response.status).toBe(404);});- it('GET /layered-intelligence/overview summarizes every active app + scheduled-task state', async () => {- appsService.getActiveApps.mockResolvedValue([- { id: 'off-app', name: 'Zeta Off' },- { id: 'on-app', name: 'Alpha On' },- { id: 'portos-default', name: 'PortOS' }- ]);- // Scheduling/enablement now comes from each app's task override (#2322).- appsService.getAppTaskTypeOverrides.mockImplementation(async (id) => ({- 'off-app': {},- 'on-app': { 'layered-intelligence': { enabled: true, intervalMs: 86400000 } },- 'portos-default': { 'layered-intelligence': { enabled: true } }- }[id] || {}));- loadSchedule.mockResolvedValue({ tasks: { 'layered-intelligence': { enabled: true } } });-- const response = await request(app).get('/api/apps/layered-intelligence/overview');-- expect(response.status).toBe(200);- expect(response.body.taskEnabled).toBe(true);- expect(response.body.improvementEnabled).toBe(true);- expect(response.body.enabledCount).toBe(2);- // Enabled first, PortOS ahead of other enabled, disabled last.- expect(response.body.apps.map(a => a.id)).toEqual(['portos-default', 'on-app', 'off-app']);- const portos = response.body.apps.find(a => a.id === 'portos-default');- expect(portos.isPortos).toBe(true);- expect(portos.allowedScopes).toContain('portos-self');- // Free-text rules never leak into the list payload.- expect(JSON.stringify(response.body)).not.toContain('"rules"');- expect(appsService.getActiveApps).toHaveBeenCalled();- });-- it('GET /layered-intelligence/overview reports taskEnabled:false when the scheduled task is off', async () => {- appsService.getActiveApps.mockResolvedValue([]);- appsService.getAppTaskTypeOverrides.mockResolvedValue({});- loadSchedule.mockResolvedValue({ tasks: {} });-- const response = await request(app).get('/api/apps/layered-intelligence/overview');-- expect(response.status).toBe(200);- expect(response.body.taskEnabled).toBe(false);- expect(response.body.enabledCount).toBe(0);- });-- it('GET /layered-intelligence/proposals sweeps only enabled apps and returns counts + links', async () => {- appsService.getActiveApps.mockResolvedValue([- { id: 'off-app', name: 'Off', repoPath: '/off' },- { id: 'on-app', name: 'On', repoPath: '/on' }- ]);- // Enablement is per-app-override driven now (#2322).- appsService.getAppTaskTypeOverrides.mockImplementation(async (id) =>- id === 'on-app' ? { 'layered-intelligence': { enabled: true } } : {});- resolveAppWorkTracker.mockResolvedValue({ resolved: 'github', forge: 'gh' });- summarizeFiledProposals.mockResolvedValue({- ok: true, tracker: 'github', open: 2, closed: 1, total: 3,- issues: [{ number: 5, title: 'X', state: 'open', url: 'https://github.com/o/r/issues/5' }]- });-- const response = await request(app).get('/api/apps/layered-intelligence/proposals');-- expect(response.status).toBe(200);- // Only the enabled app is swept (the disabled one files nothing this cares about).- expect(response.body.apps).toHaveLength(1);- expect(response.body.apps[0]).toMatchObject({ id: 'on-app', name: 'On', ok: true, total: 3, open: 2, closed: 1 });- expect(response.body.apps[0].issues[0].url).toContain('/issues/5');- expect(summarizeFiledProposals).toHaveBeenCalledTimes(1);- });-- it('GET /layered-intelligence/proposals degrades one failing app without aborting the batch', async () => {- appsService.getActiveApps.mockResolvedValue([- { id: 'a', name: 'A', repoPath: '/a' },- { id: 'b', name: 'B', repoPath: '/b' }- ]);- appsService.getAppTaskTypeOverrides.mockResolvedValue({ 'layered-intelligence': { enabled: true } });- resolveAppWorkTracker.mockResolvedValue({ resolved: 'github', forge: 'gh' });- summarizeFiledProposals- .mockResolvedValueOnce({ ok: true, tracker: 'github', open: 1, closed: 0, total: 1, issues: [] })- .mockRejectedValueOnce(new Error('boom'));-- const response = await request(app).get('/api/apps/layered-intelligence/proposals');-- expect(response.status).toBe(200);- expect(response.body.apps).toHaveLength(2);- const b = response.body.apps.find(a => a.id === 'b');- expect(b).toMatchObject({ ok: false, reason: 'error', total: 0 });- });-it('writes changed ports back to the ecosystem config (source of truth)', async () => {// repoPath must exist on disk so the pathExists guard passes.const mockApp = { id: 'app-001', name: 'App', type: 'node', repoPath: process.cwd(), apiPort: 5173, uiPort: 5174 };diff --git a/server/services/layeredIntelligence.js b/server/services/layeredIntelligence.jsindex 0d2ebafa1f..7b18d1d149 100644--- a/server/services/layeredIntelligence.js+++ b/server/services/layeredIntelligence.js@@ -138,59 +138,6 @@ export function getEffectiveConfig(app) {return merged;}-/**- * Summarize one app's loop status for the cross-app overview page. Pure and- * side-effect-free (no LLM, no forge I/O): derives the display shape from the- * app's stored config + the per-app scheduled-task override.- *- * Under option A (#2322) the SCHEDULING fields — enabled / intervalMs /- * providerId / model — live in the per-app `taskTypeOverrides['layered-intelligence']`- * (passed in as `override`), NOT in `app.layeredIntelligence`. BEHAVIOR fields- * (sources / scopes / rules / handoff) plus `lastRunAt` bookkeeping still come- * from the effective config. `nextDueAt` is `lastRunAt + intervalMs` (null when- * never run), and `due` is a display flag (only meaningful when enabled) mirroring- * the scheduler's cadence check. `rules` is reduced to a boolean so the free-text- * guidance never leaks into a list payload.- */-export function summarizeLoopStatus({ app, isPortos = false, override = null, now = Date.now() } = {}) {- const config = getEffectiveConfig({ ...app, isPortos });- const sources = config.sources || {};- const ov = (override && typeof override === 'object' && !Array.isArray(override)) ? override : {};- const enabled = ov.enabled === true;- const intervalMs = (typeof ov.intervalMs === 'number' && Number.isFinite(ov.intervalMs) && ov.intervalMs > 0)- ? ov.intervalMs- : (config.intervalMs || 0);- const providerId = ov.providerId || null;- const model = ov.model || null;- const lastRunAt = typeof config.lastRunAt === 'string' ? config.lastRunAt : null;- const last = lastRunAt ? Date.parse(lastRunAt) : NaN;- const nextDueAt = Number.isFinite(last) ? new Date(last + intervalMs).toISOString() : null;- const due = !Number.isFinite(last) || (now - last) >= intervalMs;- return {- id: app.id,- name: app.name || app.id,- isPortos,- enabled,- intervalMs,- providerId,- model,- handoffEnabled: !!config.handoff?.enabled,- hasRules: !!(typeof config.rules === 'string' && config.rules.trim()),- lastRunAt,- nextDueAt,- due: enabled && due,- allowedScopes: Array.isArray(config.allowedScopes) ? config.allowedScopes : [],- sources: {- goals: !!sources.goals,- cosMetrics: !!sources.cosMetrics,- healthReport: !!sources.healthReport,- planMd: !!sources.planMd,- openIssues: !!sources.openIssues,- customCount: Array.isArray(sources.custom) ? sources.custom.length : 0- }- };-}-/*** Whether a proposal scope is allowed for this app. A hallucinated or* hand-edited scope cannot escape this gate: it must be a recognized scope, be@@ -955,90 +902,3 @@ export function extractPlanSlugs(planContent) {while ((m = re.exec(planContent))) slugs.push(m[1].toLowerCase());return slugs;}--// ----------------------------------------------------------------------------// Filed-proposal counts + links (issue #2293). The base overview endpoint stays-// deterministic + I/O-free; THIS function does the per-app forge/Jira/PLAN read-// behind an explicit "refresh counts" action so the count/link surface is opt-in.-// -----------------------------------------------------------------------------// A ceiling on the number of proposal issues surfaced back to the UI per app so a-// repo with a large layered-intelligence backlog can't return an unbounded list;-// the count itself is still the full total, only the linked list is capped.-export const PROPOSAL_LINKS_MAX = 25;--/**- * Normalize a forge/Jira lister's `{ ok, issues }` into the overview's- * filed-proposal summary shape: `{ ok, tracker, open, closed, total, issues }`,- * where each surfaced issue is `{ number, title, state, url }` (link-ready).- * A FAILED read (`ok:false`) surfaces as `{ ok:false, reason:'read-failed' }`- * rather than a misleading `total:0` — the CLAUDE.md sentinel rule (a failed- * fetch must not collapse into "legitimately zero").- */-export function normalizeProposalSummary(listed, tracker) {- if (!listed?.ok) {- return { ok: false, tracker, reason: 'read-failed', open: 0, closed: 0, total: 0, issues: [] };- }- const all = Array.isArray(listed.issues) ? listed.issues : [];- const open = all.filter(i => i.state === 'open').length;- const issues = all.slice(0, PROPOSAL_LINKS_MAX).map(i => ({- number: i.number ?? null,- title: i.title || '',- state: i.state,- url: i.url || null- }));- return { ok: true, tracker, open, closed: all.length - open, total: all.length, issues };-}--/**- * Summarize the filed layered-intelligence proposals for ONE app — count + links,- * resolved through whatever tracker the app files to. I/O function (shells out to- * gh/glab or hits the Jira REST service); the listers it delegates to are- * catch-safe so this never throws — a failed read surfaces as `ok:false`.- *- * `tracker` is the app's resolved work tracker (`resolveAppWorkTracker(app)`),- * passed in so the caller can resolve every app's tracker concurrently. Deps are- * injectable so tests drive the dispatch without a live forge/Jira/filesystem.- */-export async function summarizeFiledProposals({ app, tracker, deps = {} } = {}) {- const {- listForge = listForgeIssues,- listJira = listJiraIssues,- readPlan = tryReadFile- } = deps;- const resolved = tracker?.resolved || 'plan';- const filer = filerForTracker(resolved);- const cwd = app?.repoPath;-- if (filer === 'forge') {- if (!tracker?.forge || !cwd) {- return { ok: false, tracker: resolved, reason: 'no-repo', open: 0, closed: 0, total: 0, issues: [] };- }- const listed = await listForge({ cli: tracker.forge, cwd });- return normalizeProposalSummary(listed, resolved);- }-- if (filer === 'jira') {- // Jira coordinates come from the app's explicit per-app config (never- // auto-detected), mirroring the sweep handler's gate.- const jira = (app?.jira?.enabled && app.jira?.instanceId && app.jira?.projectKey)- ? { instanceId: app.jira.instanceId, projectKey: app.jira.projectKey }- : null;- if (!jira) {- return { ok: false, tracker: 'jira', reason: 'jira-not-configured', open: 0, closed: 0, total: 0, issues: [] };- }- const listed = await listJira({ instanceId: jira.instanceId, projectKey: jira.projectKey });- // Jira issues carry a key (PROJ-123) but no browse URL from the lister, so- // they surface as counts without per-item links.- return normalizeProposalSummary(listed, 'jira');- }-- // plan tracker — count slug-tagged checklist items in PLAN.md. All PLAN items- // are "open" (the plan filer has no closed-state), and have no per-item URL.- if (!cwd) {- return { ok: false, tracker: 'plan', reason: 'no-repo', open: 0, closed: 0, total: 0, issues: [] };- }- const planContent = await readPlan(join(cwd, 'PLAN.md'));- const slugs = extractPlanSlugs(planContent || '');- return { ok: true, tracker: 'plan', open: slugs.length, closed: 0, total: slugs.length, issues: [] };-}diff --git a/server/services/layeredIntelligence.test.js b/server/services/layeredIntelligence.test.jsindex 6ad7689a8d..047e691d05 100644--- a/server/services/layeredIntelligence.test.js+++ b/server/services/layeredIntelligence.test.js@@ -50,11 +50,7 @@ import {LI_LABEL,LI_BLOCKING_LABEL,LI_JIRA_BLOCKING_LABEL,- LI_JOB_ID,- summarizeLoopStatus,- summarizeFiledProposals,- normalizeProposalSummary,- PROPOSAL_LINKS_MAX+ LI_JOB_ID} from './layeredIntelligence.js';describe('defaultLayeredIntelligenceConfig', () => {@@ -121,94 +117,6 @@ describe('getEffectiveConfig', () => {});});-describe('summarizeLoopStatus (overview page shape)', () => {- const DAY = 24 * 60 * 60 * 1000;- const NOW = Date.parse('2026-07-07T12:00:00Z');-- // Scheduling (enabled/intervalMs) now lives in the per-app task override (#2322);- // behavior + lastRunAt still come from app.layeredIntelligence.- it('summarizes a never-run enabled app as due with no lastRun/nextDue', () => {- const s = summarizeLoopStatus({- app: { id: 'a1', name: 'App One' },- override: { enabled: true, intervalMs: DAY },- now: NOW- });- expect(s).toMatchObject({ id: 'a1', name: 'App One', enabled: true, due: true, lastRunAt: null, nextDueAt: null });- expect(s.sources).toMatchObject({ goals: true, customCount: 0 });- expect(s.hasRules).toBe(false);- });-- it('computes nextDueAt = lastRunAt + intervalMs and due=false before the interval elapses', () => {- const lastRunAt = new Date(NOW - DAY / 2).toISOString();- const s = summarizeLoopStatus({- app: { id: 'a2', name: 'App Two', layeredIntelligence: { lastRunAt } },- override: { enabled: true, intervalMs: DAY },- now: NOW- });- expect(s.lastRunAt).toBe(lastRunAt);- expect(s.nextDueAt).toBe(new Date(Date.parse(lastRunAt) + DAY).toISOString());- expect(s.due).toBe(false);- });-- it('due is always false when the app is disabled, even past the interval', () => {- const lastRunAt = new Date(NOW - 2 * DAY).toISOString();- const s = summarizeLoopStatus({- app: { id: 'a3', name: 'Off', layeredIntelligence: { lastRunAt } },- override: { enabled: false, intervalMs: DAY },- now: NOW- });- expect(s.enabled).toBe(false);- expect(s.due).toBe(false);- });-- it('reduces rules to a boolean and never leaks the free text', () => {- const s = summarizeLoopStatus({- app: { id: 'a4', name: 'Ruled', layeredIntelligence: { rules: 'never add deps' } },- override: { enabled: true },- now: NOW- });- expect(s.hasRules).toBe(true);- expect(JSON.stringify(s)).not.toContain('never add deps');- });-- it('surfaces the hand-off enabled flag (behavior, from layeredIntelligence)', () => {- const off = summarizeLoopStatus({ app: { id: 'h0', name: 'Off' }, now: NOW });- expect(off.handoffEnabled).toBe(false);- const on = summarizeLoopStatus({- app: { id: 'h1', name: 'On', layeredIntelligence: { handoff: { enabled: true } } },- override: { enabled: true },- now: NOW- });- expect(on.handoffEnabled).toBe(true);- });-- it('reads provider/model from the override, not layeredIntelligence', () => {- const s = summarizeLoopStatus({- app: { id: 'p1', name: 'Prov' },- override: { enabled: true, providerId: 'ov-prov', model: 'ov-model' },- now: NOW- });- expect(s.providerId).toBe('ov-prov');- expect(s.model).toBe('ov-model');- });-- it('surfaces PortOS scopes + custom source count', () => {- const s = summarizeLoopStatus({- app: { id: 'portos-default', name: 'PortOS', layeredIntelligence: { sources: { custom: [{ type: 'file', ref: 'x.md' }] } } },- override: { enabled: true },- isPortos: true,- now: NOW- });- expect(s.isPortos).toBe(true);- expect(s.allowedScopes).toContain('portos-self');- expect(s.sources.customCount).toBe(1);- });-- it('falls back to the app id when name is missing', () => {- expect(summarizeLoopStatus({ app: { id: 'no-name' }, now: NOW }).name).toBe('no-name');- });-});-describe('LI_JOB_ID', () => {it('is the autonomous-job id the loop sweep runs under', () => {expect(LI_JOB_ID).toBe('job-layered-intelligence');@@ -1076,80 +984,3 @@ describe('listForgeIssues url surfacing (issue #2293)', () => {expect(issues[0].url).toBeNull();});});--describe('normalizeProposalSummary (issue #2293)', () => {- it('distinguishes a failed read from a legitimately empty one', () => {- expect(normalizeProposalSummary({ ok: false }, 'github')).toMatchObject({ ok: false, reason: 'read-failed', total: 0 });- expect(normalizeProposalSummary({ ok: true, issues: [] }, 'github')).toMatchObject({ ok: true, total: 0, open: 0, closed: 0 });- });-- it('counts open vs closed and surfaces link-ready issues', () => {- const listed = { ok: true, issues: [- { number: 1, title: 'A', state: 'open', url: 'u1' },- { number: 2, title: 'B', state: 'closed', url: 'u2' }- ] };- const s = normalizeProposalSummary(listed, 'github');- expect(s).toMatchObject({ ok: true, total: 2, open: 1, closed: 1 });- expect(s.issues).toEqual([- { number: 1, title: 'A', state: 'open', url: 'u1' },- { number: 2, title: 'B', state: 'closed', url: 'u2' }- ]);- });-- it('caps the surfaced link list at PROPOSAL_LINKS_MAX but keeps the full total', () => {- const issues = Array.from({ length: PROPOSAL_LINKS_MAX + 10 }, (_, i) => ({ number: i, title: `t${i}`, state: 'open', url: `u${i}` }));- const s = normalizeProposalSummary({ ok: true, issues }, 'github');- expect(s.total).toBe(PROPOSAL_LINKS_MAX + 10);- expect(s.issues.length).toBe(PROPOSAL_LINKS_MAX);- });-});--describe('summarizeFiledProposals (issue #2293)', () => {- it('forge: delegates to the forge lister and normalizes', async () => {- const listForge = vi.fn().mockResolvedValue({ ok: true, issues: [{ number: 3, title: 'X', state: 'open', url: 'u' }] });- const s = await summarizeFiledProposals({- app: { id: 'a', repoPath: '/repo' },- tracker: { resolved: 'github', forge: 'gh' },- deps: { listForge }- });- expect(listForge).toHaveBeenCalledWith({ cli: 'gh', cwd: '/repo' });- expect(s).toMatchObject({ ok: true, tracker: 'github', total: 1, open: 1 });- });-- it('forge: reports no-repo when the app has no repoPath', async () => {- const s = await summarizeFiledProposals({ app: { id: 'a' }, tracker: { resolved: 'github', forge: 'gh' } });- expect(s).toMatchObject({ ok: false, reason: 'no-repo', total: 0 });- });-- it('jira: reports jira-not-configured without an instance/project', async () => {- const s = await summarizeFiledProposals({ app: { id: 'a', repoPath: '/r' }, tracker: { resolved: 'jira', forge: null } });- expect(s).toMatchObject({ ok: false, tracker: 'jira', reason: 'jira-not-configured' });- });-- it('jira: delegates to the jira lister when configured', async () => {- const listJira = vi.fn().mockResolvedValue({ ok: true, issues: [{ number: 'PROJ-1', title: 'J', state: 'open' }] });- const s = await summarizeFiledProposals({- app: { id: 'a', repoPath: '/r', jira: { enabled: true, instanceId: 'i1', projectKey: 'PROJ' } },- tracker: { resolved: 'jira', forge: null },- deps: { listJira }- });- expect(listJira).toHaveBeenCalledWith({ instanceId: 'i1', projectKey: 'PROJ' });- expect(s).toMatchObject({ ok: true, tracker: 'jira', total: 1, open: 1 });- expect(s.issues[0].url).toBeNull(); // jira issues surface without per-item links- });-- it('plan: counts slug tags in PLAN.md (all open, no links)', async () => {- const readPlan = vi.fn().mockResolvedValue('- [ ] [lil-foo] a\n- [ ] [lil-bar] b\n');- const s = await summarizeFiledProposals({- app: { id: 'a', repoPath: '/r' },- tracker: { resolved: 'plan', forge: null },- deps: { readPlan }- });- expect(s).toMatchObject({ ok: true, tracker: 'plan', total: 2, open: 2, closed: 0, issues: [] });- });-- it('plan: reports no-repo without a repoPath', async () => {- const s = await summarizeFiledProposals({ app: { id: 'a' }, tracker: { resolved: 'plan', forge: null } });- expect(s).toMatchObject({ ok: false, tracker: 'plan', reason: 'no-repo' });- });-});