@tenkara/afm-linux-arm64 0.0.0-stage → 4.0.0-alpha.11

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 (283) hide show
  1. package/bin/afm +4 -0
  2. package/content/.coupling-baseline.tsv +1 -0
  3. package/content/.pending-commands.txt +2 -0
  4. package/content/CHANGELOG-archive.md +806 -0
  5. package/content/CHANGELOG.md +4330 -0
  6. package/content/PRINCIPLES.md +119 -0
  7. package/content/README-light.md +158 -0
  8. package/content/README.md +150 -0
  9. package/content/code-style/_any/file-size.md +62 -0
  10. package/content/code-style/_any/imports.md +68 -0
  11. package/content/code-style/_any/naming.md +72 -0
  12. package/content/code-style/_any/test-placement.md +57 -0
  13. package/content/code-style/nextjs-app-router/imports.md +50 -0
  14. package/content/code-style/nextjs-app-router/naming.md +50 -0
  15. package/content/code-style/prisma-postgres/error-boundary.md +55 -0
  16. package/content/code-style/prisma-postgres/imports.md +61 -0
  17. package/content/code-style/shadcn-ui/naming.md +48 -0
  18. package/content/code-style/stripe-billing/naming.md +76 -0
  19. package/content/code-style/trigger-dev-v4/imports.md +58 -0
  20. package/content/code-style/trigger-dev-v4/naming.md +49 -0
  21. package/content/code-style/trigger-dev-v4/test-placement.md +61 -0
  22. package/content/code-style/trpc-v11/error-boundary.md +51 -0
  23. package/content/code-style/trpc-v11/file-size.md +44 -0
  24. package/content/code-style/trpc-v11/naming.md +60 -0
  25. package/content/code-style/trpc-v11/test-placement.md +52 -0
  26. package/content/core/ach.md +260 -0
  27. package/content/core/afm.md +514 -0
  28. package/content/core/gotchas.md +18 -0
  29. package/content/core/prd.md +141 -0
  30. package/content/core/protocol.md +158 -0
  31. package/content/core/ust.md +65 -0
  32. package/content/guardrails/README.md +55 -0
  33. package/content/guardrails/dsl-com-ordem-obrigatoria.md +47 -0
  34. package/content/guardrails/exaustividade-de-union.md +48 -0
  35. package/content/guardrails/fronteira-de-import.md +57 -0
  36. package/content/hooks/README.md +70 -0
  37. package/content/interview/bootstrap.md +417 -0
  38. package/content/interview/promotion.md +115 -0
  39. package/content/interview/refactor.md +379 -0
  40. package/content/interview/triggers.md +107 -0
  41. package/content/modules/nextjs-app-router/ach.patch.md +44 -0
  42. package/content/modules/nextjs-app-router/gotchas.seed.md +78 -0
  43. package/content/modules/nextjs-app-router/rules.patch.md +35 -0
  44. package/content/modules/prisma-postgres/ach.patch.md +65 -0
  45. package/content/modules/prisma-postgres/rules.patch.md +28 -0
  46. package/content/modules/shadcn-ui/ach.patch.md +42 -0
  47. package/content/modules/stripe-billing/ach.patch.md +46 -0
  48. package/content/modules/stripe-billing/gotchas.seed.md +73 -0
  49. package/content/modules/stripe-billing/rules.patch.md +30 -0
  50. package/content/modules/trigger-dev-v4/ach.patch.md +64 -0
  51. package/content/modules/trigger-dev-v4/gotchas.seed.md +53 -0
  52. package/content/modules/trigger-dev-v4/rules.patch.md +35 -0
  53. package/content/modules/trpc-v11/ach.patch.md +56 -0
  54. package/content/modules/trpc-v11/rules.patch.md +34 -0
  55. package/content/modules/vireya-ui/ach.patch.md +85 -0
  56. package/content/modules/vireya-ui/gotchas.seed.md +98 -0
  57. package/content/modules/vireya-ui/rules.patch.md +36 -0
  58. package/content/ops/adr.md +54 -0
  59. package/content/ops/analyze.md +130 -0
  60. package/content/ops/clarify.md +86 -0
  61. package/content/ops/deliver.md +209 -0
  62. package/content/ops/diagnose.md +143 -0
  63. package/content/ops/evolve.md +366 -0
  64. package/content/ops/export-template.md +97 -0
  65. package/content/ops/generalize.md +117 -0
  66. package/content/ops/gotcha.md +46 -0
  67. package/content/ops/obligations.md +145 -0
  68. package/content/ops/plan.md +61 -0
  69. package/content/ops/policy.md +61 -0
  70. package/content/ops/promote.md +72 -0
  71. package/content/ops/protocol.md +51 -0
  72. package/content/ops/reconcile.md +44 -0
  73. package/content/ops/reflect.md +182 -0
  74. package/content/ops/remediate.md +143 -0
  75. package/content/ops/restructure.md +142 -0
  76. package/content/ops/rule.md +170 -0
  77. package/content/ops/specify.md +62 -0
  78. package/content/ops/tasks.md +67 -0
  79. package/content/ops/update.md +252 -0
  80. package/content/ops/verify.md +67 -0
  81. package/content/patterns/adapter.md +46 -0
  82. package/content/patterns/facade.md +47 -0
  83. package/content/patterns/factory.md +46 -0
  84. package/content/patterns/null-object.md +55 -0
  85. package/content/patterns/result-vs-exception.md +52 -0
  86. package/content/patterns/strategy.md +45 -0
  87. package/content/patterns/template-method-vs-composition.md +50 -0
  88. package/content/questions/adr.questions.yaml +14 -0
  89. package/content/questions/analyze.questions.yaml +12 -0
  90. package/content/questions/bootstrap-mapping.questions.yaml +14 -0
  91. package/content/questions/bootstrap-rules.questions.yaml +10 -0
  92. package/content/questions/bootstrap-stack.questions.yaml +23 -0
  93. package/content/questions/clarify.questions.yaml +10 -0
  94. package/content/questions/code-style.questions.yaml +12 -0
  95. package/content/questions/confirm.questions.yaml +12 -0
  96. package/content/questions/deliver.questions.yaml +23 -0
  97. package/content/questions/evolve.questions.yaml +15 -0
  98. package/content/questions/export-template-apply.questions.yaml +11 -0
  99. package/content/questions/export-template.questions.yaml +23 -0
  100. package/content/questions/gates.questions.yaml +27 -0
  101. package/content/questions/generalize.questions.yaml +13 -0
  102. package/content/questions/gotcha.questions.yaml +11 -0
  103. package/content/questions/init-template.questions.yaml +10 -0
  104. package/content/questions/init.questions.yaml +41 -0
  105. package/content/questions/obligations.questions.yaml +17 -0
  106. package/content/questions/plan.questions.yaml +14 -0
  107. package/content/questions/refactor.questions.yaml +23 -0
  108. package/content/questions/reflect.questions.yaml +13 -0
  109. package/content/questions/remediate.questions.yaml +27 -0
  110. package/content/questions/restructure.questions.yaml +15 -0
  111. package/content/questions/rf-mapping.questions.yaml +12 -0
  112. package/content/questions/rule-scope.questions.yaml +12 -0
  113. package/content/questions/rule.questions.yaml +12 -0
  114. package/content/questions/specify.questions.yaml +23 -0
  115. package/content/questions/update-artifacts.questions.yaml +10 -0
  116. package/content/questions/update-strings.questions.yaml +14 -0
  117. package/content/questions/update.questions.yaml +10 -0
  118. package/content/questions/verify.questions.yaml +9 -0
  119. package/content/roles/executor.md +18 -0
  120. package/content/roles/explorer.md +22 -0
  121. package/content/roles/reviewer.md +23 -0
  122. package/content/rubrics/enum-vs-union-vs-branded.md +40 -0
  123. package/content/rubrics/episodic-vs-semantic-boundary.md +37 -0
  124. package/content/rubrics/error-classification.md +98 -0
  125. package/content/rubrics/failure-classification.md +111 -0
  126. package/content/rubrics/negative-filters.md +38 -0
  127. package/content/rubrics/solid-triggers.md +119 -0
  128. package/content/rubrics/template-vs-streaming-precedence.md +34 -0
  129. package/content/rubrics/validation-boundary.md +94 -0
  130. package/content/rubrics/when-to-create-dsl.md +65 -0
  131. package/content/rubrics/when-to-create-lib.md +49 -0
  132. package/content/rubrics/when-to-create-module.md +39 -0
  133. package/content/rubrics/when-to-evolve-methodology.md +62 -0
  134. package/content/skills/adr.md +42 -0
  135. package/content/skills/analyze.md +28 -0
  136. package/content/skills/clarify.md +28 -0
  137. package/content/skills/deliver.md +26 -0
  138. package/content/skills/diagnose.md +42 -0
  139. package/content/skills/evolve.md +43 -0
  140. package/content/skills/export-template.md +37 -0
  141. package/content/skills/generalize.md +31 -0
  142. package/content/skills/gotcha.md +40 -0
  143. package/content/skills/init.md +77 -0
  144. package/content/skills/obligations.md +27 -0
  145. package/content/skills/plan.md +28 -0
  146. package/content/skills/policy.md +25 -0
  147. package/content/skills/promote.md +39 -0
  148. package/content/skills/protocol.md +41 -0
  149. package/content/skills/reconcile.md +45 -0
  150. package/content/skills/refactor.md +79 -0
  151. package/content/skills/reflect.md +43 -0
  152. package/content/skills/remediate.md +33 -0
  153. package/content/skills/restructure.md +46 -0
  154. package/content/skills/rule.md +43 -0
  155. package/content/skills/specify.md +28 -0
  156. package/content/skills/tasks.md +24 -0
  157. package/content/skills/update.md +58 -0
  158. package/content/skills/verify.md +29 -0
  159. package/content/templates/adr.template.md +51 -0
  160. package/content/templates/evolution-report.template.md +132 -0
  161. package/content/templates/feature-plan.template.md +84 -0
  162. package/content/templates/feature-research.template.md +56 -0
  163. package/content/templates/feature-spec.template.md +86 -0
  164. package/content/templates/feature-tasks.induced.template.md +91 -0
  165. package/content/templates/feature-tasks.template.md +82 -0
  166. package/content/templates/focus.template.md +30 -0
  167. package/content/templates/gotcha.template.md +31 -0
  168. package/content/templates/guardrail-runner.template.md +97 -0
  169. package/content/templates/guardrail.template.md +63 -0
  170. package/content/templates/learning.template.md +40 -0
  171. package/content/templates/procedure.template.md +47 -0
  172. package/content/templates/protocols/p1.md +29 -0
  173. package/content/templates/protocols/p2.md +28 -0
  174. package/content/templates/protocols/p3.md +47 -0
  175. package/content/templates/research.template.md +50 -0
  176. package/content/templates/session-handoff.template.md +58 -0
  177. package/content/templates/us.template.md +39 -0
  178. package/content/tools/gate/core-rules/PLUGIN-13-secrets.sh +36 -0
  179. package/content/tools/gate/core-rules/PLUGIN-21-code-language.sh +27 -0
  180. package/content/tools/gate/core-rules/PLUGIN-35-gate-complete.sh +19 -0
  181. package/content/tools/gate/core-rules/PLUGIN-36-absolute-path.sh +38 -0
  182. package/content/tools/gate/core-rules/PLUGIN-37-prose-language.sh +56 -0
  183. package/content/tools/gate/core-rules/PLUGIN-38-parser-marker.sh +82 -0
  184. package/content/tools/gate/core-rules/PLUGIN-39-frontmatter-ops.sh +325 -0
  185. package/content/tools/gate/core-rules/PLUGIN-40-dead-reference.sh +74 -0
  186. package/content/tools/gate/core-rules/README.md +55 -0
  187. package/content/tools/gate/guardrails.sh +740 -0
  188. package/content/tools/gate/lib/ratchet.sh +119 -0
  189. package/content/tools/gate/lib/scope.sh +85 -0
  190. package/content/tools/gate/ratchet.seed.tsv +1 -0
  191. package/content/tools/gate/rules/README.md +50 -0
  192. package/package.json +19 -5
  193. package/plugin/agy/hooks.json +29 -0
  194. package/plugin/agy/mcp_config.json +7 -0
  195. package/plugin/agy/plugin.json +6 -0
  196. package/plugin/agy/skills/afm-adr/SKILL.md +48 -0
  197. package/plugin/agy/skills/afm-analyze/SKILL.md +34 -0
  198. package/plugin/agy/skills/afm-clarify/SKILL.md +34 -0
  199. package/plugin/agy/skills/afm-deliver/SKILL.md +30 -0
  200. package/plugin/agy/skills/afm-diagnose/SKILL.md +46 -0
  201. package/plugin/agy/skills/afm-evolve/SKILL.md +49 -0
  202. package/plugin/agy/skills/afm-export-template/SKILL.md +43 -0
  203. package/plugin/agy/skills/afm-generalize/SKILL.md +37 -0
  204. package/plugin/agy/skills/afm-gotcha/SKILL.md +46 -0
  205. package/plugin/agy/skills/afm-init/SKILL.md +81 -0
  206. package/plugin/agy/skills/afm-obligations/SKILL.md +31 -0
  207. package/plugin/agy/skills/afm-plan/SKILL.md +34 -0
  208. package/plugin/agy/skills/afm-policy/SKILL.md +29 -0
  209. package/plugin/agy/skills/afm-promote/SKILL.md +43 -0
  210. package/plugin/agy/skills/afm-protocol/SKILL.md +45 -0
  211. package/plugin/agy/skills/afm-reconcile/SKILL.md +49 -0
  212. package/plugin/agy/skills/afm-refactor/SKILL.md +83 -0
  213. package/plugin/agy/skills/afm-reflect/SKILL.md +49 -0
  214. package/plugin/agy/skills/afm-remediate/SKILL.md +39 -0
  215. package/plugin/agy/skills/afm-restructure/SKILL.md +52 -0
  216. package/plugin/agy/skills/afm-rule/SKILL.md +49 -0
  217. package/plugin/agy/skills/afm-specify/SKILL.md +34 -0
  218. package/plugin/agy/skills/afm-tasks/SKILL.md +28 -0
  219. package/plugin/agy/skills/afm-update/SKILL.md +64 -0
  220. package/plugin/agy/skills/afm-verify/SKILL.md +35 -0
  221. package/plugin/claude-code/.claude-plugin/marketplace.json +15 -0
  222. package/plugin/claude-code/.claude-plugin/plugin.json +9 -0
  223. package/plugin/claude-code/.mcp.json +7 -0
  224. package/plugin/claude-code/agents/afm-executor.md +18 -0
  225. package/plugin/claude-code/agents/afm-explorer.md +20 -0
  226. package/plugin/claude-code/agents/afm-reviewer.md +21 -0
  227. package/plugin/claude-code/hooks/hooks.json +85 -0
  228. package/plugin/claude-code/skills/adr/SKILL.md +48 -0
  229. package/plugin/claude-code/skills/analyze/SKILL.md +34 -0
  230. package/plugin/claude-code/skills/clarify/SKILL.md +34 -0
  231. package/plugin/claude-code/skills/deliver/SKILL.md +30 -0
  232. package/plugin/claude-code/skills/diagnose/SKILL.md +46 -0
  233. package/plugin/claude-code/skills/evolve/SKILL.md +49 -0
  234. package/plugin/claude-code/skills/export-template/SKILL.md +43 -0
  235. package/plugin/claude-code/skills/generalize/SKILL.md +37 -0
  236. package/plugin/claude-code/skills/gotcha/SKILL.md +46 -0
  237. package/plugin/claude-code/skills/init/SKILL.md +81 -0
  238. package/plugin/claude-code/skills/obligations/SKILL.md +31 -0
  239. package/plugin/claude-code/skills/plan/SKILL.md +34 -0
  240. package/plugin/claude-code/skills/policy/SKILL.md +29 -0
  241. package/plugin/claude-code/skills/promote/SKILL.md +43 -0
  242. package/plugin/claude-code/skills/protocol/SKILL.md +45 -0
  243. package/plugin/claude-code/skills/reconcile/SKILL.md +49 -0
  244. package/plugin/claude-code/skills/refactor/SKILL.md +83 -0
  245. package/plugin/claude-code/skills/reflect/SKILL.md +49 -0
  246. package/plugin/claude-code/skills/remediate/SKILL.md +39 -0
  247. package/plugin/claude-code/skills/restructure/SKILL.md +52 -0
  248. package/plugin/claude-code/skills/rule/SKILL.md +49 -0
  249. package/plugin/claude-code/skills/specify/SKILL.md +34 -0
  250. package/plugin/claude-code/skills/tasks/SKILL.md +28 -0
  251. package/plugin/claude-code/skills/update/SKILL.md +64 -0
  252. package/plugin/claude-code/skills/verify/SKILL.md +35 -0
  253. package/plugin/opencode/afm/index.js +245 -0
  254. package/plugin/opencode/afm/tui.js +21 -0
  255. package/plugin/opencode/agents/afm-executor.md +39 -0
  256. package/plugin/opencode/agents/afm-explorer.md +92 -0
  257. package/plugin/opencode/agents/afm-reviewer.md +93 -0
  258. package/plugin/opencode/skills/afm-adr/SKILL.md +48 -0
  259. package/plugin/opencode/skills/afm-analyze/SKILL.md +34 -0
  260. package/plugin/opencode/skills/afm-clarify/SKILL.md +34 -0
  261. package/plugin/opencode/skills/afm-deliver/SKILL.md +30 -0
  262. package/plugin/opencode/skills/afm-diagnose/SKILL.md +46 -0
  263. package/plugin/opencode/skills/afm-evolve/SKILL.md +49 -0
  264. package/plugin/opencode/skills/afm-export-template/SKILL.md +43 -0
  265. package/plugin/opencode/skills/afm-generalize/SKILL.md +37 -0
  266. package/plugin/opencode/skills/afm-gotcha/SKILL.md +46 -0
  267. package/plugin/opencode/skills/afm-init/SKILL.md +81 -0
  268. package/plugin/opencode/skills/afm-obligations/SKILL.md +31 -0
  269. package/plugin/opencode/skills/afm-plan/SKILL.md +34 -0
  270. package/plugin/opencode/skills/afm-policy/SKILL.md +29 -0
  271. package/plugin/opencode/skills/afm-promote/SKILL.md +43 -0
  272. package/plugin/opencode/skills/afm-protocol/SKILL.md +45 -0
  273. package/plugin/opencode/skills/afm-reconcile/SKILL.md +49 -0
  274. package/plugin/opencode/skills/afm-refactor/SKILL.md +83 -0
  275. package/plugin/opencode/skills/afm-reflect/SKILL.md +49 -0
  276. package/plugin/opencode/skills/afm-remediate/SKILL.md +39 -0
  277. package/plugin/opencode/skills/afm-restructure/SKILL.md +52 -0
  278. package/plugin/opencode/skills/afm-rule/SKILL.md +49 -0
  279. package/plugin/opencode/skills/afm-specify/SKILL.md +34 -0
  280. package/plugin/opencode/skills/afm-tasks/SKILL.md +28 -0
  281. package/plugin/opencode/skills/afm-update/SKILL.md +64 -0
  282. package/plugin/opencode/skills/afm-verify/SKILL.md +35 -0
  283. package/README.md +0 -3
