feat(routing): implement ActivityKnowledgeBase with loader
Task 1.2 & 1.3 COMPLETE ✅ Core knowledge base infrastructure: - activity_knowledge_base.json: Catalog of 8 activities with metadata - CloneRepoActivity: Clone Git repo (stable, 1 retry) - AnalyzeCodeActivity: AST analysis (flaky, 3 retries) - SecurityScanActivity: SAST scanning (2 retries) - GenerateReportActivity: Report generation (1 retry) - DeploymentPreCheckActivity: Pre-deployment validation (flaky, 2 retries) - NotifyStatusActivity: Slack/email notifications (flaky, 3 retries) - ApproveWorkflowActivity: Human approval (120m timeout) - ArchiveResultsActivity: Cloud storage archival (flaky, 2 retries) - knowledge_base.go: KnowledgeBase loader with methods: - LoadKnowledgeBase(path) - Load from JSON file - LoadKnowledgeBaseFromDefaultPath() - Auto-discover file - GetActivity(name) - Lookup single activity - GetActivityNames() - List all activity names - HasActivity(name) - Check existence - GetTimeoutForActivity(name) - Get timeout from KB - GetRetryPolicyForActivity(name) - Get retry config - IsFlaky(name) - Check if flaky - GetDependencies(name) - Get activity dependencies - ListActivitiesByCategory(category) - Filter by category - Validate() - Check for circular dependencies - PrintSummary() - Human-readable summary - knowledge_base_test.go: 14 unit tests - Test loading, lookup, filtering, dependencies - Test timeout/retry extraction - Test validation logic - All tests PASS ✅ (22/22 total) Acceptance criteria met: ✅ Knowledge base loads successfully ✅ All 8 activities properly defined ✅ Flaky/stable flags correctly set ✅ Dependencies validate with no cycles ✅ Timeout/retry extraction works ✅ Unit tests pass (14/14 KB tests) ✅ Ready for validator (Task 1.4) Effort: 5 hours (estimated 3+2) Files: activity_knowledge_base.json (10.3KB) knowledge_base.go (246 lines) knowledge_base_test.go (324 lines)
This commit is contained in:
@@ -0,0 +1,360 @@
|
||||
{
|
||||
"version": "1.0",
|
||||
"activities": [
|
||||
{
|
||||
"name": "CloneRepoActivity",
|
||||
"description": "Clone a Git repository to the worker filesystem",
|
||||
"category": "repository",
|
||||
"inputs": {
|
||||
"repo": {
|
||||
"type": "string",
|
||||
"description": "Git repository URL",
|
||||
"required": true
|
||||
},
|
||||
"branch": {
|
||||
"type": "string",
|
||||
"description": "Git branch to clone (default: main)",
|
||||
"required": false,
|
||||
"default": "main"
|
||||
},
|
||||
"depth": {
|
||||
"type": "integer",
|
||||
"description": "Shallow clone depth (optional)",
|
||||
"required": false
|
||||
}
|
||||
},
|
||||
"outputs": {
|
||||
"path": {
|
||||
"type": "string",
|
||||
"description": "Local filesystem path where repo was cloned"
|
||||
},
|
||||
"commit": {
|
||||
"type": "string",
|
||||
"description": "Current commit hash"
|
||||
},
|
||||
"branch": {
|
||||
"type": "string",
|
||||
"description": "Current branch name"
|
||||
}
|
||||
},
|
||||
"constraints": {
|
||||
"defaultTimeout": "5m",
|
||||
"isFlaky": false,
|
||||
"recommendedRetries": 1,
|
||||
"retryBackoff": 1.5,
|
||||
"dependencies": [],
|
||||
"notes": "Network-dependent, may timeout on slow connections"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "AnalyzeCodeActivity",
|
||||
"description": "Analyze code quality, structure, and metrics using ast-grep and pi CLI",
|
||||
"category": "analysis",
|
||||
"inputs": {
|
||||
"path": {
|
||||
"type": "string",
|
||||
"description": "Local filesystem path to analyze",
|
||||
"required": true
|
||||
},
|
||||
"language": {
|
||||
"type": "string",
|
||||
"description": "Programming language (go, python, javascript, etc)",
|
||||
"required": false
|
||||
},
|
||||
"depth": {
|
||||
"type": "integer",
|
||||
"description": "Analysis depth (1=shallow, 5=deep)",
|
||||
"required": false,
|
||||
"default": 3
|
||||
}
|
||||
},
|
||||
"outputs": {
|
||||
"quality": {
|
||||
"type": "number",
|
||||
"description": "Quality score 0-1.0"
|
||||
},
|
||||
"metrics": {
|
||||
"type": "object",
|
||||
"description": "Code metrics (LOC, complexity, etc)"
|
||||
},
|
||||
"issues": {
|
||||
"type": "array",
|
||||
"description": "List of identified issues"
|
||||
},
|
||||
"summary": {
|
||||
"type": "string",
|
||||
"description": "Human-readable analysis summary"
|
||||
}
|
||||
},
|
||||
"constraints": {
|
||||
"defaultTimeout": "10m",
|
||||
"isFlaky": true,
|
||||
"recommendedRetries": 3,
|
||||
"retryBackoff": 2.0,
|
||||
"dependencies": ["CloneRepoActivity"],
|
||||
"notes": "CPU-intensive, can timeout on large repos. Flaky on memory pressure."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "SecurityScanActivity",
|
||||
"description": "Run security scanning (SAST) on codebase",
|
||||
"category": "security",
|
||||
"inputs": {
|
||||
"path": {
|
||||
"type": "string",
|
||||
"description": "Local filesystem path to scan",
|
||||
"required": true
|
||||
},
|
||||
"severity": {
|
||||
"type": "string",
|
||||
"description": "Minimum severity level (low, medium, high, critical)",
|
||||
"required": false,
|
||||
"default": "medium"
|
||||
}
|
||||
},
|
||||
"outputs": {
|
||||
"vulnerabilities": {
|
||||
"type": "array",
|
||||
"description": "List of vulnerabilities found"
|
||||
},
|
||||
"securityScore": {
|
||||
"type": "number",
|
||||
"description": "Security score 0-100"
|
||||
},
|
||||
"riskLevel": {
|
||||
"type": "string",
|
||||
"description": "Risk level (low, medium, high, critical)"
|
||||
}
|
||||
},
|
||||
"constraints": {
|
||||
"defaultTimeout": "8m",
|
||||
"isFlaky": false,
|
||||
"recommendedRetries": 2,
|
||||
"retryBackoff": 1.5,
|
||||
"dependencies": ["CloneRepoActivity"],
|
||||
"notes": "Network calls for vulnerability databases may timeout"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "GenerateReportActivity",
|
||||
"description": "Generate comprehensive report from analysis and scan results",
|
||||
"category": "reporting",
|
||||
"inputs": {
|
||||
"analysisResult": {
|
||||
"type": "object",
|
||||
"description": "Output from AnalyzeCodeActivity",
|
||||
"required": true
|
||||
},
|
||||
"securityResult": {
|
||||
"type": "object",
|
||||
"description": "Output from SecurityScanActivity",
|
||||
"required": true
|
||||
},
|
||||
"format": {
|
||||
"type": "string",
|
||||
"description": "Report format (markdown, html, json)",
|
||||
"required": false,
|
||||
"default": "markdown"
|
||||
}
|
||||
},
|
||||
"outputs": {
|
||||
"report": {
|
||||
"type": "string",
|
||||
"description": "Generated report content"
|
||||
},
|
||||
"reportPath": {
|
||||
"type": "string",
|
||||
"description": "Path to saved report file"
|
||||
}
|
||||
},
|
||||
"constraints": {
|
||||
"defaultTimeout": "2m",
|
||||
"isFlaky": false,
|
||||
"recommendedRetries": 1,
|
||||
"retryBackoff": 1.0,
|
||||
"dependencies": ["AnalyzeCodeActivity", "SecurityScanActivity"],
|
||||
"notes": "CPU-light, reliable. Depends on upstream results."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "DeploymentPreCheckActivity",
|
||||
"description": "Validate readiness for deployment (linting, tests, etc)",
|
||||
"category": "deployment",
|
||||
"inputs": {
|
||||
"path": {
|
||||
"type": "string",
|
||||
"description": "Local filesystem path to check",
|
||||
"required": true
|
||||
},
|
||||
"checkType": {
|
||||
"type": "string",
|
||||
"description": "Type of check (lint, test, build, all)",
|
||||
"required": false,
|
||||
"default": "all"
|
||||
}
|
||||
},
|
||||
"outputs": {
|
||||
"passed": {
|
||||
"type": "boolean",
|
||||
"description": "Whether all checks passed"
|
||||
},
|
||||
"failures": {
|
||||
"type": "array",
|
||||
"description": "List of failed checks"
|
||||
},
|
||||
"warnings": {
|
||||
"type": "array",
|
||||
"description": "List of warnings"
|
||||
}
|
||||
},
|
||||
"constraints": {
|
||||
"defaultTimeout": "15m",
|
||||
"isFlaky": true,
|
||||
"recommendedRetries": 2,
|
||||
"retryBackoff": 2.0,
|
||||
"dependencies": ["CloneRepoActivity"],
|
||||
"notes": "Very flaky - tests are non-deterministic, network issues, race conditions. Retry 2x."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "NotifyStatusActivity",
|
||||
"description": "Send notifications to Slack, email, or webhook",
|
||||
"category": "notification",
|
||||
"inputs": {
|
||||
"channel": {
|
||||
"type": "string",
|
||||
"description": "Target channel or email",
|
||||
"required": true
|
||||
},
|
||||
"status": {
|
||||
"type": "string",
|
||||
"description": "Status to report (success, failure, warning)",
|
||||
"required": true
|
||||
},
|
||||
"message": {
|
||||
"type": "string",
|
||||
"description": "Message body",
|
||||
"required": true
|
||||
}
|
||||
},
|
||||
"outputs": {
|
||||
"notificationId": {
|
||||
"type": "string",
|
||||
"description": "ID of sent notification"
|
||||
},
|
||||
"timestamp": {
|
||||
"type": "string",
|
||||
"description": "When notification was sent"
|
||||
}
|
||||
},
|
||||
"constraints": {
|
||||
"defaultTimeout": "3m",
|
||||
"isFlaky": true,
|
||||
"recommendedRetries": 3,
|
||||
"retryBackoff": 1.5,
|
||||
"dependencies": [],
|
||||
"notes": "Network-dependent, may fail due to network or external service issues. Retry 3x."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "ApproveWorkflowActivity",
|
||||
"description": "Human approval step or automated policy check",
|
||||
"category": "approval",
|
||||
"inputs": {
|
||||
"workflowId": {
|
||||
"type": "string",
|
||||
"description": "ID of workflow awaiting approval",
|
||||
"required": true
|
||||
},
|
||||
"requiredApprovals": {
|
||||
"type": "integer",
|
||||
"description": "Number of approvals needed (default 1)",
|
||||
"required": false,
|
||||
"default": 1
|
||||
},
|
||||
"timeoutMinutes": {
|
||||
"type": "integer",
|
||||
"description": "Minutes to wait for approval",
|
||||
"required": false,
|
||||
"default": 60
|
||||
}
|
||||
},
|
||||
"outputs": {
|
||||
"approved": {
|
||||
"type": "boolean",
|
||||
"description": "Whether approved"
|
||||
},
|
||||
"approver": {
|
||||
"type": "string",
|
||||
"description": "Who approved (if approved)"
|
||||
},
|
||||
"timestamp": {
|
||||
"type": "string",
|
||||
"description": "When approval was given"
|
||||
}
|
||||
},
|
||||
"constraints": {
|
||||
"defaultTimeout": "120m",
|
||||
"isFlaky": false,
|
||||
"recommendedRetries": 1,
|
||||
"retryBackoff": 1.0,
|
||||
"dependencies": [],
|
||||
"notes": "Waits for human input. Long timeout. Cannot retry (user input is irrevocable)."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "ArchiveResultsActivity",
|
||||
"description": "Archive analysis results to cloud storage (S3, GCS)",
|
||||
"category": "storage",
|
||||
"inputs": {
|
||||
"reportPath": {
|
||||
"type": "string",
|
||||
"description": "Path to report to archive",
|
||||
"required": true
|
||||
},
|
||||
"destination": {
|
||||
"type": "string",
|
||||
"description": "Cloud destination (s3://bucket/path or gcs://bucket/path)",
|
||||
"required": true
|
||||
},
|
||||
"metadata": {
|
||||
"type": "object",
|
||||
"description": "Optional metadata tags",
|
||||
"required": false
|
||||
}
|
||||
},
|
||||
"outputs": {
|
||||
"archiveUrl": {
|
||||
"type": "string",
|
||||
"description": "URL of archived file"
|
||||
},
|
||||
"archiveSize": {
|
||||
"type": "integer",
|
||||
"description": "Size of archived file in bytes"
|
||||
}
|
||||
},
|
||||
"constraints": {
|
||||
"defaultTimeout": "5m",
|
||||
"isFlaky": true,
|
||||
"recommendedRetries": 2,
|
||||
"retryBackoff": 1.5,
|
||||
"dependencies": [],
|
||||
"notes": "Network-dependent. May fail on network issues or service throttling. Retry 2x."
|
||||
}
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"totalActivities": 8,
|
||||
"lastUpdated": "2025-08-31T00:00:00Z",
|
||||
"categories": {
|
||||
"repository": 1,
|
||||
"analysis": 1,
|
||||
"security": 1,
|
||||
"reporting": 1,
|
||||
"deployment": 1,
|
||||
"notification": 1,
|
||||
"approval": 1,
|
||||
"storage": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user