Skip to content

refactor(gfql/cypher): consume WHERE directly from MatchClause (remove flatten seam)#1693

Merged
lmeyerov merged 1 commit into
masterfrom
dev/gfql-cypher-flatten-seam
Jul 6, 2026
Merged

refactor(gfql/cypher): consume WHERE directly from MatchClause (remove flatten seam)#1693
lmeyerov merged 1 commit into
masterfrom
dev/gfql-cypher-flatten-seam

Conversation

@lmeyerov

@lmeyerov lmeyerov commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Closes #1687. Follow-up cleanup to the LALR parser (#1682).

Context

The grammar bundles a trailing WHERE onto its MATCH clause (that's what made the WITH..WHERE attachment unambiguous). To keep the Earley→LALR switch byte-identical, the transformer took a shortcut: it split MatchClause.where back out into a synthetic standalone WhereClause item and let the pre-existing clause-assembler re-attach it — so the gnarliest ~230-line method ran untouched. #1682 flagged that seam as a scoped follow-up.

Change

The assembler now consumes MatchClause.where directly:

  • primary MATCH keeps its WHERE on the clause (and it becomes the query's top-level where, last-clause-wins so MATCH … WHERE … OPTIONAL MATCH … WHERE … scopes each predicate) — the grammar already set it, so this is a pure deletion of the split-then-reattach round-trip;
  • post-WITH re-entry MATCH's WHERE moves into reentry_wheres with the clause carrying none (the one case that genuinely needs a split).

The now-unreachable standalone-WhereClause branches in both query_body and graph_constructor are removed (the grammar can't emit a standalone WHERE item). Net −23 lines.

Pure refactor — no behavior change

  • Old-vs-new production AST differential over a 1,989-query repo corpus (every WHERE / reentry-MATCH / graph-constructor shape): 1989/1989 byte-identical, 0 AST diffs, 0 language diffs.
  • Grammar invariants (zero conflicts / strict=True / semantic-ambiguity-zero / rule-coverage) + full-repo LALR≡Earley differential: pass.
  • Full cypher suite on dgx-spark: 1,737 passed / 0 failed.
  • mypy clean.

Base

Stacked on test/gfql-viz-pipeline-acceptance (the tip of the #1675#1681 grammar stack) rather than master, so it works against the final grammar (post-EXISTS/searchAny) and rebases along with the stack. Confirmed the zero-conflict invariants still hold on the tip after those grammar additions.

🤖 Generated with Claude Code

https://claude.ai/code/session_01W5vkD2ZCyv3bmecBYoYYQy

@lmeyerov lmeyerov force-pushed the test/gfql-viz-pipeline-acceptance branch from 87b94da to db96812 Compare July 5, 2026 22:28
@lmeyerov lmeyerov force-pushed the dev/gfql-cypher-flatten-seam branch from 0c1ca54 to 3b9087c Compare July 5, 2026 22:32
@lmeyerov lmeyerov force-pushed the test/gfql-viz-pipeline-acceptance branch from db96812 to 5b692fe Compare July 5, 2026 22:39
@lmeyerov lmeyerov force-pushed the dev/gfql-cypher-flatten-seam branch from 3b9087c to 642c6ea Compare July 5, 2026 22:49
@lmeyerov lmeyerov force-pushed the test/gfql-viz-pipeline-acceptance branch from 47a793e to a1c0d28 Compare July 5, 2026 23:04
@lmeyerov lmeyerov force-pushed the dev/gfql-cypher-flatten-seam branch from 642c6ea to 79c922d Compare July 5, 2026 23:04
@lmeyerov lmeyerov force-pushed the test/gfql-viz-pipeline-acceptance branch from a1c0d28 to 151e9c3 Compare July 5, 2026 23:16
@lmeyerov lmeyerov force-pushed the dev/gfql-cypher-flatten-seam branch from 79c922d to 2e17158 Compare July 5, 2026 23:16
@lmeyerov lmeyerov changed the base branch from test/gfql-viz-pipeline-acceptance to master July 5, 2026 23:59
…e flatten seam)

The grammar bundles a trailing WHERE onto its MATCH clause. The transformer
previously split it back out into a synthetic standalone WhereClause item and
let the legacy clause-sequence assembler re-attach it — a temporary seam that
kept the Earley→LALR switch (#1682) byte-identical without touching the
gnarliest transformer method.

Now the assembler consumes MatchClause.where directly:
- primary MATCH keeps its WHERE on the clause (and it becomes the query's
  top-level `where`, last-clause-wins for per-clause scoping) — the grammar
  already set it, so this is a pure deletion of the split/re-attach round-trip;
- a post-WITH re-entry MATCH's WHERE moves into `reentry_wheres` with the
  clause carrying none (the one case that still needs a split).
The now-unreachable standalone-WhereClause branches in both query_body and
graph_constructor are removed. Net −23 lines.

Pure internal refactor, NO behavior change (closes #1687). Verified:
- old-vs-new production AST differential over a 1,989-query repo corpus:
  1989/1989 byte-identical, 0 AST diffs, 0 language diffs;
- grammar invariants (zero conflicts / strict / semantic-ambiguity-zero) +
  full-repo LALR≡Earley differential pass;
- full cypher suite on dgx-spark: 1737 passed / 0 failed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lmeyerov lmeyerov force-pushed the dev/gfql-cypher-flatten-seam branch from 2e17158 to d8b2bbf Compare July 6, 2026 00:03
@lmeyerov lmeyerov changed the base branch from master to test/gfql-viz-pipeline-acceptance July 6, 2026 00:04
Base automatically changed from test/gfql-viz-pipeline-acceptance to master July 6, 2026 00:23
@lmeyerov

lmeyerov commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

red b/c unrelated EXISTS work

@lmeyerov lmeyerov merged commit 16e8053 into master Jul 6, 2026
134 of 135 checks passed
@lmeyerov lmeyerov deleted the dev/gfql-cypher-flatten-seam branch July 6, 2026 00:33
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.

GFQL Cypher parser: remove the WHERE flatten seam (assembler should consume MatchClause.where directly)

1 participant