core/evals/grammar_roundtrip/contract.md
Shay 997a6eb043 fix(generate): plural-subject agreement, 26/26 (Phase 3)
_inflect_predicate applied base_form — a SINGLE-VERB function — to whole
humanized predicate phrases, stripping the final word's last character
class, and its plural branch never consulted `copular`. Nine of the 26 seed
predicates came out wrong and every multi-word one did:

  is defined as         -> "is defined a"     want "are defined as"
  has the following ... -> "...step"          want "have the following steps"
  belongs to            -> "belongs to"       want "belong to"
  causes                -> "caus"             want "cause"

Root causes, both single-point as §1.4 predicted:

1. morphology.agree_plural_phrase inflects the HEAD (the finite verb is the
   first token of every humanized predicate) and carries the rest through.
   base_form stays single-verb and is PINNED as still wrong on a phrase, so
   nobody "fixes" the symptom in the wrong place.
2. The plural branch now agrees the phrase. The plural NEGATED branch had the
   same defect ("do not is defined a") and is fixed with it: a plural copula
   takes a bare "not", everything else takes do-support.

Two further defects found while writing the eval cases, both fixed here:

  base_form("causes") -> "caus". The -es sibilant rule fired on a stem
  ending in a single "s"; it must require a doubled "ss" ("passes"->"pass"),
  because a single "s" is nearly always a stem ending in "e" that took a
  plain -s ("causes"->"cause").

  pluralize("proof") -> "prooves". f/fe -> ves is NOT productive in English
  (proof->proofs, chief->chiefs, roof->roofs); it is a closed set. Now
  derived as lexicon.VES_PLURAL_SINGULARS from the ves-rows of
  IRREGULAR_SINGULARS, so the rule cannot claim a word the table does not
  know. Phase 2B had put pluralize on the SERVING path, so this one was live
  — and the surface-hashing pin from #133 confirms no served surface moved,
  which is that guard's first real use.

New construction C14 quantified_copular, 13 cases: the combination that was
broken was the one never tested. Measured before: 152 corpus cases carry a
quantifier and ZERO combine it with a copular predicate.

MY FIRST DRAFT OF THOSE CASES COULD NOT FAIL. must_contain/word_order listed
quantifier, subject and object but NOT THE VERB, so "all molecules is
defined a compound" passed and reverting the fix left 47/47 green. Rewritten
with the agreed verb in both constraints plus reject_surfaces carrying the
ACTUAL pre-fix output, computed by running the reverted code rather than
guessed. Mutation now:

  baseline                      13/13 C14
  revert phrase-head agreement   4/13
  revert -es stem rule          12/13
  revert closed ves set         11/13

The 4 survivors of the first mutation are the mass-noun controls, which is
correct — "all evidence is grounded in truth" must NOT pluralize.

Same lesson as the lane pins in #133: a pin that cannot fail guards nothing,
and the only way to know is to break the thing on purpose.

grammar_roundtrip's graph corpus is harvested from the committed case files,
so it grew 280 -> 293. Updated exactly rather than loosened to an inequality:
a corpus that grows or shrinks should require a deliberate edit.

[Verification]: in-worktree on CPython 3.12.13, uv sync --locked —
agreement 26/26 (from 17/26); english_fluency_ood 117/117 + 39/39 + dev
13/13 unchanged; grammatical_coverage v1 49/49; smoke 621 unchanged;
deductive 405; scripts/verify_lane_shas.py 11/11, no pin edited.
2026-07-27 10:11:22 -07:00

6.2 KiB

Grammar Round-Trip Eval Lane — Contract

Lane: grammar_roundtrip Version: v1 Created: 2026-07-26 Plan: docs/plans/grammar-unification-2026-07-26.md (Phase 1)

What this lane measures

Whether CORE can read what it writes and write what it reads — and, critically, whether it refuses word salad.

Why it exists

evals/deterministic_fluency reports 1.00 on all six of its predicates and still passes every one of these:

candidate passes deterministic_fluency?
"banana does the." yes
"wet ground rains the is." yes
"is is is is." yes

It checks terminal punctuation, presence of a verb-shaped token, and two anti-shape regexes. It cannot distinguish English from word salad, so its 100% carries no information about fluency.

