Skip to content

#265 — render: macro lens model-selector + usage examples (Slice C) - #358

Merged
cmbays merged 3 commits into
mainfrom
macro-265-slice-c-selector-usage
Jun 13, 2026
Merged

cmbays merged 3 commits into
mainfrom
macro-265-slice-c-selector-usage

Conversation

@cmbays

@cmbays cmbays commented Jun 13, 2026 •

Copy link
Copy Markdown
Contributor

Part of #265 — the macro perspective lens, render lane Slice C.

Extends the experimental macro-lens section (behind Experiment::MacroLens) with the founder D4 model-selector and the founder D6 first-order call-site examples. Append-only on the shared fence files (render.rs, report.html); interaction.js is untouched.

What it adds

  • Model-selector (founder D4): a <select> listing the impacted (macro-calling) root-project models; selecting one shows that model's inline SQL + its call sites in place. Reuses the feature: scope to updated unit tests by default + toggle to include unchanged #91 changed-models <select> idiom. The model SQL is server-rendered from the manifest raw_code (the existing Model-SQL source — no new I/O path); the JS is a pure renderer that flips hidden on change.
  • Usage examples — first-order call sites (founder D6): a render-lane string scan of each impacted model's raw_code for the macro name, behind a generous cap (default 3 shown + a "showing N of M" disclosure; MACRO_CALL_SITE_CAP). First-order only — full ref()-lineage downstream is the explorer (explore: macro view — filtered artifact directory + dimmed impacted-model DAG #345). The per-arm fidelity chip (exact / heuristic) already states confidence honestly (S2).
  • Additive payload PODs (ImpactedModelView, CallSiteView) on ChangedMacroView; the macro_lens payload rides the JSON too (the both-surfaces precedent).

Invariants

  • Byte-identity preserved: the selector behaviour is a gated inline <script> inside the macro section, not the shared interaction.js engine — so the non-macro goldens (jaffle-shop, playground) stay byte-identical and a macro-only PR (zero in-scope models) still switches panels. Experiment OFF ⇒ the whole arm (script included) emits zero bytes.
  • Zero-egress: no new vendored asset, no src; inline script + server-rendered panels. Headless file:// network-block test green.
  • Domain stays additive; every touched fn CRAP<15 (worst new: line_invokes_macro=8).

Dogfood

The showcase macro quarantine_filter is already called inline in 3 playground models, so the regenerated examples/diff-showcase-report.html shows the selector + call sites live.

Gates (all run synchronously, in-turn)

