feat(learning): prospective held-out style-distance trend (Path A) #337

Merged
chaim merged 1 commits from worktree-style-distance-history into main 2026-06-28 21:03:51 +00:00
Owner

למה

מבחן held-out נקי כבר אינו ניתן-להרצה: כל תיק שהועלה-סופי כבר הוטמעו לקחיו, והלקחים נשמרים universal ללא תיוג-מקור → leave-one-out בלתי-אפשרי. מסלול A הופך את המבחן לפרוספקטיבי — לוכד את נקודת-ההכללה ברגע היחיד שבו היא נקייה.

מה

בהעלאת-סופי, אחרי יצירת הזוג טיוטה↔סופי אבל לפני הטמעת-לקחי-התיק (הטמעה = שלב ידני נפרד ב-/training), נלכד snapshot של style_distance (anti_pattern_total · golden-ratio max-dev · change_percent) יחד עם גודל-בריכת-הלקחים הנוכחי. מכיוון שהטיוטה נכתבה עם הבריכה הקודמת בלבד — כל שורה היא נקודת-נתון נקייה: "עם N לקחים מצטברים, הטיוטה שלנו על תיק שלא-נראה קיבלה ציון X". ככל שהבריכה גדלה — מגמה יורדת = הלמידה מכלילה.

  • db: SCHEMA_V45 טבלת style_distance_history (append-only) + helpers voice_lesson_pool_sizes / record_style_distance_snapshot / get_style_distance_history.
  • app: לכידה best-effort ב-api_upload_final_decision (לעולם לא מפילה את ההעלאה); GET /api/learning/style-distance-history למגמה.

הערות

  • שימוש-חוזר בשירות style_distance הקיים + בריכת appeal_type_rules — אין מסלול-מדד מקביל.
  • 8 התיקים הקיימים כבר מוטמעים → הטבלה מתחילה ריקה ומתמלאת מהסופי הבא (חלון ה-held-out הנקי שלהם חלף).
  • הסכמה (V45) CREATE TABLE IF NOT EXISTS תחת advisory-lock — מוחלת אוטומטית ב-startup, ללא migration ידני.
  • ללא-UI → לא נדרש שער-עיצוב. (אם UI יצרוך את ה-endpoint בעתיד → npm run api:types אחרי deploy.)

Invariants

  • G2 — שימוש-חוזר ב-style_distance/appeal_type_rules, מסלול יחיד.
  • INV-LRN4 — מדידת הפער טיוטה↔סופי; זהו משטח-המגמה שלו.
  • חישוב דטרמיניסטי (ללא LLM) → רץ בקונטיינר.

py_compile נקי ל-web/app.py ול-db.py.

🤖 Generated with Claude Code

## למה מבחן held-out **נקי** כבר אינו ניתן-להרצה: כל תיק שהועלה-סופי כבר הוטמעו לקחיו, והלקחים נשמרים `universal` ללא תיוג-מקור → leave-one-out בלתי-אפשרי. **מסלול A** הופך את המבחן ל**פרוספקטיבי** — לוכד את נקודת-ההכללה ברגע היחיד שבו היא נקייה. ## מה בהעלאת-סופי, אחרי יצירת הזוג טיוטה↔סופי אבל **לפני** הטמעת-לקחי-התיק (הטמעה = שלב ידני נפרד ב-/training), נלכד snapshot של `style_distance` (anti_pattern_total · golden-ratio max-dev · change_percent) יחד עם גודל-בריכת-הלקחים הנוכחי. מכיוון שהטיוטה נכתבה עם הבריכה ה**קודמת** בלבד — כל שורה היא נקודת-נתון נקייה: *"עם N לקחים מצטברים, הטיוטה שלנו על תיק שלא-נראה קיבלה ציון X"*. ככל שהבריכה גדלה — מגמה יורדת = הלמידה מכלילה. - **db:** `SCHEMA_V45` טבלת `style_distance_history` (append-only) + helpers `voice_lesson_pool_sizes` / `record_style_distance_snapshot` / `get_style_distance_history`. - **app:** לכידה best-effort ב-`api_upload_final_decision` (לעולם לא מפילה את ההעלאה); `GET /api/learning/style-distance-history` למגמה. ## הערות - שימוש-חוזר בשירות `style_distance` הקיים + בריכת `appeal_type_rules` — אין מסלול-מדד מקביל. - 8 התיקים הקיימים כבר מוטמעים → הטבלה מתחילה ריקה ומתמלאת מהסופי הבא (חלון ה-held-out הנקי שלהם חלף). - הסכמה (V45) `CREATE TABLE IF NOT EXISTS` תחת advisory-lock — מוחלת אוטומטית ב-startup, ללא migration ידני. - ללא-UI → לא נדרש שער-עיצוב. (אם UI יצרוך את ה-endpoint בעתיד → `npm run api:types` אחרי deploy.) ## Invariants - **G2** — שימוש-חוזר ב-style_distance/appeal_type_rules, מסלול יחיד. - **INV-LRN4** — מדידת הפער טיוטה↔סופי; זהו משטח-המגמה שלו. - חישוב דטרמיניסטי (ללא LLM) → רץ בקונטיינר. py_compile נקי ל-web/app.py ול-db.py. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
chaim added 1 commit 2026-06-28 21:03:42 +00:00
feat(learning): prospective held-out style-distance trend (Path A)
All checks were successful
G12 Leak-Guard / leak-guard (pull_request) Successful in 4s
Lint — undefined names / undefined-names (pull_request) Successful in 9s
ab510328af
A clean held-out test of voice learning was no longer runnable: every
final-uploaded case already has its lessons folded, and lessons are stored
universal/untagged so leave-one-out is impossible. Path A makes the test
prospective instead — capture the generalization datapoint at the one moment
it's clean.

On final upload, after the draft↔final pair is created but BEFORE this
case's lessons are folded (folding is a separate manual /training step), we
snapshot style_distance (anti_pattern_total, golden-ratio max-deviation,
change_percent) alongside the current voice-lesson pool size. Because the
draft was written with only the PRIOR pool, each row is a clean "with N
accumulated lessons, our draft on this unseen case scored X" datapoint. As
the pool grows over cases, a downward trend = learning generalizes.

- db: SCHEMA_V45 style_distance_history (append-only) + helpers
  voice_lesson_pool_sizes / record_style_distance_snapshot /
  get_style_distance_history.
- app: best-effort capture in api_upload_final_decision (never fails the
  upload); GET /api/learning/style-distance-history for the trend.

Reuses the existing style_distance service + appeal_type_rules pool — no
parallel metric path. The 8 existing cases are already folded, so the table
starts empty and fills from the next final (their clean window is past).

Invariants: G2 (reuse style_distance/appeal_type_rules — one path),
INV-LRN4 (measure the draft↔final gap; this is its trend surface). LLM-free
(style_distance is deterministic) so it runs in the container.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
chaim merged commit 84afdcb36c into main 2026-06-28 21:03:51 +00:00
chaim deleted branch worktree-style-distance-history 2026-06-28 21:03:51 +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#337