@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.
- package/README.md +17 -19
- package/dist/cli/arcs-flash.d.ts +1 -1
- package/dist/cli/arcs-flash.d.ts.map +1 -1
- package/dist/cli/arcs-flash.js +10 -53
- package/dist/cli/arcs-flash.js.map +1 -1
- package/dist/cli/arcs-orchestrate-caveman.d.ts +2 -2
- package/dist/cli/arcs-orchestrate-caveman.d.ts.map +1 -1
- package/dist/cli/arcs-orchestrate-caveman.js +2 -8
- package/dist/cli/arcs-orchestrate-caveman.js.map +1 -1
- package/dist/cli/arcs-orchestrate.d.ts +1 -1
- package/dist/cli/arcs-orchestrate.d.ts.map +1 -1
- package/dist/cli/arcs-orchestrate.js +4 -54
- package/dist/cli/arcs-orchestrate.js.map +1 -1
- package/dist/cli/commands/index.d.ts +0 -1
- package/dist/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/index.js +0 -1
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/project.js +1 -30
- package/dist/cli/commands/project.js.map +1 -1
- package/dist/cli/commands/proposal-doc.d.ts +2 -0
- package/dist/cli/commands/proposal-doc.d.ts.map +1 -0
- package/dist/cli/commands/proposal-doc.js +381 -0
- package/dist/cli/commands/proposal-doc.js.map +1 -0
- package/dist/cli/commands/web.js +4 -10
- package/dist/cli/commands/web.js.map +1 -1
- package/dist/cli/orchestrator-shared-blocks.d.ts +11 -30
- package/dist/cli/orchestrator-shared-blocks.d.ts.map +1 -1
- package/dist/cli/orchestrator-shared-blocks.js +49 -126
- package/dist/cli/orchestrator-shared-blocks.js.map +1 -1
- package/dist/utils/diagram-generator.d.ts.map +1 -1
- package/dist/utils/diagram-generator.js +11 -6
- package/dist/utils/diagram-generator.js.map +1 -1
- package/dist/utils/graphify-knowledge.d.ts +22 -0
- package/dist/utils/graphify-knowledge.d.ts.map +1 -0
- package/dist/utils/graphify-knowledge.js +47 -0
- package/dist/utils/graphify-knowledge.js.map +1 -0
- package/dist/utils/graphify.d.ts +104 -0
- package/dist/utils/graphify.d.ts.map +1 -0
- package/dist/utils/graphify.js +439 -0
- package/dist/utils/graphify.js.map +1 -0
- package/dist/utils/session-store.d.ts +24 -2
- package/dist/utils/session-store.d.ts.map +1 -1
- package/dist/utils/session-store.js +16 -7
- package/dist/utils/session-store.js.map +1 -1
- package/dist/utils/storage-utils.d.ts +1 -1
- package/dist/utils/storage-utils.d.ts.map +1 -1
- package/dist/utils/storage-utils.js +1 -1
- package/dist/utils/storage-utils.js.map +1 -1
- package/dist/web-client/assets/{GraphCanvas-BPDgvsyT.js → GraphCanvas-Dw6EcoDb.js} +1 -1
- package/dist/web-client/assets/{MarkdownEditor-D7TLp78z.js → MarkdownEditor-Cz5_44Ej.js} +1 -1
- package/dist/web-client/assets/{abnfDiagram-VRR7QNED-CyuP2N9t.js → abnfDiagram-VRR7QNED-CFJzLuew.js} +1 -1
- package/dist/web-client/assets/architecture-TIHT7OUA-CoHvhex9.js +1 -0
- package/dist/web-client/assets/{architectureDiagram-ZJ3FMSHR-DZ0ul9QX.js → architectureDiagram-ZJ3FMSHR-FRlSgnnW.js} +1 -1
- package/dist/web-client/assets/{blockDiagram-677ZJIJ3-LLGzlc9l.js → blockDiagram-677ZJIJ3-WUkkunPZ.js} +1 -1
- package/dist/web-client/assets/{c4Diagram-LMCZKHZV-CViu3CTc.js → c4Diagram-LMCZKHZV-BKeAsL6F.js} +1 -1
- package/dist/web-client/assets/channel-D8xMXC5_.js +1 -0
- package/dist/web-client/assets/{chunk-32BRIVSS-Bw_IuJCM.js → chunk-32BRIVSS-B0b9kUcF.js} +1 -1
- package/dist/web-client/assets/{chunk-52WLFC77-C29h440W.js → chunk-52WLFC77-i6Y-vfL3.js} +1 -1
- package/dist/web-client/assets/{chunk-C7G6YPKG-hhOrvw5w.js → chunk-C7G6YPKG-atYWm6iP.js} +1 -1
- package/dist/web-client/assets/{chunk-EX3LRPZG-COMzol-M.js → chunk-EX3LRPZG-CZD6y0UU.js} +1 -1
- package/dist/web-client/assets/{chunk-FWX5IMBZ-6vdX9EUn.js → chunk-FWX5IMBZ-CVErR-UZ.js} +2 -2
- package/dist/web-client/assets/{chunk-HOUHSVGY-DWDW6sxp.js → chunk-HOUHSVGY-BlHO2iQ3.js} +1 -1
- package/dist/web-client/assets/{chunk-ICXQ74PX-BdMYglo2.js → chunk-ICXQ74PX-Ar8kfXfa.js} +1 -1
- package/dist/web-client/assets/{chunk-MOJQB5TN-C0LAX_dC.js → chunk-MOJQB5TN-DKrK867P.js} +1 -1
- package/dist/web-client/assets/{chunk-OGEWGWER-CBx8MB7f.js → chunk-OGEWGWER-BmGykUeg.js} +1 -1
- package/dist/web-client/assets/{chunk-PUDLZKDR-DKssR1nf.js → chunk-PUDLZKDR-Bq23pnso.js} +1 -1
- package/dist/web-client/assets/{chunk-Q4XR5HBZ-B3kcxFE-.js → chunk-Q4XR5HBZ-g15qvFAN.js} +1 -1
- package/dist/web-client/assets/{chunk-V7JOEXUC-CAlymndy.js → chunk-V7JOEXUC-uyXA7S9r.js} +1 -1
- package/dist/web-client/assets/{chunk-VAUOI2AC-BowfsmTW.js → chunk-VAUOI2AC-WofZ-2M0.js} +1 -1
- package/dist/web-client/assets/{chunk-VR4S4FIN-BBOydgvt.js → chunk-VR4S4FIN-DtTkK86v.js} +1 -1
- package/dist/web-client/assets/{chunk-WYO6CB5R-DcymFbES.js → chunk-WYO6CB5R-zVyUwJq3.js} +1 -1
- package/dist/web-client/assets/{chunk-ZGVPDNZ5--uKFP-Lr.js → chunk-ZGVPDNZ5-CA1Oe3TK.js} +1 -1
- package/dist/web-client/assets/classDiagram-OUVF2IWQ-Doj1_hvZ.js +1 -0
- package/dist/web-client/assets/classDiagram-v2-EOCWNBFH-Doj1_hvZ.js +1 -0
- package/dist/web-client/assets/{cynefin-VYW2F7L2-CjboUOMA.js → cynefin-VYW2F7L2-ivJY1h_9.js} +1 -1
- package/dist/web-client/assets/{cynefinDiagram-TSTJHNR4-BcxygBP7.js → cynefinDiagram-TSTJHNR4-D2DstShq.js} +1 -1
- package/dist/web-client/assets/{dagre-VKFMJZFB-D-tiERQE.js → dagre-VKFMJZFB-CwnMRy0K.js} +1 -1
- package/dist/web-client/assets/{diagram-FQU43EPY-ChPXczaS.js → diagram-FQU43EPY-BKJv6Cvw.js} +1 -1
- package/dist/web-client/assets/{diagram-G47NLZAW-CVL3Y91h.js → diagram-G47NLZAW-CwCXcgU5.js} +1 -1
- package/dist/web-client/assets/{diagram-NH7WQ7WH-DsaNA9Lh.js → diagram-NH7WQ7WH-CkghU1-6.js} +1 -1
- package/dist/web-client/assets/{diagram-OA4YK3LP-CXhrhdhU.js → diagram-OA4YK3LP-D3siQIGu.js} +1 -1
- package/dist/web-client/assets/{diagram-WEI45ONY-BTVPnk4E.js → diagram-WEI45ONY-CSs9xTBn.js} +1 -1
- package/dist/web-client/assets/{ebnfDiagram-CCIWWBDH-BAyrRBtM.js → ebnfDiagram-CCIWWBDH--i52vMiv.js} +1 -1
- package/dist/web-client/assets/{erDiagram-Q63AITRT-Qm24Wepm.js → erDiagram-Q63AITRT-q2hgOBY1.js} +1 -1
- package/dist/web-client/assets/eventmodeling-45OFAUF4-ESVuFkJJ.js +1 -0
- package/dist/web-client/assets/flowDiagram-23GEKE2U-DN9SdR9f.js +1 -0
- package/dist/web-client/assets/{ganttDiagram-NO4QXBWP-D8h7l3XJ.js → ganttDiagram-NO4QXBWP-BZ2rBbTe.js} +1 -1
- package/dist/web-client/assets/{gitGraph-TEB2WS4Q-DIBml1SB.js → gitGraph-TEB2WS4Q-OnJ8tHgt.js} +1 -1
- package/dist/web-client/assets/{gitGraphDiagram-IHSO6WYX-CtkYoXjn.js → gitGraphDiagram-IHSO6WYX-CPNExFAr.js} +1 -1
- package/dist/web-client/assets/{index-DOSH4Q9H.js → index-DCBn-YrR.js} +38 -38
- package/dist/web-client/assets/{info-DKCQHKI2-DLEUtV5Q.js → info-DKCQHKI2-DGuJbmdY.js} +1 -1
- package/dist/web-client/assets/{infoDiagram-FWYZ7A6U-BJQ7aQux.js → infoDiagram-FWYZ7A6U-ADIAn-P5.js} +1 -1
- package/dist/web-client/assets/{ishikawaDiagram-FXEZZL3T-BPM11FvG.js → ishikawaDiagram-FXEZZL3T-CUx-RGfg.js} +1 -1
- package/dist/web-client/assets/{journeyDiagram-5HDEW3XC-C0aX2z3c.js → journeyDiagram-5HDEW3XC-BH7-tBBy.js} +1 -1
- package/dist/web-client/assets/{kanban-definition-HUTT4EX6-C56F29Ib.js → kanban-definition-HUTT4EX6-BGEXBnI2.js} +1 -1
- package/dist/web-client/assets/{line-BLFHLF2N.js → line-CC-5ezU8.js} +1 -1
- package/dist/web-client/assets/{mermaid-parser.core-BLC8FhgU.js → mermaid-parser.core-Dw18Fjbq.js} +3 -3
- package/dist/web-client/assets/{mermaid.core-BBqkKuXt.js → mermaid.core-CMQBgE43.js} +3 -3
- package/dist/web-client/assets/{mindmap-definition-LN4V7U3C-aVZbsoPc.js → mindmap-definition-LN4V7U3C-CGtjw8tB.js} +1 -1
- package/dist/web-client/assets/{packet-7NZHBO7P-D4aqSQfB.js → packet-7NZHBO7P-w71Y4Hzd.js} +1 -1
- package/dist/web-client/assets/{pegDiagram-2B236MQR-DjfyNI0U.js → pegDiagram-2B236MQR-DWtfEm4T.js} +1 -1
- package/dist/web-client/assets/{pie-RZYD4A2V-ChCwYsYj.js → pie-RZYD4A2V-S9ztgnWs.js} +1 -1
- package/dist/web-client/assets/{pieDiagram-ENE6RG2P-BeHLKkXC.js → pieDiagram-ENE6RG2P-BWZQPN4m.js} +1 -1
- package/dist/web-client/assets/{quadrantDiagram-ABIIQ3AL-stga3gvq.js → quadrantDiagram-ABIIQ3AL-DINDwblH.js} +1 -1
- package/dist/web-client/assets/{radar-I7S5WNFK-DOGheiwT.js → radar-I7S5WNFK-BOGl9krB.js} +1 -1
- package/dist/web-client/assets/{railroad-3IZDKUUU-_JnU7M6L.js → railroad-3IZDKUUU-CR9kuYSZ.js} +1 -1
- package/dist/web-client/assets/railroad-abnf-AHOZXSZD-BvbCHrlR.js +1 -0
- package/dist/web-client/assets/railroad-ebnf-EBAXGLYW-D869lbCL.js +1 -0
- package/dist/web-client/assets/railroad-peg-LSFZ7HO6-r4TXaJPI.js +1 -0
- package/dist/web-client/assets/{railroadDiagram-RFXS5EU6-C0CkMsOd.js → railroadDiagram-RFXS5EU6-byLCs9hp.js} +1 -1
- package/dist/web-client/assets/{requirementDiagram-TGXJPOKE-DuImwoRD.js → requirementDiagram-TGXJPOKE-Dn_FtbqW.js} +1 -1
- package/dist/web-client/assets/{sankeyDiagram-HTMAVEWB-kprq0XF9.js → sankeyDiagram-HTMAVEWB-DUjRrCeC.js} +1 -1
- package/dist/web-client/assets/{sequenceDiagram-DBY2YBRQ-DiXKJMF6.js → sequenceDiagram-DBY2YBRQ-BmBz8Wpq.js} +1 -1
- package/dist/web-client/assets/{stateDiagram-2N3HPSRC-D5qbVStE.js → stateDiagram-2N3HPSRC-BAYHjmqB.js} +1 -1
- package/dist/web-client/assets/stateDiagram-v2-6OUMAXLB-Bl-1K1zV.js +1 -0
- package/dist/web-client/assets/{swimlanes-5IMT3BWC-DCbw389c.js → swimlanes-5IMT3BWC-Bm942AR-.js} +1 -1
- package/dist/web-client/assets/swimlanesDiagram-G3AALYLV-DHU7bsfA.js +8 -0
- package/dist/web-client/assets/{timeline-definition-FHXFAJF6-CQeaYN_9.js → timeline-definition-FHXFAJF6-CHAZHhQk.js} +1 -1
- package/dist/web-client/assets/{treeView-QDETBFTQ-Cf7Sq3qo.js → treeView-QDETBFTQ-DHHkLsSy.js} +1 -1
- package/dist/web-client/assets/{treemap-6X3UGDF4-BovzvoTU.js → treemap-6X3UGDF4-BUxZ8fhY.js} +1 -1
- package/dist/web-client/assets/{vennDiagram-L72KCM5P-CZsJy139.js → vennDiagram-L72KCM5P-BL9TRcUU.js} +1 -1
- package/dist/web-client/assets/{wardley-OPB4EBWU-DJ7MS6XZ.js → wardley-OPB4EBWU-CfJ5mO-y.js} +1 -1
- package/dist/web-client/assets/{wardleyDiagram-EHGQE667-rqhcmsbM.js → wardleyDiagram-EHGQE667-BlH1TSjy.js} +1 -1
- package/dist/web-client/assets/{xychartDiagram-FW5EYKEG-HuK4Seps.js → xychartDiagram-FW5EYKEG-BJN6wtrV.js} +1 -1
- package/dist/web-client/index.html +1 -1
- package/dist/web-server/app.d.ts.map +1 -1
- package/dist/web-server/app.js +1 -7
- package/dist/web-server/app.js.map +1 -1
- package/dist/web-server/claude-runner.d.ts +11 -4
- package/dist/web-server/claude-runner.d.ts.map +1 -1
- package/dist/web-server/claude-runner.js +10 -14
- package/dist/web-server/claude-runner.js.map +1 -1
- package/dist/web-server/index.d.ts.map +1 -1
- package/dist/web-server/index.js +4 -1
- package/dist/web-server/index.js.map +1 -1
- package/dist/web-server/opencode-client.d.ts +123 -0
- package/dist/web-server/opencode-client.d.ts.map +1 -0
- package/dist/web-server/opencode-client.js +514 -0
- package/dist/web-server/opencode-client.js.map +1 -0
- package/dist/web-server/prompt-assembly.d.ts.map +1 -1
- package/dist/web-server/prompt-assembly.js +1 -2
- package/dist/web-server/prompt-assembly.js.map +1 -1
- package/dist/web-server/routes/sessions.d.ts +9 -6
- package/dist/web-server/routes/sessions.d.ts.map +1 -1
- package/dist/web-server/routes/sessions.js +272 -205
- package/dist/web-server/routes/sessions.js.map +1 -1
- package/dist/web-server/run-driver.d.ts +113 -0
- package/dist/web-server/run-driver.d.ts.map +1 -0
- package/dist/web-server/run-driver.js +214 -0
- package/dist/web-server/run-driver.js.map +1 -0
- package/dist/web-server/run-event-log.d.ts +23 -1
- package/dist/web-server/run-event-log.d.ts.map +1 -1
- package/dist/web-server/run-event-log.js +29 -5
- package/dist/web-server/run-event-log.js.map +1 -1
- package/dist/web-server/web-auth.d.ts +3 -5
- package/dist/web-server/web-auth.d.ts.map +1 -1
- package/dist/web-server/web-auth.js +6 -11
- package/dist/web-server/web-auth.js.map +1 -1
- package/dist/web-server/web-token.d.ts +1 -2
- package/dist/web-server/web-token.d.ts.map +1 -1
- package/dist/web-server/web-token.js +1 -2
- package/dist/web-server/web-token.js.map +1 -1
- package/opencode/arcs/bundle-runtime.json +0 -6
- package/opencode/arcs/manifest.json +8 -25
- package/opencode/arcs/prompts/arcs-docs.txt +19 -157
- package/opencode/arcs/prompts/arcs-flash.txt +46 -155
- package/opencode/arcs/prompts/arcs-orchestrate-caveman.txt +48 -164
- package/opencode/arcs/prompts/arcs-orchestrate.txt +47 -157
- package/opencode/arcs/prompts/code-reviewer.txt +20 -60
- package/opencode/arcs/prompts/graph-explorer.txt +19 -49
- package/opencode/arcs/prompts/software-engineer.txt +21 -67
- package/opencode/arcs/prompts/tech-architect.txt +20 -130
- package/opencode/arcs/skills/brainstorming/SKILL.md +20 -100
- package/opencode/arcs/skills/brainstorming/visual-companion.md +6 -264
- package/opencode/arcs/skills/caveman-commit/SKILL.md +6 -43
- package/opencode/arcs/skills/deep-pr-review/SKILL.md +18 -200
- package/opencode/arcs/skills/deep-pr-review/codegraph-diff.md +7 -93
- package/opencode/arcs/skills/deep-pr-review/review-template.md +13 -60
- package/opencode/arcs/skills/enriching-codegraph-proposals/SKILL.md +16 -156
- package/opencode/arcs/skills/implementation/SKILL.md +20 -46
- package/opencode/arcs/skills/init-project/SKILL.md +12 -150
- package/opencode/arcs/skills/systematic-debugging/SKILL.md +13 -152
- package/opencode/arcs/skills/systematic-debugging/condition-based-waiting.md +7 -110
- package/opencode/arcs/skills/systematic-debugging/defense-in-depth.md +7 -119
- package/opencode/arcs/skills/systematic-debugging/phases-reference.md +9 -166
- package/opencode/arcs/skills/systematic-debugging/root-cause-tracing.md +8 -165
- package/opencode/arcs/skills/test-driven-development/SKILL.md +10 -61
- package/opencode/arcs/skills/test-driven-development/tdd-rationalizations-and-examples.md +7 -154
- package/opencode/arcs/skills/test-driven-development/testing-anti-patterns.md +8 -295
- package/opencode/arcs/skills/to-diagram/SKILL.md +18 -206
- package/opencode/arcs/skills/writing-knowledge/SKILL.md +11 -63
- package/opencode/arcs/skills/writing-plans/SKILL.md +25 -118
- package/opencode/arcs/skills/writing-plans/plan-document-reviewer-prompt.md +10 -61
- package/package.json +1 -1
- package/skills/explore-dag.md +9 -52
- package/skills/init-project.md +9 -98
- package/skills/orchestrate.md +15 -109
- package/skills/update-docs.md +9 -60
- package/dist/web-client/assets/architecture-TIHT7OUA-Bdo2Yvm9.js +0 -1
- package/dist/web-client/assets/channel-DBNmizpo.js +0 -1
- package/dist/web-client/assets/classDiagram-OUVF2IWQ-CB3HiA1_.js +0 -1
- package/dist/web-client/assets/classDiagram-v2-EOCWNBFH-CB3HiA1_.js +0 -1
- package/dist/web-client/assets/eventmodeling-45OFAUF4-DoTBIvl5.js +0 -1
- package/dist/web-client/assets/flowDiagram-23GEKE2U-BEH23L1A.js +0 -1
- package/dist/web-client/assets/railroad-abnf-AHOZXSZD-nhNub7LE.js +0 -1
- package/dist/web-client/assets/railroad-ebnf-EBAXGLYW-BlQYe7Yf.js +0 -1
- package/dist/web-client/assets/railroad-peg-LSFZ7HO6-B3E8pRVN.js +0 -1
- package/dist/web-client/assets/stateDiagram-v2-6OUMAXLB-DWwTAG1r.js +0 -1
- package/dist/web-client/assets/swimlanesDiagram-G3AALYLV-DabrCsjZ.js +0 -8
- package/opencode/arcs/prompts/devil-advocate.txt +0 -79
- package/opencode/arcs/skills/executing-plans/SKILL.md +0 -49
- package/opencode/arcs/skills/install-claude-code-hook/SKILL.md +0 -143
- package/scripts/claude-code-session-hook.mjs +0 -146
|
@@ -1,122 +1,10 @@
|
|
|
1
|
-
# Defense
|
|
1
|
+
# Defense in Depth
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
After fixing the root cause, add another guard only when it prevents a distinct realistic failure:
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
- validate at an input boundary;
|
|
6
|
+
- preserve an invariant in the domain layer;
|
|
7
|
+
- make an unsafe state unrepresentable;
|
|
8
|
+
- monitor a failure that cannot be prevented.
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## Why Multiple Layers
|
|
10
|
-
|
|
11
|
-
Single validation: "We fixed the bug"
|
|
12
|
-
Multiple layers: "We made the bug impossible"
|
|
13
|
-
|
|
14
|
-
Different layers catch different cases:
|
|
15
|
-
- Entry validation catches most bugs
|
|
16
|
-
- Business logic catches edge cases
|
|
17
|
-
- Environment guards prevent context-specific dangers
|
|
18
|
-
- Debug logging helps when other layers fail
|
|
19
|
-
|
|
20
|
-
## The Four Layers
|
|
21
|
-
|
|
22
|
-
### Layer 1: Entry Point Validation
|
|
23
|
-
**Purpose:** Reject obviously invalid input at API boundary
|
|
24
|
-
|
|
25
|
-
```typescript
|
|
26
|
-
function createProject(name: string, workingDirectory: string) {
|
|
27
|
-
if (!workingDirectory || workingDirectory.trim() === '') {
|
|
28
|
-
throw new Error('workingDirectory cannot be empty');
|
|
29
|
-
}
|
|
30
|
-
if (!existsSync(workingDirectory)) {
|
|
31
|
-
throw new Error(`workingDirectory does not exist: ${workingDirectory}`);
|
|
32
|
-
}
|
|
33
|
-
if (!statSync(workingDirectory).isDirectory()) {
|
|
34
|
-
throw new Error(`workingDirectory is not a directory: ${workingDirectory}`);
|
|
35
|
-
}
|
|
36
|
-
// ... proceed
|
|
37
|
-
}
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
### Layer 2: Business Logic Validation
|
|
41
|
-
**Purpose:** Ensure data makes sense for this operation
|
|
42
|
-
|
|
43
|
-
```typescript
|
|
44
|
-
function initializeWorkspace(projectDir: string, sessionId: string) {
|
|
45
|
-
if (!projectDir) {
|
|
46
|
-
throw new Error('projectDir required for workspace initialization');
|
|
47
|
-
}
|
|
48
|
-
// ... proceed
|
|
49
|
-
}
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### Layer 3: Environment Guards
|
|
53
|
-
**Purpose:** Prevent dangerous operations in specific contexts
|
|
54
|
-
|
|
55
|
-
```typescript
|
|
56
|
-
async function gitInit(directory: string) {
|
|
57
|
-
// In tests, refuse git init outside temp directories
|
|
58
|
-
if (process.env.NODE_ENV === 'test') {
|
|
59
|
-
const normalized = normalize(resolve(directory));
|
|
60
|
-
const tmpDir = normalize(resolve(tmpdir()));
|
|
61
|
-
|
|
62
|
-
if (!normalized.startsWith(tmpDir)) {
|
|
63
|
-
throw new Error(
|
|
64
|
-
`Refusing git init outside temp dir during tests: ${directory}`
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
// ... proceed
|
|
69
|
-
}
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### Layer 4: Debug Instrumentation
|
|
73
|
-
**Purpose:** Capture context for forensics
|
|
74
|
-
|
|
75
|
-
```typescript
|
|
76
|
-
async function gitInit(directory: string) {
|
|
77
|
-
const stack = new Error().stack;
|
|
78
|
-
logger.debug('About to git init', {
|
|
79
|
-
directory,
|
|
80
|
-
cwd: process.cwd(),
|
|
81
|
-
stack,
|
|
82
|
-
});
|
|
83
|
-
// ... proceed
|
|
84
|
-
}
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Applying the Pattern
|
|
88
|
-
|
|
89
|
-
When you find a bug:
|
|
90
|
-
|
|
91
|
-
1. **Trace the data flow** - Where does bad value originate? Where used?
|
|
92
|
-
2. **Map all checkpoints** - List every point data passes through
|
|
93
|
-
3. **Add validation at each layer** - Entry, business, environment, debug
|
|
94
|
-
4. **Test each layer** - Try to bypass layer 1, verify layer 2 catches it
|
|
95
|
-
|
|
96
|
-
## Example from Session
|
|
97
|
-
|
|
98
|
-
Bug: Empty `projectDir` caused `git init` in source code
|
|
99
|
-
|
|
100
|
-
**Data flow:**
|
|
101
|
-
1. Test setup → empty string
|
|
102
|
-
2. `Project.create(name, '')`
|
|
103
|
-
3. `WorkspaceManager.createWorkspace('')`
|
|
104
|
-
4. `git init` runs in `process.cwd()`
|
|
105
|
-
|
|
106
|
-
**Four layers added:**
|
|
107
|
-
- Layer 1: `Project.create()` validates not empty/exists/writable
|
|
108
|
-
- Layer 2: `WorkspaceManager` validates projectDir not empty
|
|
109
|
-
- Layer 3: `WorktreeManager` refuses git init outside tmpdir in tests
|
|
110
|
-
- Layer 4: Stack trace logging before git init
|
|
111
|
-
|
|
112
|
-
**Result:** All 1847 tests passed, bug impossible to reproduce
|
|
113
|
-
|
|
114
|
-
## Key Insight
|
|
115
|
-
|
|
116
|
-
All four layers were necessary. During testing, each layer caught bugs the others missed:
|
|
117
|
-
- Different code paths bypassed entry validation
|
|
118
|
-
- Mocks bypassed business logic checks
|
|
119
|
-
- Edge cases on different platforms needed environment guards
|
|
120
|
-
- Debug logging identified structural misuse
|
|
121
|
-
|
|
122
|
-
**Don't stop at one validation point.** Add checks at every layer.
|
|
10
|
+
Do not duplicate the same check across layers without a concrete failure mode.
|
|
@@ -1,168 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Debugging Phases
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
1. Observe the complete failure.
|
|
4
|
+
2. Reproduce it reliably.
|
|
5
|
+
3. Form one specific hypothesis.
|
|
6
|
+
4. Isolate one variable.
|
|
7
|
+
5. Add a regression test when practical.
|
|
8
|
+
6. Fix the root cause.
|
|
9
|
+
7. Verify the reproduction and relevant checks.
|
|
4
10
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
**BEFORE attempting ANY fix:**
|
|
8
|
-
|
|
9
|
-
1. **Read Error Messages Carefully**
|
|
10
|
-
- Don't skip past errors or warnings
|
|
11
|
-
- They often contain the exact solution
|
|
12
|
-
- Read stack traces completely
|
|
13
|
-
- Note line numbers, file paths, error codes
|
|
14
|
-
|
|
15
|
-
2. **Reproduce Consistently**
|
|
16
|
-
- Can you trigger it reliably?
|
|
17
|
-
- What are the exact steps?
|
|
18
|
-
- Does it happen every time?
|
|
19
|
-
- If not reproducible → gather more data, don't guess
|
|
20
|
-
|
|
21
|
-
3. **Check Recent Changes**
|
|
22
|
-
- What changed that could cause this?
|
|
23
|
-
- Git diff, recent commits
|
|
24
|
-
- New dependencies, config changes
|
|
25
|
-
- Environmental differences
|
|
26
|
-
|
|
27
|
-
4. **Gather Evidence in Multi-Component Systems**
|
|
28
|
-
|
|
29
|
-
**WHEN system has multiple components (CI → build → signing, API → service → database):**
|
|
30
|
-
|
|
31
|
-
**BEFORE proposing fixes, add diagnostic instrumentation:**
|
|
32
|
-
```
|
|
33
|
-
For EACH component boundary:
|
|
34
|
-
- Log what data enters component
|
|
35
|
-
- Log what data exits component
|
|
36
|
-
- Verify environment/config propagation
|
|
37
|
-
- Check state at each layer
|
|
38
|
-
|
|
39
|
-
Run once to gather evidence showing WHERE it breaks
|
|
40
|
-
THEN analyze evidence to identify failing component
|
|
41
|
-
THEN investigate that specific component
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
**Example (multi-layer system):**
|
|
45
|
-
```bash
|
|
46
|
-
# Layer 1: Workflow
|
|
47
|
-
echo "=== Secrets available in workflow: ==="
|
|
48
|
-
echo "IDENTITY: ${IDENTITY:+SET}${IDENTITY:-UNSET}"
|
|
49
|
-
|
|
50
|
-
# Layer 2: Build script
|
|
51
|
-
echo "=== Env vars in build script: ==="
|
|
52
|
-
env | grep IDENTITY || echo "IDENTITY not in environment"
|
|
53
|
-
|
|
54
|
-
# Layer 3: Signing script
|
|
55
|
-
echo "=== Keychain state: ==="
|
|
56
|
-
security list-keychains
|
|
57
|
-
security find-identity -v
|
|
58
|
-
|
|
59
|
-
# Layer 4: Actual signing
|
|
60
|
-
codesign --sign "$IDENTITY" --verbose=4 "$APP"
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
**This reveals:** Which layer fails (secrets → workflow ✓, workflow → build ✗)
|
|
64
|
-
|
|
65
|
-
5. **Trace Data Flow**
|
|
66
|
-
|
|
67
|
-
**WHEN error is deep in call stack:**
|
|
68
|
-
|
|
69
|
-
See `root-cause-tracing.md` in this directory for the complete backward tracing technique.
|
|
70
|
-
|
|
71
|
-
**Quick version:**
|
|
72
|
-
- Where does bad value originate?
|
|
73
|
-
- What called this with bad value?
|
|
74
|
-
- Keep tracing up until you find the source
|
|
75
|
-
- Fix at source, not at symptom
|
|
76
|
-
|
|
77
|
-
## Phase 2: Pattern Analysis
|
|
78
|
-
|
|
79
|
-
**Find the pattern before fixing:**
|
|
80
|
-
|
|
81
|
-
1. **Find Working Examples**
|
|
82
|
-
- Locate similar working code in same codebase
|
|
83
|
-
- What works that's similar to what's broken?
|
|
84
|
-
|
|
85
|
-
2. **Compare Against References**
|
|
86
|
-
- If implementing pattern, read reference implementation COMPLETELY
|
|
87
|
-
- Don't skim — read every line
|
|
88
|
-
- Understand the pattern fully before applying
|
|
89
|
-
|
|
90
|
-
3. **Identify Differences**
|
|
91
|
-
- What's different between working and broken?
|
|
92
|
-
- List every difference, however small
|
|
93
|
-
- Don't assume "that can't matter"
|
|
94
|
-
|
|
95
|
-
4. **Understand Dependencies**
|
|
96
|
-
- What other components does this need?
|
|
97
|
-
- What settings, config, environment?
|
|
98
|
-
- What assumptions does it make?
|
|
99
|
-
|
|
100
|
-
## Phase 3: Hypothesis and Testing
|
|
101
|
-
|
|
102
|
-
**Scientific method:**
|
|
103
|
-
|
|
104
|
-
1. **Form Single Hypothesis**
|
|
105
|
-
- State clearly: "I think X is the root cause because Y"
|
|
106
|
-
- Write it down
|
|
107
|
-
- Be specific, not vague
|
|
108
|
-
|
|
109
|
-
2. **Test Minimally**
|
|
110
|
-
- Make the SMALLEST possible change to test hypothesis
|
|
111
|
-
- One variable at a time
|
|
112
|
-
- Don't fix multiple things at once
|
|
113
|
-
|
|
114
|
-
3. **Verify Before Continuing**
|
|
115
|
-
- Did it work? Yes → Phase 4
|
|
116
|
-
- Didn't work? Form NEW hypothesis
|
|
117
|
-
- DON'T add more fixes on top
|
|
118
|
-
|
|
119
|
-
4. **When You Don't Know**
|
|
120
|
-
- Say "I don't understand X"
|
|
121
|
-
- Don't pretend to know
|
|
122
|
-
- Ask for help
|
|
123
|
-
- Research more
|
|
124
|
-
|
|
125
|
-
## Phase 4: Implementation
|
|
126
|
-
|
|
127
|
-
**Fix the root cause, not the symptom:**
|
|
128
|
-
|
|
129
|
-
1. **Create Failing Test Case**
|
|
130
|
-
- Simplest possible reproduction
|
|
131
|
-
- Automated test if possible
|
|
132
|
-
- One-off test script if no framework
|
|
133
|
-
- MUST have before fixing
|
|
134
|
-
- Use the `arcs:test-driven-development` skill for writing proper failing tests
|
|
135
|
-
|
|
136
|
-
2. **Implement Single Fix**
|
|
137
|
-
- Address the root cause identified
|
|
138
|
-
- ONE change at a time
|
|
139
|
-
- No "while I'm here" improvements
|
|
140
|
-
- No bundled refactoring
|
|
141
|
-
|
|
142
|
-
3. **Verify Fix**
|
|
143
|
-
- Test passes now?
|
|
144
|
-
- No other tests broken?
|
|
145
|
-
- Issue actually resolved?
|
|
146
|
-
|
|
147
|
-
4. **If Fix Doesn't Work**
|
|
148
|
-
- STOP
|
|
149
|
-
- Count: How many fixes have you tried?
|
|
150
|
-
- If < 3: Return to Phase 1, re-analyze with new information
|
|
151
|
-
- **If ≥ 3: STOP and question the architecture (step 5 below)**
|
|
152
|
-
- DON'T attempt Fix #4 without architectural discussion
|
|
153
|
-
|
|
154
|
-
5. **If 3+ Fixes Failed: Question Architecture**
|
|
155
|
-
|
|
156
|
-
**Pattern indicating architectural problem:**
|
|
157
|
-
- Each fix reveals new shared state/coupling/problem in different place
|
|
158
|
-
- Fixes require "massive refactoring" to implement
|
|
159
|
-
- Each fix creates new symptoms elsewhere
|
|
160
|
-
|
|
161
|
-
**STOP and question fundamentals:**
|
|
162
|
-
- Is this pattern fundamentally sound?
|
|
163
|
-
- Are we "sticking with it through sheer inertia"?
|
|
164
|
-
- Should we refactor architecture vs. continue fixing symptoms?
|
|
165
|
-
|
|
166
|
-
**Discuss with your human partner before attempting more fixes**
|
|
167
|
-
|
|
168
|
-
This is NOT a failed hypothesis — this is a wrong architecture.
|
|
11
|
+
After three failed fixes, stop and revisit assumptions or architecture.
|
|
@@ -1,169 +1,12 @@
|
|
|
1
|
-
# Root
|
|
1
|
+
# Root-Cause Tracing
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Start at the observed failure and trace inputs backward through boundaries until the first incorrect state appears.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
At each boundary record:
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- expected value;
|
|
8
|
+
- actual value;
|
|
9
|
+
- producer;
|
|
10
|
+
- evidence.
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
```dot
|
|
12
|
-
digraph when_to_use {
|
|
13
|
-
"Bug appears deep in stack?" [shape=diamond];
|
|
14
|
-
"Can trace backwards?" [shape=diamond];
|
|
15
|
-
"Fix at symptom point" [shape=box];
|
|
16
|
-
"Trace to original trigger" [shape=box];
|
|
17
|
-
"BETTER: Also add defense-in-depth" [shape=box];
|
|
18
|
-
|
|
19
|
-
"Bug appears deep in stack?" -> "Can trace backwards?" [label="yes"];
|
|
20
|
-
"Can trace backwards?" -> "Trace to original trigger" [label="yes"];
|
|
21
|
-
"Can trace backwards?" -> "Fix at symptom point" [label="no - dead end"];
|
|
22
|
-
"Trace to original trigger" -> "BETTER: Also add defense-in-depth";
|
|
23
|
-
}
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
**Use when:**
|
|
27
|
-
- Error happens deep in execution (not at entry point)
|
|
28
|
-
- Stack trace shows long call chain
|
|
29
|
-
- Unclear where invalid data originated
|
|
30
|
-
- Need to find which test/code triggers the problem
|
|
31
|
-
|
|
32
|
-
## The Tracing Process
|
|
33
|
-
|
|
34
|
-
### 1. Observe the Symptom
|
|
35
|
-
```
|
|
36
|
-
Error: git init failed in /Users/jesse/project/packages/core
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### 2. Find Immediate Cause
|
|
40
|
-
**What code directly causes this?**
|
|
41
|
-
```typescript
|
|
42
|
-
await execFileAsync('git', ['init'], { cwd: projectDir });
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### 3. Ask: What Called This?
|
|
46
|
-
```typescript
|
|
47
|
-
WorktreeManager.createSessionWorktree(projectDir, sessionId)
|
|
48
|
-
→ called by Session.initializeWorkspace()
|
|
49
|
-
→ called by Session.create()
|
|
50
|
-
→ called by test at Project.create()
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### 4. Keep Tracing Up
|
|
54
|
-
**What value was passed?**
|
|
55
|
-
- `projectDir = ''` (empty string!)
|
|
56
|
-
- Empty string as `cwd` resolves to `process.cwd()`
|
|
57
|
-
- That's the source code directory!
|
|
58
|
-
|
|
59
|
-
### 5. Find Original Trigger
|
|
60
|
-
**Where did empty string come from?**
|
|
61
|
-
```typescript
|
|
62
|
-
const context = setupCoreTest(); // Returns { tempDir: '' }
|
|
63
|
-
Project.create('name', context.tempDir); // Accessed before beforeEach!
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## Adding Stack Traces
|
|
67
|
-
|
|
68
|
-
When you can't trace manually, add instrumentation:
|
|
69
|
-
|
|
70
|
-
```typescript
|
|
71
|
-
// Before the problematic operation
|
|
72
|
-
async function gitInit(directory: string) {
|
|
73
|
-
const stack = new Error().stack;
|
|
74
|
-
console.error('DEBUG git init:', {
|
|
75
|
-
directory,
|
|
76
|
-
cwd: process.cwd(),
|
|
77
|
-
nodeEnv: process.env.NODE_ENV,
|
|
78
|
-
stack,
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
await execFileAsync('git', ['init'], { cwd: directory });
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
**Critical:** Use `console.error()` in tests (not logger - may not show)
|
|
86
|
-
|
|
87
|
-
**Run and capture (scoped to the suspect test file — never the full suite):**
|
|
88
|
-
```bash
|
|
89
|
-
npm test -- path/to/suspect.test.ts 2>&1 | grep 'DEBUG git init'
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
**Analyze stack traces:**
|
|
93
|
-
- Look for test file names
|
|
94
|
-
- Find the line number triggering the call
|
|
95
|
-
- Identify the pattern (same test? same parameter?)
|
|
96
|
-
|
|
97
|
-
## Finding Which Test Causes Pollution
|
|
98
|
-
|
|
99
|
-
If something appears during tests but you don't know which test:
|
|
100
|
-
|
|
101
|
-
Use the bisection script `find-polluter.sh` in this directory:
|
|
102
|
-
|
|
103
|
-
```bash
|
|
104
|
-
./find-polluter.sh '.git' 'src/**/*.test.ts'
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
Runs tests one-by-one, stops at first polluter. See script for usage.
|
|
108
|
-
|
|
109
|
-
## Real Example: Empty projectDir
|
|
110
|
-
|
|
111
|
-
**Symptom:** `.git` created in `packages/core/` (source code)
|
|
112
|
-
|
|
113
|
-
**Trace chain:**
|
|
114
|
-
1. `git init` runs in `process.cwd()` ← empty cwd parameter
|
|
115
|
-
2. WorktreeManager called with empty projectDir
|
|
116
|
-
3. Session.create() passed empty string
|
|
117
|
-
4. Test accessed `context.tempDir` before beforeEach
|
|
118
|
-
5. setupCoreTest() returns `{ tempDir: '' }` initially
|
|
119
|
-
|
|
120
|
-
**Root cause:** Top-level variable initialization accessing empty value
|
|
121
|
-
|
|
122
|
-
**Fix:** Made tempDir a getter that throws if accessed before beforeEach
|
|
123
|
-
|
|
124
|
-
**Also added defense-in-depth:**
|
|
125
|
-
- Layer 1: Project.create() validates directory
|
|
126
|
-
- Layer 2: WorkspaceManager validates not empty
|
|
127
|
-
- Layer 3: NODE_ENV guard refuses git init outside tmpdir
|
|
128
|
-
- Layer 4: Stack trace logging before git init
|
|
129
|
-
|
|
130
|
-
## Key Principle
|
|
131
|
-
|
|
132
|
-
```dot
|
|
133
|
-
digraph principle {
|
|
134
|
-
"Found immediate cause" [shape=ellipse];
|
|
135
|
-
"Can trace one level up?" [shape=diamond];
|
|
136
|
-
"Trace backwards" [shape=box];
|
|
137
|
-
"Is this the source?" [shape=diamond];
|
|
138
|
-
"Fix at source" [shape=box];
|
|
139
|
-
"Add validation at each layer" [shape=box];
|
|
140
|
-
"Bug impossible" [shape=doublecircle];
|
|
141
|
-
"NEVER fix just the symptom" [shape=octagon, style=filled, fillcolor=red, fontcolor=white];
|
|
142
|
-
|
|
143
|
-
"Found immediate cause" -> "Can trace one level up?";
|
|
144
|
-
"Can trace one level up?" -> "Trace backwards" [label="yes"];
|
|
145
|
-
"Can trace one level up?" -> "NEVER fix just the symptom" [label="no"];
|
|
146
|
-
"Trace backwards" -> "Is this the source?";
|
|
147
|
-
"Is this the source?" -> "Trace backwards" [label="no - keeps going"];
|
|
148
|
-
"Is this the source?" -> "Fix at source" [label="yes"];
|
|
149
|
-
"Fix at source" -> "Add validation at each layer";
|
|
150
|
-
"Add validation at each layer" -> "Bug impossible";
|
|
151
|
-
}
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
**NEVER fix just where the error appears.** Trace back to find the original trigger.
|
|
155
|
-
|
|
156
|
-
## Stack Trace Tips
|
|
157
|
-
|
|
158
|
-
**In tests:** Use `console.error()` not logger - logger may be suppressed
|
|
159
|
-
**Before operation:** Log before the dangerous operation, not after it fails
|
|
160
|
-
**Include context:** Directory, cwd, environment variables, timestamps
|
|
161
|
-
**Capture stack:** `new Error().stack` shows complete call chain
|
|
162
|
-
|
|
163
|
-
## Real-World Impact
|
|
164
|
-
|
|
165
|
-
From debugging session (2025-10-03):
|
|
166
|
-
- Found root cause through 5-level trace
|
|
167
|
-
- Fixed at source (getter validation)
|
|
168
|
-
- Added 4 layers of defense
|
|
169
|
-
- 1847 tests passed, zero pollution
|
|
12
|
+
Fix the earliest incorrect assumption you own, not the last place that notices it. Compare with a working path when available.
|
|
@@ -1,72 +1,21 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: test-driven-development
|
|
3
|
-
description: Use
|
|
3
|
+
description: Use a focused red-green-refactor loop for observable behavior changes
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# Test-Driven Development
|
|
7
7
|
|
|
8
8
|
## When
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Use when a feature, bug fix, or behavior change benefits from executable proof. Prose, metadata, generated output, or mechanical refactors may rely on existing contracts instead of adding a new test.
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
## Loop
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
For a behavior change, write one failing test demonstrating the requirement, run to confirm expected failure, add minimal implementation, rerun until green, then refactor while preserving behavior.
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
B -->|Wrong failure| A
|
|
21
|
-
B -->|Passes immediately| D[Test is wrong — fix or delete]
|
|
22
|
-
D --> A
|
|
23
|
-
C --> E{Run test}
|
|
24
|
-
E -->|Your tests pass| F[Refactor — keep green]
|
|
25
|
-
E -->|Fails| C
|
|
26
|
-
F --> G{More behavior needed?}
|
|
27
|
-
G -->|Yes| A
|
|
28
|
-
G -->|No| H[Done — your test files green, scoped VERIFY passes]
|
|
29
|
-
```
|
|
16
|
+
1. **Failing test:** one behavior, clear name, real boundary.
|
|
17
|
+
2. **Minimal code:** only what makes the test pass.
|
|
18
|
+
3. **Refactor:** remove duplication and improve names without adding behavior.
|
|
19
|
+
4. **Verify:** run the relevant test and any proportionate integration check.
|
|
30
20
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
Code written before a test? **Delete it.** No "reference", no "adapting". Start fresh from tests.
|
|
34
|
-
|
|
35
|
-
## RED — Write Failing Test
|
|
36
|
-
|
|
37
|
-
- One behavior per test, clear name, real code (no mocks unless unavoidable)
|
|
38
|
-
- Run: `npm test -- path/to/test.test.ts` — confirm fails for the right reason
|
|
39
|
-
|
|
40
|
-
## GREEN — Minimal Code
|
|
41
|
-
|
|
42
|
-
- Simplest code to pass. Nothing beyond what the test requires.
|
|
43
|
-
- Run: re-run YOUR test file(s) (`npm test -- path/to/test.test.ts`) — confirm they pass, output pristine. Never the unscoped suite; the devil-advocate completion gate owns full-project verification.
|
|
44
|
-
|
|
45
|
-
## REFACTOR — Clean Up
|
|
46
|
-
|
|
47
|
-
- Remove duplication, improve names, extract helpers
|
|
48
|
-
- Keep tests green. Don't add behavior.
|
|
49
|
-
|
|
50
|
-
## Common Rationalizations
|
|
51
|
-
|
|
52
|
-
| Excuse | Reality |
|
|
53
|
-
|--------|---------|
|
|
54
|
-
| "Too simple to test" | Simple code breaks. Test takes 30 seconds. |
|
|
55
|
-
| "I'll test after" | Tests passing immediately prove nothing. |
|
|
56
|
-
| "Need to explore first" | Fine. Throw away exploration, then TDD. |
|
|
57
|
-
| "Test hard = design unclear" | Hard to test = hard to use. Listen to the test. |
|
|
58
|
-
| "TDD will slow me down" | TDD faster than debugging. |
|
|
59
|
-
|
|
60
|
-
## When Stuck
|
|
61
|
-
|
|
62
|
-
| Problem | Solution |
|
|
63
|
-
|---------|----------|
|
|
64
|
-
| Don't know how to test | Write wished-for API. Assertion first. |
|
|
65
|
-
| Test too complicated | Design too complicated. Simplify interface. |
|
|
66
|
-
| Must mock everything | Code too coupled. Use dependency injection. |
|
|
67
|
-
|
|
68
|
-
## Red Flags — Delete and Start Over
|
|
69
|
-
|
|
70
|
-
Code before test, test passes immediately, can't explain why test failed, rationalizing "just this once".
|
|
71
|
-
|
|
72
|
-
See `tdd-rationalizations-and-examples.md` for expanded examples and rebuttals.
|
|
21
|
+
If a test passes immediately, verify it actually covers the new behavior. Avoid mocks that merely confirm implementation details. Use `testing-anti-patterns.md` or `tdd-rationalizations-and-examples.md` only when those details help.
|