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.
Files changed (288) hide show
  1. package/README.md +52 -143
  2. package/dist/cli/index.js +28453 -15831
  3. package/dist/content/agents/hatch3r-architect.md +39 -9
  4. package/dist/content/agents/hatch3r-brownfield-spec.md +254 -0
  5. package/dist/content/agents/hatch3r-ci-watcher.md +8 -1
  6. package/dist/content/agents/hatch3r-context-rules.md +19 -1
  7. package/dist/content/agents/hatch3r-creator.md +65 -26
  8. package/dist/content/agents/hatch3r-dependency-drafter.md +162 -0
  9. package/dist/content/agents/hatch3r-devops.md +11 -1
  10. package/dist/content/agents/hatch3r-docs-writer.md +11 -1
  11. package/dist/content/agents/hatch3r-edge-case-analyst.md +134 -0
  12. package/dist/content/agents/hatch3r-enhancability.md +192 -0
  13. package/dist/content/agents/hatch3r-fixer.md +59 -8
  14. package/dist/content/agents/hatch3r-greenfield-spec.md +256 -0
  15. package/dist/content/agents/hatch3r-handoff-loader.md +29 -3
  16. package/dist/content/agents/hatch3r-handoff-preparer.md +10 -1
  17. package/dist/content/agents/hatch3r-implementer.md +139 -8
  18. package/dist/content/agents/hatch3r-incident-responder.md +96 -0
  19. package/dist/content/agents/hatch3r-learnings-loader.md +122 -88
  20. package/dist/content/agents/hatch3r-lint-fixer.md +15 -3
  21. package/dist/content/agents/hatch3r-maintainability.md +183 -0
  22. package/dist/content/agents/hatch3r-pack-installer.md +113 -0
  23. package/dist/content/agents/hatch3r-performance.md +179 -0
  24. package/dist/content/agents/hatch3r-reliability.md +193 -0
  25. package/dist/content/agents/hatch3r-researcher.md +27 -4
  26. package/dist/content/agents/hatch3r-reviewer.md +153 -103
  27. package/dist/content/agents/hatch3r-scalability.md +162 -0
  28. package/dist/content/agents/hatch3r-security.md +197 -0
  29. package/dist/content/agents/hatch3r-testability.md +204 -0
  30. package/dist/content/agents/hatch3r-ui.md +175 -0
  31. package/dist/content/agents/hatch3r-ux.md +160 -0
  32. package/dist/content/agents/modes/requirements-elicitation.md +1 -1
  33. package/dist/content/agents/modes/user-flows.md +2 -2
  34. package/dist/content/agents/shared/clarification-default-block.md +44 -0
  35. package/dist/content/agents/shared/confidence-gate.md +42 -0
  36. package/dist/content/agents/shared/cq-specialist-roster.md +26 -0
  37. package/dist/content/agents/shared/efficiency-patterns.md +32 -1
  38. package/dist/content/agents/shared/injection-patterns.md +18 -7
  39. package/dist/content/agents/shared/principles.md +60 -0
  40. package/dist/content/agents/shared/prompt-structure.md +7 -1
  41. package/dist/content/agents/shared/quality-charter.md +48 -12
  42. package/dist/content/agents/shared/quality-specialist-frame.md +141 -0
  43. package/dist/content/agents/shared/rigor-contract.md +151 -0
  44. package/dist/content/agents/shared/severity-mapping.md +92 -0
  45. package/dist/content/agents/shared/triage-vocabulary.md +46 -0
  46. package/dist/content/agents/shared/user-content-templates.md +34 -8
  47. package/dist/content/agents/shared/user-question-protocol.md +45 -3
  48. package/dist/content/checks/README.md +5 -0
  49. package/dist/content/checks/accessibility.md +14 -7
  50. package/dist/content/checks/code-quality.md +1 -1
  51. package/dist/content/checks/performance.md +7 -4
  52. package/dist/content/checks/security.md +6 -6
  53. package/dist/content/checks/testing.md +1 -1
  54. package/dist/content/commands/board/pickup-delegation-multi.md +37 -10
  55. package/dist/content/commands/board/pickup-delegation.md +7 -5
  56. package/dist/content/commands/board/pickup-modes.md +1 -0
  57. package/dist/content/commands/board/pickup-post-impl.md +1 -1
  58. package/dist/content/commands/hatch3r-api-spec.md +79 -2
  59. package/dist/content/commands/hatch3r-auth-scaffold.md +250 -0
  60. package/dist/content/commands/hatch3r-benchmark.md +90 -7
  61. package/dist/content/commands/hatch3r-board-fill.md +97 -11
  62. package/dist/content/commands/hatch3r-board-pickup.md +93 -9
  63. package/dist/content/commands/hatch3r-bug-pipeline.md +240 -0
  64. package/dist/content/commands/hatch3r-bug-plan.md +79 -3
  65. package/dist/content/commands/hatch3r-codebase-map.md +80 -4
  66. package/dist/content/commands/hatch3r-create.md +105 -7
  67. package/dist/content/commands/hatch3r-debug.md +102 -14
  68. package/dist/content/commands/hatch3r-diagnose.md +238 -0
  69. package/dist/content/commands/hatch3r-feature-plan.md +125 -5
  70. package/dist/content/commands/hatch3r-handoff.md +83 -3
  71. package/dist/content/commands/hatch3r-healthcheck.md +105 -5
  72. package/dist/content/commands/hatch3r-incident-response.md +228 -0
  73. package/dist/content/commands/hatch3r-migration-plan.md +79 -3
  74. package/dist/content/commands/hatch3r-onboard.md +94 -3
  75. package/dist/content/commands/hatch3r-pack-install.md +243 -0
  76. package/dist/content/commands/hatch3r-pr-resolve.md +106 -23
  77. package/dist/content/commands/hatch3r-project-spec.md +82 -6
  78. package/dist/content/commands/hatch3r-quick-change.md +108 -13
  79. package/dist/content/commands/hatch3r-refactor-plan.md +78 -2
  80. package/dist/content/commands/hatch3r-release.md +401 -0
  81. package/dist/content/commands/hatch3r-revision.md +98 -12
  82. package/dist/content/commands/hatch3r-roadmap.md +92 -10
  83. package/dist/content/commands/hatch3r-security-audit.md +105 -5
  84. package/dist/content/commands/hatch3r-slo-scaffold.md +246 -0
  85. package/dist/content/commands/hatch3r-spec.md +216 -0
  86. package/dist/content/commands/hatch3r-test-plan.md +85 -9
  87. package/dist/content/commands/hatch3r-workflow.md +165 -41
  88. package/dist/content/commands/revision/revision-delegation.md +6 -5
  89. package/dist/content/commands/revision/revision-modes.md +49 -4
  90. package/dist/content/commands/revision/revision-quality.md +10 -7
  91. package/dist/content/commands/shared/orchestration-frame.md +119 -0
  92. package/dist/content/github-agents/hatch3r-docs-agent.md +21 -1
  93. package/dist/content/github-agents/hatch3r-lint-agent.md +21 -1
  94. package/dist/content/github-agents/hatch3r-security-agent.md +21 -1
  95. package/dist/content/github-agents/hatch3r-test-agent.md +21 -1
  96. package/dist/content/hooks/hatch3r-file-save.md +1 -1
  97. package/dist/content/hooks/hatch3r-pre-push.md +4 -4
  98. package/dist/content/hooks/hatch3r-review-loop-cap.md +52 -0
  99. package/dist/content/mcp/mcp.json +7 -5
  100. package/dist/content/rules/hatch3r-accessibility-standards.md +14 -2
  101. package/dist/content/rules/hatch3r-accessibility-standards.mdc +12 -1
  102. package/dist/content/rules/hatch3r-agent-orchestration-detail.md +58 -19
  103. package/dist/content/rules/hatch3r-agent-orchestration-detail.mdc +58 -19
  104. package/dist/content/rules/hatch3r-agent-orchestration.md +87 -213
  105. package/dist/content/rules/hatch3r-agent-orchestration.mdc +87 -213
  106. package/dist/content/rules/hatch3r-ai-evals.md +5 -4
  107. package/dist/content/rules/hatch3r-ai-evals.mdc +3 -3
  108. package/dist/content/rules/hatch3r-ai-ux-patterns.md +6 -2
  109. package/dist/content/rules/hatch3r-ai-ux-patterns.mdc +4 -1
  110. package/dist/content/rules/hatch3r-android-patterns.md +107 -0
  111. package/dist/content/rules/hatch3r-android-patterns.mdc +102 -0
  112. package/dist/content/rules/hatch3r-anti-duplication.md +115 -0
  113. package/dist/content/rules/hatch3r-anti-duplication.mdc +115 -0
  114. package/dist/content/rules/hatch3r-api-design.md +5 -1
  115. package/dist/content/rules/hatch3r-api-design.mdc +3 -0
  116. package/dist/content/rules/hatch3r-api-versioning.md +2 -1
  117. package/dist/content/rules/hatch3r-auth-patterns.md +3 -1
  118. package/dist/content/rules/hatch3r-auth-patterns.mdc +1 -0
  119. package/dist/content/rules/hatch3r-browser-verification.md +2 -0
  120. package/dist/content/rules/hatch3r-browser-verification.mdc +2 -0
  121. package/dist/content/rules/hatch3r-capability-matrix.md +108 -0
  122. package/dist/content/rules/hatch3r-capability-matrix.mdc +108 -0
  123. package/dist/content/rules/hatch3r-ci-cd.md +8 -1
  124. package/dist/content/rules/hatch3r-ci-cd.mdc +6 -0
  125. package/dist/content/rules/hatch3r-clarification-default.md +73 -0
  126. package/dist/content/rules/hatch3r-clarification-default.mdc +73 -0
  127. package/dist/content/rules/hatch3r-code-standards.md +23 -47
  128. package/dist/content/rules/hatch3r-code-standards.mdc +22 -46
  129. package/dist/content/rules/hatch3r-component-conventions.md +3 -0
  130. package/dist/content/rules/hatch3r-component-conventions.mdc +3 -0
  131. package/dist/content/rules/hatch3r-container-hardening.md +11 -2
  132. package/dist/content/rules/hatch3r-container-hardening.mdc +9 -1
  133. package/dist/content/rules/hatch3r-contract-testing.md +2 -1
  134. package/dist/content/rules/hatch3r-cost-visibility.md +135 -0
  135. package/dist/content/rules/hatch3r-cost-visibility.mdc +135 -0
  136. package/dist/content/rules/hatch3r-cq-rule-frame.md +54 -0
  137. package/dist/content/rules/hatch3r-cq-rule-frame.mdc +49 -0
  138. package/dist/content/rules/hatch3r-data-classification.md +3 -1
  139. package/dist/content/rules/hatch3r-data-classification.mdc +2 -1
  140. package/dist/content/rules/hatch3r-deep-context.md +13 -13
  141. package/dist/content/rules/hatch3r-deep-context.mdc +13 -13
  142. package/dist/content/rules/hatch3r-dependency-management.md +16 -3
  143. package/dist/content/rules/hatch3r-dependency-management.mdc +15 -3
  144. package/dist/content/rules/hatch3r-design-system-detection.md +2 -1
  145. package/dist/content/rules/hatch3r-dotnet-patterns.md +104 -0
  146. package/dist/content/rules/hatch3r-dotnet-patterns.mdc +99 -0
  147. package/dist/content/rules/hatch3r-edge-case-discipline.md +65 -0
  148. package/dist/content/rules/hatch3r-edge-case-discipline.mdc +65 -0
  149. package/dist/content/rules/hatch3r-enhancability.md +147 -0
  150. package/dist/content/rules/hatch3r-enhancability.mdc +142 -0
  151. package/dist/content/rules/hatch3r-event-schema-evolution.md +2 -1
  152. package/dist/content/rules/hatch3r-fan-out-discipline.md +91 -0
  153. package/dist/content/rules/hatch3r-fan-out-discipline.mdc +91 -0
  154. package/dist/content/rules/hatch3r-feature-flags.md +2 -0
  155. package/dist/content/rules/hatch3r-feature-flags.mdc +2 -0
  156. package/dist/content/rules/hatch3r-flutter-patterns.md +88 -0
  157. package/dist/content/rules/hatch3r-flutter-patterns.mdc +83 -0
  158. package/dist/content/rules/hatch3r-git-conventions.md +4 -1
  159. package/dist/content/rules/hatch3r-git-conventions.mdc +2 -0
  160. package/dist/content/rules/hatch3r-go-patterns.md +98 -0
  161. package/dist/content/rules/hatch3r-go-patterns.mdc +93 -0
  162. package/dist/content/rules/hatch3r-handoff-readiness.md +10 -0
  163. package/dist/content/rules/hatch3r-handoff-readiness.mdc +10 -0
  164. package/dist/content/rules/hatch3r-i18n.md +2 -0
  165. package/dist/content/rules/hatch3r-i18n.mdc +2 -0
  166. package/dist/content/rules/hatch3r-iteration-summary.md +75 -57
  167. package/dist/content/rules/hatch3r-iteration-summary.mdc +77 -54
  168. package/dist/content/rules/hatch3r-learning-system.md +202 -0
  169. package/dist/content/rules/hatch3r-learning-system.mdc +202 -0
  170. package/dist/content/rules/hatch3r-maintainability.md +157 -0
  171. package/dist/content/rules/hatch3r-maintainability.mdc +152 -0
  172. package/dist/content/rules/hatch3r-migrations.md +2 -1
  173. package/dist/content/rules/hatch3r-observability-logging.md +1 -1
  174. package/dist/content/rules/hatch3r-observability-metrics.md +1 -1
  175. package/dist/content/rules/hatch3r-observability-tracing.md +45 -36
  176. package/dist/content/rules/hatch3r-observability-tracing.mdc +44 -35
  177. package/dist/content/rules/hatch3r-operability.md +2 -1
  178. package/dist/content/rules/hatch3r-passkey-server.md +2 -1
  179. package/dist/content/rules/hatch3r-performance-budgets.md +2 -0
  180. package/dist/content/rules/hatch3r-performance-budgets.mdc +2 -0
  181. package/dist/content/rules/hatch3r-php-laravel-patterns.md +109 -0
  182. package/dist/content/rules/hatch3r-php-laravel-patterns.mdc +104 -0
  183. package/dist/content/rules/hatch3r-progressive-delivery.md +5 -1
  184. package/dist/content/rules/hatch3r-progressive-delivery.mdc +3 -0
  185. package/dist/content/rules/hatch3r-proof-model.md +131 -0
  186. package/dist/content/rules/hatch3r-proof-model.mdc +131 -0
  187. package/dist/content/rules/hatch3r-python-patterns.md +70 -0
  188. package/dist/content/rules/hatch3r-python-patterns.mdc +65 -0
  189. package/dist/content/rules/hatch3r-react-native-patterns.md +83 -0
  190. package/dist/content/rules/hatch3r-react-native-patterns.mdc +78 -0
  191. package/dist/content/rules/hatch3r-resilience-patterns.md +2 -1
  192. package/dist/content/rules/hatch3r-reviewer-calibration.md +84 -0
  193. package/dist/content/rules/hatch3r-reviewer-calibration.mdc +84 -0
  194. package/dist/content/rules/hatch3r-right-sizing.md +68 -0
  195. package/dist/content/rules/hatch3r-right-sizing.mdc +66 -0
  196. package/dist/content/rules/hatch3r-ruby-rails-patterns.md +111 -0
  197. package/dist/content/rules/hatch3r-ruby-rails-patterns.mdc +106 -0
  198. package/dist/content/rules/hatch3r-rust-patterns.md +107 -0
  199. package/dist/content/rules/hatch3r-rust-patterns.mdc +102 -0
  200. package/dist/content/rules/hatch3r-scalability.md +137 -0
  201. package/dist/content/rules/hatch3r-scalability.mdc +132 -0
  202. package/dist/content/rules/hatch3r-secrets-management.md +10 -1
  203. package/dist/content/rules/hatch3r-secrets-management.mdc +8 -0
  204. package/dist/content/rules/hatch3r-security-patterns.md +36 -34
  205. package/dist/content/rules/hatch3r-security-patterns.mdc +35 -34
  206. package/dist/content/rules/hatch3r-security.md +97 -0
  207. package/dist/content/rules/hatch3r-security.mdc +92 -0
  208. package/dist/content/rules/hatch3r-swiftui-patterns.md +98 -0
  209. package/dist/content/rules/hatch3r-swiftui-patterns.mdc +93 -0
  210. package/dist/content/rules/hatch3r-testability.md +115 -0
  211. package/dist/content/rules/hatch3r-testability.mdc +110 -0
  212. package/dist/content/rules/hatch3r-testing.md +4 -1
  213. package/dist/content/rules/hatch3r-testing.mdc +2 -0
  214. package/dist/content/rules/hatch3r-theming.md +2 -0
  215. package/dist/content/rules/hatch3r-theming.mdc +2 -0
  216. package/dist/content/rules/hatch3r-tool-currency.md +91 -0
  217. package/dist/content/rules/hatch3r-tool-currency.mdc +86 -0
  218. package/dist/content/rules/hatch3r-tooling-hierarchy.md +29 -31
  219. package/dist/content/rules/hatch3r-tooling-hierarchy.mdc +27 -30
  220. package/dist/content/rules/hatch3r-typescript-patterns.md +58 -0
  221. package/dist/content/rules/hatch3r-typescript-patterns.mdc +53 -0
  222. package/dist/content/rules/hatch3r-ux-states-and-flows.md +11 -4
  223. package/dist/content/rules/hatch3r-ux-states-and-flows.mdc +9 -3
  224. package/dist/content/skills/hatch3r-a11y-audit/SKILL.md +10 -8
  225. package/dist/content/skills/hatch3r-a11y-audit/references/manual-audit-checklist.md +7 -5
  226. package/dist/content/skills/hatch3r-adhoc-orchestrate/SKILL.md +131 -0
  227. package/dist/content/skills/hatch3r-ai-feature/SKILL.md +4 -6
  228. package/dist/content/skills/hatch3r-api-spec/SKILL.md +27 -2
  229. package/dist/content/skills/hatch3r-architecture-review/SKILL.md +4 -7
  230. package/dist/content/skills/hatch3r-board-groom/SKILL.md +11 -0
  231. package/dist/content/skills/hatch3r-board-init/SKILL.md +17 -1
  232. package/dist/content/skills/hatch3r-board-refresh/SKILL.md +12 -1
  233. package/dist/content/skills/hatch3r-board-shared/SKILL.md +38 -1
  234. package/dist/content/skills/hatch3r-browser-verify/SKILL.md +307 -0
  235. package/dist/content/skills/hatch3r-bug-fix/SKILL.md +15 -2
  236. package/dist/content/skills/hatch3r-ci-pipeline/SKILL.md +17 -7
  237. package/dist/content/skills/hatch3r-cli-fd/SKILL.md +33 -1
  238. package/dist/content/skills/hatch3r-cli-fzf/SKILL.md +33 -1
  239. package/dist/content/skills/hatch3r-cli-gh/SKILL.md +50 -1
  240. package/dist/content/skills/hatch3r-cli-jq/SKILL.md +40 -6
  241. package/dist/content/skills/hatch3r-cli-ripgrep/SKILL.md +33 -1
  242. package/dist/content/skills/hatch3r-cli-toolbox/SKILL.md +130 -23
  243. package/dist/content/skills/hatch3r-containerize/SKILL.md +157 -0
  244. package/dist/content/skills/hatch3r-context-health/SKILL.md +9 -7
  245. package/dist/content/skills/hatch3r-cost-tracking/SKILL.md +37 -17
  246. package/dist/content/skills/hatch3r-customize/SKILL.md +5 -8
  247. package/dist/content/skills/hatch3r-dep-audit/SKILL.md +23 -7
  248. package/dist/content/skills/hatch3r-design-system-detect/SKILL.md +3 -7
  249. package/dist/content/skills/hatch3r-docs-writing/SKILL.md +159 -0
  250. package/dist/content/skills/hatch3r-enhancability-verify/SKILL.md +152 -0
  251. package/dist/content/skills/hatch3r-feature/SKILL.md +53 -3
  252. package/dist/content/skills/hatch3r-feedback/SKILL.md +103 -0
  253. package/dist/content/skills/hatch3r-gh-agentic-workflows/SKILL.md +10 -8
  254. package/dist/content/skills/hatch3r-handoff-prepare/SKILL.md +4 -7
  255. package/dist/content/skills/hatch3r-handoff-resume/SKILL.md +4 -7
  256. package/dist/content/{commands/hatch3r-hooks.md → skills/hatch3r-hooks/SKILL.md} +48 -137
  257. package/dist/content/skills/hatch3r-incident-response/SKILL.md +66 -7
  258. package/dist/content/skills/hatch3r-issue-workflow/SKILL.md +11 -0
  259. package/dist/content/skills/hatch3r-learn/SKILL.md +317 -0
  260. package/dist/content/skills/hatch3r-logical-refactor/SKILL.md +6 -7
  261. package/dist/content/skills/hatch3r-maintainability-verify/SKILL.md +146 -0
  262. package/dist/content/skills/hatch3r-migration/SKILL.md +8 -7
  263. package/dist/content/skills/hatch3r-observability-verify/SKILL.md +17 -12
  264. package/dist/content/skills/hatch3r-perf-audit/SKILL.md +13 -9
  265. package/dist/content/skills/hatch3r-pr-creation/SKILL.md +4 -7
  266. package/dist/content/skills/hatch3r-qa-validation/SKILL.md +6 -5
  267. package/dist/content/skills/hatch3r-recipe/SKILL.md +63 -60
  268. package/dist/content/skills/hatch3r-refactor/SKILL.md +6 -7
  269. package/dist/content/skills/hatch3r-release/SKILL.md +123 -11
  270. package/dist/content/skills/hatch3r-reliability-verify/SKILL.md +9 -5
  271. package/dist/content/{commands/hatch3r-report.md → skills/hatch3r-report/SKILL.md} +20 -17
  272. package/dist/content/skills/hatch3r-scalability-verify/SKILL.md +145 -0
  273. package/dist/content/skills/hatch3r-security-verify/SKILL.md +144 -0
  274. package/dist/content/skills/hatch3r-team-convention-author/SKILL.md +126 -0
  275. package/dist/content/skills/hatch3r-testability-verify/SKILL.md +147 -0
  276. package/dist/content/skills/hatch3r-ui-ux-verify/SKILL.md +19 -11
  277. package/dist/content/skills/hatch3r-visual-refactor/SKILL.md +11 -7
  278. package/package.json +50 -31
  279. package/dist/cli/index.d.ts +0 -2
  280. package/dist/cli/index.js.map +0 -1
  281. package/dist/content/agents/hatch3r-a11y-auditor.md +0 -159
  282. package/dist/content/agents/hatch3r-dependency-auditor.md +0 -219
  283. package/dist/content/agents/hatch3r-perf-profiler.md +0 -166
  284. package/dist/content/agents/hatch3r-security-auditor.md +0 -180
  285. package/dist/content/agents/hatch3r-test-writer.md +0 -171
  286. package/dist/content/commands/hatch3r-learn.md +0 -312
  287. package/dist/content/rules/hatch3r-learning-consult.md +0 -42
  288. package/dist/content/rules/hatch3r-learning-consult.mdc +0 -38
