gaia-framework 1.58.0 → 1.58.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/commands/gaia-a11y-testing.md +17 -0
- package/.claude/commands/gaia-action-items.md +23 -0
- package/.claude/commands/gaia-add-feature.md +17 -0
- package/.claude/commands/gaia-add-stories.md +17 -0
- package/.claude/commands/gaia-advanced-elicitation.md +17 -0
- package/.claude/commands/gaia-adversarial.md +15 -0
- package/.claude/commands/gaia-agent-analyst.md +14 -0
- package/.claude/commands/gaia-agent-architect.md +14 -0
- package/.claude/commands/gaia-agent-brainstorming.md +14 -0
- package/.claude/commands/gaia-agent-data-engineer.md +14 -0
- package/.claude/commands/gaia-agent-design-thinking.md +14 -0
- package/.claude/commands/gaia-agent-dev-angular.md +14 -0
- package/.claude/commands/gaia-agent-dev-flutter.md +14 -0
- package/.claude/commands/gaia-agent-dev-go.md +14 -0
- package/.claude/commands/gaia-agent-dev-java.md +14 -0
- package/.claude/commands/gaia-agent-dev-mobile.md +14 -0
- package/.claude/commands/gaia-agent-dev-python.md +14 -0
- package/.claude/commands/gaia-agent-dev-typescript.md +14 -0
- package/.claude/commands/gaia-agent-devops.md +14 -0
- package/.claude/commands/gaia-agent-innovation.md +14 -0
- package/.claude/commands/gaia-agent-performance.md +14 -0
- package/.claude/commands/gaia-agent-pm.md +14 -0
- package/.claude/commands/gaia-agent-presentation.md +14 -0
- package/.claude/commands/gaia-agent-problem-solver.md +14 -0
- package/.claude/commands/gaia-agent-qa.md +14 -0
- package/.claude/commands/gaia-agent-security.md +14 -0
- package/.claude/commands/gaia-agent-sm.md +14 -0
- package/.claude/commands/gaia-agent-storyteller.md +14 -0
- package/.claude/commands/gaia-agent-tech-writer.md +14 -0
- package/.claude/commands/gaia-agent-test-architect.md +14 -0
- package/.claude/commands/gaia-agent-ux-designer.md +14 -0
- package/.claude/commands/gaia-agent-validator.md +14 -0
- package/.claude/commands/gaia-atdd.md +17 -0
- package/.claude/commands/gaia-brainstorm.md +17 -0
- package/.claude/commands/gaia-brainstorming.md +17 -0
- package/.claude/commands/gaia-brownfield.md +17 -0
- package/.claude/commands/gaia-build-configs.md +22 -0
- package/.claude/commands/gaia-change-request.md +11 -0
- package/.claude/commands/gaia-changelog.md +16 -0
- package/.claude/commands/gaia-check-dod.md +17 -0
- package/.claude/commands/gaia-check-review-gate.md +17 -0
- package/.claude/commands/gaia-ci-setup.md +17 -0
- package/.claude/commands/gaia-code-review.md +17 -0
- package/.claude/commands/gaia-correct-course.md +17 -0
- package/.claude/commands/gaia-create-arch.md +17 -0
- package/.claude/commands/gaia-create-epics.md +17 -0
- package/.claude/commands/gaia-create-prd.md +17 -0
- package/.claude/commands/gaia-create-story.md +23 -0
- package/.claude/commands/gaia-create-ux.md +17 -0
- package/.claude/commands/gaia-creative-sprint.md +17 -0
- package/.claude/commands/gaia-deploy-checklist.md +17 -0
- package/.claude/commands/gaia-design-thinking.md +17 -0
- package/.claude/commands/gaia-dev-story.md +23 -0
- package/.claude/commands/gaia-document-project.md +17 -0
- package/.claude/commands/gaia-domain-research.md +17 -0
- package/.claude/commands/gaia-edge-cases.md +15 -0
- package/.claude/commands/gaia-edit-arch.md +17 -0
- package/.claude/commands/gaia-edit-prd.md +17 -0
- package/.claude/commands/gaia-edit-test-plan.md +17 -0
- package/.claude/commands/gaia-editorial-prose.md +15 -0
- package/.claude/commands/gaia-editorial-structure.md +15 -0
- package/.claude/commands/gaia-epic-status.md +17 -0
- package/.claude/commands/gaia-fix-story.md +17 -0
- package/.claude/commands/gaia-help.md +15 -0
- package/.claude/commands/gaia-index-docs.md +15 -0
- package/.claude/commands/gaia-infra-design.md +17 -0
- package/.claude/commands/gaia-innovation.md +17 -0
- package/.claude/commands/gaia-market-research.md +17 -0
- package/.claude/commands/gaia-memory-hygiene.md +17 -0
- package/.claude/commands/gaia-merge-docs.md +16 -0
- package/.claude/commands/gaia-mobile-testing.md +17 -0
- package/.claude/commands/gaia-nfr.md +17 -0
- package/.claude/commands/gaia-party.md +17 -0
- package/.claude/commands/gaia-perf-testing.md +17 -0
- package/.claude/commands/gaia-performance-review.md +17 -0
- package/.claude/commands/gaia-pitch-deck.md +17 -0
- package/.claude/commands/gaia-post-deploy.md +17 -0
- package/.claude/commands/gaia-problem-solving.md +17 -0
- package/.claude/commands/gaia-product-brief.md +17 -0
- package/.claude/commands/gaia-project-context.md +17 -0
- package/.claude/commands/gaia-qa-tests.md +17 -0
- package/.claude/commands/gaia-quick-dev.md +17 -0
- package/.claude/commands/gaia-quick-spec.md +17 -0
- package/.claude/commands/gaia-readiness-check.md +17 -0
- package/.claude/commands/gaia-refresh-ground-truth.md +17 -0
- package/.claude/commands/gaia-release-plan.md +17 -0
- package/.claude/commands/gaia-resume.md +25 -0
- package/.claude/commands/gaia-retro.md +20 -0
- package/.claude/commands/gaia-review-a11y.md +16 -0
- package/.claude/commands/gaia-review-api.md +16 -0
- package/.claude/commands/gaia-review-deps.md +16 -0
- package/.claude/commands/gaia-review-perf.md +16 -0
- package/.claude/commands/gaia-review-security.md +16 -0
- package/.claude/commands/gaia-rollback-plan.md +17 -0
- package/.claude/commands/gaia-run-all-reviews.md +17 -0
- package/.claude/commands/gaia-security-review.md +17 -0
- package/.claude/commands/gaia-shard-doc.md +15 -0
- package/.claude/commands/gaia-slide-deck.md +17 -0
- package/.claude/commands/gaia-sprint-plan.md +17 -0
- package/.claude/commands/gaia-sprint-status.md +17 -0
- package/.claude/commands/gaia-storytelling.md +17 -0
- package/.claude/commands/gaia-summarize.md +16 -0
- package/.claude/commands/gaia-teach-testing.md +17 -0
- package/.claude/commands/gaia-tech-debt-review.md +20 -0
- package/.claude/commands/gaia-tech-research.md +17 -0
- package/.claude/commands/gaia-test-automate.md +17 -0
- package/.claude/commands/gaia-test-design.md +17 -0
- package/.claude/commands/gaia-test-framework.md +17 -0
- package/.claude/commands/gaia-test-review.md +17 -0
- package/.claude/commands/gaia-threat-model.md +17 -0
- package/.claude/commands/gaia-trace.md +17 -0
- package/.claude/commands/gaia-triage-findings.md +20 -0
- package/.claude/commands/gaia-val-validate-plan.md +17 -0
- package/.claude/commands/gaia-val-validate.md +17 -0
- package/.claude/commands/gaia-validate-framework.md +17 -0
- package/.claude/commands/gaia-validate-prd.md +17 -0
- package/.claude/commands/gaia-validate-story.md +22 -0
- package/.claude/commands/gaia.md +32 -0
- package/CLAUDE.md +165 -0
- package/README.md +3 -3
- package/_gaia/_config/agent-manifest.csv +29 -0
- package/_gaia/_config/agents/CUSTOMIZATION-README.md +117 -0
- package/_gaia/_config/files-manifest.csv +30 -0
- package/_gaia/_config/gaia-help.csv +82 -0
- package/_gaia/_config/global.yaml +45 -0
- package/_gaia/_config/lifecycle-sequence.yaml +623 -0
- package/_gaia/_config/manifest.yaml +24 -0
- package/_gaia/_config/skill-manifest.csv +12 -0
- package/_gaia/_config/task-manifest.csv +17 -0
- package/_gaia/_config/workflow-manifest.csv +73 -0
- package/_gaia/_memory/tier2-results/.gitkeep +0 -0
- package/_gaia/_memory/tier2-results/checkpoint-resume-2026-03-24.yaml +6 -0
- package/_gaia/_memory/tier2-results/engine-scenarios-2026-03-22.yaml +14 -0
- package/_gaia/core/.resolved/.gitkeep +0 -0
- package/_gaia/core/agents/orchestrator.md +303 -0
- package/_gaia/core/config.yaml +8 -0
- package/_gaia/core/engine/error-recovery.xml +28 -0
- package/_gaia/core/engine/protocols/discover-inputs.xml +31 -0
- package/_gaia/core/engine/protocols/handoff.xml +21 -0
- package/_gaia/core/engine/protocols/preflight-check.xml +31 -0
- package/_gaia/core/engine/task-runner.xml +63 -0
- package/_gaia/core/engine/workflow.xml +225 -0
- package/_gaia/core/module-help.csv +21 -0
- package/_gaia/core/protocols/agent-specification-protocol.md +103 -0
- package/_gaia/core/protocols/review-gate-check.xml +29 -0
- package/_gaia/core/protocols/sprint-status-write-safety.xml +35 -0
- package/_gaia/core/protocols/status-sync.xml +49 -0
- package/_gaia/core/tasks/editorial-review-prose.xml +42 -0
- package/_gaia/core/tasks/editorial-review-structure.xml +43 -0
- package/_gaia/core/tasks/generate-changelog.xml +35 -0
- package/_gaia/core/tasks/help.md +45 -0
- package/_gaia/core/tasks/index-docs.xml +46 -0
- package/_gaia/core/tasks/merge-docs.xml +34 -0
- package/_gaia/core/tasks/review-accessibility.xml +47 -0
- package/_gaia/core/tasks/review-adversarial.xml +55 -0
- package/_gaia/core/tasks/review-api-design.xml +38 -0
- package/_gaia/core/tasks/review-dependency-audit.xml +38 -0
- package/_gaia/core/tasks/review-edge-case-hunter.xml +52 -0
- package/_gaia/core/tasks/review-performance.xml +49 -0
- package/_gaia/core/tasks/review-security.xml +37 -0
- package/_gaia/core/tasks/shard-doc.xml +49 -0
- package/_gaia/core/tasks/summarize-doc.xml +33 -0
- package/_gaia/core/tasks/validate-framework.xml +66 -0
- package/_gaia/core/workflows/brainstorming/steps/step-01-session-setup.md +7 -0
- package/_gaia/core/workflows/brainstorming/steps/step-02-technique-selection.md +20 -0
- package/_gaia/core/workflows/brainstorming/steps/step-03-technique-execution.md +11 -0
- package/_gaia/core/workflows/brainstorming/steps/step-04-idea-organization.md +14 -0
- package/_gaia/core/workflows/brainstorming/template.md +38 -0
- package/_gaia/core/workflows/brainstorming/workflow.yaml +26 -0
- package/_gaia/core/workflows/party-mode/steps/step-01-agent-loading.md +11 -0
- package/_gaia/core/workflows/party-mode/steps/step-02-discussion-orchestration.md +16 -0
- package/_gaia/core/workflows/party-mode/steps/step-03-graceful-exit.md +10 -0
- package/_gaia/core/workflows/party-mode/workflow.yaml +23 -0
- package/_gaia/creative/.resolved/.gitkeep +0 -0
- package/_gaia/creative/agents/brainstorming-coach.md +93 -0
- package/_gaia/creative/agents/design-thinking-coach.md +91 -0
- package/_gaia/creative/agents/innovation-strategist.md +89 -0
- package/_gaia/creative/agents/presentation-designer.md +99 -0
- package/_gaia/creative/agents/problem-solver.md +90 -0
- package/_gaia/creative/agents/storyteller.md +90 -0
- package/_gaia/creative/config.yaml +8 -0
- package/_gaia/creative/data/design-methods.csv +28 -0
- package/_gaia/creative/data/innovation-frameworks.csv +15 -0
- package/_gaia/creative/data/solving-methods.csv +14 -0
- package/_gaia/creative/data/story-types.csv +12 -0
- package/_gaia/creative/module-help.csv +8 -0
- package/_gaia/creative/teams/creative-squad.yaml +10 -0
- package/_gaia/creative/workflows/creative-sprint/checklist.md +10 -0
- package/_gaia/creative/workflows/creative-sprint/instructions.xml +40 -0
- package/_gaia/creative/workflows/creative-sprint/workflow.yaml +11 -0
- package/_gaia/creative/workflows/design-thinking/checklist.md +25 -0
- package/_gaia/creative/workflows/design-thinking/instructions.xml +38 -0
- package/_gaia/creative/workflows/design-thinking/workflow.yaml +13 -0
- package/_gaia/creative/workflows/innovation-strategy/checklist.md +26 -0
- package/_gaia/creative/workflows/innovation-strategy/instructions.xml +34 -0
- package/_gaia/creative/workflows/innovation-strategy/workflow.yaml +13 -0
- package/_gaia/creative/workflows/pitch-deck/checklist.md +22 -0
- package/_gaia/creative/workflows/pitch-deck/instructions.xml +49 -0
- package/_gaia/creative/workflows/pitch-deck/workflow.yaml +15 -0
- package/_gaia/creative/workflows/problem-solving/checklist.md +26 -0
- package/_gaia/creative/workflows/problem-solving/instructions.xml +39 -0
- package/_gaia/creative/workflows/problem-solving/workflow.yaml +13 -0
- package/_gaia/creative/workflows/slide-deck/checklist.md +21 -0
- package/_gaia/creative/workflows/slide-deck/instructions.xml +39 -0
- package/_gaia/creative/workflows/slide-deck/workflow.yaml +15 -0
- package/_gaia/creative/workflows/storytelling/checklist.md +26 -0
- package/_gaia/creative/workflows/storytelling/instructions.xml +38 -0
- package/_gaia/creative/workflows/storytelling/workflow.yaml +13 -0
- package/_gaia/dev/agents/_base-dev.md +180 -0
- package/_gaia/dev/agents/angular-dev.md +70 -0
- package/_gaia/dev/agents/flutter-dev.md +70 -0
- package/_gaia/dev/agents/go-dev.md +72 -0
- package/_gaia/dev/agents/java-dev.md +70 -0
- package/_gaia/dev/agents/mobile-dev.md +70 -0
- package/_gaia/dev/agents/python-dev.md +70 -0
- package/_gaia/dev/agents/typescript-dev.md +70 -0
- package/_gaia/dev/config.yaml +11 -0
- package/_gaia/dev/knowledge/_index.csv +25 -0
- package/_gaia/dev/knowledge/angular/angular-conventions.md +119 -0
- package/_gaia/dev/knowledge/angular/angular-patterns.md +126 -0
- package/_gaia/dev/knowledge/angular/ngrx-state.md +124 -0
- package/_gaia/dev/knowledge/angular/rxjs-patterns.md +119 -0
- package/_gaia/dev/knowledge/flutter/dart-conventions.md +143 -0
- package/_gaia/dev/knowledge/flutter/platform-channels.md +144 -0
- package/_gaia/dev/knowledge/flutter/state-management.md +144 -0
- package/_gaia/dev/knowledge/flutter/widget-patterns.md +134 -0
- package/_gaia/dev/knowledge/go/gin-fiber-patterns.md +40 -0
- package/_gaia/dev/knowledge/go/go-conventions.md +54 -0
- package/_gaia/dev/knowledge/go/go-stdlib-patterns.md +39 -0
- package/_gaia/dev/knowledge/go/go-testing-patterns.md +39 -0
- package/_gaia/dev/knowledge/java/jpa-patterns.md +136 -0
- package/_gaia/dev/knowledge/java/maven-gradle.md +189 -0
- package/_gaia/dev/knowledge/java/microservices.md +159 -0
- package/_gaia/dev/knowledge/java/spring-boot-patterns.md +160 -0
- package/_gaia/dev/knowledge/mobile/kotlin-patterns.md +193 -0
- package/_gaia/dev/knowledge/mobile/mobile-testing.md +186 -0
- package/_gaia/dev/knowledge/mobile/react-native-patterns.md +162 -0
- package/_gaia/dev/knowledge/mobile/swift-patterns.md +190 -0
- package/_gaia/dev/knowledge/python/data-pipelines.md +169 -0
- package/_gaia/dev/knowledge/python/django-patterns.md +145 -0
- package/_gaia/dev/knowledge/python/fastapi-patterns.md +164 -0
- package/_gaia/dev/knowledge/python/python-conventions.md +170 -0
- package/_gaia/dev/knowledge/typescript/express-patterns.md +188 -0
- package/_gaia/dev/knowledge/typescript/nextjs-patterns.md +166 -0
- package/_gaia/dev/knowledge/typescript/react-patterns.md +176 -0
- package/_gaia/dev/knowledge/typescript/ts-conventions.md +133 -0
- package/_gaia/dev/module-help.csv +10 -0
- package/_gaia/dev/skills/_skill-index.yaml +55 -0
- package/_gaia/dev/skills/api-design.md +229 -0
- package/_gaia/dev/skills/code-review-standards.md +226 -0
- package/_gaia/dev/skills/database-design.md +172 -0
- package/_gaia/dev/skills/docker-workflow.md +222 -0
- package/_gaia/dev/skills/documentation-standards.md +256 -0
- package/_gaia/dev/skills/git-workflow.md +157 -0
- package/_gaia/dev/skills/security-basics.md +230 -0
- package/_gaia/dev/skills/testing-patterns.md +232 -0
- package/_gaia/lifecycle/.resolved/.gitkeep +0 -0
- package/_gaia/lifecycle/agents/analyst.md +104 -0
- package/_gaia/lifecycle/agents/architect.md +109 -0
- package/_gaia/lifecycle/agents/data-engineer.md +99 -0
- package/_gaia/lifecycle/agents/devops.md +110 -0
- package/_gaia/lifecycle/agents/performance.md +92 -0
- package/_gaia/lifecycle/agents/pm.md +112 -0
- package/_gaia/lifecycle/agents/qa.md +89 -0
- package/_gaia/lifecycle/agents/security.md +108 -0
- package/_gaia/lifecycle/agents/sm.md +119 -0
- package/_gaia/lifecycle/agents/tech-writer.md +94 -0
- package/_gaia/lifecycle/agents/ux-designer.md +94 -0
- package/_gaia/lifecycle/agents/validator.md +189 -0
- package/_gaia/lifecycle/config.yaml +14 -0
- package/_gaia/lifecycle/module-help.csv +39 -0
- package/_gaia/lifecycle/skills/ground-truth-management.md +252 -0
- package/_gaia/lifecycle/skills/memory-management.md +322 -0
- package/_gaia/lifecycle/skills/validation-patterns.md +230 -0
- package/_gaia/lifecycle/teams/team-data-intensive.yaml +12 -0
- package/_gaia/lifecycle/teams/team-enterprise.yaml +16 -0
- package/_gaia/lifecycle/teams/team-full.yaml +13 -0
- package/_gaia/lifecycle/teams/team-implementation.yaml +8 -0
- package/_gaia/lifecycle/teams/team-planning.yaml +9 -0
- package/_gaia/lifecycle/teams/team-quick-ship.yaml +6 -0
- package/_gaia/lifecycle/teams/team-security-focused.yaml +13 -0
- package/_gaia/lifecycle/templates/api-documentation-template.md +112 -0
- package/_gaia/lifecycle/templates/architecture-template.md +65 -0
- package/_gaia/lifecycle/templates/brownfield-architecture-template.md +198 -0
- package/_gaia/lifecycle/templates/brownfield-assessment-template.md +78 -0
- package/_gaia/lifecycle/templates/brownfield-onboarding-template.md +160 -0
- package/_gaia/lifecycle/templates/dependency-map-template.md +73 -0
- package/_gaia/lifecycle/templates/deployment-template.md +52 -0
- package/_gaia/lifecycle/templates/epic-status-template.md +64 -0
- package/_gaia/lifecycle/templates/event-catalog-template.md +78 -0
- package/_gaia/lifecycle/templates/nfr-assessment-template.md +96 -0
- package/_gaia/lifecycle/templates/prd-template.md +83 -0
- package/_gaia/lifecycle/templates/product-brief-template.md +48 -0
- package/_gaia/lifecycle/templates/review-template.md +47 -0
- package/_gaia/lifecycle/templates/sprint-plan-template.md +45 -0
- package/_gaia/lifecycle/templates/story-template.md +118 -0
- package/_gaia/lifecycle/templates/tech-debt-dashboard-template.md +71 -0
- package/_gaia/lifecycle/templates/test-plan-template.md +56 -0
- package/_gaia/lifecycle/templates/ux-design-assessment-template.md +122 -0
- package/_gaia/lifecycle/workflows/1-analysis/advanced-elicitation/instructions.xml +44 -0
- package/_gaia/lifecycle/workflows/1-analysis/advanced-elicitation/methods.csv +9 -0
- package/_gaia/lifecycle/workflows/1-analysis/advanced-elicitation/workflow.yaml +33 -0
- package/_gaia/lifecycle/workflows/1-analysis/brainstorm-project/checklist.md +24 -0
- package/_gaia/lifecycle/workflows/1-analysis/brainstorm-project/instructions.xml +39 -0
- package/_gaia/lifecycle/workflows/1-analysis/brainstorm-project/workflow.yaml +19 -0
- package/_gaia/lifecycle/workflows/1-analysis/create-product-brief/checklist.md +27 -0
- package/_gaia/lifecycle/workflows/1-analysis/create-product-brief/instructions.xml +57 -0
- package/_gaia/lifecycle/workflows/1-analysis/create-product-brief/workflow.yaml +38 -0
- package/_gaia/lifecycle/workflows/1-analysis/domain-research/checklist.md +22 -0
- package/_gaia/lifecycle/workflows/1-analysis/domain-research/instructions.xml +34 -0
- package/_gaia/lifecycle/workflows/1-analysis/domain-research/workflow.yaml +15 -0
- package/_gaia/lifecycle/workflows/1-analysis/market-research/checklist.md +28 -0
- package/_gaia/lifecycle/workflows/1-analysis/market-research/instructions.xml +42 -0
- package/_gaia/lifecycle/workflows/1-analysis/market-research/workflow.yaml +15 -0
- package/_gaia/lifecycle/workflows/1-analysis/technical-research/checklist.md +22 -0
- package/_gaia/lifecycle/workflows/1-analysis/technical-research/instructions.xml +34 -0
- package/_gaia/lifecycle/workflows/1-analysis/technical-research/workflow.yaml +15 -0
- package/_gaia/lifecycle/workflows/2-planning/create-prd/checklist.md +36 -0
- package/_gaia/lifecycle/workflows/2-planning/create-prd/instructions.xml +80 -0
- package/_gaia/lifecycle/workflows/2-planning/create-prd/workflow.yaml +23 -0
- package/_gaia/lifecycle/workflows/2-planning/create-ux-design/checklist.md +26 -0
- package/_gaia/lifecycle/workflows/2-planning/create-ux-design/instructions.xml +49 -0
- package/_gaia/lifecycle/workflows/2-planning/create-ux-design/workflow.yaml +23 -0
- package/_gaia/lifecycle/workflows/2-planning/edit-prd/checklist.md +17 -0
- package/_gaia/lifecycle/workflows/2-planning/edit-prd/instructions.xml +50 -0
- package/_gaia/lifecycle/workflows/2-planning/edit-prd/workflow.yaml +22 -0
- package/_gaia/lifecycle/workflows/2-planning/validate-prd/checklist.md +12 -0
- package/_gaia/lifecycle/workflows/2-planning/validate-prd/instructions.xml +52 -0
- package/_gaia/lifecycle/workflows/2-planning/validate-prd/workflow.yaml +19 -0
- package/_gaia/lifecycle/workflows/3-solutioning/create-architecture/checklist.md +32 -0
- package/_gaia/lifecycle/workflows/3-solutioning/create-architecture/instructions.xml +100 -0
- package/_gaia/lifecycle/workflows/3-solutioning/create-architecture/workflow.yaml +41 -0
- package/_gaia/lifecycle/workflows/3-solutioning/create-epics-stories/checklist.md +30 -0
- package/_gaia/lifecycle/workflows/3-solutioning/create-epics-stories/instructions.xml +86 -0
- package/_gaia/lifecycle/workflows/3-solutioning/create-epics-stories/workflow.yaml +34 -0
- package/_gaia/lifecycle/workflows/3-solutioning/edit-architecture/checklist.md +24 -0
- package/_gaia/lifecycle/workflows/3-solutioning/edit-architecture/instructions.xml +91 -0
- package/_gaia/lifecycle/workflows/3-solutioning/edit-architecture/workflow.yaml +32 -0
- package/_gaia/lifecycle/workflows/3-solutioning/implementation-readiness/checklist.md +66 -0
- package/_gaia/lifecycle/workflows/3-solutioning/implementation-readiness/instructions.xml +160 -0
- package/_gaia/lifecycle/workflows/3-solutioning/implementation-readiness/workflow.yaml +48 -0
- package/_gaia/lifecycle/workflows/3-solutioning/infrastructure-design/checklist.md +24 -0
- package/_gaia/lifecycle/workflows/3-solutioning/infrastructure-design/instructions.xml +44 -0
- package/_gaia/lifecycle/workflows/3-solutioning/infrastructure-design/workflow.yaml +23 -0
- package/_gaia/lifecycle/workflows/3-solutioning/security-threat-model/checklist.md +24 -0
- package/_gaia/lifecycle/workflows/3-solutioning/security-threat-model/instructions.xml +55 -0
- package/_gaia/lifecycle/workflows/3-solutioning/security-threat-model/workflow.yaml +23 -0
- package/_gaia/lifecycle/workflows/4-implementation/action-items/instructions.xml +131 -0
- package/_gaia/lifecycle/workflows/4-implementation/action-items/workflow.yaml +19 -0
- package/_gaia/lifecycle/workflows/4-implementation/add-stories/checklist.md +27 -0
- package/_gaia/lifecycle/workflows/4-implementation/add-stories/instructions.xml +100 -0
- package/_gaia/lifecycle/workflows/4-implementation/add-stories/workflow.yaml +35 -0
- package/_gaia/lifecycle/workflows/4-implementation/change-request/checklist.md +25 -0
- package/_gaia/lifecycle/workflows/4-implementation/change-request/instructions.xml +123 -0
- package/_gaia/lifecycle/workflows/4-implementation/change-request/workflow.yaml +38 -0
- package/_gaia/lifecycle/workflows/4-implementation/check-dod/checklist.md +18 -0
- package/_gaia/lifecycle/workflows/4-implementation/check-dod/instructions.xml +54 -0
- package/_gaia/lifecycle/workflows/4-implementation/check-dod/workflow.yaml +19 -0
- package/_gaia/lifecycle/workflows/4-implementation/check-review-gate/checklist.md +18 -0
- package/_gaia/lifecycle/workflows/4-implementation/check-review-gate/instructions.xml +53 -0
- package/_gaia/lifecycle/workflows/4-implementation/check-review-gate/workflow.yaml +19 -0
- package/_gaia/lifecycle/workflows/4-implementation/code-review/checklist.md +18 -0
- package/_gaia/lifecycle/workflows/4-implementation/code-review/instructions.xml +50 -0
- package/_gaia/lifecycle/workflows/4-implementation/code-review/workflow.yaml +24 -0
- package/_gaia/lifecycle/workflows/4-implementation/correct-course/checklist.md +21 -0
- package/_gaia/lifecycle/workflows/4-implementation/correct-course/instructions.xml +63 -0
- package/_gaia/lifecycle/workflows/4-implementation/correct-course/workflow.yaml +25 -0
- package/_gaia/lifecycle/workflows/4-implementation/create-story/checklist.md +38 -0
- package/_gaia/lifecycle/workflows/4-implementation/create-story/instructions.xml +194 -0
- package/_gaia/lifecycle/workflows/4-implementation/create-story/workflow.yaml +26 -0
- package/_gaia/lifecycle/workflows/4-implementation/dev-story/checklist.md +26 -0
- package/_gaia/lifecycle/workflows/4-implementation/dev-story/instructions.xml +268 -0
- package/_gaia/lifecycle/workflows/4-implementation/dev-story/workflow.yaml +51 -0
- package/_gaia/lifecycle/workflows/4-implementation/epic-status/checklist.md +25 -0
- package/_gaia/lifecycle/workflows/4-implementation/epic-status/instructions.xml +62 -0
- package/_gaia/lifecycle/workflows/4-implementation/epic-status/workflow.yaml +24 -0
- package/_gaia/lifecycle/workflows/4-implementation/fix-story/checklist.md +12 -0
- package/_gaia/lifecycle/workflows/4-implementation/fix-story/instructions.xml +67 -0
- package/_gaia/lifecycle/workflows/4-implementation/fix-story/workflow.yaml +17 -0
- package/_gaia/lifecycle/workflows/4-implementation/qa-generate-tests/checklist.md +19 -0
- package/_gaia/lifecycle/workflows/4-implementation/qa-generate-tests/instructions.xml +52 -0
- package/_gaia/lifecycle/workflows/4-implementation/qa-generate-tests/workflow.yaml +20 -0
- package/_gaia/lifecycle/workflows/4-implementation/retrospective/checklist.md +15 -0
- package/_gaia/lifecycle/workflows/4-implementation/retrospective/instructions.xml +164 -0
- package/_gaia/lifecycle/workflows/4-implementation/retrospective/workflow.yaml +30 -0
- package/_gaia/lifecycle/workflows/4-implementation/run-all-reviews/checklist.md +14 -0
- package/_gaia/lifecycle/workflows/4-implementation/run-all-reviews/instructions.xml +78 -0
- package/_gaia/lifecycle/workflows/4-implementation/run-all-reviews/workflow.yaml +16 -0
- package/_gaia/lifecycle/workflows/4-implementation/security-review/checklist.md +29 -0
- package/_gaia/lifecycle/workflows/4-implementation/security-review/instructions.xml +80 -0
- package/_gaia/lifecycle/workflows/4-implementation/security-review/workflow.yaml +27 -0
- package/_gaia/lifecycle/workflows/4-implementation/sprint-planning/checklist.md +29 -0
- package/_gaia/lifecycle/workflows/4-implementation/sprint-planning/instructions.xml +140 -0
- package/_gaia/lifecycle/workflows/4-implementation/sprint-planning/workflow.yaml +33 -0
- package/_gaia/lifecycle/workflows/4-implementation/sprint-status/checklist.md +18 -0
- package/_gaia/lifecycle/workflows/4-implementation/sprint-status/instructions.xml +36 -0
- package/_gaia/lifecycle/workflows/4-implementation/sprint-status/workflow.yaml +19 -0
- package/_gaia/lifecycle/workflows/4-implementation/tech-debt-review/checklist.md +30 -0
- package/_gaia/lifecycle/workflows/4-implementation/tech-debt-review/instructions.xml +147 -0
- package/_gaia/lifecycle/workflows/4-implementation/tech-debt-review/workflow.yaml +24 -0
- package/_gaia/lifecycle/workflows/4-implementation/triage-findings/checklist.md +17 -0
- package/_gaia/lifecycle/workflows/4-implementation/triage-findings/instructions.xml +124 -0
- package/_gaia/lifecycle/workflows/4-implementation/triage-findings/workflow.yaml +15 -0
- package/_gaia/lifecycle/workflows/4-implementation/val-refresh-ground-truth/checklist.md +48 -0
- package/_gaia/lifecycle/workflows/4-implementation/val-refresh-ground-truth/instructions.xml +125 -0
- package/_gaia/lifecycle/workflows/4-implementation/val-refresh-ground-truth/workflow.yaml +31 -0
- package/_gaia/lifecycle/workflows/4-implementation/val-validate-artifact/checklist.md +54 -0
- package/_gaia/lifecycle/workflows/4-implementation/val-validate-artifact/instructions.xml +147 -0
- package/_gaia/lifecycle/workflows/4-implementation/val-validate-artifact/test-structure.sh +116 -0
- package/_gaia/lifecycle/workflows/4-implementation/val-validate-artifact/workflow.yaml +29 -0
- package/_gaia/lifecycle/workflows/4-implementation/val-validate-plan/checklist.md +34 -0
- package/_gaia/lifecycle/workflows/4-implementation/val-validate-plan/instructions.xml +162 -0
- package/_gaia/lifecycle/workflows/4-implementation/val-validate-plan/workflow.yaml +39 -0
- package/_gaia/lifecycle/workflows/4-implementation/validate-story/checklist.md +23 -0
- package/_gaia/lifecycle/workflows/4-implementation/validate-story/instructions.xml +146 -0
- package/_gaia/lifecycle/workflows/4-implementation/validate-story/workflow.yaml +25 -0
- package/_gaia/lifecycle/workflows/5-deployment/deployment-checklist/checklist.md +29 -0
- package/_gaia/lifecycle/workflows/5-deployment/deployment-checklist/instructions.xml +59 -0
- package/_gaia/lifecycle/workflows/5-deployment/deployment-checklist/workflow.yaml +39 -0
- package/_gaia/lifecycle/workflows/5-deployment/post-deploy-verify/checklist.md +19 -0
- package/_gaia/lifecycle/workflows/5-deployment/post-deploy-verify/instructions.xml +33 -0
- package/_gaia/lifecycle/workflows/5-deployment/post-deploy-verify/workflow.yaml +15 -0
- package/_gaia/lifecycle/workflows/5-deployment/release-plan/checklist.md +20 -0
- package/_gaia/lifecycle/workflows/5-deployment/release-plan/instructions.xml +33 -0
- package/_gaia/lifecycle/workflows/5-deployment/release-plan/workflow.yaml +19 -0
- package/_gaia/lifecycle/workflows/5-deployment/rollback-plan/checklist.md +20 -0
- package/_gaia/lifecycle/workflows/5-deployment/rollback-plan/instructions.xml +33 -0
- package/_gaia/lifecycle/workflows/5-deployment/rollback-plan/workflow.yaml +15 -0
- package/_gaia/lifecycle/workflows/anytime/brownfield-onboarding/checklist.md +52 -0
- package/_gaia/lifecycle/workflows/anytime/brownfield-onboarding/instructions.xml +122 -0
- package/_gaia/lifecycle/workflows/anytime/brownfield-onboarding/test-step7.sh +149 -0
- package/_gaia/lifecycle/workflows/anytime/brownfield-onboarding/workflow.yaml +33 -0
- package/_gaia/lifecycle/workflows/anytime/document-project/checklist.md +11 -0
- package/_gaia/lifecycle/workflows/anytime/document-project/instructions.xml +26 -0
- package/_gaia/lifecycle/workflows/anytime/document-project/workflow.yaml +15 -0
- package/_gaia/lifecycle/workflows/anytime/generate-project-context/checklist.md +11 -0
- package/_gaia/lifecycle/workflows/anytime/generate-project-context/instructions.xml +22 -0
- package/_gaia/lifecycle/workflows/anytime/generate-project-context/workflow.yaml +15 -0
- package/_gaia/lifecycle/workflows/anytime/memory-hygiene/checklist.md +66 -0
- package/_gaia/lifecycle/workflows/anytime/memory-hygiene/instructions.xml +206 -0
- package/_gaia/lifecycle/workflows/anytime/memory-hygiene/workflow.yaml +15 -0
- package/_gaia/lifecycle/workflows/anytime/performance-review/checklist.md +25 -0
- package/_gaia/lifecycle/workflows/anytime/performance-review/instructions.xml +62 -0
- package/_gaia/lifecycle/workflows/anytime/performance-review/workflow.yaml +15 -0
- package/_gaia/lifecycle/workflows/cross-phase/add-feature/checklist.md +30 -0
- package/_gaia/lifecycle/workflows/cross-phase/add-feature/instructions.xml +85 -0
- package/_gaia/lifecycle/workflows/cross-phase/add-feature/workflow.yaml +37 -0
- package/_gaia/lifecycle/workflows/quick-flow/quick-dev/checklist.md +11 -0
- package/_gaia/lifecycle/workflows/quick-flow/quick-dev/instructions.xml +26 -0
- package/_gaia/lifecycle/workflows/quick-flow/quick-dev/workflow.yaml +19 -0
- package/_gaia/lifecycle/workflows/quick-flow/quick-spec/checklist.md +13 -0
- package/_gaia/lifecycle/workflows/quick-flow/quick-spec/instructions.xml +27 -0
- package/_gaia/lifecycle/workflows/quick-flow/quick-spec/workflow.yaml +15 -0
- package/_gaia/testing/.resolved/.gitkeep +0 -0
- package/_gaia/testing/agents/test-architect.md +131 -0
- package/_gaia/testing/config.yaml +8 -0
- package/_gaia/testing/knowledge/_index.csv +22 -0
- package/_gaia/testing/knowledge/accessibility/axe-core-patterns.md +177 -0
- package/_gaia/testing/knowledge/accessibility/wcag-checks.md +191 -0
- package/_gaia/testing/knowledge/core/deterministic-testing.md +167 -0
- package/_gaia/testing/knowledge/core/fixture-architecture.md +131 -0
- package/_gaia/testing/knowledge/core/test-isolation.md +142 -0
- package/_gaia/testing/knowledge/core/test-pyramid.md +129 -0
- package/_gaia/testing/knowledge/extended/api-testing-patterns.md +196 -0
- package/_gaia/testing/knowledge/extended/data-factories.md +158 -0
- package/_gaia/testing/knowledge/extended/risk-governance.md +119 -0
- package/_gaia/testing/knowledge/extended/selector-resilience.md +109 -0
- package/_gaia/testing/knowledge/mobile-testing/appium-patterns.md +164 -0
- package/_gaia/testing/knowledge/mobile-testing/react-native-testing.md +193 -0
- package/_gaia/testing/knowledge/mobile-testing/responsive-testing.md +177 -0
- package/_gaia/testing/knowledge/performance/k6-patterns.md +200 -0
- package/_gaia/testing/knowledge/performance/lighthouse-ci.md +158 -0
- package/_gaia/testing/knowledge/specialized/contract-testing.md +173 -0
- package/_gaia/testing/knowledge/specialized/test-healing.md +129 -0
- package/_gaia/testing/knowledge/specialized/visual-testing.md +129 -0
- package/_gaia/testing/knowledge/unit-testing/jest-vitest-patterns.md +193 -0
- package/_gaia/testing/knowledge/unit-testing/junit5-patterns.md +200 -0
- package/_gaia/testing/knowledge/unit-testing/pytest-patterns.md +185 -0
- package/_gaia/testing/module-help.csv +13 -0
- package/_gaia/testing/workflows/accessibility-testing/checklist.md +12 -0
- package/_gaia/testing/workflows/accessibility-testing/instructions.xml +41 -0
- package/_gaia/testing/workflows/accessibility-testing/workflow.yaml +13 -0
- package/_gaia/testing/workflows/atdd/checklist.md +6 -0
- package/_gaia/testing/workflows/atdd/instructions.xml +36 -0
- package/_gaia/testing/workflows/atdd/workflow.yaml +22 -0
- package/_gaia/testing/workflows/ci-setup/checklist.md +9 -0
- package/_gaia/testing/workflows/ci-setup/instructions.xml +43 -0
- package/_gaia/testing/workflows/ci-setup/workflow.yaml +11 -0
- package/_gaia/testing/workflows/edit-test-plan/checklist.md +20 -0
- package/_gaia/testing/workflows/edit-test-plan/instructions.xml +65 -0
- package/_gaia/testing/workflows/edit-test-plan/workflow.yaml +35 -0
- package/_gaia/testing/workflows/mobile-testing/checklist.md +13 -0
- package/_gaia/testing/workflows/mobile-testing/instructions.xml +41 -0
- package/_gaia/testing/workflows/mobile-testing/workflow.yaml +11 -0
- package/_gaia/testing/workflows/nfr-assessment/checklist.md +7 -0
- package/_gaia/testing/workflows/nfr-assessment/instructions.xml +26 -0
- package/_gaia/testing/workflows/nfr-assessment/workflow.yaml +11 -0
- package/_gaia/testing/workflows/performance-testing/checklist.md +11 -0
- package/_gaia/testing/workflows/performance-testing/instructions.xml +41 -0
- package/_gaia/testing/workflows/performance-testing/workflow.yaml +11 -0
- package/_gaia/testing/workflows/teach-me-testing/checklist.md +6 -0
- package/_gaia/testing/workflows/teach-me-testing/instructions.xml +28 -0
- package/_gaia/testing/workflows/teach-me-testing/workflow.yaml +12 -0
- package/_gaia/testing/workflows/test-automation/checklist.md +6 -0
- package/_gaia/testing/workflows/test-automation/instructions.xml +49 -0
- package/_gaia/testing/workflows/test-automation/workflow.yaml +11 -0
- package/_gaia/testing/workflows/test-design/checklist.md +9 -0
- package/_gaia/testing/workflows/test-design/instructions.xml +47 -0
- package/_gaia/testing/workflows/test-design/workflow.yaml +11 -0
- package/_gaia/testing/workflows/test-framework/checklist.md +8 -0
- package/_gaia/testing/workflows/test-framework/instructions.xml +25 -0
- package/_gaia/testing/workflows/test-framework/workflow.yaml +11 -0
- package/_gaia/testing/workflows/test-review/checklist.md +9 -0
- package/_gaia/testing/workflows/test-review/instructions.xml +51 -0
- package/_gaia/testing/workflows/test-review/workflow.yaml +11 -0
- package/_gaia/testing/workflows/traceability/checklist.md +6 -0
- package/_gaia/testing/workflows/traceability/instructions.xml +49 -0
- package/_gaia/testing/workflows/traceability/workflow.yaml +21 -0
- package/bin/gaia-framework.js +58 -20
- package/gaia-install.sh +1 -1
- package/package.json +21 -7
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Gin & Fiber Web Framework Patterns
|
|
2
|
+
|
|
3
|
+
<!-- SECTION: gin -->
|
|
4
|
+
## Gin Patterns
|
|
5
|
+
|
|
6
|
+
- Router groups for versioned APIs: `v1 := r.Group("/api/v1")`
|
|
7
|
+
- Middleware: `r.Use(middleware)` — logging, auth, CORS, recovery
|
|
8
|
+
- Context: `c.JSON()`, `c.ShouldBindJSON()`, `c.Param()`, `c.Query()`
|
|
9
|
+
- Validation with binding tags: `binding:"required,min=1"`
|
|
10
|
+
- Error handling: custom error response struct with status codes
|
|
11
|
+
- Graceful shutdown with `signal.Notify` + `server.Shutdown`
|
|
12
|
+
|
|
13
|
+
<!-- SECTION: fiber -->
|
|
14
|
+
## Fiber Patterns
|
|
15
|
+
|
|
16
|
+
- Express-inspired API: `app.Get("/path", handler)`
|
|
17
|
+
- Middleware: `app.Use(middleware)` — similar to Express
|
|
18
|
+
- Context: `c.JSON()`, `c.BodyParser()`, `c.Params()`, `c.Query()`
|
|
19
|
+
- High performance via fasthttp (not net/http)
|
|
20
|
+
- Prefork for multi-core utilization
|
|
21
|
+
|
|
22
|
+
<!-- SECTION: grpc -->
|
|
23
|
+
## gRPC Patterns
|
|
24
|
+
|
|
25
|
+
- Protocol Buffers for service definition (`.proto` files)
|
|
26
|
+
- `protoc` compiler generates Go code
|
|
27
|
+
- Unary, server-streaming, client-streaming, bidirectional
|
|
28
|
+
- Interceptors for middleware (logging, auth, tracing)
|
|
29
|
+
- Health checks: `grpc_health_v1`
|
|
30
|
+
- Reflection for debugging: `reflection.Register(server)`
|
|
31
|
+
|
|
32
|
+
<!-- SECTION: database -->
|
|
33
|
+
## Database Patterns
|
|
34
|
+
|
|
35
|
+
- `database/sql` for raw SQL with connection pooling
|
|
36
|
+
- GORM for ORM: models with struct tags, migrations, associations
|
|
37
|
+
- sqlx for enhanced `database/sql` with named params and struct scanning
|
|
38
|
+
- Connection pool: `SetMaxOpenConns`, `SetMaxIdleConns`, `SetConnMaxLifetime`
|
|
39
|
+
- Transactions: `tx, err := db.Begin()` / `tx.Commit()` / `tx.Rollback()`
|
|
40
|
+
- Migrations: golang-migrate or GORM AutoMigrate
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Go Conventions & Project Structure
|
|
2
|
+
|
|
3
|
+
<!-- SECTION: project-layout -->
|
|
4
|
+
## Project Layout
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
project/
|
|
8
|
+
├── cmd/ # Entry points (main packages)
|
|
9
|
+
│ └── server/
|
|
10
|
+
│ └── main.go
|
|
11
|
+
├── internal/ # Private packages (not importable externally)
|
|
12
|
+
│ ├── handler/ # HTTP/gRPC handlers
|
|
13
|
+
│ ├── service/ # Business logic
|
|
14
|
+
│ ├── repository/# Data access
|
|
15
|
+
│ └── model/ # Domain models
|
|
16
|
+
├── pkg/ # Public reusable packages
|
|
17
|
+
├── api/ # API definitions (proto, OpenAPI)
|
|
18
|
+
├── config/ # Configuration
|
|
19
|
+
├── migrations/ # Database migrations
|
|
20
|
+
├── go.mod
|
|
21
|
+
├── go.sum
|
|
22
|
+
└── Makefile
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
<!-- SECTION: naming -->
|
|
26
|
+
## Naming Conventions
|
|
27
|
+
|
|
28
|
+
- Packages: short, lowercase, single word (`http`, `user`, `auth`)
|
|
29
|
+
- Exported: `PascalCase` — visible outside package
|
|
30
|
+
- Unexported: `camelCase` — private to package
|
|
31
|
+
- Interfaces: `-er` suffix for single-method (`Reader`, `Writer`, `Stringer`)
|
|
32
|
+
- Getters: no `Get` prefix — `user.Name()` not `user.GetName()`
|
|
33
|
+
- Acronyms: all caps (`HTTPHandler`, `URLParser`, `ID`)
|
|
34
|
+
- Test files: `xxx_test.go` alongside source
|
|
35
|
+
|
|
36
|
+
<!-- SECTION: code-style -->
|
|
37
|
+
## Code Style
|
|
38
|
+
|
|
39
|
+
- `gofmt` / `goimports` — non-negotiable formatting
|
|
40
|
+
- `golangci-lint` for comprehensive linting
|
|
41
|
+
- Short variable names in small scopes: `i`, `r`, `w`, `ctx`
|
|
42
|
+
- Descriptive names for exported APIs
|
|
43
|
+
- Group imports: stdlib, blank line, third-party, blank line, internal
|
|
44
|
+
- No unused imports or variables (compiler enforced)
|
|
45
|
+
|
|
46
|
+
<!-- SECTION: patterns -->
|
|
47
|
+
## Common Patterns
|
|
48
|
+
|
|
49
|
+
- Functional options: `func WithTimeout(d time.Duration) Option`
|
|
50
|
+
- Constructor: `func NewService(opts ...Option) *Service`
|
|
51
|
+
- Repository pattern: interface for data access, struct implements
|
|
52
|
+
- Middleware chain: compose handlers via wrapping
|
|
53
|
+
- Config from environment: `os.Getenv` or `viper` for complex config
|
|
54
|
+
- Graceful shutdown: `signal.NotifyContext` + `errgroup`
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Go Standard Library Patterns
|
|
2
|
+
|
|
3
|
+
<!-- SECTION: http-server -->
|
|
4
|
+
## HTTP Server Patterns
|
|
5
|
+
|
|
6
|
+
- Use `http.ServeMux` for simple routing, Gin/Fiber for complex APIs
|
|
7
|
+
- `http.Handler` interface: implement `ServeHTTP(w http.ResponseWriter, r *http.Request)`
|
|
8
|
+
- Middleware pattern: `func(next http.Handler) http.Handler`
|
|
9
|
+
- Context propagation: always pass `context.Context` through request chain
|
|
10
|
+
- Graceful shutdown: `server.Shutdown(ctx)` with signal handling
|
|
11
|
+
|
|
12
|
+
<!-- SECTION: concurrency -->
|
|
13
|
+
## Concurrency Patterns
|
|
14
|
+
|
|
15
|
+
- Goroutines for concurrent work, channels for communication
|
|
16
|
+
- `sync.WaitGroup` for waiting on multiple goroutines
|
|
17
|
+
- `sync.Mutex` / `sync.RWMutex` for shared state protection
|
|
18
|
+
- `context.Context` for cancellation and timeouts
|
|
19
|
+
- Worker pool pattern: buffered channel + N goroutines
|
|
20
|
+
- Fan-out/fan-in for parallel processing pipelines
|
|
21
|
+
- Never start a goroutine without knowing how it will stop
|
|
22
|
+
|
|
23
|
+
<!-- SECTION: error-handling -->
|
|
24
|
+
## Error Handling
|
|
25
|
+
|
|
26
|
+
- Errors are values — wrap with `fmt.Errorf("context: %w", err)`
|
|
27
|
+
- Custom error types implement `error` interface
|
|
28
|
+
- Use `errors.Is()` and `errors.As()` for error inspection
|
|
29
|
+
- Sentinel errors for expected conditions: `var ErrNotFound = errors.New("not found")`
|
|
30
|
+
- Never ignore errors — handle or propagate explicitly
|
|
31
|
+
|
|
32
|
+
<!-- SECTION: io -->
|
|
33
|
+
## I/O Patterns
|
|
34
|
+
|
|
35
|
+
- `io.Reader` / `io.Writer` interfaces for streaming
|
|
36
|
+
- `bufio` for buffered I/O
|
|
37
|
+
- `os.OpenFile` with explicit permissions
|
|
38
|
+
- `defer file.Close()` immediately after open
|
|
39
|
+
- `encoding/json` for JSON marshal/unmarshal with struct tags
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Go Testing Patterns
|
|
2
|
+
|
|
3
|
+
<!-- SECTION: unit-tests -->
|
|
4
|
+
## Unit Testing
|
|
5
|
+
|
|
6
|
+
- Test files: `*_test.go` in same package
|
|
7
|
+
- Test functions: `func TestXxx(t *testing.T)`
|
|
8
|
+
- Table-driven tests: slice of test cases with name, input, expected
|
|
9
|
+
- `t.Run(name, func(t *testing.T) { ... })` for subtests
|
|
10
|
+
- `t.Parallel()` for concurrent test execution
|
|
11
|
+
- `t.Helper()` in helper functions for correct line reporting
|
|
12
|
+
- `t.Cleanup(func())` for teardown
|
|
13
|
+
|
|
14
|
+
<!-- SECTION: mocking -->
|
|
15
|
+
## Mocking & Interfaces
|
|
16
|
+
|
|
17
|
+
- Define interfaces at the consumer, not the provider
|
|
18
|
+
- Mock by implementing the interface in test file
|
|
19
|
+
- `gomock` / `mockgen` for generated mocks
|
|
20
|
+
- `testify/mock` for assertion-style mocking
|
|
21
|
+
- Dependency injection via constructor: `func NewService(repo Repository) *Service`
|
|
22
|
+
|
|
23
|
+
<!-- SECTION: integration -->
|
|
24
|
+
## Integration Testing
|
|
25
|
+
|
|
26
|
+
- Build tags: `//go:build integration` to separate from unit tests
|
|
27
|
+
- `testcontainers-go` for database/service containers
|
|
28
|
+
- `httptest.NewServer` for HTTP integration tests
|
|
29
|
+
- `httptest.NewRecorder` for handler testing without server
|
|
30
|
+
- Setup/teardown with `TestMain(m *testing.M)`
|
|
31
|
+
|
|
32
|
+
<!-- SECTION: benchmarks -->
|
|
33
|
+
## Benchmarks & Fuzzing
|
|
34
|
+
|
|
35
|
+
- Benchmark functions: `func BenchmarkXxx(b *testing.B)` with `b.N` loop
|
|
36
|
+
- `b.ReportAllocs()` for allocation tracking
|
|
37
|
+
- Fuzz testing: `func FuzzXxx(f *testing.F)` with `f.Add()` seeds
|
|
38
|
+
- `go test -bench=. -benchmem` for memory profiling
|
|
39
|
+
- `go test -race` for race condition detection
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: JPA Entity and Repository Patterns
|
|
3
|
+
stack: java
|
|
4
|
+
version: "1.0"
|
|
5
|
+
focus: [jpa]
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# JPA Entity and Repository Patterns
|
|
9
|
+
|
|
10
|
+
## Principle
|
|
11
|
+
|
|
12
|
+
Map entities to the database with explicit fetch strategies and avoid the N+1 query problem. Use Spring Data JPA repositories for standard CRUD, custom queries for complex operations, and projections for read-only data. Always define fetch types explicitly and prefer `FetchType.LAZY` as the default.
|
|
13
|
+
|
|
14
|
+
## Rationale
|
|
15
|
+
|
|
16
|
+
JPA's default fetch strategy for `@ManyToOne` is `EAGER`, which loads related entities immediately and causes cascading queries. The N+1 problem occurs when iterating a collection triggers one query per element. Explicit `LAZY` fetching, combined with `JOIN FETCH` in queries where related data is needed, gives precise control over SQL execution. Projections (interfaces or DTOs) avoid loading full entity graphs for read-only use cases.
|
|
17
|
+
|
|
18
|
+
## Pattern Examples
|
|
19
|
+
|
|
20
|
+
### Pattern 1: Entity with Explicit Fetch Strategies
|
|
21
|
+
|
|
22
|
+
```java
|
|
23
|
+
@Entity
|
|
24
|
+
@Table(name = "orders")
|
|
25
|
+
public class Order {
|
|
26
|
+
|
|
27
|
+
@Id
|
|
28
|
+
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
29
|
+
private Long id;
|
|
30
|
+
|
|
31
|
+
@Column(nullable = false)
|
|
32
|
+
private LocalDateTime createdAt;
|
|
33
|
+
|
|
34
|
+
@Enumerated(EnumType.STRING)
|
|
35
|
+
private OrderStatus status;
|
|
36
|
+
|
|
37
|
+
// Explicit LAZY — loaded only when accessed or JOIN FETCHed
|
|
38
|
+
@ManyToOne(fetch = FetchType.LAZY)
|
|
39
|
+
@JoinColumn(name = "customer_id", nullable = false)
|
|
40
|
+
private Customer customer;
|
|
41
|
+
|
|
42
|
+
@OneToMany(mappedBy = "order", cascade = CascadeType.ALL, orphanRemoval = true)
|
|
43
|
+
private List<OrderItem> items = new ArrayList<>();
|
|
44
|
+
|
|
45
|
+
// Helper method maintains bidirectional consistency
|
|
46
|
+
public void addItem(OrderItem item) {
|
|
47
|
+
items.add(item);
|
|
48
|
+
item.setOrder(this);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public void removeItem(OrderItem item) {
|
|
52
|
+
items.remove(item);
|
|
53
|
+
item.setOrder(null);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Pattern 2: Solving N+1 with JOIN FETCH
|
|
59
|
+
|
|
60
|
+
```java
|
|
61
|
+
public interface OrderRepository extends JpaRepository<Order, Long> {
|
|
62
|
+
|
|
63
|
+
// BAD: triggers N+1 when accessing order.customer for each order
|
|
64
|
+
// List<Order> findByStatus(OrderStatus status);
|
|
65
|
+
|
|
66
|
+
// GOOD: JOIN FETCH loads customers in one query
|
|
67
|
+
@Query("""
|
|
68
|
+
SELECT o FROM Order o
|
|
69
|
+
JOIN FETCH o.customer
|
|
70
|
+
WHERE o.status = :status
|
|
71
|
+
""")
|
|
72
|
+
List<Order> findByStatusWithCustomer(@Param("status") OrderStatus status);
|
|
73
|
+
|
|
74
|
+
// Pagination with JOIN FETCH requires a count query
|
|
75
|
+
@Query(value = """
|
|
76
|
+
SELECT o FROM Order o
|
|
77
|
+
JOIN FETCH o.customer
|
|
78
|
+
WHERE o.status = :status
|
|
79
|
+
""",
|
|
80
|
+
countQuery = "SELECT COUNT(o) FROM Order o WHERE o.status = :status")
|
|
81
|
+
Page<Order> findByStatusWithCustomerPaged(
|
|
82
|
+
@Param("status") OrderStatus status, Pageable pageable);
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Pattern 3: DTO Projections for Read-Only Queries
|
|
87
|
+
|
|
88
|
+
```java
|
|
89
|
+
// Interface-based projection — JPA generates implementation
|
|
90
|
+
public interface OrderSummary {
|
|
91
|
+
Long getId();
|
|
92
|
+
LocalDateTime getCreatedAt();
|
|
93
|
+
OrderStatus getStatus();
|
|
94
|
+
String getCustomerName(); // derived from JOIN
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
public interface OrderRepository extends JpaRepository<Order, Long> {
|
|
98
|
+
|
|
99
|
+
// Returns lightweight projections, not full entities
|
|
100
|
+
@Query("""
|
|
101
|
+
SELECT o.id AS id,
|
|
102
|
+
o.createdAt AS createdAt,
|
|
103
|
+
o.status AS status,
|
|
104
|
+
c.name AS customerName
|
|
105
|
+
FROM Order o JOIN o.customer c
|
|
106
|
+
WHERE o.createdAt >= :since
|
|
107
|
+
""")
|
|
108
|
+
List<OrderSummary> findRecentOrderSummaries(
|
|
109
|
+
@Param("since") LocalDateTime since);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Record-based DTO projection (alternative)
|
|
113
|
+
public record OrderDto(Long id, String customerName, BigDecimal total) {}
|
|
114
|
+
|
|
115
|
+
@Query("""
|
|
116
|
+
SELECT new com.example.dto.OrderDto(o.id, c.name, o.total)
|
|
117
|
+
FROM Order o JOIN o.customer c
|
|
118
|
+
WHERE o.status = :status
|
|
119
|
+
""")
|
|
120
|
+
List<OrderDto> findOrderDtos(@Param("status") OrderStatus status);
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Anti-Patterns
|
|
124
|
+
|
|
125
|
+
- **Implicit EAGER fetching**: `@ManyToOne` defaults to `EAGER`. Always set `fetch = FetchType.LAZY`.
|
|
126
|
+
- **SELECT in a loop**: Iterating a list and calling `repository.findById()` per item. Use `findAllById()` or a batch query.
|
|
127
|
+
- **Returning entities from REST controllers**: Exposes internal structure, causes serialization issues with lazy proxies. Map to DTOs.
|
|
128
|
+
- **Missing `orphanRemoval`**: Without `orphanRemoval = true` on `@OneToMany`, removed children stay in the database.
|
|
129
|
+
- **`CascadeType.ALL` on `@ManyToOne`**: Cascading from child to parent can delete the parent when a child is removed.
|
|
130
|
+
|
|
131
|
+
## Integration Points
|
|
132
|
+
|
|
133
|
+
- **Spring Boot**: JPA auto-configuration sets up `EntityManager` and transaction management; see `spring-boot-patterns.md`.
|
|
134
|
+
- **Microservices**: Each service owns its database and entities; see `microservices.md` for bounded context.
|
|
135
|
+
- **Build Tools**: JPA metamodel generation requires annotation processing in Maven/Gradle; see `maven-gradle.md`.
|
|
136
|
+
- **Testing**: Use `@DataJpaTest` for repository tests with an in-memory database.
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Maven and Gradle Build Patterns
|
|
3
|
+
stack: java
|
|
4
|
+
version: "1.0"
|
|
5
|
+
focus: [build-tools]
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Maven and Gradle Build Patterns
|
|
9
|
+
|
|
10
|
+
## Principle
|
|
11
|
+
|
|
12
|
+
Use multi-module builds to organize large projects with shared dependencies managed through a BOM (Bill of Materials) or parent POM. Keep build scripts declarative, version-lock all dependencies, and use plugins for code generation, testing, and packaging. Choose Maven for convention-heavy projects and Gradle for performance-critical or highly customized builds.
|
|
13
|
+
|
|
14
|
+
## Rationale
|
|
15
|
+
|
|
16
|
+
Build tool consistency prevents "works on my machine" issues. A parent POM or BOM centralizes dependency versions so all modules use the same library versions, eliminating conflicts. Multi-module builds enable code reuse (shared DTOs, utilities) while maintaining independent compilation. Plugin management ensures consistent code quality (Checkstyle, SpotBugs) and packaging (Spring Boot fat JARs, Docker images).
|
|
17
|
+
|
|
18
|
+
## Pattern Examples
|
|
19
|
+
|
|
20
|
+
### Pattern 1: Maven Multi-Module with BOM
|
|
21
|
+
|
|
22
|
+
```xml
|
|
23
|
+
<!-- parent pom.xml -->
|
|
24
|
+
<project>
|
|
25
|
+
<groupId>com.example</groupId>
|
|
26
|
+
<artifactId>platform-parent</artifactId>
|
|
27
|
+
<version>1.0.0</version>
|
|
28
|
+
<packaging>pom</packaging>
|
|
29
|
+
|
|
30
|
+
<modules>
|
|
31
|
+
<module>common</module>
|
|
32
|
+
<module>user-service</module>
|
|
33
|
+
<module>order-service</module>
|
|
34
|
+
</modules>
|
|
35
|
+
|
|
36
|
+
<properties>
|
|
37
|
+
<java.version>21</java.version>
|
|
38
|
+
<spring-boot.version>3.3.0</spring-boot.version>
|
|
39
|
+
<mapstruct.version>1.5.5.Final</mapstruct.version>
|
|
40
|
+
</properties>
|
|
41
|
+
|
|
42
|
+
<dependencyManagement>
|
|
43
|
+
<dependencies>
|
|
44
|
+
<dependency>
|
|
45
|
+
<groupId>org.springframework.boot</groupId>
|
|
46
|
+
<artifactId>spring-boot-dependencies</artifactId>
|
|
47
|
+
<version>${spring-boot.version}</version>
|
|
48
|
+
<type>pom</type>
|
|
49
|
+
<scope>import</scope>
|
|
50
|
+
</dependency>
|
|
51
|
+
<dependency>
|
|
52
|
+
<groupId>com.example</groupId>
|
|
53
|
+
<artifactId>common</artifactId>
|
|
54
|
+
<version>${project.version}</version>
|
|
55
|
+
</dependency>
|
|
56
|
+
</dependencies>
|
|
57
|
+
</dependencyManagement>
|
|
58
|
+
</project>
|
|
59
|
+
|
|
60
|
+
<!-- user-service/pom.xml -->
|
|
61
|
+
<project>
|
|
62
|
+
<parent>
|
|
63
|
+
<groupId>com.example</groupId>
|
|
64
|
+
<artifactId>platform-parent</artifactId>
|
|
65
|
+
<version>1.0.0</version>
|
|
66
|
+
</parent>
|
|
67
|
+
<artifactId>user-service</artifactId>
|
|
68
|
+
|
|
69
|
+
<dependencies>
|
|
70
|
+
<dependency>
|
|
71
|
+
<groupId>com.example</groupId>
|
|
72
|
+
<artifactId>common</artifactId>
|
|
73
|
+
<!-- version inherited from parent -->
|
|
74
|
+
</dependency>
|
|
75
|
+
<dependency>
|
|
76
|
+
<groupId>org.springframework.boot</groupId>
|
|
77
|
+
<artifactId>spring-boot-starter-web</artifactId>
|
|
78
|
+
</dependency>
|
|
79
|
+
</dependencies>
|
|
80
|
+
</project>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Pattern 2: Gradle Kotlin DSL with Version Catalog
|
|
84
|
+
|
|
85
|
+
```kotlin
|
|
86
|
+
// gradle/libs.versions.toml — centralized version catalog
|
|
87
|
+
// [versions]
|
|
88
|
+
// spring-boot = "3.3.0"
|
|
89
|
+
// mapstruct = "1.5.5.Final"
|
|
90
|
+
// [libraries]
|
|
91
|
+
// spring-boot-web = { module = "org.springframework.boot:spring-boot-starter-web" }
|
|
92
|
+
// spring-boot-test = { module = "org.springframework.boot:spring-boot-starter-test" }
|
|
93
|
+
// mapstruct = { module = "org.mapstruct:mapstruct", version.ref = "mapstruct" }
|
|
94
|
+
|
|
95
|
+
// build.gradle.kts (root)
|
|
96
|
+
plugins {
|
|
97
|
+
java
|
|
98
|
+
id("org.springframework.boot") version libs.versions.spring.boot apply false
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
subprojects {
|
|
102
|
+
apply(plugin = "java")
|
|
103
|
+
|
|
104
|
+
java {
|
|
105
|
+
sourceCompatibility = JavaVersion.VERSION_21
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
repositories {
|
|
109
|
+
mavenCentral()
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
tasks.withType<Test> {
|
|
113
|
+
useJUnitPlatform()
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// user-service/build.gradle.kts
|
|
118
|
+
plugins {
|
|
119
|
+
id("org.springframework.boot")
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
dependencies {
|
|
123
|
+
implementation(project(":common"))
|
|
124
|
+
implementation(libs.spring.boot.web)
|
|
125
|
+
implementation(libs.mapstruct)
|
|
126
|
+
testImplementation(libs.spring.boot.test)
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Pattern 3: Plugin Configuration for Quality
|
|
131
|
+
|
|
132
|
+
```xml
|
|
133
|
+
<!-- Maven plugin management in parent POM -->
|
|
134
|
+
<build>
|
|
135
|
+
<pluginManagement>
|
|
136
|
+
<plugins>
|
|
137
|
+
<plugin>
|
|
138
|
+
<groupId>org.apache.maven.plugins</groupId>
|
|
139
|
+
<artifactId>maven-compiler-plugin</artifactId>
|
|
140
|
+
<version>3.12.1</version>
|
|
141
|
+
<configuration>
|
|
142
|
+
<release>${java.version}</release>
|
|
143
|
+
<annotationProcessorPaths>
|
|
144
|
+
<path>
|
|
145
|
+
<groupId>org.mapstruct</groupId>
|
|
146
|
+
<artifactId>mapstruct-processor</artifactId>
|
|
147
|
+
<version>${mapstruct.version}</version>
|
|
148
|
+
</path>
|
|
149
|
+
<path>
|
|
150
|
+
<groupId>org.projectlombok</groupId>
|
|
151
|
+
<artifactId>lombok</artifactId>
|
|
152
|
+
<version>${lombok.version}</version>
|
|
153
|
+
</path>
|
|
154
|
+
</annotationProcessorPaths>
|
|
155
|
+
</configuration>
|
|
156
|
+
</plugin>
|
|
157
|
+
<plugin>
|
|
158
|
+
<groupId>org.jacoco</groupId>
|
|
159
|
+
<artifactId>jacoco-maven-plugin</artifactId>
|
|
160
|
+
<version>0.8.11</version>
|
|
161
|
+
<executions>
|
|
162
|
+
<execution>
|
|
163
|
+
<goals><goal>prepare-agent</goal></goals>
|
|
164
|
+
</execution>
|
|
165
|
+
<execution>
|
|
166
|
+
<id>report</id>
|
|
167
|
+
<phase>verify</phase>
|
|
168
|
+
<goals><goal>report</goal></goals>
|
|
169
|
+
</execution>
|
|
170
|
+
</executions>
|
|
171
|
+
</plugin>
|
|
172
|
+
</plugins>
|
|
173
|
+
</pluginManagement>
|
|
174
|
+
</build>
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Anti-Patterns
|
|
178
|
+
|
|
179
|
+
- **Unmanaged dependency versions**: Declaring versions in each module instead of the parent/BOM. Leads to version conflicts.
|
|
180
|
+
- **Fat parent POM with all dependencies**: Declaring dependencies (not just `dependencyManagement`) in the parent forces all modules to inherit them.
|
|
181
|
+
- **Skipping tests in CI**: `mvn install -DskipTests` hides regressions. Only skip in local exploratory builds.
|
|
182
|
+
- **Build logic in scripts outside the build tool**: Wrapping Maven/Gradle in shell scripts that duplicate what plugins provide.
|
|
183
|
+
|
|
184
|
+
## Integration Points
|
|
185
|
+
|
|
186
|
+
- **Spring Boot**: Spring Boot Maven/Gradle plugin handles fat JAR packaging and dev-tools; see `spring-boot-patterns.md`.
|
|
187
|
+
- **JPA**: Annotation processing (Hibernate metamodel, MapStruct) configured in compiler plugin; see `jpa-patterns.md`.
|
|
188
|
+
- **Microservices**: Multi-module layout maps to service boundaries; see `microservices.md`.
|
|
189
|
+
- **CI/CD**: Build tool commands (`mvn verify`, `gradle build`) are the CI pipeline entry point.
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Microservices Patterns
|
|
3
|
+
stack: java
|
|
4
|
+
version: "1.0"
|
|
5
|
+
focus: [microservices]
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Microservices Patterns
|
|
9
|
+
|
|
10
|
+
## Principle
|
|
11
|
+
|
|
12
|
+
Decompose systems along bounded context boundaries. Each service owns its data, communicates via well-defined APIs (sync) or events (async), and is independently deployable. Use circuit breakers for resilience, saga pattern for distributed transactions, and service discovery for dynamic routing.
|
|
13
|
+
|
|
14
|
+
## Rationale
|
|
15
|
+
|
|
16
|
+
Microservices enable independent scaling, deployment, and technology choices per bounded context. However, distributed systems introduce network failures, data consistency challenges, and operational complexity. Circuit breakers prevent cascading failures by failing fast when a downstream service is unhealthy. The saga pattern replaces distributed transactions with a sequence of local transactions and compensating actions. Service discovery eliminates hard-coded URLs.
|
|
17
|
+
|
|
18
|
+
## Pattern Examples
|
|
19
|
+
|
|
20
|
+
### Pattern 1: Circuit Breaker with Resilience4j
|
|
21
|
+
|
|
22
|
+
```java
|
|
23
|
+
@Service
|
|
24
|
+
@RequiredArgsConstructor
|
|
25
|
+
public class PaymentService {
|
|
26
|
+
|
|
27
|
+
private final PaymentClient paymentClient;
|
|
28
|
+
|
|
29
|
+
@CircuitBreaker(name = "payment", fallbackMethod = "paymentFallback")
|
|
30
|
+
@TimeLimiter(name = "payment")
|
|
31
|
+
@Retry(name = "payment")
|
|
32
|
+
public CompletableFuture<PaymentResult> processPayment(PaymentRequest request) {
|
|
33
|
+
return CompletableFuture.supplyAsync(
|
|
34
|
+
() -> paymentClient.charge(request)
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
private CompletableFuture<PaymentResult> paymentFallback(
|
|
39
|
+
PaymentRequest request, Throwable ex) {
|
|
40
|
+
log.warn("Payment service unavailable, queuing: {}", ex.getMessage());
|
|
41
|
+
return CompletableFuture.completedFuture(
|
|
42
|
+
PaymentResult.queued(request.orderId())
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// application.yml
|
|
48
|
+
// resilience4j:
|
|
49
|
+
// circuitbreaker:
|
|
50
|
+
// instances:
|
|
51
|
+
// payment:
|
|
52
|
+
// sliding-window-size: 10
|
|
53
|
+
// failure-rate-threshold: 50
|
|
54
|
+
// wait-duration-in-open-state: 30s
|
|
55
|
+
// retry:
|
|
56
|
+
// instances:
|
|
57
|
+
// payment:
|
|
58
|
+
// max-attempts: 3
|
|
59
|
+
// wait-duration: 500ms
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Pattern 2: Saga Pattern (Orchestration)
|
|
63
|
+
|
|
64
|
+
```java
|
|
65
|
+
// Saga orchestrator — coordinates local transactions across services
|
|
66
|
+
@Service
|
|
67
|
+
@RequiredArgsConstructor
|
|
68
|
+
public class OrderSagaOrchestrator {
|
|
69
|
+
|
|
70
|
+
private final OrderService orderService;
|
|
71
|
+
private final InventoryClient inventoryClient;
|
|
72
|
+
private final PaymentClient paymentClient;
|
|
73
|
+
|
|
74
|
+
@Transactional
|
|
75
|
+
public OrderResult createOrder(CreateOrderCommand cmd) {
|
|
76
|
+
// Step 1: Create order (local transaction)
|
|
77
|
+
var order = orderService.create(cmd);
|
|
78
|
+
|
|
79
|
+
try {
|
|
80
|
+
// Step 2: Reserve inventory (remote call)
|
|
81
|
+
inventoryClient.reserve(order.getId(), cmd.items());
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
// Step 3: Process payment (remote call)
|
|
85
|
+
paymentClient.charge(order.getId(), cmd.total());
|
|
86
|
+
orderService.confirm(order.getId());
|
|
87
|
+
return OrderResult.success(order);
|
|
88
|
+
|
|
89
|
+
} catch (PaymentException e) {
|
|
90
|
+
// Compensate Step 2
|
|
91
|
+
inventoryClient.release(order.getId());
|
|
92
|
+
orderService.cancel(order.getId(), "Payment failed");
|
|
93
|
+
return OrderResult.failed(order, e.getMessage());
|
|
94
|
+
}
|
|
95
|
+
} catch (InventoryException e) {
|
|
96
|
+
// Compensate Step 1
|
|
97
|
+
orderService.cancel(order.getId(), "Insufficient inventory");
|
|
98
|
+
return OrderResult.failed(order, e.getMessage());
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Pattern 3: Event-Driven Communication
|
|
105
|
+
|
|
106
|
+
```java
|
|
107
|
+
// Publishing domain events
|
|
108
|
+
@Service
|
|
109
|
+
@RequiredArgsConstructor
|
|
110
|
+
public class OrderService {
|
|
111
|
+
|
|
112
|
+
private final OrderRepository orderRepository;
|
|
113
|
+
private final ApplicationEventPublisher eventPublisher;
|
|
114
|
+
|
|
115
|
+
@Transactional
|
|
116
|
+
public Order confirm(Long orderId) {
|
|
117
|
+
var order = orderRepository.findById(orderId)
|
|
118
|
+
.orElseThrow(() -> new OrderNotFoundException(orderId));
|
|
119
|
+
order.setStatus(OrderStatus.CONFIRMED);
|
|
120
|
+
var saved = orderRepository.save(order);
|
|
121
|
+
|
|
122
|
+
// Publish event — listeners can be in-process or forward to Kafka
|
|
123
|
+
eventPublisher.publishEvent(new OrderConfirmedEvent(
|
|
124
|
+
saved.getId(), saved.getCustomerId(), saved.getTotal()
|
|
125
|
+
));
|
|
126
|
+
return saved;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Event listener — async processing
|
|
131
|
+
@Component
|
|
132
|
+
@RequiredArgsConstructor
|
|
133
|
+
public class NotificationListener {
|
|
134
|
+
|
|
135
|
+
private final NotificationService notificationService;
|
|
136
|
+
|
|
137
|
+
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
|
|
138
|
+
@Async
|
|
139
|
+
public void onOrderConfirmed(OrderConfirmedEvent event) {
|
|
140
|
+
notificationService.sendOrderConfirmation(
|
|
141
|
+
event.customerId(), event.orderId()
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Anti-Patterns
|
|
148
|
+
|
|
149
|
+
- **Distributed monolith**: Splitting a monolith into services that still share a database or require synchronous calls for every operation.
|
|
150
|
+
- **Two-phase commit across services**: Distributed transactions do not scale. Use sagas with compensating actions instead.
|
|
151
|
+
- **Chatty inter-service calls**: Multiple fine-grained synchronous calls per request. Batch calls or use async events.
|
|
152
|
+
- **Shared domain models**: Services sharing entity JARs creates tight coupling. Each service defines its own models.
|
|
153
|
+
|
|
154
|
+
## Integration Points
|
|
155
|
+
|
|
156
|
+
- **Spring Boot**: Each microservice is a Spring Boot application; see `spring-boot-patterns.md`.
|
|
157
|
+
- **JPA**: Each service owns its database schema; see `jpa-patterns.md` for per-service data modeling.
|
|
158
|
+
- **Build Tools**: Multi-module Maven/Gradle builds manage microservice projects; see `maven-gradle.md`.
|
|
159
|
+
- **Docker**: Services are containerized for deployment; integrate with Docker Compose or Kubernetes.
|