#!/usr/bin/env python3
"""Bank batch-135: movement, path-following, return, carrying, and travel.

Rows are hand-authored in the main loop from Patz narrative motion sections,
Rule 85 geography cautions, and verified motion/travel dictionary entries.
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-135"
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",
}


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


ROWS = [
    (1, "The two came from the west.",
     "Bula kuwa-muny kadan.",
     "bula kuwa-muny kada-ny | they.two west-ABL come-PAST",
     "motion_come_from_source", 4, js(["bula", "kuwa", "kaday"]), js([]),
     "Patz text 51 line 2: coming from the west/source.", "0.88"),
    (2, "The two came and went to the river.",
     "Bula kadan, bula wawubaja-nga dungan.",
     "bula kada-ny, bula wawubaja-nga dunga-ny | they.two come-PAST they.two river-LOC go-PAST",
     "motion_come_then_go_goal", 5, js(["bula", "kaday", "wawubaja", "dungay"]), js([]),
     "Patz 5.5.1 / text 51 line 5: come to a scene, then go to river.", "0.90"),
    (3, "The old woman went up to get the dog.",
     "Wulbuman wangkar dungan kaya-nda mani-nka.",
     "wulbuman wangkar dunga-ny kaya-nda mani-nka | old.woman up go-PAST dog-LOC get-PURP",
     "motion_go_up_purpose", 5, js(["wulbuman", "wangkar", "dungay", "kaya", "manil"]), js([]),
     "Patz 5.5.1 ex.652: wulbuman wangkar dunga-ny kaya-nda mani-nka.", "0.90"),
    (4, "Going down, she came to the river.",
     "Badabada dunga-nya, wawubaja-nga kadan.",
     "badabada dunga-nya, wawubaja-nga kada-ny | down.there go-SUB river-LOC come-PAST",
     "motion_subordinate_go_arrive", 5, js(["badabada", "dungay", "wawubaja", "kaday"]), js([]),
     "Patz text 51 line 20: badabada dunga-nya, wawubaja-nga kada-ny.", "0.92"),
    (5, "The old woman was coming from up there with a dog.",
     "Wulbuman wangkar-mundu kaya-nji kankadan.",
     "wulbuman wangkar-mundu kaya-nji kankada-ny | old.woman up-ABESS dog-COMIT come.REDUP-PAST",
     "motion_reduplicated_come_from_vantage", 5, js(["wulbuman", "wangkar", "kaya", "kankaday"]), js([]),
     "Patz text 51 line 15: coming from up there with a dog.", "0.90"),
    (6, "The two went west and came to the mountain top.",
     "Bula kuwa dungan, wuburr-bu kadan.",
     "bula kuwa dunga-ny, wuburr-bu kada-ny | they.two west go-PAST mountain.top-LOC come-PAST",
     "motion_go_direction_arrive", 5, js(["bula", "kuwa", "dungay", "wuburr", "kaday"]), js([]),
     "Patz text 51 line 46: went west and came to the mountain top.", "0.88"),

    (7, "The pair of young men went walking to the river.",
     "Warru-bulal jambul wawubaja-nga jilba-dungan.",
     "warru-bulal jambul wawubaja-nga jilba-dunga-ny | young.man-pair two river-LOC walk-go-PAST",
     "motion_walk_go", 4, js(["warru", "-bulal", "jambul", "wawubaja", "jilba-dungay"]), js([]),
     "Patz text 51 line 1 has warru-bulal jambul, bula jilba-dunga-ny; batch avoids exact duplicate.", "0.86"),
    (8, "The child walks now.",
     "Karrkay jilba dungay niji.",
     "karrkay jilba dunga-y niji | child walk go-NONPAST now",
     "motion_walk_now", 4, js(["karrkay", "jilba", "dungay", "niji"]), js([]),
     "Dictionary jilba/jilba-dunga-y walking frame; avoids opaque example suffixes.", "0.84"),
    (9, "They went walkabout.",
     "Jana jilba dungan.",
     "jana jilba dunga-ny | they walk go-PAST",
     "motion_walkabout_attested", 4, js(["jana", "jilba", "dungay"]), js([]),
     "Dictionary usage: Jana jilba dungan, 'They went walkabout'.", "0.90"),
    (10, "The old man walked through the scrub.",
     "Mukul-dingkar madja-burr jilba-dungan.",
     "mukul-dingkar madja-burr jilba-dunga-ny | old-man scrub-PERL walk-go-PAST",
     "motion_walk_through_country", 4, js(["mukul-dingkar", "madja", "jilba-dungay"]), js([]),
     "Uses Rule 85 traversal -burr with verified jilba-dunga-y.", "0.84"),
    (11, "The dog ran down to the river.",
     "Kaya bada wawubaja-nga warrin.",
     "kaya bada wawubaja-nga warri-ny | dog down river-LOC run-PAST",
     "motion_run_goal", 4, js(["kaya", "bada", "wawubaja", "warri"]), js([]),
     "Dictionary warri = run/fly; local river goal from Rule 85.", "0.86"),
    (12, "The children ran in fright.",
     "Karrkay-karrkay yini-ji warrin.",
     "karrkay-karrkay yini-ji warri-ny | child-REDUP fright-COMIT run-PAST",
     "motion_run_with_state", 4, js(["karrkay", "yini", "warri"]), js([]),
     "Patz text 36 line 48 has yini-ji warrin 'ran in fright'.", "0.88"),
    (13, "The dog keeps running.",
     "Kaya wanarri.",
     "kaya wanarri-y | dog run.REDUP-NONPAST",
     "motion_keep_running", 4, js(["kaya", "wanarriy"]), js([]),
     "Patz text 51 line 49 and errata: wanarri-y = keep/run on.", "0.88"),
    (14, "The dog ran and ran.",
     "Kaya warrin, warrin, warrin.",
     "kaya warri-ny, warri-ny, warri-ny | dog run-PAST run-PAST run-PAST",
     "motion_repeated_run", 4, js(["kaya", "warri"]), js([]),
     "Patz text 51 line 49 repeats warri-ny for run and run.", "0.88"),
    (15, "The young man went by a shortcut.",
     "Warru kurrkal-warrin.",
     "warru kurrkal-warri-ny | young.man shortcut-run/go-PAST",
     "motion_shortcut", 4, js(["warru", "kurrkal-warri"]), js([]),
     "Dictionary kurrkal-warri = go by a shortcut.", "0.84"),
    (16, "The child walked single file behind mother.",
     "Karrkay juru-kulbawan ngamu kudamundu.",
     "karrkay juru-kulbawa-ny ngamu kudamundu | child single.file.walk-PAST mother behind",
     "motion_single_file", 4, js(["karrkay", "juru-kulbaway", "ngamu", "kudamundu"]), js([]),
     "Dictionary juru-kulbaway = walk single file; kudamundu = behind.", "0.84"),

    (17, "The dog followed the two.",
     "Kaya-ngka bulaniny wukurrin.",
     "kaya-ngka bulaniny wukurri-ny | dog-ERG they.two.ACC follow-PAST",
     "motion_follow_object", 5, js(["kaya", "bulaniny", "wukurril"]), js([]),
     "Patz text 51 line 43: Kaya-ngka wukurri-ny-da bulaniny.", "0.90"),
    (18, "The dog followed the two from behind.",
     "Kaya-ngka bulaniny kudamundu wukurrin.",
     "kaya-ngka bulaniny kudamundu wukurri-ny | dog-ERG they.two.ACC behind follow-PAST",
     "motion_follow_from_behind", 5, js(["kaya", "bulaniny", "kudamundu", "wukurril"]), js([]),
     "Patz text 12 has kudamundu wukurri-nya; combines with text 51 dog-following frame.", "0.88"),
    (19, "We could not keep following.",
     "Nganjin murruji wukurril-wukurrin.",
     "nganjin murruji wukurri-l-wukurri-ny | we.excl unable follow-l-REDUP-PAST",
     "motion_unable_follow_redup", 5, js(["nganjin", "murruji", "wukurril"]), js([]),
     "Patz ex.654: murruji wukurri-l-wukurri-ny.", "0.90"),
    (20, "The man followed the track.",
     "Dingkar-angka jina wukurrin.",
     "dingkar-angka jina wukurri-ny | man-ERG track follow-PAST",
     "motion_follow_track", 4, js(["dingkar", "jina", "wukurril"]), js([]),
     "Dictionary wukurril = follow; jina can be foot/track in tracking frames.", "0.84"),
    (21, "The dog chased the children.",
     "Kaya-ngka karrkay-karrkay kangan.",
     "kaya-ngka karrkay-karrkay kanga-ny | dog-ERG child-REDUP chase-PAST",
     "motion_chase", 4, js(["kaya", "karrkay", "kangal"]), js([]),
     "Dictionary kangal = chase.", "0.86"),
    (22, "The old woman chased the dog from camp.",
     "Wulbuman-angka kaya kangan bayan-muny.",
     "wulbuman-angka kaya kanga-ny bayan-muny | old.woman-ERG dog chase-PAST camp-ABL",
     "motion_chase_from_source", 4, js(["wulbuman", "kaya", "kangal", "bayan"]), js([]),
     "Kangal chase plus source ABL; no unattested 'drive away' coinage.", "0.84"),
    (23, "We all turned back.",
     "Ngana nyunban.",
     "ngana nyunba-ny | we.all turn.back-PAST",
     "motion_return_turn_back", 4, js(["ngana", "nyunbay"]), js([]),
     "Patz travel text: Ngana nyunba-y-baja? and nyunba-ny.", "0.90"),
    (24, "The man came from there and turned back.",
     "Dingkar yinya-muny kadan, nyunban.",
     "dingkar yinya-muny kada-ny, nyunba-ny | man that-ABL come-PAST turn.back-PAST",
     "motion_come_then_return", 4, js(["dingkar", "yinya", "kaday", "nyunbay"]), js([]),
     "Controlled from Patz travel text line 9 without the pastor loan.", "0.86"),
    (25, "The two came back to camp.",
     "Bula bayan-ba kadan-baja.",
     "bula bayan-ba kada-ny-baja | they.two camp-LOC come-PAST-again/back",
     "motion_return_to_camp", 4, js(["bula", "bayan", "kaday", "-baja"]), js([]),
     "Rule 90: -baja on motion verbs = again/back.", "0.86"),

    (26, "The old woman brought food to camp.",
     "Mukul-jalbu-ngku mayi bayan-ka wundin.",
     "mukul-jalbu-ngku mayi bayan-ka wundi-ny | old-woman-ERG food camp-DAT bring-PAST",
     "motion_bring_goal", 4, js(["mukul-jalbu", "mayi", "bayan", "wundil"]), js([]),
     "Dictionary wundil = bring/take; goal camp-DAT.", "0.86"),
    (27, "The man took the spear to the river.",
     "Dingkar-angka kalka wawubaja-nga wundin.",
     "dingkar-angka kalka wawubaja-nga wundi-ny | man-ERG spear river-LOC take-PAST",
     "motion_take_goal", 4, js(["dingkar", "kalka", "wawubaja", "wundil"]), js([]),
     "Wundil covers bring/take; river LOC can mark movement goal.", "0.84"),
    (28, "The elder sister carried the little child on her back.",
     "Babarr-angka karrkay buban muku-ba jarrakulban.",
     "babarr-angka karrkay buban muku-ba jarrakulba-ny | elder.sister-ERG child small back-LOC carry-PAST",
     "motion_carry_body_location", 4, js(["babarr", "karrkay", "buban", "muku", "jarrakulbal"]), js([]),
     "Dictionary jarrakulbal = carry; body-location carrying frame.", "0.86"),
    (29, "The man carried the log.",
     "Dingkar-angka juku jarrakulban.",
     "dingkar-angka juku jarrakulba-ny | man-ERG wood/log carry-PAST",
     "motion_carry_object", 4, js(["dingkar", "juku", "jarrakulbal"]), js([]),
     "Jarrakulbal carry with broad juku tree/wood/log object.", "0.84"),
    (30, "I took my younger sister to grandmother.",
     "Ngayu jinkurr barrman kami-nda.",
     "ngayu jinkurr barrma-ny kami-nda | I younger.sister escort/take-PAST grandmother-DAT/LOC",
     "motion_escort_attested", 5, js(["ngayu", "jinkurr", "barrmal", "kami"]), js([]),
     "Dictionary barrmal usage: ngayu jinkurr barrman kaminda.", "0.90"),
    (31, "Mother took the children to water.",
     "Ngamu-ngku karrkay-karrkay bana-ka barrman.",
     "ngamu-ngku karrkay-karrkay bana-ka barrma-ny | mother-ERG child-REDUP water-DAT escort/take-PAST",
     "motion_escort_goal", 4, js(["ngamu", "karrkay", "bana", "barrmal"]), js([]),
     "Barrmal extended within its take/escort-person frame.", "0.84"),
    (32, "He entered the house.",
     "Nyulu bayan-ba walan.",
     "nyulu bayan-ba wala-ny | he house-LOC enter-PAST",
     "motion_enter_attested", 5, js(["nyulu", "bayan", "walal"]), js([]),
     "Dictionary walal usage: Nyulu bayanba walan.", "0.90"),
    (33, "The child came out of the house.",
     "Karrkay bayan-muny wandin.",
     "karrkay bayan-muny wandi-ny | child house-ABL get.up/come.out-PAST",
     "motion_come_out", 4, js(["karrkay", "bayan", "wandil"]), js([]),
     "Errata correction: wandil is real = get up, wake, come out.", "0.86"),
    (34, "The child got up at dawn.",
     "Karrkay muduwajuny wandin.",
     "karrkay muduwajuny wandi-ny | child dawn get.up-PAST",
     "motion_get_up_time", 4, js(["karrkay", "muduwajuny", "wandil"]), js([]),
     "Wandil get up plus Rule 89 dawn temporal.", "0.86"),
    (35, "The dog went into the scrub.",
     "Kaya madja-nga walan.",
     "kaya madja-nga wala-ny | dog scrub-LOC enter-PAST",
     "motion_enter_place", 4, js(["kaya", "madja", "walal"]), js([]),
     "Walal enter with LOC place; madja verified scrub/rainforest.", "0.84"),

    (36, "We two climbed the tree.",
     "Ngali juku-ngu dakan.",
     "ngali juku-ngu daka-ny | we.two.incl tree-LOC climb-PAST",
     "motion_climb_tree", 5, js(["ngali", "juku", "dakal"]), js([]),
     "Patz text 51 line 11-12: ngali juku-ngu daka-l; bula daka-ny.", "0.90"),
    (37, "The old man climbed the tree.",
     "Mukul-dingkar juku-ngu dakan.",
     "mukul-dingkar juku-ngu daka-ny | old-man tree-LOC climb-PAST",
     "motion_climb_tree", 4, js(["mukul-dingkar", "juku", "dakal"]), js([]),
     "Dictionary dakal = climb; tree LOC frame from text 51.", "0.86"),
    (38, "The child jumped from the boat.",
     "Karrkay buwun-muny jalaman.",
     "karrkay buwun-muny jalama-ny | child boat-ABL jump-PAST",
     "motion_jump_from_source", 4, js(["karrkay", "buwun", "jalamal"]), js([]),
     "Dictionary jalamal = jump/hop/skip and get out of boat/truck/car/plane.", "0.86"),
    (39, "The dog jumped over the log.",
     "Kaya walmba kala-jalaman.",
     "kaya walmba kala-jalama-ny | dog log jump.over-PAST",
     "motion_jump_over", 4, js(["kaya", "walmba", "kala-jalamal"]), js([]),
     "Dictionary kala-jalamal = jump over.", "0.86"),
    (40, "The branch fell from the tree.",
     "Dakil juku-muny daran.",
     "dakil juku-muny dara-ny | branch tree-ABL fall-PAST",
     "motion_fall_from_source", 4, js(["dakil", "juku", "daray"]), js([]),
     "Daray fall plus Rule 91 part-from-tree ABL.", "0.84"),
    (41, "The child dropped the stone.",
     "Karrkay-ngku kulji daray-manin.",
     "karrkay-ngku kulji dara-y-mani-ny | child-ERG stone fall-y-CAUS-PAST",
     "motion_drop_causative", 5, js(["karrkay", "kulji", "daray-manil"]), js([]),
     "Patz 4.5.2 ex.521 / dictionary daray-manil = drop.", "0.88"),
    (42, "The boat drifted on the water.",
     "Buwun bana-nga jarmbil-jarmbil.",
     "buwun bana-nga jarmbil-jarmbil | boat water-LOC drift-REDUP",
     "motion_drift_water", 4, js(["buwun", "bana", "jarmbil"]), js([]),
     "Dictionary jarmbil usage: Yinya buwun jarmbil-jarmbil.", "0.86"),
    (43, "We swam through the river.",
     "Nganjin wawubaja-burr marijin.",
     "nganjin wawubaja-burr mariji-ny | we.excl river-PERL swim-PAST",
     "motion_swim_through", 5, js(["nganjin", "wawubaja", "mariji-y"]), js([]),
     "Patz ex.291: mariji-ny swim through water/river.", "0.90"),
    (44, "The child swam in the water.",
     "Karrkay bana-nga marijin.",
     "karrkay bana-nga mariji-ny | child water-LOC swim-PAST",
     "motion_swim_locative", 4, js(["karrkay", "bana", "mariji-y"]), js([]),
     "Mariji-y swim; water LOC frame.", "0.86"),
    (45, "The snake crawled through the grass.",
     "Jarba jikan-burr mara-warrin.",
     "jarba jikan-burr mara-warri-ny | snake grass-PERL crawl-PAST",
     "motion_crawl", 5, js(["jarba", "jikan", "mara-warri"]), js([]),
     "Dictionary mara-warri = crawl; keep single-r contrast with marra-warri fly.", "0.88"),
    (46, "The bird flew across the river.",
     "Buyi wawubaja-burr marra-warrin.",
     "buyi wawubaja-burr marra-warri-ny | bird river-PERL fly-PAST",
     "motion_fly_across", 5, js(["buyi", "wawubaja", "marra-warri"]), js([]),
     "Dictionary marra-warri = fly; Rule 77 warns against confusing with mara-warri crawl.", "0.88"),
    (47, "The black cockatoos flew in the late afternoon.",
     "Kadanji yilay-yilay marra-warrin.",
     "kadanji yilay-yilay marra-warri-ny | black.cockatoo late.afternoon fly-PAST",
     "motion_bird_fly_time", 4, js(["kadanji", "yilay-yilay", "marra-warri"]), js([]),
     "Bird lexicon plus Rule 89 late-afternoon temporal.", "0.86"),
    (48, "The man went to meet them.",
     "Dingkar jana-nka maku-warrin.",
     "dingkar jana-nka maku-warri-ny | man them-DAT go.to.meet-PAST",
     "motion_go_to_meet", 4, js(["dingkar", "jana", "maku-warri"]), js([]),
     "Dictionary maku-warri = go to meet someone.", "0.84"),
    (49, "The dog followed the man to meet him.",
     "Kaya-ngka dingkar maku-wukurrin.",
     "kaya-ngka dingkar maku-wukurri-ny | dog-ERG man follow.to.meet-PAST",
     "motion_follow_to_meet", 4, js(["kaya", "dingkar", "maku-wukurril"]), js([]),
     "Dictionary maku-wukurril = follow to meet someone.", "0.84"),
    (50, "The old man came close to the shallow water.",
     "Mukul-dingkar ngundu kadan yalkan-ba.",
     "mukul-dingkar ngundu kada-ny yalkan-ba | old-man close come-PAST shallow.water-LOC",
     "motion_come_close_goal", 5, js(["mukul-dingkar", "ngundu", "kaday", "yalkan"]), js([]),
     "Patz text 36 line 33: Ngundu kada-y yalkan-ba!", "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 93 draft: motion/travel lexicon", "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())
