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
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
id: hatch3r-data-classification
|
|
3
3
|
type: rule
|
|
4
4
|
description: Data classification standards covering PII handling, encryption, retention policies, and regulatory compliance
|
|
5
|
-
scope:
|
|
5
|
+
scope: conditional
|
|
6
|
+
globs: "**/models/**,**/schemas/**,**/schema*,**/database/**,**/db/**,**/*model*,**/*entity*,**/prisma/**,**/drizzle/**,**/*migration*,**/log*,**/*logger*,**/analytics/**,**/*analytics*,**/events/**,**/*telemetry*,**/export*,**/*export*"
|
|
6
7
|
tags: [floor:security]
|
|
7
8
|
precedence: high
|
|
8
9
|
quality_charter: agents/shared/quality-charter.md
|
|
@@ -27,6 +28,7 @@ cache_friendly: true
|
|
|
27
28
|
- Never log PII. Use structured logging with PII fields explicitly excluded or masked.
|
|
28
29
|
- Pseudonymize PII in analytics and reporting. Use irreversible hashing for identifiers.
|
|
29
30
|
- Provide data export and deletion endpoints for data subject requests (GDPR Article 15/17, CCPA).
|
|
31
|
+
- This rule's PII review applies wherever PII can leave the data model — not just schemas and migrations, but log statements, loggers, analytics/telemetry emitters, event payloads, and export paths. Before merging a change to any of these surfaces, confirm no Level 3+ field is logged, emitted, or exported unmasked.
|
|
30
32
|
|
|
31
33
|
## Encryption
|
|
32
34
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: Data classification standards covering PII handling, encryption, retention policies, and regulatory compliance
|
|
3
|
-
globs: ["**/models/**", "**/schemas/**", "**/schema*", "**/database/**", "**/db/**", "**/*model*", "**/*entity*", "**/prisma/**", "**/drizzle/**", "**/*migration*"]
|
|
3
|
+
globs: ["**/models/**", "**/schemas/**", "**/schema*", "**/database/**", "**/db/**", "**/*model*", "**/*entity*", "**/prisma/**", "**/drizzle/**", "**/*migration*", "**/log*", "**/*logger*", "**/analytics/**", "**/*analytics*", "**/events/**", "**/*telemetry*", "**/export*", "**/*export*"]
|
|
4
4
|
alwaysApply: false
|
|
5
5
|
precedence: high
|
|
6
6
|
---
|
|
@@ -23,6 +23,7 @@ precedence: high
|
|
|
23
23
|
- Never log PII. Use structured logging with PII fields explicitly excluded or masked.
|
|
24
24
|
- Pseudonymize PII in analytics and reporting. Use irreversible hashing for identifiers.
|
|
25
25
|
- Provide data export and deletion endpoints for data subject requests (GDPR Article 15/17, CCPA).
|
|
26
|
+
- This rule's PII review applies wherever PII can leave the data model — not just schemas and migrations, but log statements, loggers, analytics/telemetry emitters, event payloads, and export paths. Before merging a change to any of these surfaces, confirm no Level 3+ field is logged, emitted, or exported unmasked.
|
|
26
27
|
|
|
27
28
|
## Encryption
|
|
28
29
|
|
|
@@ -4,11 +4,14 @@ type: rule
|
|
|
4
4
|
description: Adaptive pre-implementation analysis — complexity scoring, requirements elicitation, similar implementation discovery, and transitive dependency tracing before coding
|
|
5
5
|
scope: always
|
|
6
6
|
tags: [orchestration, floor:protocol]
|
|
7
|
+
precedence: high
|
|
7
8
|
quality_charter: agents/shared/quality-charter.md
|
|
8
9
|
cache_friendly: true
|
|
9
10
|
---
|
|
10
11
|
# Deep Context Analysis
|
|
11
12
|
|
|
13
|
+
**Pillars:** P2 (Scientific & Practical Quality), P7 (Speed & Token Efficiency)
|
|
14
|
+
|
|
12
15
|
Before implementing any non-trivial task, assess its complexity and run proportional pre-implementation analysis. This rule ensures the agent asks the right questions, discovers existing patterns to follow, and maps the full blast radius before writing code.
|
|
13
16
|
|
|
14
17
|
## Complexity Scoring
|
|
@@ -28,11 +31,13 @@ Score every task against these signals before implementation. Each signal adds w
|
|
|
28
31
|
|
|
29
32
|
### Tier Assignment
|
|
30
33
|
|
|
31
|
-
| Total Weight | Tier | Label |
|
|
32
|
-
|
|
33
|
-
| 0–2 | 1 | Light |
|
|
34
|
-
| 3–5 | 2 | Standard |
|
|
35
|
-
| 6+ | 3 | Deep |
|
|
34
|
+
| Total Weight | Tier | Label | Model Class (per-adapter) |
|
|
35
|
+
|-------------|------|-------|---------------------------|
|
|
36
|
+
| 0–2 | 1 | Light | economy |
|
|
37
|
+
| 3–5 | 2 | Standard | default |
|
|
38
|
+
| 6+ | 3 | Deep | strongest |
|
|
39
|
+
|
|
40
|
+
The **Model Class** column is an abstract effort lever: tier scales the model class the same way it scales researcher depth (`quick`/`deep`) and Phase 4 specialist depth — `economy` for cheap mechanical changes, `default` for routine multi-file work, `strongest` for high-blast-radius reasoning. It is a hint resolved per-adapter against that adapter's model map (`src/models/resolve.ts::resolveAgentModel`, `models.default`), not a literal model id — adapters with no model-routing surface ignore it. Model class is a first-order effort lever alongside depth (`hatch3r-agent-orchestration` -> Tier-to-Phase-4 specialist depth mapping).
|
|
36
41
|
|
|
37
42
|
## Tier Actions
|
|
38
43
|
|
|
@@ -93,24 +98,19 @@ This rule augments — not replaces — the existing Universal Sub-Agent Pipelin
|
|
|
93
98
|
|
|
94
99
|
## Scoring Examples
|
|
95
100
|
|
|
96
|
-
|
|
101
|
+
Worked examples that reconcile signals to a tier (only firing signals listed):
|
|
97
102
|
|
|
98
103
|
**Example 1: "Fix typo in error message" -- Tier 1 (score 0)**
|
|
99
104
|
No signals triggered. Single file, no cross-module impact, no ambiguity.
|
|
100
105
|
|
|
101
106
|
**Example 2: "Add email validation to signup form" -- Tier 2 (score 4)**
|
|
102
107
|
- Multiple layers touched (API + UI): +3
|
|
103
|
-
- Estimated 2-3 files: +0
|
|
104
|
-
- Input validation is security-adjacent but not in a security-sensitive area: +0
|
|
105
|
-
- Clear requirements ("validate email format"): +0
|
|
106
108
|
- May trigger cross-cutting i18n for error messages: +1 (partial cross-cutting)
|
|
109
|
+
- 2-3 files, clear requirements, input validation not in a security-sensitive area: +0 each
|
|
107
110
|
|
|
108
111
|
**Example 3: "Migrate auth from session-based to JWT" -- Tier 3 (score 12)**
|
|
109
112
|
- Multiple layers (auth middleware + API + UI + storage): +3
|
|
110
|
-
- Vague term "migrate" (
|
|
111
|
-
- Cross-cutting auth concern: +2
|
|
112
|
-
- Security-sensitive area: +2
|
|
113
|
-
- Behavioral contract change (session API to JWT API): +2
|
|
113
|
+
- Vague term "migrate", cross-cutting auth, security-sensitive area, behavioral contract change (session API to JWT API): +2 each
|
|
114
114
|
- Estimated >5 files: +1 (partial -- easily >5)
|
|
115
115
|
|
|
116
116
|
When a signal partially applies (e.g., "maybe 5 files, maybe 4"), round down. Tier upgrades from adaptation (see `hatch3r-agent-orchestration-detail`) compensate for underestimates.
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: Adaptive pre-implementation analysis — complexity scoring, requirements elicitation, similar implementation discovery, and transitive dependency tracing before coding
|
|
3
3
|
alwaysApply: true
|
|
4
|
+
precedence: high
|
|
4
5
|
---
|
|
5
6
|
# Deep Context Analysis
|
|
6
7
|
|
|
8
|
+
**Pillars:** P2 (Scientific & Practical Quality), P7 (Speed & Token Efficiency)
|
|
9
|
+
|
|
7
10
|
Before implementing any non-trivial task, assess its complexity and run proportional pre-implementation analysis. This rule ensures the agent asks the right questions, discovers existing patterns to follow, and maps the full blast radius before writing code.
|
|
8
11
|
|
|
9
12
|
## Complexity Scoring
|
|
@@ -23,11 +26,13 @@ Score every task against these signals before implementation. Each signal adds w
|
|
|
23
26
|
|
|
24
27
|
### Tier Assignment
|
|
25
28
|
|
|
26
|
-
| Total Weight | Tier | Label |
|
|
27
|
-
|
|
28
|
-
| 0–2 | 1 | Light |
|
|
29
|
-
| 3–5 | 2 | Standard |
|
|
30
|
-
| 6+ | 3 | Deep |
|
|
29
|
+
| Total Weight | Tier | Label | Model Class (per-adapter) |
|
|
30
|
+
|-------------|------|-------|---------------------------|
|
|
31
|
+
| 0–2 | 1 | Light | economy |
|
|
32
|
+
| 3–5 | 2 | Standard | default |
|
|
33
|
+
| 6+ | 3 | Deep | strongest |
|
|
34
|
+
|
|
35
|
+
The **Model Class** column is an abstract effort lever: tier scales the model class the same way it scales researcher depth (`quick`/`deep`) and Phase 4 specialist depth — `economy` for cheap mechanical changes, `default` for routine multi-file work, `strongest` for high-blast-radius reasoning. It is a hint resolved per-adapter against that adapter's model map (`src/models/resolve.ts::resolveAgentModel`, `models.default`), not a literal model id — adapters with no model-routing surface ignore it. Model class is a first-order effort lever alongside depth (`hatch3r-agent-orchestration` -> Tier-to-Phase-4 specialist depth mapping).
|
|
31
36
|
|
|
32
37
|
## Tier Actions
|
|
33
38
|
|
|
@@ -88,24 +93,19 @@ This rule augments — not replaces — the existing Universal Sub-Agent Pipelin
|
|
|
88
93
|
|
|
89
94
|
## Scoring Examples
|
|
90
95
|
|
|
91
|
-
|
|
96
|
+
Worked examples that reconcile signals to a tier (only firing signals listed):
|
|
92
97
|
|
|
93
98
|
**Example 1: "Fix typo in error message" -- Tier 1 (score 0)**
|
|
94
99
|
No signals triggered. Single file, no cross-module impact, no ambiguity.
|
|
95
100
|
|
|
96
101
|
**Example 2: "Add email validation to signup form" -- Tier 2 (score 4)**
|
|
97
102
|
- Multiple layers touched (API + UI): +3
|
|
98
|
-
- Estimated 2-3 files: +0
|
|
99
|
-
- Input validation is security-adjacent but not in a security-sensitive area: +0
|
|
100
|
-
- Clear requirements ("validate email format"): +0
|
|
101
103
|
- May trigger cross-cutting i18n for error messages: +1 (partial cross-cutting)
|
|
104
|
+
- 2-3 files, clear requirements, input validation not in a security-sensitive area: +0 each
|
|
102
105
|
|
|
103
106
|
**Example 3: "Migrate auth from session-based to JWT" -- Tier 3 (score 12)**
|
|
104
107
|
- Multiple layers (auth middleware + API + UI + storage): +3
|
|
105
|
-
- Vague term "migrate" (
|
|
106
|
-
- Cross-cutting auth concern: +2
|
|
107
|
-
- Security-sensitive area: +2
|
|
108
|
-
- Behavioral contract change (session API to JWT API): +2
|
|
108
|
+
- Vague term "migrate", cross-cutting auth, security-sensitive area, behavioral contract change (session API to JWT API): +2 each
|
|
109
109
|
- Estimated >5 files: +1 (partial -- easily >5)
|
|
110
110
|
|
|
111
111
|
When a signal partially applies (e.g., "maybe 5 files, maybe 4"), round down. Tier upgrades from adaptation (see `hatch3r-agent-orchestration-detail`) compensate for underestimates.
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: hatch3r-dependency-management
|
|
3
3
|
type: rule
|
|
4
|
-
description: Lockfile discipline, CVE scanning, transitive dependency audits, major version upgrade protocol,
|
|
5
|
-
scope:
|
|
4
|
+
description: Lockfile discipline, CVE scanning, transitive dependency audits, major version upgrade protocol, bundle-size impact gates, and SHA-pinned GitHub Action enforcement for package manifests and workflow files
|
|
5
|
+
scope: conditional
|
|
6
|
+
globs: "**/package.json,**/package-lock.json,**/yarn.lock,**/pnpm-lock.yaml,**/Cargo.toml,**/Cargo.lock,**/requirements*.txt,**/pyproject.toml,**/go.mod,**/go.sum,**/Gemfile*,**/.github/workflows/**,**/*.yml,**/*.yaml"
|
|
6
7
|
tags: [maintenance, floor:security]
|
|
7
8
|
precedence: high
|
|
8
9
|
quality_charter: agents/shared/quality-charter.md
|
|
@@ -13,7 +14,7 @@ cache_friendly: true
|
|
|
13
14
|
- Always commit the lockfile. Never install without saving.
|
|
14
15
|
- Justify new dependencies in PR description: what it does, why needed, alternatives considered, bundle size impact.
|
|
15
16
|
- Prefer well-maintained packages: recent commits, active issues, no known CVEs.
|
|
16
|
-
- Pin exact versions for production deps. Use clean install (e.g., `npm ci`, `pip install -r`, `cargo build`) in CI.
|
|
17
|
+
- Pin exact versions for production deps. Use clean install (e.g., `npm ci`, `pip install -r`, `cargo build`) in CI. **hatch3r dogfoods this:** the framework's own runtime dependencies in `package.json` -> `dependencies` are pinned to exact versions (no `^` or `~`), with dev-only deps free to float per ecosystem convention. See D15-M9 for the originating finding; `.github/workflows/ci.yml` step `npm ci` enforces lockfile-only installs.
|
|
17
18
|
- Run a dependency security scanner (e.g., `npm audit`, `pip-audit`, `cargo audit`) before merging dependency changes. Fix high/critical before merge.
|
|
18
19
|
- No duplicate packages serving the same purpose. Consolidate on one.
|
|
19
20
|
- Remove unused dependencies on every cleanup pass.
|
|
@@ -50,6 +51,8 @@ When trusted publishing is not yet enabled, publish with `npm publish --provenan
|
|
|
50
51
|
|
|
51
52
|
## SBOM Generation
|
|
52
53
|
|
|
54
|
+
> Maturity tier: team+ — solo projects may defer. Per-release SBOM publishing earns its cost once consumers or compliance audits depend on it.
|
|
55
|
+
|
|
53
56
|
Every release artifact ships a CycloneDX 1.6 or SPDX 3.0.1 SBOM, committed as a release asset and signed with the same Sigstore identity that signed the artifact. CycloneDX 1.6 is ECMA-424 ratified and broadly supported (Syft, Trivy, cdxgen, GitLab native). SPDX 3.0.1 is the BSI TR-03183-2 / EU CRA baseline.
|
|
54
57
|
|
|
55
58
|
- Tooling baseline: `npm sbom --sbom-format=cyclonedx` (npm 10+), `cdxgen` (broad ecosystem coverage including Python, Java, Rust, Go), `syft` (containers + source repos).
|
|
@@ -64,6 +67,14 @@ Target SLSA Build L3 for production release artifacts: ephemeral hosted runner,
|
|
|
64
67
|
- Deploy-time verification: `slsa-verifier` CLI confirms provenance, builder identity allow-list, and source-repo match before the artifact is consumed.
|
|
65
68
|
- Pin the generator action to a 40-char commit SHA per the action-pinning policy below.
|
|
66
69
|
|
|
70
|
+
### Defense-in-Depth Limit
|
|
71
|
+
|
|
72
|
+
SLSA L3 attests build-pipeline integrity — which pipeline produced the artifact — not source integrity. A compromised build step inside a legitimate L3 pipeline produces a validly-attested malicious artifact. In the Mini Shai-Hulud incident (May 2026) the attacker injected a payload into release tarballs after `package.json` modification but before the signing step; the published packages carried valid Sigstore provenance via the workflow's `id-token: write` OIDC token, and downstream consumers that verified the L3 attestation trusted the artifact. Do not treat a passing `slsa-verifier` check as sufficient. Layer it with:
|
|
73
|
+
|
|
74
|
+
- Pre-install behavioral scan of the resolved package (`socket.dev`, `osv-scanner`) — catches install-time payloads that provenance cannot.
|
|
75
|
+
- `minimumReleaseAge: 72` and `ignore-scripts=true` per the malicious-package section below — closes the propagation window and blocks lifecycle-script execution.
|
|
76
|
+
- Attestation identity verification, not just attestation presence: assert the signing identity (builder repo + workflow ref) matches the expected publisher, so a fork-built artifact fails even with valid provenance.
|
|
77
|
+
|
|
67
78
|
## Malicious-Package Detection Beyond `npm audit`
|
|
68
79
|
|
|
69
80
|
`npm audit` only flags published CVEs. The 2025-2026 incident class — Shai-Hulud (Sep-Nov 2025), Axios 1.14.1 maintainer hijack (Mar 2026), Mini-Shai-Hulud (May 2026), DevTap typosquat (Apr-May 2026) — never reaches a CVE filing. Layer install-time behavioral detection on top of `npm audit`:
|
|
@@ -83,6 +94,8 @@ Target SLSA Build L3 for production release artifacts: ephemeral hosted runner,
|
|
|
83
94
|
|
|
84
95
|
## License Compliance
|
|
85
96
|
|
|
97
|
+
> Maturity tier: team+ — solo projects may defer. A CI license gate matters once a team or downstream redistributes the artifact; a solo prototype with no redistribution can adopt it later.
|
|
98
|
+
|
|
86
99
|
- Allow-list (default): MIT, Apache-2.0, ISC, BSD-2-Clause, BSD-3-Clause, MPL-2.0, CC0-1.0. Project policy may extend.
|
|
87
100
|
- Deny-list (default): GPL-2.0, GPL-3.0, AGPL-3.0, AGPL-3.0-or-later, SSPL-1.0, Commons Clause. AGPL triggers copyleft on network use — it is the SaaS landmine.
|
|
88
101
|
- Override requires documented business justification in the PR description plus security/legal sign-off.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Lockfile discipline, CVE scanning, transitive dependency audits, major version upgrade protocol,
|
|
3
|
-
globs: ["**/package.json", "**/package-lock.json", "**/yarn.lock", "**/pnpm-lock.yaml", "**/Cargo.toml", "**/Cargo.lock", "**/requirements*.txt", "**/pyproject.toml", "**/go.mod", "**/go.sum", "**/Gemfile*"]
|
|
2
|
+
description: Lockfile discipline, CVE scanning, transitive dependency audits, major version upgrade protocol, bundle-size impact gates, and SHA-pinned GitHub Action enforcement for package manifests and workflow files
|
|
3
|
+
globs: ["**/package.json", "**/package-lock.json", "**/yarn.lock", "**/pnpm-lock.yaml", "**/Cargo.toml", "**/Cargo.lock", "**/requirements*.txt", "**/pyproject.toml", "**/go.mod", "**/go.sum", "**/Gemfile*", "**/.github/workflows/**", "**/*.yml", "**/*.yaml"]
|
|
4
4
|
alwaysApply: false
|
|
5
5
|
precedence: high
|
|
6
6
|
---
|
|
@@ -9,7 +9,7 @@ precedence: high
|
|
|
9
9
|
- Always commit the lockfile. Never install without saving.
|
|
10
10
|
- Justify new dependencies in PR description: what it does, why needed, alternatives considered, bundle size impact.
|
|
11
11
|
- Prefer well-maintained packages: recent commits, active issues, no known CVEs.
|
|
12
|
-
- Pin exact versions for production deps. Use clean install (e.g., `npm ci`, `pip install -r`, `cargo build`) in CI.
|
|
12
|
+
- Pin exact versions for production deps. Use clean install (e.g., `npm ci`, `pip install -r`, `cargo build`) in CI. **hatch3r dogfoods this:** the framework's own runtime dependencies in `package.json` -> `dependencies` are pinned to exact versions (no `^` or `~`), with dev-only deps free to float per ecosystem convention. See D15-M9 for the originating finding; `.github/workflows/ci.yml` step `npm ci` enforces lockfile-only installs.
|
|
13
13
|
- Run a dependency security scanner (e.g., `npm audit`, `pip-audit`, `cargo audit`) before merging dependency changes. Fix high/critical before merge.
|
|
14
14
|
- No duplicate packages serving the same purpose. Consolidate on one.
|
|
15
15
|
- Remove unused dependencies on every cleanup pass.
|
|
@@ -46,6 +46,8 @@ When trusted publishing is not yet enabled, publish with `npm publish --provenan
|
|
|
46
46
|
|
|
47
47
|
## SBOM Generation
|
|
48
48
|
|
|
49
|
+
> Maturity tier: team+ — solo projects may defer. Per-release SBOM publishing earns its cost once consumers or compliance audits depend on it.
|
|
50
|
+
|
|
49
51
|
Every release artifact ships a CycloneDX 1.6 or SPDX 3.0.1 SBOM, committed as a release asset and signed with the same Sigstore identity that signed the artifact. CycloneDX 1.6 is ECMA-424 ratified and broadly supported (Syft, Trivy, cdxgen, GitLab native). SPDX 3.0.1 is the BSI TR-03183-2 / EU CRA baseline.
|
|
50
52
|
|
|
51
53
|
- Tooling baseline: `npm sbom --sbom-format=cyclonedx` (npm 10+), `cdxgen` (broad ecosystem coverage including Python, Java, Rust, Go), `syft` (containers + source repos).
|
|
@@ -60,6 +62,14 @@ Target SLSA Build L3 for production release artifacts: ephemeral hosted runner,
|
|
|
60
62
|
- Deploy-time verification: `slsa-verifier` CLI confirms provenance, builder identity allow-list, and source-repo match before the artifact is consumed.
|
|
61
63
|
- Pin the generator action to a 40-char commit SHA per the action-pinning policy below.
|
|
62
64
|
|
|
65
|
+
### Defense-in-Depth Limit
|
|
66
|
+
|
|
67
|
+
SLSA L3 attests build-pipeline integrity — which pipeline produced the artifact — not source integrity. A compromised build step inside a legitimate L3 pipeline produces a validly-attested malicious artifact. In the Mini Shai-Hulud incident (May 2026) the attacker injected a payload into release tarballs after `package.json` modification but before the signing step; the published packages carried valid Sigstore provenance via the workflow's `id-token: write` OIDC token, and downstream consumers that verified the L3 attestation trusted the artifact. Do not treat a passing `slsa-verifier` check as sufficient. Layer it with:
|
|
68
|
+
|
|
69
|
+
- Pre-install behavioral scan of the resolved package (`socket.dev`, `osv-scanner`) — catches install-time payloads that provenance cannot.
|
|
70
|
+
- `minimumReleaseAge: 72` and `ignore-scripts=true` per the malicious-package section below — closes the propagation window and blocks lifecycle-script execution.
|
|
71
|
+
- Attestation identity verification, not just attestation presence: assert the signing identity (builder repo + workflow ref) matches the expected publisher, so a fork-built artifact fails even with valid provenance.
|
|
72
|
+
|
|
63
73
|
## Malicious-Package Detection Beyond `npm audit`
|
|
64
74
|
|
|
65
75
|
`npm audit` only flags published CVEs. The 2025-2026 incident class — Shai-Hulud (Sep-Nov 2025), Axios 1.14.1 maintainer hijack (Mar 2026), Mini-Shai-Hulud (May 2026), DevTap typosquat (Apr-May 2026) — never reaches a CVE filing. Layer install-time behavioral detection on top of `npm audit`:
|
|
@@ -79,6 +89,8 @@ Target SLSA Build L3 for production release artifacts: ephemeral hosted runner,
|
|
|
79
89
|
|
|
80
90
|
## License Compliance
|
|
81
91
|
|
|
92
|
+
> Maturity tier: team+ — solo projects may defer. A CI license gate matters once a team or downstream redistributes the artifact; a solo prototype with no redistribution can adopt it later.
|
|
93
|
+
|
|
82
94
|
- Allow-list (default): MIT, Apache-2.0, ISC, BSD-2-Clause, BSD-3-Clause, MPL-2.0, CC0-1.0. Project policy may extend.
|
|
83
95
|
- Deny-list (default): GPL-2.0, GPL-3.0, AGPL-3.0, AGPL-3.0-or-later, SSPL-1.0, Commons Clause. AGPL triggers copyleft on network use — it is the SaaS landmine.
|
|
84
96
|
- Override requires documented business justification in the PR description plus security/legal sign-off.
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
id: hatch3r-design-system-detection
|
|
3
3
|
type: rule
|
|
4
4
|
description: Mandatory detection of existing design tokens, theme primitives, and component library before AI agents author new UI components
|
|
5
|
-
scope:
|
|
5
|
+
scope: conditional
|
|
6
|
+
globs: "**/*.vue,**/*.jsx,**/*.tsx,**/*.svelte,**/*.css,**/*.scss,**/components/**,**/tokens*,**/theme*,**/design-system/**,**/tailwind*"
|
|
6
7
|
tags: [implementation, floor:ui-ux, ui, design-system, frontend]
|
|
7
8
|
precedence: high
|
|
8
9
|
quality_charter: agents/shared/quality-charter.md
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: hatch3r-dotnet-patterns
|
|
3
|
+
type: rule
|
|
4
|
+
description: .NET 9 + C# 13 conventions covering minimal APIs, nullable reference types, async/await, Entity Framework Core, dependency injection, structured logging, and xUnit testing
|
|
5
|
+
scope: conditional
|
|
6
|
+
globs: "**/*.cs,**/*.csproj,**/*.sln,**/*.fsproj,**/*.vbproj,**/Directory.Build.props,**/Directory.Build.targets,**/global.json,**/nuget.config,**/appsettings.json,**/appsettings.*.json,**/Program.cs,**/Startup.cs"
|
|
7
|
+
tags: [implementation]
|
|
8
|
+
quality_charter: agents/shared/quality-charter.md
|
|
9
|
+
cache_friendly: true
|
|
10
|
+
---
|
|
11
|
+
# .NET Patterns
|
|
12
|
+
|
|
13
|
+
**Pillars:** P2 (Scientific & Practical Quality), CQ8 (Maintainability Quality)
|
|
14
|
+
|
|
15
|
+
> Applies when the project ships a .NET / C# solution. Detection signals: `*.csproj` / `*.sln` files, `global.json`, or any `*.cs` source at repo root. Includes ASP.NET Core, console apps, libraries, and Blazor projects.
|
|
16
|
+
|
|
17
|
+
## .NET / C# Language Floor
|
|
18
|
+
|
|
19
|
+
- Target .NET 9.0 (LTS-supporting upgrade path) or the current LTS (.NET 8). Pin via `global.json` (`sdk.version`) and `*.csproj` `<TargetFramework>net9.0</TargetFramework>`.
|
|
20
|
+
- Use C# 13+ features: collection expressions (`[1, 2, 3]`), primary constructors on non-record classes, `params Span<T>`. Avoid mixing older syntax with new — pick the modern form across the codebase.
|
|
21
|
+
- Enable nullable reference types (`<Nullable>enable</Nullable>` in `*.csproj`). Treat warnings as errors: `<TreatWarningsAsErrors>true</TreatWarningsAsErrors>`.
|
|
22
|
+
- Use `Directory.Build.props` to centralize SDK version, lang version, code-analysis rules, and shared package versions across all projects.
|
|
23
|
+
|
|
24
|
+
## Project Layout
|
|
25
|
+
|
|
26
|
+
- Solution structure:
|
|
27
|
+
- `src/<ProjectName>/<ProjectName>.csproj` — main library / app projects.
|
|
28
|
+
- `src/<ProjectName>.Api/` — ASP.NET Core API projects.
|
|
29
|
+
- `tests/<ProjectName>.Tests/` — unit tests per project.
|
|
30
|
+
- `tests/<ProjectName>.IntegrationTests/` — integration tests with `WebApplicationFactory`.
|
|
31
|
+
- Use `Microsoft.NET.Sdk` (or `Microsoft.NET.Sdk.Web` for ASP.NET) — do not use the legacy `csproj` format. Configure central package management via `Directory.Packages.props` to lock NuGet versions across the solution.
|
|
32
|
+
- Public API exposed via top-level types; internal helpers marked `internal`. Use `InternalsVisibleTo` for test projects only.
|
|
33
|
+
|
|
34
|
+
## ASP.NET Core (Minimal APIs)
|
|
35
|
+
|
|
36
|
+
- Prefer Minimal APIs in `Program.cs` for new services — they reduce boilerplate and integrate with Native AOT.
|
|
37
|
+
- Use route groups (`app.MapGroup("/api/v1")`) with `RequireAuthorization()`, `AddEndpointFilter`, and `WithOpenApi()` modifiers. Versioning via route prefix or `Asp.Versioning.Http` package.
|
|
38
|
+
- Endpoint handlers receive parameters via attributes: `[FromBody]`, `[FromQuery]`, `[FromRoute]`, `[FromServices]`. Async handlers return `Results.Ok(...)`, `Results.Problem(...)`, `Results.ValidationProblem(...)` — never raw exceptions for expected error paths.
|
|
39
|
+
- For controllers: use `[ApiController]` with `[Route("api/[controller]")]`. Model binding + validation is automatic; opt out of `[ApiController]`-implied filters only when you need different conventions and document the rationale.
|
|
40
|
+
|
|
41
|
+
## Dependency Injection
|
|
42
|
+
|
|
43
|
+
- Built-in `IServiceCollection` is the floor. Register via lifetime-explicit methods: `AddSingleton`, `AddScoped`, `AddTransient`. Document the lifetime choice in a comment when non-obvious.
|
|
44
|
+
- Constructor injection only. Property injection via the framework is a smell — refactor to constructor injection or accept the value through a method parameter.
|
|
45
|
+
- Configuration via the `Options` pattern: `services.Configure<MyOptions>(config.GetSection("My"))`. Inject `IOptions<MyOptions>` (or `IOptionsMonitor<T>` for change-tolerant readers). Do not inject `IConfiguration` directly.
|
|
46
|
+
- Disposable singletons: the container disposes them on app shutdown. Never call `Dispose()` manually on a resolved singleton.
|
|
47
|
+
|
|
48
|
+
## Async / Await
|
|
49
|
+
|
|
50
|
+
- Use `async Task<T>` / `async ValueTask<T>` end-to-end. Never `.Result` / `.Wait()` — they deadlock under ASP.NET Core's synchronization context.
|
|
51
|
+
- Pass `CancellationToken` as a parameter; propagate through every layer. Endpoint handlers automatically receive `HttpContext.RequestAborted`.
|
|
52
|
+
- `ConfigureAwait(false)` on library code; `ConfigureAwait(true)` (default) in UI / ASP.NET handlers. The `Microsoft.VisualStudio.Threading.Analyzers` package catches missing `ConfigureAwait` in libraries.
|
|
53
|
+
- For parallel async work: `Task.WhenAll` (all must succeed) or `Parallel.ForEachAsync` (Bounded parallelism). Avoid `Task.Run` in ASP.NET — it consumes a thread-pool slot for no benefit.
|
|
54
|
+
|
|
55
|
+
## Entity Framework Core
|
|
56
|
+
|
|
57
|
+
- EF Core 9.x is the floor. Use `AddDbContextPool<>` for ASP.NET — context pooling reduces allocation overhead.
|
|
58
|
+
- Migrations: `dotnet ef migrations add <Name>` per schema change; check generated files into VCS. Never edit migration `Designer.cs` by hand.
|
|
59
|
+
- Query discipline: prefer projected `Select(x => new Dto { ... })` over fetching entities. Use `AsNoTracking()` for read-only queries — the change tracker is unnecessary overhead.
|
|
60
|
+
- Avoid `.Include().Include()` chains beyond one level — denormalize the query into a projection.
|
|
61
|
+
- Set timeouts: `dbContext.Database.SetCommandTimeout(TimeSpan.FromSeconds(30))`. Default is unbounded.
|
|
62
|
+
- Use raw SQL (`FromSqlInterpolated`) for queries EF can't express. Never string-concatenate user input into SQL; `FromSqlInterpolated` parameterizes correctly.
|
|
63
|
+
|
|
64
|
+
## Structured Logging
|
|
65
|
+
|
|
66
|
+
- Use `Microsoft.Extensions.Logging` with structured-message templates: `logger.LogInformation("User {UserId} created order {OrderId}", userId, orderId)`. Never use interpolated strings (`$"..."`) — they lose the structure.
|
|
67
|
+
- Pin a logging provider in production: Serilog (`Serilog.AspNetCore`) for the richest sink ecosystem, or OpenTelemetry exporter for vendor-neutral pipelines.
|
|
68
|
+
- Configure log levels per category in `appsettings.json`. `Microsoft.AspNetCore` → `Warning` in production to mute request-pipeline noise.
|
|
69
|
+
- Correlation IDs: enable `ActivityIdFormat = ActivityIdFormat.W3C` for W3C Trace Context. Every log entry includes the active trace ID automatically via `TraceContext` enrichment.
|
|
70
|
+
|
|
71
|
+
## Testing
|
|
72
|
+
|
|
73
|
+
- Unit tests with xUnit (`Microsoft.NET.Test.Sdk` + `xunit` + `xunit.runner.visualstudio`). Naming convention: `Method_State_ExpectedBehavior`.
|
|
74
|
+
- Use `FluentAssertions` for readable assertions — `result.Should().BeOfType<Ok<User>>()`.
|
|
75
|
+
- Mocking: NSubstitute (recommended) or Moq. Hand-rolled fakes for interfaces with ≤3 methods.
|
|
76
|
+
- Integration tests: `WebApplicationFactory<TEntryPoint>` from `Microsoft.AspNetCore.Mvc.Testing`. Replace external dependencies (database, cache) via `IServiceCollection` overrides in `ConfigureWebHost`. Use Testcontainers (`Testcontainers.PostgreSql`, `Testcontainers.Redis`) for real-database integration tests.
|
|
77
|
+
- Coverage: `dotnet test --collect:"XPlat Code Coverage"` with Coverlet. Floor: 80% line coverage in `src/`, 90% in critical modules (auth, billing, persistence).
|
|
78
|
+
|
|
79
|
+
## Native AOT & Performance
|
|
80
|
+
|
|
81
|
+
- Native AOT support (`PublishAot=true`) for cold-start-sensitive workloads (CLI tools, serverless). Audit dependencies — reflection-heavy packages (e.g., older Newtonsoft.Json paths) break AOT.
|
|
82
|
+
- Trimming (`PublishTrimmed=true`) for self-contained deploys to reduce binary size. Mark trim-unsafe APIs with `[RequiresUnreferencedCode]`.
|
|
83
|
+
- Use `Span<T>` / `Memory<T>` for hot-path buffer manipulation. `ArrayPool<T>.Shared` for transient large buffers to reduce GC pressure.
|
|
84
|
+
- Profile with `dotnet-trace` and `dotnet-counters` before optimizing.
|
|
85
|
+
|
|
86
|
+
## NuGet Hygiene
|
|
87
|
+
|
|
88
|
+
- Central package management: define versions once in `Directory.Packages.props` (`<PackageVersion Include="Foo" Version="1.2.3" />`). Per-project references then drop the `Version` attribute.
|
|
89
|
+
- Vulnerability scanning: `dotnet list package --vulnerable --include-transitive` in CI. Block merge on listed advisories.
|
|
90
|
+
- License compliance: `dotnet-project-licenses` tool with an allowlist. Block GPL contamination via the allowlist.
|
|
91
|
+
- Pin to released versions only — never `*` or floating prerelease versions.
|
|
92
|
+
|
|
93
|
+
## References
|
|
94
|
+
|
|
95
|
+
- .NET 9 release notes: https://learn.microsoft.com/en-us/dotnet/core/whats-new/dotnet-9 (accessed 2026-05-27, official-docs)
|
|
96
|
+
- ASP.NET Core Minimal APIs: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis/ (accessed 2026-05-27, official-docs)
|
|
97
|
+
- EF Core 9.x: https://learn.microsoft.com/en-us/ef/core/what-is-new/ (accessed 2026-05-27, official-docs)
|
|
98
|
+
- C# 13 features: https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-13 (accessed 2026-05-27, official-docs)
|
|
99
|
+
|
|
100
|
+
## Cross-References
|
|
101
|
+
|
|
102
|
+
- `rules/hatch3r-api-design.md` — REST/GraphQL/gRPC contract floors apply to ASP.NET Core services.
|
|
103
|
+
- `rules/hatch3r-testing.md` — coverage thresholds carry over to `dotnet test` + Coverlet.
|
|
104
|
+
- `rules/hatch3r-observability-logging.md` — `Microsoft.Extensions.Logging` integration with the canonical logging contract.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: .NET 9 + C# 13 conventions covering minimal APIs, nullable reference types, async/await, Entity Framework Core, dependency injection, structured logging, and xUnit testing
|
|
3
|
+
globs: ["**/*.cs", "**/*.csproj", "**/*.sln", "**/*.fsproj", "**/*.vbproj", "**/Directory.Build.props", "**/Directory.Build.targets", "**/global.json", "**/nuget.config", "**/appsettings.json", "**/appsettings.*.json", "**/Program.cs", "**/Startup.cs"]
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
# .NET Patterns
|
|
7
|
+
|
|
8
|
+
**Pillars:** P2 (Scientific & Practical Quality), CQ8 (Maintainability Quality)
|
|
9
|
+
|
|
10
|
+
> Applies when the project ships a .NET / C# solution. Detection signals: `*.csproj` / `*.sln` files, `global.json`, or any `*.cs` source at repo root. Includes ASP.NET Core, console apps, libraries, and Blazor projects.
|
|
11
|
+
|
|
12
|
+
## .NET / C# Language Floor
|
|
13
|
+
|
|
14
|
+
- Target .NET 9.0 (LTS-supporting upgrade path) or the current LTS (.NET 8). Pin via `global.json` (`sdk.version`) and `*.csproj` `<TargetFramework>net9.0</TargetFramework>`.
|
|
15
|
+
- Use C# 13+ features: collection expressions (`[1, 2, 3]`), primary constructors on non-record classes, `params Span<T>`. Avoid mixing older syntax with new — pick the modern form across the codebase.
|
|
16
|
+
- Enable nullable reference types (`<Nullable>enable</Nullable>` in `*.csproj`). Treat warnings as errors: `<TreatWarningsAsErrors>true</TreatWarningsAsErrors>`.
|
|
17
|
+
- Use `Directory.Build.props` to centralize SDK version, lang version, code-analysis rules, and shared package versions across all projects.
|
|
18
|
+
|
|
19
|
+
## Project Layout
|
|
20
|
+
|
|
21
|
+
- Solution structure:
|
|
22
|
+
- `src/<ProjectName>/<ProjectName>.csproj` — main library / app projects.
|
|
23
|
+
- `src/<ProjectName>.Api/` — ASP.NET Core API projects.
|
|
24
|
+
- `tests/<ProjectName>.Tests/` — unit tests per project.
|
|
25
|
+
- `tests/<ProjectName>.IntegrationTests/` — integration tests with `WebApplicationFactory`.
|
|
26
|
+
- Use `Microsoft.NET.Sdk` (or `Microsoft.NET.Sdk.Web` for ASP.NET) — do not use the legacy `csproj` format. Configure central package management via `Directory.Packages.props` to lock NuGet versions across the solution.
|
|
27
|
+
- Public API exposed via top-level types; internal helpers marked `internal`. Use `InternalsVisibleTo` for test projects only.
|
|
28
|
+
|
|
29
|
+
## ASP.NET Core (Minimal APIs)
|
|
30
|
+
|
|
31
|
+
- Prefer Minimal APIs in `Program.cs` for new services — they reduce boilerplate and integrate with Native AOT.
|
|
32
|
+
- Use route groups (`app.MapGroup("/api/v1")`) with `RequireAuthorization()`, `AddEndpointFilter`, and `WithOpenApi()` modifiers. Versioning via route prefix or `Asp.Versioning.Http` package.
|
|
33
|
+
- Endpoint handlers receive parameters via attributes: `[FromBody]`, `[FromQuery]`, `[FromRoute]`, `[FromServices]`. Async handlers return `Results.Ok(...)`, `Results.Problem(...)`, `Results.ValidationProblem(...)` — never raw exceptions for expected error paths.
|
|
34
|
+
- For controllers: use `[ApiController]` with `[Route("api/[controller]")]`. Model binding + validation is automatic; opt out of `[ApiController]`-implied filters only when you need different conventions and document the rationale.
|
|
35
|
+
|
|
36
|
+
## Dependency Injection
|
|
37
|
+
|
|
38
|
+
- Built-in `IServiceCollection` is the floor. Register via lifetime-explicit methods: `AddSingleton`, `AddScoped`, `AddTransient`. Document the lifetime choice in a comment when non-obvious.
|
|
39
|
+
- Constructor injection only. Property injection via the framework is a smell — refactor to constructor injection or accept the value through a method parameter.
|
|
40
|
+
- Configuration via the `Options` pattern: `services.Configure<MyOptions>(config.GetSection("My"))`. Inject `IOptions<MyOptions>` (or `IOptionsMonitor<T>` for change-tolerant readers). Do not inject `IConfiguration` directly.
|
|
41
|
+
- Disposable singletons: the container disposes them on app shutdown. Never call `Dispose()` manually on a resolved singleton.
|
|
42
|
+
|
|
43
|
+
## Async / Await
|
|
44
|
+
|
|
45
|
+
- Use `async Task<T>` / `async ValueTask<T>` end-to-end. Never `.Result` / `.Wait()` — they deadlock under ASP.NET Core's synchronization context.
|
|
46
|
+
- Pass `CancellationToken` as a parameter; propagate through every layer. Endpoint handlers automatically receive `HttpContext.RequestAborted`.
|
|
47
|
+
- `ConfigureAwait(false)` on library code; `ConfigureAwait(true)` (default) in UI / ASP.NET handlers. The `Microsoft.VisualStudio.Threading.Analyzers` package catches missing `ConfigureAwait` in libraries.
|
|
48
|
+
- For parallel async work: `Task.WhenAll` (all must succeed) or `Parallel.ForEachAsync` (Bounded parallelism). Avoid `Task.Run` in ASP.NET — it consumes a thread-pool slot for no benefit.
|
|
49
|
+
|
|
50
|
+
## Entity Framework Core
|
|
51
|
+
|
|
52
|
+
- EF Core 9.x is the floor. Use `AddDbContextPool<>` for ASP.NET — context pooling reduces allocation overhead.
|
|
53
|
+
- Migrations: `dotnet ef migrations add <Name>` per schema change; check generated files into VCS. Never edit migration `Designer.cs` by hand.
|
|
54
|
+
- Query discipline: prefer projected `Select(x => new Dto { ... })` over fetching entities. Use `AsNoTracking()` for read-only queries — the change tracker is unnecessary overhead.
|
|
55
|
+
- Avoid `.Include().Include()` chains beyond one level — denormalize the query into a projection.
|
|
56
|
+
- Set timeouts: `dbContext.Database.SetCommandTimeout(TimeSpan.FromSeconds(30))`. Default is unbounded.
|
|
57
|
+
- Use raw SQL (`FromSqlInterpolated`) for queries EF can't express. Never string-concatenate user input into SQL; `FromSqlInterpolated` parameterizes correctly.
|
|
58
|
+
|
|
59
|
+
## Structured Logging
|
|
60
|
+
|
|
61
|
+
- Use `Microsoft.Extensions.Logging` with structured-message templates: `logger.LogInformation("User {UserId} created order {OrderId}", userId, orderId)`. Never use interpolated strings (`$"..."`) — they lose the structure.
|
|
62
|
+
- Pin a logging provider in production: Serilog (`Serilog.AspNetCore`) for the richest sink ecosystem, or OpenTelemetry exporter for vendor-neutral pipelines.
|
|
63
|
+
- Configure log levels per category in `appsettings.json`. `Microsoft.AspNetCore` → `Warning` in production to mute request-pipeline noise.
|
|
64
|
+
- Correlation IDs: enable `ActivityIdFormat = ActivityIdFormat.W3C` for W3C Trace Context. Every log entry includes the active trace ID automatically via `TraceContext` enrichment.
|
|
65
|
+
|
|
66
|
+
## Testing
|
|
67
|
+
|
|
68
|
+
- Unit tests with xUnit (`Microsoft.NET.Test.Sdk` + `xunit` + `xunit.runner.visualstudio`). Naming convention: `Method_State_ExpectedBehavior`.
|
|
69
|
+
- Use `FluentAssertions` for readable assertions — `result.Should().BeOfType<Ok<User>>()`.
|
|
70
|
+
- Mocking: NSubstitute (recommended) or Moq. Hand-rolled fakes for interfaces with ≤3 methods.
|
|
71
|
+
- Integration tests: `WebApplicationFactory<TEntryPoint>` from `Microsoft.AspNetCore.Mvc.Testing`. Replace external dependencies (database, cache) via `IServiceCollection` overrides in `ConfigureWebHost`. Use Testcontainers (`Testcontainers.PostgreSql`, `Testcontainers.Redis`) for real-database integration tests.
|
|
72
|
+
- Coverage: `dotnet test --collect:"XPlat Code Coverage"` with Coverlet. Floor: 80% line coverage in `src/`, 90% in critical modules (auth, billing, persistence).
|
|
73
|
+
|
|
74
|
+
## Native AOT & Performance
|
|
75
|
+
|
|
76
|
+
- Native AOT support (`PublishAot=true`) for cold-start-sensitive workloads (CLI tools, serverless). Audit dependencies — reflection-heavy packages (e.g., older Newtonsoft.Json paths) break AOT.
|
|
77
|
+
- Trimming (`PublishTrimmed=true`) for self-contained deploys to reduce binary size. Mark trim-unsafe APIs with `[RequiresUnreferencedCode]`.
|
|
78
|
+
- Use `Span<T>` / `Memory<T>` for hot-path buffer manipulation. `ArrayPool<T>.Shared` for transient large buffers to reduce GC pressure.
|
|
79
|
+
- Profile with `dotnet-trace` and `dotnet-counters` before optimizing.
|
|
80
|
+
|
|
81
|
+
## NuGet Hygiene
|
|
82
|
+
|
|
83
|
+
- Central package management: define versions once in `Directory.Packages.props` (`<PackageVersion Include="Foo" Version="1.2.3" />`). Per-project references then drop the `Version` attribute.
|
|
84
|
+
- Vulnerability scanning: `dotnet list package --vulnerable --include-transitive` in CI. Block merge on listed advisories.
|
|
85
|
+
- License compliance: `dotnet-project-licenses` tool with an allowlist. Block GPL contamination via the allowlist.
|
|
86
|
+
- Pin to released versions only — never `*` or floating prerelease versions.
|
|
87
|
+
|
|
88
|
+
## References
|
|
89
|
+
|
|
90
|
+
- .NET 9 release notes: https://learn.microsoft.com/en-us/dotnet/core/whats-new/dotnet-9 (accessed 2026-05-27, official-docs)
|
|
91
|
+
- ASP.NET Core Minimal APIs: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis/ (accessed 2026-05-27, official-docs)
|
|
92
|
+
- EF Core 9.x: https://learn.microsoft.com/en-us/ef/core/what-is-new/ (accessed 2026-05-27, official-docs)
|
|
93
|
+
- C# 13 features: https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-13 (accessed 2026-05-27, official-docs)
|
|
94
|
+
|
|
95
|
+
## Cross-References
|
|
96
|
+
|
|
97
|
+
- `rules/hatch3r-api-design.md` — REST/GraphQL/gRPC contract floors apply to ASP.NET Core services.
|
|
98
|
+
- `rules/hatch3r-testing.md` — coverage thresholds carry over to `dotnet test` + Coverlet.
|
|
99
|
+
- `rules/hatch3r-observability-logging.md` — `Microsoft.Extensions.Logging` integration with the canonical logging contract.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: hatch3r-edge-case-discipline
|
|
3
|
+
type: rule
|
|
4
|
+
description: Build-time enumeration of domain/data-correctness edge cases (cardinality, null/empty/boundary, cross-entity consistency, illegal state transitions, concurrency, partial failure) plus language-agnostic error-handling discipline — fires at Plan, Implement, and Review
|
|
5
|
+
tags: [implementation, reliability, testing, floor:content-quality]
|
|
6
|
+
scope: always
|
|
7
|
+
precedence: high
|
|
8
|
+
quality_charter: agents/shared/quality-charter.md
|
|
9
|
+
cache_friendly: true
|
|
10
|
+
---
|
|
11
|
+
# Edge-Case & Error-Handling Discipline
|
|
12
|
+
|
|
13
|
+
**Pillars:** P2 (Scientific Quality)
|
|
14
|
+
|
|
15
|
+
This rule fires whenever a feature wires together ≥2 domain entities, or whenever a function consumes external or user-supplied input. Edge-case enumeration becomes a named build-time step, not a runtime afterthought. `rules/hatch3r-resilience-patterns.md` keeps a correct system *available* under failure (breakers, retries, fallbacks); this rule keeps the system *correct* in the first place — the two complement each other and do not overlap.
|
|
16
|
+
|
|
17
|
+
## When This Fires
|
|
18
|
+
|
|
19
|
+
- **Plan:** before writing code, enumerate edge cases from the taxonomy below for every entity and every cross-entity relationship the feature touches. List them as explicit named cases (e.g. `case: two contacts collide on email + linked property`), never the placeholder "handle edge cases".
|
|
20
|
+
- **Implement:** each enumerated case is handled in code OR explicitly recorded out-of-scope with a one-line reason. No silent omission — an unlisted case is a gap, an unhandled-but-listed case needs the recorded reason.
|
|
21
|
+
- **Review:** reject the change if any taxonomy category was not enumerated for an entity-wiring feature, or an enumerated case has neither handling nor a recorded out-of-scope reason. Maps to a Medium-or-higher finding per `agents/shared/quality-charter.md` §14.
|
|
22
|
+
|
|
23
|
+
## Domain Edge-Case Taxonomy
|
|
24
|
+
|
|
25
|
+
Seven categories. For each: the question to ask, then a worked example in the real-estate domain (properties + contacts + reservations + deals).
|
|
26
|
+
|
|
27
|
+
1. **Cardinality & duplicates** — for each relationship, what happens at zero, exactly-one, and N? Can two records collide on a natural key? Worked example: two contacts share the same email AND the same linked property but carry a different status — decide the dedup key and the tie-break rule (latest-updated wins, or merge) before writing the join, or the query returns a nondeterministic row.
|
|
28
|
+
|
|
29
|
+
2. **Null / empty / zero / boundary** — apply boundary-value analysis (Min−1, Min, Max, Max+1) and equivalence partitioning to every numeric, string, and collection input. Worked example: a deal with `amount = 0`, a reservation with an empty date range (`start == end`), a property with zero linked contacts, a name string at the column-length limit and one byte over.
|
|
30
|
+
|
|
31
|
+
3. **Cross-entity consistency & referential integrity** — if A references B, can B be missing, deleted, or in an invalid state when A is read? Worked example: a reservation pointing at an archived property; a deal whose contact was merged into another contact. Define cascade vs restrict vs orphan handling explicitly for each foreign reference; the default of an unhandled dangling reference is a 500 at read time.
|
|
32
|
+
|
|
33
|
+
4. **Illegal state transitions** — model the entity lifecycle as an explicit state set, enumerate the legal transitions, and reject the rest at construction and at transition time. Worked example: a deal moving `closed → pending`; a reservation marked `confirmed` on a `withdrawn` listing. Apply make-illegal-states-unrepresentable / parse-don't-validate: validate once at the boundary, then the constructed type carries the proof so downstream code cannot re-encounter the illegal state.
|
|
34
|
+
|
|
35
|
+
5. **Concurrency & ordering** — two writers modify the same record, or events arrive out of order. Worked example: two agents accept the same reservation slot at the same instant. Name the concurrency-control choice (optimistic version column, row lock, or idempotency key) at design time; "last write wins by accident" is not a choice. Cross-link `rules/hatch3r-scalability.md` and `rules/hatch3r-resilience-patterns.md`.
|
|
36
|
+
|
|
37
|
+
6. **Partial failure across layers** — a single logical write spans cache + DB + queue + external API; what is the state when step 3 of 4 fails? Worked example: a deal is persisted to the DB, the cache is updated, the "deal-won" event is published, and the external CRM sync then times out. Define the consistency boundary (transaction, saga, or transactional outbox) and the compensating action. Cross-link `rules/hatch3r-resilience-patterns.md` failure classification.
|
|
38
|
+
|
|
39
|
+
7. **Idempotency on replay / retry** — if the operation runs twice with the same input, is the second run a no-op? Required for any non-idempotent mutation reachable by a retry. Worked example: a retried "create reservation" call must not create two reservations for one slot. Cross-link `rules/hatch3r-resilience-patterns.md` → idempotency-key.
|
|
40
|
+
|
|
41
|
+
The seven categories are a floor, not a ceiling: enumerate domain-specific invariants alongside them (e.g. "a property has at most one active deal", "a reservation date range never overlaps another confirmed reservation on the same property").
|
|
42
|
+
|
|
43
|
+
## Error-Handling Discipline
|
|
44
|
+
|
|
45
|
+
Language-agnostic principles; complements `rules/hatch3r-code-standards.md` and does not restate its TypeScript mechanics.
|
|
46
|
+
|
|
47
|
+
- **Placement:** catch at architectural boundaries only (route handler, event handler, job processor, UI error boundary); let errors propagate within a module. Defer to `rules/hatch3r-code-standards.md` → Error Boundaries for the full pattern and the TS Result-type mechanics.
|
|
48
|
+
- **Propagation with context:** every re-throw or wrap attaches the failing operation plus the relevant identifiers (entity id, correlation id — no PII, no secrets) and preserves the original cause chain. A wrap that drops the cause is a finding.
|
|
49
|
+
- **Exhaustive matching:** every discriminated union, enum, and explicit state set is matched exhaustively with a compile-time-checked default, so adding a variant breaks the build rather than falling through silently. Cross-link `rules/hatch3r-code-standards.md` → exhaustive `switch` + `never`.
|
|
50
|
+
- **Recovery vs fail-fast triage:** classify each failure as recoverable (fallback or degrade — cross-link `rules/hatch3r-resilience-patterns.md` → Graceful Degradation) or unrecoverable (fail fast with an actionable message — cross-link `agents/shared/quality-charter.md` §6). No catch block treats both alike.
|
|
51
|
+
- **No silent catch (hard rule):** an empty catch, a catch that returns `null` or a default for every error, and swallow-and-continue are all prohibited. Defer to the `rules/hatch3r-code-standards.md` Error Handling Anti-Patterns table for the canonical prohibited list. This ties to `agents/shared/quality-charter.md` §6 (never fail silently) and §8 (a case that cannot be handled at build time is a clarification trigger, not a guess).
|
|
52
|
+
|
|
53
|
+
## Cross-References
|
|
54
|
+
|
|
55
|
+
- `rules/hatch3r-code-standards.md` — Result types, custom error classes, exhaustive `switch` + `never`, error anti-pattern table (the TS mechanics this rule references rather than restates).
|
|
56
|
+
- `rules/hatch3r-resilience-patterns.md` — failure classification, idempotency-on-retry, graceful degradation (run-time resilience; this rule is build-time correctness).
|
|
57
|
+
- `rules/hatch3r-testing.md` — every enumerated edge case maps to a required test class per the Per-Feature Mandate Map and Error Path Coverage.
|
|
58
|
+
- `rules/hatch3r-scalability.md` — idempotency-key adoption on mutations.
|
|
59
|
+
- `rules/hatch3r-migrations.md` — concurrent-modification and referential-integrity handling at the schema layer.
|
|
60
|
+
- `agents/shared/quality-charter.md` — §6 (Fail Gracefully), §8 (Escalate Ambiguity Early), §13 (Adversarial Thinking).
|
|
61
|
+
|
|
62
|
+
## References
|
|
63
|
+
|
|
64
|
+
- ISTQB Certified Tester Foundation Level syllabus — Boundary Value Analysis + Equivalence Partitioning — `https://www.istqb.org/certifications/certified-tester-foundation-level` (accessed 2026-06-02, official-standards-body).
|
|
65
|
+
- Alexis King, "Parse, Don't Validate" — `https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/` (accessed 2026-06-02, named-author primary source).
|