Skip to content

fix(describe): hide language-internal functions - #4250

Merged
codeshaunted merged 2 commits into
canaryfrom
codex/describe-visibility
Jul 28, 2026
Merged

codeshaunted merged 2 commits into
canaryfrom
codex/describe-visibility

Conversation

@codeshaunted

@codeshaunted codeshaunted commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add function metadata with an explicit language-internal marker
  • mark compiler/runtime helper functions internal while keeping LLM companions user-facing
  • exclude language-internal functions from describe listings, exact lookup, fallback search, and method discovery

Validation

  • cargo test -p baml_compiler2_ast
  • cargo test -p baml_lsp2_actions
  • cargo test -p baml_cli describe_command_tests
  • cargo clippy -p baml_cli -p baml_lsp2_actions --all-targets -- -D warnings
  • full pre-commit workspace clippy

Summary by CodeRabbit

  • Enhancements
    • Improved function classification by introducing richer function metadata to better distinguish user-facing, companion, auto-derived, and language-internal functions.
    • Language-internal compiler functions are now consistently excluded from LSP listings, outlines, descriptions, navigation resolution, and generated client symbols.
    • Companion functions remain visible where appropriate, including for descriptive tooling.
  • Bug Fixes
    • More reliable function-origin handling across compilation, type checking, code generation, and editor features.
  • Tests
    • Added coverage ensuring internal functions are hidden while companion functions remain discoverable.

@vercel

vercel Bot commented Jul 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
beps Ready Ready Preview, Comment Jul 28, 2026 9:19pm
promptfiddle Ready Ready Preview, Comment Jul 28, 2026 9:19pm
promptfiddle2 Ready Ready Preview, Comment Jul 28, 2026 9:19pm

Request Review

@vercel
vercel Bot temporarily deployed to Preview – beps July 28, 2026 20:26 Inactive
@github-actions

Copy link
Copy Markdown

⏭️ Performance benchmarks were skipped

Perf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to canary/main.

To run them on this PR, do any of the following, then push a commit (or re-run CI):

  • Add RUN_CODSPEED=1 to the PR description, or
  • Include run-perf or /perf in the PR title or any commit message.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: aaa3866c-c3c3-4d3b-926b-d5fdbfd4bfb5

📥 Commits

Reviewing files that changed from the base of the PR and between f11658b and 031225e.

📒 Files selected for processing (3)
  • baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs
  • baml_language/crates/baml_lsp2_actions/src/actions.rs
  • baml_language/crates/baml_project/src/client_codegen.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • baml_language/crates/baml_lsp2_actions/src/actions.rs
  • baml_language/crates/baml_project/src/client_codegen.rs

📝 Walkthrough

Walkthrough

Function provenance is encapsulated in FunctionMetadata, which also marks language-internal functions. The metadata propagates through AST, HIR, PPIR, emission, LSP actions, project tooling, and regression tests. LSP discovery now filters internal functions while retaining user-facing companions.

Changes

Function metadata and visibility

Layer / File(s) Summary
Metadata contract and function lowering
baml_language/crates/baml_compiler2_ast/src/{ast.rs,companions.rs,lower_cst.rs,lower_expr_body.rs,lib.rs}
Adds FunctionMetadata, updates FunctionDef, and marks lowered functions as user-facing or language-internal.
Compiler metadata propagation
baml_language/crates/baml_compiler2_{hir,ppir,tir,emit}/...
Carries metadata through compiler representations and reads metadata.origin for origin classification and auto-derive behavior.
LSP internal-definition filtering
baml_language/crates/baml_lsp2_actions/src/...
Filters language-internal definitions from listings, descriptions, outlines, annotations, and targets while preserving visibility for LLM companions; adds coverage tests.
Project integrations and regression coverage
baml_language/crates/baml_project/src/..., baml_language/crates/baml_tests/src/...
Updates code generation, navigation, symbols, playground actions, and incremental tests to read origins from metadata.origin.

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

Sequence Diagram(s)

sequenceDiagram
  participant LSP as LSP actions
  participant Definition as Definition::is_language_internal
  participant ItemTree as file_item_tree
  LSP->>Definition: Check resolved definition visibility
  Definition->>ItemTree: Read FunctionMetadata.is_language_internal
  ItemTree-->>Definition: Return internal-visibility flag
  Definition-->>LSP: Allow or filter listing and description
Loading

Possibly related PRs

Suggested reviewers: antoniosarosi, hellovai, aaronvg

Poem

I’m a rabbit with metadata tucked neat,
Internal hops stay out of sight,
User companions remain in the light.
Origins travel through every tree,
LSP finds what it should see! 🐇

🚥 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 is concise and accurately reflects the main change: adding language-internal function metadata and hiding those functions from describe-related output.
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.
✨ 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 codex/describe-visibility

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.

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 28, 2026 20:33 Inactive
@github-actions

github-actions Bot commented Jul 28, 2026 •

Copy link
Copy Markdown

Binary size checks passed

✅ 7 passed

Artifact Platform File Gzip Gated on Baseline Delta Status
✅ baml-cli Linux 🔒 27.3 MB 11.6 MB file 27.3 MB -5.2 KB (-0.0%) OK
✅ packed-program Linux 🔒 17.7 MB 7.3 MB file 17.7 MB +8.2 KB (+0.0%) OK
✅ baml-cli macOS 🔒 21.2 MB 10.1 MB file 21.2 MB +16 B (+0.0%) OK
✅ packed-program macOS 🔒 13.9 MB 6.4 MB file 13.9 MB +16 B (+0.0%) OK
✅ baml-cli Windows 🔒 22.9 MB 10.4 MB file 22.9 MB -4.1 KB (-0.0%) OK
✅ packed-program Windows 🔒 14.8 MB 6.5 MB file 14.8 MB +2.6 KB (+0.0%) OK
✅ bridge_wasm WASM 16.6 MB 🔒 4.5 MB gzip 4.5 MB +7.6 KB (+0.2%) OK

