Page 2 of 8~128 min topic

Capstone: ship a tiny AI app

Define the grounded café FAQ application data contract

Types and env contracts make **grounded café FAQ app with validation, five-note retrieval, citations, tests, demo** fail closed before any provider or cluster call.

~16 min this pageData contract

1Learn the idea

Read

Define trusted borders

Implement types or schemas around CLI faq_ask so illegal states are unrepresentable at the boundary. For grounded café FAQ app with validation, five-note retrieval, citations, tests, demo, trusted inputs come from sessions, signatures, pinned digests, or workload identity — not from free-form model text. café ops lead answering hours/wifi/pets questions from a kiosk 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: unsupported questions abstain; every answer cites a note id; two-minute clean-room demo. If a config number lacks units, fix the name (timeout_ms, rpm_hard) before writing logic.

Read

Implementation artifact

def ask(q: str) -> dict: ...  # returns {answer, citation}|{abstain:True}

Read

Fixture kit

Create fixtures for the golden path and for CAP-CAFE-DEMO-01. 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 grounded café FAQ app with validation, five-note retrieval, citations, tests, demo. 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 CAP-CAFE-DEMO-01 named in a comment on the adversarial fixture.

Read

Field notes for `capstone-ship-it` / `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 grounded café FAQ app with validation, five-note retrieval, citations, tests, demo, the human stakeholder is café ops lead answering hours/wifi/pets questions from a kiosk, and the incident id you design against is CAP-CAFE-DEMO-01. Re-state the oracle in your notes — gold 5/5 cited + 3/3 abstain; demo under 120s from clean checkout — and keep the invariant visible: unsupported questions abstain; every answer cites a note id; two-minute clean-room demo. Track gold_pass and demo_seconds as the scoreboard. Surface under change control: CLI faq_ask. If you only have forty minutes, finish the fixture for demo relies on personal .env and unreproducible notebook state 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 Capstone: ship a tiny AI app, sketch the request and response shapes that cross CLI faq_ask 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 grounded café FAQ app with validation, five-note retrieval, citations, tests, demo.

Contracts you freeze now carry through the capstone demo of grounded café FAQ app with validation, five-note retrieval, citations, tests, demo.

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 CAP-CAFE-DEMO-01-class failures?

All responses are required.