From d11c0821bb9a6df3c8e362ee498a2d60088d3bd5 Mon Sep 17 00:00:00 2001 From: Alex Newman Date: Sat, 4 Apr 2026 15:17:11 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20correct=20semantic=20endpoint=20doc=20co?= =?UTF-8?q?mment=20GET=E2=86=92POST,=20clamp=20limit=201-20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up to PR #1568: fix stale doc comment that still said GET, and add limit parameter validation (default 5, clamped to 1-20 range). Co-Authored-By: Claude Opus 4.6 (1M context) --- src/services/worker/http/routes/SearchRoutes.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/worker/http/routes/SearchRoutes.ts b/src/services/worker/http/routes/SearchRoutes.ts index 650efbe9..2b947ed3 100644 --- a/src/services/worker/http/routes/SearchRoutes.ts +++ b/src/services/worker/http/routes/SearchRoutes.ts @@ -249,7 +249,7 @@ export class SearchRoutes extends BaseRouteHandler { /** * Semantic context search for per-prompt injection - * GET /api/context/semantic?q=&project=&limit=5 + * POST /api/context/semantic { q, project?, limit? } * * Queries Chroma for observations semantically similar to the user's prompt. * Returns compact markdown for injection as additionalContext. @@ -257,7 +257,7 @@ export class SearchRoutes extends BaseRouteHandler { private handleSemanticContext = this.wrapHandler(async (req: Request, res: Response): Promise => { const query = (req.body?.q || req.query.q) as string; const project = (req.body?.project || req.query.project) as string; - const limit = parseInt(String(req.body?.limit || req.query.limit || '5'), 10); + const limit = Math.min(Math.max(parseInt(String(req.body?.limit || req.query.limit || '5'), 10) || 5, 1), 20); if (!query || query.length < 20) { res.json({ context: '', count: 0 });