Capstone verification and handoff
Verify behavior before approving the design
The capstone handoff is a set of reproducible artifacts and evidence, not a promise that a cloud service is running. Use the same fictional Harbor Supply requirements, two alternatives and cost model. Begin with the local event contract. Then document the HLD, LLD, ADRs, infrastructure outline, pipeline, observability, recovery, migration and cleanup. An offline test proves only the behavior it executes.
Rehearse durable event processing in memory
This standalone Python 3 example uses SQLite in memory. An order lookup and a processed-event row share tenant identity. For this demonstration, the caller is a trusted synthetic adapter, not an authenticated user. Event processing stores the result in one transaction; the unique key detects replay. The model accepts only previously defined orders and exact quantities, simulates duplicate queue delivery, and never contacts a network. It does not implement a production outbox relay, distributed transaction, concurrency, real authentication or external side effect.
import sqlite3
def make_db(): db = sqlite3.connect(':memory:') db.executescript('''CREATE TABLE orders (tenant TEXT, id TEXT, qty INTEGER, PRIMARY KEY (tenant,id)); CREATE TABLE processed (tenant TEXT, event TEXT, order_id TEXT, qty INTEGER, PRIMARY KEY (tenant,event)); INSERT INTO orders VALUES ('cedar','o1',2), ('maple','o1',5), ('cedar','o2',3);''') return db
def process(db, tenant, event, order, qty): if not all(isinstance(s, str) and s for s in (tenant, event, order)) or type(qty) is not int or qty <= 0: return 'invalid' with db: expected = db.execute('SELECT qty FROM orders WHERE tenant=? AND id=?', (tenant, order)).fetchone() if expected != (qty,): return 'rejected' prior = db.execute('SELECT order_id,qty FROM processed WHERE tenant=? AND event=?', (tenant, event)).fetchone() if prior is not None: return 'duplicate' if prior == (order, qty) else 'conflict' db.execute('INSERT INTO processed VALUES (?,?,?,?)', (tenant, event, order, qty)) return 'accepted'
def recovery_gate(outage_min, checkpoint_age_min, verified, writer_fenced): if any(type(x) is not int or x < 0 for x in (outage_min, checkpoint_age_min)): raise ValueError('nonnegative measured minutes required') if verified is not True or writer_fenced is not True: return 'hold' return 'ready-for-review' if outage_min <= 60 and checkpoint_age_min <= 5 else 'missed-objective'
db = make_db()print(process(db, 'cedar', 'e1', 'o1', 2))print(process(db, 'cedar', 'e1', 'o1', 2))print(process(db, 'maple', 'e1', 'o1', 2))print(process(db, 'maple', 'e1', 'o1', 5))print(db.execute('SELECT SUM(qty) FROM processed').fetchone()[0])print(recovery_gate(45, 4, True, True))print(recovery_gate(45, 4, True, False))db.close()Expected output:
acceptedduplicaterejectedaccepted7ready-for-reviewholdThe composite keys allow the same local order/event identifier in different tenants. A cross-tenant quantity mismatch is rejected and an identical replay does not add another processed row. In reality, identity must be derived from a trusted source, and a tenant-valid order/event pair can still be unauthorized if the caller is not allowed to act for that tenant. The toy model does not verify identities or signatures. The processed row is the only modeled effect; it is not external fulfillment. Use durable storage, transactional deduplication and idempotent downstream operations in real systems. The recovery gate tests supplied measurements and fencing evidence, not a real restore.
Deliver the IaC and release contract
Use versioned, reviewed IaC modules for resource hierarchy, network, security rules, runtime, database, queue, storage, backup and observability. Declare environment, symbolic primary/recovery regions (replace only after approval), exact image digest, network CIDRs, allowed paths, roles, retention, capacity and ownership. The companion infrastructure outline is a static design contract, not executable Terraform. No provider version or region is claimed validated. Real plans and state may contain sensitive data; restrict them and never package them in a public portfolio.
Pipeline: commit and review -> dependency and unit tests -> build immutable artifact -> provenance and scan -> validated infrastructure plan and policy check -> independent approval bound to plan/artifact digest -> approved canary -> observe success/error/latency/queue metrics -> expand or stop. Prevent unapproved changes if the plan changes. For database updates, rollback the application only if schema remains backward compatible; do not blindly reverse destructive migrations. Verify actual post-release behavior and drift, not merely a green pipeline.
Recovery and migration runbook
Within region A, distribute stateless capacity across zones, use DB high availability and verify connection recovery. For regional loss, provision a scaled recovery runtime in approved B plus supported cross-region data replication and protected backups, with isolated keys and roles. Warm standby is a candidate for the required RTO/RPO; the allowance and replica lag must be measured and service support confirmed. A Multi-AZ configuration alone is not regional disaster recovery.
- Detect sustained service impairment, declare incident and record fault time; freeze releases.
- Confirm last consistent applied checkpoint, replication lag, data location and access to keys; preserve logs. Fence old writer and isolate old consumers. If fencing is uncertain, halt promotion to avoid split-brain.
- Promote/restore approved recovery DB, scale runtime, replay committed outbox and reconcile processed event IDs; validate synthetic order reads/writes, authorization, error and latency metrics before shifting traffic.
- Record restoration timestamp and checkpoint age relative to fault. Check RTO <=60 and RPO <=5 minutes; escalate if missed, without falsely declaring success. DNS alone does not establish recovery.
- For failback, reconcile new writes, reverse-replicate or restore under approved plan, fence writers, verify again. Never simply switch DNS back to stale data.
For a planned migration, assess source versions, licenses and dependencies; run pilot with synthetic records; full load + CDC if supported; freeze source writes, apply final checkpoint, compare keyed records, verify app smoke tests, approve traffic switch. Reserve rollback time. After target writes begin, reconciliation is required before failback. Decommission only after acceptance, retention, approved rollback horizon and owner authorization.
Observability, risk and verification evidence
| Test | Offline evidence | Required real evidence / owner |
|---|---|---|
| Cost bounds and missing gate | Python candidate model | Dated usage and provider estimates / FinOps |
| Replay and tenant-scoped records | SQLite fixtures | Concurrent, authenticated read/write/replay and negative tests / App + security |
| Recovery gate | Synthetic timing and fencing flags | Actual restore, failover and failback drill / SRE |
| SLO and peak traffic | Arithmetic and planned load profile | Real eligible requests, p95 and error budget / SRE |
| Data location | Diagram and inventory | Region, backups, logs, keys, support access / Security |
| Pipeline | Static policy and approval contract | Actual plan validation, canary and provenance / Release owner |
Monitor request SLI, error budget burn, p95, queue age, DB connections, replication lag and restore-point age. Use trace correlation and sanitized audit events. Example risks: correlated regional dependency or exhausted replica capacity (SRE, recovery rehearsal); broken tenant predicate (security, negative access suite); unchecked duplicate downstream action (application team, concurrent retry test); uncontrolled spend (FinOps, budget alert and quota review). State residual risk and approval owner. Alerts notify, not necessarily cap spending.
Optional portability: map Event v1 to a synthetic Pub/Sub envelope, preserving tenant, order and event IDs; compare the normalized tuple locally. Do not infer queue ordering, acknowledgment, retry or identity equivalence. Azure web-queue-worker and Google Cloud Run/Pub/Sub are useful comparative patterns; Google Pub/Sub defaults to at-least-once delivery. Test provider integration only in a separately approved isolated lab.
Complete the project and hand it off
Submit the written project using lab-fixtures/offline/chapter-60-capstone-project.md as the starter and reference solution. Include numbered requirements, diagrams and data flow, two architectures, ADRs, network and IAM matrix, cost model, security review, versioned static IaC outline, tests with actual versus expected outcomes, SLO plan, incident runbook, migration/cutover, cleanup and known limitations. Include evidence status for every requirement and a named role for unresolved tasks. No real data, real accounts, secrets or paid infrastructure. Cleanup for the core exercise is simply closing the in-memory database and removing only your own temporary local artifacts; no cloud resources were created. Live extensions need explicit scope, cost and teardown verification.
The planned English lesson sequence ends here. The tutorial drafts are not production-published, and the remaining technical reference candidates and course blueprints need their own authoring and review. Use the capstone to identify gaps rather than treating completion as certification.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Capstone verification and handoff — knowledge check
Choose the best answer for each offline scenario.
The same tenant and event ID arrives with the same validated payload. What does the local model do?
The old writer cannot be fenced. What should recovery do?
What proves a regional recovery target has been met?
Why bind approval to a plan and artifact digest?
What does finishing the local capstone establish?