@rryando/arcs 4.1.0 → 4.2.1

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 (213) hide show
  1. package/README.md +17 -19
  2. package/dist/cli/arcs-flash.d.ts +1 -1
  3. package/dist/cli/arcs-flash.d.ts.map +1 -1
  4. package/dist/cli/arcs-flash.js +10 -53
  5. package/dist/cli/arcs-flash.js.map +1 -1
  6. package/dist/cli/arcs-orchestrate-caveman.d.ts +2 -2
  7. package/dist/cli/arcs-orchestrate-caveman.d.ts.map +1 -1
  8. package/dist/cli/arcs-orchestrate-caveman.js +2 -8
  9. package/dist/cli/arcs-orchestrate-caveman.js.map +1 -1
  10. package/dist/cli/arcs-orchestrate.d.ts +1 -1
  11. package/dist/cli/arcs-orchestrate.d.ts.map +1 -1
  12. package/dist/cli/arcs-orchestrate.js +4 -54
  13. package/dist/cli/arcs-orchestrate.js.map +1 -1
  14. package/dist/cli/commands/index.d.ts +0 -1
  15. package/dist/cli/commands/index.d.ts.map +1 -1
  16. package/dist/cli/commands/index.js +0 -1
  17. package/dist/cli/commands/index.js.map +1 -1
  18. package/dist/cli/commands/project.js +1 -30
  19. package/dist/cli/commands/project.js.map +1 -1
  20. package/dist/cli/commands/proposal-doc.d.ts +2 -0
  21. package/dist/cli/commands/proposal-doc.d.ts.map +1 -0
  22. package/dist/cli/commands/proposal-doc.js +381 -0
  23. package/dist/cli/commands/proposal-doc.js.map +1 -0
  24. package/dist/cli/commands/web.js +4 -10
  25. package/dist/cli/commands/web.js.map +1 -1
  26. package/dist/cli/orchestrator-shared-blocks.d.ts +11 -30
  27. package/dist/cli/orchestrator-shared-blocks.d.ts.map +1 -1
  28. package/dist/cli/orchestrator-shared-blocks.js +49 -126
  29. package/dist/cli/orchestrator-shared-blocks.js.map +1 -1
  30. package/dist/utils/diagram-generator.d.ts.map +1 -1
  31. package/dist/utils/diagram-generator.js +11 -6
  32. package/dist/utils/diagram-generator.js.map +1 -1
  33. package/dist/utils/graphify-knowledge.d.ts +22 -0
  34. package/dist/utils/graphify-knowledge.d.ts.map +1 -0
  35. package/dist/utils/graphify-knowledge.js +47 -0
  36. package/dist/utils/graphify-knowledge.js.map +1 -0
  37. package/dist/utils/graphify.d.ts +104 -0
  38. package/dist/utils/graphify.d.ts.map +1 -0
  39. package/dist/utils/graphify.js +439 -0
  40. package/dist/utils/graphify.js.map +1 -0
  41. package/dist/utils/session-store.d.ts +24 -2
  42. package/dist/utils/session-store.d.ts.map +1 -1
  43. package/dist/utils/session-store.js +16 -7
  44. package/dist/utils/session-store.js.map +1 -1
  45. package/dist/utils/storage-utils.d.ts +1 -1
  46. package/dist/utils/storage-utils.d.ts.map +1 -1
  47. package/dist/utils/storage-utils.js +1 -1
  48. package/dist/utils/storage-utils.js.map +1 -1
  49. package/dist/web-client/assets/{GraphCanvas-BPDgvsyT.js → GraphCanvas-Dw6EcoDb.js} +1 -1
  50. package/dist/web-client/assets/{MarkdownEditor-D7TLp78z.js → MarkdownEditor-Cz5_44Ej.js} +1 -1
  51. package/dist/web-client/assets/{abnfDiagram-VRR7QNED-CyuP2N9t.js → abnfDiagram-VRR7QNED-CFJzLuew.js} +1 -1
  52. package/dist/web-client/assets/architecture-TIHT7OUA-CoHvhex9.js +1 -0
  53. package/dist/web-client/assets/{architectureDiagram-ZJ3FMSHR-DZ0ul9QX.js → architectureDiagram-ZJ3FMSHR-FRlSgnnW.js} +1 -1
  54. package/dist/web-client/assets/{blockDiagram-677ZJIJ3-LLGzlc9l.js → blockDiagram-677ZJIJ3-WUkkunPZ.js} +1 -1
  55. package/dist/web-client/assets/{c4Diagram-LMCZKHZV-CViu3CTc.js → c4Diagram-LMCZKHZV-BKeAsL6F.js} +1 -1
  56. package/dist/web-client/assets/channel-D8xMXC5_.js +1 -0
  57. package/dist/web-client/assets/{chunk-32BRIVSS-Bw_IuJCM.js → chunk-32BRIVSS-B0b9kUcF.js} +1 -1
  58. package/dist/web-client/assets/{chunk-52WLFC77-C29h440W.js → chunk-52WLFC77-i6Y-vfL3.js} +1 -1
  59. package/dist/web-client/assets/{chunk-C7G6YPKG-hhOrvw5w.js → chunk-C7G6YPKG-atYWm6iP.js} +1 -1
  60. package/dist/web-client/assets/{chunk-EX3LRPZG-COMzol-M.js → chunk-EX3LRPZG-CZD6y0UU.js} +1 -1
  61. package/dist/web-client/assets/{chunk-FWX5IMBZ-6vdX9EUn.js → chunk-FWX5IMBZ-CVErR-UZ.js} +2 -2
  62. package/dist/web-client/assets/{chunk-HOUHSVGY-DWDW6sxp.js → chunk-HOUHSVGY-BlHO2iQ3.js} +1 -1
  63. package/dist/web-client/assets/{chunk-ICXQ74PX-BdMYglo2.js → chunk-ICXQ74PX-Ar8kfXfa.js} +1 -1
  64. package/dist/web-client/assets/{chunk-MOJQB5TN-C0LAX_dC.js → chunk-MOJQB5TN-DKrK867P.js} +1 -1
  65. package/dist/web-client/assets/{chunk-OGEWGWER-CBx8MB7f.js → chunk-OGEWGWER-BmGykUeg.js} +1 -1
  66. package/dist/web-client/assets/{chunk-PUDLZKDR-DKssR1nf.js → chunk-PUDLZKDR-Bq23pnso.js} +1 -1
  67. package/dist/web-client/assets/{chunk-Q4XR5HBZ-B3kcxFE-.js → chunk-Q4XR5HBZ-g15qvFAN.js} +1 -1
  68. package/dist/web-client/assets/{chunk-V7JOEXUC-CAlymndy.js → chunk-V7JOEXUC-uyXA7S9r.js} +1 -1
  69. package/dist/web-client/assets/{chunk-VAUOI2AC-BowfsmTW.js → chunk-VAUOI2AC-WofZ-2M0.js} +1 -1
  70. package/dist/web-client/assets/{chunk-VR4S4FIN-BBOydgvt.js → chunk-VR4S4FIN-DtTkK86v.js} +1 -1
  71. package/dist/web-client/assets/{chunk-WYO6CB5R-DcymFbES.js → chunk-WYO6CB5R-zVyUwJq3.js} +1 -1
  72. package/dist/web-client/assets/{chunk-ZGVPDNZ5--uKFP-Lr.js → chunk-ZGVPDNZ5-CA1Oe3TK.js} +1 -1
  73. package/dist/web-client/assets/classDiagram-OUVF2IWQ-Doj1_hvZ.js +1 -0
  74. package/dist/web-client/assets/classDiagram-v2-EOCWNBFH-Doj1_hvZ.js +1 -0
  75. package/dist/web-client/assets/{cynefin-VYW2F7L2-CjboUOMA.js → cynefin-VYW2F7L2-ivJY1h_9.js} +1 -1
  76. package/dist/web-client/assets/{cynefinDiagram-TSTJHNR4-BcxygBP7.js → cynefinDiagram-TSTJHNR4-D2DstShq.js} +1 -1
  77. package/dist/web-client/assets/{dagre-VKFMJZFB-D-tiERQE.js → dagre-VKFMJZFB-CwnMRy0K.js} +1 -1
  78. package/dist/web-client/assets/{diagram-FQU43EPY-ChPXczaS.js → diagram-FQU43EPY-BKJv6Cvw.js} +1 -1
  79. package/dist/web-client/assets/{diagram-G47NLZAW-CVL3Y91h.js → diagram-G47NLZAW-CwCXcgU5.js} +1 -1
  80. package/dist/web-client/assets/{diagram-NH7WQ7WH-DsaNA9Lh.js → diagram-NH7WQ7WH-CkghU1-6.js} +1 -1
  81. package/dist/web-client/assets/{diagram-OA4YK3LP-CXhrhdhU.js → diagram-OA4YK3LP-D3siQIGu.js} +1 -1
  82. package/dist/web-client/assets/{diagram-WEI45ONY-BTVPnk4E.js → diagram-WEI45ONY-CSs9xTBn.js} +1 -1
  83. package/dist/web-client/assets/{ebnfDiagram-CCIWWBDH-BAyrRBtM.js → ebnfDiagram-CCIWWBDH--i52vMiv.js} +1 -1
  84. package/dist/web-client/assets/{erDiagram-Q63AITRT-Qm24Wepm.js → erDiagram-Q63AITRT-q2hgOBY1.js} +1 -1
  85. package/dist/web-client/assets/eventmodeling-45OFAUF4-ESVuFkJJ.js +1 -0
  86. package/dist/web-client/assets/flowDiagram-23GEKE2U-DN9SdR9f.js +1 -0
  87. package/dist/web-client/assets/{ganttDiagram-NO4QXBWP-D8h7l3XJ.js → ganttDiagram-NO4QXBWP-BZ2rBbTe.js} +1 -1
  88. package/dist/web-client/assets/{gitGraph-TEB2WS4Q-DIBml1SB.js → gitGraph-TEB2WS4Q-OnJ8tHgt.js} +1 -1
  89. package/dist/web-client/assets/{gitGraphDiagram-IHSO6WYX-CtkYoXjn.js → gitGraphDiagram-IHSO6WYX-CPNExFAr.js} +1 -1
  90. package/dist/web-client/assets/{index-DOSH4Q9H.js → index-DCBn-YrR.js} +38 -38
  91. package/dist/web-client/assets/{info-DKCQHKI2-DLEUtV5Q.js → info-DKCQHKI2-DGuJbmdY.js} +1 -1
  92. package/dist/web-client/assets/{infoDiagram-FWYZ7A6U-BJQ7aQux.js → infoDiagram-FWYZ7A6U-ADIAn-P5.js} +1 -1
  93. package/dist/web-client/assets/{ishikawaDiagram-FXEZZL3T-BPM11FvG.js → ishikawaDiagram-FXEZZL3T-CUx-RGfg.js} +1 -1
  94. package/dist/web-client/assets/{journeyDiagram-5HDEW3XC-C0aX2z3c.js → journeyDiagram-5HDEW3XC-BH7-tBBy.js} +1 -1
  95. package/dist/web-client/assets/{kanban-definition-HUTT4EX6-C56F29Ib.js → kanban-definition-HUTT4EX6-BGEXBnI2.js} +1 -1
  96. package/dist/web-client/assets/{line-BLFHLF2N.js → line-CC-5ezU8.js} +1 -1
  97. package/dist/web-client/assets/{mermaid-parser.core-BLC8FhgU.js → mermaid-parser.core-Dw18Fjbq.js} +3 -3
  98. package/dist/web-client/assets/{mermaid.core-BBqkKuXt.js → mermaid.core-CMQBgE43.js} +3 -3
  99. package/dist/web-client/assets/{mindmap-definition-LN4V7U3C-aVZbsoPc.js → mindmap-definition-LN4V7U3C-CGtjw8tB.js} +1 -1
  100. package/dist/web-client/assets/{packet-7NZHBO7P-D4aqSQfB.js → packet-7NZHBO7P-w71Y4Hzd.js} +1 -1
  101. package/dist/web-client/assets/{pegDiagram-2B236MQR-DjfyNI0U.js → pegDiagram-2B236MQR-DWtfEm4T.js} +1 -1
  102. package/dist/web-client/assets/{pie-RZYD4A2V-ChCwYsYj.js → pie-RZYD4A2V-S9ztgnWs.js} +1 -1
  103. package/dist/web-client/assets/{pieDiagram-ENE6RG2P-BeHLKkXC.js → pieDiagram-ENE6RG2P-BWZQPN4m.js} +1 -1
  104. package/dist/web-client/assets/{quadrantDiagram-ABIIQ3AL-stga3gvq.js → quadrantDiagram-ABIIQ3AL-DINDwblH.js} +1 -1
  105. package/dist/web-client/assets/{radar-I7S5WNFK-DOGheiwT.js → radar-I7S5WNFK-BOGl9krB.js} +1 -1
  106. package/dist/web-client/assets/{railroad-3IZDKUUU-_JnU7M6L.js → railroad-3IZDKUUU-CR9kuYSZ.js} +1 -1
  107. package/dist/web-client/assets/railroad-abnf-AHOZXSZD-BvbCHrlR.js +1 -0
  108. package/dist/web-client/assets/railroad-ebnf-EBAXGLYW-D869lbCL.js +1 -0
  109. package/dist/web-client/assets/railroad-peg-LSFZ7HO6-r4TXaJPI.js +1 -0
  110. package/dist/web-client/assets/{railroadDiagram-RFXS5EU6-C0CkMsOd.js → railroadDiagram-RFXS5EU6-byLCs9hp.js} +1 -1
  111. package/dist/web-client/assets/{requirementDiagram-TGXJPOKE-DuImwoRD.js → requirementDiagram-TGXJPOKE-Dn_FtbqW.js} +1 -1
  112. package/dist/web-client/assets/{sankeyDiagram-HTMAVEWB-kprq0XF9.js → sankeyDiagram-HTMAVEWB-DUjRrCeC.js} +1 -1
  113. package/dist/web-client/assets/{sequenceDiagram-DBY2YBRQ-DiXKJMF6.js → sequenceDiagram-DBY2YBRQ-BmBz8Wpq.js} +1 -1
  114. package/dist/web-client/assets/{stateDiagram-2N3HPSRC-D5qbVStE.js → stateDiagram-2N3HPSRC-BAYHjmqB.js} +1 -1
  115. package/dist/web-client/assets/stateDiagram-v2-6OUMAXLB-Bl-1K1zV.js +1 -0
  116. package/dist/web-client/assets/{swimlanes-5IMT3BWC-DCbw389c.js → swimlanes-5IMT3BWC-Bm942AR-.js} +1 -1
  117. package/dist/web-client/assets/swimlanesDiagram-G3AALYLV-DHU7bsfA.js +8 -0
  118. package/dist/web-client/assets/{timeline-definition-FHXFAJF6-CQeaYN_9.js → timeline-definition-FHXFAJF6-CHAZHhQk.js} +1 -1
  119. package/dist/web-client/assets/{treeView-QDETBFTQ-Cf7Sq3qo.js → treeView-QDETBFTQ-DHHkLsSy.js} +1 -1
  120. package/dist/web-client/assets/{treemap-6X3UGDF4-BovzvoTU.js → treemap-6X3UGDF4-BUxZ8fhY.js} +1 -1
  121. package/dist/web-client/assets/{vennDiagram-L72KCM5P-CZsJy139.js → vennDiagram-L72KCM5P-BL9TRcUU.js} +1 -1
  122. package/dist/web-client/assets/{wardley-OPB4EBWU-DJ7MS6XZ.js → wardley-OPB4EBWU-CfJ5mO-y.js} +1 -1
  123. package/dist/web-client/assets/{wardleyDiagram-EHGQE667-rqhcmsbM.js → wardleyDiagram-EHGQE667-BlH1TSjy.js} +1 -1
  124. package/dist/web-client/assets/{xychartDiagram-FW5EYKEG-HuK4Seps.js → xychartDiagram-FW5EYKEG-BJN6wtrV.js} +1 -1
  125. package/dist/web-client/index.html +1 -1
  126. package/dist/web-server/app.d.ts.map +1 -1
  127. package/dist/web-server/app.js +1 -7
  128. package/dist/web-server/app.js.map +1 -1
  129. package/dist/web-server/claude-runner.d.ts +11 -4
  130. package/dist/web-server/claude-runner.d.ts.map +1 -1
  131. package/dist/web-server/claude-runner.js +10 -14
  132. package/dist/web-server/claude-runner.js.map +1 -1
  133. package/dist/web-server/index.d.ts.map +1 -1
  134. package/dist/web-server/index.js +4 -1
  135. package/dist/web-server/index.js.map +1 -1
  136. package/dist/web-server/opencode-client.d.ts +123 -0
  137. package/dist/web-server/opencode-client.d.ts.map +1 -0
  138. package/dist/web-server/opencode-client.js +514 -0
  139. package/dist/web-server/opencode-client.js.map +1 -0
  140. package/dist/web-server/prompt-assembly.d.ts.map +1 -1
  141. package/dist/web-server/prompt-assembly.js +1 -2
  142. package/dist/web-server/prompt-assembly.js.map +1 -1
  143. package/dist/web-server/routes/sessions.d.ts +9 -6
  144. package/dist/web-server/routes/sessions.d.ts.map +1 -1
  145. package/dist/web-server/routes/sessions.js +272 -205
  146. package/dist/web-server/routes/sessions.js.map +1 -1
  147. package/dist/web-server/run-driver.d.ts +113 -0
  148. package/dist/web-server/run-driver.d.ts.map +1 -0
  149. package/dist/web-server/run-driver.js +214 -0
  150. package/dist/web-server/run-driver.js.map +1 -0
  151. package/dist/web-server/run-event-log.d.ts +23 -1
  152. package/dist/web-server/run-event-log.d.ts.map +1 -1
  153. package/dist/web-server/run-event-log.js +29 -5
  154. package/dist/web-server/run-event-log.js.map +1 -1
  155. package/dist/web-server/web-auth.d.ts +3 -5
  156. package/dist/web-server/web-auth.d.ts.map +1 -1
  157. package/dist/web-server/web-auth.js +6 -11
  158. package/dist/web-server/web-auth.js.map +1 -1
  159. package/dist/web-server/web-token.d.ts +1 -2
  160. package/dist/web-server/web-token.d.ts.map +1 -1
  161. package/dist/web-server/web-token.js +1 -2
  162. package/dist/web-server/web-token.js.map +1 -1
  163. package/opencode/arcs/bundle-runtime.json +0 -6
  164. package/opencode/arcs/manifest.json +8 -25
  165. package/opencode/arcs/prompts/arcs-docs.txt +19 -157
  166. package/opencode/arcs/prompts/arcs-flash.txt +46 -155
  167. package/opencode/arcs/prompts/arcs-orchestrate-caveman.txt +48 -164
  168. package/opencode/arcs/prompts/arcs-orchestrate.txt +47 -157
  169. package/opencode/arcs/prompts/code-reviewer.txt +20 -60
  170. package/opencode/arcs/prompts/graph-explorer.txt +19 -49
  171. package/opencode/arcs/prompts/software-engineer.txt +21 -67
  172. package/opencode/arcs/prompts/tech-architect.txt +20 -130
  173. package/opencode/arcs/skills/brainstorming/SKILL.md +20 -100
  174. package/opencode/arcs/skills/brainstorming/visual-companion.md +6 -264
  175. package/opencode/arcs/skills/caveman-commit/SKILL.md +6 -43
  176. package/opencode/arcs/skills/deep-pr-review/SKILL.md +18 -200
  177. package/opencode/arcs/skills/deep-pr-review/codegraph-diff.md +7 -93
  178. package/opencode/arcs/skills/deep-pr-review/review-template.md +13 -60
  179. package/opencode/arcs/skills/enriching-codegraph-proposals/SKILL.md +16 -156
  180. package/opencode/arcs/skills/implementation/SKILL.md +20 -46
  181. package/opencode/arcs/skills/init-project/SKILL.md +12 -150
  182. package/opencode/arcs/skills/systematic-debugging/SKILL.md +13 -152
  183. package/opencode/arcs/skills/systematic-debugging/condition-based-waiting.md +7 -110
  184. package/opencode/arcs/skills/systematic-debugging/defense-in-depth.md +7 -119
  185. package/opencode/arcs/skills/systematic-debugging/phases-reference.md +9 -166
  186. package/opencode/arcs/skills/systematic-debugging/root-cause-tracing.md +8 -165
  187. package/opencode/arcs/skills/test-driven-development/SKILL.md +10 -61
  188. package/opencode/arcs/skills/test-driven-development/tdd-rationalizations-and-examples.md +7 -154
  189. package/opencode/arcs/skills/test-driven-development/testing-anti-patterns.md +8 -295
  190. package/opencode/arcs/skills/to-diagram/SKILL.md +18 -206
  191. package/opencode/arcs/skills/writing-knowledge/SKILL.md +11 -63
  192. package/opencode/arcs/skills/writing-plans/SKILL.md +25 -118
  193. package/opencode/arcs/skills/writing-plans/plan-document-reviewer-prompt.md +10 -61
  194. package/package.json +1 -1
  195. package/skills/explore-dag.md +9 -52
  196. package/skills/init-project.md +9 -98
  197. package/skills/orchestrate.md +15 -109
  198. package/skills/update-docs.md +9 -60
  199. package/dist/web-client/assets/architecture-TIHT7OUA-Bdo2Yvm9.js +0 -1
  200. package/dist/web-client/assets/channel-DBNmizpo.js +0 -1
  201. package/dist/web-client/assets/classDiagram-OUVF2IWQ-CB3HiA1_.js +0 -1
  202. package/dist/web-client/assets/classDiagram-v2-EOCWNBFH-CB3HiA1_.js +0 -1
  203. package/dist/web-client/assets/eventmodeling-45OFAUF4-DoTBIvl5.js +0 -1
  204. package/dist/web-client/assets/flowDiagram-23GEKE2U-BEH23L1A.js +0 -1
  205. package/dist/web-client/assets/railroad-abnf-AHOZXSZD-nhNub7LE.js +0 -1
  206. package/dist/web-client/assets/railroad-ebnf-EBAXGLYW-BlQYe7Yf.js +0 -1
  207. package/dist/web-client/assets/railroad-peg-LSFZ7HO6-B3E8pRVN.js +0 -1
  208. package/dist/web-client/assets/stateDiagram-v2-6OUMAXLB-DWwTAG1r.js +0 -1
  209. package/dist/web-client/assets/swimlanesDiagram-G3AALYLV-DabrCsjZ.js +0 -8
  210. package/opencode/arcs/prompts/devil-advocate.txt +0 -79
  211. package/opencode/arcs/skills/executing-plans/SKILL.md +0 -49
  212. package/opencode/arcs/skills/install-claude-code-hook/SKILL.md +0 -143
  213. package/scripts/claude-code-session-hook.mjs +0 -146
