Skip to content

stdlib similarity matrix - #4337

Merged
2kai2kai2 merged 16 commits into
canaryfrom
kai/stdlib-similarity-matrix
Aug 6, 2026
Merged

stdlib similarity matrix#4337
2kai2kai2 merged 16 commits into
canaryfrom
kai/stdlib-similarity-matrix

Conversation

@2kai2kai2

@2kai2kai2 2kai2kai2 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Compares the baml standard library with typescript and creates a comparison table.
Also serves as an initial human-readable web reference for the baml package.

Summary by CodeRabbit

  • New Features
    • Added an interactive BAML and TypeScript standard-library comparison report.
    • Browse grouped symbols, signatures, documentation, matches, missing counterparts, references, provenance, and generic bounds.
    • Added expandable sections, keyboard navigation, cross-language links, URL-addressable views, and light/dark styling.
    • Added automated report generation, validation, incremental updates, baseline comparisons, alignment, and hosted publishing.
  • Documentation
    • Added usage, development, build, validation, and publishing guidance.
  • Tests
    • Added comprehensive coverage for extraction, matching, reporting, navigation, validation, and alignment workflows.

@vercel

vercel Bot commented Aug 6, 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 Aug 6, 2026 11:30pm
promptfiddle2 Ready Ready Preview Aug 6, 2026 11:30pm

Request Review

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds a BAML–TypeScript standard-library matrix pipeline. It extracts symbols, aligns them with model-assisted passes, reuses prior judgements, renders reports, publishes them to GitHub Pages, and provides an interactive Lit-based web application.

Changes

Exported surface contract

Layer / File(s) Summary
Surface export identity and metadata
baml_language/crates/baml_surface/src/export.rs, baml_language/crates/baml_surface/src/facts.rs, baml_language/crates/baml_surface/src/handles.rs, baml_language/crates/baml_surface/src/export_tests.rs
Exports effective throws types, declaration ownership, impl-qualified method IDs, interface fields, generic parameters, bounds, and associated types. Tests verify exported ID uniqueness and the updated metadata.

Stdlib matrix pipeline

Layer / File(s) Summary
Surface ingestion and symbol extraction
tools/stdlib-matrix/baml_src/models.baml, tools/stdlib-matrix/baml_src/ingest.baml, tools/stdlib-matrix/baml_src/symbols.baml, tools/stdlib-matrix/baml_src/ts_symbols.baml, tools/stdlib-matrix/baml_src/references.baml, tools/stdlib-matrix/extractors/ts-surface.mjs
Loads versioned surface JSON, extracts BAML and TypeScript symbols, normalizes signatures, and resolves references.
Matrix construction and revision handling
tools/stdlib-matrix/baml_src/report.baml, tools/stdlib-matrix/baml_src/pools.baml, tools/stdlib-matrix/baml_src/revision.baml, tools/stdlib-matrix/baml_src/ratchet.baml, tools/stdlib-matrix/baml_src/render.baml
Builds deterministic candidate pools and reports, compares baselines, carries forward compatible judgements, and renders Markdown output.
Alignment and CLI orchestration
tools/stdlib-matrix/baml_src/align.baml, tools/stdlib-matrix/baml_src/entry.baml, tools/stdlib-matrix/run, tools/stdlib-matrix/baml_src/tests.baml
Adds proposal, reverse sweep, verification, concurrency control, command-line execution, artifact writing, and comprehensive tests.

Publishing workflow and web application

Layer / File(s) Summary
GitHub Pages publishing
.github/workflows/stdlib-matrix.yml, tools/stdlib-matrix/README.md, tools/stdlib-matrix/baml.toml, .gitignore, .baml/.gitignore, tools/stdlib-matrix/.gitignore
Adds incremental and forced report publishing after releases or manual dispatches. Generated outputs and local caches are ignored.
Interactive matrix report
typescript2/app-stdlib-matrix/*, typescript2/app-stdlib-matrix/src/*
Adds a Lit application with grouped symbols, signatures, judgements, provenance, loading states, and BAML–TypeScript navigation.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Release as Release or manual dispatch
  participant Workflow as stdlib-matrix workflow
  participant Extractor as Surface extractors
  participant Matrix as Matrix builder
  participant Aligner as Alignment passes
  participant App as Matrix web application
  participant Pages as GitHub Pages

  Release->>Workflow: Trigger matrix workflow
  Workflow->>Extractor: Extract BAML and TypeScript surfaces
  Extractor-->>Matrix: Return versioned symbol inputs
  Matrix->>Aligner: Submit proposal, sweep, and verification requests
  Aligner-->>Matrix: Return judgements and failures
  Matrix-->>Workflow: Produce matrix.json and matrix.md
  Workflow->>Pages: Build and deploy report site
  App->>Pages: Load matrix.json
  Pages-->>App: Return matrix report
  App-->>App: Render grouped symbols and navigation
Loading

Possibly related PRs

  • BoundaryML/baml#4011: Shared compiler surface changes around interface exports and generic metadata.
  • BoundaryML/baml#4203: Related type-argument and associated-type handling affects exported metadata consumed by the matrix.
  • BoundaryML/baml#4258: Related function metadata changes overlap with the exported throws representation.

Poem

A rabbit maps each type with care,
Through BAML paths and TypeScript air.
Reports align and pages glow,
While linked symbols guide the flow.
Each judgement hops into its place,
With carrots kept for every case.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 48.89% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: adding a standard-library similarity matrix.
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 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch kai/stdlib-similarity-matrix

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 August 6, 2026 21:21 Inactive
@2kai2kai2
2kai2kai2 enabled auto-merge August 6, 2026 21:24

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

🧹 Nitpick comments (9)
typescript2/app-stdlib-matrix/src/components/matrix-symbol.ts (3)

58-65: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

SWATCH.unjudgedTs is never returned.

The swatch getter returns SWATCH.ts for the TypeScript side without a further test at Line 167, and the comment above it explains that the TypeScript side has no unjudged state. The unjudgedTs entry is therefore unreachable. Remove it, and remove the matching CSS class if src/index.css defines swatch-unjudged-ts only for this entry.

🤖 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 `@typescript2/app-stdlib-matrix/src/components/matrix-symbol.ts` around lines
58 - 65, Remove the unreachable SWATCH.unjudgedTs entry from the SWATCH
constant, and delete the matching swatch-unjudged-ts CSS class if it exists
solely for this entry. Preserve the existing TypeScript swatch behavior in the
swatch getter.

34-49: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

The four-state swatch doc comment is attached to the wrong declaration.

The block comment at Lines 34-43 describes the swatch states, but the declaration that follows it is SECTION, which has its own doc comment at Line 44. The swatch text therefore documents nothing. Move it above SWATCH at Line 58, or above the swatch getter at Line 155.

🤖 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 `@typescript2/app-stdlib-matrix/src/components/matrix-symbol.ts` around lines
34 - 49, Move the four-state swatch documentation comment from above SECTION to
the SWATCH declaration or the swatch getter, so it documents the swatch states
rather than the section-heading helper. Keep SECTION associated only with its
existing heading comment.

341-349: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Replace the linear counterpart lookup with an id index.

Line 347 scans the whole matrix.ts or matrix.baml array for each counterpart. This runs on every render of every open row, so the cost grows with the number of open rows multiplied by the surface size. SymbolIndex is already memoized per report and types.ts already builds id-to-index maps, so an exposed id-to-index lookup removes the scan.

Add an indexOfId(side, id) accessor to SymbolIndex, then use it here in place of findIndex.

🤖 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 `@typescript2/app-stdlib-matrix/src/components/matrix-symbol.ts` around lines
341 - 349, Expose an indexOfId(side, id) accessor on the memoized SymbolIndex,
reusing the existing id-to-index maps built in types.ts. Update matrix-symbol.ts
counterpart to obtain the counterpart index through SymbolIndex.indexOfId
instead of scanning the selected symbols array with findIndex, while preserving
the existing missing-symbol nothing behavior.
tools/stdlib-matrix/baml_src/report.baml (1)

308-319: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider removing the duplicated defaults and guard.

build_matrix_v2 repeats the default data paths and the baml_surface_sha256 guard that build_matrix in tools/stdlib-matrix/baml_src/entry.baml already declares. If a path changes, the two entry points can diverge. Extract the defaults and the guard into one helper, or let build_matrix_v2 delegate to a shared function.

🤖 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 `@tools/stdlib-matrix/baml_src/report.baml` around lines 308 - 319, Refactor
build_matrix_v2 to reuse the existing defaults and baml_surface_sha256
validation from build_matrix instead of duplicating them. Extract the shared
setup into a helper or delegate both entry points through one shared function,
preserving the required-hash guard and ensuring both entry points use the same
data-path defaults.
typescript2/app-stdlib-matrix/src/types.ts (1)

243-262: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider making buildGroups reject a side/array mismatch at compile time.

side and symbols are independent parameters, and the body casts on the value of side (Lines 256, 268). A call that passes 'ts' with matrix.baml type-checks and then misgroups every row. Function overloads, or a single discriminated parameter object, would make the pairing checkable.

♻️ Proposed signature
+export function buildGroups(
+  side: 'baml',
+  symbols: BamlSymbol[],
+): Array<[string, TreeNode[]]>;
+export function buildGroups(
+  side: 'ts',
+  symbols: TsSymbol[],
+): Array<[string, TreeNode[]]>;
 export function buildGroups(
   side: Side,
   symbols: Array<BamlSymbol | TsSymbol>,
 ): Array<[string, TreeNode[]]> {
🤖 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 `@typescript2/app-stdlib-matrix/src/types.ts` around lines 243 - 262, Update
buildGroups so the side discriminator is type-linked to the symbols array,
preventing 'ts' from accepting BamlSymbol[] and vice versa. Use overloads or a
discriminated parameter object while preserving the existing grouping behavior
and return type for valid pairings.
tools/stdlib-matrix/baml_src/pools.baml (2)

242-247: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider tying ts_keys to ts_symbols at the call boundary.

build_pool_with_keys pairs ts_keys to ts_symbols by position at Line 263. A caller that passes keys computed from a different array produces silently wrong pools, because at(index) ?? "" hides the mismatch. Add a length check, or pass pre-zipped pairs.

🤖 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 `@tools/stdlib-matrix/baml_src/pools.baml` around lines 242 - 247, Update
build_pool_with_keys so ts_keys and ts_symbols cannot be mismatched: validate
that both arrays have equal lengths at the call boundary and reject mismatches
before positional pairing, or change the API to accept pre-zipped symbol/key
pairs. Do not rely on the existing at(index) fallback to conceal invalid input.

262-283: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Stop the member-key scan after the first shared stem.

The loop at Line 269 keeps iterating over every member key after shares becomes true. The file documents that this comparison is the hot path, so the wasted iterations matter for the 183-owner pass.

♻️ Proposed change
         let shares = false;
         for (let member_key in member_keys) {
-            if (!shares && stems_share(member_key, key)) {
+            if (stems_share(member_key, key)) {
                 shares = true;
+                break;
             }
         }

Confirm that break is available in BAML for loops; if it is not, keep the guard as written.

🤖 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 `@tools/stdlib-matrix/baml_src/pools.baml` around lines 262 - 283, Update the
inner member_keys loop in the symbol-processing flow to stop immediately after
stems_share(member_key, key) sets shares to true by adding a break if BAML for
loops support it; otherwise preserve the existing guarded scan.
tools/stdlib-matrix/baml_src/align.baml (1)

835-848: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Count rulings that match no pairing.

apply_rulings indexes every ruling by baml\u{1f}ts, then only consults the index while walking matrix.judgements. A ruling that names a pair the matrix does not hold is dropped silently. AlignOutcome.rejected is returned empty at Line 899, so verify-pass drift produces no count, unlike apply_proposals and apply_sweep. The file header states that an inventing prompt shows up as a count.

Track the keys that were consumed and report the rest.

♻️ Proposed change
     let upheld = 0;
     let refuted = 0;
+    let used: map<string, bool> = {};
     let kept: Judgement[] = [];
     for (let judgement in matrix.judgements) {
         let key = `${judgement.baml}\u{1f}${judgement.ts ?? ""}`;
         match (rulings.get(key)) {
             null => {
                 kept.push(judgement);
             },
             let ruling: Ruling => {
+                let _ = used.set(key, true);

Then build the returned rejected list from the ruling keys absent from used, and pass it in place of [] at Line 899.

🤖 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 `@tools/stdlib-matrix/baml_src/align.baml` around lines 835 - 848, Update
apply_rulings to track ruling keys consumed while processing matrix.judgements,
then build AlignOutcome.rejected from indexed ruling keys absent from that used
set. Replace the empty rejected list returned near the function’s outcome
construction, preserving existing failure and matched-ruling handling.
tools/stdlib-matrix/baml_src/symbols.baml (1)

350-372: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

The required-method and default-method distinction is dropped.

Line 353 concatenates item.methods, item.required_methods, and item.default_methods into one loop. Every entry is emitted with origin: origin_of_method(...), which yields only method or static_method. A consumer cannot then tell a required interface method from an inherited default or from a class's inherent method.

The export layer preserves this distinction deliberately: export.rs keeps required_methods and default_methods as separate fields, and FunctionExport.from_default flags an inherited default. models.baml decodes ExportImplMethod.from_default at Line 124, but no provided file reads it. Consider extending the origin vocabulary, or recording from_default on BamlSymbol, so the report keeps the facet the export supplies.

🤖 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 `@tools/stdlib-matrix/baml_src/symbols.baml` around lines 350 - 372, Preserve
required/default method provenance in the symbol generation loop around methods,
required_methods, and default_methods instead of emitting all entries through
origin_of_method alone. Use the export metadata, including
ExportImplMethod.from_default, to distinguish inherent, required, and inherited
default methods in BamlSymbol while retaining existing method origin behavior.
🤖 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 @.github/workflows/stdlib-matrix.yml:
- Around line 61-64: Add the conditional ref configuration to the Checkout step,
using github.event.workflow_run.head_sha for workflow_run events and github.sha
otherwise, while preserving persist-credentials: false.

In `@baml_language/crates/baml_surface/src/export_tests.rs`:
- Around line 51-57: Update the census key list in the export-tests uniqueness
check to include "default_methods" alongside the existing interface member keys.
Preserve the invariant that every exported id is counted exactly once, including
ids from ItemDetail::Interface default methods.

In `@tools/stdlib-matrix/baml_src/ratchet.baml`:
- Around line 94-100: Update compare_to_baseline so body_differs reflects
changes beyond count totals, including judgement relations, reasons, or
divergences; compare the complete report body against the baseline while
excluding provenance and other input metadata. Preserve the existing advisory
behavior for identical inputs whose report contents changed.

In `@tools/stdlib-matrix/baml_src/surface.baml`:
- Around line 45-62: Update normalize_ty_display so nominal BAML type heads are
normalized within composite displays, including arrays, optionals, and nested
map key/value types, rather than only when the entire display matches a known
name. Preserve unknown structure and existing generic formatting, and ensure
names such as baml.String and baml.Uint8Array normalize wherever they appear.

In `@tools/stdlib-matrix/baml_src/symbols.baml`:
- Around line 180-182: Preserve parameter declaration order by retaining and
iterating the ordered sig.params collection in the rendering logic, using kwargs
only to look up each parameter’s value; update both
tools/stdlib-matrix/baml_src/symbols.baml:180-182 and
tools/stdlib-matrix/baml_src/references.baml:231-233 accordingly so optional
parameters and referenced text follow the original signature order.

In `@tools/stdlib-matrix/baml_src/ts_symbols.baml`:
- Around line 36-46: Update ts_origin_of to test ts_is_callable(member) before
member.static so static non-callable members are classified as property while
static callable members remain static_method. Then adjust ts_id_of to receive
member.static and determine prototype addressing from staticness rather than
origin, preserving correct IDs for static properties.

In `@tools/stdlib-matrix/extractors/ts-surface.mjs`:
- Around line 31-35: Remove the redundant "PromiseConstructor" entry from
ECMA_CONTAINERS; keep "Promise" so walkLibFile continues folding the constructor
twin into the Promise container and scope.ecma reports only containers that are
actually compared.
- Around line 74-76: Validate the --repo-root option in the argument parsing
before calling path.resolve: when --repo-root is present without a following
value, report a clear usage error and terminate instead of passing undefined to
path.resolve. Preserve the default "." root behavior when the flag is absent,
using the existing CLI entrypoint’s error-handling convention.
- Around line 152-172: Ensure member metadata records the earliest introducing
lib rather than the first lexicographically visited file. Update addMember to
revise entry.since when a later declaration has an earlier lib rank, and add the
necessary lib-version ranking near sinceOf; preserve the existing
declaration-merging and signature behavior.
- Around line 253-258: Update the declaration-file discovery loop around
walkNodeModuleFile to record each expected `@types/node` file that is missing, and
expose those skipped paths in the generated document scope. Preserve processing
for existing files, and ensure consumers can distinguish skipped declarations
from declarations that were read but matched nothing.
- Around line 272-285: Replace the locale-dependent localeCompare comparators in
the container and member sorts within the document construction flow with
locale-independent string ordering, consistent with the existing bare sort
calls. Preserve the secondary static-member ordering and all other output fields
unchanged.

In `@tools/stdlib-matrix/README.md`:
- Around line 41-44: Update the --check description in the README to state that
it refreshes the data/ directory for a later --skip-extract build while
comparing only report inputs, including the stdlib content hash and TypeScript
release; remove the claim that it writes nothing and retain the existing
exit-status behavior.

In `@tools/stdlib-matrix/run`:
- Around line 219-231: Add combination validation near the existing option
checks to reject --check when combined with --llm or --concurrency, before the
target-selection logic. Ensure the validation exits with a clear error
consistent with other unusable combinations, while leaving independent --check
behavior unchanged.
- Around line 245-251: Keep the raw-result artifact-writing block involving
raw_result, mkdir, and cp inside the non-check else branch so --check continues
writing nothing, while preserving the existing artifact path and remaining
check-mode behavior.

In `@typescript2/app-stdlib-matrix/package.json`:
- Around line 7-20: Update the typecheck script in package.json to remove the
incompatible --noEmit flag from the tsc -b command. Configure noEmit in the
referenced tsconfig.json files so project-reference typechecking remains
emit-free while preserving the existing build script.

In `@typescript2/app-stdlib-matrix/README.md`:
- Around line 10-13: Restrict the src handling in
MatrixAppElement.connectedCallback() and `#load`() to relative same-origin report
paths before calling fetch(), rejecting absolute URLs and external origins while
preserving the default ./matrix.json and named report-file cases. Update the
README usage text to document that ?src= accepts only relative same-origin
paths.

In `@typescript2/app-stdlib-matrix/src/components/matrix-app.ts`:
- Line 84: Update disconnectedCallback to remove the GOTO_EVENT listener
registered by connectedCallback, using the same this.#onGoto reference and
EventListener cast as the addEventListener call. Ensure reconnecting the element
does not accumulate handlers while preserving the existing window-listener
cleanup.

In `@typescript2/app-stdlib-matrix/src/index.css`:
- Line 5: Update the Stylelint configuration for index.css so Tailwind v4
at-rules such as `@theme` and `@utility` are recognized without lint errors. Either
configure the file to use CSS syntax or extend scss/at-rule-no-unknown with the
required Tailwind directives, including theme, utility, source, apply, variant,
and custom-variant.

In `@typescript2/app-stdlib-matrix/src/signature.ts`:
- Around line 162-181: Update typeName’s generic-argument parsing so it does not
split on commas nested inside angle brackets. Track angle-bracket depth while
scanning the substring between the outer brackets, splitting only when depth is
zero, and preserve the existing rendering for each top-level argument.
- Around line 82-104: Update activate so the modifier-key check occurs before
event.preventDefault(): unmodified anchor activation must preserve the href
fragment navigation for keyboard Enter while modified clicks still prevent
default, stop propagation, and call dispatchGoto. Keep the existing row-click
behavior outside the anchor unchanged.

---

Nitpick comments:
In `@tools/stdlib-matrix/baml_src/align.baml`:
- Around line 835-848: Update apply_rulings to track ruling keys consumed while
processing matrix.judgements, then build AlignOutcome.rejected from indexed
ruling keys absent from that used set. Replace the empty rejected list returned
near the function’s outcome construction, preserving existing failure and
matched-ruling handling.

In `@tools/stdlib-matrix/baml_src/pools.baml`:
- Around line 242-247: Update build_pool_with_keys so ts_keys and ts_symbols
cannot be mismatched: validate that both arrays have equal lengths at the call
boundary and reject mismatches before positional pairing, or change the API to
accept pre-zipped symbol/key pairs. Do not rely on the existing at(index)
fallback to conceal invalid input.
- Around line 262-283: Update the inner member_keys loop in the
symbol-processing flow to stop immediately after stems_share(member_key, key)
sets shares to true by adding a break if BAML for loops support it; otherwise
preserve the existing guarded scan.

In `@tools/stdlib-matrix/baml_src/report.baml`:
- Around line 308-319: Refactor build_matrix_v2 to reuse the existing defaults
and baml_surface_sha256 validation from build_matrix instead of duplicating
them. Extract the shared setup into a helper or delegate both entry points
through one shared function, preserving the required-hash guard and ensuring
both entry points use the same data-path defaults.

In `@tools/stdlib-matrix/baml_src/symbols.baml`:
- Around line 350-372: Preserve required/default method provenance in the symbol
generation loop around methods, required_methods, and default_methods instead of
emitting all entries through origin_of_method alone. Use the export metadata,
including ExportImplMethod.from_default, to distinguish inherent, required, and
inherited default methods in BamlSymbol while retaining existing method origin
behavior.

In `@typescript2/app-stdlib-matrix/src/components/matrix-symbol.ts`:
- Around line 58-65: Remove the unreachable SWATCH.unjudgedTs entry from the
SWATCH constant, and delete the matching swatch-unjudged-ts CSS class if it
exists solely for this entry. Preserve the existing TypeScript swatch behavior
in the swatch getter.
- Around line 34-49: Move the four-state swatch documentation comment from above
SECTION to the SWATCH declaration or the swatch getter, so it documents the
swatch states rather than the section-heading helper. Keep SECTION associated
only with its existing heading comment.
- Around line 341-349: Expose an indexOfId(side, id) accessor on the memoized
SymbolIndex, reusing the existing id-to-index maps built in types.ts. Update
matrix-symbol.ts counterpart to obtain the counterpart index through
SymbolIndex.indexOfId instead of scanning the selected symbols array with
findIndex, while preserving the existing missing-symbol nothing behavior.

In `@typescript2/app-stdlib-matrix/src/types.ts`:
- Around line 243-262: Update buildGroups so the side discriminator is
type-linked to the symbols array, preventing 'ts' from accepting BamlSymbol[]
and vice versa. Use overloads or a discriminated parameter object while
preserving the existing grouping behavior and return type for valid pairings.
🪄 Autofix

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: 47ea9850-1313-4837-bbed-9fbc1d12a3ca

📥 Commits

Reviewing files that changed from the base of the PR and between 3c7e27f and 39227c8.

⛔ Files ignored due to path filters (2)
  • baml_language/crates/baml_surface/src/snapshots/baml_surface__export_tests__assert_package_exports_fully.snap is excluded by !**/*.snap
  • typescript2/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (40)
  • .baml/.gitignore
  • .github/workflows/stdlib-matrix.yml
  • .gitignore
  • baml_language/crates/baml_surface/src/export.rs
  • baml_language/crates/baml_surface/src/export_tests.rs
  • baml_language/crates/baml_surface/src/facts.rs
  • baml_language/crates/baml_surface/src/handles.rs
  • tools/stdlib-matrix/.gitignore
  • tools/stdlib-matrix/README.md
  • tools/stdlib-matrix/baml.toml
  • tools/stdlib-matrix/baml_src/align.baml
  • tools/stdlib-matrix/baml_src/entry.baml
  • tools/stdlib-matrix/baml_src/ingest.baml
  • tools/stdlib-matrix/baml_src/models.baml
  • tools/stdlib-matrix/baml_src/pools.baml
  • tools/stdlib-matrix/baml_src/ratchet.baml
  • tools/stdlib-matrix/baml_src/references.baml
  • tools/stdlib-matrix/baml_src/render.baml
  • tools/stdlib-matrix/baml_src/report.baml
  • tools/stdlib-matrix/baml_src/revision.baml
  • tools/stdlib-matrix/baml_src/surface.baml
  • tools/stdlib-matrix/baml_src/symbols.baml
  • tools/stdlib-matrix/baml_src/tests.baml
  • tools/stdlib-matrix/baml_src/ts_symbols.baml
  • tools/stdlib-matrix/extractors/ts-surface.mjs
  • tools/stdlib-matrix/run
  • typescript2/app-stdlib-matrix/.gitignore
  • typescript2/app-stdlib-matrix/README.md
  • typescript2/app-stdlib-matrix/index.html
  • typescript2/app-stdlib-matrix/package.json
  • typescript2/app-stdlib-matrix/src/components/matrix-app.ts
  • typescript2/app-stdlib-matrix/src/components/matrix-group.ts
  • typescript2/app-stdlib-matrix/src/components/matrix-symbol.ts
  • typescript2/app-stdlib-matrix/src/index.css
  • typescript2/app-stdlib-matrix/src/main.ts
  • typescript2/app-stdlib-matrix/src/navigation.ts
  • typescript2/app-stdlib-matrix/src/signature.ts
  • typescript2/app-stdlib-matrix/src/types.ts
  • typescript2/app-stdlib-matrix/tsconfig.json
  • typescript2/app-stdlib-matrix/vite.config.ts

Comment thread .github/workflows/stdlib-matrix.yml Outdated
Comment thread baml_language/crates/baml_surface/src/export_tests.rs
Comment thread tools/stdlib-matrix/baml_src/ratchet.baml
Comment thread tools/stdlib-matrix/baml_src/surface.baml
Comment thread tools/stdlib-matrix/baml_src/symbols.baml
Comment thread typescript2/app-stdlib-matrix/README.md
Comment thread typescript2/app-stdlib-matrix/src/components/matrix-app.ts
Comment thread typescript2/app-stdlib-matrix/src/index.css
Comment thread typescript2/app-stdlib-matrix/src/signature.ts
Comment thread typescript2/app-stdlib-matrix/src/signature.ts
@vercel
vercel Bot temporarily deployed to Preview – beps August 6, 2026 21:55 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

🤖 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 `@typescript2/app-stdlib-matrix/src/components/matrix-app.ts`:
- Around line 64-67: Update the URL resolution logic used by reportSource to
catch malformed requested values passed to new URL, including invalid src query
parameters. Return "./matrix.json" for parsing failures so connectedCallback can
continue to the existing fetch failure handling.
🪄 Autofix

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: 4c8735e3-c627-4949-8b59-e75655ceae3e

📥 Commits

Reviewing files that changed from the base of the PR and between 39227c8 and dbecda4.

