Skip to content

Latest commit

 

History

History
580 lines (505 loc) · 15.7 KB

File metadata and controls

580 lines (505 loc) · 15.7 KB

AD-SDLC System Architecture

1. High-Level Agent Flow

flowchart TB
    subgraph SetupPipeline["Setup Pipeline"]
        direction LR
        MODE[Mode Detector]
        INIT[Project Initializer]
        REPOD[Repo Detector]
        GHSETUP[GitHub Repo Setup]
    end

    subgraph Input["User Input Layer"]
        UI[User Input]
        FILES[Files/URLs]
    end

    subgraph DocumentPipeline["Document Generation Pipeline"]
        direction LR
        COLLECT[Collector Agent]
        PRD[PRD Writer Agent]
        SRS[SRS Writer Agent]
        SDP[SDP Writer Agent]
        SDS[SDS Writer Agent]
        TM[Threat Model Writer Agent]
        TD[Tech Decision Writer Agent]
        UISPEC[UI Spec Writer Agent]
    end

    subgraph IssuePipeline["Issue Management Pipeline"]
        direction LR
        ISSUE[Issue Generator Agent]
        SVP[SVP Writer Agent]
        CTRL[Controller Agent]
    end

    subgraph ExecutionPipeline["Execution Pipeline"]
        direction TB
        WORKER1[Worker Agent 1]
        WORKER2[Worker Agent 2]
        WORKERN[Worker Agent N]
        VAL[Validation Agent]
        PR[PR Review Agent]
        DOCIDX[Doc Index Generator]
    end

    subgraph EnhancementPipeline["Enhancement Pipeline"]
        direction LR
        ORCH[Analysis Orchestrator Agent]
        DOCREAD[Document Reader Agent]
        CODEBASE[Codebase Analyzer Agent]
        COMP[Comparator Agent]
        IMPACT[Impact Analyzer Agent]
        REGTEST[Regression Tester Agent]
    end

    subgraph Output["Output Layer"]
        DOCS[Generated Documents]
        ISSUES[GitHub Issues]
        CODE[Source Code]
        PRS[Pull Requests]
    end

    %% Setup flow
    UI --> MODE
    MODE --> INIT
    INIT --> REPOD
    REPOD --> GHSETUP
    GHSETUP --> COLLECT

    FILES --> COLLECT

    COLLECT --> PRD
    PRD --> SRS
    SRS --> SDP
    SDP --> SDS
    SDS --> TM
    SDS --> TD
    SDS --> UISPEC

    TM --> ISSUE
    TD --> ISSUE
    UISPEC --> ISSUE
    ISSUE --> SVP
    SVP --> CTRL

    CTRL --> WORKER1
    CTRL --> WORKER2
    CTRL --> WORKERN

    WORKER1 --> VAL
    WORKER2 --> VAL
    WORKERN --> VAL
    VAL --> PR

    PR --> DOCIDX

    COLLECT -.-> DOCS
    PRD -.-> DOCS
    SRS -.-> DOCS
    SDP -.-> DOCS
    SDS -.-> DOCS
    TM -.-> DOCS
    TD -.-> DOCS
    UISPEC -.-> DOCS
    SVP -.-> DOCS
    ISSUE -.-> ISSUES
    WORKER1 -.-> CODE
    WORKER2 -.-> CODE
    WORKERN -.-> CODE
    PR -.-> PRS
    DOCIDX -.-> DOCS

    %% Enhancement Pipeline connections (Analysis Orchestrator coordinates sub-agents)
    DOCS --> ORCH
    CODE --> ORCH
    ORCH --> DOCREAD
    ORCH --> CODEBASE
    DOCREAD --> COMP
    CODEBASE --> COMP
    CODEBASE --> REGTEST
    COMP --> IMPACT
    IMPACT -.-> CTRL
    REGTEST -.-> PR
Loading

2. Agent Communication Pattern

