Skip to content

Reflection + matching on futures - #4225

Merged
2kai2kai2 merged 2 commits into
canaryfrom
kai/future-reflection
Jul 27, 2026
Merged

2kai2kai2 merged 2 commits into
canaryfrom
kai/future-reflection

Conversation

@2kai2kai2

@2kai2kai2 2kai2kai2 commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Future objects now hold their return/error types. This allows us to properly reconstruct and match on the Future<T, E> type. Also fixes the use of null instead of never as the error type for infallible futures.

Summary by CodeRabbit

  • New Features
    • Spawned futures now preserve their value and error types at runtime.
    • is checks and match expressions can distinguish futures by type parameters (including through generic spawning and within arrays), with type info preserved through awaiting, reflection, and middleware.
  • Bug Fixes
    • Improved typing diagnostics and behavior when a spawn expression is incomplete.
    • Parallel test child execution no longer panics on unexpected failures.
  • Documentation
    • Expanded the type-system specification covering variance, pattern matching reachability/exhaustiveness, interfaces, and future/error contracts.

@vercel

vercel Bot commented Jul 27, 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 27, 2026 10:58pm
promptfiddle Ready Ready Preview, Comment Jul 27, 2026 10:58pm
promptfiddle2 Ready Ready Preview, Comment Jul 27, 2026 10:58pm

Request Review

@2kai2kai2
2kai2kai2 enabled auto-merge July 27, 2026 20:26
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 27, 2026 20:26 Inactive
@coderabbitai

coderabbitai Bot commented Jul 27, 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: 7fcb4279-30e1-4ca9-bda1-6159f6272270

📥 Commits

Reviewing files that changed from the base of the PR and between 26b66a0 and eec948e.

