Skip to content

DEV-1786: PR #286 review G4 — test hardening (crossing discrimination, vacuous passes, brittle asserts) - #303

Merged
ZmeiGorynych merged 3 commits into
egor/dev-1742-one-doctrine-consolidation-of-sql-generation-dev-1450from
egor/dev-1786-pr-286-review-g4-test-hardening-crossing-discrimination
Aug 12, 2026
Merged

DEV-1786: PR #286 review G4 — test hardening (crossing discrimination, vacuous passes, brittle asserts)#303
ZmeiGorynych merged 3 commits into
egor/dev-1742-one-doctrine-consolidation-of-sql-generation-dev-1450from
egor/dev-1786-pr-286-review-g4-test-hardening-crossing-discrimination

Conversation

@ZmeiGorynych

@ZmeiGorynych ZmeiGorynych commented Aug 12, 2026

Copy link
Copy Markdown
Member

Group 4 of 4 from the CodeRabbit review triage of umbrella PR #286. Pure test-side changes — no production code touched. PRs back into the umbrella branch egor/dev-1742-….

What

All 29 review items addressed — strengthen weak/vacuous tests so they discriminate the behaviour they claim to pin, plus mechanical cleanups (hoist imports, rename stale classes/methods, use shared helpers, close a connection on setup failure).

Per the issue rules, each claimed-vacuous test (items 1, 4, 6, 7, 9, 12) was first demonstrated to pass vacuously (sabotage the asserted condition, watch it still pass), then closed so it now discriminates.

Notable deviations from the literal review items

  • Item 9InKey.values is Tuple[LiteralKey, ...], so a crossing ColumnKey cannot be placed there (the reviewer's suggestion is type-infeasible). Fixed the real vacuity via the InKey column arm instead.
  • Item 15 — the multiple ) AS _src closes are siblings (multiple windowed measures), never nested; CodeRabbit's "nested" rationale is inaccurate. Applied as harmless last-match hardening with a corrected comment.
  • Item 24c — already used ScopeFrame.__new__; no change needed.
  • Item 26 — the "vacuous" framing was wrong (asyncio_mode=auto runs it); still did the sync-def + stale-docstring cleanup.

Design decisions

  • Item 1 (first/last "crossing" tests) — relabeled in place into TestCrossingFirstLastStaysRanked. The reviewer's literal fix (assert the crossed hop in join_chain) is impossible: host-rooted ranked plans always carry join_chain=[]/target_path=(). Only the structural-time-arg case exposes the crossing at plan level (ranking_time_key.path); the other two are pinned at render level by existing DEV-1748 tests (cross-referenced).
  • Item 27 (_forward_only abandon branches) — narrowed the claim: the common forward-abandon IS exercised; the late fallbacks are defensive internal invariants unreachable from a well-formed query.

Codex review

A Codex pass on the diff surfaced two findings, both folded in:

  • tightened the golden-harness path-redaction regex so it spares URLs and compact SQL division (+ a focused unit test);
  • made the except-form guard permit re-raising handlers (the B6 defect is swallowing, not catching).

Validation

  • Full non-integration suite: 11621 passed, 4 skipped, 3 xfailed, 0 failures.
  • ruff check slayer/ tests/: clean.

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability for cross-model joins, filtering, ordering, and ranking scenarios.
    • Corrected handling of hidden ordering fields and grouped joined-column expressions.
    • Improved query routing and rerooting behavior across complex transformations.
    • Made generated error messages more stable by removing machine-specific filesystem paths while preserving useful details.
  • Tests

    • Expanded regression coverage for SQL generation, planner behavior, joins, aggregation, and dialect-specific output.

Pure test-side changes from the CodeRabbit triage of umbrella PR #286: make
weak/vacuous tests discriminate the behaviour they claim to pin, plus mechanical
cleanups (hoist imports, rename stale classes/methods, use shared helpers, close
a connection on setup failure).

Notable deviations from the literal review items:
- Item 9: InKey.values is Tuple[LiteralKey, ...], so a crossing ColumnKey cannot
  go there; the real vacuity is fixed via the InKey column arm instead.
- Item 15: the multiple `) AS _src` closes are siblings (multiple windowed
  measures), never nested; applied as last-match hardening.
- Item 24c already used ScopeFrame.__new__; no change.
- Item 27: narrowed the coverage claim — the defensive _forward_only fallbacks
  are internal invariants unreachable from a well-formed query.