@@ -0,0 +1,86 @@
1
+ ---
2
+ type: template
3
+ description: 'Template rendered during materialization: Feature {{NNN}} — {{objective title}}.'
4
+ load: cold
5
+ renders_to: 'docs/features/*/spec.md'
6
+ frontmatter_for_output: |
7
+ type: feature-spec
8
+ description: '<one sentence: what this feature does and why>'
9
+ load: cold
10
+ status: draft # draft | clarified | planned | in_progress | done | cancelled — the ONE
11
+ # lifecycle signal of the folder; the body carries no Status line. The
12
+ # same value rides in plan.md and tasks.md once they exist.
13
+ for_paths: # the globs this feature touches — the whole trigger `afm-index.sh
14
+ # --for` matches through. Empty until plan.md § 2 names them; an
15
+ # absent key is honest, a list guessed ahead of the plan is not.
16
+ - '{{glob}}'
17
+ us: US-{{NNN}} # the linked US (step 5). Omit the key entirely when none is linked yet.
18
+ rf: RF-{{NN}} # only when the feature also answers a roadmap RF. Omit otherwise.
19
+ ---
20
+
21
+ # Feature {{NNN}} — {{objective title}}
22
+
23
+ <!-- guidance -->
24
+ > A spec holds the what and the why. No technology decision.
25
+ > The linked US and the lifecycle `status` live in the frontmatter, never in the body.
26
+ <!-- /guidance -->
27
+
28
+ ## 1. Problem (from PRD/UST)
29
+
30
+ {{Restate the user job and the pain this feature solves, in 2-3 sentences. Name the persona from PRD § 3.}}
31
+
32
+ ## 2. Observable success criteria
33
+
34
+ - [ ] {{verifiable from outside — example: "user X can export a report to PDF in <3 clicks"}}
35
+ - [ ] {{metric, if any — example: "average time < 2s at p95"}}
36
+
37
+ ## 3. Scenarios (Gherkin, inherited from the US)
38
+
39
+ ```gherkin
40
+ Scenario: {{happy path name}}
41
+ Given {{precondition}}
42
+ When {{user action}}
43
+ Then {{observable result}}
44
+ And {{verifiable side effect}}
45
+ ```
46
+
47
+ ```gherkin
48
+ Scenario: {{most likely error scenario}}
49
+ Given {{precondition}}
50
+ When {{action in invalid state}}
51
+ Then {{expected typed error}}
52
+ And {{no DB side effect}}
53
+ ```
54
+
55
+ ## 4. Out of scope
56
+
57
+ - {{things explicitly NOT included — this prevents scope creep and protects future decisions}}
58
+
59
+ ## 5. Assumptions / Open questions
60
+
61
+ - [NEEDS CLARIFICATION: {{concrete unanswered question — someone must resolve this before plan}}]
62
+ - {{assumption that changes the design if it is wrong}}
63
+
64
+ ## 6. Dependencies
65
+
66
+ - US-NNN (must be `done` first — or mark as a blocker)
67
+ - Feature {{MMM}} (shares entity X, contract Y)
68
+
69
+ ## 7. Clarifications
70
+
71
+ <!-- guidance -->
72
+ {{Optional section, filled in by `afm clarify`. Each session gets a subheading `### Session YYYY-MM-DD`. Each Q/A becomes a bullet. The section stays empty until the first `clarify` run.}}
73
+
74
+ <!-- Example after the first session:
75
+ ### Session 2026-05-10
76
+ - Q: Is the PDF generated server-side or client-side? → A: Server-side (cache + signed URL)
77
+ - Q: Delivery by direct download or pre-signed URL? → A: Pre-signed URL, TTL 1h
78
+ -->
79
+ <!-- /guidance -->
80
+
81
+ ---
82
+
83
+ <!-- guidance -->
84
+ *The spec must NOT contain: stack decisions, function names, DB schema, task order. Those belong in `plan.md`.*
85
+ *The marker `[NEEDS CLARIFICATION:]` differs from `[TBD]`. Use the first for a gap that blocks execution (resolved through `afm clarify`). Use the second for a decision the user knowingly defers.*
86
+ <!-- /guidance -->
@@ -0,0 +1,91 @@
1
+ ---
2
+ type: template
3
+ description: 'Template rendered during materialization: Induced tasks — parameterized template.'
4
+ load: cold
5
+ renders_to: 'docs/templates/feature-tasks.induced.md'
6
+ ancestors: 'Agent Workflow Memory (arXiv:2409.07429): induce a reusable workflow from a successful trajectory, and parameterize the concrete values. Voyager (arXiv:2305.16291): composing from the library beats regenerating from scratch.'
7
+ frontmatter_for_output: |
8
+ type: feature-tasks
9
+ description: '<one sentence: what this task list delivers>'
10
+ load: cold
11
+ status: planned # draft | clarified | planned | in_progress | done | cancelled
12
+ for_paths:
13
+ - '{{glob}}'
14
+ us: US-{{NNN}} # Omit when no US is linked.
15
+ rf: RF-{{NN}} # Omit when no RF is linked.
16
+ tasks: # replay each item with `afm task add`, the variables filled; never by hand
17
+ - id: T001
18
+ kind: setup
19
+ files: ['{{src-path}}/domain/{domain}.ts']
20
+ refs: ['US-{{NNN}}']
21
+ parallel: true
22
+ text: 'Create the file `{{src-path}}/domain/{domain}.ts` with exported signature `domain_{domain}`.'
23
+ done: false
24
+ - id: T002
25
+ kind: setup
26
+ files: ['{{src-path}}/domain/{domain}.fixtures.ts']
27
+ refs: ['US-{{NNN}}']
28
+ parallel: true
29
+ text: 'Create the test fixture in `{{src-path}}/domain/{domain}.fixtures.ts`.'
30
+ done: false
31
+ - id: T003
32
+ kind: red
33
+ scenario: 1
34
+ files: ['{{src-path}}/domain/{domain}.test.ts']
35
+ refs: ['US-{{NNN}}']
36
+ text: 'Write test `domain_{domain} returns <result> given <input>`.'
37
+ done: false
38
+ - id: T004
39
+ kind: green
40
+ closes: T003
41
+ files: ['{{src-path}}/domain/{domain}.ts']
42
+ refs: ['US-{{NNN}}']
43
+ text: 'Add the minimal implementation of `domain_{domain}`.'
44
+ done: false
45
+ - id: T005
46
+ kind: refactor
47
+ refs: ['US-{{NNN}}']
48
+ text: 'Extract a helper if DRY reaches 3 callers (rule 8).'
49
+ done: false
50
+ - id: T006
51
+ kind: red
52
+ scenario: 2
53
+ refs: ['US-{{NNN}}']
54
+ text: 'Write a test for the error path of an invalid `{entity}` at `{boundary-procedure}`.'
55
+ done: false
56
+ - id: T007
57
+ kind: green
58
+ closes: T006
59
+ validates: '{boundary-procedure}'
60
+ refs: ['US-{{NNN}}']
61
+ text: 'Add the procedure `{boundary-procedure}` with Zod validation at the boundary (rule 16).'
62
+ done: false
63
+ - id: T008
64
+ kind: reconcile
65
+ text: 'Update `ach.md § 3` if a new component (`{domain}`/`{entity}`) was added, add an ADR if an architectural decision was made, set the US status in `ust.md` to `done`, and move the `status` frontmatter key of `spec.md`, `plan.md` and `tasks.md` to `done`.'
66
+ done: false
67
+ ---
68
+
69
+ # Induced tasks — parameterized template
70
+
71
+ <!-- guidance -->
72
+ > Induced by `afm export-template` from a feature that is **delivered and 100% green** (every task of its `tasks:` list `done: true` — gate `L_eval=1` of AWM). The concrete values of the original feature are parameterized as `{variables}`.
73
+ > The next consumer of this template starts here instead of generating tasks from scratch: fill in the variables and replay each item of the `tasks:` list above with `afm task add`, then close each one with `afm task done`. It keeps the TDD convention of `feature-tasks.template.md`: a red task, the green task that closes it, an optional refactor (`core/afm.md § 2`), and one reconcile task, last.
74
+ <!-- /guidance -->
75
+
76
+ ## Variables
77
+
78
+ | Variable | What it is | Example (from the induced feature) |
79
+ | --- | --- | --- |
80
+ | `{product-name}` | product/project name | — |
81
+ | `{domain}` | module/domain of the feature | `billing`, `auth` |
82
+ | `{entity}` | central entity touched | `Subscription`, `Session` |
83
+ | `{boundary-procedure}` | boundary procedure/handler, named as its `### Boundary` of plan § 5 | `subscriptionCreate` |
84
+
85
+ ---
86
+
87
+ <!-- guidance -->
88
+ *Fill in the variables for this feature. The rest of the TDD structure came from a validated delivery. Every task must reference US-NNN/RF-NN in its commit. Do not skip the red task (rule 1).*
89
+
90
+ > **Version bump.** In a delivery of more than one commit, the version bump is a **precondition of every commit that touches the installable surface**. It is not a task: a bump in the reconcile task leaves the earlier commits failing the gate.
91
+ <!-- /guidance -->
@@ -0,0 +1,82 @@
1
+ ---
2
+ type: template
3
+ description: 'Template rendered during materialization: Feature {{NNN}} — Tasks.'
4
+ load: cold
5
+ renders_to: 'docs/features/*/tasks.md'
6
+ frontmatter_for_output: |
7
+ type: feature-tasks
8
+ description: '<one sentence: what this task list delivers>'
9
+ load: cold
10
+ status: planned # draft | clarified | planned | in_progress | done | cancelled — the folder's
11
+ # ONE lifecycle value: `in_progress` with the first task, `done` in the
12
+ # reconcile task that moves spec.md and plan.md
13
+ for_paths: # carried from plan.md § 2, unchanged
14
+ - '{{glob}}'
15
+ us: US-{{NNN}} # carried from spec.md. Omit when spec.md omits it.
16
+ rf: RF-{{NN}} # carried from spec.md. Omit when spec.md omits it.
17
+ tasks: # written by `afm task add`, corrected by `afm task set`, closed by `afm task done`; never by hand
18
+ - id: T001
19
+ kind: setup
20
+ files: ['{{src-path}}/domain/x.ts']
21
+ refs: ['US-{{NNN}}']
22
+ parallel: true
23
+ text: '{{ex: create the empty file with an exported signature}}'
24
+ done: false
25
+ - id: T002
26
+ kind: red
27
+ scenario: 1
28
+ files: ['{{src-path}}/domain/x.test.ts']
29
+ refs: ['US-{{NNN}}']
30
+ text: '{{ex: test domain_x returns Y given Z}}'
31
+ done: false
32
+ - id: T003
33
+ kind: green
34
+ closes: T002
35
+ files: ['{{src-path}}/domain/x.ts']
36
+ refs: ['US-{{NNN}}']
37
+ text: '{{ex: minimal implementation of domain_x}}'
38
+ done: false
39
+ - id: T004
40
+ kind: refactor
41
+ refs: ['US-{{NNN}}']
42
+ text: '{{ex: extract parseInput if DRY has 3+ callers (rule 8)}}'
43
+ done: false
44
+ - id: T005
45
+ kind: red
46
+ scenario: 2
47
+ files: ['{{src-path}}/procedures/x-create.test.ts']
48
+ refs: ['US-{{NNN}}']
49
+ text: '{{ex: test the INVALID_INPUT error path of the xCreate boundary}}'
50
+ done: false
51
+ - id: T006
52
+ kind: green
53
+ closes: T005
54
+ validates: '{{boundary name of plan § 5, ex: xCreate}}'
55
+ files: ['{{src-path}}/procedures/x-create.ts']
56
+ refs: ['US-{{NNN}}']
57
+ text: '{{ex: Zod validation at the boundary (rule 16)}}'
58
+ done: false
59
+ - id: T007
60
+ kind: reconcile
61
+ text: 'ach.md § 3 if a new component landed, an ADR if a decision materialized, the US status in ust.md, and the status key of spec.md, plan.md and tasks.md set to done'
62
+ done: false
63
+ ---
64
+
65
+ # Feature {{NNN}} — Tasks
66
+
67
+ <!-- guidance -->
68
+ > The tasks live in the frontmatter `tasks:` list, never as a checklist in this body. Add each one with `afm task add {{NNN}} --kind <setup|red|green|refactor|reconcile> --text "..." [--scenario N] [--closes Txxx] [--validates <boundary>] [--files a,b] [--refs US-NNN,RF-NN] [--parallel]`: the CLI assigns the id, refuses an item that breaks a rule `afm feature lint` grades, and keeps the reconcile task last (reopening it when it was done). Correct a field with `afm task set {{NNN}} Txxx --<field> <value>`. Close each one with `afm task done {{NNN}} Txxx`: a green waits for its red, a refactor for the task before it. Never edit the list by hand.
69
+ > A TDD cycle of `core/afm.md` § 2 is a red task (`scenario: N` of spec § 3), then a green task that closes it (`closes:` the red), then an optional refactor. `parallel: true` marks a task with no dependency on the task right before it; a green or a refactor never is.
70
+ > Each new component of plan § 2 is in the `files:` of one task, with the exact path of the plan cell. Each boundary of plan § 5 needs a task whose `validates:` is its name (`### Boundary <name>`): the task that validates its input (rule 16).
71
+ > One reconcile task, the last: `afm task done` refuses it while another task is open. Run `afm feature lint {{NNN}}` until it exits 0.
72
+ > Before you start, `plan.md` has no open `[NEEDS CLARIFICATION:]` marker.
73
+ <!-- /guidance -->
74
+
75
+ ## Notes
76
+
77
+ {{ex: what the list does not say: the order of the phases, a dependency between tasks, a risk}}
78
+
79
+ <!-- guidance -->
80
+ > **Version bump.** In a delivery of more than one commit, the version bump is a **precondition of every commit that touches the installable surface**. It is not a task: a bump in the reconcile task leaves the earlier commits failing the gate.
81
+ > Every task references US-NNN or RF-NN in the commit (rule in `core/afm.md` § 2, step 7 COMMIT). Never skip the red task (rule 1 — TDD).
82
+ <!-- /guidance -->
@@ -0,0 +1,30 @@
1
+ ---
2
+ type: template
3
+ description: 'Template rendered during materialization: Current focus.'
4
+ load: cold
5
+ renders_to: 'docs/_focus.md'
6
+ frontmatter_for_output: |
7
+ type: state
8
+ description: 'Where the work is now: the focus, the last steps, the next step and the blockers.'
9
+ load: hot
10
+ ---
11
+
12
+ # Current focus
13
+
14
+ <!-- guidance -->
15
+ > This is **MUTABLE** work state (slot-state, `type: state`). The agent **OVERWRITES** it when the focus changes (`reconcile` proposes it; no hook writes the body). It does not grow by append (hard rule 20). This exempts it from rule 17, the anti-context-collapse rule. It is NOT normative knowledge. It does not enter the A1-A7 axes of `diagnose`. It answers only "where am I now". The `afm.md § 2 LER` step reads it. The SessionStart hook injects it with its age ("last updated N days ago", from the last commit or the file's mtime) and flags it as possibly stale after 7 days. It is one page only (KISS). There is no `_slots/` folder and no consolidator.
16
+ <!-- /guidance -->
17
+
18
+ ```
19
+ protocol: {{p1|p2|p3, or omit for the core/protocol.md § 2 defaults}}
20
+ cadence: reflect={{N}} evolve={{N}}
21
+ ```
22
+
23
+ <!-- guidance -->
24
+ > The two lines above are **declarations read by a hook**, not prose. `protocol:` sets the posture (`core/protocol.md § 7`). `cadence:` overrides `REFLECT_EVERY`/`EVOLVE_EVERY` (§ 2). `reflect=off` turns off the `Stop` block. Both lines are optional. When absent, the defaults apply.
25
+ <!-- /guidance -->
26
+
27
+ - **Now:** {{the task/feature in focus}}
28
+ - **Last steps:** {{what was just done}}
29
+ - **Next steps:** {{the next concrete step}}
30
+ - **Blockers:** {{what blocks progress, if anything}}
@@ -0,0 +1,31 @@
1
+ ---
2
+ type: template
3
+ description: One gotcha, as its own file under docs/gotchas/.
4
+ load: cold
5
+ renders_to: 'docs/gotchas/*.md'
6
+ frontmatter_for_output: |
7
+ type: gotcha
8
+ description: '<what the reader LEARNS, not what the file is>'
9
+ load: warm
10
+ fires_on: event # event | file-shape. Prefer event over a guessed path.
11
+ trigger_path: '{{glob}}' # ONLY when fires_on is file-shape, and a narrow glob.
12
+ fires_when: '<if you edit X, or touch Y, or investigate Z>'
13
+ bites: 2 # OPTIONAL. 2 when it bit twice, 1 when it is documented SDK behavior; omit it and `afm gotcha bite` starts it at 1.
14
+ last_bite: YYYY-MM # OPTIONAL, with bites. The month of the latest bite.
15
+ refs: # ADR ids, paths, links. Omit the key when there are none.
16
+ - ADR-NNNN
17
+ ---
18
+
19
+ # {{Área}} — {{título do gotcha}}
20
+
21
+ <!-- guidance -->
22
+ <!-- The counter lives in the frontmatter (`bites`, `last_bite`), ACE-style: `afm gotcha bite <id>` increments `bites` and sets `last_bite` on each new bite. A gotcha is confirmed 2 or more times on entry (qualification rule in `ops/gotcha.md`). 2 or more gotchas in the same area call for `afm generalize` (this consolidates them at the root, and prevents inflation). An old `last_bite` with `bites` stalled is a candidate for pruning in `afm restructure` (tombstone under rule 17: this measures incidence, not self-reported avoidance). -->
23
+ <!-- /guidance -->
24
+
25
+ ## Behavior
26
+
27
+ {{what looks intuitive + why it breaks. Cite a real reproduction or documented behavior}}
28
+
29
+ ## Solution
30
+
31
+ {{what to do instead. Make it concrete, not "be careful"}}
@@ -0,0 +1,97 @@
1
+ ---
2
+ type: template
3
+ description: 'Template rendered during materialization: Template — guardrail runner.'
4
+ load: cold
5
+ renders_to: 'docs/tools/gate/rules/*.sh'
6
+ ---
7
+
8
+ # Template — guardrail runner
9
+
10
+ <!-- guidance -->
11
+ > Skeleton of the script that a guardrail of **`hard-rule` origin** runs. The consumer repo materializes it as `docs/tools/gate/rules/<NN>-<slug>.sh` (or the path the project already uses for gates).
12
+ > **Two forms.** `afm rule new` writes a TypeScript skeleton (`<NN>-<slug>.ts`) by default and a bash one (`<NN>-<slug>.sh`) with `--runner sh`. Use TypeScript when the check is "files in a scope, a regex per line": no shell, no execute bit, and it runs on Windows. Use bash (or any executable) for a diff, a count against the ratchet, or another tool. Both obey the contract below.
13
+ > **The runner is the only part you write.** Since 3.7.0-rc.1 the aggregator, its two libraries, the ratchet and the hook body arrive materialized in `docs/tools/gate/`. Before that they were described here and shipped nowhere, so a runner written from this template died at its own `source` line.
14
+ <!-- /guidance -->
15
+
16
+ ## Contract
17
+
18
+ ```
19
+ argv[1] : "staged" | "worktree"
20
+ env RATCHET : path to the budget baseline (TSV: rule region count note)
21
+ env AFM_GATE_LIB : directory holding scope.sh and ratchet.sh, exported by the aggregator
22
+
23
+ stdout : one line per finding — "<NN>\t<path>[:<line>]\t<short message>"
24
+ exit 0 : compliant
25
+ exit 1 : violation found
26
+ exit 2 : COULD NOT decide (missing dependency, mode not applicable)
27
+ ```
28
+
29
+ <!-- guidance -->
30
+ **Exit 2 is mandatory. It is not decoration.** "Could not verify" must never become "failed". The first machine without the tool would turn the gate into a permanent block. A gate like that gets disabled, together with every other gate in the same aggregator.
31
+ <!-- /guidance -->
32
+
33
+ ## The two classes — choose before you write
34
+
35
+ | Class | Scope | Budget | Example |
36
+ | --- | --- | --- | --- |
37
+ | **Diff** | the index (what becomes the commit) | always 0 | plaintext secret, version bump, test that must run |
38
+ | **Count** | the whole repo, **even in `--staged`** | ratchet, decreases only | path convention, identifier language, single source |
39
+
40
+ <!-- guidance -->
41
+ Counting a count rule over the index is a **silent false negative**. With a budget of 7, a commit that adds 1 new violation counts 1 ≤ 7 and passes clean. The ratchet means "did not grow" only if it measures the same total it recorded.
42
+ <!-- /guidance -->
43
+
44
+ ## Skeleton: TypeScript (the default)
45
+
46
+ `afm gate` runs the file in a child process (`afm gate ts-runner`) under the same timeout and exit contract. The default export is a function of the rule builder: it imports nothing.
47
+
48
+ ```ts
49
+ export default ({ rule }) =>
50
+ rule("{{NN}}")
51
+ .in("{{glob}}") // repeat .in to add globs
52
+ .except("{{glob}}") // paths left out
53
+ .skipping(/{{comment}}/) // a line that matches is ignored
54
+ .forbid(/{{pattern}}/, "{{message}}"); // or .require(/{{pattern}}/, "{{message}}")
55
+ ```
56
+
57
+ The builder reports each match at its line and exits 0, 1 or 2 for you. Check it with `afm gate --dry-run --only {{NN}}`. Full API: `docs/tools/gate/rules/README.md`. The skeleton `afm rule new` writes throws until you replace it, so an unfinished rule exits 2 and never passes.
58
+
59
+ ## Skeleton: bash
60
+
61
+ ```bash
62
+ #!/usr/bin/env bash
63
+ # Hard rule {{NN}} — {{short statement}}.
64
+ # Why a gate, not a paragraph: {{the mistake is cheap to make, expensive to review, and
65
+ # the review that would catch it does not scale — it costs context every time the code is touched}}.
66
+ set -u
67
+ MODE="${1:-staged}"
68
+ REPO="$(git rev-parse --show-toplevel)"
69
+ # Resolve the library through the variable, never through a fixed path. The runner does not
70
+ # know where the gate lives, which is what lets the same runner work in a project that keeps
71
+ # it under `docs/tools/gate/` and in one that keeps it somewhere else.
72
+ . "${AFM_GATE_LIB:?}/scope.sh"
73
+
74
+ # Dependency guard — exit 2, never 1.
75
+ # command -v {{tool}} >/dev/null 2>&1 || exit 2
76
+
77
+ RC=0
78
+ while IFS= read -r f; do
79
+ [ -f "$REPO/$f" ] || continue
80
+ while IFS=: read -r n _; do
81
+ printf '{{NN}}\t%s:%s\t{{message}}\n' "$f" "$n"
82
+ RC=1
83
+ done < <(grep -n '{{pattern}}' "$REPO/$f")
84
+ done < <(scope_all '{{pathspec}}') # scope_files "$MODE" ... for a DIFF rule
85
+
86
+ exit $RC
87
+ ```
88
+
89
+ ## Before you call it done
90
+
91
+ - [ ] Did the assertion **fail on the old code**? Before you accept it, run it against the code as it was before the fix (`git show HEAD:<file>`, or the parent commit). It MUST fail there. A regression test that passes on the old code proves nothing.
92
+ - [ ] Does the command **distinguish** the violating case from the clean case? Test both. A gate that returns green without checking buys trust it cannot back up.
93
+ - [ ] Is there a diff that **passes the trigger but violates the intent** of the rule? If yes, the rule is reward-hackable. Rewrite it, or demote it to a principle (`core/afm.md § 1.3`).
94
+ - [ ] Does the runner fail **legitimate work** in any real case in the repo? Test this before you turn the gate on. Failing correct work is the shortest path to `--no-verify` becoming a habit.
95
+ - [ ] Did you run `guardrails.sh --baseline` before turning the rule on? It records what HEAD already breaks as declared debt. **A gate that starts red is disabled the next day**, and it takes every other rule in the same aggregator with it.
96
+ - [ ] Is the constant (threshold, prefix, directory list) **the operator's own**? Measure the repo and propose it together with the measurement (`ops/rule.md` 3.6). A "best practice" value set by the agent is the first thing to get turned off.
97
+ - [ ] Was the ratchet's `count` **measured on HEAD** before you turned the gate on? A gate that starts red gets turned off the next day.
@@ -0,0 +1,63 @@
1
+ ---
2
+ type: template
3
+ description: 'Template rendered during materialization: Guardrail: {{title — what this gate blocks}}.'
4
+ load: cold
5
+ renders_to: 'docs/guardrails/*.md'
6
+ frontmatter_for_output: |
7
+ type: guardrail
8
+ description: '<one sentence: what this gate blocks>'
9
+ load: warm
10
+ id: '<stable kebab-case slug>'
11
+ origin: recurring-failure | hard-rule
12
+ surface: pre-commit | ci | linter | type-check | script-local # the chosen surface
13
+ trigger: '<the 0/1 command>'
14
+ cost: low | medium | high
15
+ signal: '<the concrete error people kept fixing by hand: import from billing into ui, a new case in the union broke nothing>'
16
+ installed_on: 'YYYY-MM-DD' # omit the key while the guardrail is still a proposal
17
+ ---
18
+
19
+ # Guardrail: {{title — what this gate blocks}}
20
+
21
+ <!-- guidance -->
22
+ > This is a **mechanical** gate. A 0/1 check runs it on its own. It needs no judgment and no one to remember it.
23
+ > Family `docs/guardrails/` (v3.5.0+). One responsibility per file.
24
+ <!-- /guidance -->
25
+
26
+ **Two origins, one artifact** (the object is the same: a 0/1 check plus the burden of proof to refute it):
27
+
28
+ | `origin:` | Where it comes from | Who proposes it |
29
+ | --- | --- | --- |
30
+ | `recurring-failure` | `sig=` recurred in the failure records (`afm failures promotable`) | `remediate.md` (CRITIC loop, `failure-classification.md` rubric — precedence destination) |
31
+ | `hard-rule` | a hard rule already written in `afm.md § 3`, with a 0/1 trigger no one ran | `rule.md § Install the gate` |
32
+
33
+ ## Origin
34
+
35
+ {{The failure record (sig=`<hash>`, recurred N times), "explicit user correction on <date>", OR, for `hard-rule`, the rule number and proof its trigger never ran. If the surface is a new tool, state its cost.}}
36
+
37
+ ## The trigger
38
+
39
+ `{{comando}}` returns {{0 or nonzero}} when {{the condition}}.
40
+
41
+ <!-- guidance -->
42
+ This is the guardrail's whole contract. If the command cannot tell the violated case from the clean case, **the guardrail does not exist**. Measure it before you trust it. A gate that returns green without checking is worse than no gate. It buys trust it cannot back up.
43
+ <!-- /guidance -->
44
+
45
+ ## Why mechanical, not documented
46
+
47
+ {{Why a procedure or a learning was not enough here. Usually: the error is cheap to make, costly to review, and the review that would catch it does not scale. It spends context every time the code is touched.}}
48
+
49
+ ## Accepted cost
50
+
51
+ {{What this gate charges: build time, a known false positive, ceremony on a legitimate change. An undeclared cost breeds resentment. The next agent then disables the gate without recording why.}}
52
+
53
+ ## What would refute this
54
+
55
+ {{Mandatory. The conditions under which this guardrail stops making sense, and who carries the burden of proof to remove it.}}
56
+
57
+ - {{condition 1 — e.g., "the project has only one package, so there is no boundary to cross without a graph"}}
58
+ - {{condition 2 — e.g., "measured it, and the command misses the violation you actually have"}}
59
+ - {{condition 3 — e.g., "the structure is still forming, so freezing it now rejects legitimate work"}}
60
+
61
+ <!-- guidance -->
62
+ > **Burden of proof.** Changing or removing this guardrail requires **refuting one of the conditions above with evidence**, not claiming that it got in the way. Friction is the gate's intended effect. Friction alone does not prove the gate is wrong. Same discipline as "a violated rule is not a wrong rule" (`ops/reflect.md § 2`).
63
+ <!-- /guidance -->
@@ -0,0 +1,40 @@
1
+ ---
2
+ type: template
3
+ description: 'Template rendered during materialization: Learning: {{title — the lesson in one line}}.'
4
+ load: cold
5
+ renders_to: 'docs/learnings/*.md'
6
+ frontmatter_for_output: |
7
+ type: learning
8
+ description: '<one sentence: the lesson, and the area it applies to>'
9
+ load: warm
10
+ fires_on: file-shape
11
+ trigger_path: 'the glob whose files this lesson applies to'
12
+ fires_when: 'if you edit <area or path>, read this file first'
13
+ origin: 'the failure record (sig=<hash>) or the explicit user correction that recognized the failure'
14
+ recognized_by: 'the external signal: a red test, tsc, a command returning non-zero, or a user correction'
15
+ ---
16
+
17
+ # Learning: {{title — the lesson in one line}}
18
+
19
+ <!-- guidance -->
20
+ > This is an instructive file for **other Claude sessions** (and developers). It holds one **conceptual** lesson from a real failure.
21
+ > This file belongs to the `docs/learnings/` family (v3.1.0+). It comes from the CRITIC loop (`remediate.md`) when the failure is conceptual or contextual. The value sits in the *cause*, not in a mechanical sequence of steps — that case belongs in a `procedure` instead. The hook `afm-pre-edit.sh` injects this file into future sessions by path match (see `trigger_path` and `fires_when` in the frontmatter). Keep one lesson per file.
22
+ <!-- /guidance -->
23
+
24
+ ## What failed
25
+
26
+ {{The concrete symptom, anchored in the external signal — the command that returned ≠0, or the user's correction. Do not write "I thought I failed". CRITIC requires recognition by tool, not self-judgment.}}
27
+
28
+ ## The lesson
29
+
30
+ {{The conceptual root cause and what to do differently. This is reusable knowledge — the "why", not only the "what". If another Claude session, without this session's context, needs this fact to avoid repeating the failure, it belongs here (#1).}}
31
+
32
+ ## How to apply
33
+
34
+ {{What the next agent must do when it touches the trigger area. Keep this concrete and actionable.}}
35
+
36
+ ---
37
+
38
+ <!-- guidance -->
39
+ > This file **does not become a hard rule** (it has no executable 0/1 trigger — a rule with a trigger belongs in `afm.md § 3`). It is **not a gotcha** either (a gotcha is an SDK or runtime surprise, a learning is a lesson from one's own failure). This file is injectable conceptual instruction. If the lesson later gains a mechanical trigger, promote it to a rule (`afm rule`). If 2 or more learnings converge on the same point, consider `afm generalize`.
40
+ <!-- /guidance -->
@@ -0,0 +1,47 @@
1
+ ---
2
+ type: template
3
+ description: 'Template rendered during materialization: Procedure: {{title — what this runbook does}}.'
4
+ load: cold
5
+ renders_to: 'docs/procedures/*.md'
6
+ frontmatter_for_output: |
7
+ type: procedure
8
+ description: '<one sentence: what this runbook does>'
9
+ load: cold
10
+ fires_on: event | cadence
11
+ fires_when: 'the condition that starts this runbook, in one line: before cutting a release, when the build fails with X'
12
+ owner: 'who maintains this (optional, omit the key when nobody does)'
13
+ last_run: 'YYYY-MM-DD: update on each run (optional)'
14
+ origin: 'the failure record (sig=<hash>, recurred N times) or: operational sequence observed N times'
15
+ ---
16
+
17
+ # Procedure: {{title — what this runbook does}}
18
+
19
+ <!-- guidance -->
20
+ > Repeatable runbook. A **mechanical** sequence of steps, each with a 0/1 check.
21
+ > Family `docs/procedures/`, since v3.1.0. It starts from a mechanical failure that
22
+ > recurred (CRITIC loop, `remediate.md`) OR from an operational sequence repeated
23
+ > 2+ times (release, deploy, migration). One responsibility per file, 300 lines max.
24
+ <!-- /guidance -->
25
+
26
+ ## Preconditions
27
+
28
+ {{What must be true before you start. Reference `afm.md § 6.1` (pre-push) and current rules. Do not duplicate them — point to them.}}
29
+
30
+ ## Steps
31
+
32
+ 1. {{action}} — `{{command}}`
33
+ *Check:* `{{0/1 command}}` returns {{expected result}}.
34
+ 2. {{action}} — `{{command}}`
35
+ *Check:* `{{0/1 command}}` returns {{expected result}}.
36
+
37
+ <!-- guidance -->
38
+ > Each step has a **command** and a **0/1 check**. A step with no executable check is not a procedure. It is prose, so it becomes a `learning` instead.
39
+ <!-- /guidance -->
40
+
41
+ ## Rollback
42
+
43
+ {{How to undo safely if a step fails. Flag any irreversible external effect BEFORE the DB commit (saga ordering, `afm.md § 1.3`).}}
44
+
45
+ ## Known gotchas
46
+
47
+ {{Links to the surprises in `docs/gotchas.md` that bite during this runbook. Do not copy them here — link to them.}}
@@ -0,0 +1,29 @@
1
+ ---
2
+ type: protocol
3
+ description: 'Template rendered during materialization: P1 — Autonomous Delivery.'
4
+ load: cold
5
+ ---
6
+
7
+ # P1 — Autonomous Delivery
8
+
9
+ > POC and MVP work. Speed and no interaction matter more than depth.
10
+ > **Granted per session, never by the repo** (`core/protocol.md` § 6).
11
+
12
+ | Field | Value |
13
+ | --- | --- |
14
+ | `plan` | `auto` |
15
+ | `exec` | `auto` |
16
+ | `RETRY_CAP` | 2 |
17
+ | `ROUND_CAP` | **0** |
18
+ | `MAX_DISCOVERY_ROUNDS` | 2 |
19
+ | `HALT_PER_PHASE` | off |
20
+ | `SUPPRESS_SUBGATES` | on |
21
+ | `UNKNOWN_POLICY` | `[ASSUMIDO: X — porque Y]` |
22
+ | `delegation` | full |
23
+ | `MAX_PARALLEL_SUBAGENTS` | 4 |
24
+
25
+ **What "autonomous" does NOT mean here:** a hard rule with an executable trigger still stays 0/1. Safety posture stays non-negotiable (`afm.md § 1.3`). P1 relaxes **depth**: coverage, edge-case exhaustiveness, and name refinement.
26
+
27
+ **How "no questions" works mechanically:** `ROUND_CAP = 0`. With no round available, every irreducible unknown falls to `UNKNOWN_POLICY`. It becomes an assumption **recorded in the artifact** — documented, never guessed in silence (principle #4).
28
+
29
+ **Cadence:** run `reflect` after each deliverable. Run `evolve` every 3-4 deliverables.
@@ -0,0 +1,28 @@
1
+ ---
2
+ type: protocol
3
+ description: 'Template rendered during materialization: P2 — Assisted Delivery.'
4
+ load: cold
5
+ ---
6
+
7
+ # P2 — Assisted Delivery
8
+
9
+ > pair programming. The human is the senior dev. The agent escalates early instead of continuing on a wrong path.
10
+
11
+ | Field | Value |
12
+ | --- | --- |
13
+ | `plan` | `assisted` |
14
+ | `exec` | `assisted` |
15
+ | `RETRY_CAP` | **1** |
16
+ | `ROUND_CAP` | 4 |
17
+ | `MAX_DISCOVERY_ROUNDS` | 3 |
18
+ | `HALT_PER_PHASE` | **on** |
19
+ | `SUPPRESS_SUBGATES` | **off** |
20
+ | `UNKNOWN_POLICY` | ask |
21
+ | `delegation` | none |
22
+ | `MAX_PARALLEL_SUBAGENTS` | **2** |
23
+
24
+ **P2 is compositional, not introspective.** It does not mean "ask when unsure". Self-reported confidence is not a mechanical trigger (principle #3). CRITIC shows that self-critique without an external tool degrades quality. P2 sets exactly three existing knobs: suppression off, `RETRY_CAP=1` (the first red escalates), and per-phase halt.
25
+
26
+ **Floor.** Below the feature-folder heuristic (`afm.md § 2.1`), the posture degrades to "report before you commit". Asking at every step of a trivial change adds noise. Noise makes people turn the protocol off, and that is worse than not having it.
27
+
28
+ **Cadence:** run `reflect` after each deliverable. Run `evolve` every 3 to 4 deliverables.