Add composable test profiles and canonical test IDs - #4076
Conversation
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
⏭️ Performance benchmarks were skippedPerf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to To run them on this PR, do any of the following, then push a commit (or re-run CI):
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe test system now uses canonical ChangesCanonical registration and registry execution
Estimated code review effort: 4 (Complex) | ~65 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant resolve_invocation
participant TestRegistry
participant flatten_with_tolerated
participant consume_flat_report
CLI->>resolve_invocation: parse profile and merge selectors
resolve_invocation-->>CLI: TestInvocation (merged filters + overrides)
CLI->>TestRegistry: run_filtered with profile & CLI include/exclude
TestRegistry->>TestRegistry: select_names_layered, run selected/all
TestRegistry-->>flatten_with_tolerated: TestSetReport with result_names
flatten_with_tolerated-->>consume_flat_report: passed_names, tolerated_names, failed_names
consume_flat_report-->>CLI: per-leaf + aggregate output
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 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_builtins2/baml_std/testing/registry.baml`:
- Around line 716-724: Update the identities fallback around
classify_selected_names so selection-based classification is used only when
selected_names.length() equals counts.total, in addition to the existing
partition-count validation. For partial custom-runner execution without
result_names, avoid classifying uninvoked leaves as passed; preserve
runner-provided identities when available.
- Around line 17-22: Update both testset_child and testset_child_selected so
their catch-all handling does not intercept InvalidTestName; rethrow this typed
error on every execution path while preserving conversion of other execution
failures into the existing testset error leaf.
In `@baml_language/crates/baml_cli/src/test_command.rs`:
- Around line 578-584: Update the test command flow around the
`invocation.features` collection so the merged profile and CLI features are
passed through the existing feature-activation path before database/engine
compilation. Ensure repeated values from both sources are combined and honored,
and remove or otherwise resolve the unused `invocation.features` state.
- Around line 153-167: Update the root-prefix check in validate_selectors so
only a bounded canonical root prefix is exempt, rather than any selector
beginning with the characters “root”. Ensure selectors such as
“rooted::nested/case” still trigger the legacy separator diagnostic, while valid
root-prefixed selectors retain their current behavior.
In `@baml_language/crates/baml_compiler2_ast/src/lower_cst.rs`:
- Around line 2134-2137: Update the namespace validation in the path-derived
owner logic around the valid check in lower_file_with_path to match
file_package::extract_ns_name: require the namespace name to be non-empty, begin
with an ASCII alphabetic character or underscore, and allow only ASCII
alphanumeric characters or underscores thereafter. Preserve the existing
namespace push behavior for valid names.
🪄 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
Run ID: 9efa8a8e-0d8f-46cb-8a34-34a606add46d
⛔ Files ignored due to path filters (5)
baml_language/crates/baml_cli/src/snapshots/baml_cli__describe_command_tests__render_testing_package_listing.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/__testing_std__/baml_tests__compiles____testing_std____03_hir.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/__testing_std__/baml_tests__compiles____testing_std____04_5_mir.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/__testing_std__/baml_tests__compiles____testing_std____04_tir.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/__testing_std__/baml_tests__compiles____testing_std____06_codegen.snapis excluded by!**/*.snap
📒 Files selected for processing (16)
baml_language/.markdown-whitelistbaml_language/architecture/test-profiles.mdbaml_language/crates/baml_builtins2/baml_std/testing/registry.bamlbaml_language/crates/baml_builtins2/baml_std/testing/runners.bamlbaml_language/crates/baml_builtins2/baml_std/testing/types.bamlbaml_language/crates/baml_cli/src/bytecode_cache.rsbaml_language/crates/baml_cli/src/commands.rsbaml_language/crates/baml_cli/src/manifest.rsbaml_language/crates/baml_cli/src/test_command.rsbaml_language/crates/baml_cli/src/test_filter.rsbaml_language/crates/baml_cli/tests/exit_code_e2e.rsbaml_language/crates/baml_cli/tests/test_list_discovery_cache_e2e.rsbaml_language/crates/baml_cli/tests/test_profiles_e2e.rsbaml_language/crates/baml_compiler2_ast/src/lib.rsbaml_language/crates/baml_compiler2_ast/src/lower_cst.rsbaml_language/crates/baml_compiler2_hir/src/lib.rs
Binary size checks passed✅ 7 passed
Generated by |
…files # Conflicts: # baml_language/crates/baml_tests/tests/bytecode_format/snapshots/bytecode_format__bytecode_display_expanded.snap # baml_language/crates/baml_tests/tests/bytecode_format/snapshots/bytecode_format__bytecode_display_expanded_unoptimized.snap
…files # Conflicts: # baml_language/crates/baml_cli/src/test_command.rs # baml_language/crates/baml_tests/snapshots/compiles/__testing_std__/baml_tests__compiles____testing_std____03_ppir.snap # baml_language/crates/baml_tests/snapshots/compiles/__testing_std__/baml_tests__compiles____testing_std____04_5_mir.snap # baml_language/crates/baml_tests/snapshots/compiles/__testing_std__/baml_tests__compiles____testing_std____06_codegen.snap # baml_language/crates/baml_tests/tests/bytecode_format/snapshots/bytecode_format__bytecode_display_expanded.snap # baml_language/crates/baml_tests/tests/bytecode_format/snapshots/bytecode_format__bytecode_display_expanded_unoptimized.snap # baml_language/crates/baml_tests/tests/bytecode_format/snapshots/bytecode_format__bytecode_display_textual.snap
Why
baml testneeds a cheap default when a project also contains HTTP, LLM, or other expensive tests. BAML should not invent magic categories such asllmorintegration; projects should choose their own grouping conventions.A profile is a named preset argument vector for
baml test, using the same syntax taught bybaml test --help.Selector model
Every test has a canonical, project-local ID beginning with
root:root::smokeroot.orders::integration::creates_orderroot.orders.ChargeCard::declined_cardSelectors are case-sensitive and operate on the full ID:
*is a substring filter, so-i hellofinds every ID containinghello.*is an anchored glob, so-i 'root.orders::*'selects the orders namespace.This keeps common commands natural for humans and models while retaining explicit structural patterns for saved profiles. There is no special
llmtag, test annotation, or selector function in this version.Profiles and precedence
Profile
argsare parsed by the realbaml testCLI parser without shell expansion. Direct scalar options such as--coloroverride profile scalar options. Profile args cannot contain bootstrap options that resolve the profile itself:--profile,--no-profile,--from, or--help.If
[test].defaultis absent, plainbaml testcontinues to run all tests.IDs, output, and compatibility
Canonical hierarchy uses
.for BAML namespace/function ownership and::for testset/test nesting.baml test --listis the source of truth and its IDs are reused inPASS,FAIL, andTOLERATEDresult lines. Runner-only verdicts are labeledAGGREGATE.This intentionally replaces legacy slash-shaped structural selectors. Unambiguous old selectors receive an actionable
::migration suggestion, while literal/remains legal inside names.TestSetReport.result_namesis optional so existing custom testset runners remain source-compatible. Older runners that execute only part of a selection without returning identities no longer fabricate PASS lines for skipped leaves.Safety and performance
Lazy testsets are pruned before their collectors run whenever either the profile or explicit CLI filters prove that the subtree cannot contribute a selected test. This prevents excluded collectors from making HTTP/LLM calls or other side effects. Plain substring exclusions can also prune a subtree when the substring is already present in its canonical prefix.
Filtered discovery never repopulates an unfiltered cache, expansion failures are not cached, and invalid dynamic names containing reserved
::surface as discovery errors. The discovery-cache payload carries canonical IDs, intentionally invalidating old cached payloads through its serialized shape.Review fixes
The follow-up review fixes:
root,root., orroot::prefix during slash-migration validation;The CLI discovery path already propagates invalid dynamic test names before execution. Re-throwing from the lazy test child thunk would violate its
throws nevercontract, so that CodeRabbit suggestion was intentionally not applied.Testing
cargo test -p baml_cli --lib: 390/390cargo test -p baml_cli --test test_profiles_e2e -- --test-threads=1: 9/9cargo clippy -p baml_cli --all-targets --all-features -- -D warningsReview process
An implementation agent completed the first pass. A separate adversarial agent received only the specification and exercised the feature as a user. Its initial no-ship findings around lazy pruning, dynamic names, caching, literal slashes, parser/help behavior, and console identities were fixed and retested before this PR was opened.
Summary by CodeRabbit
New Features
baml.toml[test]/[test.profiles.*], including profile defaulting andargs.root::...test identifiers across listing, filtering, execution, and caching.Bug Fixes
PASS,TOLERATED,FAIL) with correct skipped-leaf and tolerant aggregation behavior./-style selectors.CLI
baml test --color alwaysbehavior and refreshed help/keyword rendering.Documentation