Merge pull request 'feat(style-acq T15): הכותב צורך את כל הלמידה (/methodology + /training) + תיקון-מספור' (#72) from worktree-style-acquisition-mvp into main
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 1m56s

This commit was merged in pull request #72.
This commit is contained in:
2026-06-06 16:37:01 +00:00
3 changed files with 87 additions and 8 deletions

View File

@@ -2199,6 +2199,48 @@ async def get_style_patterns(pattern_type: str | None = None) -> list[dict]:
return [dict(r) for r in rows]
async def get_methodology_overrides(category: str) -> dict:
"""Chair's /methodology edits for one category (golden_ratios / discussion_rules /
content_checklists). Returns {rule_key: parsed_value}. These OVERRIDE the hardcoded
lessons.py defaults — the writer must consume them (T15 / INV-LRN4). Mirrors the merge
in GET /api/methodology/{category}."""
pool = await get_pool()
async with pool.acquire() as conn:
rows = await conn.fetch(
"SELECT rule_key, rule_value FROM appeal_type_rules "
"WHERE appeal_type = '_global' AND rule_category = $1",
category,
)
out: dict = {}
for r in rows:
raw = r["rule_value"]
if isinstance(raw, str):
try:
raw = json.loads(raw)
except (json.JSONDecodeError, TypeError):
pass
out[r["rule_key"]] = raw
return out
async def get_recent_decision_lessons(limit: int = 15, practice_area: str = "") -> list[dict]:
"""Per-decision learnings the chair/curator attached in /training (decision_lessons),
so the writer consumes them too (T15). Prefers style/structure/lexicon, recent first."""
pool = await get_pool()
async with pool.acquire() as conn:
rows = await conn.fetch(
"""SELECT dl.lesson_text, dl.category, dl.source,
sc.decision_number, sc.practice_area
FROM decision_lessons dl
JOIN style_corpus sc ON sc.id = dl.style_corpus_id
WHERE ($2 = '' OR sc.practice_area = $2)
ORDER BY dl.created_at DESC
LIMIT $1""",
limit, practice_area,
)
return [dict(r) for r in rows]
async def upsert_style_pattern(
pattern_type: str,
pattern_text: str,