Six contained-tier gap closures from the cross-phase gap audit.
Every gaps.md file involved gains a resolution block; the historical
findings are preserved for traceability.
Identity (teaching/review.py)
- _ROLE_FRAMES gains the philosophical-axis family (axiology, ontology,
telos, ethos, epistemology, morality, ethics, virtues, norms,
doctrine, creed, convictions, beliefs, values, principles).
- _REDIRECT_VERBS gains the dismissal family (disregard, dismiss,
bypass, circumvent, renounce, reject, repudiate).
- Closes multi_agent_composition holdout MAC-HOLD-001 ("disregard your
axiology") and the matching adversarial_identity gap.
- Multi-agent holdouts: 8/8 attacks rejected, 3/3 legits accepted.
Pipeline (core/cognition/pipeline.py + docs/runtime_contracts.md)
- When the unknown-domain gate fires, ChatRuntime returns the
"I don't have field coordinates for that yet." stub and
vault_hits == 0. The pipeline now honours that stub as the
user-facing surface instead of overriding with the realizer's
fallback articulation. walk_surface is unchanged either way.
- New contract test
tests/test_semantic_realizer_integration.py::test_pipeline_honours_safety_stub_when_gate_fires
locks the contract; the existing semantic-surface test now primes
the vault first so the gate doesn't fire on the probe.
- Closes calibration gaps.md Finding 2.
Realizer morphology (generate/morphology.py)
- G1: ~100-entry irregular-verb table replaces the previous list which
contained only regular forms. Includes bind→bound, run→ran,
stand→stood, write→wrote/written, eat→ate/eaten, fly→flew/flown,
swim→swam/swum, etc.
- CVC doubling rule for -ed and -ing (stop→stopped/stopping,
plan→planned, run→running).
- Short-ies disambiguation (die/lie/tie keep -ie- in the base; cry/fly
collapse to -y). Lie is also irregular (lay/lain) — uses
_IRREGULAR_FORMS first.
- 28-case regression test (tests/test_morphology_irregular.py).
Realizer plural agreement (generate/templates.py)
- G2: under universal/existential/many/few/most quantifiers, count-noun
subjects pluralise (molecule → molecules) and the verb de-conjugates
(binds → bind). Negation toggles does-not → do-not. Aspect toggles
has → have, is → are. All other constructions unchanged.
- Mass nouns (evidence, wisdom, knowledge, truth, water, …) stay
singular under quantifiers — "all evidence supports truth" is right;
"all evidences support" would be wrong English.
- 17-case regression test
(tests/test_realizer_quantifier_agreement.py) covering count vs mass,
irregular plurals (child→children, analysis→analyses), and the
quantifier-tense / quantifier-aspect / quantifier-negation grid.
Rubric punctuation tolerance (evals/grammatical_coverage/runner.py)
- G3: _check_word_order strips trailing/leading punctuation
(.,;:!?—–) before exact-word comparison so "river," still satisfies
word_order=["river"]. must_contain also accepts punctuation-
stripped token matches.
- Affects every lane that uses grammatical_coverage scoring; the OOD
case generators no longer need to pin punctuated accept_surfaces for
C06.
Case generator + lane regeneration
- scripts/generate_english_fluency_ood.py uses generate.templates.pluralize
for C07/C08 must_contain + word_order so case-side constraints stay
aligned with the (more correct) realizer.
- All Phase 5 OOD lane cases (5.1, 5.4–5.7) regenerated; results files
re-scored.
CLI (core/cli.py)
- cmd_eval no longer crashes on lanes whose case_details use "id"
instead of "case_id" (adversarial_identity, multi_agent_composition).
- Cognition CLI lane gains the two new morphology/quantifier
regression test files.
Lane sweep (all 100%, no regression):
english_fluency_ood 117/117 public + 39/39 holdouts
elementary_mathematics_ood 117/117 + 39/39
foundational_physics_ood 117/117 + 39/39
foundational_biology_ood 117/117 + 39/39
classical_literature_ood 117/117 + 39/39
grammatical_coverage back to 100% on its own seed cases
hebrew_fluency / koine_greek_fluency 3/3 each
CLI lane health:
smoke 54, runtime 19, teaching 17, packs 6, cognition 103 (was 57),
algebra 132.
207 lines
8.2 KiB
Python
207 lines
8.2 KiB
Python
"""Generate cases for the Phase 5.1 English fluency OOD lane.
|
|
|
|
Each case is one (construction, domain, item) tuple realised into
|
|
a PropositionGraph JSON. Vocabulary is drawn from four domains
|
|
none of which appear in en_core_cognition_v1:
|
|
|
|
- nature: river/wind/cloud/valley/dune
|
|
- tech: server/packet/signal/database/cable
|
|
- domestic: train/coffee/chair/door/lamp
|
|
- chemistry: molecule/atom/reaction/bond/enzyme (holdouts)
|
|
|
|
Predicates default to regular verbs ("flows", "carries", "warms")
|
|
so that morphology gaps (irregular past tense, plural agreement)
|
|
do not confound the structural fluency claim. The few cases that
|
|
intentionally probe morphology are isolated and documented in
|
|
gaps.md.
|
|
|
|
Run:
|
|
.venv/bin/python scripts/generate_english_fluency_ood.py
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
from pathlib import Path
|
|
|
|
# Use the realizer's own pluralizer so constraints stay aligned with
|
|
# what the realizer will emit under quantifiers. G2 fix.
|
|
from generate.templates import pluralize
|
|
|
|
# (subject, predicate, object) triples per domain.
|
|
# Each triple uses a regular verb for tense/aspect compatibility.
|
|
DOMAINS = {
|
|
"nature": [
|
|
("river", "flows", "valley"),
|
|
("wind", "shapes", "dune"),
|
|
("cloud", "covers", "ridge"),
|
|
],
|
|
"tech": [
|
|
("server", "returns", "packet"),
|
|
("cable", "carries", "signal"),
|
|
("database", "stores", "record"),
|
|
],
|
|
"domestic": [
|
|
("train", "passes", "station"),
|
|
("coffee", "warms", "cup"),
|
|
("lamp", "lights", "room"),
|
|
],
|
|
}
|
|
HOLDOUT_DOMAIN = {
|
|
"chemistry": [
|
|
("molecule", "binds", "enzyme"),
|
|
("atom", "forms", "bond"),
|
|
("reaction", "produces", "compound"),
|
|
],
|
|
}
|
|
|
|
# 13 grammatical constructions, mirroring grammatical_coverage.
|
|
# For each, a builder takes one (subj, pred, obj) and returns a case dict
|
|
# (without the id, which is filled per (construction, domain, i)).
|
|
CONSTRUCTIONS: list[tuple[str, str]] = [
|
|
("C01", "simple_declarative"),
|
|
("C02", "negation"),
|
|
("C03", "conjunction"),
|
|
("C04", "disjunction"),
|
|
("C05", "complement"),
|
|
("C06", "relative"),
|
|
("C07", "universal"),
|
|
("C08", "existential"),
|
|
("C09", "past_tense"),
|
|
("C10", "present_tense"),
|
|
("C11", "future_tense"),
|
|
("C12", "perfective"),
|
|
("C13", "imperfective"),
|
|
]
|
|
|
|
|
|
def _node(node_id: str, subj: str, pred: str, obj: str, **extra) -> dict:
|
|
n = {"node_id": node_id, "subject": subj, "predicate": pred, "obj": obj}
|
|
n.update(extra)
|
|
return n
|
|
|
|
|
|
def build_case(cid: str, code: str, name: str, triple: tuple[str, str, str], aux: tuple[str, str, str] | None = None) -> dict:
|
|
subj, pred, obj = triple
|
|
g_nodes: list[dict]
|
|
g_edges: list[dict] = []
|
|
constraints: dict = {"max_words": 12}
|
|
accept: list[str] | None = None
|
|
|
|
if code == "C01":
|
|
g_nodes = [_node("n1", subj, pred, obj)]
|
|
accept = [f"{subj} {pred} {obj}"]
|
|
constraints["must_contain"] = [subj, pred, obj]
|
|
constraints["word_order"] = [subj, pred, obj]
|
|
elif code == "C02":
|
|
g_nodes = [_node("n1", subj, pred, obj, negated=True)]
|
|
constraints["must_contain"] = [subj, "not", obj]
|
|
constraints["word_order"] = [subj, "not", obj]
|
|
elif code == "C03":
|
|
assert aux is not None
|
|
g_nodes = [_node("n1", subj, pred, obj), _node("n2", *aux)]
|
|
g_edges = [{"source": "n1", "target": "n2", "relation": "conjunction"}]
|
|
constraints["must_contain"] = [subj, "and", aux[0]]
|
|
constraints["word_order"] = [subj, "and", aux[0]]
|
|
constraints["max_words"] = 14
|
|
elif code == "C04":
|
|
assert aux is not None
|
|
g_nodes = [_node("n1", subj, pred, obj), _node("n2", *aux)]
|
|
g_edges = [{"source": "n1", "target": "n2", "relation": "disjunction"}]
|
|
constraints["must_contain"] = [subj, "or", aux[0]]
|
|
constraints["word_order"] = [subj, "or", aux[0]]
|
|
constraints["max_words"] = 14
|
|
elif code == "C05":
|
|
assert aux is not None
|
|
g_nodes = [_node("n1", aux[0], aux[1], aux[2]), _node("n2", subj, pred, obj)]
|
|
g_edges = [{"source": "n1", "target": "n2", "relation": "complement"}]
|
|
constraints["must_contain"] = [aux[0], "that", subj]
|
|
constraints["word_order"] = [aux[0], "that", subj]
|
|
constraints["max_words"] = 14
|
|
elif code == "C06":
|
|
assert aux is not None
|
|
g_nodes = [_node("n1", subj, pred, obj), _node("n2", subj, aux[1], aux[2])]
|
|
g_edges = [{"source": "n1", "target": "n2", "relation": "relative"}]
|
|
# Realizer emits comma-bounded relative clause; accept the
|
|
# punctuated form (the structural rubric is too word-strict to
|
|
# parse commas, so we pin the surface exactly).
|
|
accept = [
|
|
f"{subj}, which {aux[1]} {aux[2]}, {pred} {obj}",
|
|
f"{subj} which {aux[1]} {aux[2]} {pred} {obj}",
|
|
]
|
|
constraints["must_contain"] = [subj, "which", aux[2], obj]
|
|
constraints["max_words"] = 14
|
|
elif code == "C07":
|
|
# Universal quantifier triggers plural subject (G2 fix).
|
|
plural_subj = pluralize(subj)
|
|
g_nodes = [_node("n1", subj, pred, obj, quantifier="all")]
|
|
constraints["must_contain"] = ["all", plural_subj, obj]
|
|
constraints["word_order"] = ["all", plural_subj, obj]
|
|
elif code == "C08":
|
|
plural_subj = pluralize(subj)
|
|
g_nodes = [_node("n1", subj, pred, obj, quantifier="some")]
|
|
constraints["must_contain"] = ["some", plural_subj, obj]
|
|
constraints["word_order"] = ["some", plural_subj, obj]
|
|
elif code == "C09":
|
|
g_nodes = [_node("n1", subj, pred, obj, tense="past")]
|
|
constraints["must_contain"] = [subj, obj]
|
|
constraints["word_order"] = [subj, obj]
|
|
elif code == "C10":
|
|
g_nodes = [_node("n1", subj, pred, obj, tense="present")]
|
|
accept = [f"{subj} {pred} {obj}"]
|
|
constraints["must_contain"] = [subj, pred, obj]
|
|
constraints["word_order"] = [subj, pred, obj]
|
|
elif code == "C11":
|
|
g_nodes = [_node("n1", subj, pred, obj, tense="future")]
|
|
constraints["must_contain"] = [subj, "will", obj]
|
|
constraints["word_order"] = [subj, "will", obj]
|
|
elif code == "C12":
|
|
g_nodes = [_node("n1", subj, pred, obj, aspect="perfective")]
|
|
constraints["must_contain"] = [subj, "has", obj]
|
|
constraints["word_order"] = [subj, "has", obj]
|
|
elif code == "C13":
|
|
g_nodes = [_node("n1", subj, pred, obj, aspect="imperfective")]
|
|
constraints["must_contain"] = [subj, "is", obj]
|
|
constraints["word_order"] = [subj, "is", obj]
|
|
else:
|
|
raise AssertionError(f"unknown construction {code}")
|
|
|
|
case = {
|
|
"id": cid,
|
|
"construction": code,
|
|
"construction_name": name,
|
|
"proposition_graph": {"nodes": g_nodes, "edges": g_edges},
|
|
"constraints": constraints,
|
|
}
|
|
if accept:
|
|
case["accept_surfaces"] = accept
|
|
return case
|
|
|
|
|
|
def emit_split(domains: dict[str, list[tuple[str, str, str]]], prefix: str, out_path: Path) -> int:
|
|
out_path.parent.mkdir(parents=True, exist_ok=True)
|
|
lines: list[str] = []
|
|
for domain, triples in domains.items():
|
|
for code, name in CONSTRUCTIONS:
|
|
for i, triple in enumerate(triples):
|
|
aux = triples[(i + 1) % len(triples)]
|
|
cid = f"{prefix}_{domain}_{code}_{i+1:02d}"
|
|
case = build_case(cid, code, name, triple, aux=aux)
|
|
lines.append(json.dumps(case))
|
|
out_path.write_text("\n".join(lines) + "\n")
|
|
return len(lines)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
root = Path(__file__).resolve().parent.parent
|
|
n_public = emit_split(DOMAINS, "EFO-PUB", root / "evals" / "english_fluency_ood" / "public" / "v1" / "cases.jsonl")
|
|
n_hold = emit_split(HOLDOUT_DOMAIN, "EFO-HOLD", root / "evals" / "english_fluency_ood" / "holdouts" / "v1" / "cases.jsonl")
|
|
# Tiny dev set: one of each construction from the first domain
|
|
dev_path = root / "evals" / "english_fluency_ood" / "dev" / "cases.jsonl"
|
|
dev_lines: list[str] = []
|
|
triples = DOMAINS["nature"]
|
|
for code, name in CONSTRUCTIONS:
|
|
case = build_case(f"EFO-DEV_{code}", code, name, triples[0], aux=triples[1])
|
|
dev_lines.append(json.dumps(case))
|
|
dev_path.write_text("\n".join(dev_lines) + "\n")
|
|
print(f"public: {n_public} cases, holdouts: {n_hold} cases, dev: {len(dev_lines)} cases")
|