Heuristic predicates will always have that failure mode, because grammaticality cannot be measured without a grammar. This lane therefore measures agreement between the two halves of CORE that already encode grammar — the reader and the writer — and requires the measurement to fail on salad. Round-trip is falsifiable with no judge, no embedding, and no gold aesthetic.

The two directions

direction pipeline what a failure means
G-round-trip graph → realize_target → surface → comprehend → graph CORE cannot read its own writing
S-round-trip surface → comprehend → graph → categorical renderer → surface CORE cannot reproduce what it just understood

Both are reported because they fail for different reasons and have different remedies.

Metrics

metric definition
g_write_rate fraction of graph cases the writer produced any surface for
g_read_rate fraction of written surfaces the reader comprehended
g_args_rate fraction of expected propositions whose argument pair was recovered
g_predicates_rate fraction whose predicate name was recovered on the same arguments
g_exact_rate fraction recovered exactly (predicate + arguments + polarity)
s_read_rate fraction of positive surfaces comprehended
s_renderable_rate fraction whose projection the categorical renderer can express at all
s_surface_match_rate fraction that render back to the input surface
reject_rate fraction of the negative corpus refused or reduced to zero propositions

g_args_rate and g_predicates_rate are reported separately on purpose. High argument agreement with low predicate agreement means the grammars align and only the vocabulary is split — a materially different remedy from both being low. Collapsing them into one boolean would hide the distinction that decides this arc's direction (plan §6).

Corpora

corpus source size
positive graphs committed english_fluency_ood + grammatical_coverage case files 293
positive surfaces in-module, each verified comprehensible by probe 8
negative surfaces hand-authored salad + deterministic token shuffles of the positives 16

The shuffles are load-bearing: they are lexically identical to positive cases — same vocabulary, same length, order destroyed. A lane that rejects hand-authored salad but accepts the shuffles is doing vocabulary checking, not grammar checking. Shuffling uses a fixed rotation rather than a PRNG so reject_rate is byte-reproducible.

Thresholds

metric v1 requirement rationale
reject_rate 1.00, always the guarantee; regression is a hard failure
g_read_rate recorded baseline, revised upward only currently a measured defect
s_surface_match_rate recorded baseline, revised upward only currently a measured defect

v1 baseline — measured on main @ 9696443a

graph_cases              293
g_write_rate             1.000
g_read_rate              0.000     <-- CORE reads 0% of what it writes
g_propositions_expected  370
g_args_rate              0.000
g_predicates_rate        0.000
g_exact_rate             0.000

surface_cases              8
s_read_rate              1.000
s_renderable_rate        0.625
s_surface_match_rate     0.000     <-- nothing renders back to its input

negative_cases            16
reject_rate              1.000     <-- the guarantee holds

Two of these are pins on known defects, not goals. They are expected to be revised upward by plan Phases 2B and 5, and must never be revised downward to accommodate a regression.

s_renderable_rate = 0.625 is not a defect: 3 of the 8 positive surfaces project to member / less predicates, which have no all X are Y categorical surface at all. Those are reported as unrenderable rather than as match failures, because "cannot write this" and "wrote this wrongly" need different fixes.

What this lane does NOT prove

Round-trip is necessary, not sufficient for fluency. It measures mutual intelligibility — both halves agreeing about a surface. Two halves can agree on an impoverished construction: english_fluency_ood accepts "river flows valley" as a correct surface, and round-trip would be perfectly happy with it.

So a high round-trip rate licenses "CORE means what it says", never "CORE writes well". The negative corpus is what prevents the first failure mode. Nothing in this lane prevents the second, and no metric here should ever be cited as evidence of prose quality.

Mutation guarantees

Every guarantee is paired with a test proving it can break (tests/test_grammar_roundtrip.py):

  • test_reject_rate_goes_red_when_the_reader_accepts_everything — an accept-everything reader must drive reject_rate to 0.0. Without this, reject_rate == 1.0 would be unfalsifiable, which is precisely the defect that makes the existing fluency lane decoration.
  • test_shuffled_negatives_reuse_positive_vocabulary — closes the vocabulary-checking escape hatch.
  • test_positive_surfaces_are_all_inside_the_reader_envelope — a refused positive would silently measure reader coverage instead of round-trip.
  • test_quantifier_map_matches_reader — the lane keeps a deliberate local copy of the reader's quantifier map so it never becomes a consumer of the thing it measures; this test fails loudly if the reader's map changes.