⛔ Files ignored due to path filters (23)
  • baml_language/crates/baml_tests/snapshots/baml_src/_root.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/cancel_cascade.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/cancel_token.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/defer.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/future_methods.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/future_types.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/http_server.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/spawn_basic.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/spawn_name_object.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/spawn_semantics.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/spawn_throws.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/streaming_parsing.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/streaming_sse_primitives.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/task_group.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__testing_std__/baml_tests__compiles____testing_std____03_ppir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__testing_std__/baml_tests__compiles____testing_std____04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__testing_std__/baml_tests__compiles____testing_std____04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__testing_std__/baml_tests__compiles____testing_std____06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/tests/bytecode_format/snapshots/bytecode_format__bytecode_display_expanded.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/tests/bytecode_format/snapshots/bytecode_format__bytecode_display_expanded_unoptimized.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/tests/bytecode_format/snapshots/bytecode_format__bytecode_display_textual.snap is excluded by !**/*.snap
📒 Files selected for processing (30)
  • baml_language/TYPE_SYSTEM.md
  • baml_language/crates/baml_builtins2/baml_std/testing/registry.baml
  • baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs
  • baml_language/crates/baml_compiler2_emit/src/emit.rs
  • baml_language/crates/baml_compiler2_emit/src/stack_carry.rs
  • baml_language/crates/baml_compiler2_mir/src/builder.rs
  • baml_language/crates/baml_compiler2_mir/src/ir.rs
  • baml_language/crates/baml_compiler2_mir/src/lower.rs
  • baml_language/crates/baml_compiler2_mir/src/pretty.rs
  • baml_language/crates/baml_compiler2_tir/src/builder.rs
  • baml_language/crates/baml_compiler2_tir/src/interfaces/impl_rules.rs
  • baml_language/crates/baml_tests/baml_src/ns_future_types/future_types.baml
  • baml_language/crates/baml_tests/baml_src/ns_spawn_semantics/spawn_semantics.baml
  • baml_language/crates/baml_tests/src/compiler2_tir/phase8_exceptions.rs
  • baml_language/crates/baml_tests/tests/spawn_specialization.rs
  • baml_language/crates/baml_type/src/family.rs
  • baml_language/crates/baml_type/src/lib.rs
  • baml_language/crates/baml_type/src/realized_ty.rs
  • baml_language/crates/bex_engine/src/future.rs
  • baml_language/crates/bex_engine/src/lib.rs
  • baml_language/crates/bex_engine/tests/combinators.rs
  • baml_language/crates/bex_engine/tests/middleware.rs
  • baml_language/crates/bex_heap/src/gc.rs
  • baml_language/crates/bex_vm/src/package_reflect/mod.rs
  • baml_language/crates/bex_vm/src/type_match.rs
  • baml_language/crates/bex_vm/src/vm.rs
  • baml_language/crates/bex_vm_types/src/bytecode.rs
  • baml_language/crates/bex_vm_types/src/types/future.rs
  • baml_language/crates/bex_vm_types/src/types/object.rs
  • baml_language/sdk_tests/crates/.gitignore
🚧 Files skipped from review as they are similar to previous changes (29)
  • baml_language/crates/baml_tests/baml_src/ns_spawn_semantics/spawn_semantics.baml
  • baml_language/sdk_tests/crates/.gitignore
  • baml_language/crates/baml_type/src/family.rs
  • baml_language/crates/bex_engine/tests/combinators.rs
  • baml_language/crates/baml_compiler2_tir/src/builder.rs
  • baml_language/crates/baml_compiler2_emit/src/stack_carry.rs
  • baml_language/crates/bex_vm/src/type_match.rs
  • baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs
  • baml_language/crates/baml_compiler2_tir/src/interfaces/impl_rules.rs
  • baml_language/crates/baml_builtins2/baml_std/testing/registry.baml
  • baml_language/crates/baml_tests/src/compiler2_tir/phase8_exceptions.rs
  • baml_language/crates/baml_type/src/realized_ty.rs
  • baml_language/crates/baml_compiler2_mir/src/pretty.rs
  • baml_language/crates/bex_vm_types/src/types/object.rs
  • baml_language/crates/bex_vm_types/src/bytecode.rs
  • baml_language/crates/bex_heap/src/gc.rs
  • baml_language/crates/bex_vm/src/vm.rs
  • baml_language/crates/baml_tests/tests/spawn_specialization.rs
  • baml_language/crates/baml_compiler2_emit/src/emit.rs
  • baml_language/crates/bex_vm_types/src/types/future.rs
  • baml_language/crates/baml_compiler2_mir/src/builder.rs
  • baml_language/crates/baml_type/src/lib.rs
  • baml_language/crates/bex_engine/tests/middleware.rs
  • baml_language/crates/baml_compiler2_mir/src/ir.rs
  • baml_language/crates/bex_vm/src/package_reflect/mod.rs
  • baml_language/crates/bex_engine/src/future.rs
  • baml_language/crates/baml_tests/baml_src/ns_future_types/future_types.baml
  • baml_language/crates/baml_compiler2_mir/src/lower.rs
  • baml_language/crates/bex_engine/src/lib.rs

📝 Walkthrough

Walkthrough

This change preserves Future<T, E> metadata from spawn lowering through bytecode, VM execution, heap storage, reflection, and matching. It also expands Future matching logic, updates never error contracts, adds runtime identity tests, and refines type-system documentation.

Changes

Typed Future Identity

Layer / File(s) Summary
Spawn contracts and lowering
baml_language/crates/baml_compiler2_ast/..., baml_language/crates/baml_compiler2_mir/..., baml_language/crates/baml_compiler2_tir/...
Spawn expressions and MIR terminators now carry inferred Future<T, E> templates, while incomplete spawns and synthetic lambda throws use explicit missing or invariant handling.
Future matching and compatibility
baml_language/crates/baml_compiler2_mir/src/lower.rs, baml_language/crates/baml_compiler2_emit/src/emit.rs, baml_language/crates/baml_compiler2_tir/src/builder.rs
Structural matching, tag shortcuts, overlap checks, and exhaustiveness handling distinguish Future type arguments.
Typed spawn runtime pipeline
baml_language/crates/baml_compiler2_emit/..., baml_language/crates/bex_vm_types/..., baml_language/crates/bex_vm/..., baml_language/crates/bex_engine/...
Spawn bytecode passes return/error descriptors through the VM and engine into heap futures, which expose them for concrete type reconstruction.
Throws contracts and validation
baml_language/crates/baml_builtins2/..., baml_language/crates/baml_tests/..., baml_language/crates/bex_engine/tests/..., baml_language/crates/bex_heap/...
Infallible futures and middleware use never; tests cover runtime identity, generic spawns, matching, arrays, diagnostics, GC, and bytecode snapshots.
Type-system and interface specification
baml_language/TYPE_SYSTEM.md, baml_language/crates/baml_type/..., baml_language/crates/bex_vm/..., baml_language/sdk_tests/crates/.gitignore
Documentation clarifies monomorphization, reachability, Self, throws inference, interfaces, runtime Future classification, and generated-file exclusions.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SpawnLowering
  participant BytecodeEmitter
  participant VM
  participant FutureManager
  participant HeapFuture
  participant TypeMatcher
  SpawnLowering->>BytecodeEmitter: provide Future<T, E> templates
  BytecodeEmitter->>VM: emit typed Spawn operands
  VM->>FutureManager: allocate with returns and throws
  FutureManager->>HeapFuture: store Future<T, E> metadata
  TypeMatcher->>HeapFuture: read returns and throws for is/match
Loading

Possibly related PRs

  • BoundaryML/baml#3520: Extends the BEP-034 spawn pipeline at the same compiler and bytecode seams.
  • BoundaryML/baml#3625: Established related spawn payload and VM plumbing extended here with Future<T, E> metadata.
  • BoundaryML/baml#4203: Also changes compiler pattern lowering and type-argument handling for runtime matching.

Poem

A rabbit leapt through spawn and type,
Carrying T and E just right.
Futures now reveal their hue,
Matches know which path is true.
“Never” keeps the errors light—
Hop, compile, and sleep tonight!

🚥 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 accurately summarizes the main change: futures now preserve type metadata for reflection and matching.
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 kai/future-reflection

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.

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

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 27, 2026 20:36 Inactive
@github-actions

github-actions Bot commented Jul 27, 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 +8.4 KB (+0.0%) OK
✅ packed-program Linux 🔒 17.7 MB 7.3 MB file 17.7 MB +12.6 KB (+0.1%) OK
✅ baml-cli macOS 🔒 21.2 MB 10.1 MB file 21.2 MB +32 B (+0.0%) OK
✅ packed-program macOS 🔒 13.8 MB 6.4 MB file 13.8 MB +16 B (+0.0%) OK
✅ baml-cli Windows 🔒 22.8 MB 10.3 MB file 22.8 MB +6.7 KB (+0.0%) OK
✅ packed-program Windows 🔒 14.7 MB 6.5 MB file 14.7 MB +10.5 KB (+0.1%) OK
✅ bridge_wasm WASM 16.6 MB 🔒 4.5 MB gzip 4.5 MB +3.7 KB (+0.1%) 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

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
putComment timed out

@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: 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_compiler2_tir/src/builder.rs`:
- Around line 5456-5466: The throws lookup in lower_spawn_expr must preserve
diagnostic-first behavior for malformed spawn bodies instead of panicking.
Handle non-lambda or missing spawn bodies before lambda_effective_throws lookup,
using the existing Ty::Null approximation (or equivalent prior fallback), while
retaining the side-table throws type for valid inferred lambdas.

In `@baml_language/crates/bex_heap/src/gc.rs`:
- Around line 2232-2233: Update both UnscheduledFuture fixtures in
baml_language/crates/bex_heap/src/gc.rs at lines 2232-2233 and 2786-2787,
changing their throws type from RealizedTy::null() to RealizedTy::never() so
they consistently represent Future<T, never>.

In `@baml_language/TYPE_SYSTEM.md`:
- Around line 418-423: Update the out-of-body generic implementation example to
use the existing implement<T> syntax instead of implements<T>. Also correct the
constraint identifier on line 438 to preserve the declared Bound capitalization.
- Line 70: The invalid variance example should read from the widened array `b`,
not the original `int[]` array `a`. Update the assignment on the affected line
to use `b[1]`, preserving the intended demonstration that a `string` value can
be read as `int`.
- Line 337: Update the generic type-parameter requirement wording in the
function declarations section to allow parameters that are either explicitly
specified or unambiguously inferred from function-value context. Ensure it
aligns with the following `let c: (int) -> int = foo` example while retaining
the monomorphization requirement.
🪄 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: a9f5014f-28a6-4e9b-ac0c-dd433833adfe

📥 Commits

Reviewing files that changed from the base of the PR and between 5fc67e6 and 35de669.

⛔ Files ignored due to path filters (23)
  • baml_language/crates/baml_tests/snapshots/baml_src/_root.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/cancel_cascade.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/cancel_token.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/defer.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/future_methods.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/future_types.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/http_server.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/spawn_basic.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/spawn_name_object.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/spawn_semantics.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/spawn_throws.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/streaming_parsing.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/streaming_sse_primitives.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/task_group.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__testing_std__/baml_tests__compiles____testing_std____03_ppir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__testing_std__/baml_tests__compiles____testing_std____04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__testing_std__/baml_tests__compiles____testing_std____04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__testing_std__/baml_tests__compiles____testing_std____06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/tests/bytecode_format/snapshots/bytecode_format__bytecode_display_expanded.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/tests/bytecode_format/snapshots/bytecode_format__bytecode_display_expanded_unoptimized.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/tests/bytecode_format/snapshots/bytecode_format__bytecode_display_textual.snap is excluded by !**/*.snap