🔒 = the size this artifact is GATED on (ceiling + delta). Binaries gate on file size (installed binary); WASM gates on gzip (download size). The other size is shown for information only.


Generated by cargo size-gate · workflow run

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 28, 2026 20:47 Inactive

@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: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
baml_language/crates/baml_project/src/symbols.rs (1)

130-135: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Exclude language-internal functions from the listing.

list_functions_with_metadata still pushes every function; changing only the origin access does not hide functions marked metadata.is_language_internal. Skip internal functions before constructing FunctionSymbol, while retaining user-facing companions.

🤖 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 `@baml_language/crates/baml_project/src/symbols.rs` around lines 130 - 135,
Update list_functions_with_metadata to filter out functions whose
metadata.is_language_internal is true before constructing or pushing
FunctionSymbol. Preserve user-facing companion functions and the existing
origin-based parameter handling for all non-internal functions.
🤖 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 `@baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs`:
- Around line 4417-4419: Update the user-lambda lowering path around
FunctionMetadata::language_internal to use FunctionMetadata::user_facing with
FunctionOrigin::UserDefined. Preserve language_internal only for
compiler-synthesized functions so normal lambdas retain user-defined provenance
and remain visible to downstream paths.

In `@baml_language/crates/baml_lsp2_actions/src/actions.rs`:
- Around line 82-84: Update the function filtering condition in the code-action
generation flow to continue when either the origin is not
FunctionOrigin::UserDefined or func.metadata.is_language_internal is true.
Preserve the existing origin check while excluding language-internal functions
from RunInPlayground code lenses.

In `@baml_language/crates/baml_project/src/client_codegen.rs`:
- Around line 200-202: Update the SDK filtering conditions around the visible
AutoDerive check and its corresponding free-function filter to also exclude
methods whose metadata.is_language_internal flag is true. Retain the existing
FunctionOrigin::AutoDerive and FunctionOrigin::Internal exclusions, applying the
metadata visibility check in both locations.

---

Outside diff comments:
In `@baml_language/crates/baml_project/src/symbols.rs`:
- Around line 130-135: Update list_functions_with_metadata to filter out
functions whose metadata.is_language_internal is true before constructing or
pushing FunctionSymbol. Preserve user-facing companion functions and the
existing origin-based parameter handling for all non-internal functions.
🪄 Autofix (Beta)

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: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9ca5fc2d-96df-4529-81ae-54467e58af15

📥 Commits

Reviewing files that changed from the base of the PR and between 384a6ff and f11658b.

📒 Files selected for processing (24)
  • baml_language/crates/baml_compiler2_ast/src/ast.rs
  • baml_language/crates/baml_compiler2_ast/src/companions.rs
  • baml_language/crates/baml_compiler2_ast/src/lib.rs
  • baml_language/crates/baml_compiler2_ast/src/lower_cst.rs
  • baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs
  • baml_language/crates/baml_compiler2_emit/src/lib.rs
  • baml_language/crates/baml_compiler2_hir/src/builder.rs
  • baml_language/crates/baml_compiler2_hir/src/contributions.rs
  • baml_language/crates/baml_compiler2_hir/src/item_tree/builder.rs
  • baml_language/crates/baml_compiler2_hir/src/item_tree/functions.rs
  • baml_language/crates/baml_compiler2_ppir/src/item_data/functions.rs
  • baml_language/crates/baml_compiler2_ppir/src/lib.rs
  • baml_language/crates/baml_compiler2_tir/src/inference.rs
  • baml_language/crates/baml_lsp2_actions/src/actions.rs
  • baml_language/crates/baml_lsp2_actions/src/annotations.rs
  • baml_language/crates/baml_lsp2_actions/src/describe.rs
  • baml_language/crates/baml_lsp2_actions/src/listing.rs
  • baml_language/crates/baml_lsp2_actions/src/listing_tests.rs
  • baml_language/crates/baml_lsp2_actions/src/outline.rs
  • baml_language/crates/baml_lsp2_actions/src/utils.rs
  • baml_language/crates/baml_project/src/client_codegen.rs
  • baml_language/crates/baml_project/src/db.rs
  • baml_language/crates/baml_project/src/symbols.rs
  • baml_language/crates/baml_tests/src/incremental/scenarios.rs

@vercel
vercel Bot temporarily deployed to Preview – beps July 28, 2026 20:59 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 28, 2026 21:06 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 28, 2026 21:19 Inactive
@codeshaunted
codeshaunted added this pull request to the merge queue Jul 28, 2026
Merged via the queue into canary with commit f4786f2 Jul 28, 2026
82 checks passed
@codeshaunted
codeshaunted deleted the codex/describe-visibility branch July 28, 2026 22:04

This branch was previously deployed

3 inactive deployments
Preview – promptfiddle — 031225e4 Deployed Jul 28, 2026 by vercel[bot]
Preview – promptfiddle2 — 031225e4 Deployed Jul 28, 2026 by vercel[bot]
Preview – beps — 031225e4 Deployed Jul 28, 2026 by vercel[bot]
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