📒 Files selected for processing (13)
  • .github/workflows/stdlib-matrix.yml
  • baml_language/crates/baml_surface/src/export_tests.rs
  • tools/stdlib-matrix/README.md
  • tools/stdlib-matrix/baml_src/models.baml
  • tools/stdlib-matrix/baml_src/ratchet.baml
  • tools/stdlib-matrix/baml_src/surface.baml
  • tools/stdlib-matrix/baml_src/tests.baml
  • tools/stdlib-matrix/baml_src/ts_symbols.baml
  • tools/stdlib-matrix/extractors/ts-surface.mjs
  • tools/stdlib-matrix/run
  • typescript2/app-stdlib-matrix/README.md
  • typescript2/app-stdlib-matrix/src/components/matrix-app.ts
  • typescript2/app-stdlib-matrix/src/signature.ts
🚧 Files skipped from review as they are similar to previous changes (10)
  • typescript2/app-stdlib-matrix/README.md
  • tools/stdlib-matrix/run
  • tools/stdlib-matrix/baml_src/models.baml
  • tools/stdlib-matrix/README.md
  • tools/stdlib-matrix/baml_src/ts_symbols.baml
  • baml_language/crates/baml_surface/src/export_tests.rs
  • tools/stdlib-matrix/baml_src/ratchet.baml
  • tools/stdlib-matrix/baml_src/surface.baml
  • .github/workflows/stdlib-matrix.yml
  • tools/stdlib-matrix/baml_src/tests.baml

