# 980 Skill Architecture Design 07e057a3

> <!-- Threat Modeling Skill | Version 3.0.0 (20260201a) | https://github.com/fr33d3m0n/threat-modeling | License: BSD-3-Clause -->

- Skill: `tools-only/980-skill-architecture-design-07e057a3` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add tools-only/980-skill-architecture-design-07e057a3`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tools-only/980-skill-architecture-design-07e057a3/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Security
- Author: tools-only (https://skillmd.com/u/tools-only)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/tools-only/980-skill-architecture-design-07e057a3

---

<!-- Threat Modeling Skill | Version 3.0.0 (20260201a) | https://github.com/fr33d3m0n/threat-modeling | License: BSD-3-Clause -->

# STRIDE Threat Modeling System Architecture Analysis

> **Version**: 2.1.0
> **Date**: 2026-01-03
> **Purpose**: Comprehensive system architecture analysis with diagrams and module relationships

> **Note (v2.1.0)**: Directory structure refactored:
> - `docs/` → `references/`
> - `knowledge/`, `schemas/`, `templates/` → `assets/` subdirectories

---

## 1. System Architecture Overview

### 1.1 High-Level Architecture Diagram

```
┌─────────────────────────────────────────────────────────────────────────────────────────────┐
│                           Code-First Deep Risk Analysis System v2.1.0                          │
├─────────────────────────────────────────────────────────────────────────────────────────────┤
│                                                                                              │
│  ┌───────────────────────────────────────────────────────────────────────────────────────┐ │
│  │                              PRESENTATION LAYER (Layer 4)                               │ │
│  ├───────────────────────────────────────────────────────────────────────────────────────┤ │
│  │                                                                                        │ │
│  │  ┌──────────────────────────────────────────────────────────────────────────────┐    │ │
│  │  │                         Claude Skill Interface                                │    │ │
│  │  │  SKILL.md ──► YAML Front Matter (name, description, triggers)                 │    │ │
│  │  │     │         ├── 8-Phase Workflow Definition                                │    │ │
│  │  │     │         ├── Report Output Convention                                   │    │ │
│  │  │     │         ├── Language Adaptation Rules                                  │    │ │
│  │  │     │         └── Core Data Model (Entity Definitions)                       │    │ │
│  │  │     │                                                                         │    │ │
│  │  │     └──► Templates (9 files)                                                  │    │ │
│  │  │           ├── RISK-ASSESSMENT-REPORT.template.md (Main Report)               │    │ │
│  │  │           ├── RISK-INVENTORY.template.md                                     │    │ │
│  │  │           ├── MITIGATION-MEASURES.template.md                                │    │ │
│  │  │           ├── PENETRATION-TEST-PLAN.template.md                              │    │ │
│  │  │           └── 5 additional templates                                         │    │ │
│  │  └──────────────────────────────────────────────────────────────────────────────┘    │ │
│  └───────────────────────────────────────────────────────────────────────────────────────┘ │
│                                              │                                              │
│                                              ▼                                              │
│  ┌───────────────────────────────────────────────────────────────────────────────────────┐ │
│  │                              WORKFLOW LAYER (Layer 3)                                  │ │
│  ├───────────────────────────────────────────────────────────────────────────────────────┤ │
│  │                                                                                        │ │
│  │  ┌────────────┐  ┌────────────┐  ┌────────────┐  ┌────────────┐                      │ │
│  │  │ WORKFLOW.md│  │VALIDATION.md│ │  REPORT.md │  │  GUIDE.md  │                      │ │
│  │  │ (839 lines)│  │ (946 lines)│  │ (852 lines)│  │ (580 lines)│                      │ │
│  │  │            │  │            │  │            │  │            │                      │ │
│  │  │ Phase 1-5  │  │  Phase 6   │  │ Phase 7-8  │  │ User Guide │                      │ │
│  │  │ Steps      │  │  Validation│  │ Mitigation │  │            │                      │ │
│  │  └─────┬──────┘  └─────┬──────┘  └─────┬──────┘  └────────────┘                      │ │
│  │        │               │               │                                              │ │
│  │        └───────────────┴───────────────┘                                              │ │
│  │                        │                                                              │ │
│  │                        ▼                                                              │ │
│  │  ┌──────────────────────────────────────────────────────────────────────────────┐    │ │
│  │  │                         8-Phase Execution Pipeline                            │    │ │
│  │  │  P1 → P2 → P3 → P4 → P5 → P6 → P7 → P8                                       │    │ │
│  │  │  Project  DFD   Trust Security STRIDE Risk   Mitigation Report               │    │ │
│  │  │                      Design  Analysis Validate                                │    │ │
│  │  └──────────────────────────────────────────────────────────────────────────────┘    │ │
│  └───────────────────────────────────────────────────────────────────────────────────────┘ │
│                                              │                                              │
│                                              ▼                                              │
│  ┌───────────────────────────────────────────────────────────────────────────────────────┐ │
│  │                              SCRIPT LAYER (Layer 2)                                    │ │
│  ├───────────────────────────────────────────────────────────────────────────────────────┤ │
│  │                                                                                        │ │
│  │  scripts/                                                                             │ │
│  │  ├── unified_kb_query.py (102KB)     ◄── Main KB Query Interface                     │ │
│  │  │   ├── STRIDE queries (--stride)                                                    │ │
│  │  │   ├── CWE/CAPEC chains (--cwe, --capec, --full-chain)                             │ │
│  │  │   ├── CVE lookups (--cve, --cve-for-cwe)                                          │ │
│  │  │   ├── Semantic search (--search)                                                   │ │
│  │  │   ├── ASVS/WSTG verification (--asvs-level, --wstg)                               │ │
│  │  │   └── Compliance queries (--stride-compliance)                                     │ │
│  │  │                                                                                    │ │
│  │  ├── module_discovery.py (11KB)            ◄── Phase 1: Project Structure                  │ │
│  │  │   └── File categorization, type detection                                         │ │
│  │  │                                                                                    │ │
│  │  ├── stride_matrix.py (7.6KB)        ◄── Phase 5: STRIDE per Interaction             │ │
│  │  │   └── Threat category calculation                                                 │ │
│  │  │                                                                                    │ │
│  │  ├── phase_data.py                    ◄── Cross-Phase Data & Validation (v2.2.2)    │ │
│  │  │   └── YAML extraction, CP1/CP2/CP3 validation                                    │ │
│  │  │                                                                                    │ │
│  │  │  [Development Only - Not in Release]                                              │ │
│  │  │  ├── collect_code_stats.py        ◄── LOC/File Statistics                        │ │
│  │  │  ├── build_knowledge_base.py      ◄── KB Build (Offline)                          │ │
│  │  │  ├── build_cve_index.py           ◄── CVE Index Build                             │ │
│  │  │  ├── prebuild_semantic_index.py   ◄── Embedding Generation                        │ │
│  │  │  └── kb_incremental_update.py     ◄── KB Updates                                  │ │
│  │                                                                                        │ │
│  └───────────────────────────────────────────────────────────────────────────────────────┘ │
│                                              │                                              │
│                                              ▼                                              │
│  ┌───────────────────────────────────────────────────────────────────────────────────────┐ │
│  │                              KNOWLEDGE LAYER (Layer 1)                                 │ │
│  ├───────────────────────────────────────────────────────────────────────────────────────┤ │
│  │                                                                                        │ │
│  │  ┌─────────────────────────────┐  ┌─────────────────────────────────────────────────┐│ │
│  │  │    SQLite Databases         │  │           YAML Knowledge Files                   ││ │
│  │  │                             │  │                                                   ││ │
│  │  │  security_kb.sqlite (14MB)  │  │  security-design.yaml (17KB)                     ││ │
│  │  │  ├── CWE (974)              │  │  ├── 16 Security Domains                         ││ │
│  │  │  ├── CAPEC (615)            │  │  └── Domain → STRIDE mapping                     ││ │
│  │  │  ├── ATT&CK (835)           │  │                                                   ││ │
│  │  │  ├── WSTG (121)             │  │  stride-library.yaml (5KB)                       ││ │
│  │  │  ├── MASTG (206)            │  │  ├── STRIDE categories                           ││ │
│  │  │  ├── ASVS (345)             │  │  └── Element→threat mapping                      ││ │
│  │  │  ├── Compliance (115)       │  │                                                   ││ │
│  │  │  └── Embeddings (3,278)     │  │  capec-mappings.yaml (300KB)                     ││ │
│  │  │                             │  │  ├── Attack patterns                              ││ │
│  │  │  security_kb_extension.sqlite │  │  └── ATT&CK mapping                             ││ │
│  │  │  (304MB)                    │  │                                                   ││ │
│  │  │  ├── CVE (323,830)          │  │  llm-threats.yaml (31KB)                         ││ │
│  │  │  └── CVE→CWE (108,409)      │  │  └── OWASP LLM Top 10                            ││ │
│  │  └─────────────────────────────┘  └─────────────────────────────────────────────────┘│ │
│  │                                                                                        │ │
│  │  ┌─────────────────────────────────────────────────────────────────────────────────┐ │ │
│  │  │                         Security Controls (L3+L4)                                │ │ │
│  │  │  security-controls/                                                              │ │ │
│  │  │  ├── control-set-{01-10}-*.md    ◄── 10 Core Domain Controls                    │ │ │
│  │  │  ├── control-set-ext-*.md        ◄── 8 Extended Domain Controls                 │ │ │
│  │  │  └── references/ (73 files)       ◄── OWASP Scenario Practices                  │ │ │
│  │  └─────────────────────────────────────────────────────────────────────────────────┘ │ │
│  └───────────────────────────────────────────────────────────────────────────────────────┘ │
│                                                                                              │
└─────────────────────────────────────────────────────────────────────────────────────────────┘
```

### 1.2 Component Summary

| Layer | Component | Files | Purpose |
|-------|-----------|-------|---------|
| **Layer 4** | Presentation | 1 SKILL + 9 templates + 4 schemas | User interface and report generation |
| **Layer 3** | Workflow | WORKFLOW + VALIDATION + REPORT + GUIDE | Phase execution logic |
| **Layer 2** | Scripts | 11 Python scripts | Automation and data processing |
| **Layer 1** | Knowledge | 2 SQLite DBs + 12 YAML files + 90 MD controls | Security knowledge store |

---

## 2. Data Flow Diagram

### 2.1 Complete System Data Flow

```
┌─────────────────────────────────────────────────────────────────────────────────────────────┐
│                              STRIDE System Data Flow Diagram                                 │
├─────────────────────────────────────────────────────────────────────────────────────────────┤
│                                                                                              │
│  ┌──────────────────────────────────────────────────────────────────────────────────────┐  │
│  │                              INPUT SOURCES                                            │  │
│  ├──────────────────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                                       │  │
│  │  [EI-01]              [EI-02]              [EI-03]              [EI-04]               │  │
│  │  User/Claude  ───►    Target      ───►    Knowledge    ───►    Previous              │  │
│  │  Request              Project              Base                 Session              │  │
│  │  (NL command)         (Codebase)           (SQLite+YAML)        (_session_meta)      │  │
│  │                                                                                       │  │
│  └────────┬─────────────────┬─────────────────┬─────────────────────┬───────────────────┘  │
│           │                 │                 │                     │                       │
│           ▼                 ▼                 ▼                     ▼                       │
│  ┌──────────────────────────────────────────────────────────────────────────────────────┐  │
│  │                              8-PHASE PROCESSING PIPELINE                              │  │
│  ├──────────────────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                                       │  │
│  │  ╔═══════════════╗      DF-01: project_context                                       │  │
│  │  ║   Phase 1     ║ ────────────────────────────────────────────────────────────►     │  │
│  │  ║   Project     ║      - file_structure, tech_stack, entry_points                   │  │
│  │  ║ Understanding ║      - security_modules, scale_metrics                            │  │
│  │  ╚═══════════════╝                                                                   │  │
│  │         │                                                                             │  │
│  │         │ DF-01                                                                       │  │
│  │         ▼                                                                             │  │
│  │  ╔═══════════════╗      DF-02: dfd_elements                                          │  │
│  │  ║   Phase 2     ║ ────────────────────────────────────────────────────────────►     │  │
│  │  ║   DFD/Call    ║      - processes[], data_stores[], data_flows[]                   │  │
│  │  ║   Flow        ║      - external_interactors[], element_map                        │  │
│  │  ╚═══════════════╝                                                                   │  │
│  │         │                                                                             │  │
│  │         │ DF-01 + DF-02                                                               │  │
│  │         ▼                                                                             │  │
│  │  ╔═══════════════╗      DF-03: boundary_context                                      │  │
│  │  ║   Phase 3     ║ ────────────────────────────────────────────────────────────►     │  │
│  │  ║   Trust       ║      - trust_boundaries[], boundary_crossings[]                   │  │
│  │  ║   Boundaries  ║      - security_zones, element_zone_mapping                       │  │
│  │  ╚═══════════════╝                                                                   │  │
│  │         │                                                                             │  │
│  │         │ DF-01 + DF-02 + DF-03                                                       │  │
│  │         ▼                                                                             │  │
│  │  ╔═══════════════╗      DF-04: security_gaps                                         │  │
│  │  ║   Phase 4     ║ ────────────────────────────────────────────────────────────►     │  │
│  │  ║   Security    ║      - domain_assessments[15], gaps[], recommendations[]          │  │
│  │  ║   Design      ║      - security_coverage_matrix                                   │  │
│  │  ╚═══════════════╝                                                                   │  │
│  │         │              ┌──────────────────────────────────────────────────────┐      │  │
│  │         │              │            KB QUERY: STRIDE → CWE → CAPEC            │      │  │
│  │         │              │  python unified_kb_query.py --stride {category}      │      │  │
│  │         ▼              └──────────────────────────────────────────────────────┘      │  │
│  │  ╔═══════════════╗      DF-05: threat_inventory                                      │  │
│  │  ║   Phase 5     ║ ────────────────────────────────────────────────────────────►     │  │
│  │  ║   STRIDE      ║      - threats[] (T-{S}-{E}-{Seq})                                │  │
│  │  ║   Analysis    ║      - element_threat_map, stride_distribution                    │  │
│  │  ╚═══════════════╝      - cwe_refs[], capec_refs[], total: 50-200                    │  │
│  │         │              ┌──────────────────────────────────────────────────────┐      │  │
│  │         │              │         KB QUERY: CAPEC → ATT&CK → CVE/KEV          │      │  │
│  │         │              │  python unified_kb_query.py --capec {id} --attack   │      │  │
│  │         ▼              └──────────────────────────────────────────────────────┘      │  │
│  │  ╔═══════════════╗      DF-06: validated_risks                                       │  │
│  │  ║   Phase 6     ║ ────────────────────────────────────────────────────────────►     │  │
│  │  ║   Risk        ║      - validated_risks[] (VR-{Seq})                               │  │
│  │  ║   Validation  ║      - poc_details[], attack_paths[], attack_chains[]             │  │
│  │  ╚═══════════════╝      - threat_disposition (count conservation)                    │  │
│  │         │              ┌──────────────────────────────────────────────────────┐      │  │
│  │         │              │      KB QUERY: CWE Mitigations + ASVS + Controls     │      │  │
│  │         │              │  python unified_kb_query.py --cwe {id} --mitigations │      │  │
│  │         ▼              └──────────────────────────────────────────────────────┘      │  │
│  │  ╔═══════════════╗      DF-07: mitigation_plan                                       │  │
│  │  ║   Phase 7     ║ ────────────────────────────────────────────────────────────►     │  │
│  │  ║   Mitigation  ║      - mitigations[] (M-{Seq})                                    │  │
│  │  ║   Planning    ║      - fix_locations, asvs_compliance, implementation_steps       │  │
│  │  ╚═══════════════╝                                                                   │  │
│  │         │                                                                             │  │
│  │         │ ALL DataFlows (DF-01 to DF-07)                                             │  │
│  │         ▼                                                                             │  │
│  │  ╔═══════════════╗      DF-08: final_reports                                         │  │
│  │  ║   Phase 8     ║ ────────────────────────────────────────────────────────────►     │  │
│  │  ║   Report      ║      - 4 Required Reports + 6 Phase Documents                     │  │
│  │  ║   Generation  ║      - Risk_Assessment_Report/{PROJECT}-*.md                      │  │
│  │  ╚═══════════════╝                                                                   │  │
│  │                                                                                       │  │
│  └──────────────────────────────────────────────────────────────────────────────────────┘  │
│                                              │                                              │
│                                              ▼                                              │
│  ┌──────────────────────────────────────────────────────────────────────────────────────┐  │
│  │                              OUTPUT ARTIFACTS                                         │  │
│  ├──────────────────────────────────────────────────────────────────────────────────────┤  │
│  │                                                                                       │  │
│  │  Risk_Assessment_Report/                                                              │  │
│  │  │                                                                                    │  │
│  │  ├── {PROJECT}-RISK-ASSESSMENT-REPORT.md    ◄── Main Report (all phases aggregated)  │  │
│  │  ├── {PROJECT}-RISK-INVENTORY.md            ◄── Complete VR list with threat_refs    │  │
│  │  ├── {PROJECT}-MITIGATION-MEASURES.md       ◄── M-{Seq} with fix_locations          │  │
│  │  ├── {PROJECT}-PENETRATION-TEST-PLAN.md     ◄── POC-based test plan                 │  │
│  │  │                                                                                    │  │
│  │  ├── P1-PROJECT-UNDERSTANDING.md            ◄── Phase 1 working document             │  │
│  │  ├── P2-DFD-ANALYSIS.md                     ◄── DFD elements and flows               │  │
│  │  ├── P3-TRUST-BOUNDARY.md                   ◄── Boundary definitions                 │  │
│  │  ├── P4-SECURITY-DESIGN-REVIEW.md           ◄── 16 domain assessments               │  │
│  │  ├── P5-STRIDE-THREATS.md                   ◄── Complete threat inventory           │  │
│  │  └── P6-RISK-VALIDATION.md                  ◄── POCs and attack paths               │  │
│  │                                                                                       │  │
│  │  .phase_working/                                                                      │  │
│  │  └── _session_meta.yaml                     ◄── Session state for recovery           │  │
│  │                                                                                       │  │
│  └──────────────────────────────────────────────────────────────────────────────────────┘  │
│                                                                                              │
└─────────────────────────────────────────────────────────────────────────────────────────────┘
```

### 2.2 Data Flow Summary Table

| Flow ID | Source | Target | Data Structure | Volume |
|---------|--------|--------|----------------|--------|
| DF-01 | P1 | P2,P3,P4 | project_context | 1 object |
| DF-02 | P2 | P3,P4,P5 | dfd_elements | 10-50 elements |
| DF-03 | P3 | P4,P5 | boundary_context | 3-10 boundaries |
| DF-04 | P4 | P5,P6 | security_gaps | 16 domain assessments |
| DF-05 | P5 | P6 | threat_inventory | 50-200 threats |
| DF-06 | P6 | P7,P8 | validated_risks | 5-30 VRs |
| DF-07 | P7 | P8 | mitigation_plan | 5-20 mitigations |
| DF-08 | P8 | Output | final_reports | 10 files |

---

## 3. Module Relationships

### 3.1 File Dependency Graph

```
┌─────────────────────────────────────────────────────────────────────────────────────────────┐
│                              Module Dependency Graph                                         │
├─────────────────────────────────────────────────────────────────────────────────────────────┤
│                                                                                              │
│  ┌─────────────────────────────────────────────────────────────────────────────────────┐   │
│  │                              SKILL.md (Entry Point)                                  │   │
│  │                              ════════════════════════                                │   │
│  │                                                                                      │   │
│  │  Defines:                                                                            │   │
│  │  ├── Workflow activation triggers                                                    │   │
│  │  ├── 8-Phase structure                                                               │   │
│  │  ├── Core Data Model (Finding → Threat → VR → Mitigation)                           │   │
│  │  ├── ID conventions (F-P{N}-{Seq}, T-{S}-{E}-{Seq}, VR-{Seq}, M-{Seq})              │   │
│  │  ├── Count conservation rules                                                        │   │
│  │  └── Knowledge architecture overview                                                 │   │
│  │                                                                                      │   │
│  └──────┬────────────────────────────────────────────────────────────────────┬─────────┘   │
│         │                                                                     │             │
│         │ references                                                          │ references  │
│         ▼                                                                     ▼             │
│  ┌───────────────────────┐  ┌────────────────────┐  ┌─────────────────────────────────┐   │
│  │     WORKFLOW.md       │  │    VALIDATION.md   │  │          REPORT.md              │   │
│  │  ═══════════════════  │  │  ═════════════════ │  │  ═══════════════════════════    │   │
│  │                       │  │                    │  │                                 │   │
│  │  Phase 1-5 Details:   │  │  Phase 6 Details:  │  │  Phase 7-8 Details:             │   │
│  │  ├── Step definitions │  │  ├── Consolidation │  │  ├── KB query patterns          │   │
│  │  ├── Output templates │  │  │   algorithm     │  │  ├── Mitigation templates       │   │
│  │  ├── Checkpoints      │  │  ├── Dedup rules   │  │  ├── ASVS integration          │   │
│  │  └── KB query points  │  │  ├── POC design    │  │  ├── Fix location tracking      │   │
│  │                       │  │  └── Attack paths  │  │  └── Report aggregation         │   │
│  └───────────┬───────────┘  └─────────┬──────────┘  └───────────────┬─────────────────┘   │
│              │                         │                             │                      │
│              │                         │                             │                      │
│              └─────────────────────────┼─────────────────────────────┘                      │
│                                        │                                                    │
│                                        │ use                                                │
│                                        ▼                                                    │
│  ┌──────────────────────────────────────────────────────────────────────────────────────┐  │
│  │                              assets/templates/ (9 files)                                     │  │
│  │                              ═════════════════════                                    │  │
│  │                                                                                       │  │
│  │  RISK-ASSESSMENT-REPORT.template.md  ◄── Main report structure (9 chapters)          │  │
│  │  RISK-INVENTORY.template.md          ◄── VR table with threat_refs                   │  │
│  │  MITIGATION-MEASURES.template.md     ◄── M-{Seq} with fix_location                   │  │
│  │  PENETRATION-TEST-PLAN.template.md   ◄── POC-based testing plan                      │  │
│  │  ARCHITECTURE-ANALYSIS.template.md   ◄── System architecture                         │  │
│  │  ATTACK-PATH-VALIDATION.template.md  ◄── Attack chain analysis                       │  │
│  │  COMPLIANCE-REPORT.template.md       ◄── Compliance mapping                          │  │
│  │  DFD-DIAGRAM.template.md             ◄── DFD visualization                           │  │
│  │  DFD-TEMPLATES.md                    ◄── DFD ASCII patterns                          │  │
│  │                                                                                       │  │
│  └──────────────────────────────────────────────────────────────────────────────────────┘  │
│                                        │                                                    │
│                                        │ validated by                                       │
│                                        ▼                                                    │
│  ┌──────────────────────────────────────────────────────────────────────────────────────┐  │
│  │                              assets/schemas/ (4 files)                                       │  │
│  │                              ══════════════════                                       │  │
│  │                                                                                       │  │
│  │  risk-detail.schema.md        ◄── VR structure, threat_refs required                 │  │
│  │  phase-risk-summary.schema.md ◄── threat_disposition, count conservation             │  │
│  │  report-naming.schema.md      ◄── {PROJECT}-{TYPE}.md naming rules                   │  │
│  │  mitigation-detail.schema.md  ◄── M-{Seq} structure, fix_location schema             │  │
│  │                                                                                       │  │
│  └──────────────────────────────────────────────────────────────────────────────────────┘  │
│                                                                                              │
└─────────────────────────────────────────────────────────────────────────────────────────────┘
```

### 3.2 Module Purpose Matrix

| Module | Type | Purpose | Dependencies |
|--------|------|---------|--------------|
| SKILL.md | Definition | Entry point, workflow definition, data model | - |
| WORKFLOW.md | Execution | Phase 1-5 step-by-step guide | SKILL.md |
| VALIDATION.md | Execution | Phase 6 consolidation and validation | SKILL.md, WORKFLOW.md |
| REPORT.md | Execution | Phase 7-8 mitigation and report | SKILL.md, VALIDATION.md |
| assets/templates/*.md | Template | Report structure and placeholders | Schemas |
| assets/schemas/*.md | Schema | Data validation rules | SKILL.md |

---

## 4. Workflow Decomposition

### 4.1 8-Phase Workflow Detail

```
┌─────────────────────────────────────────────────────────────────────────────────────────────┐
│                              8-Phase Workflow Decomposition                                  │
├─────────────────────────────────────────────────────────────────────────────────────────────┤
│                                                                                              │
│  ╔═══════════════════════════════════════════════════════════════════════════════════════╗ │
│  ║  PHASE 1: Project Understanding                                                        ║ │
│  ╠═══════════════════════════════════════════════════════════════════════════════════════╣ │
│  ║                                                                                        ║ │
│  ║  Steps:                                          Scripts:                              ║ │
│  ║  1. Get file structure ────────────────────────► module_discovery.py                 ║ │
│  ║  2. Identify project type                                                              ║ │
│  ║  3. Collect scale metrics ─────────────────────► module_discovery.py --stats         ║ │
│  ║  4. Read key files                                                                     ║ │
│  ║  5. Document architecture                                                              ║ │
│  ║                                                                                        ║ │
│  ║  Output: P1-PROJECT-UNDERSTANDING.md                                                   ║ │
│  ║  Data: project_context {file_structure, tech_stack, scale_metrics, modules}           ║ │
│  ╚═══════════════════════════════════════════════════════════════════════════════════════╝ │
│                                              │                                              │
│                                              ▼                                              │
│  ╔═══════════════════════════════════════════════════════════════════════════════════════╗ │
│  ║  PHASE 2: Call Flow & DFD Analysis                                                     ║ │
│  ╠═══════════════════════════════════════════════════════════════════════════════════════╣ │
│  ║                                                                                        ║ │
│  ║  Steps:                                          LLM Tasks:                            ║ │
│  ║  1. Identify External Interactors                - Trace user flows                   ║ │
│  ║  2. Map Processes                                - Identify data transformations      ║ │
│  ║  3. Identify Data Stores                         - Map sensitive data                  ║ │
│  ║  4. Define Data Flows                            - Assign element IDs                  ║ │
│  ║  5. Construct DFD                                                                      ║ │
│  ║                                                                                        ║ │
│  ║  Output: P2-DFD-ANALYSIS.md                                                            ║ │
│  ║  Data: dfd_elements {processes[], data_stores[], data_flows[], external_interactors[]}║ │
│  ╚═══════════════════════════════════════════════════════════════════════════════════════╝ │
│                                              │                                              │
│                                              ▼                                              │
│  ╔═══════════════════════════════════════════════════════════════════════════════════════╗ │
│  ║  PHASE 3: Trust Boundary Evaluation                                                    ║ │
│  ╠═══════════════════════════════════════════════════════════════════════════════════════╣ │
│  ║                                                                                        ║ │
│  ║  Steps:                                          LLM Tasks:                            ║ │
│  ║  1. Identify trust zones                         - Analyze network boundaries          ║ │
│  ║  2. Map elements to zones                        - Identify privilege transitions      ║ │
│  ║  3. Identify boundary crossings                  - Map data sensitivity                ║ │
│  ║  4. Document crossing risks                                                            ║ │
│  ║                                                                                        ║ │
│  ║  Output: P3-TRUST-BOUNDARY.md                                                          ║ │
│  ║  Data: boundary_context {trust_boundaries[], security_zones, boundary_crossings[]}    ║ │
│  ╚═══════════════════════════════════════════════════════════════════════════════════════╝ │
│                                              │                                              │
│                                              ▼                                              │
│  ╔═══════════════════════════════════════════════════════════════════════════════════════╗ │
│  ║  PHASE 4: Security Design Review                                                       ║ │
│  ╠═══════════════════════════════════════════════════════════════════════════════════════╣ │
│  ║                                                                                        ║ │
│  ║  Steps:                                          Knowledge Files:                      ║ │
│  ║  1. Assess 16 security domains                   - security-design.yaml               ║ │
│  ║     (AUTHN, AUTHZ, INPUT, OUTPUT,               - control-set-{01-16}.md             ║ │
│  ║      CLIENT, CRYPTO, LOG, ERROR,                - reference-set-*.md                  ║ │
│  ║      API, DATA, INFRA, SUPPLY, AI,                                                    ║ │
│  ║      MOBILE, CLOUD)                                                                    ║ │
│  ║  2. Identify security gaps                                                             ║ │
│  ║  3. Rate coverage (✅/⚠️/❌)                                                          ║ │
│  ║                                                                                        ║ │
│  ║  Output: P4-SECURITY-DESIGN-REVIEW.md                                                  ║ │
│  ║  Data: security_gaps {domain_assessments[15], gaps[], coverage_matrix}                ║ │
│  ╚═══════════════════════════════════════════════════════════════════════════════════════╝ │
│                                              │                                              │
│                                              ▼                                              │
│  ╔═══════════════════════════════════════════════════════════════════════════════════════╗ │
│  ║  PHASE 5: STRIDE Threat Analysis                                                       ║ │
│  ╠═══════════════════════════════════════════════════════════════════════════════════════╣ │
│  ║                                                                                        ║ │
│  ║  Steps:                                          Scripts:                              ║ │
│  ║  1. For each DFD element: ──────────────────────► stride_matrix.py --element {type}  ║ │
│  ║     - Get applicable STRIDE categories                                                 ║ │
│  ║  2. For each STRIDE category: ──────────────────► unified_kb_query.py --stride {cat} ║ │
│  ║     - Query CWE/CAPEC mappings                                                         ║ │
│  ║  3. Generate threat ID: T-{S}-{E}-{Seq}                                                ║ │
│  ║  4. Build threat inventory                                                             ║ │
│  ║                                                                                        ║ │
│  ║  Output: P5-STRIDE-THREATS.md                                                          ║ │
│  ║  Data: threat_inventory {threats[50-200], element_threat_map, stride_distribution}    ║ │
│  ╚═══════════════════════════════════════════════════════════════════════════════════════╝ │
│                                              │                                              │
│                                              ▼                                              │
│  ╔═══════════════════════════════════════════════════════════════════════════════════════╗ │
│  ║  PHASE 6: Risk Validation (VALIDATION.md)                                              ║ │
│  ╠═══════════════════════════════════════════════════════════════════════════════════════╣ │
│  ║                                                                                        ║ │
│  ║  Steps:                                          Scripts:                              ║ │
│  ║  1. Collect all findings (P1-P5) ◄───────────── Read .phase_working/P{1-5}*.md       ║ │
│  ║  2. Normalize to unified format                                                        ║ │
│  ║  3. Deduplicate (CWE + location match)                                                 ║ │
│  ║  4. Create VR-{Seq} with threat_refs[]                                                 ║ │
│  ║  5. Query attack patterns: ─────────────────────► unified_kb_query.py --capec --attack║ │
│  ║  6. Design POCs                                                                        ║ │
│  ║  7. Map attack paths                                                                   ║ │
│  ║  8. Track threat_disposition (count conservation)                                      ║ │
│  ║                                                                    

…(truncated)
