#!/usr/bin/env python3
"""Bank batch-136: motion case-frame alternations.

Rows are hand-authored in the main loop from Patz local-case examples,
text-51 travel frames, and the Rule-93 motion lexicon. The script only
stores the rows and guards duplicates.
"""

from __future__ import annotations

import datetime as dt
import json
import re
import sqlite3
import sys

DB = "/mnt/donto-data/donto-resources/research/translation-training/kuku-yalanji-runpod-2026-06-30/synthetic/claude-synthetic-v1-2026-07-02/synthetic.db"
LABEL = "batch-136"
NOW = dt.datetime.now(dt.timezone.utc).replace(microsecond=0).isoformat().replace("+00:00", "Z")

DENY = {
    "nyawa", "jinbi", "jibin", "walba", "julmbu", "wanan", "ngampula",
    "yalama", "ngana-jinji", "jubuny", "wural", "bigan", "jiwuny",
    "warngkul", "wanaba", "jarrkunji", "munjal", "murku", "buni",
    "kunya", "milkan", "kulur-jambul", "janyji", "buburr", "jarrmba",
    "jinji", "daga", "wanka", "yumbul", "kuku-yumbul", "jubi",
    "yilbay", "jarrakay", "janka-yukil", "jukarr", "kunkul",
    "bubu-jandu", "bubu-warral", "jani-warra", "balbay-nja",
    "bunjurril", "buri", "baral",
}


def js(values: list[str]) -> str:
    return json.dumps(values, ensure_ascii=False)


