peterfriese/system-one-foundation-models/jev-foundation-models

Claude Code and agent skill by peterfriese/system-one-foundation-models

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Evaluate TypeSafe Jev System One decision models natively through Apple's Foundation Models framework in Swift 6. Use when building iOS 27+, macOS 27+, or visionOS 27+ apps that evaluate strongly-typed @Generable structs and enums using LanguageModelSession, implementing confidence routing (RoutingPolicy, NoulJudgement, ScoreValue), configuring resilient network retries (RetryPolicy), securing mobile traffic via App Check proxy transports, or writing deterministic offline unit tests with MockJevTransport.

Install

npx vskill@latest install peterfriese/system-one-foundation-models/jev-foundation-models

SKILL.md

Jev Foundation Models Bridge

[!TIP]
Modern Multi-Backend Standard: For projects requiring on-device inference via Core ML (LayaOnDevice) or local self-hosted evaluation (LayaFoundationModels) alongside TypeSafe Jev cloud, refer to the unified system-one-foundation-models skill and package target. This skill remains focused on TypeSafe Jev cloud evaluation, resilience policies, and App Check security proxy architectures.

This skill guides the design, implementation, and testing of applications integrating TypeSafe AI's Jev System One decision model via Apple's Foundation Models framework (FoundationModels) in Swift 6.


1. Core Mental Model: Decisions, Not Chat

Jev is a System One decision model, not a text-generating LLM. It evaluates application state against a set of typed questions in a single forward pass, returning calibrated probabilities and discrete categorical decisions in 40–150ms.

  • Prompt $\to$ Application State: The text passed to session.respond(to:) represents current application context (support tickets, sensor readings, transaction logs, user inputs, or parsed documents).
  • `@Generable` Type $\to$ Decision Questions: The struct or enum defines the typed questions being asked over that state.
  • Dual Signal Output:
  1. The Answer: What the model judged (response.content containing typed enum choices, booleans, or rubric scores).
  2. The Calibrated Confidence / Probability: Whether to automate the action (response.judgement(...), response.decision(...), response.scoreValue(...)).

2. @Generable Schema Modeling Rules

SchemaTranslator maps Apple @Generable types directly to Jev decision primitives. Follow these mapping rules strictly:

Swift Type & AnnotationsJev PrimitiveQuestion Key ConventionBehavior / Output
Bool`noul`Field name (e.g. "isUrgent") or "root"Calibrated probability of truth ($0.0 \dots 1.0$). Decodes to Swift Bool.
enum: String`choice`Field name (e.g. "department") or "choice"Discrete categorical selection among defined enum cases.
Int or Double + @Guide(.range(min...max))`score`Field name (e.g. "frustrationLevel") or "root"Ordinal rubric scoring mapped to integer/numeric levels with continuous weighting.
@Guide(description: "...")`instructions`N/ANatural language instructions steering Jev's judgment.
Nested @Generable struct`nested questions`Dot-notation (e.g. "metadata.priority")Evaluates hierarchical sub-properties concurrently.
Negative Constraints (Strictly Forbidden)
  • ❌ No unconstrained `String` properties: Jev does not generate free-form text. A String property without enum choices throws JevError.invalidSchema.
  • ❌ No unstructured collections: Arrays of open-ended values ([String]) or dictionaries are not supported.
  • ❌ No text generation requests without schemas: Calling session.respond(to: "Hello") without a generating: argument throws JevError.structuredOutputRequired.
  • ❌ No tool calling: LanguageModelCapabilities for Jev only includes [.guidedGeneration]. It does not support Tool execution.
Correct Schema Example
swift
import FoundationModels
@Generable
enum SupportDepartment: String, Sendable {
case billing
case technicalSupport
case sales
}
@Generable
struct TriageDecision: Sendable {
@Guide(description: "Is this customer inquiry urgent or blocking critical business?")
var isUrgent: Bool
@Guide(description: "Which department is best suited to resolve this issue?")
var department: SupportDepartment
@Guide(description: "Customer frustration rating on a 0 to 3 scale", .range(0...3))
var frustrationLevel: Int
}

3. Canonical Call-Site, Telemetry & Confidence Routing

Always use standard Apple Foundation Models APIs (LanguageModelSession)—do not introduce proprietary session wrappers:

swift
import FoundationModels
import JevFoundationModels
// 1. Initialize the model provider
let model = JevLanguageModel(apiKey: apiKey)
let session = LanguageModelSession(model: model)
// 2. Evaluate state against the @Generable schema
let customerTicket = """
Ticket #8491: Urgent! I was charged $500 twice for renewal, and our accounts are locked!
"""
let response = try await session.respond(to: customerTicket, generating: TriageDecision.self)
// 3. Consume strongly typed decision content
let decision: TriageDecision = response.content
print("Department:", decision.department) // .billing
print("Is Urgent:", decision.isUrgent) // true
print("Frustration:", decision.frustrationLevel) // 3
Confidence Routing with RoutingPolicy

Never write naive if prob > 0.5 checks. In Jev:

  • `0.50` indicates maximum epistemic uncertainty, not "half true".
  • The undecided band ($0.35 \dots 0.65$) indicates the model is genuinely undecided (answer == nil).
  • A probability of 0.05 is a confident "no" ($\text{decisiveness} = \max(p, 1 - p) = 0.95$), which routes to .auto with answer: false.

Use RoutingPolicy to map calibrated signals into three operational actions (.auto, .confirm, .escalate):

swift
let policy = RoutingPolicy(
escalateBelow: 0.60,
autoAtOrAbove: 0.85,
undecidedBand: 0.35...0.65
)
// Categorical or Scored Decision (.auto, .confirm, .escalate)
let deptAction = response.decision(for: "department", policy: policy)
switch deptAction {
case .auto:
routeToDepartment(decision.department)
case .confirm:
suggestDepartment(decision.department)
case .escalate:
routeToGeneralQueue()
}
// Boolean (Noul) Judgement
let urgencyJudgement = response.judgement(for: "isUrgent", policy: policy)
switch urgencyJudgement.decision {
case .auto:
if urgencyJudgement.answer == true {
pageOnCallLead() // Confident Yes (p >= 0.85)
} else {
markStandardPriority() // Confident No (p <= 0.15)
}
case .confirm:
promptAgentToConfirm() // Leaning (0.16...0.34 or 0.65...0.84)
case .escalate:
assignManualReview() // Undecided band (0.35...0.65): answer is nil
}
Rubric Scoring Telemetry with ScoreValue

For @Guide(.range(...)) score properties, Jev returns probability-weighted positions across rubric levels:

swift
if let score = response.scoreValue(for: "frustrationLevel") {
print("Continuous Weighted Score:", score.value) // e.g. 2.75 (leaning toward level 3)
print("Discrete Rounded Level:", score.rounded) // 3
print("Confidence Score:", score.confidence) // 0.0 ... 1.0
if let normalized = score.normalized {
print("Normalized Rubric Position:", normalized) // 0.0 ... 1.0
}
}

4. HTTP Resilience & Swift 6 Cooperative Cancellation

Configure automated retry backoff via RetryPolicy on JevLanguageModel:

swift
let retryPolicy = RetryPolicy(
maxAttempts: 3, // Initial attempt + up to 2 retries
initialDelay: .milliseconds(500), // First retry delay
multiplier: 2.0, // Exponential backoff
jitter: 0.2, // +/- 20% random jitter to avoid thundering herds
retryableStatuses: [429, 529], // Retry rate-limits and temporary capacity limits
maxRetryAfter: .seconds(60) // Respects RFC 9110 Retry-After headers
)
let model = JevLanguageModel(apiKey: apiKey, retryPolicy: retryPolicy)
Cooperative Cancellation

In Swift 6 concurrency, task cancellation must never be swallowed or converted into a generic error:

  • `CancellationError` is NEVER wrapped in `JevError`: If a parent Task is cancelled (e.g., user navigates away in SwiftUI), CancellationError propagates directly.
  • Retry sleeps abort immediately upon cancellation.
swift
let task = Task {
try await session.respond(to: ticket, generating: TriageDecision.self)
}
// When user dismisses view or cancels operation:
task.cancel()
do {
let response = try await task.value
} catch is CancellationError {
print("Decision task cancelled cleanly.")
} catch let error as JevError {
print("Jev failure: \(error)")
}

5. Production Mobile Architecture (JevTransport)

Never embed `TYPESAFE_API_KEY` inside client application binaries.

In production iOS, macOS, or visionOS apps, route requests through a backend reverse proxy (such as a Firebase Cloud Function, Vapor backend, or Cloudflare Worker) protected by Apple App Attest / Firebase App Check.

The repository includes a ready-to-use reference transport in Integrations/FirebaseAppCheckProxy/FirebaseAppCheckTransport.swift:

swift
import JevFoundationModels
// 1. Configure the proxy transport (supports .cached or .singleUse replay-protected tokens)
let transport = FirebaseAppCheckTransport(
proxyEndpoint: URL(string: "https://your-cloud-function.cloudfunctions.net/triageProxy")!,
tokenStrategy: .cached // < 1ms cached hardware token lookup
)
// 2. Initialize model without apiKey (authentication handled by App Check + backend proxy secret)
let model = JevLanguageModel(
endpoint: URL(string: "https://your-cloud-function.cloudfunctions.net/triageProxy")!,
transport: transport
)
let session = LanguageModelSession(model: model)

6. Deterministic Offline Testing with Swift Testing (@Test)

Always test decision workflows deterministically without live network access or API credentials using MockJevTransport:

swift
import Testing
import FoundationModels
@testable import JevFoundationModels
@Suite("Triage Decision Tests")
struct TriageWorkflowTests {
@Test("Verifies triage routing and high-probability escalation")
func testUrgentBillingTriage() async throws {
let mockTransport = MockJevTransport { request in
#expect(request.questions.count == 3)
#expect(request.state.contains("charged $500 twice"))
return JevResponse(
model: "jev-mock",
answers: [
"isUrgent": JevAnswer(type: "noul", noul: 0.97, confidence: 0.95),
"department": JevAnswer(type: "choice", choice: "billing", confidence: 0.98),
"frustrationLevel": JevAnswer(type: "score", score: 2.8, confidence: 0.90)
],
usage: JevUsage(inputTokens: 85, outputTokens: 10)
)
}
let model = JevLanguageModel(apiKey: "mock-key", transport: mockTransport)
let session = LanguageModelSession(model: model)
let response = try await session.respond(
to: "charged $500 twice",
generating: TriageDecision.self
)
// Verify strongly typed content
#expect(response.content.isUrgent == true)
#expect(response.content.department == .billing)
#expect(response.content.frustrationLevel == 3) // rounded from 2.8
// Verify routing policy decision
let judgement = response.judgement(for: "isUrgent")
#expect(judgement.decision == .auto)
#expect(judgement.answer == true)
// Verify rubric telemetry
let frustration = response.scoreValue(for: "frustrationLevel")
#expect(frustration?.rounded == 3)
#expect(frustration?.value == 2.8)
}
}

7. Implementation Nuances & Troubleshooting

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/peterfriese/system-one-foundation-models/jev-foundation-models/badge)](https://verified-skill.com/skills/peterfriese/system-one-foundation-models/jev-foundation-models)

Something wrong with this skill or its page? Tell us.