Page 2 of 8~112 min topic

Blue-green deploy lab

Create the runnable skeleton and contracts

Types and env contracts make **RAG API with complete green/v1 and blue/v2 stacks behind one router** fail closed before any provider or cluster call.

~14 min this pageRunnable setup

1Try it yourself

Decision drill

Blue-green deploy desk

Two full environments — swap traffic atomically, revert fast if metrics break.

Cutover confidence70%

1/3v2 passes smoke on the idle (blue) environment. Green still serves 100%.

2Learn the idea

Read

Define trusted borders

Implement types or schemas around router → green|blue /v1/rag/answer so illegal states are unrepresentable at the boundary. For RAG API with complete green/v1 and blue/v2 stacks behind one router, trusted inputs come from sessions, signatures, pinned digests, or workload identity — not from free-form model text. release engineer flipping 100% router cut after green smoke should be able to read the contract and know which fields are optional, which are enumerated, and which abort the request. Constructors and boot paths must not perform provider side effects; injection points keep tests honest.

Read

Environment and secrets contract

Document required env vars in .env.example with placeholders only. Rotation story belongs later, but the contract already forbids printing secrets and forbids defaulting to fail-open when a dependency is missing. Invariant to encode in types/tests: blue must pass smoke + /readyz before cut; old green kept warm for 30m rollback. If a config number lacks units, fix the name (timeout_ms, rpm_hard) before writing logic.

Read

Implementation artifact

curl -sf $BLUE/readyz && ./smoke_rag.sh --base $BLUE

Read

Fixture kit

Create fixtures for the golden path and for BG-SCHEMA-ONESIDE-11. Name files after the behavior (429-retry-after.json, cross-tenant.json, empty-citation.json) rather than test1. Each fixture carries expected status/code. This kit is the shared language for validation and failure pages.

Read

Stage depth

Compatibility promise: additive fields may appear only if readers ignore unknowns safely; breaking changes bump a version visible on the wire. For AI payloads, size limits arrive before JSON parse when hostile blobs are a risk. Document how clock skew, idempotency keys, and tracing headers travel through RAG API with complete green/v1 and blue/v2 stacks behind one router. If you use feature flags later, the contract already states that flags are not authorization. Link each config knob to a unit and a failure mode (“0 means disabled” vs “0 means divide-by-zero”). A peer reviewing the PR should find BG-SCHEMA-ONESIDE-11 named in a comment on the adversarial fixture.

Read

Field notes for `blue-green-lab` / `setup-and-contract`

Generate OpenAPI or a typed client only after the hand schema is stable for one fixture round-trip. Record how errors look on the wire — problem+json, envelope, or bare status — and stick to one. Clock sources must be injectable for skew tests. If webhooks appear later, document signature header names now even as TODOs. Keep sample payloads UTF-8 and free of real emails. Add a makefile or npm script that validates schemas without network. In this chapter the product is RAG API with complete green/v1 and blue/v2 stacks behind one router, the human stakeholder is release engineer flipping 100% router cut after green smoke, and the incident id you design against is BG-SCHEMA-ONESIDE-11. Re-state the oracle in your notes — cutover < 30s; rollback restores green with zero dual-write divergence — and keep the invariant visible: blue must pass smoke + /readyz before cut; old green kept warm for 30m rollback. Track cutover_seconds and postcut_error_rate as the scoreboard. Surface under change control: router → green|blue /v1/rag/answer. If you only have forty minutes, finish the fixture for schema migration applied only on blue — green rollback serves 500s before polishing UI. Promotion language stays ternary: promote, hold, or roll back based on evidence, not hope.

Go deeper

Before you start

Why this matters

For Blue-green deploy lab, sketch the request and response shapes that cross router → green|blue /v1/rag/answer without naming a framework. Mark which fields are trusted (session, signatures, digests) versus untrusted (user text, model JSON, webhook bodies). If a field can change authorization, it does not belong in model output. Predict one 422/401 you will assert before coding adapters for RAG API with complete green/v1 and blue/v2 stacks behind one router.

In the wild

See how this idea shows up as a product and a company — then come back to the lesson. Skills transfer across vendors.

Check your understanding

Page assessment

Answer from memory. Completion is saved from this evidence, not from opening the next page.

1. Can a newcomer list trusted vs untrusted fields?
2. Does boot avoid external side effects?
3. Are fixtures named after BG-SCHEMA-ONESIDE-11-class failures?

All responses are required.