@@ -1,157 +1,10 @@
1
- # TDD Rationalizations and Examples
1
+ # TDD Quick Examples
2
2
 
3
- Companion reference for `SKILL.md`. Contains expanded rebuttals to common TDD-skipping arguments and a worked bug-fix example. Load this when the main skill's rationalizations table isn't enough — i.e. when you or a reviewer is actively arguing for skipping tests-first.
3
+ Use this optional reference when the right test boundary is unclear.
4
4
 
5
- ## Why Order Matters Expanded Rebuttals
5
+ - Bug: reproduce the reported failure, then fix it.
6
+ - Feature: assert the smallest user-visible behavior before implementation.
7
+ - Refactor: existing behavior tests may be sufficient; add a test only for an uncovered contract.
8
+ - Mechanical/prose/generated changes: verify the relevant contract instead of inventing a unit test.
6
9
 
7
- ### "I'll write tests after to verify it works"
8
-
9
- Tests written after code pass immediately. Passing immediately proves nothing:
10
- - Might test wrong thing
11
- - Might test implementation, not behavior
12
- - Might miss edge cases you forgot
13
- - You never saw it catch the bug
14
-
15
- Test-first forces you to see the test fail, proving it actually tests something.
16
-
17
- ### "I already manually tested all the edge cases"
18
-
19
- Manual testing is ad-hoc. You think you tested everything but:
20
- - No record of what you tested
21
- - Can't re-run when code changes
22
- - Easy to forget cases under pressure
23
- - "It worked when I tried it" ≠ comprehensive
24
-
25
- Automated tests are systematic. They run the same way every time.
26
-
27
- ### "Deleting X hours of work is wasteful"
28
-
29
- Sunk cost fallacy. The time is already gone. Your choice now:
30
- - Delete and rewrite with TDD (X more hours, high confidence)
31
- - Keep it and add tests after (30 min, low confidence, likely bugs)
32
-
33
- The "waste" is keeping code you can't trust. Working code without real tests is technical debt.
34
-
35
- ### "TDD is dogmatic, being pragmatic means adapting"
36
-
37
- TDD IS pragmatic:
38
- - Finds bugs before commit (faster than debugging after)
39
- - Prevents regressions (tests catch breaks immediately)
40
- - Documents behavior (tests show how to use code)
41
- - Enables refactoring (change freely, tests catch breaks)
42
-
43
- "Pragmatic" shortcuts = debugging in production = slower.
44
-
45
- ### "Tests after achieve the same goals — it's spirit not ritual"
46
-
47
- No. Tests-after answer "What does this do?" Tests-first answer "What should this do?"
48
-
49
- Tests-after are biased by your implementation. You test what you built, not what's required. You verify remembered edge cases, not discovered ones.
50
-
51
- Tests-first force edge case discovery before implementing. Tests-after verify you remembered everything (you didn't).
52
-
53
- 30 minutes of tests after ≠ TDD. You get coverage, lose proof tests work.
54
-
55
- ## Worked Example: Bug Fix via TDD
56
-
57
- **Bug:** Empty email accepted
58
-
59
- ### RED
60
- ```typescript
61
- test('rejects empty email', async () => {
62
- const result = await submitForm({ email: '' });
63
- expect(result.error).toBe('Email required');
64
- });
65
- ```
66
-
67
- ### Verify RED
68
- ```bash
69
- $ npm test -- submitForm.test.ts
70
- FAIL: expected 'Email required', got undefined
71
- ```
72
-
73
- ### GREEN
74
- ```typescript
75
- function submitForm(data: FormData) {
76
- if (!data.email?.trim()) {
77
- return { error: 'Email required' };
78
- }
79
- // ...
80
- }
81
- ```
82
-
83
- ### Verify GREEN
84
- ```bash
85
- $ npm test -- submitForm.test.ts
86
- PASS
87
- ```
88
-
89
- ### REFACTOR
90
- Extract validation for multiple fields if needed.
91
-
92
- ## Good vs Bad Tests and Implementations
93
-
94
- ### RED — Good failing test
95
-
96
- ```typescript
97
- test('retries failed operations 3 times', async () => {
98
- let attempts = 0;
99
- const operation = () => {
100
- attempts++;
101
- if (attempts < 3) throw new Error('fail');
102
- return 'success';
103
- };
104
-
105
- const result = await retryOperation(operation);
106
-
107
- expect(result).toBe('success');
108
- expect(attempts).toBe(3);
109
- });
110
- ```
111
- Clear name, tests real behavior, one thing.
112
-
113
- ### RED — Bad failing test
114
-
115
- ```typescript
116
- test('retry works', async () => {
117
- const mock = jest.fn()
118
- .mockRejectedValueOnce(new Error())
119
- .mockRejectedValueOnce(new Error())
120
- .mockResolvedValueOnce('success');
121
- await retryOperation(mock);
122
- expect(mock).toHaveBeenCalledTimes(3);
123
- });
124
- ```
125
- Vague name, tests mock not code.
126
-
127
- ### GREEN — Good minimal implementation
128
-
129
- ```typescript
130
- async function retryOperation<T>(fn: () => Promise<T>): Promise<T> {
131
- for (let i = 0; i < 3; i++) {
132
- try {
133
- return await fn();
134
- } catch (e) {
135
- if (i === 2) throw e;
136
- }
137
- }
138
- throw new Error('unreachable');
139
- }
140
- ```
141
- Just enough to pass.
142
-
143
- ### GREEN — Bad over-engineered implementation
144
-
145
- ```typescript
146
- async function retryOperation<T>(
147
- fn: () => Promise<T>,
148
- options?: {
149
- maxRetries?: number;
150
- backoff?: 'linear' | 'exponential';
151
- onRetry?: (attempt: number) => void;
152
- }
153
- ): Promise<T> {
154
- // YAGNI
155
- }
156
- ```
157
- Over-engineered. Don't add features, refactor other code, or "improve" beyond the test.
10
+ If the test passes before implementation, confirm it exercises the new behavior. If testing requires extensive mocking, look for a simpler public boundary.
@@ -1,299 +1,12 @@
1
1
  # Testing Anti-Patterns
2
2
 
3
- **Load this reference when:** writing or changing tests, adding mocks, or tempted to add test-only methods to production code.
3
+ Avoid:
4
4
 
5
- ## Overview
5
+ - tests that assert private call order instead of behavior;
6
+ - mocks that reproduce the implementation;
7
+ - broad snapshots with no meaningful contract;
8
+ - sleeps instead of observable conditions;
9
+ - one test covering several unrelated behaviors;
10
+ - adding tests solely to increase line coverage.
6
11
 
7
- Tests must verify real behavior, not mock behavior. Mocks are a means to isolate, not the thing being tested.
8
-
9
- **Core principle:** Test what the code does, not what the mocks do.
10
-
11
- **Following strict TDD prevents these anti-patterns.**
12
-
13
- ## The Iron Laws
14
-
15
- ```
16
- 1. NEVER test mock behavior
17
- 2. NEVER add test-only methods to production classes
18
- 3. NEVER mock without understanding dependencies
19
- ```
20
-
21
- ## Anti-Pattern 1: Testing Mock Behavior
22
-
23
- **The violation:**
24
- ```typescript
25
- // ❌ BAD: Testing that the mock exists
26
- test('renders sidebar', () => {
27
- render(<Page />);
28
- expect(screen.getByTestId('sidebar-mock')).toBeInTheDocument();
29
- });
30
- ```
31
-
32
- **Why this is wrong:**
33
- - You're verifying the mock works, not that the component works
34
- - Test passes when mock is present, fails when it's not
35
- - Tells you nothing about real behavior
36
-
37
- **your human partner's correction:** "Are we testing the behavior of a mock?"
38
-
39
- **The fix:**
40
- ```typescript
41
- // ✅ GOOD: Test real component or don't mock it
42
- test('renders sidebar', () => {
43
- render(<Page />); // Don't mock sidebar
44
- expect(screen.getByRole('navigation')).toBeInTheDocument();
45
- });
46
-
47
- // OR if sidebar must be mocked for isolation:
48
- // Don't assert on the mock - test Page's behavior with sidebar present
49
- ```
50
-
51
- ### Gate Function
52
-
53
- ```
54
- BEFORE asserting on any mock element:
55
- Ask: "Am I testing real component behavior or just mock existence?"
56
-
57
- IF testing mock existence:
58
- STOP - Delete the assertion or unmock the component
59
-
60
- Test real behavior instead
61
- ```
62
-
63
- ## Anti-Pattern 2: Test-Only Methods in Production
64
-
65
- **The violation:**
66
- ```typescript
67
- // ❌ BAD: destroy() only used in tests
68
- class Session {
69
- async destroy() { // Looks like production API!
70
- await this._workspaceManager?.destroyWorkspace(this.id);
71
- // ... cleanup
72
- }
73
- }
74
-
75
- // In tests
76
- afterEach(() => session.destroy());
77
- ```
78
-
79
- **Why this is wrong:**
80
- - Production class polluted with test-only code
81
- - Dangerous if accidentally called in production
82
- - Violates YAGNI and separation of concerns
83
- - Confuses object lifecycle with entity lifecycle
84
-
85
- **The fix:**
86
- ```typescript
87
- // ✅ GOOD: Test utilities handle test cleanup
88
- // Session has no destroy() - it's stateless in production
89
-
90
- // In test-utils/
91
- export async function cleanupSession(session: Session) {
92
- const workspace = session.getWorkspaceInfo();
93
- if (workspace) {
94
- await workspaceManager.destroyWorkspace(workspace.id);
95
- }
96
- }
97
-
98
- // In tests
99
- afterEach(() => cleanupSession(session));
100
- ```
101
-
102
- ### Gate Function
103
-
104
- ```
105
- BEFORE adding any method to production class:
106
- Ask: "Is this only used by tests?"
107
-
108
- IF yes:
109
- STOP - Don't add it
110
- Put it in test utilities instead
111
-
112
- Ask: "Does this class own this resource's lifecycle?"
113
-
114
- IF no:
115
- STOP - Wrong class for this method
116
- ```
117
-
118
- ## Anti-Pattern 3: Mocking Without Understanding
119
-
120
- **The violation:**
121
- ```typescript
122
- // ❌ BAD: Mock breaks test logic
123
- test('detects duplicate server', () => {
124
- // Mock prevents config write that test depends on!
125
- vi.mock('ToolCatalog', () => ({
126
- discoverAndCacheTools: vi.fn().mockResolvedValue(undefined)
127
- }));
128
-
129
- await addServer(config);
130
- await addServer(config); // Should throw - but won't!
131
- });
132
- ```
133
-
134
- **Why this is wrong:**
135
- - Mocked method had side effect test depended on (writing config)
136
- - Over-mocking to "be safe" breaks actual behavior
137
- - Test passes for wrong reason or fails mysteriously
138
-
139
- **The fix:**
140
- ```typescript
141
- // ✅ GOOD: Mock at correct level
142
- test('detects duplicate server', () => {
143
- // Mock the slow part, preserve behavior test needs
144
- vi.mock('MCPServerManager'); // Just mock slow server startup
145
-
146
- await addServer(config); // Config written
147
- await addServer(config); // Duplicate detected ✓
148
- });
149
- ```
150
-
151
- ### Gate Function
152
-
153
- ```
154
- BEFORE mocking any method:
155
- STOP - Don't mock yet
156
-
157
- 1. Ask: "What side effects does the real method have?"
158
- 2. Ask: "Does this test depend on any of those side effects?"
159
- 3. Ask: "Do I fully understand what this test needs?"
160
-
161
- IF depends on side effects:
162
- Mock at lower level (the actual slow/external operation)
163
- OR use test doubles that preserve necessary behavior
164
- NOT the high-level method the test depends on
165
-
166
- IF unsure what test depends on:
167
- Run test with real implementation FIRST
168
- Observe what actually needs to happen
169
- THEN add minimal mocking at the right level
170
-
171
- Red flags:
172
- - "I'll mock this to be safe"
173
- - "This might be slow, better mock it"
174
- - Mocking without understanding the dependency chain
175
- ```
176
-
177
- ## Anti-Pattern 4: Incomplete Mocks
178
-
179
- **The violation:**
180
- ```typescript
181
- // ❌ BAD: Partial mock - only fields you think you need
182
- const mockResponse = {
183
- status: 'success',
184
- data: { userId: '123', name: 'Alice' }
185
- // Missing: metadata that downstream code uses
186
- };
187
-
188
- // Later: breaks when code accesses response.metadata.requestId
189
- ```
190
-
191
- **Why this is wrong:**
192
- - **Partial mocks hide structural assumptions** - You only mocked fields you know about
193
- - **Downstream code may depend on fields you didn't include** - Silent failures
194
- - **Tests pass but integration fails** - Mock incomplete, real API complete
195
- - **False confidence** - Test proves nothing about real behavior
196
-
197
- **The Iron Rule:** Mock the COMPLETE data structure as it exists in reality, not just fields your immediate test uses.
198
-
199
- **The fix:**
200
- ```typescript
201
- // ✅ GOOD: Mirror real API completeness
202
- const mockResponse = {
203
- status: 'success',
204
- data: { userId: '123', name: 'Alice' },
205
- metadata: { requestId: 'req-789', timestamp: 1234567890 }
206
- // All fields real API returns
207
- };
208
- ```
209
-
210
- ### Gate Function
211
-
212
- ```
213
- BEFORE creating mock responses:
214
- Check: "What fields does the real API response contain?"
215
-
216
- Actions:
217
- 1. Examine actual API response from docs/examples
218
- 2. Include ALL fields system might consume downstream
219
- 3. Verify mock matches real response schema completely
220
-
221
- Critical:
222
- If you're creating a mock, you must understand the ENTIRE structure
223
- Partial mocks fail silently when code depends on omitted fields
224
-
225
- If uncertain: Include all documented fields
226
- ```
227
-
228
- ## Anti-Pattern 5: Integration Tests as Afterthought
229
-
230
- **The violation:**
231
- ```
232
- ✅ Implementation complete
233
- ❌ No tests written
234
- "Ready for testing"
235
- ```
236
-
237
- **Why this is wrong:**
238
- - Testing is part of implementation, not optional follow-up
239
- - TDD would have caught this
240
- - Can't claim complete without tests
241
-
242
- **The fix:**
243
- ```
244
- TDD cycle:
245
- 1. Write failing test
246
- 2. Implement to pass
247
- 3. Refactor
248
- 4. THEN claim complete
249
- ```
250
-
251
- ## When Mocks Become Too Complex
252
-
253
- **Warning signs:**
254
- - Mock setup longer than test logic
255
- - Mocking everything to make test pass
256
- - Mocks missing methods real components have
257
- - Test breaks when mock changes
258
-
259
- **your human partner's question:** "Do we need to be using a mock here?"
260
-
261
- **Consider:** Integration tests with real components often simpler than complex mocks
262
-
263
- ## TDD Prevents These Anti-Patterns
264
-
265
- **Why TDD helps:**
266
- 1. **Write test first** → Forces you to think about what you're actually testing
267
- 2. **Watch it fail** → Confirms test tests real behavior, not mocks
268
- 3. **Minimal implementation** → No test-only methods creep in
269
- 4. **Real dependencies** → You see what the test actually needs before mocking
270
-
271
- **If you're testing mock behavior, you violated TDD** - you added mocks without watching test fail against real code first.
272
-
273
- ## Quick Reference
274
-
275
- | Anti-Pattern | Fix |
276
- |--------------|-----|
277
- | Assert on mock elements | Test real component or unmock it |
278
- | Test-only methods in production | Move to test utilities |
279
- | Mock without understanding | Understand dependencies first, mock minimally |
280
- | Incomplete mocks | Mirror real API completely |
281
- | Tests as afterthought | TDD - tests first |
282
- | Over-complex mocks | Consider integration tests |
283
-
284
- ## Red Flags
285
-
286
- - Assertion checks for `*-mock` test IDs
287
- - Methods only called in test files
288
- - Mock setup is >50% of test
289
- - Test fails when you remove mock
290
- - Can't explain why mock is needed
291
- - Mocking "just to be safe"
292
-
293
- ## The Bottom Line
294
-
295
- **Mocks are tools to isolate, not things to test.**
296
-
297
- If TDD reveals you're testing mock behavior, you've gone wrong.
298
-
299
- Fix: Test real behavior or question why you're mocking at all.
12
+ Prefer stable public boundaries, realistic inputs, clear failure messages, and the smallest check that proves the requirement.