Skip to content

Refactor #1295: extract bounded reentry glue from lowering.py - #1299

Merged
lmeyerov merged 1 commit into
masterfrom
1295-extract-reentry-glue
May 5, 2026
Merged

lmeyerov merged 1 commit into
masterfrom
1295-extract-reentry-glue

Conversation

@lmeyerov

@lmeyerov lmeyerov commented May 5, 2026

Copy link
Copy Markdown
Contributor

Summary

GFQL monolith shrinkdown S2 (#1260): extract bounded-reentry helpers from cypher/lowering.py into a focused cypher/reentry/ subpackage.

  • Moves 17 reentry helpers (16 public + carry-internal _literal_limit_value, ~470 LOC) into naming.py / scope.py / carry.py / rewrite.py.
  • 16 public names re-exported from cypher.lowering so existing imports keep working unchanged (gfql_unified.py:35, tests/test_gfql.py:8).
  • Lazy from graphistry.compute.gfql.cypher import lowering as _lowering inside function bodies for the few lowering helpers still needed (_unsupported, _unsupported_at_span, _render_expr_node, _rebuild_expr_node, _rewrite_expr_identifiers, _rewrite_where_clause_and_resync, _first_pattern_node_alias, _parse_row_expr). Avoids circular imports at module load.
  • carry.py declares ResultProjectionPlan as a TYPE_CHECKING-only forward-string back-edge to lowering.

lowering.py LOC: ~10,192 (pre-#1297) → 9,659 (post-#1297 + this PR).

Out of scope (per #1295/#1260 S2 framing + #1294/#1297 guardrail)

  • _compile_bounded_reentry_query and _map_terminal_reentry_query stay in lowering.py. These are Refactor #1294: retire dual-contract reentry extras path #1297 hot zones; deferred to a follow-on monolith-shrinkdown slice. Diff verified to leave both untouched.
  • No behavior change. No public API change. No new tests (parity proof = existing tests still pass).

Validation

  • pytest -q tests/compute/gfql/cypher/ tests/compute/test_gfql.py: 1235 passed, 92 skipped, 15 xfailed, 0 failed
  • ./bin/ruff.sh graphistry/compute/gfql/cypher/: clean
  • ./bin/typecheck.sh graphistry/compute/gfql/: 73 source files clean
  • All 16 public re-exports resolve via from graphistry.compute.gfql.cypher.lowering import ...

Multi-wave review

agents/skills/review/SKILL.md flow: 3 parallel reviewer agents (correctness/symbol-parity, architecture/conventions, testing) in Wave 1; solo amplification in Wave 2. Both waves non-significant-advance (0 BLOCKER / 0 IMPORTANT). 6 cosmetic SUGGESTIONs all about helper-count phrasing in CHANGELOG, addressed in this PR.

Refs

Test plan

  • Local: pytest tests/compute/gfql/cypher/ tests/compute/test_gfql.py
  • Local: ./bin/ruff.sh + ./bin/typecheck.sh
  • CI: full test matrix on PR

🤖 Generated with Claude Code

Moves 16 reentry helpers (~470 LOC) out of cypher/lowering.py into a focused
cypher/reentry/ subpackage:
- naming.py — hidden-column / carry-name conventions (4 helpers)
- scope.py  — alias-scope traversal for hidden reentry refs (2 helpers)
- carry.py  — prefix carry-column / order helpers (4 helpers)
- rewrite.py — AST/query rewriters for reentry expressions (7 helpers)

All names are re-exported from cypher/lowering.py so existing callers keep
working unchanged. The moved modules import lowering lazily inside function
bodies for the few helpers (_unsupported, _render_expr_node,
_rewrite_where_clause_and_resync, _first_pattern_node_alias, etc.) they
still need from lowering, avoiding circular imports at module load.

lowering.py: 10192 → 9684 LOC (-508).

The orchestrator (_compile_bounded_reentry_query) and
_map_terminal_reentry_query intentionally stay in lowering.py for this slice
— they share heavy edit surface with the sibling #1294 dual-contract
retirement (PR #1297). A follow-on slice can move them once #1297 lands.

Refs: #1260 S2

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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