@@ -2,7 +2,8 @@
2
2
  id: hatch3r-security-patterns
3
3
  type: rule
4
4
  description: Security patterns including input validation, auth enforcement, and AI/agentic security for the project
5
- scope: "**/auth/**,**/security/**,**/middleware/**,**/*auth*,**/*guard*,**/*policy*,**/*permission*,**/*sanitiz*,**/*validat*"
5
+ scope: conditional
6
+ globs: "**/security/**,**/*guard*,**/*policy*,**/*permission*,**/*sanitiz*,**/*validat*"
6
7
  tags: [floor:security]
7
8
  precedence: critical
8
9
  quality_charter: agents/shared/quality-charter.md
@@ -29,12 +30,7 @@ cache_friendly: true
29
30
 
30
31
  ## Authentication Enforcement
31
32
 
32
- - Auth middleware on every route by default. Public routes require explicit opt-out with code review justification.
33
- - Token validation: pin allowed algorithms (reject `none`), enforce expiry (`exp`), verify audience (`aud`) and issuer (`iss`) claims. Reject tokens failing any check.
34
- - Session security: `HttpOnly`, `Secure`, `SameSite=Strict` (or `Lax` with justification) cookies. Rotate session ID on privilege change (login, role switch).
35
- - Multi-factor authentication for sensitive operations: admin actions, payment, account deletion, API key generation.
36
- - Rate-limit authentication endpoints (login, token refresh, password reset). Lock accounts or add progressive delays after repeated failures.
37
- - Invalidate all sessions on password change. Provide "sign out everywhere" capability.
33
+ Authentication and authorization patterns (auth middleware, token validation, session security, MFA/AAL mapping, rate-limiting auth endpoints) are owned canonically by `rules/hatch3r-auth-patterns.md`. That rule activates on `**/auth/**`, `**/login/**`, `**/session/**`, `**/middleware/**`, and related globs; this rule no longer restates them, so the two no longer double-fire on the same files. For OWASP A07 in the web-app context see the §A07 section below.
38
34
 
