Capstone design and implementation plan
Define the product and its boundaries
Build a fictional handbook assistant for two organizations, A and B. It answers approved opening-hours and contact-channel questions in English and Persian query fixtures, cites an authorized record, and abstains if evidence is absent or conflicting. It is not an HR decision system and cannot modify records. All data is invented; the lab fixture explicitly permits local learning and testing. Start with a deterministic lookup and measure it before adding generative AI. Compare Architecture A: curated aliases → tenant-scoped exact lookup → cited value; Architecture B: same authorization and retrieval → provider adapter → typed proposal → deterministic validation. Both share the same output contract. A is easier to audit and inexpensive for known FAQs but requires manual alias maintenance. B may support paraphrases and synthesis in a real implementation, but requires model evaluation, privacy review, and additional cost. Here B is a fixed mock and cannot establish that benefit. No-AI fallback: a tenant-filtered handbook browse page or support contact; do not silently route denied requests to an unfiltered search.
Build the retrieval and response boundary
The host owns authenticated tenant identity, not user-supplied text or model-generated arguments. Before context assembly select only approved, active records belonging to that tenant. A mapped topic is a teaching approximation of retrieval, not embeddings or general natural-language understanding. In a real RAG system compare lexical and semantic retrieval using held-out relevance labels and an authorized index. Here a conflict returns abstain instead of inventing a policy. The response has status, value and citations. A fixed mock provider simulates an untrusted proposal; the gate requires the exact selected value and citation. This strict rule works for canonical facts but is not a general entailment checker. A returns the authorized value directly; B rejects a mismatched citation even when the value looks plausible. The example prints A’s hours, a denied proposal for B, and B’s hours for a Persian test query. The shared alias table is not a bilingual instructional translation. No private rows should enter model context or traces. Duplicate IDs are prohibited in the fixture. The mock is a precomputed mapping keyed by question; a real adapter would receive only the authorized evidence and a bounded deadline, not the entire dataset.
def answer(question, tenant, docs, aliases, mode, mock): # Identity and tenant come from the authenticated host, not the model. # aliases are an explicit approved mapping, not a learned retriever. if mode not in ("lookup", "mock_rag"): raise ValueError("unsupported mode") topic = aliases.get(question.strip().casefold()) allowed = [d for d in docs if d["tenant"] == tenant and d["active"] is True and d["approved"] is True and d["topic"] == topic] abstain = {"status": "abstain", "value": None, "citations": []} if topic is None or not allowed or len({d["value"] for d in allowed}) != 1: return abstain evidence = sorted(allowed, key=lambda d: d["id"])[0] if mode == "mock_rag": # Only authorized evidence enters the provider context. proposal = mock.get(question, None) if (type(proposal) is not dict or set(proposal) != {"value", "citation"} or type(proposal["value"]) is not str or proposal["value"] != evidence["value"] or proposal["citation"] != evidence["id"]): return abstain return {"status": "answer", "value": evidence["value"], "citations": [evidence["id"]]}
docs = [dict(id="a1", tenant="A", topic="hours", active=True, approved=True, value="09:00-17:00"), dict(id="b1", tenant="B", topic="hours", active=True, approved=True, value="10:00-16:00")]aliases = {"hours": "hours", "ساعت": "hours"}mock = {"hours": {"value": "09:00-17:00", "citation": "a1"}}print(answer("hours", "A", docs, aliases, "lookup", mock))print(answer("hours", "B", docs, aliases, "mock_rag", mock))print(answer("ساعت", "B", docs, aliases, "lookup", mock))Expose one read-only operation
A model proposes a tool call; the host and server separately authorize it. The local fixture uses a tool name and typed arguments analogous to MCP tools/call. It does not implement the MCP protocol, transport, OAuth, discovery or version negotiation. Pin the real protocol and inspect its schema before integration; Chapter 43 introduced the 2026-07-28 revision and legacy lifecycle. The permitted operation reads one active approved record for the trusted tenant. Any other name, extra argument or missing record returns a uniform denied result. No writes, shell execution or network access are available. In production add authenticated server-side identity, request size limits, cancellation, per-call deadlines and auditable event IDs. Read-only metadata is not authorization. The example denies an unauthorized cross-tenant read and an unlisted write. OWASP describes indirect prompt injection and recommends least privilege and separate enforcement [1,2]. A document instruction cannot change permissions; even an apparently harmless model output is untrusted. A mock cannot prove resistance to real prompt injection.
def tool_read(request, tenant, docs): # Local application contract inspired by MCP tools/call, not wire conformance. denied = {"status": "denied", "value": None} if (type(request) is not dict or set(request) != {"name", "arguments"} or request["name"] != "read_handbook"): return denied args = request["arguments"] if type(args) is not dict or set(args) != {"id"} or type(args["id"]) is not str: return denied matches = [d for d in docs if d["id"] == args["id"] and d["tenant"] == tenant and d["active"] is True and d["approved"] is True] if len(matches) != 1: return denied return {"status": "ok", "value": matches[0]["value"]}
docs = [dict(id="a1", tenant="A", active=True, approved=True, value="09:00-17:00"), dict(id="b1", tenant="B", active=True, approved=True, value="10:00-16:00")]print(tool_read({"name":"read_handbook","arguments":{"id":"a1"}}, "A", docs))print(tool_read({"name":"read_handbook","arguments":{"id":"b1"}}, "A", docs))print(tool_read({"name":"write_handbook","arguments":{"id":"a1"}}, "A", docs))Architecture decision and deployment plan
Choose A for the initial release because the questions are finite and exact answers are required. Keep B experimental until an independent evaluation shows additional value without more access failures. Record the decision, rejected alternatives (including a classical intent classifier with retrieval), owner, reversal criteria, and evidence in an architecture decision record. The no-AI fallback remains accessible even if the provider fails. A proposed deployment has an authenticated API, versioned handbook/index, isolated provider gateway, policy enforcement and allowlisted telemetry. Keep credentials outside prompts, cap requests and response lengths, separate tenants in caches, and fail closed on unavailable authorization. A containerized API and read-only worker could be deployed behind a gateway, with readiness dependent on policy and index versions; no infrastructure is created by this lab. Use the operations worksheet for data retention, versioning, rollback, and cleanup. NIST AI RMF provides a risk management structure [3].
Practice and review
Run the integrated capstone fixture and compare the architectures using identical queries and ground truth. Add an unknown topic, conflicting record, inactive record, and malformed tool proposal. Explain why permission checks are not model judgments. Use separate development and evaluation cases; the included teaching set is visible and not a statistically independent holdout. Design an optional authorized model run on newly frozen unseen cases; document model and adapter revision, approved data, stop conditions and cost ceiling. Do not run live calls just to finish the worksheet. Deep training belongs to Machine Learning, and production provider and RAG implementation belongs to LLM Engineering.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Capstone design and implementation plan quiz
Assess capstone architecture, policy boundaries, evidence and release judgment.
Which architecture should be tested first for finite exact FAQs?
What controls tenant access?
A mock proposes a valid value with a different tenant citation. What should happen?
What is the local tool fixture not proving?
What is a safe no-AI fallback?