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
clamp the activity-calendar week count so a malformed request cannot exhaust memory
[._.]/ Adam Eivy3c17b7a645d3
diff --git a/server/routes/cosInsightRoutes.js b/server/routes/cosInsightRoutes.jsindex b8dc66e634..8de267cc0c 100644--- a/server/routes/cosInsightRoutes.js+++ b/server/routes/cosInsightRoutes.js@@ -16,8 +16,11 @@ const router = Router();// GET /api/cos/activity-calendar - Runs-per-day heatmap for the dashboard widgetrouter.get('/activity-calendar', asyncHandler(async (req, res) => {- const weeks = parseInt(req.query.weeks, 10) || 12;- res.json(await getActivityCalendar(weeks));+ // Clamped: the grid materializes one object per day, so an unbounded `weeks`+ // (a typo, or a stale client) would build millions of them. 260 weeks is five+ // years, past any window the heatmap renders legibly.+ const requested = parseInt(req.query.weeks, 10) || 12;+ res.json(await getActivityCalendar(Math.min(Math.max(requested, 1), 260)));}));// GET /api/cos/actionable-insights - Get prioritized action items requiring user attentiondiff --git a/server/routes/cosInsightRoutes.test.js b/server/routes/cosInsightRoutes.test.jsindex c20d282e24..247040a8c5 100644--- a/server/routes/cosInsightRoutes.test.js+++ b/server/routes/cosInsightRoutes.test.js@@ -76,6 +76,20 @@ describe('CoS Insight Routes', () => {expect(response.status).toBe(200);expect(getActivityCalendar).toHaveBeenCalledWith(4);});++ // The grid materializes one object per day, so an unbounded week count+ // would build millions of them and exhaust memory.+ it.each([+ ['?weeks=999999', 260],+ ['?weeks=-5', 1],+ ])('clamps %s to %i weeks', async (query, expected) => {+ getActivityCalendar.mockResolvedValue({ weeks: [], maxTasks: 1, summary: {} });++ const response = await request(app).get(`/api/cos/activity-calendar${query}`);++ expect(response.status).toBe(200);+ expect(getActivityCalendar).toHaveBeenCalledWith(expected);+ });});describe('GET /api/cos/actionable-insights', () => {