Skip to content

[codex] Facet runtime API cleanup and adapter boundary hardening - #65

Merged
darinkishore merged 1 commit into
mainfrom
codex/facet-adapter-boundary
Feb 8, 2026
Merged

[codex] Facet runtime API cleanup and adapter boundary hardening#65
darinkishore merged 1 commit into
mainfrom
codex/facet-adapter-boundary

Conversation

@darinkishore

Copy link
Copy Markdown
Collaborator

Summary

This PR performs a one-shot facet-only compatibility sweep and then hardens the long-term public API boundary based on an adversarial audit.

Primary changes:

  • Removes bamltype::compat usage from typed/runtime/macro paths.
  • Promotes schema registration internals into a dedicated core module and runtime traits module.
  • Renames adapter trait from BamlAdapter to FieldCodec.
  • Removes the public with_constraints helper and inlines constraint attachment in generated macro output.
  • Adds an explicit adapter extension namespace (bamltype::adapters) and moves adapter-oriented API there.
  • Keeps core runtime surface focused (BamlType*, conversion, rendering/parsing), with adapter hooks intentionally namespaced out of the top-level API.

Why

The repository is early-stage and not constrained by strict back-compat requirements, so this is a deliberate cleanup to avoid carrying bridge-era artifacts forward.

The adversarial audit found that leaving registry+adapter hooks as root-level core APIs would create long-term semver lock-in around internals likely to evolve. This PR incorporates the follow-up hardening to avoid that lock-in.

Detailed changes

bamltype core

  • Added crates/bamltype/src/runtime.rs for runtime traits/error types.
  • Renamed/moved registry implementation into crates/bamltype/src/schema_registry.rs (SchemaRegistry) and wired schema builder to it.
  • Added crates/bamltype/src/adapters.rs:
    • adapters::FieldCodec
    • adapters::AdapterSchemaRegistry
  • Removed crates/bamltype/src/compat.rs.
  • Updated facet_ext, convert, and schema_builder to new module boundaries.

macro integration

  • crates/dsrs-macros/src/lib.rs:
    • Stops generating bamltype::compat::* paths.
    • Inlines TypeIR constraint extension instead of using with_constraints.
    • Drops generated BamlTypeInternal::register(...) delegation.
  • crates/bamltype-derive/src/lib.rs:
    • Uses runtime_crate::adapters::FieldCodec in generated adapter hooks.

dspy-rs integration

  • Removed compat-path usage in typed interfaces and runtime code.
  • Updated root exports to canonical bamltype symbols only.

tests

  • Updated all adapter/registry path usage to bamltype::adapters::* (and corresponding facet_runtime::adapters::* paths).
  • Updated compat-path imports in macro and dspy tests.

Validation

  • cargo fmt --all
  • cargo check --workspace
  • cargo test -p bamltype --tests
  • cargo test -p dsrs_macros --tests
  • cargo test -p dspy-rs --tests
  • cargo test --workspace

All passed.

User impact

This is intentionally breaking for old compat paths and root-level adapter/registry imports. The result is a cleaner facet-native API surface and a clearer extension boundary for custom field codecs.

@darinkishore
darinkishore marked this pull request as ready for review February 8, 2026 20:02
@darinkishore
darinkishore merged commit 7fb5cdd into main Feb 8, 2026
8 of 10 checks passed
@darinkishore
darinkishore deleted the codex/facet-adapter-boundary branch February 8, 2026 20:05
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