Hyper Go Backend Techdebt Refactor
Refactor Go backend services to meet Hyperion gold standards with improved code quality, test coverage, and compliance.
# Hyperion Go Backend Tech Debt & Refactor Task
Refactor Go backend services to meet Hyperion gold standards with improved code quality, test coverage, and compliance.
## Instructions
You are coordinating a Go backend refactoring/tech debt task. Focus on code quality, compliance, and test coverage.
### Phase 1: Service Audit (Sequential)
1. **Query Past Lessons on Refactoring**
reflection_query_relevant_lessons({ situation: "Refactoring {{service_name}} to meet gold standards", limit: 5 })
2. **Analyze Current Service State**
code_index_search({ query: "{{service_name}} main handlers services", retrieve: "chunk-m", fileTypes: [".go"], minScore: 0.5 })
3. **Query Known Tech Debt Patterns**
coordinator_query_knowledge({ collection: "hyperion_bugs", query: "tech debt refactoring {{service_name}}", limit: 3 })
4. **Run Compliance Audit**
Execute these checks to identify violations:
- `make lint` - Check all linting rules
- `go test ./... -cover` - Current test coverage
- Search for forbidden patterns:
- `c.Get("identity")` or `c.MustGet("identity")`
- `models.NewSystemIdentity()`
- `GetCompanyPublicKey()`
- `http.NewServeMux()` or `gorilla/mux`
- Static `JWT_SECRET` in configs
### Phase 2: Task Planning (Sequential)
5. **Create Human Task**
coordinator_create_human_task({ prompt: "Tech debt refactor: {{service_name}} - {{focus_areas}}" })
→ Save humanTaskId
6. **Record Refactoring Decision**
reflection_record_decision({ chatId: "{{session_id}}", context: { userRequest: "Refactor {{service_name}} to gold standards", availableInfo: "Audit findings: {{violations_found}}, coverage: {{current_coverage}}%", uncertainty: "{{breaking_change_risks}}" }, decision: { action: "{{refactoring_approach}}", reasoning: "{{why_this_priority_order}}", alternatives: ["{{other_approaches}}"], confidence: {{0.0_to_1.0}} }, predictions: { successProbability: {{0.0_to_1.0}}, risks: ["{{potential_regressions}}", "{{api_breaking_changes}}"], timeEstimate: "{{estimate}}" } })
→ Save decisionId
### Phase 3: Agent Task Creation
7. **Create Security Compliance Task** (Priority 1 - Critical)
coordinator_create_agent_task({ humanTaskId: "{{from_step_5}}", agentName: "go-dev", role: "Fix security and compliance violations to meet Hyperion gold standards", contextSummary: " WHY: Security violations create vulnerabilities and break CI/CD WHAT: Fix all linting violations and security patterns VIOLATIONS FOUND: - {{list_violations_from_audit}} MANDATORY FIXES: - Replace c.Get('identity') → middleware.GetIdentityFromCentralizedGinContext(c) - Replace NewSystemIdentity() → HTTP/Gin identity provider - Replace GetCompanyPublicKey() → security-api /validate endpoint - Replace gorilla/mux → Gin framework - Remove static JWT_SECRET → MCPJWTMiddleware CONSTRAINTS: - Run make lint after EVERY change - NO functional changes, ONLY compliance fixes - Preserve existing behavior exactly TESTING: Run existing tests after each fix ", filesModified: ["{{files_with_violations}}"], qdrantCollections: ["technical-knowledge"], todos: [ { description: "Fix identity access pattern violations", filePath: "{{service}}/internal/handlers/", contextHint: "Replace c.Get/MustGet('identity') with middleware.GetIdentityFromCentralizedGinContext(c)" }, { description: "Fix JWT validation patterns", filePath: "{{service}}/internal/middleware/", contextHint: "Use security-api /validate, NOT GetCompanyPublicKey()" }, { description: "Run make lint and fix remaining issues", contextHint: "Iterate until make lint passes with 0 errors" } ] })
→ Save securityTaskId
8. **Create Code Quality Refactor Task** (Priority 2)
coordinator_create_agent_task({ humanTaskId: "{{from_step_5}}", agentName: "go-dev", role: "Improve code quality, reduce complexity, apply DRY principles", contextSummary: " WHY: Improve maintainability and reduce tech debt WHAT: Refactor code following Go best practices TARGETS: - Functions >50 lines → Extract helpers - Duplicate code → Create shared utilities - Complex conditionals → Simplify or extract - Magic numbers/strings → Named constants - Missing error wrapping → Add context with fmt.Errorf CONSTRAINTS: - Preserve API contracts (no breaking changes) - Keep commits atomic (one refactor per commit) - Add comments for complex logic - Follow Go naming conventions DEPENDENCIES: Wait for security compliance task ", filesModified: ["{{target_files}}"], todos: [ { description: "Identify and extract duplicate code patterns", contextHint: "Search for similar code blocks, create shared functions in internal/utils/" }, { description: "Simplify complex functions (>50 lines)", contextHint: "Extract helper functions, use early returns, reduce nesting" }, { description: "Add error context wrapping", contextHint: "Use fmt.Errorf('operation failed: %w', err) pattern" }, { description: "Replace magic values with constants", contextHint: "Create constants.go for service-specific values" } ] })
→ Save codeQualityTaskId
9. **Create Test Coverage Task** (Priority 3)
coordinator_create_agent_task({ humanTaskId: "{{from_step_5}}", agentName: "go-dev", role: "Increase unit ```
Maintain Hyper Go Backend Techdebt Refactor?
Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.
[Hyper Go Backend Techdebt Refactor on getagentictools](https://getagentictools.com/loops/hyperionwave-ai-hyperion-go-backend-tech-debt-refactor-task?ref=badge)