Merge pull request 'feat(learning): prospective held-out style-distance trend (Path A)' (#337) from worktree-style-distance-history into main
This commit was merged in pull request #337.
This commit is contained in:
28
web/app.py
28
web/app.py
@@ -3835,6 +3835,25 @@ async def api_upload_final_decision(case_number: str, file: UploadFile = File(..
|
||||
# checking + missing-precedent flagging (07-learning §1.3). Surfaced, not silent.
|
||||
library = await _enroll_final_in_library(case, case_number, final_text, chair_name)
|
||||
|
||||
# Path A — prospective held-out snapshot. Right now the draft (decision_blocks)
|
||||
# was written with only the PRIOR lesson pool — this case's lessons fold later,
|
||||
# manually, in /training. So measuring style-distance HERE is a clean
|
||||
# generalization datapoint. Append-only; best-effort (never fails the upload).
|
||||
try:
|
||||
from legal_mcp.services import style_distance as _sd
|
||||
sd = await _sd.style_distance(case_number)
|
||||
if isinstance(sd, dict) and "error" not in sd:
|
||||
pool = await db.voice_lesson_pool_sizes()
|
||||
summ = sd.get("summary", {})
|
||||
await db.record_style_distance_snapshot(
|
||||
case_number, pair_id,
|
||||
pool.get("discussion_rules", 0), pool.get("transition_phrases", 0),
|
||||
summ.get("anti_pattern_total"), summ.get("ratio_max_deviation_pp"),
|
||||
summ.get("change_percent"),
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning("held-out style-distance snapshot failed for %s: %s", case_number, e)
|
||||
|
||||
case_dir = config.find_case_dir(case_number)
|
||||
if case_dir.exists():
|
||||
commit_and_push(case_dir, f"החלטה סופית של היו\"ר: {final_name}")
|
||||
@@ -4760,6 +4779,15 @@ async def api_learning_style_distance(case_number: str):
|
||||
return await _sd.style_distance(case_number)
|
||||
|
||||
|
||||
@app.get("/api/learning/style-distance-history")
|
||||
async def api_learning_style_distance_history():
|
||||
"""Path A — מגמת ה-held-out הפרוספקטיבי: snapshot של מרחק-הסגנון שנלכד בכל
|
||||
העלאת-סופי *לפני* הטמעת-לקחי-התיק, מול גודל-בריכת-הלקחים באותו רגע. ירידה
|
||||
ב-anti_pattern_total / change_percent ככל שהבריכה גדלה = הלמידה מכלילה."""
|
||||
items = await db.get_style_distance_history()
|
||||
return {"items": items, "count": len(items)}
|
||||
|
||||
|
||||
def _coerce_json(raw):
|
||||
if isinstance(raw, str):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user