SwiftJev is the TypeSafe Jev provider for SwiftDecision. It sends typed Noul, Choice, and Score prompts to the hosted System One API and returns validated probability distributions through SwiftDecision's DecisionBackend protocol.
dependencies: [
.package(url: "https://github.com/SoundBlaster/SwiftJev.git", from: "0.5.0"),
.package(url: "https://github.com/SoundBlaster/SwiftDecision.git", from: "0.8.0")
]Add both products to the target that uses them:
.product(name: "SwiftDecision", package: "SwiftDecision"),
.product(name: "SwiftJev", package: "SwiftJev")Set TYPESAFE_API_KEY or pass a key explicitly:
import SwiftDecision
import SwiftJev
let backend = try SwiftJev.JevDecisionBackend()
let engine = DecisionEngine(backend: backend)
let result = try await engine.noul(
statement: "Is the service unavailable for all customers?",
context: "The status page reports that all customers cannot sign in."
)
print(result.value, result.probabilities)The backend validates every prompt and response against the Jev Noul, Choice, and Score contracts. It preserves prompt option order, rejects redirects, checks cancellation, and never includes credentials or response bodies in errors. HTTP transport is injectable for deterministic tests; no network requests happen during initialization.
For Choice prompts, SwiftJev returns the full probability distribution in prompt option order, and SwiftDecision picks the answer from that distribution under its own acceptance policy. By default the API's choice label only has to name one of the prompt options, matching the TypeSafe API, which can return a near-tie choice slightly below the highest probability. To reject responses whose choice falls too far below the most probable option, set a gap; 0 requires the strict argmax:
let backend = try SwiftJev.JevDecisionBackend(maximumChoiceProbabilityGap: 0.02)The backend defaults to https://api.typesafe.ai/v1. To use a compatible proxy such as CoreInfra Hub, select an API root; SwiftJev appends /systemone:
let backend = try SwiftJev.JevDecisionBackend(
apiKey: ProcessInfo.processInfo.environment["COREINFRA_API_KEY"],
endpoint: .baseURL(URL(string: "https://hub.coreinfra.ai/typesafe/api/v1")!)
)For a gateway that gives you a complete operation URL, use it unchanged:
let backend = try SwiftJev.JevDecisionBackend(
apiKey: ProcessInfo.processInfo.environment["COREINFRA_API_KEY"],
endpoint: .operationURL(URL(string: "https://hub.example/custom/systemone")!)
)Custom endpoints require an explicit API key. The URL must be an absolute HTTPS URL without user information, query, or fragment. The proxy must accept the TypeSafe System One request and response contract. Keep API keys in the host environment or Keychain; do not embed a shared key in an app binary.
For iOS apps, store a user-provided API key in Keychain and pass it explicitly to JevDecisionBackend. See the iOS Keychain runbook. Do not ship a shared provider key inside an app binary.
export TYPESAFE_API_KEY="your-api-key"The benchmark is opt-in because requests are billable:
SWIFTJEV_RUN_JEV_BENCHMARKS=1 TYPESAFE_API_KEY="$TYPESAFE_API_KEY" \
swift run --disable-sandbox JevBenchmark --samples 20It reports end-to-end sequential latency and throughput for Noul, Choice, and Score. The benchmark never runs in CI and does not print prompts or credentials.
SwiftJev owns the provider and HTTP transport. SwiftDecision owns typed decision APIs, policy validation, acceptance and fallback behavior, cancellation, timeouts, and traces. This package is intentionally a thin provider adapter; it does not expose raw System One response models.
Apache License 2.0. See LICENSE.
JevFailureClassifier.classify(error) returns a DecisionFailureCategory without
changing the thrown error. Cancellation, authentication, TLS, malformed responses,
and invalid configuration are not transient. Timeouts, selected connectivity
errors, HTTP 429, 408, 425 and 5xx are classified separately. This is descriptive:
the caller decides whether to retry or use a fallback. No automatic recovery is
added to predict. For a total deadline across several inferences, pass the same
SwiftDecision DecisionBudget to each engine call; HTTP timeout is an inactivity
limit and does not replace that budget.
The optional local backend belongs to SwiftDecision, not to this Jev HTTP provider. A separately downloaded, versioned GLiNER Core ML distribution contains INT8 weights, tokenizer files, license notices, conversion provenance, and checksums. Follow the SwiftDecision integration guide.
SwiftJev does not bundle, download or run the model. Applications may choose Jev through SwiftJev or the local backend through SwiftDecision, with explicit provider selection. No automatic provider or credential fallback is introduced.