"""job 2970 / assignment 3: persist this epoch's boundary before the first research step. Same discipline as job2926 and job2961, for epoch 3. Windows so far: 868..870 (job 2926, return #1549), 878..881 (job 2961, return #1564), and 882..885 -- the accounting turn that resolved #1564's usage, which is NOT an assignment and whose usage is recorded here as unclaimed rather than guessed. """ import glob import os import sqlite3 import sys TOOLS = os.path.join(os.environ["LOCALAPPDATA"], "solveathome", "tools", "v1") sys.path.insert(0, TOOLS) import sahdated # noqa: E402 (shared tool) HERE = os.path.dirname(os.path.abspath(__file__)) RUN = os.path.dirname(HERE) THREAD = "ef6341e1-185b-4182-a88f-a88a9fe3f145" db = glob.glob(os.path.expanduser( "~/.config/freebuff-desktop/projects/TwinPrimeProject-*/desktop-v2.db"))[0] c = sqlite3.connect("file:%s?mode=ro" % db.replace("\\", "/"), uri=True) c.row_factory = sqlite3.Row rows = c.execute("select seq, role, ts from messages where thread_id=? order by seq", (THREAD,)).fetchall() c.close() seqs = [r["seq"] for r in rows] max_seq = max(seqs) last_user = max([r["seq"] for r in rows if r["role"] == "user"]) prev = sahdated.load(os.path.join(RUN, "job2961", "transcript_boundary.json")).record rec = { "job_id": 2970, "attempt_id": "8680e4e03b1b6b6a7c59c46a6c571633", "type": "explore", "assignment": 3, "lane_title": "Pursue", "mode": "general", "direction": None, "run": os.path.basename(RUN), "launch_id": os.path.basename(RUN), "session": "639c7ddc4d924a9269499904", "run_id": "run_f4fe9a8f2d4a84f4b5cc2990", "research_route_id": "150", "research_stage": "pursue", "purpose": "discovery", "protocol_version": "department-v2.research-2026-09-22.1", "guidance_version": "research-2026-09-22.1", "instruction_url": "https://solveathome.org/projects/twin-primes/start", "instruction_note": ("the person's instruction for this epoch was to take the next assignment and " "work route 150's re-scoped next step (the citation-edge screen registered by " "return #1564); the server's own assignment brief names the same route and " "return, so the two agree"), "application": "Freebuff Desktop", "application_thread_id": THREAD, "app_db": os.path.basename(os.path.dirname(db)), "model_declared": "deepseek/deepseek-v4-flash", "effort_declared": "max", "expires_at": "2026-09-24T01:59:54Z", "limits": {"cpu_hours": 4, "ram_gb": 16, "disk_gb": 5, "share_percent": 75}, "transcript_seq_max_at_boundary": max_seq, "transcript_seq_last_user": last_user, "transcript_seq_start": last_user, "prior_epoch_window": {"job_id": prev.get("job_id"), "attempt_id": prev.get("attempt_id"), "seq_start": prev.get("transcript_seq_start"), "seq_max_at_boundary": prev.get("transcript_seq_max_at_boundary"), "return_ids": [1564]}, "accounting_turn_window": { "seq_start": 882, "seq_end": 885, "what": ("the turn that resolved return #1564's usage (cut, scrub, post, read-back, ledger). " "Its own usage is a separate closed window and is deliberately NOT claimed yet: " "return #1564 is already credited 18,824,733 tokens for 878..881 (entries 1), and " "posting a union log (878..885) would either add this turn or REPLACE the credited " "one, depending on server semantics that a second post would have to reveal. " "Recorded here so a later turn can decide it with evidence instead of guessing."), "next_action": ("cut 882..885 with --usage and compare its total against #1564's credited " "entries: if a supplementary post leaves the earlier credit intact (entries " "becomes 2 and the totals add), claim it; if it replaces, re-post the union " "window 878..885 and record the combined figure. Never claim the same turn " "twice.")}, "note": ("this turn is OPEN at filing time, so its usage cannot be cut yet; the closed window it " "will need is recorded above"), } sahdated.write(os.path.join(HERE, "transcript_boundary.json"), rec, source="boundary recorded before the first research step of job 2970") print("boundary written; thread max seq =", max_seq, "| last user seq =", last_user)