📒 Files selected for processing (29)
  • baml_language/TYPE_SYSTEM.md
  • baml_language/crates/baml_builtins2/baml_std/testing/registry.baml
  • baml_language/crates/baml_compiler2_emit/src/emit.rs
  • baml_language/crates/baml_compiler2_emit/src/stack_carry.rs
  • baml_language/crates/baml_compiler2_mir/src/builder.rs
  • baml_language/crates/baml_compiler2_mir/src/ir.rs
  • baml_language/crates/baml_compiler2_mir/src/lower.rs
  • baml_language/crates/baml_compiler2_mir/src/pretty.rs
  • baml_language/crates/baml_compiler2_tir/src/builder.rs
  • baml_language/crates/baml_compiler2_tir/src/interfaces/impl_rules.rs
  • baml_language/crates/baml_tests/baml_src/ns_future_types/future_types.baml
  • baml_language/crates/baml_tests/baml_src/ns_spawn_semantics/spawn_semantics.baml
  • baml_language/crates/baml_tests/src/compiler2_tir/phase8_exceptions.rs
  • baml_language/crates/baml_tests/tests/spawn_specialization.rs
  • baml_language/crates/baml_type/src/family.rs
  • baml_language/crates/baml_type/src/lib.rs
  • baml_language/crates/baml_type/src/realized_ty.rs
  • baml_language/crates/bex_engine/src/future.rs
  • baml_language/crates/bex_engine/src/lib.rs
  • baml_language/crates/bex_engine/tests/combinators.rs
  • baml_language/crates/bex_engine/tests/middleware.rs
  • baml_language/crates/bex_heap/src/gc.rs
  • baml_language/crates/bex_vm/src/package_reflect/mod.rs
  • baml_language/crates/bex_vm/src/type_match.rs
  • baml_language/crates/bex_vm/src/vm.rs
  • baml_language/crates/bex_vm_types/src/bytecode.rs
  • baml_language/crates/bex_vm_types/src/types/future.rs
  • baml_language/crates/bex_vm_types/src/types/object.rs
  • baml_language/sdk_tests/crates/.gitignore

