What you'll build and prove
The first five phases gave you individual operational skills. This final lesson shows how to combine them without losing trust boundaries. Unlike the earlier coding clinics, the capstone asks you to develop one complete function across multiple scenarios, then document a modular local version. The shared course navigator above controls the guided Learn → Capstone progression; this page's On This Page outline covers just the lesson.
- Build one integrated Python function rather than repeat isolated syntax drills.
- Validate structured CSV inventory, configuration, observation coverage and replay keys before publishing results.
- Implement sustained failure and recovery thresholds, while retaining unknown measurements and an open-alert state.
- Produce deterministic incident drafts with stable keys and safe minimal content.
- Gate simulated remediation behind exact authorization and revision checking.
- Return explicit failure reasons and preserve the caller's previous verified report.
- Write repeatable scenario tests and a professional, multi-file Git handoff.
- Explain the difference between a simulated plan, execution evidence and verified restoration.
Prerequisite: Complete Lesson 05 — Safe Remediation & Recovery and its Practice challenges. Review earlier lessons through the shared course navigation if any stage is unfamiliar.
Read the incident brief and define the acceptance contract
Northstar Ops supports two fictional branch services: WEB, a customer portal, and BACKUP, a job-status endpoint. A monitoring cycle supplies recorded health observations for every inventoried service. Your Python program must validate those observations, identify sustained incidents, create a deterministic incident handoff, and prepare exactly one narrowly scoped remediation proposal when an authorized approval exists. The browser workbench does not run probes, create actual tickets or modify a server. Its job is to prove your decisions are defensible.
Don't begin with the fix
Start by writing the expected input and output contracts. Unknown evidence should never be promoted to healthy status, nor should a rejected inventory silently produce a partial report.
Link five earlier phases
The input pipeline builds on Git and inventory validation; the report uses connectivity/health evidence, stable ticket keys, stateful monitoring thresholds and change-control gates.
Define demonstrable completion
A passing result must cover every scoped host, prevent duplicate ticket drafts, refuse unauthorized or stale plans, and preserve the previous verified result on errors.
scenario = {'site':'HQ','service':'web','host':'APP-01'}
key = ':'.join([scenario['site'],scenario['host'],scenario['service']]).lower()
print(key)
# Stable incident identity; not a ticket creation API call.Why is one successful run against the sample incident insufficient proof that the control room is reliable? Reveal the explanation after predicting.
A realistic tool must handle malformed inputs, mismatched host coverage, sustained failures, recoveries, unknown readings, stale approvals, and replayed incidents. Test those cases independently.
Treat inventory, policy and observation cycles as separate trust boundaries
The fictional inventory is a CSV export containing host, site, service, and revision. The monitoring policy establishes a site, mode and thresholds. Each cycle must provide exactly one measured state for every device at the selected site. Validate the complete dataset and reject duplicates, missing columns, invalid states or unexpected hosts before generating a ticket or change plan. This is deliberately different from the DNS restoration incident used in university assessments.
CSV schema is a contract
Check unique headers as well as row shape; normalize the hostname and site consistently. A revised configuration snapshot must not be substituted for an unverified current state.
Coverage is evidence
Every cycle must include the complete selected-site inventory, even if a probe result is unknown. If one host is missing, the cycle is incomplete—not proof that the host is healthy.
Configuration is not authorization
Policy mode plan creates read-only drafts. Simulate mode requires a separately supplied approval with exact site, target, change ID, revision and open maintenance window.
expected = {'APP-01','DB-01'}
cycle = {'APP-01':'failed','DB-01':'unknown'}
print(set(cycle) == expected)
# A complete cycle can still contain uncertain measurements.One cycle is missing DB-01. Can the report count DB-01 as unknown and continue? Reveal the explanation after predicting.
Not under the capstone's full-coverage contract. An unknown is an explicit observation, while a missing record means evidence is incomplete. Refuse the full report until coverage is established.
Build a finite health and alert state machine
Each input cycle represents one finite point in time. The function evaluates states healthy, failed and unknown against explicit consecutive-failure and recovery thresholds. A sustained failure opens one alert. The alert stays open until enough healthy cycles prove recovery. Unknown resets confirmed streaks but preserves an already-open alert. At the final cycle, classify every host into exactly one report group: alerts, recovered, watch, unknown or healthy.
Open only on confirmed evidence
Three failures with a threshold of three open one alert; failed → unknown → failed does not satisfy that threshold, because the confirmed streak was interrupted.
Recovery is a distinct transition
After an alert opens, two consecutive healthy checks may close it under the configured policy. Repeated failures while it is open do not create new incidents.
Classify the final state honestly
Open alerts take precedence. Otherwise a final unknown belongs to unknown, a final insufficient failure to watch, a verified recovery to recovered, and remaining healthy devices to healthy.
states = ['failed','failed','failed','unknown','healthy','healthy']
open_alert = False
fail = good = 0
for status in states:
if status == 'failed':
fail, good = fail+1, 0
if fail >= 3: open_alert = True
elif status == 'healthy':
good, fail = good+1, 0
if open_alert and good >= 2: open_alert = False
else:
fail = good = 0
print('open' if open_alert else 'closed')An open alert receives one healthy check, then an unknown check. Should that automatically close the alert? Reveal the explanation after predicting.
No. Unknown interrupts the consecutive healthy recovery streak and does not prove the service recovered. Keep the alert open pending valid evidence.
Generate stable, minimal incident proposals
The end-to-end report is not allowed to call a live ticket API. Instead it prepares a ticket draft for each currently open alert that has not already been processed. Build a stable key from normalized site, host and service and compare it to the set of previously seen keys. Drafts contain only the key, target and a controlled summary; no credentials, command output or speculative root cause. In a future approved deployment, an integration adapter could reconcile drafts with confirmed server-side ticket IDs.
Stable across cycles
Do not include timestamps or run IDs in the incident key. The same ongoing event must produce the same key on subsequent simulated runs.
Respect previously processed work
If an incident key is already in seen, leave it out of new drafts. Do not mutate seen; this function is a pure evaluation of current evidence.
Report creation honestly
A ticket_drafts entry is a proposed action, not a created ticket. It is not proof of API success or delivery of a stakeholder notification.
key = 'hq:app-01:web'
seen = {'hq:app-01:web'}
new_drafts = [] if key in seen else [{'key':key,'target':'APP-01'}]
print(len(new_drafts))The same WEB incident remains open through five cycles. Should the monitor create five new ticket drafts? Reveal the explanation after predicting.
No. Use stable incident identity and previously processed keys. Keep recording evidence, but generate a new draft only when the alert has not yet been handled.
Validate the simulated remediation approval and revision
Simulate mode is still read-only, but it models the exact authorization gates that would be needed before a real change. The injected approval must match the monitored site, a known target, the exact permitted action, an approved boolean True, a nonblank change ID, an open window and a captured expected revision. A proposed change is eligible only when that target has an open alert and its inventory revision equals the approved revision. An incorrect revision is a stale plan and blocks the entire simulated report without replacing previously verified output.
One target, not a fleet
A scoped approval for APP-01 cannot authorize an action on DB-01. Even though the program reads the whole site, the simulated change proposal covers only the explicitly named host. Approval must also name the specific action; permission to review a restart never authorizes another operation.
Revision is a concurrency guard
If a different operator changed the target from revision r7 to r8 after approval, the plan must be reconsidered. Do not force the original change to fit the new state.
A proposal is not execution
Return ready-for-review for a simulated proposal only. There are no real writes, service restarts, rollback operations or ticket updates in the browser capstone.
approval = {'id':'CHG-7','target':'APP-01',
'action':'review-service-restart','expected_revision':'r7'}
current_revision = 'r8'
if approval['action'] != 'review-service-restart':
print('unauthorized action')
else:
print('stale' if current_revision != approval['expected_revision']
else 'ready-for-review')
# No service is restarted here.The correct target is approved and currently alerting, but the revision no longer matches. Can the tool still return a successful change plan? Reveal the explanation after predicting.
No. It must report a stale approval state and preserve prior verified output rather than acting on an outdated assumption.
Preserve the previous verified handoff on failure
Production automation often has a trusted last-good report. Capstone errors return a small blocked record with a reason and the untouched previous report. Reject invalid configuration, malformed CSV, duplicate inventory rows, missing cycle coverage, unsafe observations and invalid or stale approvals. Do not produce a success-looking report for only the devices that happened to respond. The previous report should not be mutated, even when a new complete report is produced.
Errors belong to specific gates
Return config when the site, mode, thresholds or replay keys are invalid; csv or duplicate when inventory cannot be trusted; coverage or observations when a cycle is incomplete or inconsistent.
Approval refusal is not a system outage
Return approval when the simulated change is outside scope, lacks trusted authorization or has a closed window; return stale when the captured revision no longer matches.
Preserve immutability
Create new result arrays and dictionaries; do not mutate the caller's inventory, cycle records, prior report, replay keys or approval objects.
previous = {'report_id':'last-good-12'}
blocked = {'ok':False,'reason':'coverage','previous':previous}
print(blocked['reason'],blocked['previous']['report_id'])
# No partial report is published.One of three devices is missing from a monitoring cycle, but the other two are healthy. Should the program publish a two-device healthy report? Reveal the explanation after predicting.
No. The selected site inventory establishes required coverage. Return the blocked reason and preserve the earlier verified report until the missing evidence can be reconciled.
Separate a proposed repair from verified service recovery
This browser capstone models an operations decision and deliberately cannot prove that a real configuration change or application recovery occurred. Its output reports alert status, ticket drafts and an eligible-for-review plan; it never labels an incident resolved merely because an approval exists. The optional local project goes further with an injected fake service adapter, post-change verification fixture and rollback decision. It still performs no real network operations. On a production project, actual recovery requires trusted post-change measurements and confirmation from the relevant ticketing system.
A proposed action has zero execution evidence
Even a plan that passes approval and revision checks remains a plan. It should not update a ticket to resolved or tell stakeholders their service is restored.
A fake adapter teaches the boundary
A locally injected function can return 201, 202 or timeout fixtures to test safe response handling. It is not a substitute for the real provider's authentication, transaction and retry contract.
Post-change verification is independent
A real deployment would read configuration after applying, validate service/application health and verify any ticket update separately. An uncertain result requires reconciliation and review.
result = {'change_plan':'ready-for-review','service_verification':'not-run'}
print('resolved' if result['service_verification']=='pass' else 'still-open')If the capstone reports ready-for-review and a ticket draft exists, has an incident been remediated? Reveal the explanation after predicting.
No. Those are proposed actions. No external service changes or confirmed ticket writes occurred; a production workflow would require distinct execution and post-change evidence.
Package the project, test edge cases and explain tradeoffs
A professional capstone needs a handoff another technician can run, test, inspect and audit. Split validation, state transitions, planning and serialization into comprehensible functions. Use a local Git branch, an inventory fixture, small test datasets, explicit run modes and a README that explains reason codes and limitations. The final review should demonstrate a good run and multiple blocked runs without replacing the last verified result. Keep all test hostnames and data fictional.
Evidence over screenshots alone
Include repeatable unittest cases, deterministic JSON output and a written explanation of which input each failure validates. Screen captures can complement this but are not a substitute for tests.
Use clear boundaries between modules
Keep inputs/fixtures, monitoring policy, incident drafts and simulated change planning separate so a future maintainer can replace the offline adapters without rewriting core decision logic.
Document deployment limitations
State that this is not an unattended production monitor. A real tool also needs authorized access, schedule ownership, observability, storage, secret handling, audit controls and controlled remediation.
checks = {'inventory':'pass','thresholds':'pass','approval':'pass','live-recovery':'not-tested'}
print('ready-for-learning-review' if all(v=='pass' for k,v in checks.items() if k!='live-recovery') else 'revise')Why should the README explicitly state that the capstone never contacted a real service? Reveal the explanation after predicting.
Because simulated checks prove logic under supplied cases, not that external APIs, schedules, host identity, network paths or production recovery work. Clear limitations prevent unsupported claims.
Northstar Operations Control Room
The Northstar Ops NOC needs a decision engine that turns a validated service inventory and a finite series of recorded health checks into a reliable site report. When monitoring identifies a sustained failure, the program prepares deduplicated incident drafts. In simulate mode it may also propose one approved, revision-matched change for review. The entire workflow is offline: no real probes, API tickets, mail, service restarts or infrastructure modifications.
Work through one complete cycle before building your program
Start with this fictional plan-mode dataset and reason through what the program should return. This is a worked decision trace, not a completed implementation or an external service request.
csv_text = 'host,site,service,revision\nAPP-01,HQ,web,r7\nDB-01,HQ,backup,b3\n'
cycles = [
{'APP-01':'failed', 'DB-01':'healthy'},
{'APP-01':'failed', 'DB-01':'healthy'},
]
settings = {'site':'HQ','mode':'plan','fail_after':2,'recover_after':2}
previous = {'report_id':'verified-009'}
seen = set()
# Plan mode does not use approval.- Validate the inventory and coverage: two unique HQ devices appear in both cycles; the CSV has all four required columns.
- Count consecutive failures: APP-01 opens one alert on the second confirmed failure, while DB-01 remains healthy.
- Build a stable unseen key hq:app-01:web. This creates one ticket draft, not an actual ticket.
- Apply the planning boundary: mode 'plan' cannot propose a change, even if a valid approval were supplied.
- Preserve the previous report unchanged and build one deterministic new report with a complete classification for both devices.
Reveal the exact successful result only after predicting the output.
{'ok': True, 'mode': 'plan',
'report': {'site': 'HQ', 'total': 2,
'alerts': ['APP-01'], 'recovered': [],
'watch': [], 'unknown': [], 'healthy': ['DB-01']},
'ticket_drafts': [{'key': 'hq:app-01:web', 'target': 'APP-01',
'summary': 'WEB check requires review'}],
'change_plans': [], 'previous': {'report_id': 'verified-009'}}Try changing APP-01's second sample from failed to unknown. It becomes unknown rather than an open alert, so no ticket draft is proposed.
Before coding, read the full acceptance contract on the next page. These eight deliverables establish exactly what counts as a complete or blocked run. Write a small validation helper, a state machine, a deterministic reporting helper, and a tightly gated simulation planner rather than one long chain of side-effecting commands.
- Implement run_control_room(csv_text, cycles, settings, approval, previous, seen) as a pure function. Do not perform network calls, file writes, shell commands, actual ticket updates, scheduling or printing within the function.
- Validate settings as exactly site, mode, fail_after and recover_after. Site is a nonempty string (normalized uppercase); mode is plan or simulate. Thresholds are actual integers (not bools): fail_after 2–4, recover_after 1–3. seen must be a set of lowercase nonempty incident-key strings. On invalid settings or seen, block with reason config before processing any data.
- Parse csv_text with csv.DictReader; require exactly the unique headers host, site, service, revision in any order. All row values must be nonempty strings. Normalize host/site uppercase and service lowercase; service is web or backup. Reject malformed headers/rows as csv; duplicates of (site,host), ignoring case and whitespace, as duplicate.
- Select inventory rows from settings.site. cycles must be a list of 1–8 dictionaries (even for a zero-device site). Each cycle must contain exactly one state for every selected-site host, matched case-insensitively after trimming; allowed states are healthy, failed and unknown. Reject wrong containers, repeated normalized host keys and invalid state values as observations; missing or extra host coverage as coverage. When a selected site has zero devices, one or more empty dictionaries are valid cycles; an empty cycles list is invalid.
- Track each selected host across all cycles. Open an alert after fail_after consecutive failed states; while open, close it after recover_after consecutive healthy states. An unknown resets streak counters but never automatically closes an open alert. At the final cycle, classify each host into exactly one sorted list: alerts, recovered, watch, unknown, healthy. An open alert takes priority; otherwise final unknown is unknown, final failed below threshold is watch, a host that recovered from an earlier alert is recovered, and remaining hosts are healthy.
- For every final open alert not already present in seen, return one sorted ticket draft containing key=site:host:service (lowercase), target=normalized hostname and summary='SERVICE check requires review' with uppercase service. This is only a draft: no real ticket is created. Do not mutate seen or earlier reports.
- In simulate mode, approval must be a dictionary with exactly id, site, target, action, expected_revision, approved, window_open. Require nonblank strings, actual True booleans, a matching normalized site, a known selected-site target, and the exact approved action 'review-service-restart'; otherwise return approval. If the approved target is currently alerting, compare its captured inventory revision with expected_revision; a mismatch returns stale. On a match, propose {change_id:ID,target:HOST,action:'review-service-restart',state:'ready-for-review'}. In plan mode approval is ignored and change_plans is empty. A proposal never means execution or verified recovery.
- On every failure return exactly {'ok':False,'reason':CODE,'previous':previous}, with CODE one of config, csv, duplicate, observations, coverage, approval, stale. On success return exactly {'ok':True,'mode':MODE,'report':{'site':SITE,'total':N,'alerts':[...],'recovered':[...],'watch':[...],'unknown':[...],'healthy':[...]},'ticket_drafts':[...],'change_plans':[...],'previous':previous}. All lists are deterministically sorted, and all input objects remain unchanged.
Write one complete program. Defend eight scenarios.
Your next guided milestone is the integrated Control Room capstone, not a sequence of more isolated exercises. It includes a real Python editor, eight changed-input scenario groups, an explicit output contract, an independent multi-file local project, and a final engineering handoff.
Use the shared Continue Your Learning Path panel below to mark Lesson 06 complete and open the final capstone. That panel also tracks full-course completion after you finish the last milestone.
