Skip to content

#265 — render: macro lens section MVP (Slice B) - #356

Merged
cmbays merged 1 commit into
mainfrom
macro-265-slice-b-render
Jun 13, 2026
Merged

cmbays merged 1 commit into
mainfrom
macro-265-slice-b-render

Conversation

@cmbays

@cmbays cmbays commented Jun 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The render lane for the macro perspective (epic #265, Slice B). A macros/*.sql edit is invisible to cute-dbt's model-and-unit-test scope selection; this adds an EXPERIMENTAL "macro changed" report section that consumes the merged Slice-A domain layer (macro_blast_radius + changed_macros_{pr_diff,baseline}) and surfaces, per changed root-project macro:

  • the rendered macro body diff (reusing the feature: inline SQL diff for changed models in PR-review report (report-mode, diff-sourced) #111 reconstruct hunk renderer via a new reconstruct_macro_sql_diff, the model_sql_diff sibling),
  • the impacted-model count (the reverse blast-radius cardinality),
  • the impacted models as a collapsible directory tree grouped by original_file_path (founder D3 — list/tree only, no inline bodies),
  • a per-arm fidelity chip (baseline = exact macro-body comparison; pr-diff = path/name heuristic).

Gating + invariants

  • New Experiment::MacroLens ("macro-lens" id, additive). Off ⇒ macro_lens = None ⇒ JSON key omitted + {% if macro_lens %} emits zero bytes ⇒ non-macro goldens byte-identical (jaffle-shop, playground regenerate unchanged; only diff-showcase moves, and its only payload delta is the added macro_lens key).
  • Section renders ABOVE the governance chips (founder "near the top").
  • Copy says "macro changed", never a state:modified.macros selector (critique S2). Vendor-package macros are filtered out of the lens. No focused DAG, no report→explore hyperlink (explore-only, explore: macro view — filtered artifact directory + dimmed impacted-model DAG #345; one-file zero-egress holds).
  • Domain purity preserved: the new domain fn (reconstruct_macro_sql_diff) is additive in pr_diff.rs; no comparator/scoping/state.rs touch.

Dogfood (same PR)

Synthetic root-project macro source playground-source/macros/data_quality/quarantine_filter.sql (byte-aligned to the committed manifest macro_sql) + a macro edit hunk in playground-pr-diff.patch; the diff-showcase golden regenerates with the section (3 impacted models across two directory subtrees: marts/core + intermediate/healthcare). Both new fixtures are listed in tests/fixtures/MANIFEST.toml (synthetic_only = true).

Gates (all green)

  • cargo fmt --check, cargo clippy --all-targets --locked -D warnings, cargo nextest run (1931 pass), cargo test --test bdd (216 scenarios), headless --run-ignored all (95 pass, real Chromium / file:// / network-blocked — section renders + tree expands), headless_zero_egress (11 pass — zero requests), cargo doc -D warnings, cargo deny check, crap4rs scorecard PASS (every new fn < 15; worst overall 15.0).
  • New features/macro_perspective.feature (4 scenarios: pr-diff edit → section present; no edit → absent + byte-stable; experiment OFF → absent; vendor macro → filtered). Feature-count mirror bumped 28→29 in ci.yml AND lefthook.yml atomically.
  • diff-showcase golden byte-identical to renderer output (verified).

Part of #265.

🤖 Generated with Claude Code


Open in Stage

…ree (#265 Slice B)

The render lane for the macro perspective (epic #265). A macros/*.sql edit
is invisible to model-and-unit-test scope selection; this adds an
EXPERIMENTAL "macro changed" report section that consumes the merged Slice-A
domain layer (macro_blast_radius + changed_macros_{pr_diff,baseline}) and
surfaces, per changed root-project macro:

- the rendered macro body diff (reusing the #111 reconstruct hunk renderer
  via a new domain reconstruct_macro_sql_diff, the model_sql_diff sibling),
- the impacted-model count (the reverse blast radius cardinality),
- the impacted models as a collapsible directory tree grouped by
  original_file_path (founder D3 — list/tree only, no inline bodies),
- a per-arm fidelity chip (baseline = exact macro-body comparison;
  pr-diff = path/name heuristic).

Everything is gated behind a new Experiment::MacroLens ("macro-lens" id):
when off the cli passes macro_lens = None, so the JSON key is omitted
(skip_serializing_if) and the {% if macro_lens %} template section emits zero
bytes — the non-macro goldens (jaffle-shop, playground) stay byte-identical.
The section renders ABOVE the governance chips (founder "near the top").

Copy says "macro changed", never a state:modified.macros selector (critique
S2). Vendor-package macros are filtered out of the lens (critique posture).
No focused DAG, no report→explore hyperlink (explore-only, #345; the one-file
zero-egress contract holds).

Dogfood (same PR): a synthetic root-project macro source file
(playground-source/macros/data_quality/quarantine_filter.sql, byte-aligned
to the committed manifest macro_sql) + a macro edit hunk in
playground-pr-diff.patch; the diff-showcase golden regenerates with the
section (3 impacted models across two directory subtrees). The only golden
payload change is the added macro_lens key.

Gates: new features/macro_perspective.feature (4 scenarios — pr-diff edit /
no-edit byte-stable / experiment-off / vendor-filtered), feature-count
mirror bumped 28→29 in ci.yml + lefthook.yml. Headless (real Chromium,
file://, network-blocked) asserts the section renders + the tree expands.
crap4rs PASS (every new fn <15; worst overall 15.0). fmt/clippy --locked/
nextest (1931)/bdd (216)/headless (95)/zero-egress (11)/doc/deny all green.

Part of #265.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@cmbays, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 3 minutes and 3 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d90d90aa-c80e-46a7-848c-cc7c66dd3a74

📥 Commits

Reviewing files that changed from the base of the PR and between c3bd746 and eae7a31.

📒 Files selected for processing (16)
  • .github/workflows/ci.yml
  • examples/diff-showcase-report.html
  • features/macro_perspective.feature
  • lefthook.yml
  • src/adapters/render.rs
  • src/cli/mod.rs
  • src/domain/experimental.rs
  • src/domain/mod.rs
  • src/domain/pr_diff.rs
  • templates/report.html
  • tests/fixtures/MANIFEST.toml
  • tests/fixtures/playground-pr-diff.patch
  • tests/fixtures/playground-source/macros/data_quality/quarantine_filter.sql
  • tests/headless_toggle.rs
  • tests/steps/macro_perspective.rs
  • tests/steps/mod.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch macro-265-slice-b-render

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.

@ghost

ghost commented Jun 13, 2026

Copy link
Copy Markdown

@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.

🧭 Explore preview

The two-page cute-dbt explore explorer — dag.html (model lineage) + tests.html (unit-test viewer). Same golden/live split as the report.

🟡 Golden explore

The committed examples/explore/ playground golden (the full synthetic playground manifest). Byte-identity gated in Example report check. Stable across PRs.

Page View Download
explore/dag.html ▶ Open ↗ ⬇ Download
explore/tests.html ▶ Open ↗ ⬇ Download

🐶 Live explore

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

▶ Open ↗ opens the report or explorer in your browser in one
click — published to this repo's GitHub Pages under
/pr-356/.
⬇ 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 27471437940 -R breezy-bays-labs/cute-dbt -n report-preview-playground
open report-preview-playground/playground-report.html

Posted by report-preview.yml for eae7a31f2371627b7b513564a2b2499a71500772. 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 implements the macro perspective lens (cute-dbt#265, Slice B), which identifies changed root-project macros and displays their body diffs alongside a collapsible directory tree of impacted models. The feature is gated behind the macro-lens experimental switch. Key additions include the build_macro_lens and reconstruct_macro_sql_diff functions, updated CLI and rendering pipelines, HTML template integration, and comprehensive BDD and headless browser tests. Feedback on the changes suggests a defensive panic-safety improvement in src/adapters/render.rs to use .iter().skip(shared) instead of direct slicing when traversing directory segments.

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.

Comment thread src/adapters/render.rs
@cmbays
cmbays merged commit 4e20ec8 into main Jun 13, 2026
35 checks passed
@cmbays
cmbays deleted the macro-265-slice-b-render branch June 13, 2026 15:55
github-actions Bot added a commit that referenced this pull request Jun 13, 2026
@cmbays

cmbays commented Jun 13, 2026

Copy link
Copy Markdown
Contributor Author

🧾 Merge debrief — #356 (#265 Slice B: macro lens section MVP)

Merged 4e20ec8 · Part of #265 (epic stays open; Slices C/D remain) · feat → patch.

What shipped: the experimental macro lens section — when a macro changes in the PR, the report renders (above the governance chips) the macro body diff + the impacted-model directory tree + the blast-radius count + a per-arm fidelity chip (baseline=exact / pr-diff=heuristic). Gated behind a new Experiment::MacroLens; zero bytes when off (non-macro goldens byte-identical). New domain reconstruct_macro_sql_diff (mirrors model_sql_diff, including the engine-divergent trailing-newline strip). Dogfood: a synthetic root-project macro referenced by ≥2 models + an edit hunk → diff-showcase regenerated to show the section.

Deviations from the build-plan (both benign, both probed):

  1. Vendor-macro filter sits at the render lane (build_macro_lens → is_root_project_macro), not the domain — because the merged pr-diff changed-macro channel is path-primary (resolves any macro whose file the PR touched, regardless of package), so a vendor macro can reach the changed set and must be dropped at the lens. I probed this (the builder flagged it): is_root_project_macro correctly drops pkg != project_name; a null-filled package defensively includes (sound — a PR-touched macro with no package is almost certainly root); covered by an explicit build_macro_lens_filters_out_vendor_package_macros unit test + the BDD vendor scenario. Correct.
  2. The plan named a reverse_apply hunk renderer; the actual reusable mechanism is BlockSpan + reconstruct_one (the model_sql_diff sibling). No functional difference.

Bot disposition — 1 thread, rejected probe-first:

  • gemini @render.rs:2287: prefer .iter().skip(n) over &dirs[shared..] for panic-safety, citing "the repository's general rules." Rejected: the slice is provably panic-safe — shared is a common-prefix count from zip(open_dirs, dirs).take_while(eq).count() three lines above, structurally ≤ dirs.len(); no such repo rule exists (checked AGENTS/CLAUDE/ARCHITECTURE/CONTRIBUTING — the citation is gemini's own heuristic, not a cute-dbt rule); and the direct-slice-after-safe-index idiom is already established in sibling code (cell_diff.rs:365/368). Changing one site would diverge from that idiom for zero safety gain. (CodeRabbit didn't post on this PR — likely rate-limited; CI was the second backstop.)

Gates (all green): clippy --locked, nextest 1931, BDD 29 features / 216 scenarios, headless 95 + zero-egress 11 (real Chromium, network-blocked), doc -D, deny, crap4rs PASS (worst 15.0; execute_report 14.00; every new fn ≤4), goldens contained (jaffle/playground byte-identical; diff-showcase delta = only the macro_lens key + the section DOM), feature-count 28→29 (ci.yml + lefthook.yml atomically; new features/macro_perspective.feature).

Recovery note: this is the same slice that hit the arm-and-wait stall earlier — it was corrected, rebuilt cleanly, and is now merged. No residue.

Risks / follow-ups: none filed. The macro lens is experimental → it goes to Claude Design for visual polish alongside governance.

Next: builder-macro → Slice C (model-selector to view an impacted model's SQL + first-order usage examples), then Slice D (capped inline bodies + the gen-time knob).

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