Vacuous passes for items 1/4/6/7/9/12 were demonstrated (sabotage → current
test still passes) before closing. Codex review folded in: tightened the
golden-harness path redaction to spare URLs/compact division (+unit test), and
made the except-form guard permit re-raising handlers.

Full non-integration suite green (11621 passed); ruff clean.
@linear

linear Bot commented Aug 12, 2026

Copy link
Copy Markdown

DEV-1786

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The pull request updates test infrastructure and regression coverage. It improves SQLite cleanup, SQL parsing, exception-path redaction, structural SQL assertions, order-only behavior checks, isolation coverage, and rerooting validation.

Changes

Test coverage and harness updates

Layer / File(s) Summary
Harness and parsing stability
tests/_dev1746_fixtures.py, tests/_engine_helpers.py, tests/_golden_harness.py, tests/test_dev1745_golden_sql.py
SQLite setup now closes connections reliably. Source extraction handles sibling subqueries. Recorded exception messages redact absolute paths.
Structural SQL and dependency assertions
tests/test_dev1745_*.py, tests/test_agg_render_spec.py, tests/test_dev1744_*.py, tests/test_sql_generator.py
Tests use AST and dialect-aware SQL inspection for filters, CTEs, reachability, aggregation output, and rank windows.
Order-only and isolation coverage
tests/test_dev1712_order_only_hidden_slots.py, tests/test_dev1733_order_only_transform_composite.py, tests/test_dev1746_isolation_classifier.py, tests/test_filtered_local_isolation.py
Coverage now verifies resolved joined order-only slots, preserved grouping boundaries, shared crossing-filter fixtures, and ranked crossing-input measures.
Rerooting validation
tests/test_dev1747_*.py
Rerooting tests validate emitted cross-model SQL, scoped monkeypatches, exception-handler structure, type annotations, aggregate grain preservation, and AST return types.

Estimated code review effort: 3 (Moderate) | ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 70.69% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the PR as test hardening and specifies its focus on crossing discrimination, vacuous passes, and brittle assertions.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch egor/dev-1786-pr-286-review-g4-test-hardening-crossing-discrimination

Comment @coderabbitai help to get the list of available commands.

- Sonar S9073 (test_dev1745_golden_sql.py): split the composite path-redaction
  assertion into separate asserts.
- Codex (test_dev1747_reroot_filter_routing.py): the re-raise guard now requires
  a TOP-LEVEL raise in the handler body — a raise buried in a conditional branch
  no longer counts as non-swallowing.
- Codex (_golden_harness.py): broaden the path-redaction regex to also collapse
  single-segment mounts (e.g. /workspace), still sparing URLs and compact SQL
  division; extend the unit test to cover it.
@ZmeiGorynych

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

…ion-dev-1450' of https://github.com/MotleyAI/slayer into egor/dev-1786-pr-286-review-g4-test-hardening-crossing-discrimination

# Conflicts:
#	tests/test_dev1745_reachability.py
@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/test_dev1745_reachability.py (1)

529-532: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Move these imports to the module import block.

The coding guideline requires imports at the top of Python files. Import filter_reachability_for and recompute_filter_reachability with the other module imports.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_dev1745_reachability.py` around lines 529 - 532, Move the
filter_reachability_for and recompute_filter_reachability imports from the local
scope into the module-level import block, keeping their existing usage
unchanged.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/test_dev1745_fragment_joins.py`:
- Around line 159-171: Strengthen both tests in the fragment-join test class by
asserting the complete entered-fragment result equals ["regions.weight"], while
retaining the existing assertions that the marker values are absent. Update the
assertions in the window/90d and fmt/%Y-%m test cases; do not alter
_entered_fragments behavior.

---

Nitpick comments:
In `@tests/test_dev1745_reachability.py`:
- Around line 529-532: Move the filter_reachability_for and
recompute_filter_reachability imports from the local scope into the module-level
import block, keeping their existing usage unchanged.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ef6da37f-6764-4ec5-b074-768939d836a6

📥 Commits

Reviewing files that changed from the base of the PR and between 9022aa7 and 4b09694.

