feat(learning): grow style-exemplars from every final (P1 #5) #343

Merged
chaim merged 1 commits from worktree-grow-exemplars into main 2026-06-28 21:58:13 +00:00
Owner

הפער שנסגר

קורפוס ה-style_exemplars (ערוץ B — שליפת-פרוזה ברמת-בלוק של דפנה שהכותב משתמש בה) היה קפוא ב-seed החד-פעמי: סופי חדש נכנס ל-style_corpus אך מעולם לא פורק לדוגמאות (8137/8126/8174 = 0). הכותב שלף רק פסקאות-seed ממרץ-אפריל, ללא קשר לכמה סופיים נחתמו.

התיקון

חילוץ הליבה (section→paragraph→Voyage-embed→replace) לשירות משותף legal_mcp.services.style_exemplars.extract_and_storeמימוש יחיד המשמש גם את ה-backfill החד-פעמי וגם את מסלול-ה-enroll (G2; אין מחלץ מקביל). _enroll_final_in_library קורא לו בכל העלאת-סופי (source='internal_committee', אותו מקור ש-search_style_exemplars של הכותב קורא). Voyage REST → בטוח-בקונטיינר; best-effort, מדווח, לא מפיל את ההעלאה.

אפקט

כל סופי חתום מגדיל את קורפוס-הדוגמאות → שליפת-הסגנון של הכותב משתפרת בכל החלטה. זה התיקון המרכזי ל"לומד מכל החלטה" בערוץ B. מסלול A יעקוב אם הבריכה הגדלה מורידה את מרחק-הסגנון.

Invariants

  • G2 — מסלול-חילוץ יחיד (backfill + enroll).
  • INV-LRN5 — פרוזת-סגנון בלבד; מהות במסלול אחר.
  • INV-LRN4 — לולאת draft↔final מזינה כעת גם את ערוץ-הדוגמאות.

py_compile נקי לשלושת הקבצים; חתימות embed_texts/_split_into_sections אומתו.

🤖 Generated with Claude Code

## הפער שנסגר קורפוס ה-style_exemplars (**ערוץ B** — שליפת-פרוזה ברמת-בלוק של דפנה שהכותב משתמש בה) היה **קפוא ב-seed החד-פעמי**: סופי חדש נכנס ל-style_corpus אך **מעולם לא פורק לדוגמאות** (8137/8126/8174 = 0). הכותב שלף רק פסקאות-seed ממרץ-אפריל, ללא קשר לכמה סופיים נחתמו. ## התיקון חילוץ הליבה (section→paragraph→Voyage-embed→replace) לשירות משותף `legal_mcp.services.style_exemplars.extract_and_store` — **מימוש יחיד** המשמש גם את ה-backfill החד-פעמי וגם את מסלול-ה-enroll (G2; אין מחלץ מקביל). `_enroll_final_in_library` קורא לו בכל העלאת-סופי (`source='internal_committee'`, אותו מקור ש-`search_style_exemplars` של הכותב קורא). Voyage REST → בטוח-בקונטיינר; best-effort, מדווח, לא מפיל את ההעלאה. ## אפקט כל סופי חתום **מגדיל את קורפוס-הדוגמאות** → שליפת-הסגנון של הכותב משתפרת בכל החלטה. זה התיקון המרכזי ל"לומד מכל החלטה" בערוץ B. מסלול A יעקוב אם הבריכה הגדלה מורידה את מרחק-הסגנון. ## Invariants - **G2** — מסלול-חילוץ יחיד (backfill + enroll). - **INV-LRN5** — פרוזת-סגנון בלבד; מהות במסלול אחר. - **INV-LRN4** — לולאת draft↔final מזינה כעת גם את ערוץ-הדוגמאות. py_compile נקי לשלושת הקבצים; חתימות `embed_texts`/`_split_into_sections` אומתו. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
chaim added 1 commit 2026-06-28 21:58:04 +00:00
feat(learning): grow style-exemplars from every final (P1 #5)
All checks were successful
G12 Leak-Guard / leak-guard (pull_request) Successful in 3s
Lint — undefined names / undefined-names (pull_request) Successful in 10s
93a9404663
The style-exemplar corpus (channel B — the writer's block-level retrieval of
Dafna's real prose) was FROZEN at the one-time seed backfill: new finals were
enrolled into style_corpus but never broken into exemplars, so the richest style
channel never grew (8137/8126/8174 had 0 exemplars). The writer kept retrieving
only March–April seed paragraphs no matter how many finals were signed.

Extract the per-decision exemplar logic (section→paragraph→Voyage-embed→replace)
into a shared service `legal_mcp.services.style_exemplars.extract_and_store` —
the SINGLE implementation now used by BOTH the one-time backfill and the live
enrollment path (G2; no parallel extractor). `_enroll_final_in_library` calls it
on every final upload (source='internal_committee', the same source the writer's
search_style_exemplars reads). Voyage embeds over REST → container-safe;
best-effort, surfaced in the upload response, never fails the upload.

Effect: every signed final now grows the exemplar corpus, so the writer's
block-level style retrieval improves with each decision — the core "learn from
every decision" fix for channel B. Path A (style_distance_history) will track
whether the larger exemplar pool reduces style-distance over time.

Invariants: G2 (one extraction path shared by backfill + enroll), INV-LRN5
(style/structure prose only — substance routes elsewhere), INV-LRN4 (the
draft↔final loop now feeds the exemplar channel, not just the lesson channel).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
chaim merged commit b0a6c2fe01 into main 2026-06-28 21:58:13 +00:00
chaim deleted branch worktree-grow-exemplars 2026-06-28 21:58:13 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ezer-mishpati/legal-ai#343