Plan 002
Source: ADR-002 - Risk Analysis Management System
Created: 2026-02-17
Authors: inful, Count
Overview
Build a risk analysis management daemon with cause-outcome-mitigation model, Systems/Components hierarchy, and flexible calculation service.
Work Breakdown
Phase 1: Project Setup & Infrastructure
| # |
Task |
Estimate |
Status |
| 1.1 |
Initialize Go module (go mod init) |
10m |
✅ |
| 1.2 |
Set up project structure per golang-standards |
20m |
✅ |
| 1.3 |
Create go.mod with dependencies (chi, huma, sqlite3, migrations, sqlc) |
15m |
✅ |
| 1.4 |
Set up Makefile with build/test/coverage targets |
20m |
✅ |
| 1.5 |
Create .golangci.yml with preferred linters |
15m |
✅ |
| 1.6 |
Set up git repository on Forgejo |
10m |
✅ |
Phase 2: Database Schema & Migrations
| # |
Task |
Estimate |
Status |
| 2.1 |
Create database/migrations/001_initial_schema.sql |
45m |
✅ |
| 2.2 |
Define System table |
- |
✅ |
| 2.3 |
Define Component table |
- |
✅ |
| 2.4 |
Define RiskOutcome table |
- |
✅ |
| 2.5 |
Define Causality table |
- |
✅ |
| 2.6 |
Define RiskPair table |
- |
✅ |
| 2.7 |
Define Mitigation table |
- |
✅ |
| 2.8 |
Set up golang-migrate migration runner |
30m |
✅ |
Phase 3: SQLc Queries & Types
| # |
Task |
Estimate |
Status |
| 3.1 |
Create sqlc.yaml configuration |
15m |
✅ |
| 3.2 |
Write queries/system.sql |
30m |
✅ |
| 3.3 |
Write queries/component.sql |
30m |
✅ |
| 3.4 |
Write queries/risk_outcome.sql |
30m |
✅ |
| 3.5 |
Write queries/causality.sql |
30m |
✅ |
| 3.6 |
Write queries/risk_pair.sql |
30m |
✅ |
| 3.7 |
Write queries/mitigation.sql |
30m |
✅ |
| 3.8 |
Run sqlc generate and verify types |
20m |
✅ |
Phase 4: Domain Models & Services
| # |
Task |
Estimate |
Status |
| 4.1 |
Create internal/models/ with domain types |
30m |
☐ |
| 4.2 |
Implement internal/service/system.go |
45m |
☐ |
| 4.3 |
Implement internal/service/component.go |
45m |
☐ |
| 4.4 |
Implement internal/service/risk_outcome.go |
45m |
☐ |
| 4.5 |
Implement internal/service/causality.go |
45m |
☐ |
| 4.6 |
Implement internal/service/risk_pair.go |
45m |
☐ |
| 4.7 |
Implement internal/service/mitigation.go |
45m |
☐ |
| 4.8 |
Implement internal/service/risk_calculator.go |
60m |
☐ |
Phase 5: HTTP API (Huma/Chi)
| # |
Task |
Estimate |
Status |
| 5.1 |
Create internal/api/server.go with Chi router |
30m |
☐ |
| 5.2 |
Set up Huma API with OpenAPI spec |
30m |
☐ |
| 5.3 |
Implement System handlers |
60m |
☐ |
| 5.4 |
Implement Component handlers |
60m |
☐ |
| 5.5 |
Implement RiskOutcome handlers |
60m |
☐ |
| 5.6 |
Implement Causality handlers |
60m |
☐ |
| 5.7 |
Implement RiskPair handlers |
60m |
☐ |
| 5.8 |
Implement Mitigation handlers |
60m |
☐ |
| 5.9 |
Add error handling middleware |
30m |
☐ |
| 5.10 |
Add logging middleware |
30m |
☐ |
Phase 6: Testing
| # |
Task |
Estimate |
Status |
| 6.1 |
Write Example function tests for System |
45m |
☐ |
| 6.2 |
Write Example function tests for Component |
45m |
☐ |
| 6.3 |
Write Example function tests for RiskOutcome |
45m |
☐ |
| 6.4 |
Write Example function tests for Causality |
45m |
☐ |
| 6.5 |
Write Example function tests for RiskPair |
45m |
☐ |
| 6.6 |
Write Example function tests for Mitigation |
45m |
☐ |
| 6.7 |
Write integration tests for risk calculation |
60m |
☐ |
| 6.8 |
Achieve >70% coverage |
ongoing |
☐ |
Phase 7: Configuration & Deployment
| # |
Task |
Estimate |
Status |
| 7.1 |
Create cmd/riskyd/main.go |
30m |
☐ |
| 7.2 |
Add environment configuration |
30m |
☐ |
| 7.3 |
Add config file support |
30m |
☐ |
| 7.4 |
Set up graceful shutdown |
20m |
☐ |
| 7.5 |
Create Dockerfile |
30m |
☐ |
| 7.6 |
Write README.md with setup instructions |
45m |
☐ |
| 7.7 |
Write API documentation |
30m |
☐ |
Completion Criteria
Current Status
Last updated: 2026-02-17
| Phase |
Progress |
| Phase 1: Setup |
0/6 |
| Phase 2: Database |
0/8 |
| Phase 3: SQLc |
0/8 |
| Phase 4: Services |
0/8 |
| Phase 5: API |
0/10 |
| Phase 6: Testing |
0/8 |
| Phase 7: Deploy |
0/7 |
Overall: 0/55 tasks complete
Estimated Timeline
| Phase |
Duration |
Cumulative |
| Phase 1 |
1.5h |
1.5h |
| Phase 2 |
2.5h |
4h |
| Phase 3 |
4h |
8h |
| Phase 4 |
5.5h |
13.5h |
| Phase 5 |
7.5h |
21h |
| Phase 6 |
6h |
27h |
| Phase 7 |
3.5h |
30.5h |
Total Estimated: ~30-35 hours
Next Action
Ready to begin Phase 1.1: Initialize Go module.
This will create go.mod in a new repository. Should I create the repository on Forgejo first, or start locally?