hatch3r 1.9.0 → 2.0.0
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/README.md +52 -143
- package/dist/cli/index.js +28453 -15831
- package/dist/content/agents/hatch3r-architect.md +39 -9
- package/dist/content/agents/hatch3r-brownfield-spec.md +254 -0
- package/dist/content/agents/hatch3r-ci-watcher.md +8 -1
- package/dist/content/agents/hatch3r-context-rules.md +19 -1
- package/dist/content/agents/hatch3r-creator.md +65 -26
- package/dist/content/agents/hatch3r-dependency-drafter.md +162 -0
- package/dist/content/agents/hatch3r-devops.md +11 -1
- package/dist/content/agents/hatch3r-docs-writer.md +11 -1
- package/dist/content/agents/hatch3r-edge-case-analyst.md +134 -0
- package/dist/content/agents/hatch3r-enhancability.md +192 -0
- package/dist/content/agents/hatch3r-fixer.md +59 -8
- package/dist/content/agents/hatch3r-greenfield-spec.md +256 -0
- package/dist/content/agents/hatch3r-handoff-loader.md +29 -3
- package/dist/content/agents/hatch3r-handoff-preparer.md +10 -1
- package/dist/content/agents/hatch3r-implementer.md +139 -8
- package/dist/content/agents/hatch3r-incident-responder.md +96 -0
- package/dist/content/agents/hatch3r-learnings-loader.md +122 -88
- package/dist/content/agents/hatch3r-lint-fixer.md +15 -3
- package/dist/content/agents/hatch3r-maintainability.md +183 -0
- package/dist/content/agents/hatch3r-pack-installer.md +113 -0
- package/dist/content/agents/hatch3r-performance.md +179 -0
- package/dist/content/agents/hatch3r-reliability.md +193 -0
- package/dist/content/agents/hatch3r-researcher.md +27 -4
- package/dist/content/agents/hatch3r-reviewer.md +153 -103
- package/dist/content/agents/hatch3r-scalability.md +162 -0
- package/dist/content/agents/hatch3r-security.md +197 -0
- package/dist/content/agents/hatch3r-testability.md +204 -0
- package/dist/content/agents/hatch3r-ui.md +175 -0
- package/dist/content/agents/hatch3r-ux.md +160 -0
- package/dist/content/agents/modes/requirements-elicitation.md +1 -1
- package/dist/content/agents/modes/user-flows.md +2 -2
- package/dist/content/agents/shared/clarification-default-block.md +44 -0
- package/dist/content/agents/shared/confidence-gate.md +42 -0
- package/dist/content/agents/shared/cq-specialist-roster.md +26 -0
- package/dist/content/agents/shared/efficiency-patterns.md +32 -1
- package/dist/content/agents/shared/injection-patterns.md +18 -7
- package/dist/content/agents/shared/principles.md +60 -0
- package/dist/content/agents/shared/prompt-structure.md +7 -1
- package/dist/content/agents/shared/quality-charter.md +48 -12
- package/dist/content/agents/shared/quality-specialist-frame.md +141 -0
- package/dist/content/agents/shared/rigor-contract.md +151 -0
- package/dist/content/agents/shared/severity-mapping.md +92 -0
- package/dist/content/agents/shared/triage-vocabulary.md +46 -0
- package/dist/content/agents/shared/user-content-templates.md +34 -8
- package/dist/content/agents/shared/user-question-protocol.md +45 -3
- package/dist/content/checks/README.md +5 -0
- package/dist/content/checks/accessibility.md +14 -7
- package/dist/content/checks/code-quality.md +1 -1
- package/dist/content/checks/performance.md +7 -4
- package/dist/content/checks/security.md +6 -6
- package/dist/content/checks/testing.md +1 -1
- package/dist/content/commands/board/pickup-delegation-multi.md +37 -10
- package/dist/content/commands/board/pickup-delegation.md +7 -5
- package/dist/content/commands/board/pickup-modes.md +1 -0
- package/dist/content/commands/board/pickup-post-impl.md +1 -1
- package/dist/content/commands/hatch3r-api-spec.md +79 -2
- package/dist/content/commands/hatch3r-auth-scaffold.md +250 -0
- package/dist/content/commands/hatch3r-benchmark.md +90 -7
- package/dist/content/commands/hatch3r-board-fill.md +97 -11
- package/dist/content/commands/hatch3r-board-pickup.md +93 -9
- package/dist/content/commands/hatch3r-bug-pipeline.md +240 -0
- package/dist/content/commands/hatch3r-bug-plan.md +79 -3
- package/dist/content/commands/hatch3r-codebase-map.md +80 -4
- package/dist/content/commands/hatch3r-create.md +105 -7
- package/dist/content/commands/hatch3r-debug.md +102 -14
- package/dist/content/commands/hatch3r-diagnose.md +238 -0
- package/dist/content/commands/hatch3r-feature-plan.md +125 -5
- package/dist/content/commands/hatch3r-handoff.md +83 -3
- package/dist/content/commands/hatch3r-healthcheck.md +105 -5
- package/dist/content/commands/hatch3r-incident-response.md +228 -0
- package/dist/content/commands/hatch3r-migration-plan.md +79 -3
- package/dist/content/commands/hatch3r-onboard.md +94 -3
- package/dist/content/commands/hatch3r-pack-install.md +243 -0
- package/dist/content/commands/hatch3r-pr-resolve.md +106 -23
- package/dist/content/commands/hatch3r-project-spec.md +82 -6
- package/dist/content/commands/hatch3r-quick-change.md +108 -13
- package/dist/content/commands/hatch3r-refactor-plan.md +78 -2
- package/dist/content/commands/hatch3r-release.md +401 -0
- package/dist/content/commands/hatch3r-revision.md +98 -12
- package/dist/content/commands/hatch3r-roadmap.md +92 -10
- package/dist/content/commands/hatch3r-security-audit.md +105 -5
- package/dist/content/commands/hatch3r-slo-scaffold.md +246 -0
- package/dist/content/commands/hatch3r-spec.md +216 -0
- package/dist/content/commands/hatch3r-test-plan.md +85 -9
- package/dist/content/commands/hatch3r-workflow.md +165 -41
- package/dist/content/commands/revision/revision-delegation.md +6 -5
- package/dist/content/commands/revision/revision-modes.md +49 -4
- package/dist/content/commands/revision/revision-quality.md +10 -7
- package/dist/content/commands/shared/orchestration-frame.md +119 -0
- package/dist/content/github-agents/hatch3r-docs-agent.md +21 -1
- package/dist/content/github-agents/hatch3r-lint-agent.md +21 -1
- package/dist/content/github-agents/hatch3r-security-agent.md +21 -1
- package/dist/content/github-agents/hatch3r-test-agent.md +21 -1
- package/dist/content/hooks/hatch3r-file-save.md +1 -1
- package/dist/content/hooks/hatch3r-pre-push.md +4 -4
- package/dist/content/hooks/hatch3r-review-loop-cap.md +52 -0
- package/dist/content/mcp/mcp.json +7 -5
- package/dist/content/rules/hatch3r-accessibility-standards.md +14 -2
- package/dist/content/rules/hatch3r-accessibility-standards.mdc +12 -1
- package/dist/content/rules/hatch3r-agent-orchestration-detail.md +58 -19
- package/dist/content/rules/hatch3r-agent-orchestration-detail.mdc +58 -19
- package/dist/content/rules/hatch3r-agent-orchestration.md +87 -213
- package/dist/content/rules/hatch3r-agent-orchestration.mdc +87 -213
- package/dist/content/rules/hatch3r-ai-evals.md +5 -4
- package/dist/content/rules/hatch3r-ai-evals.mdc +3 -3
- package/dist/content/rules/hatch3r-ai-ux-patterns.md +6 -2
- package/dist/content/rules/hatch3r-ai-ux-patterns.mdc +4 -1
- package/dist/content/rules/hatch3r-android-patterns.md +107 -0
- package/dist/content/rules/hatch3r-android-patterns.mdc +102 -0
- package/dist/content/rules/hatch3r-anti-duplication.md +115 -0
- package/dist/content/rules/hatch3r-anti-duplication.mdc +115 -0
- package/dist/content/rules/hatch3r-api-design.md +5 -1
- package/dist/content/rules/hatch3r-api-design.mdc +3 -0
- package/dist/content/rules/hatch3r-api-versioning.md +2 -1
- package/dist/content/rules/hatch3r-auth-patterns.md +3 -1
- package/dist/content/rules/hatch3r-auth-patterns.mdc +1 -0
- package/dist/content/rules/hatch3r-browser-verification.md +2 -0
- package/dist/content/rules/hatch3r-browser-verification.mdc +2 -0
- package/dist/content/rules/hatch3r-capability-matrix.md +108 -0
- package/dist/content/rules/hatch3r-capability-matrix.mdc +108 -0
- package/dist/content/rules/hatch3r-ci-cd.md +8 -1
- package/dist/content/rules/hatch3r-ci-cd.mdc +6 -0
- package/dist/content/rules/hatch3r-clarification-default.md +73 -0
- package/dist/content/rules/hatch3r-clarification-default.mdc +73 -0
- package/dist/content/rules/hatch3r-code-standards.md +23 -47
- package/dist/content/rules/hatch3r-code-standards.mdc +22 -46
- package/dist/content/rules/hatch3r-component-conventions.md +3 -0
- package/dist/content/rules/hatch3r-component-conventions.mdc +3 -0
- package/dist/content/rules/hatch3r-container-hardening.md +11 -2
- package/dist/content/rules/hatch3r-container-hardening.mdc +9 -1
- package/dist/content/rules/hatch3r-contract-testing.md +2 -1
- package/dist/content/rules/hatch3r-cost-visibility.md +135 -0
- package/dist/content/rules/hatch3r-cost-visibility.mdc +135 -0
- package/dist/content/rules/hatch3r-cq-rule-frame.md +54 -0
- package/dist/content/rules/hatch3r-cq-rule-frame.mdc +49 -0
- package/dist/content/rules/hatch3r-data-classification.md +3 -1
- package/dist/content/rules/hatch3r-data-classification.mdc +2 -1
- package/dist/content/rules/hatch3r-deep-context.md +13 -13
- package/dist/content/rules/hatch3r-deep-context.mdc +13 -13
- package/dist/content/rules/hatch3r-dependency-management.md +16 -3
- package/dist/content/rules/hatch3r-dependency-management.mdc +15 -3
- package/dist/content/rules/hatch3r-design-system-detection.md +2 -1
- package/dist/content/rules/hatch3r-dotnet-patterns.md +104 -0
- package/dist/content/rules/hatch3r-dotnet-patterns.mdc +99 -0
- package/dist/content/rules/hatch3r-edge-case-discipline.md +65 -0
- package/dist/content/rules/hatch3r-edge-case-discipline.mdc +65 -0
- package/dist/content/rules/hatch3r-enhancability.md +147 -0
- package/dist/content/rules/hatch3r-enhancability.mdc +142 -0
- package/dist/content/rules/hatch3r-event-schema-evolution.md +2 -1
- package/dist/content/rules/hatch3r-fan-out-discipline.md +91 -0
- package/dist/content/rules/hatch3r-fan-out-discipline.mdc +91 -0
- package/dist/content/rules/hatch3r-feature-flags.md +2 -0
- package/dist/content/rules/hatch3r-feature-flags.mdc +2 -0
- package/dist/content/rules/hatch3r-flutter-patterns.md +88 -0
- package/dist/content/rules/hatch3r-flutter-patterns.mdc +83 -0
- package/dist/content/rules/hatch3r-git-conventions.md +4 -1
- package/dist/content/rules/hatch3r-git-conventions.mdc +2 -0
- package/dist/content/rules/hatch3r-go-patterns.md +98 -0
- package/dist/content/rules/hatch3r-go-patterns.mdc +93 -0
- package/dist/content/rules/hatch3r-handoff-readiness.md +10 -0
- package/dist/content/rules/hatch3r-handoff-readiness.mdc +10 -0
- package/dist/content/rules/hatch3r-i18n.md +2 -0
- package/dist/content/rules/hatch3r-i18n.mdc +2 -0
- package/dist/content/rules/hatch3r-iteration-summary.md +75 -57
- package/dist/content/rules/hatch3r-iteration-summary.mdc +77 -54
- package/dist/content/rules/hatch3r-learning-system.md +202 -0
- package/dist/content/rules/hatch3r-learning-system.mdc +202 -0
- package/dist/content/rules/hatch3r-maintainability.md +157 -0
- package/dist/content/rules/hatch3r-maintainability.mdc +152 -0
- package/dist/content/rules/hatch3r-migrations.md +2 -1
- package/dist/content/rules/hatch3r-observability-logging.md +1 -1
- package/dist/content/rules/hatch3r-observability-metrics.md +1 -1
- package/dist/content/rules/hatch3r-observability-tracing.md +45 -36
- package/dist/content/rules/hatch3r-observability-tracing.mdc +44 -35
- package/dist/content/rules/hatch3r-operability.md +2 -1
- package/dist/content/rules/hatch3r-passkey-server.md +2 -1
- package/dist/content/rules/hatch3r-performance-budgets.md +2 -0
- package/dist/content/rules/hatch3r-performance-budgets.mdc +2 -0
- package/dist/content/rules/hatch3r-php-laravel-patterns.md +109 -0
- package/dist/content/rules/hatch3r-php-laravel-patterns.mdc +104 -0
- package/dist/content/rules/hatch3r-progressive-delivery.md +5 -1
- package/dist/content/rules/hatch3r-progressive-delivery.mdc +3 -0
- package/dist/content/rules/hatch3r-proof-model.md +131 -0
- package/dist/content/rules/hatch3r-proof-model.mdc +131 -0
- package/dist/content/rules/hatch3r-python-patterns.md +70 -0
- package/dist/content/rules/hatch3r-python-patterns.mdc +65 -0
- package/dist/content/rules/hatch3r-react-native-patterns.md +83 -0
- package/dist/content/rules/hatch3r-react-native-patterns.mdc +78 -0
- package/dist/content/rules/hatch3r-resilience-patterns.md +2 -1
- package/dist/content/rules/hatch3r-reviewer-calibration.md +84 -0
- package/dist/content/rules/hatch3r-reviewer-calibration.mdc +84 -0
- package/dist/content/rules/hatch3r-right-sizing.md +68 -0
- package/dist/content/rules/hatch3r-right-sizing.mdc +66 -0
- package/dist/content/rules/hatch3r-ruby-rails-patterns.md +111 -0
- package/dist/content/rules/hatch3r-ruby-rails-patterns.mdc +106 -0
- package/dist/content/rules/hatch3r-rust-patterns.md +107 -0
- package/dist/content/rules/hatch3r-rust-patterns.mdc +102 -0
- package/dist/content/rules/hatch3r-scalability.md +137 -0
- package/dist/content/rules/hatch3r-scalability.mdc +132 -0
- package/dist/content/rules/hatch3r-secrets-management.md +10 -1
- package/dist/content/rules/hatch3r-secrets-management.mdc +8 -0
- package/dist/content/rules/hatch3r-security-patterns.md +36 -34
- package/dist/content/rules/hatch3r-security-patterns.mdc +35 -34
- package/dist/content/rules/hatch3r-security.md +97 -0
- package/dist/content/rules/hatch3r-security.mdc +92 -0
- package/dist/content/rules/hatch3r-swiftui-patterns.md +98 -0
- package/dist/content/rules/hatch3r-swiftui-patterns.mdc +93 -0
- package/dist/content/rules/hatch3r-testability.md +115 -0
- package/dist/content/rules/hatch3r-testability.mdc +110 -0
- package/dist/content/rules/hatch3r-testing.md +4 -1
- package/dist/content/rules/hatch3r-testing.mdc +2 -0
- package/dist/content/rules/hatch3r-theming.md +2 -0
- package/dist/content/rules/hatch3r-theming.mdc +2 -0
- package/dist/content/rules/hatch3r-tool-currency.md +91 -0
- package/dist/content/rules/hatch3r-tool-currency.mdc +86 -0
- package/dist/content/rules/hatch3r-tooling-hierarchy.md +29 -31
- package/dist/content/rules/hatch3r-tooling-hierarchy.mdc +27 -30
- package/dist/content/rules/hatch3r-typescript-patterns.md +58 -0
- package/dist/content/rules/hatch3r-typescript-patterns.mdc +53 -0
- package/dist/content/rules/hatch3r-ux-states-and-flows.md +11 -4
- package/dist/content/rules/hatch3r-ux-states-and-flows.mdc +9 -3
- package/dist/content/skills/hatch3r-a11y-audit/SKILL.md +10 -8
- package/dist/content/skills/hatch3r-a11y-audit/references/manual-audit-checklist.md +7 -5
- package/dist/content/skills/hatch3r-adhoc-orchestrate/SKILL.md +131 -0
- package/dist/content/skills/hatch3r-ai-feature/SKILL.md +4 -6
- package/dist/content/skills/hatch3r-api-spec/SKILL.md +27 -2
- package/dist/content/skills/hatch3r-architecture-review/SKILL.md +4 -7
- package/dist/content/skills/hatch3r-board-groom/SKILL.md +11 -0
- package/dist/content/skills/hatch3r-board-init/SKILL.md +17 -1
- package/dist/content/skills/hatch3r-board-refresh/SKILL.md +12 -1
- package/dist/content/skills/hatch3r-board-shared/SKILL.md +38 -1
- package/dist/content/skills/hatch3r-browser-verify/SKILL.md +307 -0
- package/dist/content/skills/hatch3r-bug-fix/SKILL.md +15 -2
- package/dist/content/skills/hatch3r-ci-pipeline/SKILL.md +17 -7
- package/dist/content/skills/hatch3r-cli-fd/SKILL.md +33 -1
- package/dist/content/skills/hatch3r-cli-fzf/SKILL.md +33 -1
- package/dist/content/skills/hatch3r-cli-gh/SKILL.md +50 -1
- package/dist/content/skills/hatch3r-cli-jq/SKILL.md +40 -6
- package/dist/content/skills/hatch3r-cli-ripgrep/SKILL.md +33 -1
- package/dist/content/skills/hatch3r-cli-toolbox/SKILL.md +130 -23
- package/dist/content/skills/hatch3r-containerize/SKILL.md +157 -0
- package/dist/content/skills/hatch3r-context-health/SKILL.md +9 -7
- package/dist/content/skills/hatch3r-cost-tracking/SKILL.md +37 -17
- package/dist/content/skills/hatch3r-customize/SKILL.md +5 -8
- package/dist/content/skills/hatch3r-dep-audit/SKILL.md +23 -7
- package/dist/content/skills/hatch3r-design-system-detect/SKILL.md +3 -7
- package/dist/content/skills/hatch3r-docs-writing/SKILL.md +159 -0
- package/dist/content/skills/hatch3r-enhancability-verify/SKILL.md +152 -0
- package/dist/content/skills/hatch3r-feature/SKILL.md +53 -3
- package/dist/content/skills/hatch3r-feedback/SKILL.md +103 -0
- package/dist/content/skills/hatch3r-gh-agentic-workflows/SKILL.md +10 -8
- package/dist/content/skills/hatch3r-handoff-prepare/SKILL.md +4 -7
- package/dist/content/skills/hatch3r-handoff-resume/SKILL.md +4 -7
- package/dist/content/{commands/hatch3r-hooks.md → skills/hatch3r-hooks/SKILL.md} +48 -137
- package/dist/content/skills/hatch3r-incident-response/SKILL.md +66 -7
- package/dist/content/skills/hatch3r-issue-workflow/SKILL.md +11 -0
- package/dist/content/skills/hatch3r-learn/SKILL.md +317 -0
- package/dist/content/skills/hatch3r-logical-refactor/SKILL.md +6 -7
- package/dist/content/skills/hatch3r-maintainability-verify/SKILL.md +146 -0
- package/dist/content/skills/hatch3r-migration/SKILL.md +8 -7
- package/dist/content/skills/hatch3r-observability-verify/SKILL.md +17 -12
- package/dist/content/skills/hatch3r-perf-audit/SKILL.md +13 -9
- package/dist/content/skills/hatch3r-pr-creation/SKILL.md +4 -7
- package/dist/content/skills/hatch3r-qa-validation/SKILL.md +6 -5
- package/dist/content/skills/hatch3r-recipe/SKILL.md +63 -60
- package/dist/content/skills/hatch3r-refactor/SKILL.md +6 -7
- package/dist/content/skills/hatch3r-release/SKILL.md +123 -11
- package/dist/content/skills/hatch3r-reliability-verify/SKILL.md +9 -5
- package/dist/content/{commands/hatch3r-report.md → skills/hatch3r-report/SKILL.md} +20 -17
- package/dist/content/skills/hatch3r-scalability-verify/SKILL.md +145 -0
- package/dist/content/skills/hatch3r-security-verify/SKILL.md +144 -0
- package/dist/content/skills/hatch3r-team-convention-author/SKILL.md +126 -0
- package/dist/content/skills/hatch3r-testability-verify/SKILL.md +147 -0
- package/dist/content/skills/hatch3r-ui-ux-verify/SKILL.md +19 -11
- package/dist/content/skills/hatch3r-visual-refactor/SKILL.md +11 -7
- package/package.json +50 -31
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.js.map +0 -1
- package/dist/content/agents/hatch3r-a11y-auditor.md +0 -159
- package/dist/content/agents/hatch3r-dependency-auditor.md +0 -219
- package/dist/content/agents/hatch3r-perf-profiler.md +0 -166
- package/dist/content/agents/hatch3r-security-auditor.md +0 -180
- package/dist/content/agents/hatch3r-test-writer.md +0 -171
- package/dist/content/commands/hatch3r-learn.md +0 -312
- package/dist/content/rules/hatch3r-learning-consult.md +0 -42
- package/dist/content/rules/hatch3r-learning-consult.mdc +0 -38
|
@@ -4,7 +4,7 @@ type: rule
|
|
|
4
4
|
description: Distributed tracing, OpenTelemetry conventions, and AI agent instrumentation for the project
|
|
5
5
|
scope: conditional
|
|
6
6
|
globs: "**/*trac*,**/*span*,**/*telemetry*,**/*otel*,**/*agent*,**/observability/**,**/routes/**,**/handlers/**,**/services/**,**/api/**,**/middleware/**,**/controllers/**,**/lib/**"
|
|
7
|
-
tags: [devops]
|
|
7
|
+
tags: [devops, observability]
|
|
8
8
|
precedence: high
|
|
9
9
|
quality_charter: agents/shared/quality-charter.md
|
|
10
10
|
cache_friendly: true
|
|
@@ -35,7 +35,7 @@ Distributed tracing, OpenTelemetry semantic conventions, AI agent instrumentatio
|
|
|
35
35
|
|
|
36
36
|
## OpenTelemetry Semantic Conventions
|
|
37
37
|
|
|
38
|
-
Follow the [OpenTelemetry Semantic Conventions](https://opentelemetry.io/docs/specs/semconv/) (v1.
|
|
38
|
+
Follow the [OpenTelemetry Semantic Conventions](https://opentelemetry.io/docs/specs/semconv/) (v1.41.1) for consistent attribute naming across all telemetry signals.
|
|
39
39
|
|
|
40
40
|
### Standard Attribute Namespaces
|
|
41
41
|
|
|
@@ -85,43 +85,46 @@ Every telemetry-producing service must declare resource attributes at startup:
|
|
|
85
85
|
|
|
86
86
|
## AI Agent Instrumentation
|
|
87
87
|
|
|
88
|
-
Follow the [OpenTelemetry GenAI Semantic Conventions](https://opentelemetry.io/docs/specs/semconv/gen-ai/) for AI/LLM agent instrumentation.
|
|
88
|
+
Follow the [OpenTelemetry GenAI Semantic Conventions](https://opentelemetry.io/docs/specs/semconv/gen-ai/) for AI/LLM agent instrumentation. The GenAI conventions are Development status — gate any opt-in alias emission on `OTEL_SEMCONV_STABILITY_OPT_IN` and re-check the spec each P3 currency cycle.
|
|
89
89
|
|
|
90
90
|
### GenAI Span Attributes
|
|
91
91
|
|
|
92
92
|
Use these attributes on all spans representing interactions with generative AI models:
|
|
93
93
|
|
|
94
|
-
| Attribute | Type | Description | Example |
|
|
95
|
-
|
|
96
|
-
| `gen_ai.
|
|
97
|
-
| `gen_ai.
|
|
98
|
-
| `gen_ai.
|
|
99
|
-
| `gen_ai.
|
|
100
|
-
| `gen_ai.request.
|
|
101
|
-
| `gen_ai.
|
|
102
|
-
| `gen_ai.
|
|
103
|
-
| `gen_ai.usage.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
-
|
|
94
|
+
| Attribute | Type | Requirement | Description | Example |
|
|
95
|
+
|-----------|------|-------------|-------------|---------|
|
|
96
|
+
| `gen_ai.operation.name` | string | Required | Operation kind: `chat`, `generate_content`, `embeddings`, `create_agent`, `invoke_agent`, `execute_tool` | `chat`, `invoke_agent` |
|
|
97
|
+
| `gen_ai.provider.name` | string | Required | GenAI provider name | `openai`, `anthropic`, `azure.ai.openai` |
|
|
98
|
+
| `gen_ai.request.model` | string | Required | Model name as specified in the request | `gpt-4o`, `claude-sonnet-4-20250514` |
|
|
99
|
+
| `gen_ai.response.model` | string | Recommended | Model name as returned in the response | `gpt-4o-2024-08-06` |
|
|
100
|
+
| `gen_ai.request.max_tokens` | int | Recommended | Maximum tokens requested for generation | `4096` |
|
|
101
|
+
| `gen_ai.request.temperature` | float | Recommended | Temperature parameter | `0.7` |
|
|
102
|
+
| `gen_ai.response.finish_reasons` | string[] | Recommended | Reasons the model stopped generating | `["stop"]`, `["length"]` |
|
|
103
|
+
| `gen_ai.usage.input_tokens` | int | Recommended | Tokens in the input/prompt | `1250` |
|
|
104
|
+
| `gen_ai.usage.output_tokens` | int | Recommended | Tokens in the generated output | `530` |
|
|
105
|
+
|
|
106
|
+
- Always set `gen_ai.operation.name`, `gen_ai.provider.name`, and `gen_ai.request.model` on every GenAI span.
|
|
107
|
+
- Record `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` from the API response for cost dashboards. `gen_ai.operation.name` + `gen_ai.provider.name` are the required label pair on GenAI metrics (`gen_ai.client.token.usage`, `gen_ai.client.operation.duration`).
|
|
107
108
|
- Use `gen_ai.response.finish_reasons` to detect truncated outputs (`length`) and trigger re-prompting.
|
|
109
|
+
- **Migration (SemConv v1.37.0, 2025-07-05):** `gen_ai.system` is renamed to `gen_ai.provider.name`; emit the new key. Instrumentations bridging older collectors may dual-emit the legacy `gen_ai.system` alias only under `OTEL_SEMCONV_STABILITY_OPT_IN=gen_ai_latest_experimental`.
|
|
108
110
|
|
|
109
111
|
### Agent Invocation Spans
|
|
110
112
|
|
|
111
113
|
Instrument the full lifecycle of an agent invocation with a dedicated span. This span is the parent for all LLM calls, tool executions, and sub-agent delegations.
|
|
112
114
|
|
|
113
|
-
- **Span name pattern:** `agent.
|
|
114
|
-
- **Required attributes:** `
|
|
115
|
+
- **Span name pattern:** `invoke_agent {gen_ai.agent.name}` (OTel GenAI agent span naming).
|
|
116
|
+
- **Required attributes:** `gen_ai.operation.name` = `invoke_agent`, `gen_ai.agent.id`, `gen_ai.agent.name`. Use `create_agent` for the agent-construction span.
|
|
117
|
+
- **Project-namespaced extras:** `app.agent.parent_id`, `app.agent.task` carry hatch3r-specific context the GenAI namespace does not define (prefix custom attributes per the Attribute Naming Guidelines above).
|
|
115
118
|
- **Span events for state transitions:** `agent.planning`, `agent.tool_selection`, `agent.awaiting_human`, `agent.delegating`, `agent.completed`, `agent.error`
|
|
116
119
|
|
|
117
120
|
```typescript
|
|
118
|
-
const agentSpan = tracer.startSpan('
|
|
121
|
+
const agentSpan = tracer.startSpan('invoke_agent code_reviewer', {
|
|
119
122
|
attributes: {
|
|
120
|
-
'
|
|
121
|
-
'agent.
|
|
122
|
-
'agent.
|
|
123
|
-
'agent.
|
|
124
|
-
'agent.
|
|
123
|
+
'gen_ai.operation.name': 'invoke_agent',
|
|
124
|
+
'gen_ai.agent.id': invocationId,
|
|
125
|
+
'gen_ai.agent.name': 'code_reviewer',
|
|
126
|
+
'app.agent.parent_id': parentAgentId ?? '',
|
|
127
|
+
'app.agent.task': `review PR #${prNumber}`,
|
|
125
128
|
},
|
|
126
129
|
});
|
|
127
130
|
agentSpan.addEvent('agent.planning');
|
|
@@ -134,26 +137,32 @@ agentSpan.end();
|
|
|
134
137
|
|
|
135
138
|
Every tool invocation by an agent creates a child span of the agent invocation span.
|
|
136
139
|
|
|
137
|
-
- **Span name pattern:** `tool.
|
|
138
|
-
- **Required attributes:** `
|
|
139
|
-
-
|
|
140
|
+
- **Span name pattern:** `execute_tool {gen_ai.tool.name}` (OTel GenAI tool span naming).
|
|
141
|
+
- **Required attributes:** `gen_ai.operation.name` = `execute_tool`, `gen_ai.tool.name`.
|
|
142
|
+
- **Project-namespaced extras:** `app.tool.input_hash` (SHA-256), `app.tool.output_status`, `app.tool.duration_ms`, `app.tool.parameters_count` — hatch3r audit-trail fields the GenAI namespace does not define.
|
|
143
|
+
- Tool spans must be children of the invoking agent span. Set span status to `ERROR` when `app.tool.output_status` is `error` or `timeout`.
|
|
140
144
|
- For tools performing I/O, create nested child spans using appropriate semantic conventions (`http.*`, `db.*`).
|
|
141
145
|
|
|
142
146
|
```typescript
|
|
143
147
|
const toolSpan = tracer.startSpan(
|
|
144
|
-
'
|
|
145
|
-
{
|
|
148
|
+
'execute_tool git_diff',
|
|
149
|
+
{
|
|
150
|
+
attributes: {
|
|
151
|
+
'gen_ai.operation.name': 'execute_tool',
|
|
152
|
+
'gen_ai.tool.name': 'git_diff',
|
|
153
|
+
},
|
|
154
|
+
},
|
|
146
155
|
trace.setSpan(context.active(), agentSpan),
|
|
147
156
|
);
|
|
148
157
|
try {
|
|
149
158
|
const result = await tools.gitDiff(params);
|
|
150
159
|
toolSpan.setAttributes({
|
|
151
|
-
'tool.output_status': 'success',
|
|
152
|
-
'tool.duration_ms': performance.now() - startTime,
|
|
153
|
-
'tool.input_hash': hashInput(params),
|
|
160
|
+
'app.tool.output_status': 'success',
|
|
161
|
+
'app.tool.duration_ms': performance.now() - startTime,
|
|
162
|
+
'app.tool.input_hash': hashInput(params),
|
|
154
163
|
});
|
|
155
164
|
} catch (err) {
|
|
156
|
-
toolSpan.setAttributes({ 'tool.output_status': 'error' });
|
|
165
|
+
toolSpan.setAttributes({ 'app.tool.output_status': 'error' });
|
|
157
166
|
toolSpan.setStatus({ code: SpanStatusCode.ERROR, message: err.message });
|
|
158
167
|
toolSpan.recordException(err);
|
|
159
168
|
throw err;
|
|
@@ -164,8 +173,8 @@ try {
|
|
|
164
173
|
|
|
165
174
|
### LLM Request/Response Tracing
|
|
166
175
|
|
|
167
|
-
- **Span name pattern:** `gen_ai.
|
|
168
|
-
- **Token tracking:** Capture `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens`. Aggregate in metrics:
|
|
176
|
+
- **Span name pattern:** `{gen_ai.operation.name} {gen_ai.request.model}` (e.g., `chat gpt-4o`, `generate_content claude-sonnet-4-20250514`)
|
|
177
|
+
- **Token tracking:** Capture `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens`. Aggregate in the registered GenAI metrics: Histogram `gen_ai.client.token.usage` (attribute `gen_ai.token.type` = `input`/`output`), Histogram `gen_ai.client.operation.duration`.
|
|
169
178
|
- **Model version tracking:** Record both `gen_ai.request.model` and `gen_ai.response.model` for drift detection.
|
|
170
179
|
- **Retry spans:** Each retry attempt is a separate child span. Set `gen_ai.request.retries` on the final span. Record `http.response.status_code` on failed spans (429 vs 500+).
|
|
171
180
|
- Never log raw prompt content or full model responses as span attributes. Use token counts for cost tracking and correlated logs for prompt debugging in non-production environments.
|
|
@@ -173,7 +182,7 @@ try {
|
|
|
173
182
|
|
|
174
183
|
### Tool Call Audit Trail
|
|
175
184
|
|
|
176
|
-
Maintain a structured audit log for every tool invocation in agentic workflows, separate from tracing spans.
|
|
185
|
+
Maintain a structured audit log for every tool invocation in agentic workflows, separate from tracing spans. These are hatch3r log-schema field names (not OTel span attributes); on the tool span itself, emit the OTel GenAI keys (`gen_ai.tool.name`, `gen_ai.operation.name`) plus the `app.tool.*` extras from "Tool Call Spans" above.
|
|
177
186
|
|
|
178
187
|
| Field | Type | Description |
|
|
179
188
|
|-------|------|-------------|
|
|
@@ -30,7 +30,7 @@ Distributed tracing, OpenTelemetry semantic conventions, AI agent instrumentatio
|
|
|
30
30
|
|
|
31
31
|
## OpenTelemetry Semantic Conventions
|
|
32
32
|
|
|
33
|
-
Follow the [OpenTelemetry Semantic Conventions](https://opentelemetry.io/docs/specs/semconv/) (v1.
|
|
33
|
+
Follow the [OpenTelemetry Semantic Conventions](https://opentelemetry.io/docs/specs/semconv/) (v1.41.1) for consistent attribute naming across all telemetry signals.
|
|
34
34
|
|
|
35
35
|
### Standard Attribute Namespaces
|
|
36
36
|
|
|
@@ -80,43 +80,46 @@ Every telemetry-producing service must declare resource attributes at startup:
|
|
|
80
80
|
|
|
81
81
|
## AI Agent Instrumentation
|
|
82
82
|
|
|
83
|
-
Follow the [OpenTelemetry GenAI Semantic Conventions](https://opentelemetry.io/docs/specs/semconv/gen-ai/) for AI/LLM agent instrumentation.
|
|
83
|
+
Follow the [OpenTelemetry GenAI Semantic Conventions](https://opentelemetry.io/docs/specs/semconv/gen-ai/) for AI/LLM agent instrumentation. The GenAI conventions are Development status — gate any opt-in alias emission on `OTEL_SEMCONV_STABILITY_OPT_IN` and re-check the spec each P3 currency cycle.
|
|
84
84
|
|
|
85
85
|
### GenAI Span Attributes
|
|
86
86
|
|
|
87
87
|
Use these attributes on all spans representing interactions with generative AI models:
|
|
88
88
|
|
|
89
|
-
| Attribute | Type | Description | Example |
|
|
90
|
-
|
|
91
|
-
| `gen_ai.
|
|
92
|
-
| `gen_ai.
|
|
93
|
-
| `gen_ai.
|
|
94
|
-
| `gen_ai.
|
|
95
|
-
| `gen_ai.request.
|
|
96
|
-
| `gen_ai.
|
|
97
|
-
| `gen_ai.
|
|
98
|
-
| `gen_ai.usage.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
-
|
|
89
|
+
| Attribute | Type | Requirement | Description | Example |
|
|
90
|
+
|-----------|------|-------------|-------------|---------|
|
|
91
|
+
| `gen_ai.operation.name` | string | Required | Operation kind: `chat`, `generate_content`, `embeddings`, `create_agent`, `invoke_agent`, `execute_tool` | `chat`, `invoke_agent` |
|
|
92
|
+
| `gen_ai.provider.name` | string | Required | GenAI provider name | `openai`, `anthropic`, `azure.ai.openai` |
|
|
93
|
+
| `gen_ai.request.model` | string | Required | Model name as specified in the request | `gpt-4o`, `claude-sonnet-4-20250514` |
|
|
94
|
+
| `gen_ai.response.model` | string | Recommended | Model name as returned in the response | `gpt-4o-2024-08-06` |
|
|
95
|
+
| `gen_ai.request.max_tokens` | int | Recommended | Maximum tokens requested for generation | `4096` |
|
|
96
|
+
| `gen_ai.request.temperature` | float | Recommended | Temperature parameter | `0.7` |
|
|
97
|
+
| `gen_ai.response.finish_reasons` | string[] | Recommended | Reasons the model stopped generating | `["stop"]`, `["length"]` |
|
|
98
|
+
| `gen_ai.usage.input_tokens` | int | Recommended | Tokens in the input/prompt | `1250` |
|
|
99
|
+
| `gen_ai.usage.output_tokens` | int | Recommended | Tokens in the generated output | `530` |
|
|
100
|
+
|
|
101
|
+
- Always set `gen_ai.operation.name`, `gen_ai.provider.name`, and `gen_ai.request.model` on every GenAI span.
|
|
102
|
+
- Record `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` from the API response for cost dashboards. `gen_ai.operation.name` + `gen_ai.provider.name` are the required label pair on GenAI metrics (`gen_ai.client.token.usage`, `gen_ai.client.operation.duration`).
|
|
102
103
|
- Use `gen_ai.response.finish_reasons` to detect truncated outputs (`length`) and trigger re-prompting.
|
|
104
|
+
- **Migration (SemConv v1.37.0, 2025-07-05):** `gen_ai.system` is renamed to `gen_ai.provider.name`; emit the new key. Instrumentations bridging older collectors may dual-emit the legacy `gen_ai.system` alias only under `OTEL_SEMCONV_STABILITY_OPT_IN=gen_ai_latest_experimental`.
|
|
103
105
|
|
|
104
106
|
### Agent Invocation Spans
|
|
105
107
|
|
|
106
108
|
Instrument the full lifecycle of an agent invocation with a dedicated span. This span is the parent for all LLM calls, tool executions, and sub-agent delegations.
|
|
107
109
|
|
|
108
|
-
- **Span name pattern:** `agent.
|
|
109
|
-
- **Required attributes:** `
|
|
110
|
+
- **Span name pattern:** `invoke_agent {gen_ai.agent.name}` (OTel GenAI agent span naming).
|
|
111
|
+
- **Required attributes:** `gen_ai.operation.name` = `invoke_agent`, `gen_ai.agent.id`, `gen_ai.agent.name`. Use `create_agent` for the agent-construction span.
|
|
112
|
+
- **Project-namespaced extras:** `app.agent.parent_id`, `app.agent.task` carry hatch3r-specific context the GenAI namespace does not define (prefix custom attributes per the Attribute Naming Guidelines above).
|
|
110
113
|
- **Span events for state transitions:** `agent.planning`, `agent.tool_selection`, `agent.awaiting_human`, `agent.delegating`, `agent.completed`, `agent.error`
|
|
111
114
|
|
|
112
115
|
```typescript
|
|
113
|
-
const agentSpan = tracer.startSpan('
|
|
116
|
+
const agentSpan = tracer.startSpan('invoke_agent code_reviewer', {
|
|
114
117
|
attributes: {
|
|
115
|
-
'
|
|
116
|
-
'agent.
|
|
117
|
-
'agent.
|
|
118
|
-
'agent.
|
|
119
|
-
'agent.
|
|
118
|
+
'gen_ai.operation.name': 'invoke_agent',
|
|
119
|
+
'gen_ai.agent.id': invocationId,
|
|
120
|
+
'gen_ai.agent.name': 'code_reviewer',
|
|
121
|
+
'app.agent.parent_id': parentAgentId ?? '',
|
|
122
|
+
'app.agent.task': `review PR #${prNumber}`,
|
|
120
123
|
},
|
|
121
124
|
});
|
|
122
125
|
agentSpan.addEvent('agent.planning');
|
|
@@ -129,26 +132,32 @@ agentSpan.end();
|
|
|
129
132
|
|
|
130
133
|
Every tool invocation by an agent creates a child span of the agent invocation span.
|
|
131
134
|
|
|
132
|
-
- **Span name pattern:** `tool.
|
|
133
|
-
- **Required attributes:** `
|
|
134
|
-
-
|
|
135
|
+
- **Span name pattern:** `execute_tool {gen_ai.tool.name}` (OTel GenAI tool span naming).
|
|
136
|
+
- **Required attributes:** `gen_ai.operation.name` = `execute_tool`, `gen_ai.tool.name`.
|
|
137
|
+
- **Project-namespaced extras:** `app.tool.input_hash` (SHA-256), `app.tool.output_status`, `app.tool.duration_ms`, `app.tool.parameters_count` — hatch3r audit-trail fields the GenAI namespace does not define.
|
|
138
|
+
- Tool spans must be children of the invoking agent span. Set span status to `ERROR` when `app.tool.output_status` is `error` or `timeout`.
|
|
135
139
|
- For tools performing I/O, create nested child spans using appropriate semantic conventions (`http.*`, `db.*`).
|
|
136
140
|
|
|
137
141
|
```typescript
|
|
138
142
|
const toolSpan = tracer.startSpan(
|
|
139
|
-
'
|
|
140
|
-
{
|
|
143
|
+
'execute_tool git_diff',
|
|
144
|
+
{
|
|
145
|
+
attributes: {
|
|
146
|
+
'gen_ai.operation.name': 'execute_tool',
|
|
147
|
+
'gen_ai.tool.name': 'git_diff',
|
|
148
|
+
},
|
|
149
|
+
},
|
|
141
150
|
trace.setSpan(context.active(), agentSpan),
|
|
142
151
|
);
|
|
143
152
|
try {
|
|
144
153
|
const result = await tools.gitDiff(params);
|
|
145
154
|
toolSpan.setAttributes({
|
|
146
|
-
'tool.output_status': 'success',
|
|
147
|
-
'tool.duration_ms': performance.now() - startTime,
|
|
148
|
-
'tool.input_hash': hashInput(params),
|
|
155
|
+
'app.tool.output_status': 'success',
|
|
156
|
+
'app.tool.duration_ms': performance.now() - startTime,
|
|
157
|
+
'app.tool.input_hash': hashInput(params),
|
|
149
158
|
});
|
|
150
159
|
} catch (err) {
|
|
151
|
-
toolSpan.setAttributes({ 'tool.output_status': 'error' });
|
|
160
|
+
toolSpan.setAttributes({ 'app.tool.output_status': 'error' });
|
|
152
161
|
toolSpan.setStatus({ code: SpanStatusCode.ERROR, message: err.message });
|
|
153
162
|
toolSpan.recordException(err);
|
|
154
163
|
throw err;
|
|
@@ -159,8 +168,8 @@ try {
|
|
|
159
168
|
|
|
160
169
|
### LLM Request/Response Tracing
|
|
161
170
|
|
|
162
|
-
- **Span name pattern:** `gen_ai.
|
|
163
|
-
- **Token tracking:** Capture `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens`. Aggregate in metrics:
|
|
171
|
+
- **Span name pattern:** `{gen_ai.operation.name} {gen_ai.request.model}` (e.g., `chat gpt-4o`, `generate_content claude-sonnet-4-20250514`)
|
|
172
|
+
- **Token tracking:** Capture `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens`. Aggregate in the registered GenAI metrics: Histogram `gen_ai.client.token.usage` (attribute `gen_ai.token.type` = `input`/`output`), Histogram `gen_ai.client.operation.duration`.
|
|
164
173
|
- **Model version tracking:** Record both `gen_ai.request.model` and `gen_ai.response.model` for drift detection.
|
|
165
174
|
- **Retry spans:** Each retry attempt is a separate child span. Set `gen_ai.request.retries` on the final span. Record `http.response.status_code` on failed spans (429 vs 500+).
|
|
166
175
|
- Never log raw prompt content or full model responses as span attributes. Use token counts for cost tracking and correlated logs for prompt debugging in non-production environments.
|
|
@@ -168,7 +177,7 @@ try {
|
|
|
168
177
|
|
|
169
178
|
### Tool Call Audit Trail
|
|
170
179
|
|
|
171
|
-
Maintain a structured audit log for every tool invocation in agentic workflows, separate from tracing spans.
|
|
180
|
+
Maintain a structured audit log for every tool invocation in agentic workflows, separate from tracing spans. These are hatch3r log-schema field names (not OTel span attributes); on the tool span itself, emit the OTel GenAI keys (`gen_ai.tool.name`, `gen_ai.operation.name`) plus the `app.tool.*` extras from "Tool Call Spans" above.
|
|
172
181
|
|
|
173
182
|
| Field | Type | Description |
|
|
174
183
|
|-------|------|-------------|
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
id: hatch3r-operability
|
|
3
3
|
type: rule
|
|
4
4
|
description: Operability patterns in user code — liveness / readiness / startup probes, graceful shutdown, feature flags, runbook URL annotations, health endpoints
|
|
5
|
-
scope:
|
|
5
|
+
scope: conditional
|
|
6
|
+
globs: "**/services/**,**/handlers/**,**/health*,**/probes/**,**/k8s/**,**/manifests/**,**/charts/**,**/feature*,**/flags/**"
|
|
6
7
|
tags: [implementation, devops]
|
|
7
8
|
precedence: high
|
|
8
9
|
quality_charter: agents/shared/quality-charter.md
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
id: hatch3r-passkey-server
|
|
3
3
|
type: rule
|
|
4
4
|
description: Server-side WebAuthn / passkey ceremony — registration, authentication, attestation, counter, RP-ID, recovery, FIDO CXP/CXF awareness
|
|
5
|
-
scope:
|
|
5
|
+
scope: conditional
|
|
6
|
+
globs: "**/auth/**,**/passkey*,**/webauthn*,**/fido*,**/credentials/**,**/api/**,**/handlers/**"
|
|
6
7
|
tags: [implementation, floor:security]
|
|
7
8
|
precedence: high
|
|
8
9
|
quality_charter: agents/shared/quality-charter.md
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: hatch3r-php-laravel-patterns
|
|
3
|
+
type: rule
|
|
4
|
+
description: PHP 8.3+ and Laravel 11.x conventions covering typed properties, attributes, Eloquent ORM, Service Container DI, Pest testing, queue workers, and Laravel Pint formatting
|
|
5
|
+
scope: conditional
|
|
6
|
+
globs: "**/*.php,**/composer.json,**/composer.lock,**/artisan,**/phpunit.xml,**/phpunit.xml.dist,**/phpstan.neon,**/phpstan.neon.dist,**/pint.json,**/.php-cs-fixer.php,**/app/**,**/bootstrap/**,**/config/**,**/database/migrations/**,**/routes/**,**/tests/**"
|
|
7
|
+
tags: [implementation]
|
|
8
|
+
quality_charter: agents/shared/quality-charter.md
|
|
9
|
+
cache_friendly: true
|
|
10
|
+
---
|
|
11
|
+
# PHP / Laravel Patterns
|
|
12
|
+
|
|
13
|
+
**Pillars:** P2 (Scientific & Practical Quality), CQ8 (Maintainability Quality)
|
|
14
|
+
|
|
15
|
+
> Applies when the project ships a PHP application. Detection signals: `composer.json` at repo root, `artisan` script (Laravel), or any `*.php` source file. Symfony and Symfony-based projects also follow most of the language-level guidance here.
|
|
16
|
+
|
|
17
|
+
## PHP Language Floor
|
|
18
|
+
|
|
19
|
+
- Target PHP 8.3+ (8.4 recommended for new projects). Use typed properties, constructor property promotion, enums, readonly classes, first-class callable syntax. Avoid PHP 7.x patterns in new code.
|
|
20
|
+
- Enable strict types in every file (`declare(strict_types=1);` as the first statement after `<?php`). The IDE / Pint config enforces presence.
|
|
21
|
+
- Static analysis: PHPStan level 8 or Psalm level 1 in CI. Treat warnings as errors. Configure via `phpstan.neon` with project-specific baselines for legacy code.
|
|
22
|
+
- Format with Laravel Pint (Laravel projects) or PHP-CS-Fixer with PER 2.0 / PSR-12 ruleset. Run in CI; reformat-on-save in editors.
|
|
23
|
+
|
|
24
|
+
## Project Layout (Laravel)
|
|
25
|
+
|
|
26
|
+
- Default Laravel structure:
|
|
27
|
+
- `app/Models/` — Eloquent models.
|
|
28
|
+
- `app/Http/Controllers/` — controllers (HTTP only, thin orchestration).
|
|
29
|
+
- `app/Services/<Domain>/` — domain services and business logic.
|
|
30
|
+
- `app/Actions/` — single-purpose action classes (one public `execute()` method).
|
|
31
|
+
- `app/Jobs/` — queue jobs.
|
|
32
|
+
- `app/Policies/` — authorization policies.
|
|
33
|
+
- Keep controllers thin: receive request → call action / service → return response. Business logic in services or action classes, not controllers.
|
|
34
|
+
- Public API of the app: HTTP routes (`routes/api.php`, `routes/web.php`), Artisan commands (`app/Console/Commands/`), broadcast channels (`routes/channels.php`).
|
|
35
|
+
|
|
36
|
+
## Laravel 11.x
|
|
37
|
+
|
|
38
|
+
- Laravel 11 is the floor (Feb 2024 release, supported through 2026). Migrate from earlier versions via the official upgrade guide; do not skip major versions.
|
|
39
|
+
- Use the streamlined application skeleton: `bootstrap/app.php` with `withRouting`, `withMiddleware`, `withExceptions` configuration callbacks. Avoid restoring the legacy `kernel.php` files for new projects.
|
|
40
|
+
- Configuration: `config/*.php` returns arrays; access via `config('key.path')`. Never call `env()` outside `config/*.php` — `php artisan config:cache` invalidates direct `env()` calls in app code.
|
|
41
|
+
- Environment-specific config: `.env.local`, `.env.production`. Never commit `.env` files to VCS.
|
|
42
|
+
|
|
43
|
+
## Eloquent ORM
|
|
44
|
+
|
|
45
|
+
- Define models with explicit `$fillable` (allowlist) — never `$guarded = []`. Mass-assignment vulnerabilities are real.
|
|
46
|
+
- Type-hint relationship return types: `public function orders(): HasMany { ... }`. The static analyzer catches relationship typos.
|
|
47
|
+
- N+1 query prevention: eager-load relationships explicitly (`User::with('orders.items')->...`). Use the Laravel debug bar or `LazyEagerLoad::enforce()` in tests to catch N+1 violations in CI.
|
|
48
|
+
- Avoid mass operations through Eloquent (`Model::all()`, then iterating). Use the query builder, chunked queries (`->chunk(100, function ($users) { ... })`), or lazy collections for large result sets.
|
|
49
|
+
- Migrations are forward-only in production. Never `php artisan migrate:rollback` against production. For destructive schema changes, write a forward-only migration that achieves the same outcome.
|
|
50
|
+
|
|
51
|
+
## Service Container & DI
|
|
52
|
+
|
|
53
|
+
- Constructor injection via type-hinted parameters. The container auto-resolves bindings declared in service providers.
|
|
54
|
+
- Define bindings in `app/Providers/AppServiceProvider.php` (or feature-specific providers). Use `bind` for transient services, `singleton` for app-wide singletons, `scoped` for request-scoped.
|
|
55
|
+
- Contextual bindings via `$this->app->when(MyController::class)->needs(LoggerInterface::class)->give(...)`. Stops type-hint hacks.
|
|
56
|
+
- Avoid `app()` and `resolve()` helpers in app code — they obscure dependencies. Reserve for service providers and one-off scripts.
|
|
57
|
+
|
|
58
|
+
## HTTP Layer
|
|
59
|
+
|
|
60
|
+
- Form Requests (`php artisan make:request StoreUserRequest`) for input validation. Define `rules()`, `authorize()`, and `messages()` methods. Controllers receive the validated request, never `$request->all()` blindly.
|
|
61
|
+
- Resource classes (`php artisan make:resource UserResource`) for API responses. Stop returning raw Eloquent models — Resources control the shape and protect against accidental field leaks.
|
|
62
|
+
- Use route model binding (`Route::get('/users/{user}', [UserController::class, 'show'])` with type-hinted `User $user`). Automatic 404s and stable URL conventions.
|
|
63
|
+
- Middleware: composable via `bootstrap/app.php` `withMiddleware()`. Avoid global middleware unless it applies to all routes — prefer route groups.
|
|
64
|
+
|
|
65
|
+
## Queues & Jobs
|
|
66
|
+
|
|
67
|
+
- Use Laravel queues for any work over 200ms: emails, third-party API calls, image processing, report generation. Synchronous handling blocks the HTTP response.
|
|
68
|
+
- Job classes implement `ShouldQueue`. Configure retry counts (`public int $tries = 3`) and backoff (`public function backoff(): array { return [60, 300, 1800]; }`). Idempotency keys for jobs touching external APIs.
|
|
69
|
+
- Driver choice: Redis (`predis/predis` or `phpredis`) for high throughput, Database for low-volume / dev. Avoid Beanstalkd / SQS unless infrastructure requires it.
|
|
70
|
+
- Run workers via Horizon (`laravel/horizon`) for production observability and balanced auto-scaling. Configure tags, supervisors, and memory limits in `config/horizon.php`.
|
|
71
|
+
|
|
72
|
+
## Testing
|
|
73
|
+
|
|
74
|
+
- Use Pest (`pestphp/pest`) for new test suites — terser syntax than PHPUnit, runs on top of PHPUnit. PHPUnit alone is acceptable for legacy projects.
|
|
75
|
+
- Test types under `tests/`:
|
|
76
|
+
- `tests/Unit/` — pure logic, no Laravel bootstrap.
|
|
77
|
+
- `tests/Feature/` — full HTTP / queue / database flows with `RefreshDatabase` trait.
|
|
78
|
+
- `tests/Browser/` — Dusk for end-to-end browser tests.
|
|
79
|
+
- Database tests: `RefreshDatabase` trait wraps each test in a transaction and rolls back. Never use `DatabaseMigrations` in CI — too slow.
|
|
80
|
+
- Mock external services with Laravel's HTTP facade (`Http::fake([...])`). Never hit real network in tests.
|
|
81
|
+
- Coverage: `php artisan test --coverage --min=80`. Floor: 80% line coverage; 90% in critical modules (auth, billing, persistence).
|
|
82
|
+
|
|
83
|
+
## Security
|
|
84
|
+
|
|
85
|
+
- Validate every user input via Form Requests. Never trust `$request->all()` direct to a model.
|
|
86
|
+
- Authorization via Policies (`app/Policies/`) registered in `AuthServiceProvider`. Controllers call `$this->authorize('update', $post)`. Never authorize in views — too late.
|
|
87
|
+
- CSRF protection: Laravel adds it by default to web routes. Do not disable globally.
|
|
88
|
+
- Mass-assignment: `$fillable` allowlist on every model. Audit `$guarded = []` patterns and migrate.
|
|
89
|
+
- Encryption: `Crypt::encryptString()` for sensitive at-rest data. Never reinvent symmetric encryption.
|
|
90
|
+
|
|
91
|
+
## Composer & Dependency Hygiene
|
|
92
|
+
|
|
93
|
+
- Pin versions in `composer.json` to caret ranges (`^11.0` for Laravel itself, `^1.2` for stable libraries). Avoid `*` and `dev-` requirements in production.
|
|
94
|
+
- Lock file (`composer.lock`) committed for applications. Library packages typically omit the lock.
|
|
95
|
+
- Vulnerability scanning: `composer audit` (PHP 8.2+, Composer 2.4+) in CI against the FriendsOfPHP/security-advisories database. Block merge on advisories.
|
|
96
|
+
- License compliance: `composer-license-checker` with an allowlist. Block GPL contamination.
|
|
97
|
+
|
|
98
|
+
## References
|
|
99
|
+
|
|
100
|
+
- PHP 8.3 release notes: https://www.php.net/releases/8.3/en.php (accessed 2026-05-27, official-docs)
|
|
101
|
+
- Laravel 11 upgrade guide: https://laravel.com/docs/11.x/upgrade (accessed 2026-05-27, official-docs)
|
|
102
|
+
- Laravel docs: https://laravel.com/docs/11.x (accessed 2026-05-27, official-docs)
|
|
103
|
+
- Pest: https://pestphp.com/docs/installation (accessed 2026-05-27, official-docs)
|
|
104
|
+
|
|
105
|
+
## Cross-References
|
|
106
|
+
|
|
107
|
+
- `rules/hatch3r-api-design.md` — REST/GraphQL/gRPC contract floors apply to Laravel API endpoints.
|
|
108
|
+
- `rules/hatch3r-testing.md` — coverage thresholds carry over to `php artisan test --coverage`.
|
|
109
|
+
- `rules/hatch3r-secrets-management.md` — `.env` handling and secret rotation patterns.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: PHP 8.3+ and Laravel 11.x conventions covering typed properties, attributes, Eloquent ORM, Service Container DI, Pest testing, queue workers, and Laravel Pint formatting
|
|
3
|
+
globs: ["**/*.php", "**/composer.json", "**/composer.lock", "**/artisan", "**/phpunit.xml", "**/phpunit.xml.dist", "**/phpstan.neon", "**/phpstan.neon.dist", "**/pint.json", "**/.php-cs-fixer.php", "**/app/**", "**/bootstrap/**", "**/config/**", "**/database/migrations/**", "**/routes/**", "**/tests/**"]
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
# PHP / Laravel Patterns
|
|
7
|
+
|
|
8
|
+
**Pillars:** P2 (Scientific & Practical Quality), CQ8 (Maintainability Quality)
|
|
9
|
+
|
|
10
|
+
> Applies when the project ships a PHP application. Detection signals: `composer.json` at repo root, `artisan` script (Laravel), or any `*.php` source file. Symfony and Symfony-based projects also follow most of the language-level guidance here.
|
|
11
|
+
|
|
12
|
+
## PHP Language Floor
|
|
13
|
+
|
|
14
|
+
- Target PHP 8.3+ (8.4 recommended for new projects). Use typed properties, constructor property promotion, enums, readonly classes, first-class callable syntax. Avoid PHP 7.x patterns in new code.
|
|
15
|
+
- Enable strict types in every file (`declare(strict_types=1);` as the first statement after `<?php`). The IDE / Pint config enforces presence.
|
|
16
|
+
- Static analysis: PHPStan level 8 or Psalm level 1 in CI. Treat warnings as errors. Configure via `phpstan.neon` with project-specific baselines for legacy code.
|
|
17
|
+
- Format with Laravel Pint (Laravel projects) or PHP-CS-Fixer with PER 2.0 / PSR-12 ruleset. Run in CI; reformat-on-save in editors.
|
|
18
|
+
|
|
19
|
+
## Project Layout (Laravel)
|
|
20
|
+
|
|
21
|
+
- Default Laravel structure:
|
|
22
|
+
- `app/Models/` — Eloquent models.
|
|
23
|
+
- `app/Http/Controllers/` — controllers (HTTP only, thin orchestration).
|
|
24
|
+
- `app/Services/<Domain>/` — domain services and business logic.
|
|
25
|
+
- `app/Actions/` — single-purpose action classes (one public `execute()` method).
|
|
26
|
+
- `app/Jobs/` — queue jobs.
|
|
27
|
+
- `app/Policies/` — authorization policies.
|
|
28
|
+
- Keep controllers thin: receive request → call action / service → return response. Business logic in services or action classes, not controllers.
|
|
29
|
+
- Public API of the app: HTTP routes (`routes/api.php`, `routes/web.php`), Artisan commands (`app/Console/Commands/`), broadcast channels (`routes/channels.php`).
|
|
30
|
+
|
|
31
|
+
## Laravel 11.x
|
|
32
|
+
|
|
33
|
+
- Laravel 11 is the floor (Feb 2024 release, supported through 2026). Migrate from earlier versions via the official upgrade guide; do not skip major versions.
|
|
34
|
+
- Use the streamlined application skeleton: `bootstrap/app.php` with `withRouting`, `withMiddleware`, `withExceptions` configuration callbacks. Avoid restoring the legacy `kernel.php` files for new projects.
|
|
35
|
+
- Configuration: `config/*.php` returns arrays; access via `config('key.path')`. Never call `env()` outside `config/*.php` — `php artisan config:cache` invalidates direct `env()` calls in app code.
|
|
36
|
+
- Environment-specific config: `.env.local`, `.env.production`. Never commit `.env` files to VCS.
|
|
37
|
+
|
|
38
|
+
## Eloquent ORM
|
|
39
|
+
|
|
40
|
+
- Define models with explicit `$fillable` (allowlist) — never `$guarded = []`. Mass-assignment vulnerabilities are real.
|
|
41
|
+
- Type-hint relationship return types: `public function orders(): HasMany { ... }`. The static analyzer catches relationship typos.
|
|
42
|
+
- N+1 query prevention: eager-load relationships explicitly (`User::with('orders.items')->...`). Use the Laravel debug bar or `LazyEagerLoad::enforce()` in tests to catch N+1 violations in CI.
|
|
43
|
+
- Avoid mass operations through Eloquent (`Model::all()`, then iterating). Use the query builder, chunked queries (`->chunk(100, function ($users) { ... })`), or lazy collections for large result sets.
|
|
44
|
+
- Migrations are forward-only in production. Never `php artisan migrate:rollback` against production. For destructive schema changes, write a forward-only migration that achieves the same outcome.
|
|
45
|
+
|
|
46
|
+
## Service Container & DI
|
|
47
|
+
|
|
48
|
+
- Constructor injection via type-hinted parameters. The container auto-resolves bindings declared in service providers.
|
|
49
|
+
- Define bindings in `app/Providers/AppServiceProvider.php` (or feature-specific providers). Use `bind` for transient services, `singleton` for app-wide singletons, `scoped` for request-scoped.
|
|
50
|
+
- Contextual bindings via `$this->app->when(MyController::class)->needs(LoggerInterface::class)->give(...)`. Stops type-hint hacks.
|
|
51
|
+
- Avoid `app()` and `resolve()` helpers in app code — they obscure dependencies. Reserve for service providers and one-off scripts.
|
|
52
|
+
|
|
53
|
+
## HTTP Layer
|
|
54
|
+
|
|
55
|
+
- Form Requests (`php artisan make:request StoreUserRequest`) for input validation. Define `rules()`, `authorize()`, and `messages()` methods. Controllers receive the validated request, never `$request->all()` blindly.
|
|
56
|
+
- Resource classes (`php artisan make:resource UserResource`) for API responses. Stop returning raw Eloquent models — Resources control the shape and protect against accidental field leaks.
|
|
57
|
+
- Use route model binding (`Route::get('/users/{user}', [UserController::class, 'show'])` with type-hinted `User $user`). Automatic 404s and stable URL conventions.
|
|
58
|
+
- Middleware: composable via `bootstrap/app.php` `withMiddleware()`. Avoid global middleware unless it applies to all routes — prefer route groups.
|
|
59
|
+
|
|
60
|
+
## Queues & Jobs
|
|
61
|
+
|
|
62
|
+
- Use Laravel queues for any work over 200ms: emails, third-party API calls, image processing, report generation. Synchronous handling blocks the HTTP response.
|
|
63
|
+
- Job classes implement `ShouldQueue`. Configure retry counts (`public int $tries = 3`) and backoff (`public function backoff(): array { return [60, 300, 1800]; }`). Idempotency keys for jobs touching external APIs.
|
|
64
|
+
- Driver choice: Redis (`predis/predis` or `phpredis`) for high throughput, Database for low-volume / dev. Avoid Beanstalkd / SQS unless infrastructure requires it.
|
|
65
|
+
- Run workers via Horizon (`laravel/horizon`) for production observability and balanced auto-scaling. Configure tags, supervisors, and memory limits in `config/horizon.php`.
|
|
66
|
+
|
|
67
|
+
## Testing
|
|
68
|
+
|
|
69
|
+
- Use Pest (`pestphp/pest`) for new test suites — terser syntax than PHPUnit, runs on top of PHPUnit. PHPUnit alone is acceptable for legacy projects.
|
|
70
|
+
- Test types under `tests/`:
|
|
71
|
+
- `tests/Unit/` — pure logic, no Laravel bootstrap.
|
|
72
|
+
- `tests/Feature/` — full HTTP / queue / database flows with `RefreshDatabase` trait.
|
|
73
|
+
- `tests/Browser/` — Dusk for end-to-end browser tests.
|
|
74
|
+
- Database tests: `RefreshDatabase` trait wraps each test in a transaction and rolls back. Never use `DatabaseMigrations` in CI — too slow.
|
|
75
|
+
- Mock external services with Laravel's HTTP facade (`Http::fake([...])`). Never hit real network in tests.
|
|
76
|
+
- Coverage: `php artisan test --coverage --min=80`. Floor: 80% line coverage; 90% in critical modules (auth, billing, persistence).
|
|
77
|
+
|
|
78
|
+
## Security
|
|
79
|
+
|
|
80
|
+
- Validate every user input via Form Requests. Never trust `$request->all()` direct to a model.
|
|
81
|
+
- Authorization via Policies (`app/Policies/`) registered in `AuthServiceProvider`. Controllers call `$this->authorize('update', $post)`. Never authorize in views — too late.
|
|
82
|
+
- CSRF protection: Laravel adds it by default to web routes. Do not disable globally.
|
|
83
|
+
- Mass-assignment: `$fillable` allowlist on every model. Audit `$guarded = []` patterns and migrate.
|
|
84
|
+
- Encryption: `Crypt::encryptString()` for sensitive at-rest data. Never reinvent symmetric encryption.
|
|
85
|
+
|
|
86
|
+
## Composer & Dependency Hygiene
|
|
87
|
+
|
|
88
|
+
- Pin versions in `composer.json` to caret ranges (`^11.0` for Laravel itself, `^1.2` for stable libraries). Avoid `*` and `dev-` requirements in production.
|
|
89
|
+
- Lock file (`composer.lock`) committed for applications. Library packages typically omit the lock.
|
|
90
|
+
- Vulnerability scanning: `composer audit` (PHP 8.2+, Composer 2.4+) in CI against the FriendsOfPHP/security-advisories database. Block merge on advisories.
|
|
91
|
+
- License compliance: `composer-license-checker` with an allowlist. Block GPL contamination.
|
|
92
|
+
|
|
93
|
+
## References
|
|
94
|
+
|
|
95
|
+
- PHP 8.3 release notes: https://www.php.net/releases/8.3/en.php (accessed 2026-05-27, official-docs)
|
|
96
|
+
- Laravel 11 upgrade guide: https://laravel.com/docs/11.x/upgrade (accessed 2026-05-27, official-docs)
|
|
97
|
+
- Laravel docs: https://laravel.com/docs/11.x (accessed 2026-05-27, official-docs)
|
|
98
|
+
- Pest: https://pestphp.com/docs/installation (accessed 2026-05-27, official-docs)
|
|
99
|
+
|
|
100
|
+
## Cross-References
|
|
101
|
+
|
|
102
|
+
- `rules/hatch3r-api-design.md` — REST/GraphQL/gRPC contract floors apply to Laravel API endpoints.
|
|
103
|
+
- `rules/hatch3r-testing.md` — coverage thresholds carry over to `php artisan test --coverage`.
|
|
104
|
+
- `rules/hatch3r-secrets-management.md` — `.env` handling and secret rotation patterns.
|
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
id: hatch3r-progressive-delivery
|
|
3
3
|
type: rule
|
|
4
4
|
description: Progressive delivery — canary, blue-green, feature-flag rollout with auto-rollback on SLO burn; staged rollout to prevent CrowdStrike-class incidents
|
|
5
|
-
scope:
|
|
5
|
+
scope: conditional
|
|
6
|
+
globs: "**/.github/workflows/**,**/deploy/**,**/k8s/**,**/manifests/**,**/argo/**,**/flagger/**,**/spinnaker/**,**/rollout*"
|
|
6
7
|
tags: [devops]
|
|
8
|
+
precedence: high
|
|
7
9
|
quality_charter: agents/shared/quality-charter.md
|
|
8
10
|
cache_friendly: true
|
|
9
11
|
---
|
|
10
12
|
# Progressive Delivery
|
|
11
13
|
|
|
14
|
+
**Pillars:** P2 (Scientific & Practical Quality), CQ4 (Reliability Quality)
|
|
15
|
+
|
|
12
16
|
## Three Rollout Strategies
|
|
13
17
|
|
|
14
18
|
Choose one per service based on risk profile and resource budget:
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
description: Progressive delivery — canary, blue-green, feature-flag rollout with auto-rollback on SLO burn; staged rollout to prevent CrowdStrike-class incidents
|
|
3
3
|
globs: ["**/.github/workflows/**", "**/deploy/**", "**/k8s/**", "**/manifests/**", "**/argo/**", "**/flagger/**", "**/spinnaker/**", "**/rollout*"]
|
|
4
4
|
alwaysApply: false
|
|
5
|
+
precedence: high
|
|
5
6
|
---
|
|
6
7
|
# Progressive Delivery
|
|
7
8
|
|
|
9
|
+
**Pillars:** P2 (Scientific & Practical Quality), CQ4 (Reliability Quality)
|
|
10
|
+
|
|
8
11
|
## Three Rollout Strategies
|
|
9
12
|
|
|
10
13
|
Choose one per service based on risk profile and resource budget:
|