Skip to content

feat(type-provider): add FScript export type provider with strict runtime signature checks#2

Merged
pchalamet merged 1 commit intomainfrom
feature/type-provider
Feb 26, 2026
Merged

feat(type-provider): add FScript export type provider with strict runtime signature checks#2
pchalamet merged 1 commit intomainfrom
feature/type-provider

Conversation

@pchalamet
Copy link
Contributor

@pchalamet pchalamet commented Feb 26, 2026

Summary

Adds a new MagnusOpera.FScript.TypeProvider package that projects [<export>] FScript functions into strongly-typed F# static methods.

The provider:

  • parses and type-checks scripts at compile time,
  • fails F# compilation on script parse/type errors,
  • exposes exported functions with mapped argument/return types,
  • supports runtime script replacement through a provider-level resolver,
  • enforces strict runtime signature compatibility via compile-time fingerprint checks.

Main changes

  • New project: src/FScript.TypeProvider
    • Provider.fs (type provider entry + generated members)
    • Contract.fs (type mapping, fingerprinting, serialized contract)
    • ScriptRuntime.fs (extern resolution, runtime loading, invocation, compatibility checks)
  • Runtime extraction helper: src/FScript.Runtime/ExportSignatures.fs
    • ScriptHost now reuses this shared exported-signature extraction path.
  • Solution wiring:
    • added FScript.TypeProvider and FScript.TypeProvider.Tests to FScript.sln.

Supported exported signature shapes (v1)

  • unit, int (int64), float, bool, string
  • list<T>, option<T>, tuples (2..8), map<string, T>

Unsupported exported types fail provider generation (records/unions/named types/function values/unresolved generics/non-string map keys).

Tests

Added integration coverage in tests/FScript.TypeProvider.Tests with fixture projects:

  • valid script compiles and exposes callable members,
  • compile fails on script type errors,
  • compile fails on unsupported exported signature shapes,
  • runtime override succeeds with compatible signatures and fails on signature mismatch.

Docs + release notes

  • Added spec: docs/specs/fsharp-type-provider.md
  • Updated:
    • docs/specs/README.md
    • docs/specs/embedding-fscript-language.md
    • docs/architecture/assemblies-and-roles.md
  • Updated CHANGELOG.md ([Unreleased]).

Validation

  • make build
  • make test
  • make smoke-tests

@pchalamet pchalamet merged commit 41288c1 into main Feb 26, 2026
2 checks passed
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