feat(claims): אכלוס claims.party_name במקור + backfill — סגירת השדה-המת (#224)
עד כה claims.party_name נשאר ריק והצבירה/הכתיבה גזרו את הפרדת-המשיבים מ-source_document בזמן-ריצה (שדה-מת). עכשיו הוא מאוכלס במקור ונקרא ע"י הצרכנים. - claims_extractor.extract_and_store_claims: מחתים party_name=source_document ל-SPLIT_PARTIES (respondent/permit_applicant); single-voice נשאר ''. אותו כלל SPLIT_PARTIES של הצבירה (G2, import לא-מעגלי). - SCHEMA_V52: backfill idempotent ל-claims קיימים (רק split + party_name ריק). - argument_aggregator + block_writer._build_claims_context: קוראים claims.party_name, עם fallback ל-source_document ל-claims מדור-קודם. התנהגות זהה (party_name==source_document) — אפס-רגרסיה, אך השדה כעת מקור-האמת (G1). py_compile + טעינת-שרשרת-ייבוא נקיים. סוגר את הפתוח האחרון של #224. Invariants: G1 (אכלוס במקור, לא גזירה-בקריאה), G2 (כלל-פיצול יחיד). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1918,6 +1918,20 @@ ALTER TABLE cases ADD COLUMN IF NOT EXISTS hearing_attendees JSONB NOT NULL DEFA
|
||||
"""
|
||||
|
||||
|
||||
# V52 (#224): backfill claims.party_name for existing rows. The extractor now
|
||||
# stamps party_name = source_document for the multi-litigant sides at write time
|
||||
# (claims_extractor), but claims stored before that shipped have party_name=''.
|
||||
# For those, the brief label is the source pleading — same rule the aggregator
|
||||
# uses (respondent / permit_applicant split). Idempotent: only fills empties, so
|
||||
# re-running is a no-op. Single-voice sides (appellant/committee) stay ''.
|
||||
SCHEMA_V52_SQL = """
|
||||
UPDATE claims SET party_name = source_document
|
||||
WHERE party_role IN ('respondent', 'permit_applicant')
|
||||
AND COALESCE(party_name, '') = ''
|
||||
AND COALESCE(source_document, '') <> '';
|
||||
"""
|
||||
|
||||
|
||||
# Stable, arbitrary key for the session-level advisory lock that serialises
|
||||
# schema DDL across processes. Every short-lived process (cron drains, services)
|
||||
# re-runs the idempotent migrations on startup; without this lock two processes
|
||||
@@ -1991,6 +2005,7 @@ async def _apply_schema_ddl(conn: asyncpg.Connection) -> None:
|
||||
await conn.execute(SCHEMA_V49_SQL)
|
||||
await conn.execute(SCHEMA_V50_SQL)
|
||||
await conn.execute(SCHEMA_V51_SQL)
|
||||
await conn.execute(SCHEMA_V52_SQL)
|
||||
|
||||
|
||||
async def init_schema() -> None:
|
||||
|
||||
Reference in New Issue
Block a user