📒 Files selected for processing (22)
  • tests/_dev1746_fixtures.py
  • tests/_engine_helpers.py
  • tests/_golden_harness.py
  • tests/test_agg_render_spec.py
  • tests/test_cross_model_rename_dev1448.py
  • tests/test_dev1712_order_only_hidden_slots.py
  • tests/test_dev1733_order_only_transform_composite.py
  • tests/test_dev1744_naming_allocator.py
  • tests/test_dev1744_value_expr.py
  • tests/test_dev1745_fragment_joins.py
  • tests/test_dev1745_golden_sql.py
  • tests/test_dev1745_mode_a_door.py
  • tests/test_dev1745_plan_time_routing.py
  • tests/test_dev1745_reachability.py
  • tests/test_dev1746_isolation_classifier.py
  • tests/test_dev1747_golden_sql.py
  • tests/test_dev1747_local_with_chain.py
  • tests/test_dev1747_prebound_planner.py
  • tests/test_dev1747_reroot_filter_routing.py
  • tests/test_dev1747_reroot_visitor.py
  • tests/test_filtered_local_isolation.py
  • tests/test_sql_generator.py

Comment on lines +159 to +171
entered = self._entered_fragments(
kwargs=(("window", "90d"),), agg="wscaled_sum",
)
assert "90d" not in entered, entered

def test_marker_that_is_not_parseable_sql_is_still_skipped(self) -> None:
"""The failure this guards: a marker whose text sqlglot rejects. It
must never reach the door, which raises."""
assert self._entered_fragments(kwargs=(("fmt", "%Y-%m"),)) == []
"""The failure this guards: a marker whose text sqlglot rejects. Under a
TEMPLATED aggregation the substitution filter is what skips it, so it
never reaches the door (which would raise)."""
entered = self._entered_fragments(
kwargs=(("fmt", "%Y-%m"),), agg="wscaled_sum",
)
assert "%Y-%m" not in entered, entered

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert that the default fragment is still scanned.

Both tests only assert that the marker value is absent. A regression that skips all fragment scanning when any marker exists will pass both tests. Assert entered == ["regions.weight"] in each case.

Proposed fix
         entered = self._entered_fragments(
             kwargs=(("window", "90d"),), agg="wscaled_sum",
         )
-        assert "90d" not in entered, entered
+        assert entered == ["regions.weight"], entered
...
         entered = self._entered_fragments(
             kwargs=(("fmt", "%Y-%m"),), agg="wscaled_sum",
         )
-        assert "%Y-%m" not in entered, entered
+        assert entered == ["regions.weight"], entered
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
entered = self._entered_fragments(
kwargs=(("window", "90d"),), agg="wscaled_sum",
)
assert "90d" not in entered, entered
def test_marker_that_is_not_parseable_sql_is_still_skipped(self) -> None:
"""The failure this guards: a marker whose text sqlglot rejects. It
must never reach the door, which raises."""
assert self._entered_fragments(kwargs=(("fmt", "%Y-%m"),)) == []
"""The failure this guards: a marker whose text sqlglot rejects. Under a
TEMPLATED aggregation the substitution filter is what skips it, so it
never reaches the door (which would raise)."""
entered = self._entered_fragments(
kwargs=(("fmt", "%Y-%m"),), agg="wscaled_sum",
)
assert "%Y-%m" not in entered, entered
entered = self._entered_fragments(
kwargs=(("window", "90d"),), agg="wscaled_sum",
)
assert entered == ["regions.weight"], entered
def test_marker_that_is_not_parseable_sql_is_still_skipped(self) -> None:
"""The failure this guards: a marker whose text sqlglot rejects. Under a
TEMPLATED aggregation the substitution filter is what skips it, so it
never reaches the door (which would raise)."""
entered = self._entered_fragments(
kwargs=(("fmt", "%Y-%m"),), agg="wscaled_sum",
)
assert entered == ["regions.weight"], entered
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_dev1745_fragment_joins.py` around lines 159 - 171, Strengthen both
tests in the fragment-join test class by asserting the complete entered-fragment
result equals ["regions.weight"], while retaining the existing assertions that
the marker values are absent. Update the assertions in the window/90d and
fmt/%Y-%m test cases; do not alter _entered_fragments behavior.

@ZmeiGorynych
ZmeiGorynych merged commit ff2654c into egor/dev-1742-one-doctrine-consolidation-of-sql-generation-dev-1450 Aug 12, 2026
4 checks passed
ZmeiGorynych added a commit that referenced this pull request Aug 12, 2026
Siblings G1 (#300), G3 (#301), G4 (#303) landed on the umbrella. One conflict
in slayer/engine/isolation.py: kept G1's DEV-1783 union body + precise return
type for _crossing_input_paths, applied this branch's typed `bundle`
(ResolvedSourceBundle) over G1's `Any`, and reconciled the typing import
(TYPE_CHECKING + List, dropping the now-unused Any). Full non-integration suite
green (11645 passed).
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