Comment thread baml_language/crates/bex_heap/src/gc.rs Resolved
Comment thread baml_language/TYPE_SYSTEM.md Resolved
Comment thread baml_language/TYPE_SYSTEM.md Resolved
Comment thread baml_language/TYPE_SYSTEM.md Resolved
@2kai2kai2
2kai2kai2 force-pushed the kai/future-reflection branch from 35de669 to 26b66a0 Compare July 27, 2026 21:41
@vercel
vercel Bot temporarily deployed to Preview – beps July 27, 2026 21:43 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 27, 2026 21:50 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 27, 2026 22:04 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: 1

🧹 Nitpick comments (1)
baml_language/crates/baml_tests/src/compiler2_tir/phase8_exceptions.rs (1)

994-1043: 📐 Maintainability & Code Quality | 🔵 Trivial

Run the required Rust library tests before merge.

Because this PR changes Rust code, run cargo test --lib from the workspace root.

Also applies to: 1080-1080

🤖 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_tests/src/compiler2_tir/phase8_exceptions.rs`
around lines 994 - 1043, Run the required Rust library test suite from the
workspace root with cargo test --lib, and ensure it passes before merging.

Source: Coding guidelines

🤖 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/TYPE_SYSTEM.md`:
- Around line 122-125: Update the match reachability and exhaustiveness rules
described in the documentation: guarded arms must be excluded from prior-pattern
coverage and exhaustiveness unions, but their patterns must still be checked for
provable reachability against earlier unguarded arms. Revise the wording around
`match` arm reachability and the `if`-guard behavior to distinguish these two
responsibilities.