clippy (exit 0) · fmt --check · nextest (1939 passed) · bdd (29 features, 217 scenarios — +1 scenario in the existing macro_perspective.feature, no feature-count bump) · headless selector-switch + zero-egress (real Chromium, file://, network-blocked) · rustdoc -D warnings · cargo deny · crap4rs scorecard PASS.

🤖 Generated with Claude Code


Open in Stage

…s (Slice C)

Extends the experimental macro-lens section (cute-dbt#265, behind
`Experiment::MacroLens`) with the founder D4 model-selector and the
founder D6 first-order call-site examples.

- `ImpactedModelView` / `CallSiteView` additive payload PODs on
  `ChangedMacroView`: each impacted (macro-calling) root-project model
  carries its inline raw SQL (server-rendered from the manifest
  `raw_code`, the existing Model-SQL source — no new I/O path) plus its
  first-order call sites of the changed macro, behind a generous cap
  (default 3 shown + the "more" copy; `MACRO_CALL_SITE_CAP`).
- `impacted_model_views` / `macro_call_sites` / `line_invokes_macro`:
  pure render-lane string scans over already-loaded source (zero-egress,
  zero new I/O). The call-site match is bounded so `x_macro_name(` never
  false-matches; it is first-order only (full ref()-lineage downstream is
  the explorer, #345).
- Template: the impacted-model `<select>` (reusing the #91 idiom) + a
  server-rendered per-model panel (inline SQL + call sites) for every
  impacted model, only the first visible. The selector behaviour is a
  GATED inline `<script>` inside the macro section (not the shared
  interaction.js engine), so the non-macro goldens stay byte-identical
  and a macro-only PR with zero in-scope models still switches panels.
  Pure renderer — flips `hidden` on change, never recomputes or fetches.

Dogfood: the showcase macro `quarantine_filter` is already called inline
in 3 playground models, so the regenerated `diff-showcase` golden shows
the selector + call sites live. jaffle-shop + playground stay
byte-identical (interaction.js untouched).

Gates: clippy/fmt/nextest (1939)/bdd (29 features, +1 scenario in the
existing macro_perspective.feature — no feature-count bump)/headless
selector-switch + zero-egress/doc/deny all green; every touched fn
CRAP<15 (worst new: line_invokes_macro=8).

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 22 minutes and 14 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: d0b7a32e-2099-4add-aaf5-77591c4da562

📥 Commits

Reviewing files that changed from the base of the PR and between a094704 and 2629c17.

📒 Files selected for processing (6)
  • examples/diff-showcase-report.html
  • features/macro_perspective.feature
  • src/adapters/render.rs
  • templates/report.html
  • tests/headless_toggle.rs
  • tests/steps/macro_perspective.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch macro-265-slice-c-selector-usage

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

Ready to review this PR? Stage has broken it down into 7 individual chapters for you:

Title
1 Define data structures for macro call sites
2 Implement macro call site scanning logic
3 Render model selector and SQL panels
4 Verify macro lens with unit tests
5 Test selector behavior in headless browser
6 Add BDD scenarios for macro perspective
7 Update showcase report example
Open in Stage

Chapters generated by Stage for commit 2629c17 on Jun 13, 2026 4:31pm UTC.

@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 impacted-model selector and first-order call-site display for the macro lens feature. It introduces the necessary data structures, parsing logic to extract macro call sites from model source code, and frontend rendering templates with inline JavaScript to toggle between model panels. Additionally, comprehensive unit, BDD, and headless browser tests are added. The review feedback highlights a potential infinite loop in line_invokes_macro if macro_name is empty, suggesting a defensive guard to ensure robustness.

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
@github-actions

github-actions Bot commented Jun 13, 2026 •

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
jaffle-shop-report.html ▶ Open ↗ ⬇ Download
diff-showcase-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-358/.
⬇ 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 27472481085 -R breezy-bays-labs/cute-dbt -n report-preview-playground
open report-preview-playground/playground-report.html

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

cmbays and others added 2 commits June 13, 2026 12:29
gemini (PR #358) flagged a latent hang: `str::find("")` returns
`Some(0)` and a zero-length name never advances the scan cursor, so
`line_invokes_macro` would spin forever on an empty `macro_name`. The
sole caller (`macro_call_sites`) already guards the empty name, but a
private helper whose safety depends on a non-local caller invariant — and
whose failure mode is a silent hang — earns a local defensive guard.

Returns false at the top on an empty name + a focused unit test
(`line_invokes_macro("select foo()", "")` is false and does not hang).
No rendered-output path hits the empty-name case, so the goldens are
byte-identical (confirmed: `git diff --text` clean on examples/).

Part of #265

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cmbays
cmbays merged commit 4ece2d2 into main Jun 13, 2026
35 checks passed
@cmbays
cmbays deleted the macro-265-slice-c-selector-usage branch June 13, 2026 16:36
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 — #358 (#265 Slice C: macro model-selector + usage examples)

Merged 4ece2d2 · Part of #265 (Slice D remains) · feat → patch.

What shipped: the macro lens now has an impacted-model <select> that shows the chosen model's SQL inline + its first-order macro call-sites (behind a cap, "showing N of M"), all server-rendered (every panel's SQL + call sites composed in Rust). Founder D4 (selector) + D6 (first-order callers in the report; full-downstream is the explorer's job, #345). Dogfood was already live — quarantine_filter is called in 3 playground models, so the regenerated diff-showcase golden shows the selector + 9 call-site lines.

Architectural deviation (I probed it — sound, arguably better): the selector behaviour went into a gated, section-scoped inline <script> inside the {% match macro_lens %} arm, not the shared interaction.js. Reason: adding to interaction.js would churn every golden (inert-JS presence, the #269 pattern) for an experimental feature's JS and couple it to the model-bearing engine — which doesn't even boot on a macro-only PR (zero in-scope models). I read the script: a scoped IIFE, plain DOM (no jQuery), no fetch / no recompute — it only flips hidden on <select> change, and emits zero bytes when the experiment is off (so non-macro goldens stay byte-identical). This is the correct call. Precedent noted: if section-scoped inline scripts ever proliferate, consolidate into one gated engine.

Bot disposition — 1 thread, ACCEPTED:

  • gemini @render.rs:2379 — line_invokes_macro infinite-loops on an empty macro_name (find("") → Some(0), cursor never advances). The sole caller guards it (no live bug), but it's a private helper whose safety depended on a non-local caller invariant, and a silent hang is the worst latent failure — so I accepted the one-line defensive guard (distinguishable from the #265 — render: macro lens section MVP (Slice B) #356 slice nit, which was provably safe by local construction). Builder applied the guard + a no-hang unit test (8c5c568).

Gates (green): clippy via rtk proxy, nextest 1940 (+ the guard test), BDD 29/217, headless selector-switch + zero-egress (real Chromium, network-blocked), doc -D, deny, crap4rs (every new fn <15), goldens byte-identical (only diff-showcase changed; jaffle/playground identical). Branch-updated past #357 + re-gated before merge.

Risks / follow-ups: none filed. Next: Slice D (capped inline model bodies via a TOML/CLI gen-time knob, default ~10 + the S5 dispatch-macro fixture + golden-size assertion) → macro report lane COMPLETE → Claude Design handoff → then the #345 explorer macro view.

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