39
35
  ## Fail-Closed Defaults
40
36
 
@@ -138,6 +134,8 @@ cache_friendly: true
138
134
 
139
135
  ## OWASP Top 10 2025 (Web Application Security)
140
136
 
137
+ Subsection order and titles follow the official OWASP Top 10:2025 release (https://owasp.org/Top10/2025/, accessed 2026-06-05). The 2025 list reorders the 2021 set: Security Misconfiguration rises to A02, A03 becomes Software Supply Chain Failures (an expansion of 2021's Vulnerable and Outdated Components), and Injection moves to A05.
138
+
141
139
  ### A01 — Broken Access Control
142
140
 
143
141
  - Enforce access control server-side. Client-side checks are UX, not security.
@@ -147,7 +145,32 @@ cache_friendly: true
147
145
  - Rate-limit API access to minimize automated IDOR scanning and credential stuffing.
148
146
  - Log access control failures and alert on repeated violations from the same identity.
149
147
 
150
- ### A02 — Cryptographic Failures
148
+ ### A02 — Security Misconfiguration
149
+
150
+ - Harden all environments: remove default accounts, disable unused features/ports/services, remove sample applications.
151
+ - Use identical security configuration across development, staging, and production. Differences in security settings between environments mask vulnerabilities.
152
+ - Automate configuration verification: infrastructure-as-code with security baselines, configuration scanning in CI.
153
+ - Send security headers on every response (HSTS, CSP, X-Content-Type-Options, X-Frame-Options). Centralize in middleware.
154
+ - Review cloud permissions quarterly. Remove unused IAM roles, security groups, and service accounts.
155
+ - Disable detailed error messages in production. Use generic error responses with correlation IDs for debugging.
156
+
157
+ ### A03 — Software Supply Chain Failures
158
+
159
+ Expands 2021's Vulnerable and Outdated Components to cover the full dependency, build, and distribution chain — third-party code, build tools, CI/CD systems, and package registries.
160
+
161
+ - Maintain a software bill of materials (SBOM) for all direct and transitive dependencies.
162
+ - Run `npm audit` (or equivalent) in CI on every build. Block merges with critical or high vulnerabilities.
163
+ - Subscribe to security advisories for all critical dependencies using the platform's built-in tools or third-party equivalents:
164
+ - **GitHub:** Dependabot alerts and security advisories
165
+ - **Azure DevOps:** Microsoft Defender for DevOps or WhiteSource/Mend integration
166
+ - **GitLab:** GitLab Dependency Scanning CI template, or Snyk integration
167
+ - Remove unused dependencies. Unused code with known vulnerabilities is still a risk.
168
+ - Pin dependency versions in lockfiles. Review lockfile changes in PRs with the same scrutiny as code changes.
169
+ - Verify package provenance: prefer signed packages, scoped registries, and `npm ci` over `npm install`. Reject `npx -y` on untrusted names (typosquatting / dependency confusion).
170
+ - Harden the build pipeline itself: pin CI actions by commit SHA, restrict who can modify pipeline config, and treat build secrets as production credentials.
171
+ - Establish SLAs for vulnerability remediation: critical within 24 hours, high within 1 week, moderate within 1 sprint.
172
+
173
+ ### A04 — Cryptographic Failures
151
174
 
152
175
  - Classify data by sensitivity (PII, financial, health, credentials). Apply encryption requirements per classification.
153
176
  - Encrypt data in transit (TLS 1.2+ mandatory, prefer 1.3) and at rest (AES-256 or equivalent).
@@ -156,7 +179,7 @@ cache_friendly: true
156
179
  - Generate cryptographic keys with secure random sources (`crypto.randomBytes`, not `Math.random`). Never hard-code keys or IVs.
157
180
  - Disable caching for responses containing sensitive data (`Cache-Control: no-store`).
158
181
 
159
- ### A03 — Injection
182
+ ### A05 — Injection
160
183
 
161
184
  - Use parameterized queries or prepared statements for all database operations. Zero tolerance for string concatenation with user input in queries.
162
185
  - Apply context-aware output encoding: HTML entities, URL encoding, JavaScript escaping, CSS escaping, LDAP escaping — matched to the output context.
@@ -164,7 +187,7 @@ cache_friendly: true
164
187
  - Use `LIMIT` and pagination in queries to prevent mass data disclosure via injection.
165
188
  - For OS command execution: avoid entirely if possible. If necessary, use parameterized APIs (not shell interpolation) with strict input validation.
166
189
 
167
- ### A04 — Insecure Design
190
+ ### A06 — Insecure Design
168
191
 
169
192
  - Use threat modeling during design phase (STRIDE, attack trees, or equivalent). Identify trust boundaries and abuse cases before writing code.
170
193
  - Establish and enforce secure design patterns: separation of concerns, defense in depth, least privilege, fail-closed.
@@ -172,28 +195,7 @@ cache_friendly: true
172
195
  - Design rate limiting, resource quotas, and cost controls into the architecture — not as afterthoughts.
173
196
  - Establish secure development lifecycle (SDL) practices: security requirements, design review, code review, testing.
174
197
 
175
- ### A05Security Misconfiguration
176
-
177
- - Harden all environments: remove default accounts, disable unused features/ports/services, remove sample applications.
178
- - Use identical security configuration across development, staging, and production. Differences in security settings between environments mask vulnerabilities.
179
- - Automate configuration verification: infrastructure-as-code with security baselines, configuration scanning in CI.
180
- - Send security headers on every response (HSTS, CSP, X-Content-Type-Options, X-Frame-Options). Centralize in middleware.
181
- - Review cloud permissions quarterly. Remove unused IAM roles, security groups, and service accounts.
182
- - Disable detailed error messages in production. Use generic error responses with correlation IDs for debugging.
183
-
184
- ### A06 — Vulnerable and Outdated Components
185
-
186
- - Maintain a software bill of materials (SBOM) for all direct and transitive dependencies.
187
- - Run `npm audit` (or equivalent) in CI on every build. Block merges with critical or high vulnerabilities.
188
- - Subscribe to security advisories for all critical dependencies using the platform's built-in tools or third-party equivalents:
189
- - **GitHub:** Dependabot alerts and security advisories
190
- - **Azure DevOps:** Microsoft Defender for DevOps or WhiteSource/Mend integration
191
- - **GitLab:** GitLab Dependency Scanning CI template, or Snyk integration
192
- - Remove unused dependencies. Unused code with known vulnerabilities is still a risk.
193
- - Pin dependency versions in lockfiles. Review lockfile changes in PRs with the same scrutiny as code changes.
194
- - Establish SLAs for vulnerability remediation: critical within 24 hours, high within 1 week, moderate within 1 sprint.
195
-
196
- ### A07 — Identification and Authentication Failures
198
+ ### A07Authentication Failures
197
199
 
198
200
  - Implement multi-factor authentication for privileged accounts and sensitive operations.
199
201
  - Enforce password complexity requirements: minimum 8 characters, check against breached password databases (Have I Been Pwned API).
@@ -202,7 +204,7 @@ cache_friendly: true
202
204
  - Never expose session IDs in URLs. Use secure, HttpOnly, SameSite cookies.
203
205
  - Implement account lockout with notification after repeated failed attempts.
204
206
 
205
- ### A08 — Software and Data Integrity Failures
207
+ ### A08 — Software or Data Integrity Failures
206
208
 
207
209
  - Verify integrity of all software updates, dependencies, and CI/CD pipeline artifacts using digital signatures or checksums.
208
210
  - Use lockfiles and verify their integrity. `npm ci` (not `npm install`) in CI for deterministic builds that fail on lockfile drift.
@@ -214,7 +216,7 @@ cache_friendly: true
214
216
  - **Azure DevOps:** Pin pipeline tasks by exact version (e.g., `task@2`)
215
217
  - **GitLab CI:** Pin included templates by SHA or tag reference
216
218
 
217
- ### A09 — Security Logging and Monitoring Failures
219
+ ### A09 — Security Logging and Alerting Failures
218
220
 
219
221
  - Log all authentication events (success, failure, lockout), access control failures, input validation failures, and security-relevant business events.
220
222
  - Use structured logging with correlation IDs. Include: timestamp, severity, event type, user identity (if available), source IP, resource accessed, outcome.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  description: Security patterns including input validation, auth enforcement, and AI/agentic security for the project
3
- globs: ["**/auth/**", "**/security/**", "**/middleware/**", "**/*auth*", "**/*guard*", "**/*policy*", "**/*permission*", "**/*sanitiz*", "**/*validat*"]
3
+ globs: ["**/security/**", "**/*guard*", "**/*policy*", "**/*permission*", "**/*sanitiz*", "**/*validat*"]
4
4
  alwaysApply: false
5
5
  precedence: critical
6
6
  ---
@@ -25,12 +25,7 @@ precedence: critical
25
25
 
26
26
  ## Authentication Enforcement
27
27
 
28
- - Auth middleware on every route by default. Public routes require explicit opt-out with code review justification.
29
- - Token validation: pin allowed algorithms (reject `none`), enforce expiry (`exp`), verify audience (`aud`) and issuer (`iss`) claims. Reject tokens failing any check.
30
- - Session security: `HttpOnly`, `Secure`, `SameSite=Strict` (or `Lax` with justification) cookies. Rotate session ID on privilege change (login, role switch).
31
- - Multi-factor authentication for sensitive operations: admin actions, payment, account deletion, API key generation.
32
- - Rate-limit authentication endpoints (login, token refresh, password reset). Lock accounts or add progressive delays after repeated failures.
33
- - Invalidate all sessions on password change. Provide "sign out everywhere" capability.
28
+ Authentication and authorization patterns (auth middleware, token validation, session security, MFA/AAL mapping, rate-limiting auth endpoints) are owned canonically by `rules/hatch3r-auth-patterns.md`. That rule activates on `**/auth/**`, `**/login/**`, `**/session/**`, `**/middleware/**`, and related globs; this rule no longer restates them, so the two no longer double-fire on the same files. For OWASP A07 in the web-app context see the §A07 section below.
34
29
 
35
30
  ## Fail-Closed Defaults
36
31
 
@@ -134,6 +129,8 @@ precedence: critical
134
129
 
135
130
  ## OWASP Top 10 2025 (Web Application Security)
136
131
 
132
+ Subsection order and titles follow the official OWASP Top 10:2025 release (https://owasp.org/Top10/2025/, accessed 2026-06-05). The 2025 list reorders the 2021 set: Security Misconfiguration rises to A02, A03 becomes Software Supply Chain Failures (an expansion of 2021's Vulnerable and Outdated Components), and Injection moves to A05.
133
+
137
134
  ### A01 — Broken Access Control
138
135
 
139
136
  - Enforce access control server-side. Client-side checks are UX, not security.
@@ -143,7 +140,32 @@ precedence: critical
143
140
  - Rate-limit API access to minimize automated IDOR scanning and credential stuffing.
144
141
  - Log access control failures and alert on repeated violations from the same identity.
145
142
 
146
- ### A02 — Cryptographic Failures
143
+ ### A02 — Security Misconfiguration
144
+
145
+ - Harden all environments: remove default accounts, disable unused features/ports/services, remove sample applications.
146
+ - Use identical security configuration across development, staging, and production. Differences in security settings between environments mask vulnerabilities.
147
+ - Automate configuration verification: infrastructure-as-code with security baselines, configuration scanning in CI.
148
+ - Send security headers on every response (HSTS, CSP, X-Content-Type-Options, X-Frame-Options). Centralize in middleware.
149
+ - Review cloud permissions quarterly. Remove unused IAM roles, security groups, and service accounts.
150
+ - Disable detailed error messages in production. Use generic error responses with correlation IDs for debugging.
151
+
152
+ ### A03 — Software Supply Chain Failures
153
+
154
+ Expands 2021's Vulnerable and Outdated Components to cover the full dependency, build, and distribution chain — third-party code, build tools, CI/CD systems, and package registries.
155
+
156
+ - Maintain a software bill of materials (SBOM) for all direct and transitive dependencies.
157
+ - Run `npm audit` (or equivalent) in CI on every build. Block merges with critical or high vulnerabilities.
158
+ - Subscribe to security advisories for all critical dependencies using the platform's built-in tools or third-party equivalents:
159
+ - **GitHub:** Dependabot alerts and security advisories
160
+ - **Azure DevOps:** Microsoft Defender for DevOps or WhiteSource/Mend integration
161
+ - **GitLab:** GitLab Dependency Scanning CI template, or Snyk integration
162
+ - Remove unused dependencies. Unused code with known vulnerabilities is still a risk.
163
+ - Pin dependency versions in lockfiles. Review lockfile changes in PRs with the same scrutiny as code changes.
164
+ - Verify package provenance: prefer signed packages, scoped registries, and `npm ci` over `npm install`. Reject `npx -y` on untrusted names (typosquatting / dependency confusion).
165
+ - Harden the build pipeline itself: pin CI actions by commit SHA, restrict who can modify pipeline config, and treat build secrets as production credentials.
166
+ - Establish SLAs for vulnerability remediation: critical within 24 hours, high within 1 week, moderate within 1 sprint.
167
+
168
+ ### A04 — Cryptographic Failures
147
169
 
148
170
  - Classify data by sensitivity (PII, financial, health, credentials). Apply encryption requirements per classification.
149
171
  - Encrypt data in transit (TLS 1.2+ mandatory, prefer 1.3) and at rest (AES-256 or equivalent).
@@ -152,7 +174,7 @@ precedence: critical
152
174
  - Generate cryptographic keys with secure random sources (`crypto.randomBytes`, not `Math.random`). Never hard-code keys or IVs.
153
175
  - Disable caching for responses containing sensitive data (`Cache-Control: no-store`).
154
176
 
155
- ### A03 — Injection
177
+ ### A05 — Injection
156
178
 
157
179
  - Use parameterized queries or prepared statements for all database operations. Zero tolerance for string concatenation with user input in queries.
158
180
  - Apply context-aware output encoding: HTML entities, URL encoding, JavaScript escaping, CSS escaping, LDAP escaping — matched to the output context.
@@ -160,7 +182,7 @@ precedence: critical
160
182
  - Use `LIMIT` and pagination in queries to prevent mass data disclosure via injection.
161
183
  - For OS command execution: avoid entirely if possible. If necessary, use parameterized APIs (not shell interpolation) with strict input validation.
162
184
 
163
- ### A04 — Insecure Design
185
+ ### A06 — Insecure Design
164
186
 
165
187
  - Use threat modeling during design phase (STRIDE, attack trees, or equivalent). Identify trust boundaries and abuse cases before writing code.
166
188
  - Establish and enforce secure design patterns: separation of concerns, defense in depth, least privilege, fail-closed.
@@ -168,28 +190,7 @@ precedence: critical
168
190
  - Design rate limiting, resource quotas, and cost controls into the architecture — not as afterthoughts.
169
191
  - Establish secure development lifecycle (SDL) practices: security requirements, design review, code review, testing.
170
192
 
171
- ### A05Security Misconfiguration
172
-
173
- - Harden all environments: remove default accounts, disable unused features/ports/services, remove sample applications.
174
- - Use identical security configuration across development, staging, and production. Differences in security settings between environments mask vulnerabilities.
175
- - Automate configuration verification: infrastructure-as-code with security baselines, configuration scanning in CI.
176
- - Send security headers on every response (HSTS, CSP, X-Content-Type-Options, X-Frame-Options). Centralize in middleware.
177
- - Review cloud permissions quarterly. Remove unused IAM roles, security groups, and service accounts.
178
- - Disable detailed error messages in production. Use generic error responses with correlation IDs for debugging.
179
-
180
- ### A06 — Vulnerable and Outdated Components
181
-
182
- - Maintain a software bill of materials (SBOM) for all direct and transitive dependencies.
183
- - Run `npm audit` (or equivalent) in CI on every build. Block merges with critical or high vulnerabilities.
184
- - Subscribe to security advisories for all critical dependencies using the platform's built-in tools or third-party equivalents:
185
- - **GitHub:** Dependabot alerts and security advisories
186
- - **Azure DevOps:** Microsoft Defender for DevOps or WhiteSource/Mend integration
187
- - **GitLab:** GitLab Dependency Scanning CI template, or Snyk integration
188
- - Remove unused dependencies. Unused code with known vulnerabilities is still a risk.
189
- - Pin dependency versions in lockfiles. Review lockfile changes in PRs with the same scrutiny as code changes.
190
- - Establish SLAs for vulnerability remediation: critical within 24 hours, high within 1 week, moderate within 1 sprint.
191
-
192
- ### A07 — Identification and Authentication Failures
193
+ ### A07Authentication Failures
193
194
 
194
195
  - Implement multi-factor authentication for privileged accounts and sensitive operations.
195
196
  - Enforce password complexity requirements: minimum 8 characters, check against breached password databases (Have I Been Pwned API).
@@ -198,7 +199,7 @@ precedence: critical
198
199
  - Never expose session IDs in URLs. Use secure, HttpOnly, SameSite cookies.
199
200
  - Implement account lockout with notification after repeated failed attempts.
200
201
 
201
- ### A08 — Software and Data Integrity Failures
202
+ ### A08 — Software or Data Integrity Failures
202
203
 
203
204
  - Verify integrity of all software updates, dependencies, and CI/CD pipeline artifacts using digital signatures or checksums.
204
205
  - Use lockfiles and verify their integrity. `npm ci` (not `npm install`) in CI for deterministic builds that fail on lockfile drift.
@@ -210,7 +211,7 @@ precedence: critical
210
211
  - **Azure DevOps:** Pin pipeline tasks by exact version (e.g., `task@2`)
211
212
  - **GitLab CI:** Pin included templates by SHA or tag reference
212
213
 
213
- ### A09 — Security Logging and Monitoring Failures
214
+ ### A09 — Security Logging and Alerting Failures
214
215
 
215
216
  - Log all authentication events (success, failure, lockout), access control failures, input validation failures, and security-relevant business events.
216
217
  - Use structured logging with correlation IDs. Include: timestamp, severity, event type, user identity (if available), source IP, resource accessed, outcome.
@@ -0,0 +1,97 @@
1
+ ---
2
+ id: hatch3r-security-rule
3
+ type: rule
4
+ description: CQ3 Security Quality measurement rule — supply-chain integrity, auth depth, secret hygiene, OWASP ASI controls; specialist routing to hatch3r-security
5
+ scope: conditional
6
+ globs: "src/**,**/auth/**,**/.github/workflows/**,**/Dockerfile*,**/package.json,**/package-lock.json,**/pnpm-lock.yaml,**/yarn.lock"
7
+ tags: [floor:security, floor:content-quality, security]
8
+ precedence: high
9
+ quality_charter: agents/shared/quality-charter.md
10
+ cache_friendly: true
11
+ ---
12
+ # Security Quality (CQ3)
13
+
14
+ **Pillars:** P6 (Security & Trust), CQ3 (Security Quality)
15
+
16
+ ## Scope
17
+
18
+ This rule binds the CQ3 measurement set across end-user code that hatch3r generates AND the framework's own source tree. It complements (does not duplicate) two adjacent rules:
19
+
20
+ - `rules/hatch3r-security-patterns.md` (critical precedence) — input-validation + auth-enforcement patterns at the code level.
21
+ - `rules/hatch3r-secrets-management.md` (critical precedence) — secret detection, env-var hygiene, lockfile policy.
22
+
23
+ This rule owns the CQ3 threshold set, the specialist agent routing, and the per-finding escalation pathway.
24
+
25
+ ## CQ3 Threshold Set
26
+
27
+ Source: pillar CQ3 (see `agents/shared/principles.md`). Every threshold below is measurable per audit cycle; missing measurement is a Medium finding minimum.
28
+
29
+ | Threshold | Target | Measurement source |
30
+ |-----------|--------|--------------------|
31
+ | npm provenance | 100% on release artifacts | `npm publish --provenance`; verify via `npm view {pkg} --json | jq .provenance` |
32
+ | SBOM (CycloneDX 1.6 or SPDX 3.0.1) | Attached to every release | CI artifact; `syft` or `cyclonedx-npm` output |
33
+ | SHA-pinned GitHub Actions | 100% — 40-char commit SHA | `.github/workflows/*.yml` grep for `uses: .*@[a-f0-9]{40}` |
34
+ | Cosign-signed containers | 100% on published images | `cosign verify --certificate-identity-regexp` against issuer + Rekor entry |
35
+ | OAuth 2.1 conformance | 100% on auth-bearing services | PKCE on public + confidential clients; refresh-token rotation with reuse detection; implicit + ROPC absent |
36
+ | OIDC ID-token validation | 100% — `iss`, `aud`, `azp`, `exp`, `nonce`, JWKS signature | Code audit per `rules/hatch3r-auth-patterns.md` |
37
+ | DPoP sender-constraint (RFC 9449) | 100% on browser tokens | `htm`, `htu`, `iat`, `jti` validation; key-thumbprint binding |
38
+ | WebAuthn server ceremony | 100% on passwordless flows | Challenge TTL + single-use; RP-ID hash; signature; counter strictly greater; opaque `user.id` |
39
+ | Hardcoded secrets count | 0 per cycle | `gitleaks detect --redact`, `trufflehog filesystem`, `detect-secrets scan` |
40
+ | OWASP ASI01-10 coverage | 100% on agent-produced code | Per-control verification against the current agentic-security domain checklist |
41
+ | CVE advisory acknowledgement | ≤90-day staleness | `npm audit --audit-level=high`; `osv-scanner -r .`; GHSA inspection |
42
+
43
+ ## Specialist Agent Routing
44
+
45
+ The CQ3 envelope is owned by a single specialist. Route every trigger below to it:
46
+
47
+ | Trigger | Route to |
48
+ |---------|----------|
49
+ | Auth-flow PR (sign-in, refresh, step-up, logout, token introspection, M2M) | `agents/hatch3r-security.md` (CQ3 specialist) |
50
+ | Release-touching PR (workflow YAML, Dockerfile, package manifest, container manifest, SBOM tooling) | `agents/hatch3r-security.md` (CQ3 specialist) |
51
+ | Project-specific deep audit (database rules, cloud functions, data flows, OWASP Top 10) | `agents/hatch3r-security.md` (CQ3 specialist — deep-audit mode) |
52
+ | CVE response — advisory ≤90 days old matches `package.json` lockfile or SHA-pinned action | `agents/hatch3r-security.md` (CQ3 specialist) + framework-owner escalation per CONSTITUTION §2 P6 |
53
+ | Container hardening (rootless, distroless, non-root UID, capabilities dropped) | `rules/hatch3r-container-hardening.md` (rule) + `agents/hatch3r-security.md` (review) |
54
+
55
+ The CQ3 specialist gates the floor, emits `progress_toward_pillar: content-quality.CQ3+<delta>` per finding, AND performs deep project-specific audits when invoked in deep-audit mode. One agent, one routing surface.
56
+
57
+ ## Severity Mapping
58
+
59
+ The Specialist-Status to canonical-severity map (`CRITICAL` → Critical, `FINDINGS` → High + Medium, `PASS` → Low + Info) is the shared CQ frame per `rules/hatch3r-cq-rule-frame.md` → Specialist-Status to Canonical-Severity Map, sourced from `agents/shared/severity-mapping.md`. CQ3 Action per status:
60
+
61
+ - `CRITICAL`: Block release; framework-owner escalation; ≤7d resolution per CONSTITUTION §2 P6.
62
+ - `FINDINGS`: Block merge on `floor:security` paths; ≤14d resolution for High.
63
+ - `PASS`: Surface in iteration summary; no merge block.
64
+
65
+ ## Per-Finding Output Format
66
+
67
+ Every finding emitted under this rule uses the CQ per-finding rigor-field schema per `rules/hatch3r-cq-rule-frame.md` → Per-Finding Output Format (rigor-contract fields per `agents/shared/rigor-contract.md`), with `<N>` = CQ3. The `proof_trace` excerpt is the command-output for the measurement that produced the finding (e.g. `npm audit`, `gitleaks`, SHA-pin grep).
68
+
69
+ ## Per-Tier Floor Admission
70
+
71
+ Decision 4 (CONSTITUTION §6) admits CQ3 floor items per maturity tier:
72
+
73
+ | Tier | Floor admission |
74
+ |------|-----------------|
75
+ | solo | npm audit clean; no hardcoded secrets; PKCE on OAuth public clients |
76
+ | team | + SBOM attached to release; SHA-pinned actions on release workflow |
77
+ | scaleup | + DPoP on browser tokens; refresh-token rotation; OIDC strict validation |
78
+ | enterprise | + WebAuthn server ceremony; cosign on containers; OWASP ASI01-10 100%; CVE acknowledgement ≤7d for Critical |
79
+
80
+ Tier escalation tightens the floor; previous baselines do not survive a tier bump without re-measurement.
81
+
82
+ ## When to Invoke
83
+
84
+ - Every PR touching `src/auth/*`, JWT verification, cookie wiring, OAuth client config, WebAuthn ceremony, or `.github/workflows/*.yml`.
85
+ - Every release-prep gate before publishing — SBOM, provenance, SHA-pin, cosign on all release artifacts.
86
+ - Every dependency update PR — `npm audit`, `osv-scanner`, GHSA inspection; populate `securityNote` per `rules/hatch3r-tool-currency.md` if a CLI tool is affected.
87
+ - Quarterly OWASP ASI revision review — the ASI revision number changes; rerun the 100% coverage gate against the current revision.
88
+
89
+ ## References
90
+
91
+ - Pillar CQ3 (measurement set + specialist owner; see `agents/shared/principles.md`).
92
+ - The agentic-security audit domain (OWASP ASI controls + supply-chain audit checklists).
93
+ - `agents/hatch3r-security.md` (CQ3 specialist agent — auth + supply-chain + ASI scope).
94
+ - `agents/hatch3r-security.md` (CQ3 specialist — deep-audit mode for project-specific audits).
95
+ - `rules/hatch3r-security-patterns.md` (input-validation + auth enforcement at code level).
96
+ - `rules/hatch3r-secrets-management.md` (secret detection + env-var hygiene + lockfile policy).
97
+ - `rules/hatch3r-container-hardening.md` (rootless / distroless / non-root UID / capability discipline).
@@ -0,0 +1,92 @@
1
+ ---
2
+ description: CQ3 Security Quality measurement rule — supply-chain integrity, auth depth, secret hygiene, OWASP ASI controls; specialist routing to hatch3r-security
3
+ globs: ["src/**", "**/auth/**", "**/.github/workflows/**", "**/Dockerfile*", "**/package.json", "**/package-lock.json", "**/pnpm-lock.yaml", "**/yarn.lock"]
4
+ alwaysApply: false
5
+ precedence: high
6
+ ---
7
+ # Security Quality (CQ3)
8
+
9
+ **Pillars:** P6 (Security & Trust), CQ3 (Security Quality)
10
+
11
+ ## Scope
12
+
13
+ This rule binds the CQ3 measurement set across end-user code that hatch3r generates AND the framework's own source tree. It complements (does not duplicate) two adjacent rules:
14
+
15
+ - `rules/hatch3r-security-patterns.md` (critical precedence) — input-validation + auth-enforcement patterns at the code level.
16
+ - `rules/hatch3r-secrets-management.md` (critical precedence) — secret detection, env-var hygiene, lockfile policy.
17
+
18
+ This rule owns the CQ3 threshold set, the specialist agent routing, and the per-finding escalation pathway.
19
+
20
+ ## CQ3 Threshold Set
21
+
22
+ Source: pillar CQ3 (see `agents/shared/principles.md`). Every threshold below is measurable per audit cycle; missing measurement is a Medium finding minimum.
23
+
24
+ | Threshold | Target | Measurement source |
25
+ |-----------|--------|--------------------|
26
+ | npm provenance | 100% on release artifacts | `npm publish --provenance`; verify via `npm view {pkg} --json | jq .provenance` |
27
+ | SBOM (CycloneDX 1.6 or SPDX 3.0.1) | Attached to every release | CI artifact; `syft` or `cyclonedx-npm` output |
28
+ | SHA-pinned GitHub Actions | 100% — 40-char commit SHA | `.github/workflows/*.yml` grep for `uses: .*@[a-f0-9]{40}` |
29
+ | Cosign-signed containers | 100% on published images | `cosign verify --certificate-identity-regexp` against issuer + Rekor entry |
30
+ | OAuth 2.1 conformance | 100% on auth-bearing services | PKCE on public + confidential clients; refresh-token rotation with reuse detection; implicit + ROPC absent |
31
+ | OIDC ID-token validation | 100% — `iss`, `aud`, `azp`, `exp`, `nonce`, JWKS signature | Code audit per `rules/hatch3r-auth-patterns.md` |
32
+ | DPoP sender-constraint (RFC 9449) | 100% on browser tokens | `htm`, `htu`, `iat`, `jti` validation; key-thumbprint binding |
33
+ | WebAuthn server ceremony | 100% on passwordless flows | Challenge TTL + single-use; RP-ID hash; signature; counter strictly greater; opaque `user.id` |
34
+ | Hardcoded secrets count | 0 per cycle | `gitleaks detect --redact`, `trufflehog filesystem`, `detect-secrets scan` |
35
+ | OWASP ASI01-10 coverage | 100% on agent-produced code | Per-control verification against the current agentic-security domain checklist |
36
+ | CVE advisory acknowledgement | ≤90-day staleness | `npm audit --audit-level=high`; `osv-scanner -r .`; GHSA inspection |
37
+
38
+ ## Specialist Agent Routing
39
+
40
+ The CQ3 envelope is owned by a single specialist. Route every trigger below to it:
41
+
42
+ | Trigger | Route to |
43
+ |---------|----------|
44
+ | Auth-flow PR (sign-in, refresh, step-up, logout, token introspection, M2M) | `agents/hatch3r-security.md` (CQ3 specialist) |
45
+ | Release-touching PR (workflow YAML, Dockerfile, package manifest, container manifest, SBOM tooling) | `agents/hatch3r-security.md` (CQ3 specialist) |
46
+ | Project-specific deep audit (database rules, cloud functions, data flows, OWASP Top 10) | `agents/hatch3r-security.md` (CQ3 specialist — deep-audit mode) |
47
+ | CVE response — advisory ≤90 days old matches `package.json` lockfile or SHA-pinned action | `agents/hatch3r-security.md` (CQ3 specialist) + framework-owner escalation per CONSTITUTION §2 P6 |
48
+ | Container hardening (rootless, distroless, non-root UID, capabilities dropped) | `rules/hatch3r-container-hardening.md` (rule) + `agents/hatch3r-security.md` (review) |
49
+
50
+ The CQ3 specialist gates the floor, emits `progress_toward_pillar: content-quality.CQ3+<delta>` per finding, AND performs deep project-specific audits when invoked in deep-audit mode. One agent, one routing surface.
51
+
52
+ ## Severity Mapping
53
+
54
+ The Specialist-Status to canonical-severity map (`CRITICAL` → Critical, `FINDINGS` → High + Medium, `PASS` → Low + Info) is the shared CQ frame per `rules/hatch3r-cq-rule-frame.md` → Specialist-Status to Canonical-Severity Map, sourced from `agents/shared/severity-mapping.md`. CQ3 Action per status:
55
+
56
+ - `CRITICAL`: Block release; framework-owner escalation; ≤7d resolution per CONSTITUTION §2 P6.
57
+ - `FINDINGS`: Block merge on `floor:security` paths; ≤14d resolution for High.
58
+ - `PASS`: Surface in iteration summary; no merge block.
59
+
60
+ ## Per-Finding Output Format
61
+
62
+ Every finding emitted under this rule uses the CQ per-finding rigor-field schema per `rules/hatch3r-cq-rule-frame.md` → Per-Finding Output Format (rigor-contract fields per `agents/shared/rigor-contract.md`), with `<N>` = CQ3. The `proof_trace` excerpt is the command-output for the measurement that produced the finding (e.g. `npm audit`, `gitleaks`, SHA-pin grep).
63
+
64
+ ## Per-Tier Floor Admission
65
+
66
+ Decision 4 (CONSTITUTION §6) admits CQ3 floor items per maturity tier:
67
+
68
+ | Tier | Floor admission |
69
+ |------|-----------------|
70
+ | solo | npm audit clean; no hardcoded secrets; PKCE on OAuth public clients |
71
+ | team | + SBOM attached to release; SHA-pinned actions on release workflow |
72
+ | scaleup | + DPoP on browser tokens; refresh-token rotation; OIDC strict validation |
73
+ | enterprise | + WebAuthn server ceremony; cosign on containers; OWASP ASI01-10 100%; CVE acknowledgement ≤7d for Critical |
74
+
75
+ Tier escalation tightens the floor; previous baselines do not survive a tier bump without re-measurement.
76
+
77
+ ## When to Invoke
78
+
79
+ - Every PR touching `src/auth/*`, JWT verification, cookie wiring, OAuth client config, WebAuthn ceremony, or `.github/workflows/*.yml`.
80
+ - Every release-prep gate before publishing — SBOM, provenance, SHA-pin, cosign on all release artifacts.
81
+ - Every dependency update PR — `npm audit`, `osv-scanner`, GHSA inspection; populate `securityNote` per `rules/hatch3r-tool-currency.md` if a CLI tool is affected.
82
+ - Quarterly OWASP ASI revision review — the ASI revision number changes; rerun the 100% coverage gate against the current revision.
83
+
84
+ ## References
85
+
86
+ - Pillar CQ3 (measurement set + specialist owner; see `agents/shared/principles.md`).
87
+ - The agentic-security audit domain (OWASP ASI controls + supply-chain audit checklists).
88
+ - `agents/hatch3r-security.md` (CQ3 specialist agent — auth + supply-chain + ASI scope).
89
+ - `agents/hatch3r-security.md` (CQ3 specialist — deep-audit mode for project-specific audits).
90
+ - `rules/hatch3r-security-patterns.md` (input-validation + auth enforcement at code level).
91
+ - `rules/hatch3r-secrets-management.md` (secret detection + env-var hygiene + lockfile policy).
92
+ - `rules/hatch3r-container-hardening.md` (rootless / distroless / non-root UID / capability discipline).
@@ -0,0 +1,98 @@
1
+ ---
2
+ id: hatch3r-swiftui-patterns
3
+ type: rule
4
+ description: SwiftUI and Swift conventions covering Swift 6 concurrency, @Observable + @Bindable, navigation stacks, Swift Package Manager, modular architecture, and XCTest
5
+ scope: conditional
6
+ globs: "**/*.swift,**/*.swiftinterface,**/Package.swift,**/Package.resolved,**/*.xcodeproj/**,**/*.xcworkspace/**,**/Info.plist,**/*.entitlements,**/Tuist/**,**/Project.swift,**/Workspace.swift,**/ios/**,**/macos/**,**/visionOS/**,**/watchOS/**,**/tvOS/**"
7
+ tags: [implementation]
8
+ quality_charter: agents/shared/quality-charter.md
9
+ cache_friendly: true
10
+ ---
11
+ # SwiftUI Patterns
12
+
13
+ **Pillars:** P2 (Scientific & Practical Quality), CQ8 (Maintainability Quality)
14
+
15
+ > Applies when the project ships a SwiftUI/UIKit app or Swift package. Detection signals: `Package.swift`, `*.xcodeproj`, `*.xcworkspace`, or `*.swift` files at repo root.
16
+
17
+ ## Swift Language Floor
18
+
19
+ - Target Swift 6.0+ with strict concurrency checking enabled (`SWIFT_STRICT_CONCURRENCY=complete`). Data-race-safety is the default; opt-out (`@unchecked Sendable`) requires a code comment justifying thread-safety reasoning.
20
+ - Adopt `async/await` throughout. Wrap legacy completion-handler APIs with `withCheckedThrowingContinuation` at the boundary; do not propagate completion-handler signatures into new code.
21
+ - Use `Sendable` conformance for types crossing actor boundaries. `actor` for shared mutable state; `MainActor`-isolated types for UI state.
22
+ - Strict typing: no `Any` outside of bridging code. Prefer `some Protocol` (opaque return types) over existential `any Protocol` when the concrete type is known at compile time.
23
+
24
+ ## SwiftUI App Architecture
25
+
26
+ - Use `@Observable` macro (Swift 5.9+) for view-model state classes; `@Bindable` for two-way binding in views. `ObservableObject` + `@Published` is legacy — migrate during regular refactors.
27
+ - Pick ONE app-state pattern per app and document it in `docs/architecture.md`:
28
+ - **MV (Model–View) with `@Observable`** — recommended default. View-models are simple `@Observable` classes; views observe by reference.
29
+ - **TCA (The Composable Architecture)** — when the team wants unidirectional data flow with reducers + effects.
30
+ - **MVVM with Combine** — when the team already has heavy Combine investment. Avoid in greenfield code.
31
+ - View body is a pure function of state. Never perform side effects in `body`; use `.task { ... }` or `.onChange(of:) { ... }` modifiers.
32
+ - Compose small `View` types — a view exceeding 200 lines is a refactor signal. Extract subviews and use `@ViewBuilder` for conditional content.
33
+
34
+ ## Navigation
35
+
36
+ - Use `NavigationStack` (iOS 16+) with path-driven navigation: bind a `[Destination]` path to the stack and push routes by appending to the array. `NavigationView` is deprecated — migrate.
37
+ - Type the navigation destination via `navigationDestination(for:)` modifiers. Avoid `NavigationLink(destination:)` for stack-pushed views — it bypasses path binding.
38
+ - Deep links: parse incoming URLs in the `.onOpenURL { ... }` modifier on the root view and update the navigation path. Test universal links on a real device — simulators do not honor associated-domains entitlements reliably.
39
+ - Sheets and popovers via `.sheet(item:)` with an `Identifiable` payload — never pass a `Bool` and a separate state variable.
40
+
41
+ ## Concurrency
42
+
43
+ - Long-running work: `Task { ... }` for fire-and-forget, `await Task { ... }.value` for cancelable async work. Always check `Task.isCancelled` inside loops.
44
+ - Detached tasks (`Task.detached`) only when you need to escape MainActor isolation; document why in a comment. They inherit no priority or actor isolation.
45
+ - `TaskGroup` for parallel fan-out: prefer `withThrowingTaskGroup` for error propagation. Limit concurrency explicitly (`group.addTask` with a semaphore) when the workload could overload the network or disk.
46
+ - Use AsyncStream / AsyncSequence for event streams. Wrap delegate-based APIs (CLLocationManager, etc.) with `AsyncStream.makeStream(of:)` rather than maintaining ad-hoc callback caches.
47
+
48
+ ## Modular Architecture
49
+
50
+ - Swift Package Manager (SPM) is the dependency floor. Vendor packages via local Swift packages, not CocoaPods or Carthage (both in maintenance for new projects).
51
+ - Project structure (Tuist or hand-rolled):
52
+ - `App/` — main app target (UI + composition root only).
53
+ - `Features/<Feature>/` — feature modules, each its own SwiftPM target.
54
+ - `Core/` — shared utilities, networking, persistence.
55
+ - Each feature module exports a public API via `public` types; everything else is `internal`. Cross-feature imports go through `Core/` interfaces.
56
+ - Tuist (`Project.swift`, `Workspace.swift`) for multi-target projects above 5 modules. Hand-managed `.xcodeproj` files are merge-conflict prone — Tuist regenerates them deterministically.
57
+
58
+ ## Performance
59
+
60
+ - Profile with Instruments (Time Profiler, Allocations, SwiftUI). Target 60fps on the oldest supported device class.
61
+ - Avoid heavy work in `View.body`. Cache derived values with `@State` initialized via `init` or compute once in `.task { ... }`.
62
+ - Lists: `List` with stable `Identifiable` IDs and `id: \.id` explicit key paths. Use `LazyVStack` inside `ScrollView` for non-Sectioned lists.
63
+ - Images: `AsyncImage` for network images, `Image(systemName:)` for SF Symbols. For high-frequency reload, use `nuke` or `Kingfisher` with disk cache configured.
64
+ - View identity: stable IDs prevent SwiftUI from re-creating views on every state change. `ForEach(items, id: \.id)` — never use `ForEach(items.indices)` for mutable arrays.
65
+
66
+ ## Accessibility
67
+
68
+ - Every interactive view has an `.accessibilityLabel(_:)`, `.accessibilityHint(_:)`, and an appropriate `.accessibilityIdentifier(_:)` for UI tests.
69
+ - Group decorative views with `.accessibilityElement(children: .ignore)` so VoiceOver does not stop on every visual element.
70
+ - Dynamic Type: prefer `.font(.body)` and the semantic font modifiers over fixed-point sizes. Test with the largest accessibility size (`accessibility5`).
71
+ - Reduced Motion: gate animations on `@Environment(\.accessibilityReduceMotion)` — disable parallax, springy bounces, and decorative transitions when set.
72
+
73
+ ## Testing
74
+
75
+ - Unit tests with XCTest (`*Tests/`). Use `swift-testing` (Swift 6) for new test suites when you need parameterized tests, traits, or parallel execution semantics.
76
+ - UI tests with XCUITest under `*UITests/`. Use accessibility identifiers for query stability — never use text labels for selectors.
77
+ - Snapshot tests via `swift-snapshot-testing` (pointfreeco) for SwiftUI view regressions. Configure per-device snapshots in CI.
78
+ - Mock HTTP with `URLProtocol` subclass or `swift-openapi-generator` mock transport. Never hit real network in unit tests.
79
+
80
+ ## Builds & Distribution
81
+
82
+ - Sign with App Store Connect API keys, not Apple ID password. Configure via `xcrun altool --apiKey` or fastlane `app_store_connect_api_key`.
83
+ - Bitcode is removed (Xcode 14+) — do not enable. dSYM archive every release for crash symbolication; upload to Crashlytics / Sentry / TestFlight automatically in CI.
84
+ - App size: enable `SWIFT_OPTIMIZATION_LEVEL=-O` for release builds. Track size via `xcodebuild -resultBundlePath` JSON output in CI.
85
+ - TestFlight for beta distribution. Use external groups for QA, internal groups for engineering — never share builds via plain `.ipa` files.
86
+
87
+ ## References
88
+
89
+ - Swift 6 concurrency: https://www.swift.org/migration/documentation/migrationguide/ (accessed 2026-05-27, official-docs)
90
+ - SwiftUI `@Observable`: https://developer.apple.com/documentation/observation (accessed 2026-05-27, official-docs)
91
+ - NavigationStack: https://developer.apple.com/documentation/swiftui/navigationstack (accessed 2026-05-27, official-docs)
92
+ - swift-testing: https://developer.apple.com/xcode/swift-testing/ (accessed 2026-05-27, official-docs)
93
+
94
+ ## Cross-References
95
+
96
+ - `rules/hatch3r-component-conventions.md` — four-state surface contract maps to SwiftUI `phase`-based async views.
97
+ - `rules/hatch3r-testing.md` — coverage thresholds and determinism rules apply to XCTest / swift-testing.
98
+ - `rules/hatch3r-accessibility-standards.md` — WCAG mapping for SwiftUI `accessibility*` modifiers.