ROWS = [
    (1, "The man went to the river.",
     "Dingkar wawubaja-nga dungan.",
     "dingkar wawubaja-nga dunga-ny | man river-LOC go-PAST",
     "motion_loc_goal", 5, js(["dingkar", "wawubaja", "dungay"]), js([]),
     "Rule 60/93: LOC doubles as allative goal; Patz has wawubaja-nga dunga-y.", "0.90"),
    (2, "The man came from the river.",
     "Dingkar wawubaja-muny kadan.",
     "dingkar wawubaja-muny kada-ny | man river-ABL come-PAST",
     "motion_abl_source", 5, js(["dingkar", "wawubaja", "kaday"]), js([]),
     "ABL -muny source contrasted with LOC/allative goal.", "0.88"),
    (3, "The woman went to the scrub.",
     "Jalbu madja-nga dungan.",
     "jalbu madja-nga dunga-ny | woman scrub-LOC go-PAST",
     "motion_loc_goal", 4, js(["jalbu", "madja", "dungay"]), js([]),
     "Rule 85: madja-nga LOC; LOC can mark motion goal.", "0.86"),
    (4, "The woman came from the scrub.",
     "Jalbu madja-muny kadan.",
     "jalbu madja-muny kada-ny | woman scrub-ABL come-PAST",
     "motion_abl_source", 4, js(["jalbu", "madja", "kaday"]), js([]),
     "ABL source contrast with preceding madja-nga goal row.", "0.86"),
    (5, "The child went into the house.",
     "Karrkay bayan-ba walan.",
     "karrkay bayan-ba wala-ny | child house-LOC enter-PAST",
     "motion_loc_enter", 4, js(["karrkay", "bayan", "walal"]), js([]),
     "Dictionary walal: enter/go into; LOC place frame.", "0.88"),
    (6, "The dog came out of the house.",
     "Kaya bayan-muny wandin.",
     "kaya bayan-muny wandi-ny | dog house-ABL come.out-PAST",
     "motion_abl_emerge", 4, js(["kaya", "bayan", "wandil"]), js([]),
     "Dictionary wandil = come out/get up; ABL marks source.", "0.86"),
    (7, "The child went into the scrub.",
     "Karrkay madja-nga walan.",
     "karrkay madja-nga wala-ny | child scrub-LOC enter-PAST",
     "motion_loc_enter", 4, js(["karrkay", "madja", "walal"]), js([]),
     "Walal enter with LOC place; contrasts house/scrub goal.", "0.84"),
    (8, "The bird flew from the tree.",
     "Buyi juku-muny marra-warrin.",
     "buyi juku-muny marra-warri-ny | bird tree-ABL fly-PAST",
     "motion_abl_source", 4, js(["buyi", "juku", "marra-warri"]), js([]),
     "ABL source with Rule 93 marra-warri fly; preserves fly/crawl contrast.", "0.86"),
    (9, "The child climbed on the tree.",
     "Karrkay juku-ngu dakan.",
     "karrkay juku-ngu daka-ny | child tree-LOC climb-PAST",
     "motion_loc_climb", 5, js(["karrkay", "juku", "dakal"]), js([]),
     "Patz text 51 tree-climb frame: juku-ngu daka-l/daka-ny.", "0.90"),
    (10, "Leaves fell from the tree.",
     "Birra juku-muny daran.",
     "birra juku-muny dara-ny | leaves tree-ABL fall-PAST",
     "motion_abl_fall", 4, js(["birra", "juku", "daray"]), js([]),
     "Rule 91 plant-part ABL from tree plus daray fall.", "0.86"),

    (11, "We two swam through the river.",
     "Ngali wawubaja-burr marijin.",
     "ngali wawubaja-burr mariji-ny | we.two.incl river-PERL swim-PAST",
     "motion_perl_traversal", 5, js(["ngali", "wawubaja", "mariji-y"]), js([]),
     "Patz ex.291: river-PERL swim through; subject varied to avoid duplication.", "0.90"),
    (12, "The dog ran through the scrub.",
     "Kaya madja-burr warrin.",
     "kaya madja-burr warri-ny | dog scrub-PERL run-PAST",
     "motion_perl_traversal", 4, js(["kaya", "madja", "warri"]), js([]),
     "PERL traversal through a place, with verified warri run.", "0.84"),
    (13, "The woman walked through the scrub.",
     "Jalbu madja-burr jilba-dungan.",
     "jalbu madja-burr jilba-dunga-ny | woman scrub-PERL walk-go-PAST",
     "motion_perl_walk", 4, js(["jalbu", "madja", "jilba-dunga-y"]), js([]),
     "Rule 93 walking verb plus Rule 85 traversal -burr.", "0.84"),
    (14, "The snake crawled through the scrub.",
     "Jarba madja-burr mara-warrin.",
     "jarba madja-burr mara-warri-ny | snake scrub-PERL crawl-PAST",
     "motion_perl_crawl", 5, js(["jarba", "madja", "mara-warri"]), js([]),
     "PERL traversal plus single-r mara-warri crawl.", "0.88"),
    (15, "The bird flew across the water.",
     "Buyi bana-burr marra-warrin.",
     "buyi bana-burr marra-warri-ny | bird water-PERL fly-PAST",
     "motion_perl_fly", 5, js(["buyi", "bana", "marra-warri"]), js([]),
     "PERL across/through water plus double-r marra-warri fly.", "0.86"),
    (16, "The child jumped over the log.",
     "Karrkay walmba kala-jalaman.",
     "karrkay walmba kala-jalama-ny | child log jump.over-PAST",
     "motion_jump_over_object", 4, js(["karrkay", "walmba", "kala-jalamal"]), js([]),
     "Dictionary kala-jalamal = jump over; familiar object frame.", "0.86"),
    (17, "The dog jumped from behind the tree.",
     "Kaya juku-muny kudamundu-muny jalaman.",
     "kaya juku-muny kudamundu-muny jalama-ny | dog tree-ABL behind-ABL jump-PAST",
     "motion_behind_abl", 5, js(["kaya", "juku", "kudamundu", "jalamal"]), js([]),
     "Patz ex.112: jump from behind the tree uses juku-muny kudamundu-muny.", "0.90"),
    (18, "The man went through the scrub.",
     "Dingkar madja-burr dungan.",
     "dingkar madja-burr dunga-ny | man scrub-PERL go-PAST",
     "motion_perl_go", 4, js(["dingkar", "madja", "dungay"]), js([]),
     "PERL traversal with simple motion verb; avoids baral road rows.", "0.84"),
    (19, "The young men went through the grass.",
     "Warru-warru jikan-burr dungan.",
     "warru-warru jikan-burr dunga-ny | young.men grass-PERL go-PAST",
     "motion_perl_go", 4, js(["warru", "jikan", "dungay"]), js([]),
     "Grass lexeme plus PERL traversal; no road/path lexeme introduced.", "0.84"),
    (20, "The dog followed behind the man.",
     "Kaya-ngka dingkar kudamundu wukurrin.",
     "kaya-ngka dingkar kudamundu wukurri-ny | dog-ERG man behind follow-PAST",
     "motion_behind_follow", 5, js(["kaya", "dingkar", "kudamundu", "wukurril"]), js([]),
     "Patz ex.111 and text 12: kudamundu with following means behind/from behind.", "0.88"),

    (21, "The man went with a dog.",
     "Dingkar kaya-nji dungan.",
     "dingkar kaya-nji dunga-ny | man dog-COMIT go-PAST",
     "motion_comit_companion", 5, js(["dingkar", "kaya", "dungay"]), js([]),
     "COMIT accompaniment; Patz has motion rows with kaya-nji.", "0.88"),
    (22, "The man went without a dog.",
     "Dingkar kaya-kari dungan.",
     "dingkar kaya-kari dunga-ny | man dog-PRIV go-PAST",
     "motion_priv_companion_absent", 5, js(["dingkar", "kaya", "dungay"]), js([]),
     "Rule 62: PRIV -kari marks without/lacking, not ABESS -mundu.", "0.86"),
    (23, "The young man went with a spear.",
     "Warru kalka-ji dungan.",
     "warru kalka-ji dunga-ny | young.man spear-COMIT go-PAST",
     "motion_comit_tool", 5, js(["warru", "kalka", "dungay"]), js([]),
     "Patz ex.551: going with spear/axe uses COMIT.", "0.90"),
    (24, "The young man went without a spear.",
     "Warru kalka-kari dungan.",
     "warru kalka-kari dunga-ny | young.man spear-PRIV go-PAST",
     "motion_priv_tool_absent", 5, js(["warru", "kalka", "dungay"]), js([]),
     "PRIV contrast to preceding COMIT tool row.", "0.86"),
    (25, "The woman came with food.",
     "Jalbu mayi-ji kadan.",
     "jalbu mayi-ji kada-ny | woman food-COMIT come-PAST",
     "motion_comit_carried_item", 4, js(["jalbu", "mayi", "kaday"]), js([]),
     "COMIT having/accompaniment with a carried item; simple source-safe noun.", "0.84"),
    (26, "The woman came without food.",
     "Jalbu mayi-kari kadan.",
     "jalbu mayi-kari kada-ny | woman food-PRIV come-PAST",
     "motion_priv_absence", 4, js(["jalbu", "mayi", "kaday"]), js([]),
     "PRIV absence paired with mayi-ji COMIT row.", "0.84"),
    (27, "I went with a friend.",
     "Ngayu jawun-unji dungan.",
     "ngayu jawun-unji dunga-ny | I friend-COMIT:pt go-PAST",
     "motion_comit_human_companion", 5, js(["ngayu", "jawun", "dungay"]), js([]),
     "Patz ex.163: Ngayu jawun-unji dunga-y.", "0.90"),
    (28, "I went without a friend.",
     "Ngayu jawun-kari dungan.",
     "ngayu jawun-kari dunga-ny | I friend-PRIV go-PAST",
     "motion_priv_human_companion", 4, js(["ngayu", "jawun", "dungay"]), js([]),
     "PRIV -kari on human companion noun; contrasts ex.163 COMIT.", "0.84"),
    (29, "The old woman was coming from up there.",
     "Wulbuman wangkar-mundu kankadan.",
     "wulbuman wangkar-mundu kankada-ny | old.woman up-ABESS come.REDUP-PAST",
     "motion_abess_vantage", 5, js(["wulbuman", "wangkar", "kankaday"]), js([]),
     "Text 51 uses wangkar-mundu with kankada-ny; ABESS is vantage/source, not privative.", "0.90"),
    (30, "People shouted from down there.",
     "Bama yirrka-n-yirrkay badabada-mundu.",
     "bama yirrka-n-yirrka-y badabada-mundu | people shout-REDUP-NONPAST down.there-ABESS",
     "abess_vantage_nonmotion", 5, js(["bama", "yirrkay", "badabada"]), js([]),
     "Patz ex.110: Bama yirrka-n-yirrka-y badabada-mundu.", "0.90"),

    (31, "The man went to the river to spear fish.",
     "Dingkar wawubaja-nga dungan kuyu dama-nka.",
     "dingkar wawubaja-nga dunga-ny kuyu dama-nka | man river-LOC go-PAST fish spear-PURP",
     "motion_goal_purpose", 5, js(["dingkar", "wawubaja", "dungay", "kuyu", "damal"]), js([]),
     "Patz ex.406: went to river to spear fish; subject varied.", "0.90"),
    (32, "The woman went to the scrub to get food.",
     "Jalbu madja-nga dungan mayi mani-nka.",
     "jalbu madja-nga dunga-ny mayi mani-nka | woman scrub-LOC go-PAST food get-PURP",
     "motion_goal_purpose", 4, js(["jalbu", "madja", "dungay", "mayi", "manil"]), js([]),
     "LOC goal plus purposive `mani-nka`; no DAT confusion.", "0.86"),
    (33, "The child went to the house to eat food.",
     "Karrkay bayan-ba dungan mayi nuka-nka.",
     "karrkay bayan-ba dunga-ny mayi nuka-nka | child house-LOC go-PAST food eat-PURP",
     "motion_goal_purpose", 4, js(["karrkay", "bayan", "dungay", "mayi", "nukal"]), js([]),
     "LOC goal plus purposive `nuka-nka`.", "0.86"),
    (34, "Mother got up to see the child.",
     "Ngamu wandin karrkay nyaji-nka.",
     "ngamu wandi-ny karrkay nyaji-nka | mother get.up-PAST child see-PURP",
     "motion_purpose", 5, js(["ngamu", "wandil", "karrkay", "nyajil"]), js([]),
     "Patz ex.407 has wandi-ny with a seeing purposive.", "0.88"),
    (35, "The old man went up to get the spear.",
     "Mukul-dingkar wangkar dungan kalka mani-nka.",
     "mukul-dingkar wangkar dunga-ny kalka mani-nka | old-man up go-PAST spear get-PURP",
     "motion_direction_purpose", 5, js(["mukul-dingkar", "wangkar", "dungay", "kalka", "manil"]), js([]),
     "Text 51 ex.652 pattern: wangkar dunga-ny ... mani-nka.", "0.88"),
    (36, "They went to the river to get fish.",
     "Jana wawubaja-nga dungan kuyu mani-nka.",
     "jana wawubaja-nga dunga-ny kuyu mani-nka | they river-LOC go-PAST fish get-PURP",
     "motion_goal_purpose", 4, js(["jana", "wawubaja", "dungay", "kuyu", "manil"]), js([]),
     "River LOC goal plus purposive; source-shaped from hunting/fishing motion examples.", "0.86"),
    (37, "The woman took food to camp.",
     "Jalbu-ngku mayi bayan-ka wundin.",
     "jalbu-ngku mayi bayan-ka wundi-ny | woman-ERG food camp-DAT bring/take-PAST",
     "motion_dative_goal_transfer", 4, js(["jalbu", "mayi", "bayan", "wundil"]), js([]),
     "Rule 93 wundil bring/take; DAT goal used for transfer-to-camp.", "0.84"),
    (38, "The old man took the spear to camp.",
     "Mukul-dingkar-angka kalka bayan-ka wundin.",
     "mukul-dingkar-angka kalka bayan-ka wundi-ny | old-man-ERG spear camp-DAT take-PAST",
     "motion_dative_goal_transfer", 4, js(["mukul-dingkar", "kalka", "bayan", "wundil"]), js([]),
     "Wundil take plus DAT goal; avoids uncertain person-recipient frame.", "0.84"),
    (39, "Mother took the child to water.",
     "Ngamu-ngku karrkay bana-ka barrman.",
     "ngamu-ngku karrkay bana-ka barrma-ny | mother-ERG child water-DAT escort/take-PAST",
     "motion_dative_goal_escort", 4, js(["ngamu", "karrkay", "bana", "barrmal"]), js([]),
     "Barrmal person-escort frame with DAT goal.", "0.86"),
    (40, "The man carried wood from the scrub to camp.",
     "Dingkar-angka juku madja-muny bayan-ka jarrakulban.",
     "dingkar-angka juku madja-muny bayan-ka jarrakulba-ny | man-ERG wood scrub-ABL camp-DAT carry-PAST",
     "motion_source_goal_carry", 5, js(["dingkar", "juku", "madja", "bayan", "jarrakulbal"]), js([]),
     "Combines ABL source + DAT goal with verified carry verb.", "0.86"),
    (41, "The old woman brought food from the river to camp.",
     "Mukul-jalbu-ngku mayi wawubaja-muny bayan-ka wundin.",
     "mukul-jalbu-ngku mayi wawubaja-muny bayan-ka wundi-ny | old-woman-ERG food river-ABL camp-DAT bring-PAST",
     "motion_source_goal_transfer", 5, js(["mukul-jalbu", "mayi", "wawubaja", "bayan", "wundil"]), js([]),
     "ABL source + DAT goal transfer frame.", "0.86"),
    (42, "The child dropped the stone on the foot.",
     "Karrkay-ngku kulji jina-nga daray-manin.",
     "karrkay-ngku kulji jina-nga dara-y-mani-ny | child-ERG stone foot-LOC fall-y-CAUS-PAST",
     "motion_loc_impact_goal", 5, js(["karrkay", "kulji", "jina", "daray-manil"]), js([]),
     "Patz ex.521 drop uses foot-LOC impact goal; possessor omitted for simplicity.", "0.88"),

    (43, "I came back to camp.",
     "Ngayu bayan-ba kadan-baja.",
     "ngayu bayan-ba kada-ny-baja | I camp-LOC come-PAST-back",
     "motion_return_loc_goal", 5, js(["ngayu", "bayan", "kaday", "-baja"]), js([]),
     "Rule 90/93: motion -baja = back/again; LOC goal.", "0.88"),
    (44, "They went on again through the scrub.",
     "Jana madja-burr dungan-baja.",
     "jana madja-burr dunga-ny-baja | they scrub-PERL go-PAST-again/on",
     "motion_again_perl", 5, js(["jana", "madja", "dungay", "-baja"]), js([]),
     "Patz travel text uses dunga-ny-baja for going on; PERL path added.", "0.86"),
    (45, "The two turned back from the river.",
     "Bula wawubaja-muny nyunban.",
     "bula wawubaja-muny nyunba-ny | they.two river-ABL turn.back-PAST",
     "motion_return_abl_source", 5, js(["bula", "wawubaja", "nyunbay"]), js([]),
     "Nyunbay turn back with ABL source contrast.", "0.86"),
    (46, "The woman came back from the house.",
     "Jalbu bayan-muny kadan-baja.",
     "jalbu bayan-muny kada-ny-baja | woman house-ABL come-PAST-back",
     "motion_return_abl_source", 5, js(["jalbu", "bayan", "kaday", "-baja"]), js([]),
     "ABL source plus motion -baja back/again.", "0.86"),
    (47, "The dog ran back to camp.",
     "Kaya bayan-ba warrin-baja.",
     "kaya bayan-ba warri-ny-baja | dog camp-LOC run-PAST-back",
     "motion_return_loc_goal", 4, js(["kaya", "bayan", "warri", "-baja"]), js([]),
     "Motion -baja on run, with LOC goal.", "0.84"),
    (48, "The children came back to mother.",
     "Karrkay-karrkay ngamu-ndu kadan-baja.",
     "karrkay-karrkay ngamu-ndu kada-ny-baja | children mother-LOC:pt come-PAST-back",
     "motion_return_human_goal", 5, js(["karrkay", "ngamu", "kaday", "-baja"]), js([]),
     "Human/kin goal uses potent LOC; compare jinkurr-bul-undu and Queenie-nda examples.", "0.86"),
    (49, "The man came from there and came back to camp.",
     "Dingkar yinya-muny kadan, bayan-ba kadan-baja.",
     "dingkar yinya-muny kada-ny, bayan-ba kada-ny-baja | man that-ABL come-PAST camp-LOC come-PAST-back",
     "motion_source_return_goal", 5, js(["dingkar", "yinya", "kaday", "bayan", "-baja"]), js([]),
     "ABL demonstrative source plus LOC return goal.", "0.86"),
    (50, "We went from camp through the scrub to the river.",
     "Nganjin bayan-muny madja-burr wawubaja-nga dungan.",
     "nganjin bayan-muny madja-burr wawubaja-nga dunga-ny | we.excl camp-ABL scrub-PERL river-LOC go-PAST",
     "motion_source_path_goal", 5, js(["nganjin", "bayan", "madja", "wawubaja", "dungay"]), js([]),
     "Full source-path-goal case-frame chain: ABL + PERL + LOC/allative.", "0.88"),
]