---

Nitpick comments:
In `@baml_language/crates/baml_tests/src/compiler2_tir/phase8_exceptions.rs`:
- Around line 994-1043: Run the required Rust library test suite from the
workspace root with cargo test --lib, and ensure it passes before merging.
🪄 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: d6ab3a23-d636-48a5-8c32-e7a30f7b6c41

📥 Commits

Reviewing files that changed from the base of the PR and between 35de669 and 26b66a0.

⛔ Files ignored due to path filters (23)
  • baml_language/crates/baml_tests/snapshots/baml_src/_root.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/cancel_cascade.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/cancel_token.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/defer.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/future_methods.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/future_types.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/http_server.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/spawn_basic.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/spawn_name_object.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/spawn_semantics.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/spawn_throws.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/streaming_parsing.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/streaming_sse_primitives.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/task_group.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__testing_std__/baml_tests__compiles____testing_std____03_ppir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__testing_std__/baml_tests__compiles____testing_std____04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__testing_std__/baml_tests__compiles____testing_std____04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__testing_std__/baml_tests__compiles____testing_std____06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/tests/bytecode_format/snapshots/bytecode_format__bytecode_display_expanded.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/tests/bytecode_format/snapshots/bytecode_format__bytecode_display_expanded_unoptimized.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/tests/bytecode_format/snapshots/bytecode_format__bytecode_display_textual.snap is excluded by !**/*.snap
📒 Files selected for processing (30)
  • baml_language/TYPE_SYSTEM.md
  • baml_language/crates/baml_builtins2/baml_std/testing/registry.baml
  • baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs
  • baml_language/crates/baml_compiler2_emit/src/emit.rs
  • baml_language/crates/baml_compiler2_emit/src/stack_carry.rs
  • baml_language/crates/baml_compiler2_mir/src/builder.rs
  • baml_language/crates/baml_compiler2_mir/src/ir.rs
  • baml_language/crates/baml_compiler2_mir/src/lower.rs
  • baml_language/crates/baml_compiler2_mir/src/pretty.rs
  • baml_language/crates/baml_compiler2_tir/src/builder.rs
  • baml_language/crates/baml_compiler2_tir/src/interfaces/impl_rules.rs
  • baml_language/crates/baml_tests/baml_src/ns_future_types/future_types.baml
  • baml_language/crates/baml_tests/baml_src/ns_spawn_semantics/spawn_semantics.baml
  • baml_language/crates/baml_tests/src/compiler2_tir/phase8_exceptions.rs
  • baml_language/crates/baml_tests/tests/spawn_specialization.rs
  • baml_language/crates/baml_type/src/family.rs
  • baml_language/crates/baml_type/src/lib.rs
  • baml_language/crates/baml_type/src/realized_ty.rs
  • baml_language/crates/bex_engine/src/future.rs
  • baml_language/crates/bex_engine/src/lib.rs
  • baml_language/crates/bex_engine/tests/combinators.rs
  • baml_language/crates/bex_engine/tests/middleware.rs
  • baml_language/crates/bex_heap/src/gc.rs
  • baml_language/crates/bex_vm/src/package_reflect/mod.rs
  • baml_language/crates/bex_vm/src/type_match.rs
  • baml_language/crates/bex_vm/src/vm.rs
  • baml_language/crates/bex_vm_types/src/bytecode.rs
  • baml_language/crates/bex_vm_types/src/types/future.rs
  • baml_language/crates/bex_vm_types/src/types/object.rs
  • baml_language/sdk_tests/crates/.gitignore
🚧 Files skipped from review as they are similar to previous changes (24)
  • baml_language/crates/baml_tests/baml_src/ns_spawn_semantics/spawn_semantics.baml
  • baml_language/crates/baml_type/src/family.rs
  • baml_language/crates/baml_compiler2_mir/src/pretty.rs
  • baml_language/sdk_tests/crates/.gitignore
  • baml_language/crates/baml_tests/tests/spawn_specialization.rs
  • baml_language/crates/baml_compiler2_emit/src/stack_carry.rs
  • baml_language/crates/baml_compiler2_tir/src/interfaces/impl_rules.rs
  • baml_language/crates/bex_vm_types/src/bytecode.rs
  • baml_language/crates/baml_compiler2_tir/src/builder.rs
  • baml_language/crates/baml_builtins2/baml_std/testing/registry.baml
  • baml_language/crates/bex_engine/tests/combinators.rs
  • baml_language/crates/baml_compiler2_mir/src/ir.rs
  • baml_language/crates/bex_vm/src/package_reflect/mod.rs
  • baml_language/crates/baml_type/src/lib.rs
  • baml_language/crates/baml_compiler2_mir/src/builder.rs
  • baml_language/crates/bex_vm_types/src/types/object.rs
  • baml_language/crates/baml_compiler2_emit/src/emit.rs
  • baml_language/crates/bex_heap/src/gc.rs
  • baml_language/crates/bex_engine/src/lib.rs
  • baml_language/crates/bex_engine/tests/middleware.rs
  • baml_language/crates/baml_tests/baml_src/ns_future_types/future_types.baml
  • baml_language/crates/bex_engine/src/future.rs
  • baml_language/crates/bex_vm/src/vm.rs
  • baml_language/crates/baml_compiler2_mir/src/lower.rs

Comment thread baml_language/TYPE_SYSTEM.md Resolved
`spawn { 1 }` now has type `Future<int, never>` instead of `Future<int,
null>`. The body is infallible; while cancellation and other threading
failures are possible those are panics.
@2kai2kai2
2kai2kai2 force-pushed the kai/future-reflection branch from 26b66a0 to eec948e Compare July 27, 2026 22:37
@vercel
vercel Bot temporarily deployed to Preview – beps July 27, 2026 22:38 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 27, 2026 22:45 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 27, 2026 22:58 Inactive
@2kai2kai2
2kai2kai2 added this pull request to the merge queue Jul 27, 2026
Merged via the queue into canary with commit f4e6e3e Jul 27, 2026
81 checks passed
@2kai2kai2
2kai2kai2 deleted the kai/future-reflection branch July 27, 2026 23:18

This branch was previously deployed

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