Page 3 of 8~112 min topic

Feature flags lab

Implement one traceable happy path

One clean transaction through **POST /v1/rag/answer** must match the oracle: 5% cohort sees index_v2 citations; kill switch returns everyone to v1 in < 60s.

~14 min this pageVertical slice

1Try it yourself

Decision drill

Feature flag lab

Flags control who sees what — without redeploying code.

Release control72%

1/3New RAG index for 5% of traffic.

2Learn the idea

Read

Order the successful transaction

Code the narrow path that serves release captain flipping rag_index_v2 for cohort canary: accept → authorize/normalize → call dependency → validate → record. Keep stages named so a trace can show which boundary passed. Success must emit evidence useful to flag_exposure_pct and citation_delta_v2_vs_v1, not only a 200 with prose. Predict the observable for POST /v1/rag/answer before running: 5% cohort sees index_v2 citations; kill switch returns everyone to v1 in < 60s.

Read

Run with fakes first

Drive the path with recording fakes or local stubs. Assert call order and arguments. Idempotency keys or stable ids should keep retries from duplicating costly work where the product requires it. Product under test remains FastAPI RAG endpoint whose v2 index is dark-launched then exposed to 5% — resist adding unrelated features mid-path.

Read

Implementation artifact

if flags.enabled("rag_index_v2", ctx, percent=5):
    index = indexes["v2"]
else:
    index = indexes["v1"]

Read

Compare prediction to result

For Feature flags lab, paste the CLI/HTTP transcript beside your prediction for POST /v1/rag/answer. If the oracle is unmet (5% cohort sees index_v2 citations; kill switch returns everyone to v1 in < 60s), stop and debug this page; do not compensate with prompt folktales. Re-run once after a clean process start to catch hidden global state that would invalidate FLAG-CLIENT-TRUST-4.

Read

Stage depth

Performance sketch: measure local p95 for the fake-backed path so later regressions are obvious. Keep concurrency modest until failure-handling proves limits. Log a single structured event per success with request id, revision, and the evidence field behind flag_exposure_pct and citation_delta_v2_vs_v1. Avoid hidden global caches in the happy path unless the lab is about caching — and even then key by tenant. If the path calls a model, pin model id in config and echo it in the response for auditability. Remember release captain flipping rag_index_v2 for cohort canary experiences wall-clock time, not your debugger’s single-step comfort.

Read

Field notes for `feature-flags-lab` / `happy-path`

Prefer explicit function names over a single god-object handleRequest. Thread a correlation id from ingress to the last log line. When streaming, define what partial failure means before coding. Snapshot one successful response body in fixtures after redaction. If the path writes to a queue, assert message attributes in the fake. Stop adding retries on this page; that is the next concern. In this chapter the product is FastAPI RAG endpoint whose v2 index is dark-launched then exposed to 5%, the human stakeholder is release captain flipping rag_index_v2 for cohort canary, and the incident id you design against is FLAG-CLIENT-TRUST-4. Re-state the oracle in your notes — 5% cohort sees index_v2 citations; kill switch returns everyone to v1 in < 60s — and keep the invariant visible: flag writes require RBAC; client-supplied flag values never authorize access. Track flag_exposure_pct and citation_delta_v2_vs_v1 as the scoreboard. Surface under change control: POST /v1/rag/answer. If you only have forty minutes, finish the fixture for browser-exposed flag lets attackers force v2 (unreviewed) index 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

Without calling production, order the steps a single success takes for release captain flipping rag_index_v2 for cohort canary. Circle the first irreversible side effect. Your prediction should mention POST /v1/rag/answer and the evidence field that proves 5% cohort sees index_v2 citations; kill switch returns everyone to v1 in < 60s.

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. Is call order asserted, not assumed?
2. Does success evidence support flag_exposure_pct and citation_delta_v2_vs_v1?
3. Did you compare prediction vs transcript?

All responses are required.