def scan_static() -> list[str]:
    issues: list[str] = []
    if len(ROWS) != 50:
        issues.append(f"expected 50 rows, got {len(ROWS)}")
    seqs = [r[0] for r in ROWS]
    if seqs != list(range(1, 51)):
        issues.append(f"seqs must be 1..50, got {seqs[:5]}...{seqs[-5:]}")
    seen_ku: set[str] = set()
    for row in ROWS:
        seq, english, kuku, analysis, _frame, _tier, words_used, loans_used, _evidence, _confidence = row
        label = f"{LABEL}.{seq:02d}"
        if not english[:1].isupper() or english.rstrip("'\"").rstrip()[-1:] not in ".!?":
            issues.append(f"{label}: English must be capitalized and final-punctuated")
        if " | " not in analysis:
            issues.append(f"{label}: analysis missing gloss separator")
        if not kuku[:1].isupper():
            issues.append(f"{label}: Kuku surface must start uppercase")
        for field_name, payload in (("words_used", words_used), ("loans_used", loans_used)):
            try:
                json.loads(payload)
            except Exception as exc:
                issues.append(f"{label}: {field_name} is not JSON: {exc}")
        low = f" {kuku.lower()} {analysis.lower()} "
        for word in DENY:
            if re.search(rf"(?<![a-z]){re.escape(word)}(?![a-z])", low):
                issues.append(f"{label}: denied phantom/wrong-sense token {word!r}")
        if kuku.lower() in seen_ku:
            issues.append(f"{label}: duplicate Kuku surface within batch")
        seen_ku.add(kuku.lower())
    return issues


