When a model answers a 100,000-token legal or clinical question correctly, we usually cannot tell why. It may have read and combined facts scattered through the document. It may already know the statute or the clinical guideline from pre-training. Or it may have memorized the benchmark itself. This ambiguity matters most when comparing open-weights models with proprietary ones. Open models often look close to parity on static benchmarks and then fall apart on long, demanding inputs. We propose a test generator that separates these explanations. It writes a fresh, fictional-but-realistic rulebook for each test item: a statute, contract, or treatment protocol whose logic is a small program we can execute. It then buries the rulebook and a case file inside a long document made of real legal or clinical text. Half the rulebooks deliberately contradict real-world doctrine or guidelines. A model can only answer those correctly by reading the document. Memory of the domain, or of earlier test releases, actively hurts it.
In plain terms, we turn "does the model reason over long domain documents?" into a controlled experiment with three dials. The first dial is whether the document's rule agrees or disagrees with what the model already knows. The second is how long the document is. The third is whether the question shares words with the relevant passages. Because every answer comes from executing the rule program, scoring needs no LLM judge. Because every item is freshly generated, a leaked test set does not help a model.
Core Claim
The open-versus-proprietary gap on long domain documents is not a uniform loss of ability as documents get longer. We hypothesize that it is concentrated in one corner of the design: long documents, low word overlap between question and evidence, and rules that contradict prior knowledge. In that corner, weaker models fall back on what they remember about the domain instead of what the document says. Existing benchmarks cannot see this, because their rules and facts are mostly the real ones. Our measurable prediction is that the override gap grows with context length faster for open models than for proprietary ones. The override gap is accuracy when the document's rule matches real-world knowledge minus accuracy when it contradicts it. A second claim concerns methodology. A generator that executes rule programs over long realistic text gives contamination resistance of the kind DyVal provides for arithmetic, extended to unstructured professional domains, which the file flags as unsolved.
What Already Exists and How This Differs
Four prior works motivate the gap, and each covers part of it.
DyVal generates reasoning problems on the fly from directed acyclic graphs, meaning dependency graphs with no cycles. It showed that WizardMath-13B and phi-1.5 "scored nearly zero" on its fresh problems despite strong static scores. However, it covers only short formal problems in math, logic, and reachability. We reuse its central idea, executable ground truth that is regenerated on demand, and move it into long legal and clinical prose.
MedOdyssey is the closest domain work. It injects novel or fictional medical facts into contexts of up to 200K tokens to defeat memorization. Its injected facts are fixed retrieval needles scored by string matching, and once published they can be scraped into training data. Our injected objects differ in three ways. They are multi-step rules that must be applied to case facts, not looked up. They are regenerated for each evaluation. They are deliberately set against real guidelines, so prior knowledge becomes a measurable source of error rather than a nuisance.
NoLiMa removes word overlap between question and needle and finds that 11 of 13 models fall below 50% of their short-context baseline by 32K tokens. Its 58 question–needle pairs are static and concern everyday entity associations, not professional rules. 100-LongBench introduces LongScore, which subtracts short-context ability from long-context scores. It observed that adding law and healthcare data hurt Llama 3.2-1B, but it could not tell whether the cause was length or missing domain knowledge. Our factorial design is built to answer exactly that question. We borrow LongScore's normalization and NoLiMa's overlap control as components rather than competing with them.
On the domain side, LegalBench reports that models struggle with rule-conclusion unless the rule is placed in the prompt, which is direct evidence that parametric recall and in-context rule use are separable. Its tasks are short, though. DOLOMITES supplies realistic long-form professional tasks, but it is static and relies on proprietary LLM judges. This is the verification problem that executable rules avoid, at the cost of restricting outputs to structured decisions. LongCodeBench gets executable verification through unit tests, but only for code and only on pre-cutoff repositories.
Research Program
The generator has three layers.
The first layer is a rule program. It is a small graph of conditions, exceptions, thresholds, and defeaters, such as "liability attaches if A and B unless C, where C is overridden by D after 30 days." Clinically, an example is "drug X is contraindicated above creatinine threshold T unless condition E." Each rule program is drawn from a template family seeded from a real doctrine or guideline. For example, LegalBench-style successor liability and rule-application typologies would supply legal templates, and dosing or eligibility logic common in public guidelines would supply clinical ones. Each template has a "consistent" instantiation that matches the real rule and a "counterfactual" instantiation that flips one decisive element. Flippable elements include a threshold, the direction of an exception, or the order of precedence.
The second layer is a case file: generated facts such as dates, parties, and lab values, sampled so that the consistent and counterfactual rules produce different answers.
The third layer is a haystack of real domain text into which the rule clauses and case facts are scattered. Legal haystacks come from public court opinions, for example the ECtHR and SCOTUS texts in LexGLUE. Clinical haystacks come from public clinical narrative text. Scattering is controlled at lengths of 2K, 8K, 32K, 64K, and 128K tokens. We fix the character-to-token budget across tokenizers in the manner of MedOdyssey's identical-context control.
Rule clauses are rendered into statute-like or protocol-like prose by hand-written templates, with LLM paraphrase as an option. The paraphrase is accepted only if an independent parser recovers the same rule program and a domain expert spot-checks a sample. This step is the main engineering risk, because a rendering that silently changes the rule corrupts the ground truth. We will report the expert disagreement rate. For each item we also compute word overlap between the question and the evidence clauses (ROUGE-1, as NoLiMa does) and stratify into high- and low-overlap versions.
Every item is answered three ways: closed-book with no document, with only the gold clauses (about 1K tokens), and with the full haystack. Models must return a structured decision with cited clause identifiers. This lets us separately score the decision, the evidence chain, and format validity, which tracks the JSON failures MedOdyssey reported for open models.
We then fit a logistic model of correctness on the following terms: rule consistency, log length, overlap level, model family (open or proprietary), and their interactions. The coefficient of interest is the three-way interaction of counterfactual rule × length × open-model family.
Baselines
The naive reference point is closed-book accuracy on consistent rules, i.e., what the model gets from domain memory alone. If full-document accuracy on consistent items barely exceeds this, the document is not being used. The second reference is the gold-clauses-only condition. It plays the role of 100-LongBench's short-context base ability, and every long-context score is normalized against it, LongScore-style. Since 100-LongBench is the strongest existing tool for separating length from base ability, we run its normalization on our items rather than only quoting its benchmark. The file reports qualitative LongScore drops for Qwen 2.5-7B and 14B but no reported result found on Lacuna for numerical LongScore values.
The strongest existing measurement baseline is running NoLiMa and a closed-book domain QA test separately and combining them additively. This is the cheap version of our decomposition. We run NoLiMa on the same models with the same decoding settings. As a reference figure, NoLiMa reports GPT-4o at 99.3% at short lengths and 69.7% at 32K tokens, and effective context lengths as low as 1K–2K for some models claiming 128K. Our benchmark beats this baseline if the additive prediction, NoLiMa degradation plus closed-book domain deficit, significantly misestimates per-model accuracy in the counterfactual long cells. It also beats it if the additive prediction ranks open and proprietary models differently from what our joint measurement shows.
The strongest method baseline is retrieval-augmented generation. A BM25 retriever and a dense retriever each select the top 4K tokens, which are given to each model. The retriever budget and chunking are tuned identically for all models on a held-out generator seed. LongCodeBench reports that this kind of retrieval hurt Claude 3.5 Sonnet on LongSWE-Bench, but the file gives no number, so no reported result found on Lacuna for RAG on long domain rule application. Retrieval "wins" if it closes the counterfactual long-context gap for open models to within the 95% confidence interval of their gold-clauses score.
Two ablations isolate the key ingredient. The first removes counterfactual flips, so only consistent rules remain. If the open–proprietary gap at length is unchanged, prior-knowledge override is not the mechanism. The second replaces the domain haystack and domain rule with DyVal-style abstract variables padded with the same haystack. This tests whether the domain framing adds anything over padded symbolic reasoning.
Why not just…?
Why not just combine NoLiMa with closed-book LegalBench scores? This is the most serious threat, because if the effects are additive our joint design is unnecessary. The evidence against additivity is indirect. LegalBench shows that rule-in-prompt and rule-from-memory performance differ, and 100-LongBench could not attribute its domain drop. The decisive test is the additive-baseline comparison above. If the three-way interaction is near zero and the additive model predicts per-cell accuracy well, we will report that the cheaper combination suffices and present the generator mainly as a contamination-resistant replacement for static items.
Why not just use MedOdyssey's novel-fact injection? Injected fictional facts test whether a model can find a new fact, not whether it will apply a new rule that contradicts an old one. They are also fixed once released. We include a matched condition with fictional facts but no rule conflict to measure how much of the gap appears only under conflict.
Why not just retrieve and keep contexts short? Retrieval may genuinely fix the consistent, high-overlap cells. NoLiMa's ROUGE-1 of 0.069 for low-overlap needles suggests that lexical retrievers will miss evidence clauses that share no words with the question, and exceptions and defeaters are typically worded that way. The RAG baseline settles this directly. If dense retrieval recovers low-overlap counterfactual items, that is a useful practical finding, and we will say so.
Why not just keep the test set private or paraphrase it? Private sets cannot be audited, as P⁴Bench argues. DyVal's near-zero results for models that score well on static sets suggest that paraphrase preserves memorizable patterns. Our contamination check below tests resistance directly instead of assuming it.
Proposed Experiments and Decisive Checks
We will evaluate open models (Qwen2.5-7B and 14B Instruct, Llama 3.1, DeepSeek-R1, and LongChat-13B-16K at its supported lengths) and proprietary models (GPT-4o, Gemini 1.5 Pro, Claude 3.5 Sonnet). The two domains are law and clinical protocols, with roughly 500 items per cell across consistent/counterfactual × five lengths × two overlap levels, generated from fresh seeds. Metrics are decision accuracy, evidence-chain F1 on cited clauses, format validity, override gap, LongScore-normalized degradation, and effective context length at NoLiMa's 85% threshold.
The first decisive check is the main hypothesis. The override gap should rise with length significantly faster for open models, meaning a positive three-way interaction with a confidence interval excluding zero. A uniform drop across conditions would falsify it.
The second check tests contamination resistance by deliberately contaminating an open model. We fine-tune Qwen2.5-7B on 2,000 released items and compare it on those items versus freshly seeded items from the same templates. A resistant generator shows a large gain on released items and none on fresh ones. If fresh-item accuracy also rises, the model is learning template regularities rather than instances. We would then report template-level leakage as a limit and test whether holding out entire template families removes it.
The third check is the padded-DyVal ablation. If it ranks models identically to the domain version, the domain layer adds cost without information, and we will narrow the claim accordingly.
The fourth check validates against real practice. On a small expert-written set of genuine long dockets and records, cell-level scores from our generator should predict model rankings better than LegalBench, NoLiMa, or MedOdyssey alone.
References
- DyVal: Dynamic Evaluation of Large Language Models for Reasoning Tasks
- MedOdyssey: A Medical Domain Benchmark for Long Context Evaluation Up to 200K Tokens
- NoLiMa: Long-Context Evaluation Beyond Literal Matching
- 100-LongBench: Are de facto Long-Context Benchmarks Literally Evaluating Long-Context Ability?
- LegalBench: A Collaboratively Built Benchmark for Measuring Legal Reasoning in Large Language Models
- Dolomites: Domain-Specific Long-Form Methodical Tasks
- LongCodeBench: Evaluating Coding LLMs at 1M Context Windows
- $\text{P}^4$Bench: Contamination-Proof, Publicly Verifiable, and Privacy-Preserving LLM Evaluation via Zero-Knowledge Proofs