Skip to content

#249 — accept double-quoted ref()/source() in given-input leaf extraction - #272

Merged
cmbays merged 1 commit into
mainfrom
domain-249-double-quote-leaf-extraction
Jun 12, 2026
Merged

cmbays merged 1 commit into
mainfrom
domain-249-double-quote-leaf-extraction

Conversation

@cmbays

@cmbays cmbays commented Jun 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #249

src/domain/checks.rs given_input_leaf extracted the leaf relation with rfind('\'') — single-quote only. A double-quoted given input (ref("x"), which dbt accepts and both engines ship verbatim on the manifest wire, #245) lost its leaf binding entirely. The RED test showed the real blast radius is worse than the issue's stated Unknown degradation: in union.arm-coverage a fed arm read as provably unfed and produced a false UNCOVERED nag (Uncovered vs Covered on otherwise-identical twins). The second consumer, side_rows (the join.left-null-propagation / join.anti-join family), mocked the side as an empty table the same way.

The fix

The right-to-left scan now accepts either quote style under the same matching-quote rule as strip_matching_quotes (PR #248): the closing quote's character determines the style, the opener must be the same character, and mixed or unbalanced pairs fail open to None. Both checks.rs consumers are fixed through the one shared helper.

On the issue's Discovery question (helper placement): kept as a domain-local implementation rather than promoting strip_matching_quotes inward — the domain scan is deliberately different machinery (right-to-left over the whole call text, tolerating trailing non-string kwargs like ref('orders', v=2) — now pinned by test), while the render-side helper strips one pre-isolated argument. Sharing would have forced a render-parser refactor well beyond this slice.

TDD

  • RED: union_double_quoted_given_classifies_like_its_single_quoted_twin (detector level — failed with Uncovered vs Covered { by: [...] }) and given_input_leaf_extracts_double_quoted_arguments (helper level).
  • Pins kept/added: single-quote family unchanged, per-argument mixed styles for source("a", 'b') (each arg is its own string literal — engine-valid, the #245 — accept double-quoted ref()/source() given inputs in Rust parsers #248 contract), versioned-ref kwarg tolerance, and the negative family — ref("x') / ref('x") mixed pairs and unbalanced quotes all stay None (matching the strip_matching_quotes contract), this and non-call shapes stay None.

Audit — other single-quote-only assumptions in the same family

Greped src/domain/ for quote handling around ref(/source( and string-literal stripping:

  • src/domain/checks.rs given_input_leaf — the only remaining in-scope site; fixed here (both call sites: arm_coverage_for_test L1049, side_rows L1449).
  • src/domain/cell_diff.rs unquote — already dual-quote with matching-pair semantics (pinned by unquote_strips_only_a_matching_surrounding_pair). No change.
  • src/domain/unit_test_yaml.rs parse_yaml_scalar — already handles both YAML quote styles incl. escapes. No change.
  • src/domain/unit_test_table.rs — single-quote logic there is SQL string-literal parsing (csv/sql fixture rows), where ' is the string delimiter and " is an identifier quote by SQL semantics. Correct as-is; out of this family.
  • src/domain/check_config.rs parse_pragma — double-quote-only by its own documented grammar (-- cute-dbt: ignore(id, "reason")), not a dbt wire shape. Out of scope.
  • refs_display / suggested_given_sketch render ref('…') with single quotes — output formatting, not parsing. Unchanged.

JS twin (givenOwnerLabel) was fixed in #240/PR #244; render-side Rust parsers in #245/PR #248.

Dogfood (paired fixture change — the showcase rule)

No committed fixture carried a double-quoted given, so the fix would have been invisible in artifacts. Splice: both playground mart_dq_summary tests' stg_synthea__medications givens flipped to ref("stg_synthea__medications") in playground-current.json and playground-baseline.json (identical on both sides, so scope/changed classification is untouched) and the paired source YAML (same-revision contract; 1:1 in-place line replacements at lines 1392/1433, both above the pr-diff showcase's @@ -1446 hunks — line numbers unshifted). The sibling encounters givens stay single-quoted, so the goldens show both styles side by side.

Load-bearing by construction: both feeders of the medications arm are now double-quoted, so pre-fix code renders union[combined_metrics] as a false uncovered; the committed goldens pin covered. The existing playground_union_with_both_arms_fed_is_covered_with_attribution integration test and the playground_union_arm_findings insta snapshot now also guard the fix on real fixture data.

Goldens (all 5 regenerated per the CI matrix)

  • Changed: examples/playground-report.html, examples/diff-showcase-report.html, examples/explore/tests.html — delta is exclusively the quote flip (YAML drawer text + payload input fields, bound_to_node still populated, union[combined_metrics] stays covered).
  • Byte-identical: examples/jaffle-shop-report.html, examples/explore/dag.html (empty git diff --text after regeneration).
  • tests/fixtures/MANIFEST.toml: SHA-256s recomputed for the three changed fixtures + provenance descriptions extended with the domain: given_input_leaf single-quote-only leaf extraction — double-quoted ref() degrades arm-coverage to Unknown #249 hand-surgery note.

Cross-regen protocol: this PR touches goldens — if another concurrently-merging PR also regenerates examples/, the second-to-merge must regenerate over the merged tree.

Also: the two BDD step regexes' input capture widened from "([^"]+)" to "(.+)" so a feature line can name a double-quoted input string (trailing anchors keep the capture unambiguous; single-quoted inputs unaffected).

Gates (run directly, not via lefthook)

  • cargo fmt --check — clean
  • cargo clippy --all-targets --locked -- -D warnings — exit 0
  • cargo nextest run — 1276 passed
  • cargo test --test bdd — 163 scenarios / 1044 steps passed
  • cargo test --test headless_zero_egress --locked -- --ignored — 10 passed; cargo test --test headless_toggle --locked -- --ignored — 71 passed
  • RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --locked — exit 0
  • cargo deny check — exit 0

Versioning: fix → patch. No breaking change.

🤖 Generated with Claude Code


Open in Stage

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced parsing of dbt ref() and source() calls to support both single and double quote formats.
    • Improved robustness in handling edge cases, including trailing non-string parameters.
  • Tests

    • Expanded test coverage to validate both single and double-quoted input formats.
    • Added assertions for quote-style variations in unit test scenarios.

…t leaf extraction

given_input_leaf scanned for single-quoted arguments only
(rfind('\'')), so a double-quoted given input — ref("x"), which dbt
accepts and both engines ship verbatim on the manifest wire
(cute-dbt#245) — lost its leaf binding entirely. In the
union.arm-coverage check a fed arm then read as provably unfed and
degraded to a FALSE UNCOVERED nag (worse than the issue's stated
Unknown); the join checks' side_rows consumer mocked the side empty the
same way.

- the right-to-left scan now accepts either quote style under the
  matching-quote rule (open/close must be the SAME character; mixed or
  unbalanced pairs stay None, fail-open) — the domain twin of the
  renderer's strip_matching_quotes contract from PR #248, kept local
  because domain never imports adapters and the scan deliberately
  tolerates trailing non-string kwargs (ref('orders', v=2))
- TDD: leaf-extraction test family (single-quote pins stay, double-
  quote accepts, per-argument mixed styles for source(), mixed/
  unbalanced-quote None pins) + a detector-level twin pinning that a
  double-quoted given classifies arm-coverage identically to its
  single-quoted twin (RED showed Uncovered vs Covered)
- dogfood (the paired-fixture rule): both playground mart_dq_summary
  tests' stg_synthea__medications givens flipped to ref("…") in
  current+baseline manifests AND the paired source YAML (same-revision
  contract; 1:1 in-place line edits keep the pr-diff showcase hunk
  numbers unshifted), so the committed goldens prove
  union[combined_metrics] stays COVERED through a double-quoted given
- goldens regenerated: playground / diff-showcase / explore tests.html
  carry the quote flip (bound_to_node intact in the payload);
  jaffle-shop + explore dag.html byte-identical
- BDD steps' input capture widened to greedy (.+) so feature lines can
  carry a double-quoted input string; MANIFEST.toml SHAs + provenance
  notes updated

Closes #249

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 12, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR extends dbt given-input parsing to accept double-quoted ref(...) and source(...) arguments alongside single quotes, enforcing matching quote pairs. Core parsing logic updated in src/domain/checks.rs, Cucumber step regexes adapted to handle embedded quotes, feature documentation and assertions updated, test fixture data quote-styles flipped, and fixture metadata hashes/descriptions refreshed.

Changes

Quote-style preservation for dbt ref/source givens

Layer / File(s) Summary
Core given_input_leaf parsing logic
src/domain/checks.rs
Parsing logic extended to extract the last string literal argument using right-to-left scan, accept both single and double quotes (matching-pair enforcement), and tolerate trailing non-string kwargs. Documentation comments updated accordingly.
Unit tests for given_input_leaf quote handling
src/domain/checks.rs
Comprehensive test suite validates single/double-quoted ref(...)/source(...) inputs, case-insensitive keywords, lowercased leaf names, rejection of mixed/unbalanced quotes and non-call shapes, and union-arm coverage regression confirming double-quoted inputs produce identical verdicts as single-quoted variants.
Cucumber step regex updates for embedded quotes
tests/steps/unit_test_format_coverage.rs
Step regexes for given_fixture_shape and given_fixture_tabulation switched from quote-excluding capture to greedy capture (.+) to match inputs containing embedded double quotes like ref("..."), while remaining anchored to surrounding format/verdict tokens.
Feature documentation and scenario assertions
features/unit_test_format_coverage.feature
Documentation note added specifying stg_synthea__medications uses double-quoted ref("...") while encounters sibling remains single-quoted. CSV and SQL scenario steps updated to assert fixture inputs and shape expectations using double-quoted form.
Test fixture quote-style updates
tests/fixtures/playground-source/models/marts/analytics/_analytics__models.yml
Two dbt unit test given blocks switch ref('stg_synthea__medications') quoting from single to double quotes without altering model names or test expectations.
Fixture metadata and provenance updates
tests/fixtures/MANIFEST.toml
SHA256 hashes updated for playground-baseline.json, playground-current.json, and _analytics__models.yml. Descriptions expanded with cute-dbt#249 quote-style surgery documentation including union-arm coverage equivalence and YAML hunk stability notes.

Possibly related issues

Possibly related PRs

  • breezy-bays-labs/cute-dbt#248: Adjusts parsing of dbt given inputs in src/adapters/render.rs (parse_ref_name/parse_source_ref) to correctly handle double-quoted string literals, paralleling the main PR's given_input_leaf() enhancements in src/domain/checks.rs.
  • breezy-bays-labs/cute-dbt#63: Introduces the unit_test_format_coverage feature, Cucumber steps, and dbt-playground fixture wiring that this PR extends by tightening given_input_leaf() parsing and updating step regexes to preserve ref("...") quote styles.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A rabbit hops through quotes so bright,
Single, double, left and right—
Both are valid, both align,
Coverage stays on one fine line! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and precisely summarizes the main change: extending given-input leaf extraction to accept double-quoted ref()/source() calls, addressing the core bug fix described in the PR objectives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch domain-249-double-quote-leaf-extraction

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions

Copy link
Copy Markdown
Contributor

📄 Rendered report preview

All golden examples regenerated cleanly.

🟡 Golden examples

Committed to examples/ and byte-identity gated — the canonical reports contributors and consumers browse. Stable across PRs.

Report View Download
playground-report.html ▶ Open ↗ ⬇ Download
diff-showcase-report.html ▶ Open ↗ ⬇ Download
jaffle-shop-report.html ▶ Open ↗ ⬇ Download

🐶 Live dogfood preview

This PR doesn't touch dbt-project/, so there's no live dogfood preview.

▶ Open ↗ opens the report in your browser in one click —
published to this repo's GitHub Pages under /pr-272/.
⬇ Download fetches the same self-contained HTML as a workflow
artifact (auth-gated; works fully offline). Either way the report
makes zero external resource requests.

The Pages preview may take ~1 min to update after this comment
posts. On PRs from forks the Open link is unavailable (read-only
token) — use Download.

Alternative: GitHub CLI
# gh CLI >= 2.63 extracts into ./report-preview-playground/.
gh run download 27391176941 -R breezy-bays-labs/cute-dbt -n report-preview-playground
open report-preview-playground/playground-report.html

Posted by report-preview.yml for ddace5a56a27b8a6a1ec34981798054dac3f42dc. Affordance only — never blocks merge.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for both single and double quotes in dbt unit test given inputs (e.g., ref("...") as well as ref('...')), addressing issue cute-dbt#249. The given_input_leaf function in src/domain/checks.rs was updated to scan for either quote style while ensuring matching open and close quotes. Corresponding unit tests, feature files, test steps, and fixtures were updated to verify this behavior. There are no review comments to assess, so I have no additional feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@cmbays
cmbays merged commit 17b1367 into main Jun 12, 2026
32 of 33 checks passed
@cmbays
cmbays deleted the domain-249-double-quote-leaf-extraction branch June 12, 2026 02:50
github-actions Bot added a commit that referenced this pull request Jun 12, 2026
@cmbays

cmbays commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

Overnight orchestration wrap-up

Merged as 17b1367 (squash) under Christopher's overnight authority — CI fully green (all checks), 0 unresolved review threads, push verified (origin == head ddace5a). Issue #249 auto-closed ✔.

What shipped: given_input_leaf now accepts double-quoted ref()/source() under the matching-quote rule (mixed/unbalanced → fail-open None), fixing both consumers (union arm-coverage + join side rows). TDD RED proved the pre-fix degradation was a false Uncovered nag, worse than the Unknown the issue hypothesized. Dogfood splice pins the behavior in the playground goldens.

Cross-regen note: this PR regenerated 3 goldens (playground, diff-showcase, explore/tests.html). The two in-flight golden-touching branches (#251 AA tokens, #266 dbt_project.yml panel) have been instructed to merge this main and regenerate over the merged tree before their PRs finalize.

🤖 Generated with Claude Code

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.

domain: given_input_leaf single-quote-only leaf extraction — double-quoted ref() degrades arm-coverage to Unknown

1 participant