|
| 1 | +<!-- |
| 2 | +SPDX-License-Identifier: MIT |
| 3 | +Copyright (c) 2026 AIDLC Traceability Tool Contributors |
| 4 | +--> |
| 5 | + |
| 6 | +# AIDLC Traceability Matrix Tool |
| 7 | + |
| 8 | +A Python CLI tool that generates comprehensive traceability matrices from AI-DLC (AI-Driven Development Life Cycle) project artifacts. Analyzes requirements, user stories, implementation units, components, and source code to produce detailed traceability reports. |
| 9 | + |
| 10 | +## Features |
| 11 | + |
| 12 | +- **Multi-Stage Pipeline Architecture**: 6-stage process from artifact discovery to report generation |
| 13 | +- **AI-Powered Relationship Discovery**: Optional multi-agent system using Amazon Bedrock for semantic analysis |
| 14 | +- **Smart Boilerplate Detection**: Language-independent detection of non-functional code (init files, test infrastructure, auto-generated code) |
| 15 | +- **Multiple Output Formats**: Generate markdown and HTML reports with dark mode and interactive features |
| 16 | +- **Gap Analysis**: Automatically detect orphaned artifacts and incomplete traces |
| 17 | +- **Coverage Metrics**: Calculate traceability coverage across all artifact types |
| 18 | + |
| 19 | +## What It Does |
| 20 | + |
| 21 | +The tool analyzes AI-DLC project artifacts and produces traceability matrices showing: |
| 22 | + |
| 23 | +- Which requirements map to which user stories |
| 24 | +- Which stories are implemented by which units |
| 25 | +- Which units correspond to which design components |
| 26 | +- Which components are realized in which source files |
| 27 | +- Coverage gaps and orphaned artifacts |
| 28 | + |
| 29 | +### Artifact Types Supported |
| 30 | + |
| 31 | +- **Requirements**: Business requirements from `requirements.md` |
| 32 | +- **User Stories**: From `stories.md` |
| 33 | +- **Implementation Units**: From `units-breakdown.md` |
| 34 | +- **Design Components**: From `application-components.md` |
| 35 | +- **Code Plans**: From `code-plan.md` |
| 36 | +- **Source Code**: Actual implementation files |
| 37 | +- **Tests**: Test files (tracked separately) |
| 38 | + |
| 39 | +## Installation |
| 40 | + |
| 41 | +```bash |
| 42 | +# Clone the repository |
| 43 | +git clone <repository-url> |
| 44 | +cd AIDLC-Traceability |
| 45 | + |
| 46 | +# Install in development mode |
| 47 | +uv sync |
| 48 | +``` |
| 49 | + |
| 50 | +**Requirements**: Python 3.12 or higher |
| 51 | + |
| 52 | +## Quick Start |
| 53 | + |
| 54 | +### Basic Usage |
| 55 | + |
| 56 | +```bash |
| 57 | +# Generate traceability matrix with AI analysis (requires Amazon Bedrock access) |
| 58 | +traceability generate --input /path/to/aidlc-project --format markdown |
| 59 | + |
| 60 | +# Generate without AI (faster, rule-based only) |
| 61 | +traceability generate --input /path/to/project --no-ai |
| 62 | + |
| 63 | +# Generate both markdown and HTML reports |
| 64 | +traceability generate --input /path/to/project --format both |
| 65 | +``` |
| 66 | + |
| 67 | +### AWS Configuration (for AI Analysis) |
| 68 | + |
| 69 | +The AI-powered analysis requires AWS credentials with Amazon Bedrock access. The minimum required IAM permissions are: |
| 70 | + |
| 71 | +- `bedrock:InvokeModel` |
| 72 | +- `bedrock:InvokeModelWithResponseStream` |
| 73 | +- `sts:GetCallerIdentity` (for credential validation) |
| 74 | + |
| 75 | +See [docs/bedrock-security.md](docs/bedrock-security.md) for a complete least-privilege IAM policy and credential management guidance. |
| 76 | + |
| 77 | +```bash |
| 78 | +# Use specific AWS profile and region |
| 79 | +traceability generate --input /path/to/project --profile my-profile --region us-east-1 |
| 80 | + |
| 81 | +# Or use default AWS credentials |
| 82 | +export AWS_PROFILE=your-profile |
| 83 | +traceability generate --input /path/to/project |
| 84 | +``` |
| 85 | + |
| 86 | +### Advanced Options |
| 87 | + |
| 88 | +```bash |
| 89 | +# Enable verbose logging |
| 90 | +traceability generate --input /path/to/project --verbose |
| 91 | + |
| 92 | +# Get help |
| 93 | +traceability --help |
| 94 | +traceability generate --help |
| 95 | +``` |
| 96 | + |
| 97 | +## Architecture |
| 98 | + |
| 99 | +### 6-Stage Pipeline |
| 100 | + |
| 101 | +1. **Discovery**: Locate `aidlc-docs/` directory and categorize artifact files |
| 102 | +2. **Parsing**: Extract structured data from markdown files and source code |
| 103 | +3. **AI Analysis** (optional): Multi-agent semantic relationship discovery |
| 104 | +4. **Graph Building**: Construct NetworkX directed graph of relationships |
| 105 | +5. **Coverage Analysis**: Detect gaps and calculate metrics |
| 106 | +6. **Report Generation**: Render markdown or HTML reports |
| 107 | + |
| 108 | +### Multi-Agent AI System |
| 109 | + |
| 110 | +When AI analysis is enabled, the tool uses 4 specialized Strands agents: |
| 111 | + |
| 112 | +- **Requirements → Stories Agent**: Maps business requirements to user stories |
| 113 | +- **Stories → Units Agent**: Traces user stories to implementation units |
| 114 | +- **Units → Components Agent**: Links units to design components |
| 115 | +- **Components → Code Agent**: Connects components to source files |
| 116 | + |
| 117 | +Each agent is focused on a specific artifact pair, preventing context pollution and enabling parallel analysis. |
| 118 | + |
| 119 | +## Project Structure |
| 120 | + |
| 121 | +``` |
| 122 | +AIDLC-Traceability/ |
| 123 | +├── src/traceability/ # Main implementation |
| 124 | +│ ├── cli.py # Click-based CLI |
| 125 | +│ ├── pipeline.py # Pipeline orchestration |
| 126 | +│ ├── models.py # Pydantic data models |
| 127 | +│ ├── discovery.py # Artifact discovery |
| 128 | +│ ├── graph.py # NetworkX graph builder |
| 129 | +│ ├── analysis.py # Coverage gap detection |
| 130 | +│ ├── agent.py # Strands AI integration |
| 131 | +│ ├── parsers/ # Specialized parsers |
| 132 | +│ │ ├── requirements.py |
| 133 | +│ │ ├── stories.py |
| 134 | +│ │ ├── units.py |
| 135 | +│ │ ├── code_plans.py |
| 136 | +│ │ ├── components.py |
| 137 | +│ │ └── code.py # Code parser with boilerplate detection |
| 138 | +│ └── generators/ # Report generators |
| 139 | +│ ├── markdown.py |
| 140 | +│ └── html.py |
| 141 | +├── input-docs/ # Original specifications |
| 142 | +├── tests/ # Test suite |
| 143 | +└── pyproject.toml # Project configuration |
| 144 | +``` |
| 145 | + |
| 146 | +## Technical Stack |
| 147 | + |
| 148 | +- **Language**: Python 3.12+ |
| 149 | +- **CLI Framework**: Click |
| 150 | +- **Key Libraries**: |
| 151 | + - `pydantic` - Data validation and models |
| 152 | + - `networkx` - Graph construction and analysis |
| 153 | + - `strands-agents` - AI-powered relationship discovery |
| 154 | + - `boto3` - Amazon Bedrock integration |
| 155 | + - `jinja2` - HTML template rendering |
| 156 | + - `rich` - Terminal output formatting |
| 157 | +- **Linter**: Ruff (120 char line length) |
| 158 | +- **Test Framework**: pytest |
| 159 | + |
| 160 | +## Development |
| 161 | + |
| 162 | +```bash |
| 163 | +# Run linter |
| 164 | +ruff check src/ |
| 165 | + |
| 166 | +# Run tests (when implemented) |
| 167 | +pytest |
| 168 | + |
| 169 | +# Install in editable mode |
| 170 | +uv sync |
| 171 | +``` |
| 172 | + |
| 173 | +## Output Examples |
| 174 | + |
| 175 | +### Markdown Report |
| 176 | + |
| 177 | +The markdown report includes: |
| 178 | +- Summary statistics (artifact counts, coverage percentages) |
| 179 | +- Complete traceability matrix showing all relationships |
| 180 | +- Gap analysis highlighting orphaned artifacts |
| 181 | +- Detailed artifact listings by type |
| 182 | + |
| 183 | +### HTML Report |
| 184 | + |
| 185 | +The HTML report provides: |
| 186 | +- Interactive dark mode toggle |
| 187 | +- Resizable sidebar for navigation |
| 188 | +- Collapsible sections |
| 189 | +- Syntax-highlighted code snippets |
| 190 | +- Visual coverage indicators |
| 191 | + |
| 192 | +## AI-DLC Context |
| 193 | + |
| 194 | +This tool is designed to analyze projects built using the AI-Driven Development Life Cycle (AI-DLC) methodology. AI-DLC projects typically maintain their artifacts in an `aidlc-docs/` directory with standardized markdown files. |
| 195 | + |
| 196 | +## Disclaimer |
| 197 | + |
| 198 | +This tool generates traceability documentation to support your development and compliance workflows. It does not provide legal, regulatory, or compliance advice, and does not guarantee compliance with any specific standard or regulation. Users are solely responsible for ensuring their projects meet applicable regulatory requirements. See [LEGAL_DISCLAIMER.md](LEGAL_DISCLAIMER.md) for full terms. |
| 199 | + |
| 200 | +## License |
| 201 | + |
| 202 | +This project is licensed under the [MIT License](LICENSE). |
0 commit comments