diff --git a/mcp-server/src/legal_mcp/services/style_analyzer.py b/mcp-server/src/legal_mcp/services/style_analyzer.py index 1103807..810b0b1 100644 --- a/mcp-server/src/legal_mcp/services/style_analyzer.py +++ b/mcp-server/src/legal_mcp/services/style_analyzer.py @@ -109,26 +109,30 @@ SYNTHESIS_PROMPT = """\ """ -async def analyze_corpus(appeal_subtype: str = "") -> dict: +async def analyze_corpus(appeal_subtype: str = "", limit: int = 0) -> dict: """Analyze the style corpus and extract/update patterns. Args: appeal_subtype: filter by appeal subtype (e.g. 'betterment_levy', 'building_permit'). Empty string = all decisions. + limit: max decisions to analyze. 0 = ALL (T8 — full 48/48 coverage feeds the + author-features the writer's profile relies on; the old LIMIT 20 silently + dropped a third of Dafna's corpus). Returns summary of patterns found. """ pool = await db.get_pool() + lim_sql = f" LIMIT {int(limit)}" if limit and limit > 0 else "" async with pool.acquire() as conn: if appeal_subtype: rows = await conn.fetch( "SELECT full_text, decision_number FROM style_corpus " - "WHERE appeal_subtype = $1 ORDER BY decision_date DESC LIMIT 20", + "WHERE appeal_subtype = $1 ORDER BY decision_date DESC" + lim_sql, appeal_subtype, ) else: rows = await conn.fetch( - "SELECT full_text, decision_number FROM style_corpus ORDER BY decision_date DESC LIMIT 20" + "SELECT full_text, decision_number FROM style_corpus ORDER BY decision_date DESC" + lim_sql ) if not rows: