From eb8a4d5a66abbf1e535a04a9d86fa2ae4251ce2b Mon Sep 17 00:00:00 2001 From: scrimshawlife-ctrl Date: Fri, 16 Oct 2026 12:23:17 -0700 Subject: [PATCH 01/15] spec 009 T026/T028: windowed export context, R statuses non-gold, Jev use_mention + tests --- scripts/v2/export_splits.py | 96 +++++++++++ scripts/v2/sense_labels.py | 248 +++++++++++++++++++++++++++++ tests/test_export_window_v2.py | 56 +++++++ tests/test_sense_use_mention_v2.py | 56 +++++++ 4 files changed, 456 insertions(+) create mode 100644 scripts/v2/export_splits.py create mode 100644 scripts/v2/sense_labels.py create mode 100644 tests/test_export_window_v2.py create mode 100644 tests/test_sense_use_mention_v2.py diff --git a/scripts/v2/export_splits.py b/scripts/v2/export_splits.py new file mode 100644 index 00000000..7ef0be39 --- /dev/null +++ b/scripts/v2/export_splits.py @@ -0,0 +1,96 @@ +#!/usr/bin/env python3 +"""Export train/val/test JSONL from the PRIVATE local store, deduped on text hash. + +Dedup rules (deterministic): + 1. Within a split, keep one row per (content_sha256, term); prefer human-gold, then lowest record_id. + 2. Across splits, each text lives in ONE split, priority test > val > train (protects held-out). +Outputs (private, local_store/export/): {train,val,test}.jsonl (SFT rows), gold_test.jsonl +(prereg_eval.py format: record_id, gold, family), test_manifest.txt + sha256, export_report.json. +SFT row: record_id, split, term, term_family, lineage_family, context, label, label_source, slur_tagged. +""" +import json, os, hashlib, collections, sys +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) # 2026-10-16: current tracker ruling_queue, not the vi-data copy +from ruling_queue import split_for, window_excerpt, NON_GOLD_ROW_STATUS +ROOT = os.environ.get("HYPERLEX_LOCAL_STORE", "local_store") # private store; path set on the operator box +OUT = ROOT + "/export" +PRI = {"test": 0, "val": 1, "train": 2} + + +def gold(r): + h = r.get("human_ruling") or {} + if h.get("row_status") in NON_GOLD_ROW_STATUS: # spec 009 R = unusable evidence: never gold + return None + return h.get("sense") if str(h.get("source", "")).lower() == "human" and h.get("sense") in ("SLANG_SENSE", "OTHER_SENSE") else None + + +def context_of(r): + """T026: target-centred window (same width as the ruling queue) instead of the full post.""" + ctx, kind = window_excerpt(r.get("contextual_use") or "", r["term"]) + return ctx, kind + + +def main(src=ROOT + "/curated_sense_observation.jsonl", out=OUT): + os.makedirs(out, exist_ok=True) + rows = [json.loads(l) for l in open(src) if l.strip()] + rep_ns = sum(1 for r in rows if (r.get("human_ruling") or {}).get("row_status") in NON_GOLD_ROW_STATUS) + for r in rows: + r["_split"] = (r.get("human_ruling") or {}).get("split") or split_for(r["term_family"]) + rep = {"input_rows": len(rows), "non_gold_row_status_rows": rep_ns} + # 1 within-split (text, term) + best = {} + for r in sorted(rows, key=lambda r: (gold(r) is None, r["record_id"])): + k = (r["_split"], r["content_sha256"], r["term"].lower()) + best.setdefault(k, r) + rows1 = list(best.values()); rep["dropped_exact_dup"] = len(rows) - len(rows1) + # 2 cross-split + home = {} + for r in rows1: + s = home.get(r["content_sha256"]) + if s is None or PRI[r["_split"]] < PRI[s]: + home[r["content_sha256"]] = r["_split"] + rows2 = [r for r in rows1 if home[r["content_sha256"]] == r["_split"]] + rep["dropped_cross_split"] = len(rows1) - len(rows2) + by = collections.defaultdict(list) + for r in rows2: + g = gold(r) + ctx, kind = context_of(r) + h = r.get("human_ruling") or {} + by[r["_split"]].append({ + "record_id": r["record_id"], "split": r["_split"], "term": r["term"], "term_family": r["term_family"], + "lineage_family": (r.get("mutation_lineage") or {}).get("lineage_family"), + "context": ctx, "context_match": kind, "label": g or r["sense_candidate"], + "use_mention": h.get("use_mention"), "row_status": h.get("row_status"), + "excerpt_provenance": h.get("excerpt_provenance"), + "label_source": "human" if g else "model:" + str((r.get("model_proposal") or {}).get("model_or_rule")), + "slur_tagged": bool((r.get("sensitivity") or {}).get("slur_tagged")), "text_contains_slur": bool((r.get("sensitivity") or {}).get("text_contains_slur"))}) + for s in ("train", "val", "test"): + with open(f"{out}/{s}.jsonl", "w") as fh: + for x in sorted(by[s], key=lambda x: x["record_id"]): + fh.write(json.dumps(x, ensure_ascii=False) + "\n") + gt = sorted((x for x in by["test"] if x["label_source"] == "human"), key=lambda x: x["record_id"]) + with open(f"{out}/gold_test.jsonl", "w") as fh: + for x in gt: + fh.write(json.dumps({"record_id": x["record_id"], "gold": x["label"], "family": x["lineage_family"] or x["term_family"]}) + "\n") + man = "".join(x["record_id"] + "\n" for x in gt) + open(f"{out}/test_manifest.txt", "w").write(man) + rep["test_manifest_sha256"] = hashlib.sha256(man.encode()).hexdigest() + texts = {s: {hashlib.sha256(x["context"].encode()).hexdigest() for x in by[s]} for s in by} + terms = {s: {x["term"].lower() for x in by[s]} for s in by} + rep.update({"rows": {s: len(by[s]) for s in by}, "gold_rows": {s: sum(x["label_source"] == "human" for x in by[s]) for s in by}, + "gold_test": len(gt), + "text_overlap": {"train_test": len(texts["train"] & texts["test"]), "val_test": len(texts["val"] & texts["test"]), "train_val": len(texts["train"] & texts["val"])}, + "term_overlap": {"train_test": len(terms["train"] & terms["test"]), "val_test": len(terms["val"] & terms["test"]), "train_val": len(terms["train"] & terms["val"])}, + "label_by_family": {str(k): dict(v) for k, v in _lab(rows2).items()}}) + json.dump(rep, open(f"{out}/export_report.json", "w"), indent=2) + print(json.dumps({k: v for k, v in rep.items() if k != "label_by_family"}, indent=2)) + + +def _lab(rows): + c = collections.defaultdict(collections.Counter) + for r in rows: + c[(r.get("mutation_lineage") or {}).get("lineage_family")][gold(r) or r["sense_candidate"]] += 1 + return c + + +if __name__ == "__main__": + main() diff --git a/scripts/v2/sense_labels.py b/scripts/v2/sense_labels.py new file mode 100644 index 00000000..c756d1f1 --- /dev/null +++ b/scripts/v2/sense_labels.py @@ -0,0 +1,248 @@ +#!/usr/bin/env python3 +# Mirror of the operator-box Jev sense labeller (spec 009 T028, 2026-10-16); paths generalized. +# PROVENANCE: NEW 2026-09-25 PT (Danny 10:50 PT). Additive: writes only table observation_sense_v1. +"""Per-observation sense labels (SLANG_SENSE | OTHER_SENSE | UNKNOWN) via Jev, batched per term. + +Only observations of tracked terms (observations.term_canonical = terms.canonical_form) that have no +label under the current sense contract version are sent (incremental: the daily export only labels +new observations). + +Usage: sense_labels.py [--backfill] [--dry-run] [--max-cost-usd 1.0] +""" +from __future__ import annotations + +import argparse +import hashlib +import json +import os +import sqlite3 +import subprocess +from datetime import datetime, timezone +from pathlib import Path + +HERE = Path(__file__).resolve().parent +DB = Path(os.environ.get("VERN_DB", "data/vernacular.sqlite3")) +SENSE_CONTRACT = Path(os.environ.get("SENSE_CONTRACT", HERE / "jev_sense_contract.json")) # spec 009 T028: point at a rebuilt-sense-v2 contract to emit use_mention +JEV_CLIENT = Path(os.environ.get("JEV_CLIENT", str(HERE / "jev_client.mjs"))) +CACHE = HERE / "receipts" / "jev-cache" +PRICE = 0.042 # USD per 1M input tokens (TypeSafe jev-1.13), output free +LABELS = ("SLANG_SENSE", "OTHER_SENSE", "UNKNOWN") +UM_SUFFIX = "_um" # spec 009 T028: per-post use/mention question id suffix + + +def contract() -> dict: + return json.loads(SENSE_CONTRACT.read_text()) + + +def contract_sha() -> str: + return hashlib.sha256(SENSE_CONTRACT.read_bytes()).hexdigest() + + +def ensure_table(con) -> None: + con.execute("""CREATE TABLE IF NOT EXISTS observation_sense_v1 ( + observation_id TEXT PRIMARY KEY, term_id TEXT NOT NULL, label TEXT NOT NULL, prob REAL, + contract_version TEXT NOT NULL, computed_at TEXT NOT NULL)""") + cols = {r[1] for r in con.execute("PRAGMA table_info(observation_sense_v1)")} + if "use_mention" not in cols: # additive (spec 009 T028); NULL = not labelled (read as USE under v1.4) + con.execute("ALTER TABLE observation_sense_v1 ADD COLUMN use_mention TEXT") + + +def load_labels(db: Path = DB, version: str | None = None) -> dict: + """{observation_id: (label, prob)} for the current sense contract version ({} if table absent).""" + version = version or contract()["version"] + con = sqlite3.connect(f"file:{db}?mode=ro", uri=True, timeout=120) + try: + rows = con.execute("SELECT observation_id, label, prob FROM observation_sense_v1 WHERE contract_version=?", + (version,)).fetchall() + except sqlite3.OperationalError as e: + if "no such table" not in str(e): + raise # 11:33 PT fix: a lock (discovery lane writing) must fail loudly, never read as "no rows" + rows = [] + con.close() + return {r[0]: (r[1], r[2]) for r in rows} + + +def pending(db: Path = DB) -> dict: + """{term_id: {"cf", "p", "obs": [(observation_id, text)]}} of unlabeled tracked-term observations.""" + have = load_labels(db) + con = sqlite3.connect(f"file:{db}?mode=ro", uri=True, timeout=120) + terms = {cf: (tid, json.loads(pl)) for tid, cf, pl in con.execute("SELECT term_id, canonical_form, payload FROM terms")} + out = {} + for oid, cf, pl, created in con.execute( + "SELECT observation_id, term_canonical, payload, created_at FROM observations ORDER BY created_at, observation_id"): + if cf not in terms or oid in have: + continue + tid, p = terms[cf] + o = json.loads(pl) + out.setdefault(tid, {"cf": cf, "p": p, "obs": []})["obs"].append((oid, o.get("text") or o.get("raw_excerpt") or "")) + con.close() + return out + + +def build_request(cf: str, p: dict, batch: list, c: dict) -> dict: + posts = [{"id": f"p{i}", "text": (txt or "")[: c["max_post_chars"]]} for i, (_, txt) in enumerate(batch)] + qt = c["question_template"] + qs = {x["id"]: {"type": qt["type"], "instructions": qt["instructions"].format(pid=x["id"], term=cf), + "criteria": qt["criteria"]} for x in posts} + if c.get("closed_set_use_mention"): # rebuilt-sense-v2: one extra USE/MENTION choice per post + for x in posts: + qs[x["id"] + UM_SUFFIX] = {"type": "choice", + "instructions": f"Post {x['id']} in STATE.posts: does it USE the term '{cf}' to convey meaning, " + "or MENTION it (define, quote, ask what it means, comment on its form)? " + f"A definition embedded inside a genuine use is USE. Judge only post {x['id']}.", + "criteria": qt.get("criteria_use_mention") or {k: k for k in c["closed_set_use_mention"]}} + state = {"term": cf, "recorded_slang_meaning": p.get("current_summary") or "", + "possible_meanings": p.get("possible_meanings") or [], "posts": posts} + return {"state": state, "questions": qs, "model": c.get("model", "jev-latest")} + + +def estimate(req: dict) -> float: + return len(json.dumps(req)) / 4 * 2 * 2 * PRICE / 1e6 + + +def _tok(v) -> int: + if isinstance(v, dict): + v = v.get("total", v.get("noCache", 0)) + try: + return int(v or 0) + except (TypeError, ValueError): + return 0 + + +def call(req: dict, csha: str, dry_run: bool) -> tuple[dict, bool]: + h = hashlib.sha256(json.dumps(req, sort_keys=True, ensure_ascii=False).encode()).hexdigest() + cp = CACHE / f"sense_{csha[:12]}_{h}.json" + if cp.exists(): + try: + return json.loads(cp.read_text()), True + except Exception: + pass + try: + pr = subprocess.run(["node", str(JEV_CLIENT)], input=json.dumps(req), capture_output=True, text=True, timeout=180) + res = json.loads((pr.stdout.strip().splitlines() or ["{}"])[-1]) + except Exception as e: + return {"ok": False, "error_class": "jev_call_error", "error": type(e).__name__}, False + if res.get("ok") and (res.get("backend") != "typesafe" or res.get("dry_run") or res.get("emulated")): + return {"ok": False, "error_class": "not_real_jev", "error": f"backend={res.get('backend')}"}, False + if res.get("ok") and not dry_run: + CACHE.mkdir(parents=True, exist_ok=True) + cp.write_text(json.dumps(res)) + return res, False + + +def parse_answer(answers: dict, pid: str, c: dict) -> tuple: + """(label, prob, use_mention) for one post. Fail closed: missing/out-of-set/low-prob sense -> UNKNOWN; + missing/out-of-set use_mention -> None (unlabelled). Contract v2 rule: a MENTION is never SLANG_SENSE.""" + min_p = float(c["min_top_probability"]) + a = answers.get(pid) + lab, prob = "UNKNOWN", None + if isinstance(a, dict) and a.get("choice") in c["closed_set"]: + try: + prob = float((a.get("probabilities") or {}).get(a["choice"])) + except (TypeError, ValueError): + prob = None + lab = a["choice"] if prob is not None and prob >= min_p else "UNKNOWN" + um = None + if c.get("closed_set_use_mention"): + b = answers.get(pid + UM_SUFFIX) + if isinstance(b, dict) and b.get("choice") in c["closed_set_use_mention"]: + try: + up = float((b.get("probabilities") or {}).get(b["choice"])) + except (TypeError, ValueError): + up = None + um = b["choice"] if up is not None and up >= min_p else None + if um == "MENTION" and lab == "SLANG_SENSE": + lab = "OTHER_SENSE" + return lab, prob, um + + +def label_pending(db: Path = DB, max_cost_usd: float = 1.0, dry_run: bool = False, allow_live: bool = True, + only: set | None = None) -> dict: + """Label every pending observation (only the given canonical forms if `only`; export --only scoping, 2026-09-25 11:13 PT). + Returns stats incl. terms whose labeling is incomplete (fail closed).""" + c = contract(); csha = contract_sha(); ver = c["version"]; min_p = float(c["min_top_probability"]) + todo = pending(db) + if only: + todo = {k: v for k, v in todo.items() if v["cf"] in only} + stats = {"sense_contract_version": ver, "sense_contract_sha256": csha, "pending_posts": sum(len(v["obs"]) for v in todo.values()), + "pending_terms": len(todo), "batches": 0, "live_calls": 0, "cache_hits": 0, "labeled": 0, + "labels": {k: 0 for k in LABELS}, "incomplete_terms": [], "errors": [], "usage_input_tokens": 0, + "cost_usd_estimated_pre_call": 0.0} + if not todo: + return stats + con = None if dry_run else sqlite3.connect(db, timeout=30) + if con: + with con: + ensure_table(con) + now = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ") + for tid, v in todo.items(): + obs = v["obs"] + for i in range(0, len(obs), c["batch_size"]): + batch = obs[i:i + c["batch_size"]] + req = build_request(v["cf"], v["p"], batch, c) + est = estimate(req) + if not allow_live: + h = hashlib.sha256(json.dumps(req, sort_keys=True, ensure_ascii=False).encode()).hexdigest() + if not (CACHE / f"sense_{csha[:12]}_{h}.json").exists(): + stats["errors"].append({"term": v["cf"], "error_class": "live_disabled"}); stats["incomplete_terms"].append(v["cf"]); break + elif stats["cost_usd_estimated_pre_call"] + est > max_cost_usd: + stats["errors"].append({"term": v["cf"], "error_class": "spend_cap"}); stats["incomplete_terms"].append(v["cf"]); break + res, hit = call(req, csha, dry_run) + stats["batches"] += 1 + if hit: + stats["cache_hits"] += 1 + else: + stats["live_calls"] += 1; stats["cost_usd_estimated_pre_call"] += est + stats["usage_input_tokens"] += _tok((res.get("usage") or {}).get("inputTokens")) + if not res.get("ok"): + stats["errors"].append({"term": v["cf"], "error_class": res.get("error_class"), "error": str(res.get("error", ""))[:120]}) + stats["incomplete_terms"].append(v["cf"]); break + rows = [] + for j, (oid, _) in enumerate(batch): + lab, prob, um = parse_answer(res.get("answers") or {}, f"p{j}", c) + rows.append((oid, tid, lab, prob, ver, now, um)) + stats["labels"][lab] += 1 + if um: + stats.setdefault("use_mention", {}).setdefault(um, 0) + stats["use_mention"][um] += 1 + stats["labeled"] += len(rows) + if con: + with con: + con.executemany("INSERT INTO observation_sense_v1(observation_id, term_id, label, prob, contract_version, computed_at, use_mention) " + "VALUES (?,?,?,?,?,?,?) ON CONFLICT(observation_id) DO UPDATE SET term_id=excluded.term_id, " + "label=excluded.label, prob=excluded.prob, contract_version=excluded.contract_version, " + "computed_at=excluded.computed_at, use_mention=excluded.use_mention", rows) + if con: + con.close() + stats["cost_usd_actual_est"] = round(stats["usage_input_tokens"] * PRICE / 1e6, 6) + stats["cost_usd_estimated_pre_call"] = round(stats["cost_usd_estimated_pre_call"], 6) + stats["incomplete_terms"] = sorted(set(stats["incomplete_terms"])) + return stats + + +if __name__ == "__main__": + ap = argparse.ArgumentParser() + ap.add_argument("--backfill", action="store_true", help="one-time backfill of all unlabeled tracked-term observations") + ap.add_argument("--dry-run", action="store_true", help="count pending only; no Jev calls, no writes") + ap.add_argument("--max-cost-usd", type=float, default=1.0) + a = ap.parse_args() + if a.dry_run: + pd = pending() + reqs = [build_request(v["cf"], v["p"], v["obs"][i:i + contract()["batch_size"]], contract()) + for v in pd.values() for i in range(0, len(v["obs"]), contract()["batch_size"])] + print(json.dumps({"pending_posts": sum(len(v["obs"]) for v in pd.values()), "pending_terms": len(pd), + "batches": len(reqs), "cost_usd_estimated_pre_call": round(sum(map(estimate, reqs)), 6)})) + else: + cap = a.max_cost_usd if a.backfill else min(a.max_cost_usd, 1.0) + s = label_pending(max_cost_usd=cap) + s.setdefault("usage_input_tokens", 0) + s.setdefault("cost_usd_actual_est", 0.0) + run = datetime.now().strftime("%Y%m%d-%H%M%S") + (HERE / "receipts").mkdir(exist_ok=True) + (HERE / "receipts" / f"sense-{'backfill' if a.backfill else 'run'}-{run}.json").write_text(json.dumps(s, indent=2)) + with (HERE / "ledger.jsonl").open("a") as f: + f.write(json.dumps({"run_id": f"sense-{run}", "kind": "sense_backfill" if a.backfill else "sense_run", + "max_cost_usd": cap, **{k: s.get(k) for k in ("pending_posts", "batches", "live_calls", "labeled", + "labels", "incomplete_terms", "usage_input_tokens", "cost_usd_estimated_pre_call", "cost_usd_actual_est", + "sense_contract_sha256")}}) + "\n") + print(json.dumps(s, indent=1)) diff --git a/tests/test_export_window_v2.py b/tests/test_export_window_v2.py new file mode 100644 index 00000000..c9ab153d --- /dev/null +++ b/tests/test_export_window_v2.py @@ -0,0 +1,56 @@ +"""Spec 009 T026: export context is the target-centred window; R row statuses are never gold.""" +import json, os, sys, tempfile +sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "scripts", "v2")) +import export_splits as ex +import ruling_queue as rq + + +def _row(rid, term, text, split="test", sense="SLANG_SENSE", **h): + hr = {"source": "human", "sense": sense, "split": split, **h} + return {"record_id": rid, "term": term, "term_family": "fam-a", "contextual_use": text, + "content_sha256": rid, "sense_candidate": "SLANG_SENSE", "human_ruling": hr, + "mutation_lineage": {"lineage_family": "general-slang"}, "model_proposal": {}, "sensitivity": {}} + + +def _run(rows): + d = tempfile.mkdtemp() + src = os.path.join(d, "in.jsonl") + with open(src, "w") as fh: + for r in rows: + fh.write(json.dumps(r) + "\n") + ex.main(src=src, out=d) + out = {} + for s in ("train", "val", "test"): + out.update({x["record_id"]: x for x in map(json.loads, open(os.path.join(d, s + ".jsonl")))}) + return out, json.load(open(os.path.join(d, "export_report.json"))), d + + +def test_context_is_target_window_not_head(): + text = "x" * 2000 + " zorbly " + "y" * 2000 + out, _, _ = _run([_row("r1", "zorbly", text)]) + ctx = out["r1"]["context"] + assert "zorbly" in ctx and len(ctx) <= rq.EXCERPT_CHARS + 2 + assert out["r1"]["context_match"] == "word" + + +def test_short_text_unchanged(): + out, _, _ = _run([_row("r1", "zorbly", "so zorbly")]) + assert out["r1"]["context"] == "so zorbly" + + +def test_non_gold_row_status_excluded(): + rows = [_row("ta", "zorbly", "a zorbly", row_status="TARGET_ABSENT"), + _row("ue", "zorbly", "b zorbly", row_status="UNUSABLE_EVIDENCE"), + _row("ok", "zorbly", "c zorbly", use_mention="USE")] + out, rep, d = _run(rows) + gold = {json.loads(l)["record_id"] for l in open(os.path.join(d, "gold_test.jsonl"))} + assert gold == {"ok"} + assert out["ta"]["label_source"].startswith("model:") and out["ta"]["row_status"] == "TARGET_ABSENT" + assert out["ok"]["use_mention"] == "USE" + assert rep["non_gold_row_status_rows"] == 2 + + +def test_gold_helper_matches_ruling_queue(): + for st in rq.NON_GOLD_ROW_STATUS: + assert ex.gold({"human_ruling": {"source": "human", "sense": "OTHER_SENSE", "row_status": st}}) is None + assert ex.gold({"human_ruling": {"source": "human", "sense": "OTHER_SENSE"}}) == "OTHER_SENSE" diff --git a/tests/test_sense_use_mention_v2.py b/tests/test_sense_use_mention_v2.py new file mode 100644 index 00000000..316952b7 --- /dev/null +++ b/tests/test_sense_use_mention_v2.py @@ -0,0 +1,56 @@ +"""Spec 009 T028: the Jev sense labeller emits use_mention under rebuilt-sense-v2.""" +import json, os, sqlite3, sys, tempfile +sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "scripts", "v2")) +import sense_labels as sl + +V2 = json.load(open(os.path.join(os.path.dirname(__file__), "..", "specs", "009-ruling-label-taxonomy", "contracts", "jev_sense_contract.v2.json"))) +V1 = {k: v for k, v in V2.items() if k not in ("closed_set_use_mention",)} +V1["version"] = "rebuilt-sense-v1" + + +def _a(choice, p): + return {"choice": choice, "probabilities": {choice: p}} + + +def test_v2_request_has_use_mention_question_per_post(): + req = sl.build_request("zorbly", {}, [("o1", "t1"), ("o2", "t2")], V2) + assert set(req["questions"]) == {"p0", "p1", "p0_um", "p1_um"} + assert set(req["questions"]["p0_um"]["criteria"]) == {"USE", "MENTION"} + + +def test_v1_request_unchanged(): + req = sl.build_request("zorbly", {}, [("o1", "t1")], V1) + assert set(req["questions"]) == {"p0"} + + +def test_parse_use(): + assert sl.parse_answer({"p0": _a("SLANG_SENSE", 0.9), "p0_um": _a("USE", 0.8)}, "p0", V2) == ("SLANG_SENSE", 0.9, "USE") + + +def test_mention_is_never_slang_sense(): + lab, _, um = sl.parse_answer({"p0": _a("SLANG_SENSE", 0.9), "p0_um": _a("MENTION", 0.9)}, "p0", V2) + assert (lab, um) == ("OTHER_SENSE", "MENTION") + + +def test_missing_or_low_use_mention_fails_closed_to_none(): + assert sl.parse_answer({"p0": _a("OTHER_SENSE", 0.9)}, "p0", V2)[2] is None + assert sl.parse_answer({"p0": _a("OTHER_SENSE", 0.9), "p0_um": _a("MENTION", 0.2)}, "p0", V2)[2] is None + assert sl.parse_answer({"p0": _a("OTHER_SENSE", 0.9), "p0_um": _a("BOTH", 0.9)}, "p0", V2)[2] is None + + +def test_v1_parse_has_no_use_mention(): + assert sl.parse_answer({"p0": _a("SLANG_SENSE", 0.9), "p0_um": _a("MENTION", 0.9)}, "p0", V1) == ("SLANG_SENSE", 0.9, None) + + +def test_low_sense_prob_is_unknown(): + assert sl.parse_answer({"p0": _a("SLANG_SENSE", 0.3)}, "p0", V2)[0] == "UNKNOWN" + + +def test_ensure_table_adds_column_additively(): + db = os.path.join(tempfile.mkdtemp(), "v.sqlite3") + con = sqlite3.connect(db) + con.execute("CREATE TABLE observation_sense_v1 (observation_id TEXT PRIMARY KEY, term_id TEXT NOT NULL, label TEXT NOT NULL, " + "prob REAL, contract_version TEXT NOT NULL, computed_at TEXT NOT NULL)") + con.execute("INSERT INTO observation_sense_v1 VALUES ('o1','t','SLANG_SENSE',1.0,'rebuilt-sense-v1','x')") + sl.ensure_table(con); sl.ensure_table(con) + assert con.execute("SELECT label, use_mention FROM observation_sense_v1").fetchall() == [("SLANG_SENSE", None)] From 568afa0d4f242070ee3e3824028d8aca07d1ae04 Mon Sep 17 00:00:00 2001 From: scrimshawlife-ctrl Date: Fri, 16 Oct 2026 12:24:46 -0700 Subject: [PATCH 02/15] PR #31: fix Opus review findings (v2 use_mention fails closed, R rows out of SFT, overlap on post hash); KANBAN + T028 done --- scripts/v2/export_splits.py | 7 ++++++- scripts/v2/sense_labels.py | 6 +++--- tests/test_export_window_v2.py | 3 ++- tests/test_sense_use_mention_v2.py | 9 +++++++++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/scripts/v2/export_splits.py b/scripts/v2/export_splits.py index 7ef0be39..4b48ce6c 100644 --- a/scripts/v2/export_splits.py +++ b/scripts/v2/export_splits.py @@ -49,6 +49,10 @@ def main(src=ROOT + "/curated_sense_observation.jsonl", out=OUT): if s is None or PRI[r["_split"]] < PRI[s]: home[r["content_sha256"]] = r["_split"] rows2 = [r for r in rows1 if home[r["content_sha256"]] == r["_split"]] + # Opus review PR #31: rows a human judged unusable (R) are not SFT rows either; counted, kept in the store + rows2_all = rows2 + rows2 = [r for r in rows2 if (r.get("human_ruling") or {}).get("row_status") not in NON_GOLD_ROW_STATUS] + rep["dropped_non_gold_row_status"] = len(rows2_all) - len(rows2) rep["dropped_cross_split"] = len(rows1) - len(rows2) by = collections.defaultdict(list) for r in rows2: @@ -74,7 +78,8 @@ def main(src=ROOT + "/curated_sense_observation.jsonl", out=OUT): man = "".join(x["record_id"] + "\n" for x in gt) open(f"{out}/test_manifest.txt", "w").write(man) rep["test_manifest_sha256"] = hashlib.sha256(man.encode()).hexdigest() - texts = {s: {hashlib.sha256(x["context"].encode()).hexdigest() for x in by[s]} for s in by} + sha = {r["record_id"]: r["content_sha256"] for r in rows2} + texts = {s: {sha[x["record_id"]] for x in by[s]} for s in by} # whole-post hash, not the window terms = {s: {x["term"].lower() for x in by[s]} for s in by} rep.update({"rows": {s: len(by[s]) for s in by}, "gold_rows": {s: sum(x["label_source"] == "human" for x in by[s]) for s in by}, "gold_test": len(gt), diff --git a/scripts/v2/sense_labels.py b/scripts/v2/sense_labels.py index c756d1f1..be6b0e2f 100644 --- a/scripts/v2/sense_labels.py +++ b/scripts/v2/sense_labels.py @@ -151,8 +151,8 @@ def parse_answer(answers: dict, pid: str, c: dict) -> tuple: except (TypeError, ValueError): up = None um = b["choice"] if up is not None and up >= min_p else None - if um == "MENTION" and lab == "SLANG_SENSE": - lab = "OTHER_SENSE" + if lab == "SLANG_SENSE" and um != "USE": # v2: MENTION -> OTHER_SENSE; unresolved -> UNKNOWN (fail closed) + lab, prob = ("OTHER_SENSE", None) if um == "MENTION" else ("UNKNOWN", prob) return lab, prob, um @@ -244,5 +244,5 @@ def label_pending(db: Path = DB, max_cost_usd: float = 1.0, dry_run: bool = Fals f.write(json.dumps({"run_id": f"sense-{run}", "kind": "sense_backfill" if a.backfill else "sense_run", "max_cost_usd": cap, **{k: s.get(k) for k in ("pending_posts", "batches", "live_calls", "labeled", "labels", "incomplete_terms", "usage_input_tokens", "cost_usd_estimated_pre_call", "cost_usd_actual_est", - "sense_contract_sha256")}}) + "\n") + "sense_contract_sha256", "use_mention")}}) + "\n") print(json.dumps(s, indent=1)) diff --git a/tests/test_export_window_v2.py b/tests/test_export_window_v2.py index c9ab153d..b954d959 100644 --- a/tests/test_export_window_v2.py +++ b/tests/test_export_window_v2.py @@ -45,7 +45,8 @@ def test_non_gold_row_status_excluded(): out, rep, d = _run(rows) gold = {json.loads(l)["record_id"] for l in open(os.path.join(d, "gold_test.jsonl"))} assert gold == {"ok"} - assert out["ta"]["label_source"].startswith("model:") and out["ta"]["row_status"] == "TARGET_ABSENT" + assert "ta" not in out and "ue" not in out + assert rep["dropped_non_gold_row_status"] == 2 assert out["ok"]["use_mention"] == "USE" assert rep["non_gold_row_status_rows"] == 2 diff --git a/tests/test_sense_use_mention_v2.py b/tests/test_sense_use_mention_v2.py index 316952b7..43377742 100644 --- a/tests/test_sense_use_mention_v2.py +++ b/tests/test_sense_use_mention_v2.py @@ -54,3 +54,12 @@ def test_ensure_table_adds_column_additively(): con.execute("INSERT INTO observation_sense_v1 VALUES ('o1','t','SLANG_SENSE',1.0,'rebuilt-sense-v1','x')") sl.ensure_table(con); sl.ensure_table(con) assert con.execute("SELECT label, use_mention FROM observation_sense_v1").fetchall() == [("SLANG_SENSE", None)] + + +def test_slang_with_unresolved_use_mention_is_unknown(): + for um in ({}, {"p0_um": _a("BOTH", 0.9)}, {"p0_um": _a("MENTION", 0.3)}): + assert sl.parse_answer({"p0": _a("SLANG_SENSE", 0.9), **um}, "p0", V2)[0] == "UNKNOWN" + + +def test_mention_override_clears_prob(): + assert sl.parse_answer({"p0": _a("SLANG_SENSE", 0.9), "p0_um": _a("MENTION", 0.9)}, "p0", V2) == ("OTHER_SENSE", None, "MENTION") From c1121a3947161eadfac3c39ccdae91094eec55be Mon Sep 17 00:00:00 2001 From: scrimshawlife-ctrl Date: Fri, 16 Oct 2026 12:24:59 -0700 Subject: [PATCH 03/15] KANBAN: current state and Danny decisions; spec 009 T028 done --- docs/KANBAN.md | 27 +++++++++++++----------- specs/009-ruling-label-taxonomy/tasks.md | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/docs/KANBAN.md b/docs/KANBAN.md index 436938dd..80ff406b 100644 --- a/docs/KANBAN.md +++ b/docs/KANBAN.md @@ -1,6 +1,6 @@ # Hyperlex v2 kanban (steps to data READY) -Updated 2026-10-16 12:20 PM PT. Mirrors: +Updated 2026-10-16 12:35 PM PT. Mirrors: - Notion board: https://app.notion.com/p/f57ad22c76d7436c9e024229be560a8e - GitHub Project: https://github.com/orgs/Zero-State-LLC/projects/28 (Column field) - Obsidian: `Projects/Hyperlex v2 board.md` @@ -8,22 +8,25 @@ Updated 2026-10-16 12:20 PM PT. Mirrors: The Obsidian board is the source of truth. This file carries no slur terms, post text or private rows. ## Backlog -- [ ] **Sort the 358 unfamilied rows.** Owner: Danny. Left over from the PR #27 family change. +- [ ] **Hold-out supply for the test split.** Owner: Danny (decision). Only 19 test-split terms have observations and nearly all are at the 10-gold-per-term limit; 21 test terms have none. Options: (a) raise the 10-gold limit and the 3-per-queue cap for test terms (about 25 rows per queue under the 3 cap; 179 unruled rows exist on full terms); (b) authorize collection for the 21 empty test terms; (c) move families into the test split. ## Next -- [ ] **Rebuild the training export.** Owner: Grok Bot. The current export predates the 10-15 backfill, the repair re-ruling and the auto-reject audit move. -- [ ] **Family review: 8 items via Kimi.** Owner: Grok Bot (Kimi pass), Danny (final call). -- [ ] **T026 follow-up: excerpt windowing in all export paths.** Owner: Grok Bot. Check `export_splits` and the other excerpt consumers use the same window as the queue (spec 009). -- [ ] **T028: `use_mention` in the Jev sense labelling runtime.** Owner: Grok Bot. `metrics-rule-v1.5` / `rebuilt-sense-v2` are specced in spec 009, but the runtime doesn't produce the field yet. +- [ ] **Danny decisions on families (private).** Owner: Danny. 1 Kimi low-confidence item (cockmonger: vulgar-insult vs nsfw-sexual) and 4 held terms from the new-row sort (2 possible slurs, 1 possible slur pun, 1 low confidence); held terms are named in the private store only. 63 rows stay unfamilied until then. +- [ ] **15 quarantined gold rows.** Owner: Danny (decision). Ruled gold rows (3 test, 2 val, 10 train) fail the existing DQ checks (author id present plus suspect synthetic source id). Fix the check, or keep them out. ## In progress -- [ ] **Raise test gold to 250 (G1), then 470 (G5).** Owner: Danny (rulings), Grok Bot (queues). 159/250 for G1 and 159/470 for G5 as of 2026-10-16. +- [ ] **Raise test gold to 250 (G1), then 470 (G5).** Owner: Danny (rulings), Grok Bot (queues). Export 156/250 (landing 159). Queue 2026-10-16b built: 3 test rows (supply-limited, see Backlog). +- [ ] **PR #31: T026/T028 (windowed export context, R statuses non-gold, Jev use_mention).** Owner: Danny (merge yes). Opus review findings fixed; 42 tests pass. ## Blocked -- [ ] **Freeze the held-out test manifest.** Owner: Grok Bot, with Danny's sign-off. Blocked on G1 reaching 250 and the export rebuild. -- [ ] **Archive repo is read-only (scrimshawlife-ctrl/Hyperlex).** Owner: Danny. The VERDICT-RULES v1.5 push got a 403 because the repo is archived. v1.5 lives in `specs/009-ruling-label-taxonomy/verdict-rules-v1.5.md`. Decide: unarchive it, or move VERDICT-RULES into this repo. +- [ ] **Freeze the held-out test manifest.** Owner: Grok Bot, with Danny's sign-off. Blocked on G1 reaching 250. +- [ ] **Archive repo is read-only (scrimshawlife-ctrl/Hyperlex).** Owner: Danny. Decide: unarchive it, or move VERDICT-RULES into this repo. ## Done -- [x] **Betting-sharp replacement pick.** Retired in PR #27 (220c108); six lineage families added. -- [x] **Spec 009 Q1-Q5 decisions applied, and the repair queue re-ruled** (2026-10-16). 0 `TARGET_ABSENT` rows remain. -- [x] **Merge specs 008 and 009 to main.** #28 squash d87e3af, #29 squash 4f17542 (2026-10-16). +- [x] **Rebuild the training export** (2026-10-16 12:30 PM PT). Row status, use_mention and excerpt provenance carried; R statuses out of gold and SFT; windowed context. Store 9,523 rows; gold test 156 / val 158 / train 933; overlaps 0. Author/community backfill re-run (author 15.1%, platform 100%, sub 88.0%). +- [x] **Family review: 8 items via Kimi** (moonshotai/kimi-k3). 7 settled (two private families vulgar-insult and nsfw-sexual, 2 terms to noise, 1 to general-slang, slur borderline kept borderline); 1 low-confidence item to Danny. +- [x] **Sort the 358 unfamilied rows.** Done via the Kimi verdicts plus an Opus sort of new rows (15 terms assigned, 6 to noise, 4 held). Assignments live in the private overlay. +- [x] **T026 export windowing and T028 Jev use_mention** coded with tests (PR #31, unmerged). +- [x] **Betting-sharp replacement pick.** Retired in PR #27 (220c108). +- [x] **Spec 009 Q1-Q5 decisions applied, and the repair queue re-ruled** (2026-10-16). +- [x] **Merge specs 008 and 009 to main.** #28 squash d87e3af, #29 squash 4f17542. diff --git a/specs/009-ruling-label-taxonomy/tasks.md b/specs/009-ruling-label-taxonomy/tasks.md index 97b74be9..672a0ebd 100644 --- a/specs/009-ruling-label-taxonomy/tasks.md +++ b/specs/009-ruling-label-taxonomy/tasks.md @@ -33,6 +33,6 @@ - [x] T026 Re-window excerpts for the 85 repair rows (50 TARGET_ABSENT + 3 review + 32 flagged), then re-queue (rulings/repair/2026-10-16-target-absent.txt on the operator box). - [ ] T027 (BLOCKED: remote scrimshawlife-ctrl/Hyperlex is archived/read-only, push 403; v1.5 lives in this spec) Push Hyperlex-archive metrics-rule-v1.5 commit (needs approval; that remote is public). -- [ ] T028 Implement use_mention in the Jev sense labelling runtime. +- [x] T028 Implement use_mention in the Jev sense labelling runtime. (2026-10-16: scripts/v2/sense_labels.py, PR #31; the live runtime emits it once pointed at the v2 contract) - T026 done 2026-10-16: queue excerpts are windowed around the target (`window_excerpt`, 500 chars); `ruling_queue.py repair` re-queues landed rows with original_text + previous_label kept. Repair queue 2026-10-16-repair: 85 rows (test 15, val 14, train 56) on the operator box. Re-ruling a TARGET_ABSENT row as non-R moves its status to status_history. From 1ac3029cd2e9be6b8c44c78b29778ab5beecc466 Mon Sep 17 00:00:00 2001 From: scrimshawlife-ctrl Date: Fri, 16 Oct 2026 12:47:34 -0700 Subject: [PATCH 04/15] docs: Hyperlex v2 parity 2026-10-16 (G1 245/250, T2 149/300, independent-recount readiness rule) --- STATUS.md | 14 +++++++------- docs/KANBAN.md | 29 +++++++++++++++++++---------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/STATUS.md b/STATUS.md index 5535ecd7..d4053246 100644 --- a/STATUS.md +++ b/STATUS.md @@ -13,20 +13,20 @@ This file is the operator snapshot. The docs site copies it to [status](https://scrimshawlife-ctrl.github.io/Hyperlex/status/). Do not treat it as a Hub card or a Brier score. -## Hyperlex v2 dataset and specs 008/009 (2026-10-16 PT) +## Hyperlex v2 dataset and specs 008/009 (2026-10-16 1:05 PM PT) - **Spec 008, lexical emergence** (PR #28, merged as d87e3af): SHADOW. CR-5 is amended by 009: R is row-level and never a term rejection. - **Spec 009, ruling label taxonomy** (PR #29, merged as 4f17542): - Labels: S, O, U, and R. R means "unusable evidence" and is recorded as a row status, `TARGET_ABSENT` or `UNUSABLE_EVIDENCE`. - - Replies: corrections-only and multi-part replies are supported. + - Replies: corrections-only and multi-part replies are supported. M in a reply means O with `use_mention=MENTION`. - Term auto-reject is removed. - Excerpts are windowed around the target. - VERDICT-RULES is now `metrics-rule-v1.5` (use/mention split). -- **Ruling landing:** 1,343 rulings and 1,307 gold (test 159, val 164, train 984). - - Test gold is 159/470 (G1 159/250). - - 0 `TARGET_ABSENT` rows remain. -- **Board:** https://app.notion.com/p/f57ad22c76d7436c9e024229be560a8e (mirror of the Obsidian board). -- **Readiness:** NOT READY (G1 test gold, export rebuild, manifest freeze). No Spark run without READY and Danny's go. +- **Ruling landing:** 1,439 rulings and 1,396 gold (test 248, val 164, train 984). +- **Export:** gold test 245, val 158, train 933; overlaps 0; manifest 245 ids (not frozen). +- **Readiness:** NOT READY. G1 test gold 245/250 (independent recount 245). T2 ruled meanings 149/300 (independent recount 149). Rule (Danny 2026-10-16): the two checks are independent and each needs its own recount. No Spark run without READY and Danny's go. +- **Test-gap fill (Danny 2026-10-16):** posts collected for 18/21 empty test terms; queues 2026-10-16c and 16d ruled; 16e (33 rows) prepared, not sent. +- **Board:** https://app.notion.com/p/f57ad22c76d7436c9e024229be560a8e (mirror of the Obsidian board). Kanban: `docs/KANBAN.md`. - Tooling runs from `hyperlex-v2-tracker/ruling_queue.py` on the operator box. The mirror is `scripts/v2/ruling_queue.py`. ## Trajectory diff --git a/docs/KANBAN.md b/docs/KANBAN.md index 80ff406b..c4e7d32a 100644 --- a/docs/KANBAN.md +++ b/docs/KANBAN.md @@ -1,31 +1,40 @@ # Hyperlex v2 kanban (steps to data READY) -Updated 2026-10-16 12:35 PM PT. Mirrors: +Updated 2026-10-16 1:05 PM PT (parity pass). Mirrors: - Notion board: https://app.notion.com/p/f57ad22c76d7436c9e024229be560a8e - GitHub Project: https://github.com/orgs/Zero-State-LLC/projects/28 (Column field) - Obsidian: `Projects/Hyperlex v2 board.md` The Obsidian board is the source of truth. This file carries no slur terms, post text or private rows. -## Backlog -- [ ] **Hold-out supply for the test split.** Owner: Danny (decision). Only 19 test-split terms have observations and nearly all are at the 10-gold-per-term limit; 21 test terms have none. Options: (a) raise the 10-gold limit and the 3-per-queue cap for test terms (about 25 rows per queue under the 3 cap; 179 unruled rows exist on full terms); (b) authorize collection for the 21 empty test terms; (c) move families into the test split. +## Readiness: NOT READY +Readiness rule (Danny 2026-10-16 12:45 PT): test-gold coverage (G1) and ruled meanings (T2) are independent checks. Each must be met and verified by its own separate recount; one shared figure never establishes READY. + +| Check | Count | Independent recount | Status | +|---|---|---|---| +| G1 test gold (export) | 245/250 | 245 (test.jsonl human S/O = gold_test.jsonl = manifest ids) | SHORT by 5 | +| T2 ruled meanings | 149/300 | 149 (operator_definitions by source: 100 T2 review + 47 queue definitions + 2 chat) | SHORT by 151 | + +Ruling landing: 1,439 rulings, 1,396 gold (test 248, val 164, train 984). Export gold: test 245, val 158, train 933. Manifest 245 ids, sha c10826ed…, not frozen. ## Next -- [ ] **Danny decisions on families (private).** Owner: Danny. 1 Kimi low-confidence item (cockmonger: vulgar-insult vs nsfw-sexual) and 4 held terms from the new-row sort (2 possible slurs, 1 possible slur pun, 1 low confidence); held terms are named in the private store only. 63 rows stay unfamilied until then. +- [ ] **Danny decisions on families (private).** Owner: Danny. 1 Kimi low-confidence item and 4 held terms (named in the private store only). 63 rows stay unfamilied until then. - [ ] **15 quarantined gold rows.** Owner: Danny (decision). Ruled gold rows (3 test, 2 val, 10 train) fail the existing DQ checks (author id present plus suspect synthetic source id). Fix the check, or keep them out. +- [ ] **Reach 300 ruled meanings (T2).** Owner: Grok Bot (drafts), Danny (rulings). 149/300. Plan proposed 2026-10-16: draft meanings for undefined terms with evidence, then collect for undefined terms without posts. ## In progress -- [ ] **Raise test gold to 250 (G1), then 470 (G5).** Owner: Danny (rulings), Grok Bot (queues). Export 156/250 (landing 159). Queue 2026-10-16b built: 3 test rows (supply-limited, see Backlog). -- [ ] **PR #31: T026/T028 (windowed export context, R statuses non-gold, Jev use_mention).** Owner: Danny (merge yes). Opus review findings fixed; 42 tests pass. +- [ ] **Raise test gold to 250 (G1), then 470 (G5).** Owner: Danny (rulings), Grok Bot (queues). Export 245/250 (landing 248); G5 245/470. Test-gap fill: 228 posts collected for 18/21 empty test terms; queues 2026-10-16c (54) and 16d (42) ruled and applied. Queue 2026-10-16e (33 rows, 11 terms) prepared, not sent. tlpur needs context; god shot skipped (insufficient context). +- [ ] **PR #31: T026/T028 (windowed export context, R statuses non-gold, Jev use_mention).** Owner: Danny (merge yes). Opus review findings fixed; 42 tests pass. Not merged. ## Blocked -- [ ] **Freeze the held-out test manifest.** Owner: Grok Bot, with Danny's sign-off. Blocked on G1 reaching 250. +- [ ] **Freeze the held-out test manifest.** Owner: Grok Bot, with Danny's sign-off. Blocked on G1 reaching 250 and on READY. - [ ] **Archive repo is read-only (scrimshawlife-ctrl/Hyperlex).** Owner: Danny. Decide: unarchive it, or move VERDICT-RULES into this repo. ## Done -- [x] **Rebuild the training export** (2026-10-16 12:30 PM PT). Row status, use_mention and excerpt provenance carried; R statuses out of gold and SFT; windowed context. Store 9,523 rows; gold test 156 / val 158 / train 933; overlaps 0. Author/community backfill re-run (author 15.1%, platform 100%, sub 88.0%). -- [x] **Family review: 8 items via Kimi** (moonshotai/kimi-k3). 7 settled (two private families vulgar-insult and nsfw-sexual, 2 terms to noise, 1 to general-slang, slur borderline kept borderline); 1 low-confidence item to Danny. -- [x] **Sort the 358 unfamilied rows.** Done via the Kimi verdicts plus an Opus sort of new rows (15 terms assigned, 6 to noise, 4 held). Assignments live in the private overlay. +- [x] **Test split supply decision** (Danny 2026-10-16 12:25 PT): collect for the 21 empty test terms; raising the test cap 10→15 only if short. Collected for 18/21 (3 still empty). Top-up not used. +- [x] **Rebuild the training export** (re-run 2026-10-16 12:46 PM PT after queue 16d). Store 9,751 rows; exported 9,446; overlaps 0. +- [x] **Family review: 8 items via Kimi** (moonshotai/kimi-k3). 7 settled; 1 low-confidence item to Danny. +- [x] **Sort the 358 unfamilied rows.** Kimi verdicts plus an Opus sort of new rows (15 terms assigned, 6 to noise, 4 held). - [x] **T026 export windowing and T028 Jev use_mention** coded with tests (PR #31, unmerged). - [x] **Betting-sharp replacement pick.** Retired in PR #27 (220c108). - [x] **Spec 009 Q1-Q5 decisions applied, and the repair queue re-ruled** (2026-10-16). From dc0cbe6c011a1b2e4222e09cee2b594cae42df2a Mon Sep 17 00:00:00 2001 From: scrimshawlife-ctrl Date: Fri, 16 Oct 2026 13:08:27 -0700 Subject: [PATCH 05/15] docs: Hyperlex v2 after queue 16e (G1 rows 274/250 by recount, 37 terms; T2 149/300; NOT READY) --- STATUS.md | 10 +++++----- docs/KANBAN.md | 11 ++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/STATUS.md b/STATUS.md index d4053246..8cb9796d 100644 --- a/STATUS.md +++ b/STATUS.md @@ -13,7 +13,7 @@ This file is the operator snapshot. The docs site copies it to [status](https://scrimshawlife-ctrl.github.io/Hyperlex/status/). Do not treat it as a Hub card or a Brier score. -## Hyperlex v2 dataset and specs 008/009 (2026-10-16 1:05 PM PT) +## Hyperlex v2 dataset and specs 008/009 (2026-10-16 1:15 PM PT) - **Spec 008, lexical emergence** (PR #28, merged as d87e3af): SHADOW. CR-5 is amended by 009: R is row-level and never a term rejection. - **Spec 009, ruling label taxonomy** (PR #29, merged as 4f17542): @@ -22,10 +22,10 @@ This file is the operator snapshot. The docs site copies it to [status](https:// - Term auto-reject is removed. - Excerpts are windowed around the target. - VERDICT-RULES is now `metrics-rule-v1.5` (use/mention split). -- **Ruling landing:** 1,439 rulings and 1,396 gold (test 248, val 164, train 984). -- **Export:** gold test 245, val 158, train 933; overlaps 0; manifest 245 ids (not frozen). -- **Readiness:** NOT READY. G1 test gold 245/250 (independent recount 245). T2 ruled meanings 149/300 (independent recount 149). Rule (Danny 2026-10-16): the two checks are independent and each needs its own recount. No Spark run without READY and Danny's go. -- **Test-gap fill (Danny 2026-10-16):** posts collected for 18/21 empty test terms; queues 2026-10-16c and 16d ruled; 16e (33 rows) prepared, not sent. +- **Ruling landing:** 1,472 rulings and 1,425 gold (test 277, val 164, train 984). +- **Export:** gold test 274, val 158, train 933; overlaps 0; manifest 274 ids (not frozen). +- **Readiness:** NOT READY. G1 test gold rows 274/250 met (independent recount 274; 37 terms vs roadmap >=150, open). T2 ruled meanings 149/300 (independent recount 149). Rule (Danny 2026-10-16): the two checks are independent and each needs its own recount. No Spark run without READY and Danny's go. +- **Test-gap fill (Danny 2026-10-16):** posts collected for 18/21 empty test terms; queues 2026-10-16c, 16d and 16e ruled and applied. - **Board:** https://app.notion.com/p/f57ad22c76d7436c9e024229be560a8e (mirror of the Obsidian board). Kanban: `docs/KANBAN.md`. - Tooling runs from `hyperlex-v2-tracker/ruling_queue.py` on the operator box. The mirror is `scripts/v2/ruling_queue.py`. diff --git a/docs/KANBAN.md b/docs/KANBAN.md index c4e7d32a..79164d21 100644 --- a/docs/KANBAN.md +++ b/docs/KANBAN.md @@ -1,6 +1,6 @@ # Hyperlex v2 kanban (steps to data READY) -Updated 2026-10-16 1:05 PM PT (parity pass). Mirrors: +Updated 2026-10-16 1:15 PM PT (queue 2026-10-16e applied). Mirrors: - Notion board: https://app.notion.com/p/f57ad22c76d7436c9e024229be560a8e - GitHub Project: https://github.com/orgs/Zero-State-LLC/projects/28 (Column field) - Obsidian: `Projects/Hyperlex v2 board.md` @@ -12,10 +12,11 @@ Readiness rule (Danny 2026-10-16 12:45 PT): test-gold coverage (G1) and ruled me | Check | Count | Independent recount | Status | |---|---|---|---| -| G1 test gold (export) | 245/250 | 245 (test.jsonl human S/O = gold_test.jsonl = manifest ids) | SHORT by 5 | +| G1 test gold rows (export) | 274/250 | 274 (test.jsonl human S/O = gold_test.jsonl = manifest ids) | MET (rows) | +| G1 term breadth (roadmap >=150 terms) | 37 terms | 37 | NOT MET; Danny to confirm the clause applies | | T2 ruled meanings | 149/300 | 149 (operator_definitions by source: 100 T2 review + 47 queue definitions + 2 chat) | SHORT by 151 | -Ruling landing: 1,439 rulings, 1,396 gold (test 248, val 164, train 984). Export gold: test 245, val 158, train 933. Manifest 245 ids, sha c10826ed…, not frozen. +Ruling landing: 1,472 rulings, 1,425 gold (test 277, val 164, train 984). Export gold: test 274, val 158, train 933. Manifest 274 ids, sha 57543bbd…, not frozen. ## Next - [ ] **Danny decisions on families (private).** Owner: Danny. 1 Kimi low-confidence item and 4 held terms (named in the private store only). 63 rows stay unfamilied until then. @@ -23,11 +24,11 @@ Ruling landing: 1,439 rulings, 1,396 gold (test 248, val 164, train 984). Export - [ ] **Reach 300 ruled meanings (T2).** Owner: Grok Bot (drafts), Danny (rulings). 149/300. Plan proposed 2026-10-16: draft meanings for undefined terms with evidence, then collect for undefined terms without posts. ## In progress -- [ ] **Raise test gold to 250 (G1), then 470 (G5).** Owner: Danny (rulings), Grok Bot (queues). Export 245/250 (landing 248); G5 245/470. Test-gap fill: 228 posts collected for 18/21 empty test terms; queues 2026-10-16c (54) and 16d (42) ruled and applied. Queue 2026-10-16e (33 rows, 11 terms) prepared, not sent. tlpur needs context; god shot skipped (insufficient context). +- [ ] **Raise test gold to 250 (G1), then 470 (G5).** Owner: Danny (rulings), Grok Bot (queues). Rows: export 274/250 met (recount 274; landing 277); G5 274/470; 37 test terms (roadmap >=150 open). Test-gap fill: 228 posts for 18/21 empty test terms; queues 2026-10-16c (54), 16d (42), 16e (33) ruled and applied. tlpur needs context. - [ ] **PR #31: T026/T028 (windowed export context, R statuses non-gold, Jev use_mention).** Owner: Danny (merge yes). Opus review findings fixed; 42 tests pass. Not merged. ## Blocked -- [ ] **Freeze the held-out test manifest.** Owner: Grok Bot, with Danny's sign-off. Blocked on G1 reaching 250 and on READY. +- [ ] **Freeze the held-out test manifest.** Owner: Grok Bot, with Danny's sign-off. Blocked on READY (T2 149/300) and Danny's sign-off. - [ ] **Archive repo is read-only (scrimshawlife-ctrl/Hyperlex).** Owner: Danny. Decide: unarchive it, or move VERDICT-RULES into this repo. ## Done From ff112c90b64a5025b823679fe5cccc9a74345462 Mon Sep 17 00:00:00 2001 From: scrimshawlife-ctrl Date: Fri, 16 Oct 2026 14:12:14 -0700 Subject: [PATCH 06/15] status: test floor redefined, T2 149/300 (per Danny 2026-10-16) --- STATUS.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/STATUS.md b/STATUS.md index 8cb9796d..f8e414a2 100644 --- a/STATUS.md +++ b/STATUS.md @@ -167,3 +167,8 @@ data/backfill/2026/ ## README Operator front door expanded for stack parity with Athanor / Semion / Yggdrasil (2026-09-11). Changelog-style dumps stay in CHANGELOG / receipts — not the main page. + +### 2026-10-16 2:20 PM PT +- G1 test floor redefined per Danny 2026-10-16 approval of recommendation: >=250 human-ruled test rows covering all test-lineage terms with posts (37). Now MET (274 export rows, 37/37 terms). 150 terms = train pool / overall gold (G2/G3). G5 uses term-level bootstrap (PR #33). +- T2 ruled meanings 149/300 (140 with >=3 contexts, 133 with >=3 slang contexts). 128 model drafts staged for review, not counted. +- Verdict: NOT READY (T2). From 24b9d518f2746a30c43f4aac55d2da3142d33ffd Mon Sep 17 00:00:00 2001 From: scrimshawlife-ctrl Date: Fri, 16 Oct 2026 14:41:52 -0700 Subject: [PATCH 07/15] fix(v2): export dedupe on normalised exported text, not only source hash (readiness check 2026-10-16) --- scripts/v2/export_splits.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/v2/export_splits.py b/scripts/v2/export_splits.py index 4b48ce6c..062651ce 100644 --- a/scripts/v2/export_splits.py +++ b/scripts/v2/export_splits.py @@ -29,6 +29,14 @@ def context_of(r): return ctx, kind +def text_key(r): + """Dedup key on the exported text itself (case/whitespace-normalised), not only the source post hash: + identical short excerpts from different posts were surviving as duplicates (readiness check 2026-10-16).""" + import hashlib as _h + t = " ".join(str(r.get("contextual_use") or "").lower().split()) + return _h.sha256(t.encode()).hexdigest() if t else r["content_sha256"] + + def main(src=ROOT + "/curated_sense_observation.jsonl", out=OUT): os.makedirs(out, exist_ok=True) rows = [json.loads(l) for l in open(src) if l.strip()] @@ -39,16 +47,16 @@ def main(src=ROOT + "/curated_sense_observation.jsonl", out=OUT): # 1 within-split (text, term) best = {} for r in sorted(rows, key=lambda r: (gold(r) is None, r["record_id"])): - k = (r["_split"], r["content_sha256"], r["term"].lower()) + k = (r["_split"], text_key(r), r["term"].lower()) best.setdefault(k, r) rows1 = list(best.values()); rep["dropped_exact_dup"] = len(rows) - len(rows1) # 2 cross-split home = {} for r in rows1: - s = home.get(r["content_sha256"]) + s = home.get(text_key(r)) if s is None or PRI[r["_split"]] < PRI[s]: - home[r["content_sha256"]] = r["_split"] - rows2 = [r for r in rows1 if home[r["content_sha256"]] == r["_split"]] + home[text_key(r)] = r["_split"] + rows2 = [r for r in rows1 if home[text_key(r)] == r["_split"]] # Opus review PR #31: rows a human judged unusable (R) are not SFT rows either; counted, kept in the store rows2_all = rows2 rows2 = [r for r in rows2 if (r.get("human_ruling") or {}).get("row_status") not in NON_GOLD_ROW_STATUS] From 857ec3674f03d579b36e66910ef475d051d4e5cd Mon Sep 17 00:00:00 2001 From: scrimshawlife-ctrl Date: Fri, 16 Oct 2026 14:42:03 -0700 Subject: [PATCH 08/15] status: pre-Spark readiness check 2026-10-16 --- STATUS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/STATUS.md b/STATUS.md index f8e414a2..1ea64c1d 100644 --- a/STATUS.md +++ b/STATUS.md @@ -172,3 +172,6 @@ Operator front door expanded for stack parity with Athanor / Semion / Yggdrasil - G1 test floor redefined per Danny 2026-10-16 approval of recommendation: >=250 human-ruled test rows covering all test-lineage terms with posts (37). Now MET (274 export rows, 37/37 terms). 150 terms = train pool / overall gold (G2/G3). G5 uses term-level bootstrap (PR #33). - T2 ruled meanings 149/300 (140 with >=3 contexts, 133 with >=3 slang contexts). 128 model drafts staged for review, not counted. - Verdict: NOT READY (T2). + +### 2026-10-16 3:05 PM PT pre-Spark check +- PASS: test gold 273/250, 37/37 test terms, 186 train terms, formats, overlap 0, duplicates fixed (manifest sha now a03c8619, not frozen). FAIL: T2 149/300. Danny: 15 quarantined gold rows, whether the slur family counts toward the family gate. Verdict NOT READY. From 7732d68f02715addf65a28dc4c92bb39aba3d629 Mon Sep 17 00:00:00 2001 From: scrimshawlife-ctrl Date: Fri, 16 Oct 2026 15:02:10 -0700 Subject: [PATCH 09/15] status: family assignments 2026-10-16 --- STATUS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/STATUS.md b/STATUS.md index 1ea64c1d..9be3162a 100644 --- a/STATUS.md +++ b/STATUS.md @@ -175,3 +175,6 @@ Operator front door expanded for stack parity with Athanor / Semion / Yggdrasil ### 2026-10-16 3:05 PM PT pre-Spark check - PASS: test gold 273/250, 37/37 test terms, 186 train terms, formats, overlap 0, duplicates fixed (manifest sha now a03c8619, not frozen). FAIL: T2 149/300. Danny: 15 quarantined gold rows, whether the slur family counts toward the family gate. Verdict NOT READY. + +### 2026-10-16 3:15 PM PT family assignments +- 18 unfamilied terms assigned to parent families, 3 sent to noise, 5 held for Danny (refs F1-F5, private). 0 split moves. Test gold now spans 10 lineage families (H3 needs >=8). Gate 17 families (16 without slur). From 5571cb9ca7b524a2a57aa32720abd367001a5d91 Mon Sep 17 00:00:00 2001 From: scrimshawlife-ctrl Date: Fri, 16 Oct 2026 15:05:10 -0700 Subject: [PATCH 10/15] status: algo ruling --- STATUS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/STATUS.md b/STATUS.md index 9be3162a..4636cf0b 100644 --- a/STATUS.md +++ b/STATUS.md @@ -178,3 +178,6 @@ Operator front door expanded for stack parity with Athanor / Semion / Yggdrasil ### 2026-10-16 3:15 PM PT family assignments - 18 unfamilied terms assigned to parent families, 3 sent to noise, 5 held for Danny (refs F1-F5, private). 0 split moves. Test gold now spans 10 lineage families (H3 needs >=8). Gate 17 families (16 without slur). + +### 2026-10-16 3:10 PM PT +- algo: off the noise list, Danny-ruled meaning (algorithm / platform feed; mechanism note: clipping), family tiktok-lifestyle, split unchanged. Meanings 150/300 (141 with >=3 contexts / 134 with >=3 slang contexts). Test families 10; test gold rows without a family 86. From ead8ab551ce1e23350162230b4d427fdd8eabc57 Mon Sep 17 00:00:00 2001 From: scrimshawlife-ctrl Date: Fri, 16 Oct 2026 15:18:14 -0700 Subject: [PATCH 11/15] feat(v2): word-formation field (taxonomy + export formation key, backward-compatible) and formation research input (draft) --- docs/v2/FORMATION_RESEARCH_2026-10-16.md | 38 ++++++++++++++++++++++++ docs/v2/FORMATION_TAXONOMY.md | 38 ++++++++++++++++++++++++ scripts/v2/export_splits.py | 14 +++++++++ 3 files changed, 90 insertions(+) create mode 100644 docs/v2/FORMATION_RESEARCH_2026-10-16.md create mode 100644 docs/v2/FORMATION_TAXONOMY.md diff --git a/docs/v2/FORMATION_RESEARCH_2026-10-16.md b/docs/v2/FORMATION_RESEARCH_2026-10-16.md new file mode 100644 index 00000000..4a9e6f02 --- /dev/null +++ b/docs/v2/FORMATION_RESEARCH_2026-10-16.md @@ -0,0 +1,38 @@ +# Research: making word formation a first-class signal in Hyperlex (draft input) + +Prompt: Danny, 2026-10-16 3:07 PM PT: "Model needs to know how slang forms anyways. Otherwise how to predict? Look at what we have already and research how we can extend Hyperlex with this as a consideration." + +Status: research input only. No state changes beyond the approved formation field. **Citations are from memory and are unverified.** No model or literature-search spend was used, because the session spend cap had already been passed. Check the DOIs and venues before anything is promoted. + +## (a) What Hyperlex already has +| Asset | Formation / prediction content | Gap | +|---|---|---| +| Spec 001, mutation grammar (`specs/001-mutation-grammar`) | "Slang is a productive grammar." Operator-stack detection (`mutation_trace.v0.1`), lineage `branch_operator` (finished history) and `mutation_prediction.v1` (future forms of a slang atom) | Operators are detector-side (adversarial rewrites). They are not tied to the v2 data or labelled as formation types. | +| Spec 008, lexical emergence (PR #28, merged) | Observe from the first attestation. Adoption, diffusion and persistence are outcomes to measure | Formation is not modelled as a driver of emergence or diffusion. | +| v2 T1 (sense) / T2 (meaning) / T3 (lineage family) | Families group terms by register and community (e.g. `-maxxing` sits in brainrot-aura by family, not by mechanism) | There is no mechanism label. Families mix mechanisms. | +| Spec 007, Hyperlexical model, and the rc3 history (pointer/copy head) | A copy/pointer head over the input span, aimed at surface reuse | The rc3 notes weren't found on main today. Re-check the archive. A copy head is a natural fit for clipping, affixation and respelling, where the output reuses parts of the input. | +| Vernacular discovery (`run_discover.py`) and the T2 discovery pass (`discovery/discover_pass.py`) | Finds new candidate terms from posts | There is no prior over likely forms. A formation-aware filter could rank candidates such as productive affixes. | +| New: `terms.formation_json` plus the export `formation` field | 366 terms tagged across 11 mechanisms | The tags are INFERRED (Opus) and await Danny's corrections. | + +## (b) Literature +- **Morphological productivity.** Baayen (1992, *Yearbook of Morphology*) and Baayen (2009, in *Corpus Linguistics: An International Handbook*) use hapax-based productivity, P = n1/N, to measure which affixes are actively coining. It applies directly to `-maxxing`, `-pilled`, `-core` and `-gender`. See also Plag (2003) and Bauer (1983, 2001 *Morphological Productivity*). +- **Blends and clippings.** Gries (2004, *Linguistics*) studies blend structure. Deri & Knight (2015, NAACL) generate portmanteaus with FSTs. Kulkarni & Wang (2018, NAACL, "Simple models for word formation in slang") cover blends, clippings and reduplicatives. +- **Eggcorns.** Liberman (2003, Language Log) and the Eggcorn Database (eggcorns.lascribe.net) treat these as reanalysis. They are rare in our data (1 tag). +- **Emergence and diffusion.** Grieve, Nini & Guo (2018, *Journal of English Linguistics*) map lexical innovation on American Twitter. Grieve et al. (2017, *English Language and Linguistics*) analyse lexical emergence online. Eisenstein, O'Connor, Smith & Xing (2014, *PLoS ONE*) study the diffusion of lexical change on social media. Ryskina et al. (2020, SCiL) find that neologisms are born in sparse semantic neighbourhoods. +- **LLMs and novel words; wug tests.** Berko (1958, *Word*) is the original wug test. Weissweiler et al. (2023, EMNLP) test ChatGPT's morphology on wugs. Hofmann et al. (2020, EMNLP, DagoBERT) generate derivational morphology. Hofmann et al. (2021, ACL) show that tokenisation hurts handling of derivations. Schick & Schütze (2019/2020) estimate embeddings for rare words. +- **Compositional generalisation.** SCAN (Lake & Baroni 2018, ICML), COGS (Kim & Linzen 2020, EMNLP) and CFQ (Keysers et al. 2020, ICLR) hold out recombinations. The same logic gives a held-out formation axis. +- **Slang generation and interpretation.** Sun, Zemel & Xu (2021, TACL, "A computational framework for slang generation"), plus Sun et al. 2019 (CogSci) on slang as categorisation. Ni & Wang (2017, IJCNLP) on explaining non-standard words and phrases. Wilson et al. (2020, LREC) on Urban Dictionary embeddings. + +## (c) Extension options +| Option | Data | Specs | Eval | Readiness effect | Cost | Risks | +|---|---|---|---|---|---|---| +| 1. **Formation label as an auxiliary task** (multi-label head next to T1) | Already have 366 term tags; needs Danny's corrections (2026-10-16g) | Add to spec 009 / G5 as exploratory | Macro-F1 per type on test terms; does T1 improve with the auxiliary head? | None if kept exploratory | About $0 (tags exist); small Spark compute | Term-level labels repeat across rows, so the head can memorise the term. Keep it term-split (it already is). | +| 2. **Formation-conditioned held-out** (unseen productive affix or mechanism as a split axis) | Pick 1–2 affixes (e.g. -gender, -core) whose terms are all in test | New split axis in G5; must not move existing splits, so only *report* a slice over existing test terms, or pre-register for v3 | T1 accuracy on test terms grouped by formation type, as a report-only slice | None if report-only. A real re-split would change the manifest, so defer it | $0 | The slices are small (37 test terms), so CIs will be wide. Use the term-level bootstrap. | +| 3. **Generation / prediction task** (base + mechanism → form, or form → base + mechanism + meaning) | Needs base words: derivable for clipping, blend and affixation (about 145 terms) | New task T6 (or a spec 001 `mutation_prediction.v1` bridge) | Exact or edit-distance match on held-out terms; human plausibility ratings | Separate track; doesn't block G1–G5 | Labelling bases is about $0.10–0.30 at Flash cost; eval needs human review | Synthetic leakage if generated forms are fed back as data. Keep generated forms out of the observation store. | +| 4. **Wug-style synthetic probes** (nonce bases with real affixes, e.g. "blorpmaxxing") | Templated probe set, about 200 items | Probe-only appendix to G5 | Does the model assign the affix sense to nonce words? Compare BASE vs LoRA | None. Probes are never training data | About $0 to make; inference on Spark | Contamination if probes leak into train. Store them in a separate file, hash it, and add a fail-closed guard in `train_lora`. | + +## Recommendation (smallest useful path, no readiness delay) +1. Now: keep the formation field as metadata (done). Danny corrects 2026-10-16g along with the 16m rulings. +2. G5 (no gate change): add **report-only** formation slices of T1 test accuracy and a wug probe set as exploratory analyses. Pre-register them in the G5 doc so they don't count as peeking. This needs no re-split and no manifest change. +3. After G5: add the auxiliary formation head (option 1) and productivity tracking (Baayen P per affix over time), which ties into spec 008 diffusion. +4. v3: a formation-held-out split (option 2) and a generation task (option 3), linked to spec 001 `mutation_prediction.v1`. diff --git a/docs/v2/FORMATION_TAXONOMY.md b/docs/v2/FORMATION_TAXONOMY.md new file mode 100644 index 00000000..fe1ec779 --- /dev/null +++ b/docs/v2/FORMATION_TAXONOMY.md @@ -0,0 +1,38 @@ +# Hyperlex v2: word-formation (mechanism) field + +Status: DRAFT. Approved by Danny on 2026-10-16 at 3:06 PM PT. This is a term-level attribute. It is **not** a lineage family and it does **not** drive the split. + +## Schema (backward-compatible) +- `terms.formation_json` is a nullable TEXT column holding `{"types": [..], "confidence": "high|medium|low", "basis": "...", "note": "..."}`. A term may carry more than one type. +- The export adds `formation: [..]` to each row and writes `[]` when the field is absent. Consumers must tolerate the key being missing or empty: `train_lora.load`, `prereg_eval` and `base_audit` all ignore it. +- `basis` records where the tag came from: `INFERRED:opus formation tag 2026-10-16`, or a Danny ruling (`algo` = clipping, 2026-10-16 3:04 PM PT, "example of symbolic compression"). + +## Types +| Value | Definition | Example | +|---|---|---| +| clipping | A word shortened, keeping one part | algorithm → algo | +| blend | Parts of two words fused, usually with overlap | brunch, frenemy | +| acronym_initialism | Built from the initial letters of a phrase | fr, icl, kys | +| eggcorn | A misheard or reinterpreted phrase that makes local sense | "for all intensive purposes" | +| compound | Two or more whole words joined | slop grenade | +| affixation | A productive prefix or suffix | -maxxing, -pilled, -core, -gender | +| semantic_shift | An existing word with a new sense (broadening, narrowing, metaphor) | cooked, mid, sharp | +| borrowing | Taken from another language or dialect | izzat | +| phonetic_respelling | A spelling that reflects pronunciation or accent | dutty, finna | +| coinage_other | Invented outright, or another process | — | +| unknown | The type can't be told from the evidence | — | + +## Sources +- Bauer, L. (1983). *English Word-Formation*. Cambridge University Press. +- Plag, I. (2003). *Word-Formation in English*. Cambridge University Press. Covers clipping, blending, affixation, compounding and conversion. +- Baayen, R. H. (1992). Quantitative aspects of morphological productivity. *Yearbook of Morphology 1991*, 109–149. Productivity measure P = n1/N. +- Gries, S. Th. (2004). Shouldn't it be breakfunch? A quantitative analysis of blend structure in English. *Linguistics* 42(3). +- Liberman, M. (2003). "Egg corns: folk etymology, malapropism, mondegreen, ???" Language Log, 23 Sep 2003. This is where Pullum's coinage "eggcorn" was introduced. See also the Eggcorn Database (eggcorns.lascribe.net). + +These citations are from memory. Verify the DOIs and pages before the spec is frozen. + +## Tagging, 2026-10-16 +- Opus tagged all 366 terms in batches of 40. Danny ruled `algo` as clipping. +- Tag counts: compound 114, semantic_shift 110, affixation 65, clipping 46, blend 34, acronym_initialism 29, borrowing 25, phonetic_respelling 25, coinage_other 21, unknown 20, eggcorn 1. +- 118 terms carry more than one type. Confidence: 175 high, 126 medium, 65 low. +- The corrections-only review list is in the private tracker. Slur-family terms are in a separate private file and appear here only as counts. diff --git a/scripts/v2/export_splits.py b/scripts/v2/export_splits.py index 062651ce..a5a8010c 100644 --- a/scripts/v2/export_splits.py +++ b/scripts/v2/export_splits.py @@ -29,6 +29,18 @@ def context_of(r): return ctx, kind +def formation_map(db="/workspace/vernacular-ingest/data/vernacular.sqlite3"): + """term (lower) -> list of word-formation types from terms.formation_json (2026-10-16). Optional, backward-compatible: + missing column/db -> {} and rows get formation=[] (consumers must tolerate absence).""" + import sqlite3 + try: + c = sqlite3.connect(f"file:{db}?mode=ro", uri=True) + return {cf.lower(): (json.loads(fj) or {}).get("types", []) for cf, fj in + c.execute("SELECT canonical_form, formation_json FROM terms WHERE formation_json IS NOT NULL")} + except Exception: + return {} + + def text_key(r): """Dedup key on the exported text itself (case/whitespace-normalised), not only the source post hash: identical short excerpts from different posts were surviving as duplicates (readiness check 2026-10-16).""" @@ -63,6 +75,7 @@ def main(src=ROOT + "/curated_sense_observation.jsonl", out=OUT): rep["dropped_non_gold_row_status"] = len(rows2_all) - len(rows2) rep["dropped_cross_split"] = len(rows1) - len(rows2) by = collections.defaultdict(list) + FORM = formation_map() for r in rows2: g = gold(r) ctx, kind = context_of(r) @@ -70,6 +83,7 @@ def main(src=ROOT + "/curated_sense_observation.jsonl", out=OUT): by[r["_split"]].append({ "record_id": r["record_id"], "split": r["_split"], "term": r["term"], "term_family": r["term_family"], "lineage_family": (r.get("mutation_lineage") or {}).get("lineage_family"), + "formation": FORM.get(r["term"].lower(), []), "context": ctx, "context_match": kind, "label": g or r["sense_candidate"], "use_mention": h.get("use_mention"), "row_status": h.get("row_status"), "excerpt_provenance": h.get("excerpt_provenance"), From 91f7f0e978631bf50f0a9e5b4663817b2ee43a96 Mon Sep 17 00:00:00 2001 From: scrimshawlife-ctrl Date: Fri, 16 Oct 2026 15:32:56 -0700 Subject: [PATCH 12/15] docs: T2 254/300 after 16m meanings ruling (independent recount) --- docs/KANBAN.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/KANBAN.md b/docs/KANBAN.md index 79164d21..57238b7f 100644 --- a/docs/KANBAN.md +++ b/docs/KANBAN.md @@ -14,21 +14,21 @@ Readiness rule (Danny 2026-10-16 12:45 PT): test-gold coverage (G1) and ruled me |---|---|---|---| | G1 test gold rows (export) | 274/250 | 274 (test.jsonl human S/O = gold_test.jsonl = manifest ids) | MET (rows) | | G1 term breadth (roadmap >=150 terms) | 37 terms | 37 | NOT MET; Danny to confirm the clause applies | -| T2 ruled meanings | 149/300 | 149 (operator_definitions by source: 100 T2 review + 47 queue definitions + 2 chat) | SHORT by 151 | +| T2 ruled meanings | 254/300 | 254 (defined terms with a terms row; = 150 before + 104 from queue 16m, Danny 2026-10-16 3:29 PM PT). 170 with >=3 contexts / 157 with >=3 slang contexts | SHORT by 46 | Ruling landing: 1,472 rulings, 1,425 gold (test 277, val 164, train 984). Export gold: test 274, val 158, train 933. Manifest 274 ids, sha 57543bbd…, not frozen. ## Next - [ ] **Danny decisions on families (private).** Owner: Danny. 1 Kimi low-confidence item and 4 held terms (named in the private store only). 63 rows stay unfamilied until then. - [ ] **15 quarantined gold rows.** Owner: Danny (decision). Ruled gold rows (3 test, 2 val, 10 train) fail the existing DQ checks (author id present plus suspect synthetic source id). Fix the check, or keep them out. -- [ ] **Reach 300 ruled meanings (T2).** Owner: Grok Bot (drafts), Danny (rulings). 149/300. Plan proposed 2026-10-16: draft meanings for undefined terms with evidence, then collect for undefined terms without posts. +- [ ] **Reach 300 ruled meanings (T2).** Owner: Grok Bot (drafts), Danny (rulings). 254/300 after queue 16m (+104 ratified, 23 rejected as insufficient evidence for a generalized sense, kept in the emergence registry; 1 held). Next: term-discovery pass (~57-77 terms, ~$0.76-1.02), waits on Danny's cost approval. ## In progress - [ ] **Raise test gold to 250 (G1), then 470 (G5).** Owner: Danny (rulings), Grok Bot (queues). Rows: export 274/250 met (recount 274; landing 277); G5 274/470; 37 test terms (roadmap >=150 open). Test-gap fill: 228 posts for 18/21 empty test terms; queues 2026-10-16c (54), 16d (42), 16e (33) ruled and applied. tlpur needs context. - [ ] **PR #31: T026/T028 (windowed export context, R statuses non-gold, Jev use_mention).** Owner: Danny (merge yes). Opus review findings fixed; 42 tests pass. Not merged. ## Blocked -- [ ] **Freeze the held-out test manifest.** Owner: Grok Bot, with Danny's sign-off. Blocked on READY (T2 149/300) and Danny's sign-off. +- [ ] **Freeze the held-out test manifest.** Owner: Grok Bot, with Danny's sign-off. Blocked on READY (T2 254/300) and Danny's sign-off. - [ ] **Archive repo is read-only (scrimshawlife-ctrl/Hyperlex).** Owner: Danny. Decide: unarchive it, or move VERDICT-RULES into this repo. ## Done From 74b41608475f3f12abad3bf27f0b9e9eea73f57f Mon Sep 17 00:00:00 2001 From: scrimshawlife-ctrl Date: Fri, 16 Oct 2026 15:54:28 -0700 Subject: [PATCH 13/15] docs: T2 318/300 met after 16m + disc rulings (independent recounts) --- docs/KANBAN.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/KANBAN.md b/docs/KANBAN.md index 57238b7f..98d8fc24 100644 --- a/docs/KANBAN.md +++ b/docs/KANBAN.md @@ -14,21 +14,21 @@ Readiness rule (Danny 2026-10-16 12:45 PT): test-gold coverage (G1) and ruled me |---|---|---|---| | G1 test gold rows (export) | 274/250 | 274 (test.jsonl human S/O = gold_test.jsonl = manifest ids) | MET (rows) | | G1 term breadth (roadmap >=150 terms) | 37 terms | 37 | NOT MET; Danny to confirm the clause applies | -| T2 ruled meanings | 254/300 | 254 (defined terms with a terms row; = 150 before + 104 from queue 16m, Danny 2026-10-16 3:29 PM PT). 170 with >=3 contexts / 157 with >=3 slang contexts | SHORT by 46 | +| T2 ruled meanings | 318/300 | (A) 318 definitions; (B) 150 pre-16m + 168 from the 16m and disc ruling ledgers = 318 (Danny 2026-10-16 3:29 and 3:52 PM PT). 171 with >=3 store contexts / 157 with >=3 slang contexts | MET | Ruling landing: 1,472 rulings, 1,425 gold (test 277, val 164, train 984). Export gold: test 274, val 158, train 933. Manifest 274 ids, sha 57543bbd…, not frozen. ## Next - [ ] **Danny decisions on families (private).** Owner: Danny. 1 Kimi low-confidence item and 4 held terms (named in the private store only). 63 rows stay unfamilied until then. - [ ] **15 quarantined gold rows.** Owner: Danny (decision). Ruled gold rows (3 test, 2 val, 10 train) fail the existing DQ checks (author id present plus suspect synthetic source id). Fix the check, or keep them out. -- [ ] **Reach 300 ruled meanings (T2).** Owner: Grok Bot (drafts), Danny (rulings). 254/300 after queue 16m (+104 ratified, 23 rejected as insufficient evidence for a generalized sense, kept in the emergence registry; 1 held). Next: term-discovery pass (~57-77 terms, ~$0.76-1.02), waits on Danny's cost approval. +- [x] **Reach 300 ruled meanings (T2).** Owner: Grok Bot (drafts), Danny (rulings). 318/300 MET 2026-10-16 4:05 PM PT after queues 16m and disc (65 new term rows; export byte-identical, 0 split changes). ## In progress - [ ] **Raise test gold to 250 (G1), then 470 (G5).** Owner: Danny (rulings), Grok Bot (queues). Rows: export 274/250 met (recount 274; landing 277); G5 274/470; 37 test terms (roadmap >=150 open). Test-gap fill: 228 posts for 18/21 empty test terms; queues 2026-10-16c (54), 16d (42), 16e (33) ruled and applied. tlpur needs context. - [ ] **PR #31: T026/T028 (windowed export context, R statuses non-gold, Jev use_mention).** Owner: Danny (merge yes). Opus review findings fixed; 42 tests pass. Not merged. ## Blocked -- [ ] **Freeze the held-out test manifest.** Owner: Grok Bot, with Danny's sign-off. Blocked on READY (T2 254/300) and Danny's sign-off. +- [ ] **Freeze the held-out test manifest.** Owner: Grok Bot, with Danny's sign-off. T2 met; blocked on Danny's sign-off (and the 15 quarantined gold rows decision). - [ ] **Archive repo is read-only (scrimshawlife-ctrl/Hyperlex).** Owner: Danny. Decide: unarchive it, or move VERDICT-RULES into this repo. ## Done From 6af5f3e2579630614898ed1aa6e2fba9356fb7cf Mon Sep 17 00:00:00 2001 From: scrimshawlife-ctrl Date: Fri, 16 Oct 2026 16:00:00 -0700 Subject: [PATCH 14/15] docs(v2): test manifest frozen (a03c8619, 273 ids); readiness READY per Danny go 2026-10-16 --- docs/KANBAN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/KANBAN.md b/docs/KANBAN.md index 98d8fc24..52d59c3b 100644 --- a/docs/KANBAN.md +++ b/docs/KANBAN.md @@ -28,7 +28,7 @@ Ruling landing: 1,472 rulings, 1,425 gold (test 277, val 164, train 984). Export - [ ] **PR #31: T026/T028 (windowed export context, R statuses non-gold, Jev use_mention).** Owner: Danny (merge yes). Opus review findings fixed; 42 tests pass. Not merged. ## Blocked -- [ ] **Freeze the held-out test manifest.** Owner: Grok Bot, with Danny's sign-off. T2 met; blocked on Danny's sign-off (and the 15 quarantined gold rows decision). +- [x] **Freeze the held-out test manifest.** Done 2026-10-16 4:00 PM PT (Danny go 3:55 PM PT): 273 ids, sha256 a03c8619…; recorded in docs/v2/G5_PREREG_EVAL.md (PR #33), tag v2-test-freeze-2026-10-16. The 15 quarantined gold rows stay out of test. Readiness: READY (G1 273, 37/37 test terms; T2 318/300). Nothing runs on the Sparks until Danny says go. - [ ] **Archive repo is read-only (scrimshawlife-ctrl/Hyperlex).** Owner: Danny. Decide: unarchive it, or move VERDICT-RULES into this repo. ## Done From 527bebe361566846b98ffcc1d6631a5384cf06d0 Mon Sep 17 00:00:00 2001 From: scrimshawlife-ctrl Date: Fri, 16 Oct 2026 16:19:17 -0700 Subject: [PATCH 15/15] docs(v2): open items applied per Danny 2026-10-16; manifest unchanged, READY --- docs/KANBAN.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/KANBAN.md b/docs/KANBAN.md index 52d59c3b..bf09211f 100644 --- a/docs/KANBAN.md +++ b/docs/KANBAN.md @@ -40,3 +40,4 @@ Ruling landing: 1,472 rulings, 1,425 gold (test 277, val 164, train 984). Export - [x] **Betting-sharp replacement pick.** Retired in PR #27 (220c108). - [x] **Spec 009 Q1-Q5 decisions applied, and the repair queue re-ruled** (2026-10-16). - [x] **Merge specs 008 and 009 to main.** #28 squash d87e3af, #29 squash 4f17542. +- [x] **Open items (Danny 2026-10-16 4:03 PM PT).** Held family calls applied; family gate reported as 16 (one private family excluded from H3 claims); betting-sharp stays retired; meaning/dictionary rows added for 65 new terms; formation tags accepted; 80-row label audit queued for Danny. Test manifest a03c8619 unchanged; readiness still READY.