flowchart TB
    subgraph Orchestrator["Main Orchestrator"]
        MAIN[Main Claude Agent]
    end

    subgraph Subagents["Specialized Subagents"]
        A1[Collector]
        A2[PRD Writer]
        A3[SRS Writer]
        A3B[SDP Writer]
        A4[SDS Writer]
        A4B[Threat Model Writer]
        A4C[Tech Decision Writer]
        A_UISPEC[UI Spec Writer]
        A5[Issue Generator]
        A5B[SVP Writer]
        A6[Controller]
        A7[Worker]
        A8[PR Reviewer]
        A_VALID[Validation]
        A_DOCIDX[Doc Index Generator]
        A9[Document Reader]
        A_CODERD[Code Reader]
        A10[Codebase Analyzer]
        A11[Impact Analyzer]
        A12[Analysis Orchestrator]
        A13[Comparator]
        A_CI[CI Fixer]
        A_STGV[Stage Verifier]
        A_RTM[RTM Builder]
        A_MODE[Mode Detector]
        A_INIT[Project Initializer]
        A_REPO[Repo Detector]
        A_GHSETUP[GitHub Repo Setup]
    end

    subgraph Scratchpad["File-based State (Scratchpad)"]
        S1[info/*.yaml]
        S2[docs/prd/*.md]
        S3[docs/srs/*.md]
        S3B[docs/sdp/*.md]
        S4[docs/sds/*.md]
        S4C[docs/dbs/*.md]
        S4B[docs/tm/*.md]
        S4D[docs/decisions/*.md]
        S5[issues/*.json]
        S5B[docs/svp/*.md]
        S6[progress/*.yaml]
        S7[state/current_state.yaml]
        S8[analysis/architecture_overview.yaml]
        S9[analysis/dependency_graph.json]
        S10[impact/impact_report.yaml]
        S11[analysis/pipeline_state.yaml]
        S12[analysis/analysis_report.yaml]
        S13[analysis/comparison_result.yaml]
    end

    MAIN -->|spawn| A1
    MAIN -->|spawn| A2
    MAIN -->|spawn| A3
    MAIN -->|spawn| A3B
    MAIN -->|spawn| A4
    MAIN -->|spawn| A4B
    MAIN -->|spawn| A4C
    MAIN -->|spawn| A_UISPEC
    MAIN -->|spawn| A5
    MAIN -->|spawn| A5B
    MAIN -->|spawn| A6
    MAIN -->|spawn| A7
    MAIN -->|spawn| A8
    MAIN -->|spawn| A_VALID
    MAIN -->|spawn| A_DOCIDX
    MAIN -->|spawn| A9
    MAIN -->|spawn| A_CODERD
    MAIN -->|spawn| A10
    MAIN -->|spawn| A11
    MAIN -->|spawn| A12
    MAIN -->|spawn| A13
    MAIN -->|spawn| A_CI
    MAIN -->|spawn| A_STGV
    MAIN -->|spawn| A_RTM
    MAIN -->|spawn| A_MODE
    MAIN -->|spawn| A_INIT
    MAIN -->|spawn| A_REPO
    MAIN -->|spawn| A_GHSETUP

    A1 -->|write| S1
    A2 -->|read| S1
    A2 -->|write| S2
    A3 -->|read| S2
    A3 -->|write| S3
    A3B -->|read| S2
    A3B -->|read| S3
    A3B -->|write| S3B
    A4 -->|read| S3
    A4 -->|write| S4
    A4 -->|write| S4C
    A4B -->|read| S4
    A4B -->|write| S4B
    A4C -->|read| S2
    A4C -->|read| S3
    A4C -->|read| S4
    A4C -->|write| S4D
    A5 -->|read| S4
    A5 -->|read| S4B
    A5 -->|read| S4D
    A5 -->|write| S5
    A5B -->|read| S3
    A5B -->|read| S5
    A5B -->|write| S5B
    A6 -->|read| S5
    A6 -->|write| S6
    A7 -->|read| S5
    A7 -->|read| S6
    A8 -->|read| S6

    %% Enhancement Pipeline file access
    A9 -->|read| S2
    A9 -->|read| S3
    A9 -->|read| S4
    A9 -->|write| S7
    A10 -->|write| S8
    A10 -->|write| S9
    A11 -->|read| S7
    A11 -->|read| S8
    A11 -->|read| S9
    A11 -->|write| S10

    %% Analysis Orchestrator coordinates pipeline
    A12 -->|write| S11
    A12 -->|write| S12
    A12 -->|read| S7
    A12 -->|read| S8
    A12 -->|read| S13

    %% Comparator compares documents and code
    A13 -->|read| S7
    A13 -->|read| S8
    A13 -->|write| S13

    A1 -.->|result| MAIN
    A2 -.->|result| MAIN
    A3 -.->|result| MAIN
    A3B -.->|result| MAIN
    A4 -.->|result| MAIN
    A4B -.->|result| MAIN
    A4C -.->|result| MAIN
    A_UISPEC -.->|result| MAIN
    A5 -.->|result| MAIN
    A5B -.->|result| MAIN
    A6 -.->|result| MAIN
    A7 -.->|result| MAIN
    A8 -.->|result| MAIN
    A_VALID -.->|result| MAIN
    A_DOCIDX -.->|result| MAIN
    A9 -.->|result| MAIN
    A_CODERD -.->|result| MAIN
    A10 -.->|result| MAIN
    A11 -.->|result| MAIN
    A12 -.->|result| MAIN
    A13 -.->|result| MAIN
    A_CI -.->|result| MAIN
    A_STGV -.->|result| MAIN
    A_RTM -.->|result| MAIN
    A_MODE -.->|result| MAIN
    A_INIT -.->|result| MAIN
    A_REPO -.->|result| MAIN
    A_GHSETUP -.->|result| MAIN
Loading

3. Document Traceability Flow

flowchart LR
    subgraph PRD["PRD"]
        FR001[FR-001: User Auth]
        FR002[FR-002: Dashboard]
        FR003[FR-003: Reports]
    end

    subgraph SRS["SRS"]
        SF001[SF-001: Login]
        SF002[SF-002: Session]
        SF003[SF-003: Dashboard View]
        SF004[SF-004: Report Gen]
    end

    subgraph SDS["SDS"]
        CMP001[CMP-001: AuthService]
        CMP002[CMP-002: SessionMgr]
        CMP003[CMP-003: DashboardCtrl]
        CMP004[CMP-004: ReportEngine]
    end

    subgraph Issues["GitHub Issues"]
        I001["#1: Implement AuthService"]
        I002["#2: Add SessionMgr"]
        I003["#3: Create Dashboard API"]
        I004["#4: Build ReportEngine"]
    end

    FR001 --> SF001
    FR001 --> SF002
    FR002 --> SF003
    FR003 --> SF004

    SF001 --> CMP001
    SF002 --> CMP002
    SF003 --> CMP003
    SF004 --> CMP004

    CMP001 --> I001
    CMP002 --> I002
    CMP003 --> I003
    CMP004 --> I004
Loading

4. Controller Agent Work Distribution

flowchart TB
    subgraph IssueQueue["Issue Queue"]
        Q1["#1 (P0, no deps)"]
        Q2["#2 (P0, blocked by #1)"]
        Q3["#3 (P1, no deps)"]
        Q4["#4 (P1, blocked by #3)"]
        Q5["#5 (P2, no deps)"]
    end

    subgraph Controller["Controller Agent"]
        PRIO[Priority Analyzer]
        DEP[Dependency Resolver]
        ASSIGN[Work Assigner]
    end

    subgraph Workers["Worker Pool"]
        W1[Worker 1]
        W2[Worker 2]
        W3[Worker 3]
    end

    subgraph Status["Status Tracking"]
        DONE[Completed]
        PROG[In Progress]
        WAIT[Waiting]
    end

    Q1 --> PRIO
    Q2 --> PRIO
    Q3 --> PRIO
    Q4 --> PRIO
    Q5 --> PRIO

    PRIO --> DEP
    DEP --> ASSIGN

    ASSIGN --> W1
    ASSIGN --> W2
    ASSIGN --> W3

    W1 --> DONE
    W2 --> PROG
    W3 --> PROG

    DONE --> DEP
Loading

5. State Machine

stateDiagram-v2
    [*] --> Collecting: User Input

    Collecting --> Clarifying: Need More Info
    Clarifying --> Collecting: User Response
    Collecting --> PRD_Drafting: Info Complete

    PRD_Drafting --> PRD_Review: Draft Ready
    PRD_Review --> PRD_Drafting: Revisions Needed
    PRD_Review --> SRS_Drafting: Approved

    SRS_Drafting --> SRS_Review: Draft Ready
    SRS_Review --> SRS_Drafting: Revisions Needed
    SRS_Review --> SDS_Drafting: Approved

    SDS_Drafting --> SDS_Review: Draft Ready
    SDS_Review --> SDS_Drafting: Revisions Needed
    SDS_Review --> Issues_Creating: Approved

    Issues_Creating --> Work_Assigning: Issues Created
    Work_Assigning --> Implementing: Assigned

    Implementing --> PR_Creating: Code Complete
    PR_Creating --> PR_Reviewing: PR Created
    PR_Reviewing --> Implementing: Changes Requested
    PR_Reviewing --> Merged: Approved

    Merged --> Work_Assigning: More Issues
    Merged --> [*]: All Complete
Loading

6. Error Handling & Retry Flow

flowchart TB
    START[Agent Task Start]
    EXEC[Execute Task]
    CHECK{Success?}
    RETRY{Attempts < 3?}
    INC[Increment Counter]
    WAIT[Exponential Backoff]
    SUCCESS[Report Success]
    FAIL[Report Failure]
    ESCALATE[Escalate to User]

    START --> EXEC
    EXEC --> CHECK
    CHECK -->|Yes| SUCCESS
    CHECK -->|No| RETRY
    RETRY -->|Yes| INC
    INC --> WAIT
    WAIT --> EXEC
    RETRY -->|No| FAIL
    FAIL --> ESCALATE
Loading

7. Parallel Execution Model

sequenceDiagram
    participant User
    participant Main as Main Agent
    participant Ctrl as Controller
    participant W1 as Worker 1
    participant W2 as Worker 2
    participant W3 as Worker 3
    participant PR as PR Reviewer

    User->>Main: Start Project
    Main->>Main: Run Document Pipeline
    Main->>Ctrl: Issues Ready

    par Parallel Work
        Ctrl->>W1: Issue #1
        Ctrl->>W2: Issue #3
        Ctrl->>W3: Issue #5
    end

    W1-->>Ctrl: #1 Complete
    Ctrl->>W2: Issue #2 (was blocked by #1)

    W3-->>Ctrl: #5 Complete
    W2-->>Ctrl: #3 Complete

    Ctrl->>W1: Issue #4 (was blocked by #3)
    W2-->>Ctrl: #2 Complete
    W1-->>Ctrl: #4 Complete

    Ctrl->>PR: All Issues Complete
    PR->>PR: Review & Merge
    PR-->>User: Project Complete
Loading

8. Verification & Validation (V&V) Pipeline

The V&V pipeline ensures that pipeline outputs are complete and that the final implementation conforms to its requirements.

Stage Verifier

The Stage Verifier agent checks the outputs of each pipeline stage for completeness and correctness before the workflow advances to the next stage. It validates that all required artifacts (documents, issues, code) have been produced and meet structural expectations.

RTM Builder

The RTM (Requirements Traceability Matrix) Builder agent creates and maintains a traceability matrix that links requirements from PRD through SRS, SDS, issues, and implementation. This matrix provides end-to-end visibility into requirement coverage and identifies any gaps.

Validation Agent

The Validation agent validates the final implementation against the original requirements. It runs after all workers have completed their tasks and before PR review, ensuring that the delivered code satisfies the acceptance criteria defined in the upstream documents.

9. Directory Structure

claude_code_agent/
├── .claude/
│   └── agents/                    # Agent Definitions (34 files)
│       ├── ad-sdlc-orchestrator.md # AD-SDLC Orchestrator Agent
│       ├── analysis-orchestrator.md # Analysis Orchestrator Agent
│       ├── ci-fixer.md            # CI Fixer Agent
│       ├── code-reader.md         # Code Reader Agent
│       ├── codebase-analyzer.md   # Codebase Analyzer Agent
│       ├── collector.md           # Information Collector Agent
│       ├── controller.md          # Controller Agent
│       ├── doc-code-comparator.md # Doc-Code Comparator Agent
│       ├── doc-index-generator.md # Doc Index Generator Agent
│       ├── document-reader.md     # Document Reader Agent
│       ├── github-repo-setup.md   # GitHub Repo Setup Agent
│       ├── impact-analyzer.md     # Impact Analyzer Agent
│       ├── issue-generator.md     # Issue Generator Agent
│       ├── issue-reader.md        # Issue Reader Agent
│       ├── mode-detector.md       # Mode Detector Agent
│       ├── pr-reviewer.md         # PR Reviewer Agent
│       ├── prd-updater.md         # PRD Updater Agent
│       ├── prd-writer.md          # PRD Writer Agent
│       ├── project-initializer.md # Project Initializer Agent
│       ├── regression-tester.md   # Regression Tester Agent
│       ├── repo-detector.md       # Repo Detector Agent
│       ├── rtm-builder.md         # RTM Builder Agent
│       ├── sdp-writer.md          # SDP Writer Agent
│       ├── sds-updater.md         # SDS Updater Agent
│       ├── sds-writer.md          # SDS Writer Agent
│       ├── srs-updater.md         # SRS Updater Agent
│       ├── srs-writer.md          # SRS Writer Agent
│       ├── stage-verifier.md      # Stage Verifier Agent
│       ├── svp-writer.md          # SVP Writer Agent
│       ├── tech-decision-writer.md # Tech Decision Writer Agent
│       ├── threat-model-writer.md # Threat Model Writer Agent
│       ├── ui-spec-writer.md      # UI Spec Writer Agent
│       ├── validation.md          # Validation Agent
│       └── worker.md              # Worker Agent
│
├── .ad-sdlc/
│   ├── scratchpad/               # Inter-agent State
│   │   ├── info/                 # Collected information
│   │   ├── documents/            # Generated documents
│   │   ├── issues/               # Issue tracking
│   │   └── progress/             # Progress tracking
│   │
│   ├── templates/                # Document Templates
│   │   ├── prd-template.md
│   │   ├── srs-template.md
│   │   ├── sds-template.md
│   │   └── issue-template.md
│   │
│   └── config/                   # Configuration
│       ├── agents.yaml
│       └── workflow.yaml
│
├── docs/
│   ├── prd/                      # PRD Documents
│   ├── srs/                      # SRS Documents
│   ├── sds/                      # SDS Documents
│   ├── dbs/                      # DBS Documents (Database Schema Specifications emitted by SDS Writer)
│   ├── tm/                       # Threat Model Documents
│   ├── decisions/                # Technology Decision Documents (emitted by Tech Decision Writer)
│   ├── svp/                      # SVP Documents (Software Verification Plans emitted by SVP Writer)
│   └── architecture/             # Architecture Docs
│
└── src/                          # Generated Source Code