--- test_id: diagrams-architect-001 test_name: C4 Context Diagram Generation coverage: - TC-B001 # User request detected - TC-B004 # Correct Mermaid syntax - TC-B005 # C4 Level 1 conventions - TC-B006 # Saved to correct location - TC-B007 # File named correctly priority: P1 tags: - c4-model - context-diagram - level-1 --- # Test Case: C4 Context Diagram Generation ## Scenario User requests a C4 context diagram for an authentication system to understand system boundaries and external actors. ## Input **User Request**: "Create C4 context diagram for authentication system" **Context Provided** (optional): - System handles user registration, login, password management - Integrates with email service for verification - Integrates with SMS gateway for 2FA - Supports OAuth providers (Google, GitHub, Microsoft) ## Expected Agent Behavior 1. **Recognize diagram type**: C4 Context (Level 1) 2. **Choose appropriate template**: `c4-context-template.mmd` 3. **Generate diagram** with: - Clear title: "Authentication System Context" - Main system: Authentication System - Users: User, Administrator - External systems: Email Service, SMS Gateway, OAuth Providers - Relationships showing data flow 4. **Validate syntax**: - Starts with `C4Context` (NO `mermaid` keyword) - All elements have descriptions in quotes - All relationships labeled - Proper indentation (2 spaces) 5. **Specify file path**: `.specweave/docs/internal/architecture/diagrams/auth-context.mmd` 6. **Provide validation instructions**: Tell user to verify rendering ## Expected Output **Diagram Content** (approximate): ``` C4Context title Authentication System Context Person(user, "User", "A user who needs to authenticate") Person(admin, "Administrator", "Manages user accounts") System(auth, "Authentication System", "Handles user authentication, registration, password management") System_Ext(email, "Email Service", "Sends verification and password reset emails") System_Ext(sms, "SMS Gateway", "Sends 2FA codes via SMS") System_Ext(oauth, "OAuth Providers", "Google, GitHub, Microsoft identity providers") Rel(user, auth, "Authenticates, registers, resets password") Rel(admin, auth, "Manages users, views audit logs") Rel(auth, email, "Sends emails via") Rel(auth, sms, "Sends SMS via") Rel(auth, oauth, "Delegates authentication to") ``` **File Path**: `.specweave/docs/internal/architecture/diagrams/auth-context.mmd` **Validation Message**: ``` ✅ Diagram created: .specweave/docs/internal/architecture/diagrams/auth-context.mmd 📋 VALIDATION REQUIRED: 1. Open the file in VS Code 2. Install Mermaid Preview extension if needed 3. Verify the diagram renders correctly 4. Confirm all systems and relationships are visible ``` ## Success Criteria - [ ] Diagram uses correct C4 Context syntax - [ ] NO `mermaid` keyword present - [ ] All elements (Person, System, System_Ext) have descriptions - [ ] All relationships (Rel) have labels - [ ] Indentation is correct (2 spaces per level) - [ ] File path follows conventions - [ ] Validation instructions provided - [ ] Diagram would render correctly in Mermaid Preview ## Failure Scenarios **Scenario 1: Uses `mermaid` keyword** ``` mermaid C4Context ... ``` ❌ FAIL: C4 diagrams must start directly with `C4Context` **Scenario 2: Missing descriptions** ``` C4Context Person(user, User) ``` ❌ FAIL: All elements must have descriptions in quotes **Scenario 3: Incorrect file location** ``` File: .specweave/docs/diagrams/context.mmd ``` ❌ FAIL: Should be in `architecture/diagrams/` subdirectory ## Traceability **Covers User Stories**: - US-B001: Create C4 Context Diagram **Covers Acceptance Criteria**: - TC-B001: User request detected by diagrams-generator skill - TC-B004: Agent creates diagram with correct Mermaid syntax - TC-B005: Diagram follows C4 Level 1 conventions (system boundary, external actors) - TC-B006: Diagram saved to correct location - TC-B007: File named correctly (e.g., `auth-context.mmd`)