Comment thread typescript2/app-stdlib-matrix/src/components/matrix-app.ts
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 August 6, 2026 22:02 Inactive
@2kai2kai2
2kai2kai2 disabled auto-merge August 6, 2026 22:32
@2kai2kai2
2kai2kai2 enabled auto-merge August 6, 2026 22:33
@vercel
vercel Bot temporarily deployed to Preview – beps August 6, 2026 22:56 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 August 6, 2026 23:03 Inactive
@github-actions

github-actions Bot commented Aug 6, 2026

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.

@2kai2kai2
2kai2kai2 force-pushed the kai/stdlib-similarity-matrix branch from d084258 to dcba401 Compare August 6, 2026 23:15
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@vercel
vercel Bot temporarily deployed to Preview – beps August 6, 2026 23:17 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps August 6, 2026 23:23 Inactive
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 August 6, 2026 23:30 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.

🧹 Nitpick comments (1)
typescript2/app-stdlib-matrix/src/navigation.ts (1)

123-136: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Extract the Ref equality check into one helper.

register and nameOf both compare two refs by group plus path.join(). Two copies of the same rule can drift. A single helper keeps the identity rule in one place.

♻️ Proposed refactor
+function samePlace(a: Ref, b: Ref): boolean {
+  return a.group === b.group && a.path.join() === b.path.join();
+}
+
 function register(names: NameMap, key: string, ref: Ref) {
   const existing = names.get(key);
   if (existing === undefined) {
     names.set(key, ref);
     return;
   }
   if (existing === null) return;
-  if (
-    existing.group !== ref.group ||
-    existing.path.join() !== ref.path.join()
-  ) {
-    names.set(key, null);
-  }
+  if (!samePlace(existing, ref)) names.set(key, null);
 }
     const resolved = this.resolve(side, dotted);
