JevGen.Policies 1.0.0-preview.3

This is a prerelease version of JevGen.Policies.
dotnet add package JevGen.Policies --version 1.0.0-preview.3
                    
NuGet\Install-Package JevGen.Policies -Version 1.0.0-preview.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="JevGen.Policies" Version="1.0.0-preview.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="JevGen.Policies" Version="1.0.0-preview.3" />
                    
Directory.Packages.props
<PackageReference Include="JevGen.Policies" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add JevGen.Policies --version 1.0.0-preview.3
                    
#r "nuget: JevGen.Policies, 1.0.0-preview.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package JevGen.Policies@1.0.0-preview.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=JevGen.Policies&version=1.0.0-preview.3&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=JevGen.Policies&version=1.0.0-preview.3&prerelease
                    
Install as a Cake Tool

JevGen

NuGet CI

Refit for typed AI decisions.

JevGen turns an ordinary C# interface into a strongly typed AI decision client at compile time. No HTTP code, no JSON, no question dictionaries, no result parsing, no runtime reflection.

public enum Department
{
    [JevOption("billing", "Invoices, payments and refunds")]
    Billing,

    [JevOption("technical", "Defects, outages and technical support")]
    Technical,

    [JevOption("sales", "Pricing and new business")]
    Sales,
}

[JevClient]
public interface ITicketAI
{
    [JevChoice("Which department should handle this ticket?")]
    Task<ChoiceResult<Department>> RouteAsync(Ticket ticket, CancellationToken cancellationToken = default);
}
builder.Services.AddJevClient<ITicketAI>();
var result = await ticketAI.RouteAsync(ticket);

if (result.Confidence >= 0.90)
{
    RouteTo(result.Value);
}

That is the whole integration. The source generator writes the implementation, the request construction, the question metadata and the result mapping.


Why the result types look like that

RouteAsync returns ChoiceResult<Department>, not Department. That is the central design decision in JevGen, and it is deliberate.

A model that answers "Billing" at 94% confidence and one that answers "Billing" at 41% confidence with most of the remaining probability on "Technical" are telling you very different things. An API that returns Department throws that away and leaves the caller unable to tell the two apart.

So JevGen preserves it:

var result = await ticketAI.RouteAsync(ticket);

result.Value                                // Department.Billing
result.Confidence                           // 0.94
result.ProbabilityOf(Department.Technical)  // 0.04

You can still opt into a bare primitive where the uncertainty genuinely has no use, but you have to say so explicitly with AllowPrimitiveResult.


Installation

dotnet add package JevGen --prerelease
dotnet add package JevGen.Providers.TypeSafe --prerelease   # or JevGen.Providers.OpenRouter

--prerelease is required: the current release is 1.0.0-preview.2, and NuGet ignores prerelease versions unless you ask for them. Pin the version instead if you prefer: --version 1.0.0-preview.2.

The source generator and analyzers flow with JevGen as analyzer assets; there is nothing else to install.

builder.Services.AddTypeSafeJev(options => options.ApiKey = configuration["TypeSafe:ApiKey"]);
builder.Services.AddJevClient<ITicketAI>();

Or through OpenRouter, which needs no early access:

builder.Services.AddOpenRouterJev(options =>
{
    options.ApiKey = configuration["OpenRouter:ApiKey"];
    options.Model = JevModel.Latest;                    // ~typesafe/jev-latest
    // options.Model = "typesafe/jev-1.13-20260917";    // or pin a build
});

builder.Services.AddJevClient<ITicketAI>().UseOpenRouter();

Jev is a decisions model, so it is served on its own endpoint rather than through chat/completions — the provider handles that. See provider configuration for the endpoints each host uses and the identifiers JevModel.Latest resolves to.


What you get

Compile-time contracts Twenty-one diagnostics catch malformed contracts before you run them
One state, many questions [JevEvaluate] issues every question in a single request
Provider independence The same contract runs on TypeSafe, OpenRouter, a gateway or your own provider
Native AOT No reflection, no dynamic code; the AOT test publishes and executes a native binary in CI
Testing Fakes drive the real generated client, so tests cover request and result mapping
Policies Confidence thresholds classify results; they never execute business side effects
Observability OpenTelemetry activities and metrics, with state recording off by default
Resilience Retry, timeout, circuit breaking and cross-provider fallback

Aggregate evaluations

Several questions against one state, in one round trip:

public sealed record TicketAssessment
{
    [JevNoul("Does this require urgent attention?")]
    public required NoulResult Urgent { get; init; }

    [JevChoice("Which department should handle it?")]
    public required ChoiceResult<Department> Department { get; init; }

    [JevScore("Rate the severity.", Min = 1, Max = 5)]
    public required ScoreResult Severity { get; init; }
}

[JevEvaluate]
Task<TicketAssessment> AssessAsync(Ticket ticket, CancellationToken cancellationToken = default);

Hosting is separate from semantics

The contract above never names a provider. Switching where it runs is configuration:

services.AddJevClient<ITicketAI>().UseTypeSafe();
services.AddJevClient<ITicketAI>().UseOpenRouter();
services.AddJevClient<ITicketAI>().UseProvider<InternalGatewayJevProvider>();

Writing your own provider means implementing one interface. It requires no generator changes, no new attributes, no reflection and no change to any contract. See docs/provider-configuration.md.


Testing

var fake = JevFake.Create<ITicketAI>();
fake.Returns("route", Department.Billing, confidence: 0.94);

var result = await fake.Client.RouteAsync(ticket);

fake.Client is the generated implementation, not a mock of the interface. Your test exercises the real request construction and the real option mapping.


Documentation


Samples

Sample Shows
TicketRouting The basics, end to end
FraudDetection Why the distribution matters, and decision policies
ContentModeration Asymmetric thresholds for asymmetric costs
AgentToolRouting Guardrails, tool routing and model routing
AspNetCore Minimal APIs, health checks and problem details
NativeAot Publishing a native binary

Building

dotnet build
dotnet test
dotnet publish tests/JevGen.AotTests -c Release -r linux-x64
./tests/JevGen.AotTests/bin/Release/net10.0/linux-x64/publish/JevGen.AotTests

Requires the .NET 10 SDK.


Status

Pre-1.0, published on nuget.org as 1.0.0-preview.2. The public API may still change; see docs/architecture.md for the versioning policy.

Licence

MIT.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on JevGen.Policies:

Package Downloads
JevGen.Extensions.AI

Integrates JevGen's typed decisions with Microsoft.Extensions.AI: tool routing, guardrails, model routing and confidence gates for agentic applications.

JevGen.AspNetCore

ASP.NET Core integration for JevGen: health checks, problem-details mapping, confidence-gate endpoint filters and configuration validation.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-preview.3 77 9/22/2026
1.0.0-preview.2 84 9/19/2026
1.0.0-preview.1 75 9/18/2026