Skip to content

test: synthetic corpora with matcher-independent ground truth - #1

Open
rikkhill wants to merge 2 commits into
mainfrom
0.2-synthetic-corpora
Open

rikkhill wants to merge 2 commits into
mainfrom
0.2-synthetic-corpora

Conversation

@rikkhill

Copy link
Copy Markdown
Owner

What

Adds a synthetic-corpus generator and the suite that consumes it. Test-only — nothing under python/epigrep/ or src/ references it, so invariant 5 holds and the wheel is unchanged.

Why

The existing tests derive their answer key from epigrep itself: apps/epigrep-eval/tasks.json freezes expectations the matcher computed, and the semantic fixtures, while hand-written, are tiny. Both catch drift; neither catches a semantic regression at volume.

crates/epigrep-py/tests/synth.py goes the other way. A PatternSpec describes a pattern; the generator plants episodes that are matches or near-misses by construction and never calls match() or explain(). Each negative violates exactly one clause at exactly one step, which is directly its expected NearMiss reason, so all four reasons are covered without hand-enumeration.

Two noise regimes:

  • disjoint — background types the pattern can never mention, so ground truth is exact set equality;
  • adversarial — background reusing the pattern's own vocabulary, where ground truth no longer holds and the corpus feeds oracle/compiled parity and metamorphic properties instead.

The answer key has teeth, and that is asserted

Random gaps almost never land on a window's inclusive bound, so the first pass missed a one-unit widening of a three-step window. Planted episodes now sit on the boundaries — first positive at each window's upper bound, window_exceeded negatives missing by exactly 1, predicate values boundary-tight. test_a_single_clause_change_breaks_the_answer_key runs nine one-clause pattern mutations and requires each to break the corpus. A companion test requires adversarial noise to genuinely perturb results, so that regime cannot silently test nothing.

Deliberate v1 restrictions

Each enforced by PatternSpec.validate, with tests asserting the rejection:

  • event types must be distinct across a spec (repeated types make a planted event play two roles and break matcher-independent ground truth, so A -> A shapes are not generable);
  • predicate literals are integers, so satisfying and violating values are always constructible;
  • an unwindowed transition forces one episode per partition, since without a window a start's reach is unbounded.

Equal-timestamp tie-breaking is not covered here; it stays with fixtures 02/03.

Verified locally

Check Result
pytest crates/epigrep-py/tests/ 476 passed, 6 skipped
cargo test 52 + 2 passed
cargo fmt --check, clippy (core + epigrep-py) clean
check_version_sync.py, diff LICENSE pass
mkdocs build --strict pass
apps/ tests 56 passed

🤖 Generated with Claude Code

https://claude.ai/code/session_01CjMbfWJXUgcHTxd4c7BfHM

Rikk Hill and others added 2 commits August 11, 2026 16:18
The existing tests derive their answer key from epigrep itself: the eval
corpus freezes expectations the matcher computed, and the semantic
fixtures, while hand-written, are tiny. Both catch drift; neither can
catch a semantic regression at volume.

Add a generator that goes the other way. A PatternSpec describes a
pattern; the generator plants episodes that are matches or near-misses by
construction and never calls match() or explain(), so the answer key is
independent of the code under test. Each negative violates exactly one
clause at exactly one step, which is directly its expected NearMiss
reason, so all four reasons are covered without hand-enumeration.

Two noise regimes. Disjoint background uses types the pattern can never
mention, giving exact ground truth. Adversarial background reuses the
pattern's own vocabulary, where ground truth no longer holds and the
corpus feeds oracle/compiled parity and metamorphic properties instead.

The answer key is made to have teeth, and this is asserted rather than
assumed: random gaps almost never land on a window's inclusive bound, so
the first pass missed a one-unit widening of a three-step window. Planted
episodes now sit on the boundaries (first positive at each window's upper
bound, window_exceeded negatives missing by exactly 1, predicate values
boundary-tight), and a mutation test requires nine one-clause pattern
changes to each break the corpus. A companion test requires adversarial
noise to genuinely perturb results, so that regime cannot silently test
nothing.

Test-only: nothing under python/epigrep/ or src/ references synth, so
invariant 5 holds and the wheel is unchanged. Three v1 restrictions are
enforced by PatternSpec.validate with tests asserting the rejection --
distinct event types per spec, integer predicate literals, and no shared
partitions for unwindowed specs. Equal-timestamp tie-breaking stays with
fixtures 02/03.

Verified: pytest 476 passed / 6 skipped; cargo test 52+2 passed; fmt and
clippy (core and epigrep-py) clean; check_version_sync and LICENSE diff
pass; mkdocs build --strict passes; apps/ 56 passed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CjMbfWJXUgcHTxd4c7BfHM
Per reference:repo-agent-policy, a repo's stated commands block and its CI
must never disagree. Three did.

- mkdocs build --strict never gated a pull request. docs.yml runs it only
  on pushes to main, behind a paths: filter for docs/ and mkdocs.yml, so a
  PR could break the docs build (or a README snippet) unnoticed. ci.yml now
  owns the gate; docs.yml stays responsible for publishing.

- The Python job installed a hand-listed "maturin pytest pandas" rather
  than the [test] extra declared in pyproject, so polars and pyarrow were
  absent and the parquet CLI test and the polars eventise test skipped
  silently -- a 0.2 shipped feature untested in CI. It now installs the
  built wheel by path with its [test] extra, which keeps epigrep coming
  from dist/ while sourcing test dependencies from pyproject, so the two
  cannot drift apart again.

- The apps/ apparatus tests ran nowhere. They consume the public installed
  API and had no gate stopping them rotting. Gating them does not make
  apparatus part of the package, so invariant 5 is reworded rather than
  weakened: apps/ still may not be imported by python/epigrep/, appear in
  the wheel, or become a dependency.

Also adds .claude/skills/epigrep-slice/, the optional repo-local slice
skill the canon sanctions, encoding the loop executably instead of as
prose an agent may skip -- including the step OB keeps proving necessary:
verify OB's claims against the repo before planning, because it has
repeatedly gone stale about merge and release state. CLAUDE.md's workflow
now also says to open a PR, since CI does not run on a bare branch push.

.gitignore excludes .claude/settings.local.json; the committed skills
directory is deliberate.

Verified: pytest 476 passed / 6 skipped; apps/ 56 passed; mkdocs build
--strict clean; ci.yml parses.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CjMbfWJXUgcHTxd4c7BfHM

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant