Typed AI Application Contract
Explicit success/refusal/degraded/error result types.
Build and test the reliability layer around a production LLM application, including contracts, validation, retries, idempotency, fallback routing, observability, and release gates.

Build and test the reliability layer around a production LLM application, including contracts, validation, retries, idempotency, fallback routing, observability, and release gates.
Explicit success/refusal/degraded/error result types.
Provider-neutral generation boundary for timeout, telemetry, configuration, usage, and parsing.
One concrete SDK adapter isolated from business logic.
Explicit success/refusal/degraded/error result types.
src/contracts.tsProvider-neutral generation boundary for timeout, telemetry, configuration, usage, and parsing.
src/model-gateway.tsOne concrete SDK adapter isolated from business logic.
src/providers/adapter.tsRequest schema-constrained output and validate again locally.
src/validation/schema.tsApply deterministic domain checks after schema validation.
src/validation/business.tsBounded retry policy with error classification, jitter, and total deadline.
src/reliability/retry.tsSafe mock action guarded by policy, authorization, and idempotency.
src/actions/idempotent.tsExplicit failure-triggered fallback with telemetry.
src/routing/fallback.tsTrace application/model boundaries and usage without capturing sensitive content by default.
src/observability/tracing.tsFail CI when quality, reliability, latency, safety, or cost thresholds regress.
src/eval/release-gate.tsInject 500 ms, 2 s, 5 s, and over-deadline latency.
Compare no retry, fixed retry, and exponential backoff under 429/5xx faults.
Classify outputs as parseable, schema-valid, and business-valid.
Run identical tasks under healthy and failed-primary conditions.
Use a mock provider by default; live calls only when explicitly authorized.
git clone https://github.com/sarvab-dev/prodai-stack-labs
cd prodai-stack-labs/production-ai-system-design
npm install
npm testca6908c