From f69080ae3019c809cb680e909cdff926b3ed502d Mon Sep 17 00:00:00 2001 From: Christopher Bays Date: Tue, 23 Jun 2026 01:30:06 -0400 Subject: [PATCH 1/2] =?UTF-8?q?feat(adapters):=20#470=20=E2=80=94=20raw=5F?= =?UTF-8?q?dag=20nodes=20+=20node=5Fmap.compiled=20(N=E2=86=921,=20omit-on?= =?UTF-8?q?-ambiguous)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit S2 of the raw⇄compiled DAG spine (epic #468). Delivers the raw structural DAG NODES + the N→1 compiled⇄raw correspondence, projected once from the assembled SourceMap into code_map. Edges + node_map.raw (1→N, observed) are S3 (#471) and are deliberately ABSENT here — never faked. What landed (in src/adapters/render.rs, beside CodeMapPayload/gather_raw_zones): - RawDagNodePayload { id, role: cte|terminal|zone, is_zone, presence } + RawDagPayload { nodes } + NodeMapPayload { compiled } — Serialize-only projections, omit-when-empty so pre-#470 goldens stay byte-stable. - build_raw_dag_and_node_map: every node a SOUND literal raw_code region — verbatim WITH CTEs (via the SHARED #469/#473 masking scan, presence compiled_in), the #448 zone entries (honest 3-state presence), and a WITH-less model → exactly ONE terminal raw node (mirrors from_cte_graph's terminal synthesis) so node_map.compiled stays total. - node_map.compiled (compiledId → rawId, N→1): verbatim-CTE identity, the WITH-less terminal, else a unique structural-containment fold to the ONE template zone (the {% for %}-fanned CTEs). unique_containing_zone returns None on zero-or-multiple → the key is OMITTED, never a guessed rawId. The three honesty rules: - omit-on-ambiguous: a compiled node with no UNIQUE raw origin omits its key. - sound literal nodes: every raw node is a real lexical region of raw_code (never a predicted/fabricated node). - WITH-less terminal totality + fanned→one-template: one terminal raw node for a WITH-less model; all fanned compiled CTEs map back to the ONE zone. A pruned {% if is_incremental() %} zone is compiled_out (NEVER compiled_in). TDD (tests before impl, render.rs test module): nodes-sound · with-less-single-terminal · fanned-nodes-map-to-one-template · macro-CTE-no-unique-origin-omits · ambiguous-two-zones-omits · incremental-guard-compiled_out · no-raw-structure-omits-both (byte-stable) · serialize-wire-shape. Dogfood fixture: incremental-showcase GOLDEN — a SYNTHETIC manifest whose fct_events wraps an inner CTE inside {% if is_incremental() %} and whose compiled_code is the fresh-build shape (guard PRUNED), so the regenerated golden shows the verbatim `base` CTE as compiled_in and the pruned guard as a first-class compiled_out zone raw node. Hand-authored compiled_code (no real dbt compile) → no root_path/username leak; listed in MANIFEST.toml, synthetic_only. Goldens: all example reports flipped (code_map JSON grew with raw_dag.nodes + node_map.compiled); regenerated + byte-verified. jaffle-shop chrome snapshot accepted (additive raw_dag/node_map only). Source-map completeness guard, fixture-manifest gate, fmt, clippy --all-targets --locked, full nextest, BDD, cargo doc -D warnings, cargo deny, crap4rs all green. Closes #470 Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_0199AmBCec5kyVEEF1Qd7TSF --- .github/workflows/ci.yml | 24 + examples/comments-showcase-report.html | 2 +- examples/diff-showcase-report.html | 2 +- examples/explore-macro/tests.html | 2 +- examples/explore-seed/tests.html | 2 +- examples/explore/tests.html | 2 +- examples/incremental-showcase-report.html | 11920 ++++++++++++++++ examples/jaffle-shop-report.html | 2 +- examples/playground-report.html | 2 +- examples/prdiff-minidag-report.html | 2 +- examples/seed-showcase-report.html | 2 +- src/adapters/render.rs | 588 +- tests/fixtures/MANIFEST.toml | 74 + .../incremental-showcase-current.json | 96 + .../incremental-showcase-pr-diff.patch | 6 + .../models/marts/fct_events.sql | 15 + .../models/staging/stg_events.sql | 1 + ...egration__rendered_chrome_jaffle_shop.snap | 2 +- 18 files changed, 12733 insertions(+), 11 deletions(-) create mode 100644 examples/incremental-showcase-report.html create mode 100644 tests/fixtures/incremental-showcase-current.json create mode 100644 tests/fixtures/incremental-showcase-pr-diff.patch create mode 100644 tests/fixtures/incremental-showcase-source/models/marts/fct_events.sql create mode 100644 tests/fixtures/incremental-showcase-source/models/staging/stg_events.sql diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5af168c..bbaaffe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -779,6 +779,30 @@ jobs: output: examples/seed-showcase-report.html project_root: tests/fixtures/seed-showcase-source experimental: "1" + # cute-dbt#470 (epic #468, S2) — the GOLDEN raw-DAG incremental + # showcase. A dedicated minimal SYNTHETIC manifest (one incremental + # model + its staging dep) whose `fct_events` raw_code wraps an inner + # CTE inside a `{% if is_incremental() %}` guard, and whose + # compiled_code is the FRESH-build shape (the guard body PRUNED). So + # the regenerated golden exercises the raw structural DAG: the + # verbatim `base` CTE as a `compiled_in` raw node, and the pruned + # incremental guard as a first-class `compiled_out` zone raw node + # (never falsely "compiled") — the honest incremental-CTE visibility + # the spine was built for. node_map.compiled folds `base → base` + # (identity); the pruned zone is type-incapable of a fold target. + # Rendered in --pr-diff mode (a synthetic one-line edit to the model + # file marks it in-scope). No baseline — the showcase is --pr-diff + # only. The compiled manifest is hand-authored (the fresh-build + # compile), never from a real `dbt compile`, so it leaks no + # root_path/username (synthetic-only fixture invariant). + - name: incremental-showcase + mode: report + current: tests/fixtures/incremental-showcase-current.json + baseline: "" + pr_diff: tests/fixtures/incremental-showcase-pr-diff.patch + output: examples/incremental-showcase-report.html + project_root: tests/fixtures/incremental-showcase-source + experimental: "" # cute-dbt#404 (epic #352) — the GOLDEN PR-scope lineage mini-DAG. # A dedicated minimal manifest with a CONNECTOR PATH # (stg_orders → int_order_items → fct_orders): stg_orders and diff --git a/examples/comments-showcase-report.html b/examples/comments-showcase-report.html index ca7ca01..a97917b 100644 --- a/examples/comments-showcase-report.html +++ b/examples/comments-showcase-report.html @@ -2634,7 +2634,7 @@

Expected

- + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/jaffle-shop-report.html b/examples/jaffle-shop-report.html index ec8f295..00d9044 100644 --- a/examples/jaffle-shop-report.html +++ b/examples/jaffle-shop-report.html @@ -2580,7 +2580,7 @@

Expected

- + + + + +