#!/usr/bin/env python3 """prompts.py -- the speed prompts: slices of the frozen S0 articles, a nonce first, one instruction after. THE SOURCE. Series set S0's "the 42 articles" (SERIES-SETS.md: `kit/articles.json`, 1,916,801 bytes, sha256 withheld-2026-10-13), vendored byte for byte at vendor/jev/kit/articles.json and checked on every load. The corpus is every article's `state` in the file's own order, joined by a blank line. THE SLICES (frozen once, then never rebuilt). For each context the slice is the longest prefix of the corpus, cut at a word boundary, whose token count on the FIRST llama.cpp server's own /tokenize (add_special false) is at most the target: 4K = 4,000, 32K = 32,000, 128K = 128,000 tokens (128,000 + the nonce, the template and 256 generated tokens fit the 131,072 context both engines run). The first arm to run (L-IQ3) builds them inside its sandbox and writes SLICES.json beside the records; every later arm reads that file and refuses to start without it, and every row carries the slice's sha256 and the token count each server reports for the whole prompt (both engines read the same GGUF tokenizer, so the counts should agree; a disagreement is printed, never corrected). THE PROMPT (one user turn, thinking off): nonces.nonce(...) first -- the kit's "Ticket NNNNNNNN.\n\n", keyed by (arm family "strata-speed", context, level 1, repeat, request 0), never by the engine, so the same repeat sends the same bytes to every arm and greedy outputs stay comparable -- then the slice, a blank line, and INSTRUCTION. """ import hashlib import json import os import common as C ARTICLES = os.path.join(C.VENDOR, "jev", "kit", "articles.json") ARTICLES_SHA = "withheld-2026-10-13" INSTRUCTION = "Write a detailed, section-by-section summary of the text above." NONCE_SEED = "strata-bench-2026-10-02" NONCE_FAMILY = "strata-speed" def corpus(): raw = open(ARTICLES, "rb").read() got = hashlib.sha256(raw).hexdigest() if got != ARTICLES_SHA: raise RuntimeError(f"articles.json sha {got[:12]} is not S0's {ARTICLES_SHA[:12]}") arts = json.loads(raw.decode("utf-8")) return "\n\n".join(a["state"] for a in arts.values()), list(arts) def build_slices(tokenize, targets=None, log=print): """{ctx: {target, tokens, chars, sha256, text}} -- binary search on word boundaries against `tokenize(text)`.""" targets = targets or C.CONTEXTS text, slugs = corpus() cuts = [i for i, ch in enumerate(text) if ch in " \n"] + [len(text)] out = {} for ctx, target in targets.items(): lo, hi = 0, len(cuts) - 1 best = None while lo <= hi: mid = (lo + hi) // 2 n = tokenize(text[:cuts[mid]]) if n <= target: best = (cuts[mid], n) lo = mid + 1 else: hi = mid - 1 if best is None: raise RuntimeError(f"no slice of the corpus fits {target} tokens") s = text[:best[0]].rstrip() n = tokenize(s) out[ctx] = {"target": target, "tokens": n, "chars": len(s), "sha256": hashlib.sha256(s.encode()).hexdigest(), "text": s} log(f"slice {ctx}: {n} tokens (target {target}), {len(s)} chars, sha {out[ctx]['sha256'][:12]}") return {"source": {"file": "vendor/jev/kit/articles.json", "sha256": ARTICLES_SHA, "articles": len(slugs), "order_sha256": hashlib.sha256("\n".join(slugs).encode()).hexdigest()}, "rule": "longest word-boundary prefix of the corpus with tokens <= target on the first llama.cpp " "server's /tokenize (add_special false)", "slices": out} def nonce_text(ctx, repeat, nonces_mod): return nonces_mod.nonce(NONCE_FAMILY, ctx, 1, int(repeat), 0, seed=NONCE_SEED) def prompt(slice_text, ctx, repeat, nonces_mod): n = nonce_text(ctx, repeat, nonces_mod) return n + slice_text + "\n\n" + INSTRUCTION, n