Skip to content

fully remove untyped signatures #52

Open

Description

@darinkishore

we need to figure out some way to have it be type checked though, which seems tricky, because we want to preserve the behavior of DSPy modules where modules can add (or mutate) fields.

other issues are examples and optimizers.

wondering if metasignature is still needed

Activity

  1. darinkishore commented on Feb 12, 2026

    @darinkishore
    CollaboratorAuthor

    Codebase audit — remaining untyped signature usage

    Where Example (untyped HashMap) still lives:

    1. Cache (utils/cache.rs):

      • Cache::get(&self, key: RawExample) — cache key is derived from Example
      • Cache::insert(&mut self, key: RawExample, ...)
      • CacheEntry { prompt: String, prediction: Prediction } — Prediction is also untyped
    2. Serialization (data/serialize.rs):

      • load_jsonl() returns Vec<Example> (untyped)
      • save_examples_as_jsonl() takes Vec<Example>
    3. Prediction (data/prediction.rs):

      • Prediction likely wraps untyped data (need to check)
    4. Macros (lib.rs):

      • field! macro emits serde_json::Value via schemars
      • sign! macro creates Predict::<__InlineSignature>::new() but doesn't wire up typed infra
    5. __macro_support re-exports schemars solely for field!

    6. Specials (core/specials.rs):

      • History, ToolCall derive schemars::JsonSchema

    schemars removal path:

    1. Migrate specials.rs to BamlType/Facet (Migrate specials.rs (History, ToolCall, NoTool) to typed architecture #72)
    2. Modernize field!/sign! to emit typed SignatureSchema (Modernize field!/sign!/hashmap! macros to emit typed SignatureSchema #73)
    3. Remove schemars from __macro_support and Cargo.toml

    Example removal path:

    1. Cache key → hash of CompletionRequest (Cache: fix key to be request-based, not Example-based #71)
    2. CacheEntry → store raw messages + BamlValue, not Prediction
    3. load_jsonl/save_examples_as_jsonl → deprecate or make generic over Serialize/Deserialize
    4. Then Example can become pub(crate) or removed entirely

    MetaSignature: probably not needed once Example is gone. The typed SignatureSchema + Facet reflection covers field mutation (optimizers already use named_parameters walker to find and mutate Predict leaves).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions