Capstone › Capstone Build I: Foundation › Day 351

Hands-on lab — Day 351: Choosing and Scoping Your Capstone

Commands

Setup

pip install -r requirements/requirements.txt

Run

python examples/scoping.py

Test

bash tests/run_tests.sh

File tree

examples/scoping.py
expected-output/examples-run.txt
expected-output/FIELDS.md
expected-output/measured-values.txt
expected-output/run-output.txt
expected-output/starter-run.txt
expected-output/test-output.txt
expected-output/test-run.txt
metadata.yml
README.md
requirements/requirements.txt
security.md
starter/scoping.py
tests/run_tests.sh
tests/test_scoping.py
troubleshooting.md

Lab README

Day 351 Lab: Choosing and Scoping Your Capstone

Lesson

Purpose

Build a Capstone Project Scoping & Feasibility Scorer in Python that audits project charters across the 6 mandatory engineering pillars and quantifies SLA feasibility.

Learning objectives

  • Define a structured project charter schema.
  • Validate the 6 mandatory engineering pillars.
  • Calculate SLA feasibility scores and risk ratings.
  • Generate an approved Project Charter and Feasibility Report.

Prerequisites

  • Python 3.10+ installed
  • pytest installed

Supported operating systems

  • macOS, Linux, Windows WSL2

Hardware requirements

  • Standard CPU, 512MB RAM

Required software

  • Python 3.10+, pytest

Free and open-source options

  • Python Standard Library, Pytest

Installation

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements/requirements.txt

File structure

  • starter/scoping.py: Starter implementation skeleton
  • examples/scoping.py: Verified reference implementation
  • tests/test_scoping.py: Test suite
  • expected-output/: Captured execution logs

How to run

python3 examples/scoping.py

What the commands do

  • Evaluates sample project charters and computes quantitative feasibility metrics.

Expected output

{
  "project_name": "Enterprise Financial Analyst Assistant",
  "feasibility_score": 100.0,
  "feasibility_grade": "EXCELLENT",
  "warnings": [],
  "is_approved_for_build": true
}

Validation steps

Run test runner:

bash tests/run_tests.sh

Tests

The test suite validates:

  • Mandatory engineering pillar verification
  • SLA latency and accuracy auditing
  • Feasibility score computation
  • Incomplete charter rejection
  • Production charter JSON export

Cleanup

rm -rf .pytest_cache __pycache__ .venv

Troubleshooting

Ensure all 6 pillar keys are present in the charter dictionary.

Security notes

Runs locally with zero external network calls.

Extension exercises

Implement an automated Markdown Project Charter exporter.

Day number: 351 of 365

Expected output

FIELDS.md

# Measured Values
- `feasibility_score`: 100.0
- `pillars_validated`: 6

examples-run.txt

{
  "project_name": "Enterprise Financial Analyst Assistant",
  "feasibility_score": 100.0,
  "feasibility_grade": "EXCELLENT",
  "warnings": [],
  "is_approved_for_build": true
}

measured-values.txt

feasibility_score=100.0
pillars_validated=6

run-output.txt

{
  "project_name": "Enterprise Financial Analyst Assistant",
  "feasibility_score": 100.0,
  "feasibility_grade": "EXCELLENT",
  "warnings": [],
  "is_approved_for_build": true
}

starter-run.txt

An untouched starter fails the suite. Captured from a real run:

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <examples.scoping.CapstoneScopingValidator object at 0x10677e190>

    def evaluate_feasibility(self) -> Dict[str, Any]:
>       raise NotImplementedError('TASK 2: implement evaluate_feasibility.')
E       NotImplementedError: TASK 2: implement evaluate_feasibility.

examples/scoping.py:21: NotImplementedError
=========================== short test summary info ============================
FAILED tests/test_scoping.py::test_valid_charter_evaluation - NotImplementedE...
FAILED tests/test_scoping.py::test_missing_pillars_penalty - NotImplementedEr...
FAILED tests/test_scoping.py::test_excessive_latency_sla_penalty - NotImpleme...
FAILED tests/test_scoping.py::test_low_eval_accuracy_sla_penalty - NotImpleme...
FAILED tests/test_scoping.py::test_unviable_charter_rejection - NotImplemente...
============================== 5 failed in 0.03s ===============================

Implement each TASK in starter/, copy it over examples/, and the same
suite goes green.

test-output.txt

============================= test session starts ==============================
platform darwin -- Python 3.14.0, pytest-9.1.1, pluggy-1.6.0 -- <repo>/.venv-tools/bin/python3.14
cachedir: .pytest_cache
rootdir: <repo>/labs/sections/capstone/day-351-choosing-and-scoping-your-capstone
plugins: cov-7.1.0, anyio-4.14.2
collecting ... collected 5 items

tests/test_scoping.py::test_valid_charter_evaluation PASSED              [ 20%]
tests/test_scoping.py::test_missing_pillars_penalty PASSED               [ 40%]
tests/test_scoping.py::test_excessive_latency_sla_penalty PASSED         [ 60%]
tests/test_scoping.py::test_low_eval_accuracy_sla_penalty PASSED         [ 80%]
tests/test_scoping.py::test_unviable_charter_rejection PASSED            [100%]

============================== 5 passed in 0.01s ===============================

test-run.txt

============================= test session starts ==============================
platform darwin -- Python 3.14.0, pytest-9.1.1, pluggy-1.6.0 -- <repo>/.venv-tools/bin/python3.14
cachedir: .pytest_cache
rootdir: <repo>/labs/sections/capstone/day-351-choosing-and-scoping-your-capstone
plugins: cov-7.1.0, anyio-4.14.2
collecting ... collected 5 items

tests/test_scoping.py::test_valid_charter_evaluation PASSED              [ 20%]
tests/test_scoping.py::test_missing_pillars_penalty PASSED               [ 40%]
tests/test_scoping.py::test_excessive_latency_sla_penalty PASSED         [ 60%]
tests/test_scoping.py::test_low_eval_accuracy_sla_penalty PASSED         [ 80%]
tests/test_scoping.py::test_unviable_charter_rejection PASSED            [100%]

============================== 5 passed in 0.01s ===============================

Source files

examples/scoping.py (2812 bytes)
import json
from typing import Dict, Any, List, Tuple

class CapstoneScopingValidator:
    def __init__(self, project_charter: Dict[str, Any]):
        self.charter = project_charter
        self.pillars = [
            "data_ingestion",
            "core_ai_reasoning",
            "automated_evals",
            "cloud_deployment",
            "observability",
            "security_hardening"
        ]

    def validate_pillars(self) -> Tuple[bool, List[str]]:
        missing = []
        for p in self.pillars:
            if p not in self.charter.get("engineering_pillars", {}):
                missing.append(f"Missing mandatory pillar: {p}")
            elif not self.charter["engineering_pillars"][p].get("enabled", False):
                missing.append(f"Pillar disabled: {p}")
        return len(missing) == 0, missing

    def evaluate_feasibility(self) -> Dict[str, Any]:
        score = 100.0
        warnings = []

        slas = self.charter.get("slas", {})
        if "p95_latency_ms" not in slas or slas["p95_latency_ms"] > 1000:
            score -= 15.0
            warnings.append("p95 latency SLA missing or exceeding 1000ms threshold")

        if "min_eval_accuracy" not in slas or slas["min_eval_accuracy"] < 0.80:
            score -= 15.0
            warnings.append("Evaluation accuracy target missing or below 80%")

        valid_pillars, missing_pillars = self.validate_pillars()
        if not valid_pillars:
            score -= 10.0 * len(missing_pillars)
            warnings.extend(missing_pillars)

        grade = "EXCELLENT" if score >= 85 else ("VIABLE" if score >= 70 else "AT_RISK")

        return {
            "project_name": self.charter.get("title", "Untitled Capstone"),
            "feasibility_score": max(0.0, score),
            "feasibility_grade": grade,
            "warnings": warnings,
            "is_approved_for_build": score >= 70.0
        }

if __name__ == "__main__":
    charter = {
        "title": "Enterprise Financial Analyst Assistant",
        "archetype": "enterprise_rag",
        "slas": {"p95_latency_ms": 450, "min_eval_accuracy": 0.88, "monthly_budget_usd": 30},
        "engineering_pillars": {
            "data_ingestion": {"enabled": True, "method": "hybrid_vector_bm25"},
            "core_ai_reasoning": {"enabled": True, "method": "fastapi_structured_llm"},
            "automated_evals": {"enabled": True, "method": "ragas_triad_suite"},
            "cloud_deployment": {"enabled": True, "method": "docker_compose_k8s"},
            "observability": {"enabled": True, "method": "opentelemetry_prometheus"},
            "security_hardening": {"enabled": True, "method": "pii_vault_prompt_waf"}
        }
    }
    validator = CapstoneScopingValidator(charter)
    print(json.dumps(validator.evaluate_feasibility(), indent=2))
metadata.yml (394 bytes)
lesson_id: D351
day: 351
kind: python
languages:
- python
setup_commands:
- pip install -r requirements/requirements.txt
run_commands:
- python examples/scoping.py
test_commands:
- bash tests/run_tests.sh
cleanup_commands:
- rm -rf __pycache__ .pytest_cache
requires_network: false
requires_api_key: false
estimated_minutes: 55
last_executed: '2026-08-30'
executed_on: macOS 15.0 Apple Silicon
requirements/requirements.txt (14 bytes)
pytest>=7.0.0
starter/scoping.py (1651 bytes)
"""STARTER -- implement each TASK below, then run the tests.

Every function that raises NotImplementedError is yours to write. The
imports, constants and data structures are given; the logic is not.
Run `bash tests/run_tests.sh` to see which tasks are still outstanding.
"""

import json
from typing import Dict, Any, List, Tuple

class CapstoneScopingValidator:

    def __init__(self, project_charter: Dict[str, Any]):
        self.charter = project_charter
        self.pillars = ['data_ingestion', 'core_ai_reasoning', 'automated_evals', 'cloud_deployment', 'observability', 'security_hardening']

    def validate_pillars(self) -> Tuple[bool, List[str]]:
        raise NotImplementedError('TASK 1: implement validate_pillars.')

    def evaluate_feasibility(self) -> Dict[str, Any]:
        raise NotImplementedError('TASK 2: implement evaluate_feasibility.')
if __name__ == '__main__':
    charter = {'title': 'Enterprise Financial Analyst Assistant', 'archetype': 'enterprise_rag', 'slas': {'p95_latency_ms': 450, 'min_eval_accuracy': 0.88, 'monthly_budget_usd': 30}, 'engineering_pillars': {'data_ingestion': {'enabled': True, 'method': 'hybrid_vector_bm25'}, 'core_ai_reasoning': {'enabled': True, 'method': 'fastapi_structured_llm'}, 'automated_evals': {'enabled': True, 'method': 'ragas_triad_suite'}, 'cloud_deployment': {'enabled': True, 'method': 'docker_compose_k8s'}, 'observability': {'enabled': True, 'method': 'opentelemetry_prometheus'}, 'security_hardening': {'enabled': True, 'method': 'pii_vault_prompt_waf'}}}
    validator = CapstoneScopingValidator(charter)
    print(json.dumps(validator.evaluate_feasibility(), indent=2))
tests/run_tests.sh (253 bytes)
#!/usr/bin/env bash
set -e
export PYTHONPATH=examples:.
if [ -n "$PYTEST" ]; then
    $PYTEST tests/test_*.py -v
elif command -v pytest &> /dev/null; then
    pytest tests/test_*.py -v
else
    python3 -m unittest discover -s tests -p 'test_*.py' -v
fi
tests/test_scoping.py (2279 bytes)
import pytest
from examples.scoping import CapstoneScopingValidator

@pytest.fixture
def valid_charter():
    return {
        "title": "Medical Diagnostic Assistant",
        "archetype": "enterprise_rag",
        "slas": {"p95_latency_ms": 400, "min_eval_accuracy": 0.90, "monthly_budget_usd": 50},
        "engineering_pillars": {
            "data_ingestion": {"enabled": True},
            "core_ai_reasoning": {"enabled": True},
            "automated_evals": {"enabled": True},
            "cloud_deployment": {"enabled": True},
            "observability": {"enabled": True},
            "security_hardening": {"enabled": True}
        }
    }

def test_valid_charter_evaluation(valid_charter):
    validator = CapstoneScopingValidator(valid_charter)
    res = validator.evaluate_feasibility()
    assert res["feasibility_score"] == 100.0
    assert res["feasibility_grade"] == "EXCELLENT"
    assert res["is_approved_for_build"] is True
    assert len(res["warnings"]) == 0

def test_missing_pillars_penalty(valid_charter):
    del valid_charter["engineering_pillars"]["observability"]
    del valid_charter["engineering_pillars"]["security_hardening"]
    validator = CapstoneScopingValidator(valid_charter)
    res = validator.evaluate_feasibility()
    assert res["feasibility_score"] == 80.0
    assert len(res["warnings"]) == 2

def test_excessive_latency_sla_penalty(valid_charter):
    valid_charter["slas"]["p95_latency_ms"] = 2500
    validator = CapstoneScopingValidator(valid_charter)
    res = validator.evaluate_feasibility()
    assert res["feasibility_score"] == 85.0
    assert any("latency" in w for w in res["warnings"])

def test_low_eval_accuracy_sla_penalty(valid_charter):
    valid_charter["slas"]["min_eval_accuracy"] = 0.65
    validator = CapstoneScopingValidator(valid_charter)
    res = validator.evaluate_feasibility()
    assert res["feasibility_score"] == 85.0
    assert any("accuracy" in w for w in res["warnings"])

def test_unviable_charter_rejection():
    charter = {"title": "Vague Unbounded App"}
    validator = CapstoneScopingValidator(charter)
    res = validator.evaluate_feasibility()
    assert res["feasibility_score"] < 50.0
    assert res["feasibility_grade"] == "AT_RISK"
    assert res["is_approved_for_build"] is False

Troubleshooting

Troubleshooting - Day 351\nEnsure all 6 mandatory pillar keys exist in the charter.\n

Security notes

Security - Day 351\nScoping validator audits project security pillar readiness.\n