From 1ab19cb38283b89d470092bf3e78f3fc37f5c13d Mon Sep 17 00:00:00 2001 From: oabrivard Date: Thu, 26 Mar 2026 14:48:43 +0100 Subject: [PATCH] docs: add spec for configurable summary length Co-Authored-By: Claude Opus 4.6 (1M context) --- .../specs/2026-03-26-summary-length-design.md | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 docs/superpowers/specs/2026-03-26-summary-length-design.md diff --git a/docs/superpowers/specs/2026-03-26-summary-length-design.md b/docs/superpowers/specs/2026-03-26-summary-length-design.md new file mode 100644 index 0000000..d39fc0a --- /dev/null +++ b/docs/superpowers/specs/2026-03-26-summary-length-design.md @@ -0,0 +1,86 @@ +# Design: Configurable Summary Length + +**Date**: 2026-03-26 +**Scope**: Add a user setting to control summary detail level (court/moyen/detaille) + +--- + +## Context + +Currently, article summaries are fixed at 4-5 lines based on 500 chars of article body. Users want longer summaries to avoid opening articles when the summary is sufficient. + +--- + +## 1. New setting: `summary_length` + +**Column:** `summary_length INTEGER NOT NULL DEFAULT 3` in the `settings` table. + +Values and their effect on the classify prompt: + +| Value | Label | Summary instruction | Body snippet size | +|-------|-------|--------------------|--------------------| +| 1 | Court | "un resume de 3 a 4 lignes" | 500 chars | +| 2 | Moyen | "un resume de 6 a 8 lignes" | 2000 chars | +| 3 | Detaille | "un resume de 12 a 15 lignes" | 4000 chars (full scrape) | + +Default: **3 (Detaille)** — generates comprehensive summaries by default. + +Validation: value must be 1, 2, or 3. + +--- + +## 2. Prompt change + +`build_article_classify_prompt` receives `summary_length: i32` as a new parameter. It adjusts the prompt instruction: + +- Current: `"Genere un titre clair et un resume de 4 a 5 lignes."` +- New: dynamically selects the line count based on `summary_length` + +The body snippet parameter (`body_snippet`) is already passed by the caller — the caller controls the truncation length. + +--- + +## 3. Pipeline change + +In `synthesis.rs`, the body snippet truncation in both Phase 1 and Phase 2 Brave classify loops changes from: + +```rust +let body_snippet: String = body_text.chars().take(500).collect(); +``` + +To a dynamic value based on `settings.summary_length`: + +```rust +let snippet_size = match settings.summary_length { + 1 => 500, + 2 => 2000, + _ => 4000, +}; +let body_snippet: String = body_text.chars().take(snippet_size).collect(); +``` + +--- + +## 4. Frontend + +A slider in Settings with 3 positions labeled "Court", "Moyen", "Detaille". Default position: "Detaille" (rightmost). + +Placed in the generation settings section, near `max_items_per_category`. + +--- + +## 5. Files to modify + +- **Create:** `backend/migrations/20260326000023_add_summary_length.sql` +- **Modify:** `backend/src/models/settings.rs` — add `summary_length` to `UserSettings`, `UpdateSettingsRequest`, `Default`, validation (1-3) +- **Modify:** `backend/src/db/settings.rs` — add `summary_length` to `SettingsRow`, queries, binds +- **Modify:** `backend/src/services/prompts.rs` — `build_article_classify_prompt` takes `summary_length`, adjusts instruction +- **Modify:** `backend/src/services/synthesis.rs` — dynamic snippet size based on `settings.summary_length` +- **Modify:** `frontend/src/types.ts` — add `summary_length: number` to `UserSettings` and `DEFAULT_SETTINGS` +- **Modify:** `frontend/src/pages/Settings.tsx` — add slider component +- **Modify:** `frontend/src/i18n/fr.ts` — labels for slider +- **Modify:** `CLAUDE.md` — migration count +- **Modify:** `backend/src/services/prompts.rs` tests — update `test_settings()` fixture, add test for summary_length +- **Modify:** `backend/tests/api_syntheses_test.rs` — add `summary_length` to settings payload +- **Modify:** `backend/tests/pipeline_test.rs` — add `summary_length` to settings payload +- **Modify:** `e2e/tests/generation-live.spec.ts` — add `summary_length` to settings payload