def main() -> int:
    issues = scan_static()
    if issues:
        print("pre-bank scan failed:")
        for issue in issues:
            print(f"  - {issue}")
        return 1

    db = sqlite3.connect(DB)
    db.execute("PRAGMA foreign_keys = ON")
    db.execute("BEGIN")
    existing = db.execute("SELECT id FROM batches WHERE label=?", (LABEL,)).fetchone()
    if existing:
        batch_id = existing[0]
        accepted = db.execute(
            "SELECT COUNT(*) FROM sentences WHERE batch_id=? AND status IN ('accepted','revised')",
            (batch_id,),
        ).fetchone()[0]
        if accepted:
            raise SystemExit(f"{LABEL} already has accepted/revised rows; refusing to overwrite")
        db.execute("DELETE FROM reviews WHERE sentence_id IN (SELECT id FROM sentences WHERE batch_id=?)", (batch_id,))
        db.execute("DELETE FROM sentences WHERE batch_id=?", (batch_id,))
        db.execute("UPDATE batches SET notes=?, created_at=? WHERE id=?", ("rebanked under_review", NOW, batch_id))
    else:
        cur = db.execute(
            "INSERT INTO batches(label, cheatsheet_version, guide_version, notes, created_at) VALUES(?,?,?,?,?)",
            (LABEL, "Rule 94 draft: motion case-frame alternations", "operator-guide-2026-07-07", "under_review", NOW),
        )
        batch_id = cur.lastrowid

    dupes = []
    for seq, _english, kuku, *_rest in ROWS:
        hit = db.execute(
            """
            SELECT b.label, s.seq
            FROM sentences s JOIN batches b ON b.id=s.batch_id
            WHERE lower(trim(s.kuku))=lower(trim(?))
              AND s.status!='rejected'
              AND s.batch_id!=?
            """,
            (kuku, batch_id),
        ).fetchone()
        if hit:
            dupes.append(f"{LABEL}.{seq:02d} duplicates {hit[0]}.{hit[1]:02d}: {kuku}")
    if dupes:
        db.rollback()
        print("cross-corpus duplicate check failed:")
        for dupe in dupes:
            print(f"  - {dupe}")
        return 1

    db.executemany(
        """
        INSERT INTO sentences(
            batch_id, seq, english, kuku, analysis, frame, tier, words_used,
            loans_used, evidence, status, confidence, rights_status, author,
            created_at, updated_at
        ) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
        """,
        [
            (
                batch_id, seq, english, kuku, analysis, frame, tier, words_used,
                loans_used, evidence, "under_review", confidence,
                "project_approved_synthetic_pending_elder_verification",
                "claude-main", NOW, NOW,
            )
            for seq, english, kuku, analysis, frame, tier, words_used, loans_used, evidence, confidence in ROWS
        ],
    )
    db.commit()
    count = db.execute("SELECT COUNT(*) FROM sentences WHERE batch_id=?", (batch_id,)).fetchone()[0]
    avg_words = db.execute(
        "SELECT AVG(LENGTH(kuku)-LENGTH(REPLACE(kuku,' ',''))+1.0) FROM sentences WHERE batch_id=?",
        (batch_id,),
    ).fetchone()[0]
    print(f"banked {LABEL}: {count} rows under_review; avg Kuku words/row={avg_words:.2f}")
    return 0


if __name__ == "__main__":
    sys.exit(main())
