Add DB schema V4: methodology alignment columns
New columns for methodology-aware decision pipeline: claims table: - claim_handling (address/bundle/skip) — per-claim handling mode - bundle_group — group name for bundled claims - handling_reason — explanation for skip/bundle cases table: - standard_of_review — review standard (independent discretion / etc.) - subject_categories — JSONB array of topics in the appeal case_law table: - precedent_level — hierarchy (supreme/administrative/national/district) - is_binding — binding holding vs. obiter dictum - creac_role — how it serves reasoning (rule/explanation/analogy) decisions table: - issue_order — JSONB array of ordered issues with type - claim_handling — JSONB overrides from chair_directions Migration tested and applied successfully on production DB. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -397,6 +397,51 @@ CREATE INDEX IF NOT EXISTS idx_case_law_embeddings_vec
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
# ── Phase 4: Methodology alignment ──────────────────────────────
|
||||||
|
|
||||||
|
SCHEMA_V4_SQL = """
|
||||||
|
|
||||||
|
-- ═══════════════════════════════════════════════════════════════════
|
||||||
|
-- V4: Methodology alignment (decision-methodology.md)
|
||||||
|
-- ═══════════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
|
-- claims: טיפול בטענות (bundle/skip) + סוג טענה
|
||||||
|
ALTER TABLE claims ADD COLUMN IF NOT EXISTS claim_type TEXT DEFAULT 'claim';
|
||||||
|
-- claim / response / reply
|
||||||
|
ALTER TABLE claims ADD COLUMN IF NOT EXISTS claim_handling TEXT DEFAULT 'address';
|
||||||
|
-- address (דיון מלא) / bundle (קיבוץ) / skip (דילוג)
|
||||||
|
ALTER TABLE claims ADD COLUMN IF NOT EXISTS bundle_group TEXT DEFAULT '';
|
||||||
|
-- שם הקבוצה לקיבוץ (למשל "פגמים פרוצדורליים")
|
||||||
|
ALTER TABLE claims ADD COLUMN IF NOT EXISTS handling_reason TEXT DEFAULT '';
|
||||||
|
-- נימוק לדילוג/קיבוץ (למשל "נבחנה ולא מצאנו ממש")
|
||||||
|
|
||||||
|
-- cases: תקן ביקורת + קטגוריות נושא
|
||||||
|
ALTER TABLE cases ADD COLUMN IF NOT EXISTS standard_of_review TEXT DEFAULT '';
|
||||||
|
-- "שיקול דעת תכנוני עצמאי" / "בחינת שומה מכרעת" / ...
|
||||||
|
ALTER TABLE cases ADD COLUMN IF NOT EXISTS subject_categories JSONB DEFAULT '[]';
|
||||||
|
-- ["חניה", "קווי בניין", "גובה", "שימוש חורג", ...]
|
||||||
|
|
||||||
|
-- case_law: רמת תקדים + מעמד
|
||||||
|
ALTER TABLE case_law ADD COLUMN IF NOT EXISTS precedent_level TEXT DEFAULT '';
|
||||||
|
-- עליון / מנהלי / ועדת ערר ארצית / ועדת ערר מחוזית
|
||||||
|
ALTER TABLE case_law ADD COLUMN IF NOT EXISTS is_binding BOOLEAN DEFAULT TRUE;
|
||||||
|
-- הלכה מחייבת (true) / אמרת אגב (false)
|
||||||
|
ALTER TABLE case_law ADD COLUMN IF NOT EXISTS creac_role TEXT DEFAULT '';
|
||||||
|
-- rule (הנחה עליונה) / explanation (הרחבה) / analogy (אנלוגיה)
|
||||||
|
|
||||||
|
-- decisions: סדר סוגיות + תקן ביקורת
|
||||||
|
ALTER TABLE decisions ADD COLUMN IF NOT EXISTS issue_order JSONB DEFAULT '[]';
|
||||||
|
-- סדר הסוגיות שנקבע ע"י המנצח: [{"title": "...", "type": "threshold/dispositive/secondary"}]
|
||||||
|
ALTER TABLE decisions ADD COLUMN IF NOT EXISTS claim_handling JSONB DEFAULT '{}';
|
||||||
|
-- {"overrides": [{"claim_id": "...", "handling": "bundle", "group": "..."}]}
|
||||||
|
|
||||||
|
-- indexes
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_claims_handling ON claims(claim_handling);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_claims_type ON claims(claim_type);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_case_law_level ON case_law(precedent_level);
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
async def init_schema() -> None:
|
async def init_schema() -> None:
|
||||||
pool = await get_pool()
|
pool = await get_pool()
|
||||||
async with pool.acquire() as conn:
|
async with pool.acquire() as conn:
|
||||||
@@ -404,7 +449,8 @@ async def init_schema() -> None:
|
|||||||
await conn.execute(MIGRATIONS_SQL)
|
await conn.execute(MIGRATIONS_SQL)
|
||||||
await conn.execute(SCHEMA_V2_SQL)
|
await conn.execute(SCHEMA_V2_SQL)
|
||||||
await conn.execute(SCHEMA_V3_SQL)
|
await conn.execute(SCHEMA_V3_SQL)
|
||||||
logger.info("Database schema initialized (v1 + v2 + v3)")
|
await conn.execute(SCHEMA_V4_SQL)
|
||||||
|
logger.info("Database schema initialized (v1 + v2 + v3 + v4)")
|
||||||
|
|
||||||
|
|
||||||
# ── Case CRUD ───────────────────────────────────────────────────────
|
# ── Case CRUD ───────────────────────────────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user