-    return resolved &&
-      resolved.group === place.group &&
-      resolved.path.join() === place.path.join()
-      ? dotted
-      : null;
+    return resolved && samePlace(resolved, place) ? dotted : null;

Also applies to: 301-311

🤖 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 `@typescript2/app-stdlib-matrix/src/navigation.ts` around lines 123 - 136,
Extract the shared Ref identity comparison used by register and nameOf into a
single helper that compares group and path.join(). Replace both inline
comparisons with this helper, preserving the existing name registration and
lookup behavior.
🤖 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.

Nitpick comments:
In `@typescript2/app-stdlib-matrix/src/navigation.ts`:
- Around line 123-136: Extract the shared Ref identity comparison used by
register and nameOf into a single helper that compares group and path.join().
Replace both inline comparisons with this helper, preserving the existing name
registration and lookup behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 83f583be-b88a-428f-a033-2409a1a5e7b2

📥 Commits

Reviewing files that changed from the base of the PR and between 3c7e27f and 9943142.

⛔ Files ignored due to path filters (2)
  • baml_language/crates/baml_surface/src/snapshots/baml_surface__export_tests__assert_package_exports_fully.snap is excluded by !**/*.snap
  • typescript2/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (40)
  • .baml/.gitignore
  • .github/workflows/stdlib-matrix.yml
  • .gitignore
  • baml_language/crates/baml_surface/src/export.rs
  • baml_language/crates/baml_surface/src/export_tests.rs
  • baml_language/crates/baml_surface/src/facts.rs
  • baml_language/crates/baml_surface/src/handles.rs
  • tools/stdlib-matrix/.gitignore
  • tools/stdlib-matrix/README.md
  • tools/stdlib-matrix/baml.toml
  • tools/stdlib-matrix/baml_src/align.baml
  • tools/stdlib-matrix/baml_src/entry.baml
  • tools/stdlib-matrix/baml_src/ingest.baml
  • tools/stdlib-matrix/baml_src/models.baml
  • tools/stdlib-matrix/baml_src/pools.baml
  • tools/stdlib-matrix/baml_src/ratchet.baml
  • tools/stdlib-matrix/baml_src/references.baml
  • tools/stdlib-matrix/baml_src/render.baml
  • tools/stdlib-matrix/baml_src/report.baml
  • tools/stdlib-matrix/baml_src/revision.baml
  • tools/stdlib-matrix/baml_src/surface.baml
  • tools/stdlib-matrix/baml_src/symbols.baml
  • tools/stdlib-matrix/baml_src/tests.baml
  • tools/stdlib-matrix/baml_src/ts_symbols.baml
  • tools/stdlib-matrix/extractors/ts-surface.mjs
  • tools/stdlib-matrix/run
  • typescript2/app-stdlib-matrix/.gitignore
  • typescript2/app-stdlib-matrix/README.md
  • typescript2/app-stdlib-matrix/index.html
  • typescript2/app-stdlib-matrix/package.json
  • typescript2/app-stdlib-matrix/src/components/matrix-app.ts
  • typescript2/app-stdlib-matrix/src/components/matrix-group.ts
  • typescript2/app-stdlib-matrix/src/components/matrix-symbol.ts
  • typescript2/app-stdlib-matrix/src/index.css
  • typescript2/app-stdlib-matrix/src/main.ts
  • typescript2/app-stdlib-matrix/src/navigation.ts
  • typescript2/app-stdlib-matrix/src/signature.ts
  • typescript2/app-stdlib-matrix/src/types.ts
  • typescript2/app-stdlib-matrix/tsconfig.json
  • typescript2/app-stdlib-matrix/vite.config.ts
🚧 Files skipped from review as they are similar to previous changes (35)
  • tools/stdlib-matrix/extractors/ts-surface.mjs
  • typescript2/app-stdlib-matrix/README.md
  • tools/stdlib-matrix/baml.toml
  • typescript2/app-stdlib-matrix/.gitignore
  • baml_language/crates/baml_surface/src/handles.rs
  • tools/stdlib-matrix/baml_src/render.baml
  • typescript2/app-stdlib-matrix/src/main.ts
  • baml_language/crates/baml_surface/src/facts.rs
  • baml_language/crates/baml_surface/src/export_tests.rs
  • typescript2/app-stdlib-matrix/vite.config.ts
  • typescript2/app-stdlib-matrix/tsconfig.json
  • typescript2/app-stdlib-matrix/src/components/matrix-app.ts
  • .gitignore
  • tools/stdlib-matrix/baml_src/models.baml
  • typescript2/app-stdlib-matrix/package.json
  • tools/stdlib-matrix/baml_src/ratchet.baml
  • typescript2/app-stdlib-matrix/src/components/matrix-group.ts
  • baml_language/crates/baml_surface/src/export.rs
  • typescript2/app-stdlib-matrix/src/types.ts
  • tools/stdlib-matrix/run
  • tools/stdlib-matrix/baml_src/revision.baml
  • tools/stdlib-matrix/baml_src/ingest.baml
  • typescript2/app-stdlib-matrix/src/signature.ts
  • typescript2/app-stdlib-matrix/index.html
  • tools/stdlib-matrix/baml_src/align.baml
  • tools/stdlib-matrix/baml_src/references.baml
  • .baml/.gitignore
  • typescript2/app-stdlib-matrix/src/components/matrix-symbol.ts
  • tools/stdlib-matrix/baml_src/symbols.baml
  • tools/stdlib-matrix/baml_src/surface.baml
  • tools/stdlib-matrix/baml_src/pools.baml
  • tools/stdlib-matrix/.gitignore
  • tools/stdlib-matrix/baml_src/tests.baml
  • tools/stdlib-matrix/baml_src/entry.baml
  • tools/stdlib-matrix/baml_src/ts_symbols.baml

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

Binary size checks passed

7 passed

Artifact Platform File Gzip Gated on Baseline Delta Status
baml-cli Linux 🔒 27.8 MB 11.8 MB file 27.4 MB +387.4 KB (+1.4%) OK
packed-program Linux 🔒 18.0 MB 7.4 MB file 17.7 MB +281.6 KB (+1.6%) OK
baml-cli macOS 🔒 21.6 MB 10.3 MB file 21.3 MB +296.4 KB (+1.4%) OK
packed-program macOS 🔒 14.1 MB 6.5 MB file 13.8 MB +211.0 KB (+1.5%) OK
baml-cli Windows 🔒 23.2 MB 10.5 MB file 23.0 MB +269.7 KB (+1.2%) OK
packed-program Windows 🔒 15.0 MB 6.6 MB file 14.8 MB +210.9 KB (+1.4%) OK
bridge_wasm WASM 17.1 MB 🔒 4.7 MB gzip 4.6 MB +43.5 KB (+0.9%) 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

@2kai2kai2
2kai2kai2 added this pull request to the merge queue Aug 6, 2026
Merged via the queue into canary with commit b4a97f8 Aug 6, 2026
84 checks passed
@2kai2kai2
2kai2kai2 deleted the kai/stdlib-similarity-matrix branch August 6, 2026 23:54
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