Release 11.0 (full): passage readings held back when the sentence leaves out a question word, the judge names the step it refused, the part format v1, anyone's sealed test, the sleep cycle, and the six orbiters as files in the pack (part 4)
Browse filesHead oracle_release_runtime_w575. Root 5985f38d66bcdedbdedb74db90432675a32ddce9dfe2d196b3282c40581d889b. Solana anchor: pending Ben's signature. Internal week (seven simulated nights): 0 parts admitted, 0 new wrong, published as measured. Full changelog: CHANGELOG_11.md.
Files changed (3)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361#!/usr/bin/env python3
"""oracle_release_runtime_w575 - 10.5: THE HEAD RECEIVES. Constitution article 1, first three tips, all on one turn:
- a question the head can't answer opens a hole, kept for the session, and the reply says what it would take in;
- the next turn can fill it: a statement that says the hole's words and adds something new is a claim, kept with who said it;
- a statement about the last answer is a correction: it goes through the same comparison `check` uses, and both are shown;
- a reading the flash found below its threshold is offered, marked as held back, with its steps. It is never stated as an answer.
A claim or a held-back reading is never an answer. status stays "received" or "held_back", so nothing here can raise a yes; it counts as cited to the speaker and the
reply says so. Nothing about what a question or a statement looks like is listed: a statement joins a hole by the words they share
and what it adds, each word weighted by how rare the store says it is. Claims are written to <state>/receive/claims.jsonl, for the sleep cycle. Never imports a runtime other than its
parent, w574."""
import json
import math
import re
import sqlite3
import sys
import time
from pathlib import Path
from oracle_release_runtime_w574 import OracleReleaseRuntimeW574 as _Base
import oracle_release_runtime_w563 as W563
import oracle_release_runtime_w420 as _W420
import oracle_release_runtime_w442 as _W442
from oracle_release_runtime_w563 import terminal_refusal
from oracle_release_runtime_w572 import ASKED
WORD = re.compile(r"[a-z0-9][a-z0-9.\-]*", re.I)
JOIN = 0.95 # the share of a hole's weight a statement must say to join it (join_measure: 3,000 built pairs, held-out half: precision 0.992, Wilson low 0.98, recall 0.632)
SUBJECT = 6.2 # log(500): a word in fewer than 1 in 500 of the store's rows is what the hole is about, and a statement must say it
RARE = 2.3 # log(10): what a statement adds has a word in fewer than 1 in 10 of the store's rows, or a number
class Written(set):
"""a sentence's words: a set that iterates in the order they were written. The passage reader measured word order and distance on a plain set, which is hash order"""
def __init__(self, ws=()):
self.order = list(dict.fromkeys(ws))
super().__init__(self.order)
def __iter__(self):
return iter(self.order)
def __ior__(self, other):
for w in other:
if w not in self:
self.order.append(w)
self.add(w)
return self
def _written(s):
return Written(_W420._stem(t) for t in re.findall(r"[a-z0-9]+", s.lower()))
_W420._toks = _W442._toks = _written
def words(s):
return [w.lower().rstrip(".") for w in WORD.findall(str(s))]
def asks(text):
return "?" in str(text) or bool(ASKED.match(str(text)))
def witnessed(fam, mod, r, q, givens):
"""how many givens the answer was computed from (plan 3.4): a given counts if any nudge of it moves the answer, so 0 for more successes
than trials, flat at one nudge, is a computed answer. fam._dependence tries one +7% nudge; this adds half and double."""
ms = list(mod.NUM.finditer(q)) if hasattr(mod, "NUM") else []
if len(ms) != len(givens):
return fam._dependence(r, q, givens)
o, base, dep = r["_organ"], mod._answer_value(r["response"], givens), 0
for m in ms:
moved = False
txt = m.group(0).replace(",", "")
try:
v = float(txt)
except ValueError:
dep += 1
continue
alts = [mod._perturb(q, m)] + [q[:m.start()] + (str(int(x)) if x == int(x) else "%.3f" % x) + q[m.end():] for x in (v / 2, v * 2)]
for t in alts:
a = o.reply(t, "counterfactual")
if a is None or a["kind"] != r["kind"] or a["status"] != r["status"]:
moved = True
elif base is None:
moved = a["response"] != r["response"]
else:
moved = not mod._same_value(base, mod._answer_value(a["response"], mod._givens(t)), rel=1e-4)
if moved:
break
dep += moved
return dep
PRONOUNS = {_W442._stem(w) for w in ("it", "its", "they", "their", "he", "his", "she", "her")}
class OracleReleaseRuntimeW575(_Base):
def _owner_words(self, q, session_id, r):
"""w563's owner stage with its two checks on shape replaced by a witness of computation: every given bound (witnessed), so a true
answer that is 0 or equals a given isn't withheld for how it looks. One given read back stays refused: nothing else moved it."""
path = str(r.get("path", ""))
if terminal_refusal(r) or any(k in path.lower() for k in W563.STANDS) or not W563.READING.search(path):
return r
consulted = set(W563.SPEC_IN_PATH.findall(path))
try:
fam, mod = W563._load()
with W563._LOCK:
chosen, trace = fam._one(q, "w563" + str(session_id)[:30])
if chosen is None or chosen.get("declined") or chosen.get("status") != "answered":
return r
if (trace or {}).get("rule") not in ("only", "agree"):
return r
sid = chosen.get("id") or getattr(chosen.get("_organ"), "id", None)
if not sid or sid in consulted:
return r
givens = mod._givens(q)
if givens and witnessed(fam, mod, chosen, q, givens) < len(givens):
return r
except Exception: # noqa: BLE001 - a specialist failure never breaks the turn; the parent's reply stands
return r
resp = str(chosen.get("response", ""))
if W563.QTY.search(q) or path.startswith("restated>organ:math"):
given = W563._givens(q)
if len(given) < 2 and not [v for v in W563._givens(resp) if not any(abs(v - g) <= 1e-9 * max(1.0, abs(g)) for g in given)]:
return r
else:
m = W563.SUBJECT.search(q)
if not m or m.group(1).strip().lower() not in resp.lower():
return r
out = W563.replacement_reply(r)
out.update(status="answered", response=resp + " [%s]" % sid, references=chosen.get("references", []),
path="owner_words>specialist_call>specialist:%s>%s" % (sid, chosen.get("kind", "")))
out.pop("why", None)
return out
def __init__(self, *a, **k):
super().__init__(*a, **k)
self._k575_store_path = k.get("wikipedia_build")
self._k575_weights, self._k575_store_db, self._k575_store_n = {}, None, 0
self._k575_state, self._k575_below = k.get("state_root") or "state", {}
self._k575_parts = {} # shape -> part id: reading rules that passed their exam
for f in sorted(Path(self._k575_state).glob("parts/*.json")):
try:
part = json.load(open(f, encoding="utf-8"))
if part.get("kind") == "reading-rule" and "shape" in part["body"] and "route_to" not in part["body"]: # a route part is consolidation's, not the reader's
# a skeleton part states readings of its shape from the score its exam held at (none: any score above nothing)
key = ("steps:" if part["body"].get("shape_kind") == "steps" else "") + part["body"]["shape"]
self._k575_parts[key] = (part["id"], float(part["body"].get("min_score", 0.0)))
except (OSError, ValueError, KeyError): # a bad file costs that part, never the head
pass
def _k575_weight(self, w):
"""how much a word says, read from the store: log(rows / rows holding it). A word the store has never seen says the most."""
if w not in self._k575_weights:
try:
if self._k575_store_db is None:
db = "%s/wikipedia_specialist.sqlite3" % self._k575_store_path
self._k575_store_db = sqlite3.connect("file:%s?mode=ro" % db, uri=True, check_same_thread=False)
self._k575_store_n = self._k575_store_db.execute("select count(*) from source_rows_docsize").fetchone()[0]
df = self._k575_store_db.execute("select count(*) from source_rows where source_rows match ?", ('"%s"' % w.replace('"', ""),)).fetchone()[0]
self._k575_weights[w] = math.log(self._k575_store_n / (1 + df))
except (sqlite3.Error, TypeError): # without the store every word counts the same
self._k575_weights[w] = RARE
return self._k575_weights[w]
def _k575_joins(self, q, text):
"""what `text` adds to the question q, when it says q's words by weight; None when it doesn't join"""
a, t = set(words(q)[1:]), words(text) # the first word asks: a statement doesn't repeat it
total = sum(self._k575_weight(w) for w in a)
if total <= 0 or sum(self._k575_weight(w) for w in a & set(t)) < JOIN * total:
return None
if any(self._k575_weight(w) >= SUBJECT for w in a - set(t)):
return None # the same words about another subject: a statement about water fills no hole about frobnium
new = [w for w in t if w not in a]
return new if any(c.isdigit() for w in new for c in w) or any(self._k575_weight(w) >= RARE for w in new) else None
def _k575_receive_state(self, sid):
if not hasattr(self, "_k575_received"):
self._k575_received = {}
return self._k575_received.setdefault(sid, {"hole": None, "last": None, "claims": []})
def _k575_keep_claim(self, sid, q, text, kind, verdict=None, ours=None):
c = {"session": str(sid), "question": q, "claim": str(text), "kind": kind, "verdict": verdict, "ours": ours}
self._k575_receive_state(sid)["claims"].append(c)
self._k575_log("claims", c)
return c
def _k575_log(self, name, entry):
"""what the day took in, for the sleep cycle: <state>/receive/<name>.jsonl"""
try:
root = Path(self._k575_state) / "receive"
root.mkdir(parents=True, exist_ok=True)
with open(root / (name + ".jsonl"), "a", encoding="utf-8") as f:
f.write(json.dumps(dict(entry, t=round(time.time(), 3))) + chr(10))
except OSError: # a full disk costs the record, never the turn
pass
def _reading_holds(self, t, prog):
"""w572's check (every name the reading uses is written in the question), and its other half (11-03): every whole name the question
writes is used by the reading. KQA val, 600 questions: 0 right readings refused, 1 wrong caught; it would have refused "John Carter of
the University of Texas School of Law ... at Texas Tech" read without Texas Tech"""
if not super()._reading_holds(t, prog):
return False
import reading_names
return not reading_names.names_unused(t, prog)
def _r434_passage(self, s, res, t0):
"""the passage reader with the same half of the check (11-03): the one question word a covering sentence may leave out cannot be a name
the passage writes. Gate 18 read "Did ireland qualify for the 2018 world cup?" off "Serbia qualified directly for the 2018 FIFA World
Cup" and said yes; Ireland was the word left out"""
m = _W442.PASSAGE.match(s)
names = set()
prev = {}
if m:
last = set()
for sent in _W442._sentences(m.group(1)):
words = re.findall(r"[A-Za-z][A-Za-z0-9']*", sent)
names |= {_W442._stem(w.lower()) for w in words[1:] if w[:1].isupper()}
pool = frozenset(_W442._stem(t) for t in _W442._toks(sent))
prev[pool] = last # a pronoun in this sentence names what the sentence before it named
last = set(pool)
self._k575_pnames, self._k575_prev = names, prev
try:
out = super()._r434_passage(s, res, t0)
finally:
self._k575_pnames, self._k575_prev = set(), {}
return self._k575_passage_held(out, m)
def _k575_passage_held(self, out, m):
"""a passage answer whose sentence leaves out a word of the question is a reading the passage doesn't state: held back, with the
sentence and the word, never stated (11-04). On the gate these were 18 right and 4 wrong: guesses, not readings"""
if not out or out.get("status") != "answered" or out.get("path") != "reading:passage_yesno" or not m:
return out
rd = (out.get("provenance") or {}).get("reading") or {}
if rd.get("coverage", 1) >= 1:
return out
sent = out["references"][0]["text"]
pool = {_W442._stem(t) for t in _W442._toks(sent)}
aliased = {a.get("term") for a in rd.get("aliases", [])}
q = m.group(2).strip()
missing = [t for t in _W442._qterms(q) if _W442._stem(t) not in pool and t not in aliased]
verdict = out["response"].split(".")[0]
word = ", ".join("'%s'" % t for t in missing) or "one word of the question"
out = dict(out, status="held_back", path="reading:held_back",
response="I have a reading I can't state yet. Held back: %s. The passage sentence closest to the question is \"%s\", and it "
"doesn't say %s. If you know whether it's right, tell me." % (verdict, sent[:300], word))
out["provenance"] = dict(out.get("provenance") or {}, held_back={"verdict": verdict, "missing": missing})
return out
def _r436_covered(self, terms, terms_stem, numbers, pool):
ok, cov, via = super()._r436_covered(terms, terms_stem, numbers, pool)
if ok and cov < 1:
aliased = {t for t, _ in via}
missing = [ts for t, ts in zip(terms, terms_stem) if ts not in pool and t not in aliased]
names = getattr(self, "_k575_pnames", ())
before = getattr(self, "_k575_prev", {}).get(frozenset(pool), set()) if pool & PRONOUNS else set()
if any(ts in names and ts not in before for ts in missing):
return False, 0.0, via
return ok, cov, via
def _k575_held(self, t):
"""the flash's reading of t below its threshold, or None. Run only when this turn's flash stopped at the threshold."""
cov = getattr((getattr(self, "_organs", None) or {}).get("facts"), "coverage", None)
if cov is None or not cov.why.get("below score threshold") or cov.why["below score threshold"] == self._k575_below.get(id(cov)):
return None
self._k575_below[id(cov)] = cov.why["below score threshold"]
floor = cov.threshold()
cov.threshold = lambda: float("-inf")
try:
r = cov.flash_answer(t)
except Exception: # noqa: BLE001 - a failure here costs the turn nothing
return None
finally:
del cov.threshold
if not r or r.get("status") != "answered" or r["show"]["score"] <= 0 or not self._reading_holds(t, r["show"]["program"]):
return None # a score of nothing is no reading: it offered a film length for a greeting
steps = [x.split(" -> ")[0] for x in self._organs["facts"].explain(r["show"]["program"])]
return {"answer": r["answer"], "steps": steps, "score": r["show"]["score"], "threshold": floor, "program": r["show"]["program"]}
def chat(self, text: str, session_id: str = "default") -> dict:
st = self._k575_receive_state(session_id)
if not asks(text):
hole, last = st["hole"], st["last"]
if hole and self._k575_joins(hole["question"], text):
self._k575_keep_claim(session_id, hole["question"], text, "hole")
st["hole"] = None
return {"status": "received", "path": "receive>hole_filled", "references": [], "provenance": {"organ": "receive", "by": "speaker"},
"response": "Received, as your claim: %s I can't check it against what I hold yet, so when I use it I'll say it came from you."
% str(text).strip().rstrip(".").__add__(".")}
if last and self._k575_joins(last["question"], text):
from handoff101 import compare
v, _note = compare(last["answer"], " ".join(self._k575_joins(last["question"], text)))
self._k575_keep_claim(session_id, last["question"], text, "correction", v, last["answer"])
return {"status": "received", "path": "receive>correction", "references": [], "provenance": {"organ": "receive", "by": "speaker", "verdict": v},
"response": "My answer was %s, reached by %s. You said: %s Compared: %s. Both are kept for checking."
% (last["answer"], last["path"], str(text).strip().rstrip(".") + ".", v.lower())}
import step_address
cov_ = getattr((getattr(self, "_organs", None) or {}).get("facts"), "coverage", None)
if cov_ is not None:
step_address.watch(cov_) # the judge's refusals on this turn, so a hole can name the step it stopped at
step_address.reset(cov_)
r = super().chat(text, session_id)
if not isinstance(r, dict):
return r
if r.get("status") == "answered":
from handoff101 import answer_of
import answer_form
said = answer_of(r)
if not answer_form.fits(text, str(r.get("response", "")) if answer_form.asked(text) == "yes_no" else said):
# the law at the exit, for every organ: an answer that isn't the kind the question asks for is not said; it becomes a hole
# naming what was asked (gate 16a: 0 of 1,808 valid answers refused, 2 false yes caught)
want = answer_form.asked(text)
st["hole"] = {"question": str(text), "kind": "form:" + want}
self._k575_log("holes", {"session": str(session_id), "question": str(text), "kind": "form:" + want, "path": str(r.get("path", "")), "refused": str(said)[:200]})
out = {k: v for k, v in r.items() if k != "why"}
out.update(status="declined", path="receive>form_refused>" + str(r.get("path", "")), hole=st["hole"],
response="I found an answer, but it isn't %s, which is what you asked for, so I won't give it. If you know it, tell me and I'll keep it as your claim."
% {"date": "a date", "number": "a number", "yes_no": "a yes or no", "relation": "a relation between the two"}[want])
return out
st.update(hole=None, last={"question": str(text), "answer": said, "path": str(r.get("path"))})
return r
if terminal_refusal(r) or not asks(text):
return r
for c in reversed(st["claims"]):
if c["kind"] == "hole" and set(words(c["question"])) == set(words(text)):
out = {k: v for k, v in r.items() if k != "why"}
out.update(status="received", path="receive>claim_recalled", provenance={"organ": "receive", "by": "speaker"},
response="You told me: %s That is your claim. I haven't checked it against what I hold." % c["claim"].strip().rstrip(".").__add__("."))
return out
held = self._k575_held(str(text))
if held and self._k575_parts:
cov = self._organs["facts"].coverage
feats = sys.modules[type(cov).__module__].step_features(held["program"])
part, floor = self._k575_parts.get(" > ".join(f for _i, f, lit in feats if lit is None)) or self._k575_parts.get("steps:" + " > ".join(st["function"] for st in held["program"]), (None, 0.0))
if part and held["score"] >= floor: # an admitted part says a reading of this shape can be stated from its exam's score
out = {k: v for k, v in r.items() if k != "why"}
out.update(status="answered", path="receive>part:%s" % part[:12], provenance={"organ": "reader90", "part": part, "held_back": held},
response="%s. From the knowledge base, step by step: %s." % (held["answer"], "; ".join(held["steps"])))
st.update(hole=None, last={"question": str(text), "answer": held["answer"], "path": out["path"]})
return out
if held:
st["last"] = {"question": str(text), "answer": held["answer"], "path": "organ:reader90>held_back"}
self._k575_log("held", {"session": str(session_id), "question": str(text), **held})
out = {k: v for k, v in r.items() if k != "why"}
out.update(status="held_back", path="receive>held_back", provenance={"organ": "reader90", "held_back": held}, response=
"I have a reading I can't state yet. Held back: %s. Steps: %s. It scored %.2f, and I state readings at %.2f or above. If you know whether it's right, tell me."
% (held["answer"], "; ".join(held["steps"]), held["score"], held["threshold"]))
return out
from declines import classify
kind = classify(str(r.get("response", "")), str(r.get("path", "")))
st["hole"] = {"question": str(text), "kind": kind}
addr = step_address.address(cov_) if cov_ is not None else None
if addr and addr["steps"]: # the hole's address: the step kind the closest refused reading lacks (11-04)
st["hole"]["address"] = addr
self._k575_log("holes", {"session": str(session_id), "question": str(text), "kind": kind, "path": str(r.get("path", "")), "address": st["hole"].get("address")})
out = dict(r)
out["hole"] = st["hole"]
out["response"] = str(r.get("response", "")).rstrip() + (" " + step_address.say(addr) if st["hole"].get("address") else "") + \
" If you know it, tell me and I'll keep it as your claim."
return out123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475#!/usr/bin/env python3
"""reading_names - the other half of the head's reading check. w572 refuses a reading that uses a name the question doesn't write; this refuses
a reading that leaves out a name the question DOES write: a whole name, capitalised in the question, that the store's own linker reads as a
thing, and that no step of the program uses. Found 2026-11-03: "When was John Carter of the University of Texas School of Law educated at
Texas Tech University until?" read the end time of the Law School statement and never used Texas Tech (said 1969, the store holds 1964).
usage (measure on KQA val with known answers): reading_names.py <n>"""
import re
import unicodedata
def _fold(s):
return " ".join(re.sub(r"[^a-z0-9 ]+", " ", unicodedata.normalize("NFKD", str(s)).encode("ascii", "ignore").decode().lower()).split())
def names_unused(q, prog):
"""whole names the question writes that the program never uses -> [span]; [] when there is no linker (outside a release)"""
try:
import entity_linker_v3 as L
except Exception: # noqa: BLE001
return []
used = " | ".join(_fold(x) for st in prog for x in st.get("inputs", []))
spans = []
for span, cands in L.link(q, 3):
fs = _fold(span)
if not cands or len(fs) < 4 or not str(span)[:1].isupper() or fs in used:
continue
if " " not in str(span).strip() and _fold(q).startswith(fs + " "):
continue # a sentence's first word is capitalised for the sentence, not as a name ("Tell me", "Since when")
spans.append(span)
# a span inside a longer unused span is the same name; a span inside a used input is used
return [s for s in spans if not any(_fold(s) != _fold(o) and _fold(s) in _fold(o) for o in spans)]
if __name__ == "__main__":
import importlib.util
import json
import random
import sys
import time
n = int(sys.argv[1]) if len(sys.argv) > 1 else 600
T = "/opt/rel105/t"
spec = importlib.util.spec_from_file_location("o7", T + "/oracle7.py")
o7 = importlib.util.module_from_spec(spec)
sys.argv = ["oracle7.py"]
spec.loader.exec_module(o7)
eng = o7.Engine()
rt = eng._rt
for _ in range(60):
if "facts" in rt._organs:
break
time.sleep(5)
from handoff101 import compare
cov = rt._organs["facts"].coverage
val = json.load(open(T + "/root/organs10/kqa/val.json"))
random.Random(311).shuffle(val)
tally = {"right_kept": 0, "right_refused": 0, "wrong_kept": 0, "wrong_refused": 0}
ex = []
for k, it in enumerate(val[:n]):
try:
r = cov.flash_answer(it["question"])
except Exception: # noqa: BLE001
continue
if not r or r.get("status") != "answered" or not rt._reading_holds(it["question"], r["show"]["program"]):
continue
ok = compare(str(r["answer"]), str(it["answer"]))[0] == "CONFIRMED"
un = names_unused(it["question"], r["show"]["program"])
key = ("right" if ok else "wrong") + ("_refused" if un else "_kept")
tally[key] += 1
if un and len(ex) < 25:
ex.append({"ok": ok, "q": it["question"][:110], "unused": un, "said": str(r["answer"])[:40], "gold": str(it["answer"])[:40]})
if k % 100 == 0:
print(k, tally, flush=True)
print(json.dumps(tally))
for e in ex:
print(json.dumps(e))123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596#!/usr/bin/env python3"""step_address - the judge names the step it refused (paper-four-limits, section 6.1). The flash's judge (Coverage.align, strict) alreadysays, for each shape it refuses, which question words no step reads and which steps the question never writes. Watched for one question,the closest refused shape (fewest unexplained) gives the hole its address: the step kind that is missing, from the step itself or, for aword, from the judge's own learned alignment (the feature the word most means). Nothing about questions is listed here.usage (measure on KQA val): step_address.py <n>"""import collections
def watch(cov): """wrap the judge once, so every strict refusal is kept on cov._sa_refused until the next reset""" if getattr(cov, "_sa_wrapped", False): return orig = cov.align
def align(question, prog, template=None, strict=False): ok, why = orig(question, prog, template=template, strict=strict) if strict and not ok and why: cov._sa_refused.append((prog, why)) return ok, why cov.align, cov._sa_wrapped, cov._sa_refused = align, True, []
def reset(cov): if getattr(cov, "_sa_wrapped", False): cov._sa_refused = []
KIND = {"IN": "relate", "C": "concept", "FN": "function", "OP": "compare"}
def address(cov): """the closest refused shape's address -> {"steps": [kind ...], "words": {word: kind}, "shape": [function ...]} or None""" refused = getattr(cov, "_sa_refused", []) if not refused: return None prog, why = min(refused, key=lambda pw: (len(pw[1].get("unexplained_words", [])) + len(pw[1].get("unsaid_steps", [])), len(pw[0]))) words = {} for w in why.get("unexplained_words", []): top = max(cov.align_w.get(w, {}).items(), key=lambda kv: kv[1], default=(None, 0.0))[0] words[w] = KIND.get(str(top).split(":", 1)[0], "find") if top else "find" # a word the alignment never learned names a thing steps = [u.split(" ", 1)[0] for u in why.get("unsaid_steps", [])] kinds = sorted(set(words.values()) | {("find" if s == "Find" else "value") for s in steps}) return {"steps": kinds, "words": words, "unsaid": why.get("unsaid_steps", [])[:4], "shape": [st["function"] for st in prog]}
def say(addr): """one sentence for the reply""" parts = [] if addr["words"]: parts.append("no step reads %s" % ", ".join("'%s' (%s)" % (w, k) for w, k in list(addr["words"].items())[:4])) if addr["unsaid"]: parts.append("%s" % "; ".join(addr["unsaid"][:2])) return "The closest reading I formed (%s) stops there: %s." % (" > ".join(addr["shape"]), "; ".join(parts))
if __name__ == "__main__": import importlib.util import json import os import random import sys import time n = int(sys.argv[1]) if len(sys.argv) > 1 else 400 T = os.environ.get("O7_TREE_RUN", "/opt/rel105/t") spec = importlib.util.spec_from_file_location("o7", T + "/oracle7.py") o7 = importlib.util.module_from_spec(spec) sys.argv = ["oracle7.py"] spec.loader.exec_module(o7) rt = o7.Engine()._rt for _ in range(60): if "facts" in rt._organs: break time.sleep(5) cov = rt._organs["facts"].coverage watch(cov) val = json.load(open(T + "/root/organs10/kqa/val.json")) random.Random(2026).shuffle(val) tally, kinds, ex = collections.Counter(), collections.Counter(), [] for it in val[:n]: reset(cov) why0 = cov.why["judge refused every shape"] r = cov.flash_answer(it["question"]) if cov.why["judge refused every shape"] == why0: continue a = address(cov) tally["refused"] += 1 tally["addressed" if a and a["steps"] else "no address"] += 1 if a: kinds.update(a["steps"]) if len(ex) < 12: ex.append({"q": it["question"][:100], "gold": [s["function"] for s in it["program"]], "say": say(a)[:220]}) print(json.dumps({"refused": tally["refused"], "addressed": tally["addressed"], "no_address": tally["no address"], "kinds": dict(kinds)})) for e in ex: print(json.dumps(e)) print("done")root/fable-content/oracle-m-series-2026-08-15/self_loop/admitted/oracle_release_runtime_w575.pyAdded+361
root/fable-content/oracle-m-series-2026-08-15/self_loop/admitted/reading_names.pyAdded+75
root/fable-content/oracle-m-series-2026-08-15/self_loop/admitted/step_address.pyAdded+96