@use-the-fork/spindle 0.0.0-stage → 0.0.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 (245) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -2
  3. package/build/Assets/Blueprints/Catalog.js +110 -0
  4. package/build/Assets/Blueprints/agents/general.agent.md +67 -0
  5. package/build/Assets/Blueprints/agents/sdd-code-reviewer.agent.md +62 -0
  6. package/build/Assets/Blueprints/agents/sdd-code-slop-reviewer.agent.md +59 -0
  7. package/build/Assets/Blueprints/agents/sdd-implementer.agent.md +77 -0
  8. package/build/Assets/Blueprints/agents/sdd-orchestrator.agent.md +42 -0
  9. package/build/Assets/Blueprints/agents/sdd-re-review.agent.md +57 -0
  10. package/build/Assets/Blueprints/agents/sdd-reviewer.agent.md +89 -0
  11. package/build/Assets/Blueprints/agents/sdd-task-reviewer.agent.md +54 -0
  12. package/build/Assets/Blueprints/agents/shared-codebase-analyzer.agent.md +151 -0
  13. package/build/Assets/Blueprints/agents/shared-codebase-locator.agent.md +130 -0
  14. package/build/Assets/Blueprints/agents/shared-codebase-pattern-finder.agent.md +247 -0
  15. package/build/Assets/Blueprints/agents/shared-explore.agent.md +53 -0
  16. package/build/Assets/Blueprints/agents/shared-r.agent.md +17 -0
  17. package/build/Assets/Blueprints/agents/shared-rw.agent.md +17 -0
  18. package/build/Assets/Blueprints/agents/shared-rwx.agent.md +17 -0
  19. package/build/Assets/Blueprints/agents/shared-web-search-researcher.agent.md +122 -0
  20. package/build/Assets/Blueprints/instructions/code-commenting.instructions.md +39 -0
  21. package/build/Assets/Blueprints/instructions/source-architecture.instructions.md +15 -0
  22. package/build/Assets/Blueprints/skills/asd-ste100/CREDITS.MD +1 -0
  23. package/build/Assets/Blueprints/skills/asd-ste100/SKILL.md +83 -0
  24. package/build/Assets/Blueprints/skills/asd-ste100/examples/before-after.md +107 -0
  25. package/build/Assets/Blueprints/skills/asd-ste100/references/writing-rules.md +65 -0
  26. package/build/Assets/Blueprints/skills/author-agent/SKILL.md +26 -0
  27. package/build/Assets/Blueprints/skills/author-design/SKILL.md +38 -0
  28. package/build/Assets/Blueprints/skills/author-instruction/SKILL.md +28 -0
  29. package/build/Assets/Blueprints/skills/author-skill/SKILL.md +26 -0
  30. package/build/Assets/Blueprints/skills/grill/SKILL.md +33 -0
  31. package/build/Assets/Blueprints/skills/grill-design/SKILL.md +41 -0
  32. package/build/Assets/Blueprints/skills/grill-with-docs/SKILL.md +14 -0
  33. package/build/Assets/Blueprints/skills/implement/SKILL.md +79 -0
  34. package/build/Assets/Blueprints/skills/implement-spec/SKILL.md +34 -0
  35. package/build/Assets/Blueprints/skills/improve-codebase-architecture/HTML-REPORT.md +129 -0
  36. package/build/Assets/Blueprints/skills/improve-codebase-architecture/SKILL.md +74 -0
  37. package/build/Assets/Blueprints/skills/int-code-review/SKILL.md +76 -0
  38. package/build/Assets/Blueprints/skills/int-code-slop-review/SKILL.md +238 -0
  39. package/build/Assets/Blueprints/skills/int-code-slop-review/rules/_sections.md +36 -0
  40. package/build/Assets/Blueprints/skills/int-code-slop-review/rules/_template.md +42 -0
  41. package/build/Assets/Blueprints/skills/int-code-slop-review/rules/comments-closing-brace-labels.md +112 -0
  42. package/build/Assets/Blueprints/skills/int-code-slop-review/rules/comments-empty-docblocks.md +132 -0
  43. package/build/Assets/Blueprints/skills/int-code-slop-review/rules/comments-narration.md +118 -0
  44. package/build/Assets/Blueprints/skills/int-code-slop-review/rules/comments-placeholder.md +130 -0
  45. package/build/Assets/Blueprints/skills/int-code-slop-review/rules/defensive-generic-catch.md +153 -0
  46. package/build/Assets/Blueprints/skills/int-code-slop-review/rules/defensive-impossible-null.md +157 -0
  47. package/build/Assets/Blueprints/skills/int-code-slop-review/rules/defensive-missing-real.md +157 -0
  48. package/build/Assets/Blueprints/skills/int-code-slop-review/rules/naming-generic-placeholders.md +120 -0
  49. package/build/Assets/Blueprints/skills/int-code-slop-review/rules/naming-over-descriptive.md +108 -0
  50. package/build/Assets/Blueprints/skills/int-code-slop-review/rules/naming-suffix-abuse.md +167 -0
  51. package/build/Assets/Blueprints/skills/int-code-slop-review/rules/naming-type-in-name.md +100 -0
  52. package/build/Assets/Blueprints/skills/int-code-slop-review/rules/over-eng-dependency-creep.md +114 -0
  53. package/build/Assets/Blueprints/skills/int-code-slop-review/rules/over-eng-premature-interface.md +136 -0
  54. package/build/Assets/Blueprints/skills/int-code-slop-review/rules/over-eng-single-method-class.md +161 -0
  55. package/build/Assets/Blueprints/skills/int-code-slop-review/rules/over-eng-useless-wrapper.md +140 -0
  56. package/build/Assets/Blueprints/skills/int-code-slop-review/rules/style-as-any-escape.md +127 -0
  57. package/build/Assets/Blueprints/skills/int-code-slop-review/rules/style-debug-artifacts.md +144 -0
  58. package/build/Assets/Blueprints/skills/int-code-slop-review/rules/style-hyper-consistent.md +84 -0
  59. package/build/Assets/Blueprints/skills/int-code-slop-review/rules/style-no-hack-scars.md +113 -0
  60. package/build/Assets/Blueprints/skills/int-code-slop-review/rules/style-trivial-boilerplate.md +191 -0
  61. package/build/Assets/Blueprints/skills/int-code-slop-review/rules/test-doesnt-throw.md +132 -0
  62. package/build/Assets/Blueprints/skills/int-code-slop-review/rules/test-mirror-implementation.md +125 -0
  63. package/build/Assets/Blueprints/skills/int-code-slop-review/rules/test-mock-everything.md +148 -0
  64. package/build/Assets/Blueprints/skills/int-code-slop-review/rules/test-snapshot-abuse.md +131 -0
  65. package/build/Assets/Blueprints/skills/int-codebase-design/SKILL.md +116 -0
  66. package/build/Assets/Blueprints/skills/int-codebase-design/references/DEEPENING.md +37 -0
  67. package/build/Assets/Blueprints/skills/int-codebase-design/references/DESIGN-IT-TWICE.md +44 -0
  68. package/build/Assets/Blueprints/skills/int-domain-modeling/SKILL.md +78 -0
  69. package/build/Assets/Blueprints/skills/int-domain-modeling/references/ADR-FORMAT.md +47 -0
  70. package/build/Assets/Blueprints/skills/int-domain-modeling/references/GLOSSARY-FORMAT.md +60 -0
  71. package/build/Assets/Blueprints/skills/int-prototype/LOGIC.md +67 -0
  72. package/build/Assets/Blueprints/skills/int-prototype/SKILL.md +30 -0
  73. package/build/Assets/Blueprints/skills/int-prototype/UI.md +112 -0
  74. package/build/Assets/Blueprints/skills/int-retrospective/SKILL.md +88 -0
  75. package/build/Assets/Blueprints/skills/int-retrospective/assets/retrospective-prompt.md +38 -0
  76. package/build/Assets/Blueprints/skills/int-retrospective/references/assessment.md +56 -0
  77. package/build/Assets/Blueprints/skills/int-subagent-driven-dev/SKILL.md +64 -0
  78. package/build/Assets/Blueprints/skills/int-subagent-driven-dev/assets/implementer-prompt.md +40 -0
  79. package/build/Assets/Blueprints/skills/int-subagent-driven-dev/assets/reviewer-prompt.md +43 -0
  80. package/build/Assets/Blueprints/skills/int-subagent-driven-dev/references/aggregate-review.md +7 -0
  81. package/build/Assets/Blueprints/skills/int-subagent-driven-dev/references/corrective-rounds.md +72 -0
  82. package/build/Assets/Blueprints/skills/int-subagent-driven-dev/references/example-workflow.md +25 -0
  83. package/build/Assets/Blueprints/skills/int-subagent-driven-dev/references/full-spec.md +72 -0
  84. package/build/Assets/Blueprints/skills/int-subagent-driven-dev/references/implementer-corrections.md +9 -0
  85. package/build/Assets/Blueprints/skills/int-subagent-driven-dev/references/review-inputs.md +26 -0
  86. package/build/Assets/Blueprints/skills/int-subagent-driven-dev/references/verification-evidence.md +7 -0
  87. package/build/Assets/Blueprints/skills/int-test-driven-development/SKILL.md +51 -0
  88. package/build/Assets/Blueprints/skills/int-test-driven-development/references/mocking.md +31 -0
  89. package/build/Assets/Blueprints/skills/int-test-driven-development/references/tests.md +68 -0
  90. package/build/Assets/Blueprints/skills/int-testing-agent-guidance/SKILL.md +53 -0
  91. package/build/Assets/Blueprints/skills/int-verification-before-completion/SKILL.md +25 -0
  92. package/build/Assets/Blueprints/skills/int-writing-agents/SKILL.md +66 -0
  93. package/build/Assets/Blueprints/skills/int-writing-for-agents/SKILL.md +86 -0
  94. package/build/Assets/Blueprints/skills/int-writing-instruction/SKILL.md +57 -0
  95. package/build/Assets/Blueprints/skills/int-writing-skills/SKILL.md +129 -0
  96. package/build/Assets/Blueprints/skills/int-writing-skills/assets/interactive.md +83 -0
  97. package/build/Assets/Blueprints/skills/int-writing-skills/assets/reference.md +32 -0
  98. package/build/Assets/Blueprints/skills/int-writing-skills/references/arguments.md +50 -0
  99. package/build/Assets/Blueprints/skills/int-writing-skills/references/interactive-skills.md +53 -0
  100. package/build/Assets/Blueprints/skills/int-writing-skills/references/persuasion-principles.md +220 -0
  101. package/build/Assets/Blueprints/skills/int-writing-skills/references/reference-skills.md +20 -0
  102. package/build/Assets/Blueprints/skills/int-writing-skills/references/testing-skills.md +48 -0
  103. package/build/Assets/Blueprints/skills/retrospective/SKILL.md +16 -0
  104. package/build/Assets/Blueprints/skills/setup-project/SKILL.md +66 -0
  105. package/build/Assets/Blueprints/skills/to-spec/SKILL.md +53 -0
  106. package/build/Assets/Blueprints/skills/to-tickets/SKILL.md +49 -0
  107. package/build/Assets/Blueprints/skills/update-tooling/SKILL.md +86 -0
  108. package/build/Assets/Templates/Catalog.js +12 -0
  109. package/build/Assets/Templates/Catalog.ts +17 -0
  110. package/build/Assets/Templates/project/copilot-instructions.md +17 -0
  111. package/build/Assets/Templates/project/domain.md +51 -0
  112. package/build/Assets/Templates/project/ticket-tracker.md +33 -0
  113. package/build/Assets/Templates/sdd/design.md +25 -0
  114. package/build/Assets/Templates/sdd/spec.md +29 -0
  115. package/build/Assets/Templates/sdd/ticket.md +15 -0
  116. package/build/BlueprintManagement/BlueprintManagementServiceProvider.js +15 -0
  117. package/build/BlueprintManagement/Catalog/BlueprintCatalog.js +238 -0
  118. package/build/BlueprintManagement/Commands/BlueprintCommandOptions.js +9 -0
  119. package/build/BlueprintManagement/Commands/ConflictPolicy.js +6 -0
  120. package/build/BlueprintManagement/Commands/InitCommand.js +117 -0
  121. package/build/BlueprintManagement/Commands/Prompts.js +66 -0
  122. package/build/BlueprintManagement/Commands/UpdateCommand.js +86 -0
  123. package/build/BlueprintManagement/Handlers/Agents/AgentHandler.js +21 -0
  124. package/build/BlueprintManagement/Handlers/BlueprintHandlers.js +4 -0
  125. package/build/BlueprintManagement/Handlers/Instructions/InstructionHandler.js +21 -0
  126. package/build/BlueprintManagement/Handlers/Skills/SkillHandler.js +10 -0
  127. package/build/BlueprintManagement/Reconciliation/BlueprintCatalogPlanner.js +87 -0
  128. package/build/BlueprintManagement/Reconciliation/BlueprintRemovalCoordinator.js +78 -0
  129. package/build/BlueprintManagement/Services/BlueprintReconciliationService.js +391 -0
  130. package/build/BlueprintManagement/Services/InstallationService.js +54 -0
  131. package/build/BlueprintManagement/Support/BlueprintFiles.js +113 -0
  132. package/build/BlueprintManagement/Types/Blueprint.js +1 -0
  133. package/build/BlueprintManagement/Types/Installation.js +1 -0
  134. package/build/BlueprintManagement/Types/Reconciliation.js +1 -0
  135. package/build/BlueprintManagement/Versioning/BlueprintVersion.js +70 -0
  136. package/build/BlueprintManagement/Versioning/BlueprintVersioning.js +55 -0
  137. package/build/Commands/Command.js +3 -0
  138. package/build/Commands/CommandOptions.js +12 -0
  139. package/build/Config/Config.js +3 -0
  140. package/build/Foundation/Application.js +112 -0
  141. package/build/Foundation/ApplicationBuilder.js +23 -0
  142. package/build/Foundation/Bootstrap/Bootstrapper.js +2 -0
  143. package/build/Foundation/Bootstrap/DiscoverGitRoot.js +8 -0
  144. package/build/Foundation/Bootstrap/LoadConsoleArgs.js +47 -0
  145. package/build/Foundation/Bootstrap/LoadProjectConfiguration.js +144 -0
  146. package/build/Foundation/Bootstrap/RegisterProviders.js +12 -0
  147. package/build/Foundation/Bootstrap/RequireProjectConfiguration.js +14 -0
  148. package/build/Foundation/ConsoleInvocation.js +1 -0
  149. package/build/Foundation/Container.js +185 -0
  150. package/build/Foundation/FoundationServiceProvider.js +5 -0
  151. package/build/Foundation/Kernel.js +30 -0
  152. package/build/Foundation/Service.js +23 -0
  153. package/build/Foundation/ServiceProvider.js +12 -0
  154. package/build/Git/GitServiceProvider.js +8 -0
  155. package/build/Git/Services/GitService.js +26 -0
  156. package/build/Project/ProjectServiceProvider.js +8 -0
  157. package/build/Project/Services/ProjectService.js +124 -0
  158. package/build/SubagentDrivenDevelopment/Commands/ChecksRecordCommand.js +35 -0
  159. package/build/SubagentDrivenDevelopment/Commands/ChecksRequireCommand.js +33 -0
  160. package/build/SubagentDrivenDevelopment/Commands/ClaimCommand.js +23 -0
  161. package/build/SubagentDrivenDevelopment/Commands/CorrectCommand.js +37 -0
  162. package/build/SubagentDrivenDevelopment/Commands/CreateCommand.js +26 -0
  163. package/build/SubagentDrivenDevelopment/Commands/FindingCreateCommand.js +39 -0
  164. package/build/SubagentDrivenDevelopment/Commands/FindingUpdateCommand.js +36 -0
  165. package/build/SubagentDrivenDevelopment/Commands/FinishCommand.js +23 -0
  166. package/build/SubagentDrivenDevelopment/Commands/ImplementCommand.js +23 -0
  167. package/build/SubagentDrivenDevelopment/Commands/NextCommand.js +21 -0
  168. package/build/SubagentDrivenDevelopment/Commands/ReadyCommand.js +21 -0
  169. package/build/SubagentDrivenDevelopment/Commands/RequirementsDecideCommand.js +33 -0
  170. package/build/SubagentDrivenDevelopment/Commands/ResumeCommand.js +31 -0
  171. package/build/SubagentDrivenDevelopment/Commands/ReviewCommand.js +55 -0
  172. package/build/SubagentDrivenDevelopment/Commands/ReviewRequireCommand.js +12 -0
  173. package/build/SubagentDrivenDevelopment/Commands/StatusCommand.js +21 -0
  174. package/build/SubagentDrivenDevelopment/Commands/SubmitCommand.js +59 -0
  175. package/build/SubagentDrivenDevelopment/Commands/TicketCommentCommand.js +24 -0
  176. package/build/SubagentDrivenDevelopment/Commands/TicketCreateCommand.js +25 -0
  177. package/build/SubagentDrivenDevelopment/Commands/TicketUpdateCommand.js +31 -0
  178. package/build/SubagentDrivenDevelopment/Commands/groups.js +36 -0
  179. package/build/SubagentDrivenDevelopment/Evidence/GitEvidence.js +449 -0
  180. package/build/SubagentDrivenDevelopment/Evidence/ReportEvidence.js +80 -0
  181. package/build/SubagentDrivenDevelopment/Models/Assignments.js +1 -0
  182. package/build/SubagentDrivenDevelopment/Models/Evidence.js +1 -0
  183. package/build/SubagentDrivenDevelopment/Models/Findings.js +1 -0
  184. package/build/SubagentDrivenDevelopment/Models/Options.js +1 -0
  185. package/build/SubagentDrivenDevelopment/Models/Workflow.js +16 -0
  186. package/build/SubagentDrivenDevelopment/Persistence/AssignmentSchema.js +155 -0
  187. package/build/SubagentDrivenDevelopment/Persistence/CheckSchema.js +71 -0
  188. package/build/SubagentDrivenDevelopment/Persistence/FeatureWorkspace.js +76 -0
  189. package/build/SubagentDrivenDevelopment/Persistence/FileSystem.js +28 -0
  190. package/build/SubagentDrivenDevelopment/Persistence/FindingSchema.js +81 -0
  191. package/build/SubagentDrivenDevelopment/Persistence/LedgerRepository.js +322 -0
  192. package/build/SubagentDrivenDevelopment/Persistence/PathSafety.js +62 -0
  193. package/build/SubagentDrivenDevelopment/Persistence/ProgressSchema.js +95 -0
  194. package/build/SubagentDrivenDevelopment/Persistence/ReadinessReader.js +40 -0
  195. package/build/SubagentDrivenDevelopment/Persistence/ReviewSchema.js +68 -0
  196. package/build/SubagentDrivenDevelopment/Persistence/TicketRepository.js +147 -0
  197. package/build/SubagentDrivenDevelopment/Persistence/WorkspaceTransaction.js +282 -0
  198. package/build/SubagentDrivenDevelopment/Policies/AcceptancePolicy.js +100 -0
  199. package/build/SubagentDrivenDevelopment/Policies/AssignmentPolicy.js +36 -0
  200. package/build/SubagentDrivenDevelopment/Policies/CheckPolicy.js +93 -0
  201. package/build/SubagentDrivenDevelopment/Policies/FindingPolicy.js +53 -0
  202. package/build/SubagentDrivenDevelopment/Policies/InputValidation.js +36 -0
  203. package/build/SubagentDrivenDevelopment/Policies/ReadinessPolicy.js +26 -0
  204. package/build/SubagentDrivenDevelopment/Policies/RequiredReviewers.js +12 -0
  205. package/build/SubagentDrivenDevelopment/Policies/ReviewPolicy.js +87 -0
  206. package/build/SubagentDrivenDevelopment/Policies/WorkflowPolicy.js +85 -0
  207. package/build/SubagentDrivenDevelopment/Services/AssignmentService.js +269 -0
  208. package/build/SubagentDrivenDevelopment/Services/ChecksService.js +319 -0
  209. package/build/SubagentDrivenDevelopment/Services/CorrectionService.js +273 -0
  210. package/build/SubagentDrivenDevelopment/Services/DeliveryCorrectionService.js +253 -0
  211. package/build/SubagentDrivenDevelopment/Services/DeliveryFindingService.js +302 -0
  212. package/build/SubagentDrivenDevelopment/Services/DeliveryService.js +160 -0
  213. package/build/SubagentDrivenDevelopment/Services/DeliverySubmissionService.js +273 -0
  214. package/build/SubagentDrivenDevelopment/Services/FeatureCreationService.js +138 -0
  215. package/build/SubagentDrivenDevelopment/Services/FeatureInspectionService.js +399 -0
  216. package/build/SubagentDrivenDevelopment/Services/FindingService.js +392 -0
  217. package/build/SubagentDrivenDevelopment/Services/IntegrationService.js +258 -0
  218. package/build/SubagentDrivenDevelopment/Services/ReadinessService.js +21 -0
  219. package/build/SubagentDrivenDevelopment/Services/RequirementsService.js +216 -0
  220. package/build/SubagentDrivenDevelopment/Services/ReviewService.js +471 -0
  221. package/build/SubagentDrivenDevelopment/Services/SubmissionService.js +299 -0
  222. package/build/SubagentDrivenDevelopment/Services/TicketService.js +186 -0
  223. package/build/SubagentDrivenDevelopment/SubagentDrivenDevelopmentServiceProvider.js +113 -0
  224. package/build/Support/Records.js +5 -0
  225. package/build/Support/Repository.js +139 -0
  226. package/build/Support/Stacks.js +10 -0
  227. package/build/TemplateRendering/Computed/ComputedContextService.js +13 -0
  228. package/build/TemplateRendering/Computed/ComputedVariableProvider.js +6 -0
  229. package/build/TemplateRendering/Computed/ComputedVariableProviders.js +6 -0
  230. package/build/TemplateRendering/Computed/Providers/InternalSkillDescriptionProvider.js +6 -0
  231. package/build/TemplateRendering/Computed/Providers/SpindlePackageManagerProvider.js +11 -0
  232. package/build/TemplateRendering/Computed/ResolveRenderContext.js +18 -0
  233. package/build/TemplateRendering/Rendering/RenderText.js +43 -0
  234. package/build/TemplateRendering/TemplateRenderingServiceProvider.js +8 -0
  235. package/build/Tooling/Commands/ToolingAddCommand.js +29 -0
  236. package/build/Tooling/Commands/ToolingListCommand.js +19 -0
  237. package/build/Tooling/Commands/ToolingRemoveCommand.js +19 -0
  238. package/build/Tooling/Commands/ToolingUpdateCommand.js +30 -0
  239. package/build/Tooling/Commands/groups.js +4 -0
  240. package/build/Tooling/Models/ToolingEntry.js +1 -0
  241. package/build/Tooling/Services/ToolingService.js +278 -0
  242. package/build/Tooling/ToolingServiceProvider.js +15 -0
  243. package/build/cli.js +36 -0
  244. package/build/index.js +31 -0
  245. package/package.json +54 -3
@@ -0,0 +1,125 @@
1
+ ---
2
+ title: Tests That Mirror the Implementation
3
+ impact: HIGH
4
+ impactDescription: "Tests re-encode the production code; pass because they re-implement the same logic, not because they verify Behavior"
5
+ tags: testing, mirror-tests, ai-fingerprint
6
+ ---
7
+
8
+ ## Tests That Mirror the Implementation
9
+
10
+ **Impact: HIGH (Tests re-encode the production code; pass because they re-implement the same logic, not because they verify Behavior)**
11
+
12
+ AI generates tests by reading the function and translating its logic into the test. If `calculateTax` does `subtotal * 0.06`, the test sets `subtotal = 100`, then says "expect result to be `100 * 0.06`". The test passes because both sides compute the same thing. It would still pass if the function silently switched to `subtotal * 0.07` — IF the AI also "updated" the test to match.
13
+
14
+ Real tests state the **expected concrete answer**, not a formula computed from the input. They verify what _should_ be true, not "the function does what the function does".
15
+
16
+ ## Incorrect
17
+
18
+ ```typescript
19
+ // ❌ The test re-implements the function
20
+
21
+ // Production:
22
+ export function calculateTax(subtotal: number): number {
23
+ return subtotal * 0.06;
24
+ }
25
+
26
+ // Test:
27
+ import { calculateTax } from "./calculateTax";
28
+
29
+ describe("calculateTax", () => {
30
+ it("calculates tax", () => {
31
+ const subtotal = 100;
32
+ expect(calculateTax(subtotal)).toBe(subtotal * 0.06); // re-encodes the formula
33
+ });
34
+
35
+ it("handles zero", () => {
36
+ expect(calculateTax(0)).toBe(0 * 0.06); // tautology
37
+ });
38
+ });
39
+ ```
40
+
41
+ ```php
42
+ // ❌ Same pattern in PHP
43
+ public function test_it_calculates_tax(): void
44
+ {
45
+ $subtotal = 100;
46
+ $expected = $subtotal * 0.06; // re-encoded
47
+ $this->assertEquals($expected, calculateTax($subtotal));
48
+ }
49
+ ```
50
+
51
+ **Why it's slop:**
52
+
53
+ - The test passes because RHS and LHS use the same formula — you've verified `x === x`
54
+ - If the formula in production silently changes to `0.07`, but the test "uses the formula" (or AI updates the test to match), the test still passes — and the bug ships
55
+ - Both sides of the equation come from the same place, so the test catches nothing the type system doesn't
56
+
57
+ ## Correct — concrete, named expected values
58
+
59
+ ```typescript
60
+ // ✅ Concrete expectations
61
+ describe("calculateTax", () => {
62
+ it("charges 6% on the subtotal", () => {
63
+ expect(calculateTax(100)).toBe(6);
64
+ expect(calculateTax(50)).toBe(3);
65
+ expect(calculateTax(1.5)).toBe(0.09);
66
+ });
67
+
68
+ it("returns 0 for a 0 subtotal", () => {
69
+ expect(calculateTax(0)).toBe(0);
70
+ });
71
+
72
+ it("rejects negative subtotals", () => {
73
+ expect(() => calculateTax(-10)).toThrow(InvalidSubtotal);
74
+ });
75
+ });
76
+ ```
77
+
78
+ ```php
79
+ // ✅ Concrete expectations
80
+ public function test_charges_six_percent_on_subtotal(): void
81
+ {
82
+ $this->assertEquals(6.0, calculateTax(100));
83
+ $this->assertEquals(3.0, calculateTax(50));
84
+ $this->assertEquals(0.09, calculateTax(1.50));
85
+ }
86
+ ```
87
+
88
+ **Why it reads human:**
89
+
90
+ - The expected value is _named_ — `6` is what 6% of 100 is, written as the answer
91
+ - If the production formula changes to `0.07`, the test fails at `expect(calculateTax(100)).toBe(6)` because `7 !== 6`
92
+ - The bug is caught at the boundary; the test holds the spec
93
+
94
+ ## A particularly dangerous variant: bug-then-regenerate
95
+
96
+ ```
97
+ User: "There's a bug — calculateTax is returning the wrong value for negatives."
98
+ AI: "I'll regenerate the test for you."
99
+ ```
100
+
101
+ The regenerated test happens to pass for the new buggy Behavior. The test now ratifies the bug. This pattern is documented in Larridin (2025) and is one of the most insidious failure modes.
102
+
103
+ **Rule:** when fixing a bug, the test is written FIRST (red), with concrete expected values that reflect the correct Behavior. Then the production code is changed. Then the test goes green. Never accept "regenerate the test to match the new implementation".
104
+
105
+ ## Detection
106
+
107
+ This is hard to detect mechanically — the pattern is "RHS includes the same constants/operations as the production code". Useful heuristics:
108
+
109
+ ```bash
110
+ # Tests where expected values use the same magic number as the source
111
+ # (extract numeric constants from src/, then grep tests for them)
112
+ grep -rEoh '[0-9]+\.[0-9]+|[0-9]+_[0-9]+' --include='*.ts' src/ | sort -u > /tmp/src-constants.txt
113
+ grep -rEoh '[0-9]+\.[0-9]+|[0-9]+_[0-9]+' --include='*.test.ts' tests/ | sort -u > /tmp/test-constants.txt
114
+ comm -12 /tmp/src-constants.txt /tmp/test-constants.txt | head
115
+ # If many magic numbers from src appear in tests, they may be re-encoding the implementation
116
+
117
+ # Mutation testing is the gold-standard detection:
118
+ # - Stryker (JS/TS): https://stryker-mutator.io/
119
+ # - Infection (PHP): https://infection.github.io/
120
+ # If a mutation in the source doesn't fail a test, the test is mirror-ware.
121
+ ```
122
+
123
+ **Mutation testing is the right answer here.** Add Stryker or Infection to your CI and require a minimum mutation score on PRs touching the unit-test directory.
124
+
125
+ Reference: [Stryker Mutator](https://stryker-mutator.io/) · [Infection](https://infection.github.io/) · Internal: [`test-mock-everything`](test-mock-everything.md), [`test-doesnt-throw`](test-doesnt-throw.md)
@@ -0,0 +1,148 @@
1
+ ---
2
+ title: Mock-Everything Tests That Assert Nothing
3
+ impact: CRITICAL
4
+ impactDescription: "Tests that pass forever; they re-encode the implementation rather than verify Behavior"
5
+ tags: testing, mocks, ai-fingerprint
6
+ ---
7
+
8
+ ## Mock-Everything Tests That Assert Nothing
9
+
10
+ **Impact: CRITICAL (Tests that pass forever; they re-encode the implementation rather than verify Behavior)**
11
+
12
+ When AI generates tests, the most common failure mode is "mock every dependency, then assert that the mocks were called". The test passes the moment it's written and passes forever — including when the underlying Behavior is silently broken. arXiv 2602.00409 (2026): coding agents produce significantly more over-mocked tests than human authors.
13
+
14
+ A real test verifies **outcome**, not **interaction**. Mocking a database to assert "create() was called with X" verifies that you wrote the implementation that calls `create()`. It doesn't verify that the customer record actually lands in the table.
15
+
16
+ ## Incorrect
17
+
18
+ ```typescript
19
+ // ❌ Mock-everything test that asserts mock interactions
20
+
21
+ import { describe, it, expect, vi } from "vitest";
22
+
23
+ import { UserService } from "./UserService";
24
+
25
+ describe("UserService", () => {
26
+ it("createUser saves the user", async () => {
27
+ const mockRepo = {
28
+ save: vi.fn().mockResolvedValue({ id: 1, email: "a@b.com" }),
29
+ findByEmail: vi.fn().mockResolvedValue(null),
30
+ };
31
+ const mockMailer = { send: vi.fn() };
32
+ const mockHasher = { hash: vi.fn().mockReturnValue("hashed") };
33
+
34
+ const service = new UserService(mockRepo, mockMailer, mockHasher);
35
+ await service.createUser({ email: "a@b.com", password: "x" });
36
+
37
+ expect(mockRepo.save).toHaveBeenCalled(); // weak — passes if .save() called with anything
38
+ expect(mockMailer.send).toHaveBeenCalled();
39
+ expect(mockHasher.hash).toHaveBeenCalledWith("x"); // verifies you wrote .hash() — not that it's secure
40
+ });
41
+ });
42
+ ```
43
+
44
+ ```php
45
+ // ❌ Same pattern in PHPUnit / Pest
46
+ test('processOrder calls payment gateway', function () {
47
+ $payments = $this->mock(PaymentGateway::class);
48
+ $payments->shouldReceive('charge')->once(); // verifies an interaction, not an outcome
49
+
50
+ $service = new OrderService($payments);
51
+ $service->process(new Order(/* ... */));
52
+ });
53
+ ```
54
+
55
+ **Why it's slop:**
56
+
57
+ - The test passes even if `save()` stores the wrong fields, or `hash()` returns the input unchanged, or `charge()` skips actual payment
58
+ - It locks in the implementation's structure (every refactor breaks the test even when Behavior is fine)
59
+ - "Was the mock called" is rarely a useful assertion — what matters is "did the outcome happen"
60
+ - The test gives false confidence in coverage reports
61
+
62
+ ## Correct — verify the outcome, with real dependencies where possible
63
+
64
+ ```typescript
65
+ // ✅ Integration test against a real (in-memory) DB; assert what changed
66
+ import { describe, it, expect, beforeEach } from "vitest";
67
+
68
+ import { createTestDb } from "./testUtils";
69
+ import { UserService } from "./UserService";
70
+
71
+ describe("UserService", () => {
72
+ let db;
73
+ beforeEach(async () => {
74
+ db = await createTestDb();
75
+ });
76
+
77
+ it("createUser creates a user row with hashed password and sends welcome email", async () => {
78
+ const mailer = makeFakeMailer(); // collect-and-inspect, not a mock-with-asserts
79
+ const service = new UserService(db.users, mailer);
80
+
81
+ await service.createUser({ email: "a@b.com", password: "plaintext" });
82
+
83
+ const stored = await db.users.findByEmail("a@b.com");
84
+ expect(stored).toBeDefined();
85
+ expect(stored!.email).toBe("a@b.com");
86
+ expect(stored!.passwordHash).not.toBe("plaintext"); // hash actually happened
87
+ expect(bcrypt.compareSync("plaintext", stored!.passwordHash)).toBe(true);
88
+ expect(mailer.sentTo("a@b.com")).toHaveLength(1); // outcome, not interaction
89
+ });
90
+ });
91
+ ```
92
+
93
+ ```php
94
+ // ✅ Laravel: use the real database (RefreshDatabase) + fake the boundary services
95
+ test('processOrder charges customer and marks order paid', function () {
96
+ Mail::fake();
97
+ Http::fake([
98
+ 'api.stripe.com/*' => Http::response(['id' => 'ch_test_123', 'status' => 'succeeded'], 200),
99
+ ]);
100
+
101
+ $order = Order::factory()->create(['status' => 'pending', 'total' => 100_00]);
102
+
103
+ (new OrderService(new StripeGateway()))->process($order);
104
+
105
+ expect($order->fresh()->status)->toBe('paid');
106
+ expect($order->fresh()->stripe_charge_id)->toBe('ch_test_123');
107
+ Mail::assertSent(OrderConfirmation::class, fn ($m) => $m->order->is($order));
108
+ });
109
+ ```
110
+
111
+ **Why it reads human:**
112
+
113
+ - Each assertion checks **what should be true after the operation** — not "did you call X"
114
+ - Refactoring the internal calls is safe — the test still passes if the outcomes hold
115
+ - Real bugs (forgotten hash, wrong field assignment, missing email) trigger the test failures
116
+ - The test reads like a customer story: "after createUser, the user exists, password is hashed, welcome email is sent"
117
+
118
+ ## When mocks ARE appropriate
119
+
120
+ A few legitimate uses:
121
+
122
+ - **Cost / side-effect boundaries** — real Stripe calls (use `Http::fake()` in Laravel; mock the HTTP boundary)
123
+ - **Slow externals** — third-party APIs with rate limits (mock the HTTP boundary)
124
+ - **Time-sensitive code** — freeze the clock (Carbon test helpers, vi.setSystemTime), don't mock all of time
125
+ - **Hard-to-reproduce error paths** — force a `ConnectionException` to test the retry handler
126
+
127
+ The pattern: **mock at the network/IO boundary, not at every internal class.**
128
+
129
+ ## Detection
130
+
131
+ ```bash
132
+ # Tests that import the mock library more than the assertion library (rough)
133
+ grep -rEn '(vi\.fn|jest\.fn|->mock\(|->shouldReceive)' \
134
+ --include='*.test.ts' --include='*.spec.ts' --include='*Test.php' \
135
+ | wc -l
136
+
137
+ # Tests asserting only on mock interactions, no DB / outcome checks
138
+ # (heuristic: file has 'toHaveBeenCalled' / 'shouldReceive' but no 'expect(<repo>.find' or 'assertDatabaseHas')
139
+ for f in $(find . -name '*Test.php' -o -name '*.test.ts' 2>/dev/null); do
140
+ has_mock=$(grep -cE 'toHaveBeenCalled|shouldReceive' "$f")
141
+ has_outcome=$(grep -cE 'assertDatabaseHas|->fresh\(|findByEmail|toBe\(|toEqual\(' "$f")
142
+ if [ "$has_mock" -gt 3 ] && [ "$has_outcome" -lt 1 ]; then
143
+ echo "MOCK-ONLY: $f"
144
+ fi
145
+ done
146
+ ```
147
+
148
+ Reference: [arXiv 2602.00409 — Are Coding Agents Generating Over-Mocked Tests?](https://arxiv.org/abs/2602.00409) · Internal: [`test-mirror-implementation`](test-mirror-implementation.md), [`test-doesnt-throw`](test-doesnt-throw.md)
@@ -0,0 +1,131 @@
1
+ ---
2
+ title: Snapshot Tests Replacing behavioral Assertions
3
+ impact: HIGH
4
+ impactDescription: "Snapshots ratify whatever the function currently returns; engineers approve diffs without reading them"
5
+ tags: testing, snapshots, ai-fingerprint
6
+ ---
7
+
8
+ ## Snapshot Tests Replacing Behavioral Assertions
9
+
10
+ **Impact: HIGH (Snapshots ratify whatever the function currently returns; engineers approve diffs without reading them)**
11
+
12
+ A snapshot test calls the function, captures the output, and asserts "matches the saved snapshot". For genuinely stable, large, structural outputs (rendered React component DOM, generated SQL, large JSON shapes), snapshots are useful. For everything else — and especially when AI generates them — they're a way to make a test pass without writing a real assertion.
13
+
14
+ The failure mode is well-documented: a test fails on a real bug, the engineer runs `vitest -u` to "update snapshots", ships. The snapshot test now ratifies the bug. Repeat across a team and snapshots become noise the team has trained itself to ignore.
15
+
16
+ ## Incorrect
17
+
18
+ ```typescript
19
+ // ❌ Snapshot tests instead of behavioral assertions
20
+
21
+ describe("calculateRefund", () => {
22
+ it("matches snapshot", () => {
23
+ expect(calculateRefund(order)).toMatchSnapshot(); // what should the answer be?
24
+ });
25
+ });
26
+
27
+ describe("formatPrice", () => {
28
+ it("matches snapshot", () => {
29
+ expect(formatPrice(1234.5)).toMatchSnapshot();
30
+ });
31
+ });
32
+ ```
33
+
34
+ ```typescript
35
+ // ❌ Component snapshots that lock in entire DOM
36
+ describe('OrderCard', () => {
37
+ it('renders', () => {
38
+ const { container } = render(<OrderCard order={makeOrder()} />);
39
+ expect(container).toMatchSnapshot(); // 800-line snapshot file
40
+ });
41
+ });
42
+ ```
43
+
44
+ **Why it's slop:**
45
+
46
+ - "Matches snapshot" doesn't say what the answer is — readers can't tell what the test verifies
47
+ - When the snapshot fails (because the team made an intentional change), the engineer reflexively runs `-u` to update
48
+ - Snapshot files grow huge; nobody reviews them in PRs
49
+ - AI generates snapshot tests by default because it's the easiest way to "test" without writing an actual assertion
50
+
51
+ ## Correct — explicit behavioral assertions
52
+
53
+ ```typescript
54
+ // ✅ Concrete expectations
55
+
56
+ describe('calculateRefund', () => {
57
+ it('refunds the full order minus the restocking fee', () => {
58
+ const order = makeOrder({ total: 100_00, restockingFee: 5_00 });
59
+ expect(calculateRefund(order)).toEqual({
60
+ amount: 95_00,
61
+ stripeChargeId: order.stripeChargeId,
62
+ });
63
+ });
64
+
65
+ it('refunds zero if the order is past the return window', () => {
66
+ const order = makeOrder({ returnsCloseAt: subDays(new Date(), 1) });
67
+ expect(() => calculateRefund(order)).toThrow(RefundWindowClosed);
68
+ });
69
+ });
70
+
71
+ describe('formatPrice', () => {
72
+ it('formats USD with two decimal places and a leading $', () => {
73
+ expect(formatPrice(1234.5)).toBe('$1,234.50');
74
+ });
75
+ });
76
+
77
+ describe('OrderCard', () => {
78
+ it('shows the order number, total, and status', () => {
79
+ const order = makeOrder({ id: 'ord_123', total: 50_00, status: 'paid' });
80
+ render(<OrderCard order={order} />);
81
+ expect(screen.getByText('Order #ord_123')).toBeInTheDocument();
82
+ expect(screen.getByText('$50.00')).toBeInTheDocument();
83
+ expect(screen.getByText('Paid')).toBeInTheDocument();
84
+ });
85
+ });
86
+ ```
87
+
88
+ **Why it reads human:**
89
+
90
+ - The test reads as the spec — "refunds the full order minus the restocking fee"
91
+ - Concrete expected values; bug-then-regenerate doesn't silently work
92
+ - Component tests assert _Behavior_ (specific text appears) not _DOM shape_ (every class name and attribute)
93
+
94
+ ## When snapshots ARE worth using
95
+
96
+ Genuine cases for snapshot testing:
97
+
98
+ - **Large generated artifacts** — SQL output from an ORM, generated migration files, OpenAPI specs
99
+ - **Structural data** — public API JSON responses where any structural change should be reviewed
100
+ - **Visual regression** — actual screenshot comparison (e.g., Playwright `toHaveScreenshot`)
101
+
102
+ For these:
103
+
104
+ - Keep the snapshot small (don't snapshot the whole HTML tree if you can snapshot the relevant attribute)
105
+ - Review the snapshot diff IN the PR (treat snapshot files as code)
106
+ - Don't `-u` reflexively; understand the change
107
+
108
+ ## Detection
109
+
110
+ ```bash
111
+ # Snapshot usage in the repo
112
+ grep -rEn 'toMatchSnapshot\(|toMatchInlineSnapshot\(' --include='*.test.ts' --include='*.spec.ts' --include='*.test.tsx' src/ tests/ | wc -l
113
+
114
+ # Snapshot files
115
+ find . -name '__snapshots__' -type d 2>/dev/null
116
+
117
+ # Heuristic: snapshot files larger than 200 lines = probably too big to review
118
+ find . -path '*/__snapshots__/*.snap' -type f -exec wc -l {} \; 2>/dev/null \
119
+ | awk '$1 > 200 { print "TOO LARGE: " $2 " (" $1 " lines)" }'
120
+
121
+ # Tests that use ONLY snapshot assertions, no toBe / toEqual
122
+ for f in $(find . -name '*.test.tsx' -o -name '*.test.ts' 2>/dev/null); do
123
+ snap=$(grep -c 'toMatchSnapshot' "$f")
124
+ real=$(grep -cE 'toBe\(|toEqual\(|toContain\(|toBeInTheDocument' "$f")
125
+ if [ "$snap" -gt 0 ] && [ "$real" = "0" ]; then
126
+ echo "SNAPSHOT-ONLY: $f"
127
+ fi
128
+ done
129
+ ```
130
+
131
+ Reference: [Kent C. Dodds — Effective Snapshot Testing](https://kentcdodds.com/blog/effective-snapshot-testing) · [Vitest snapshot docs](https://vitest.dev/guide/snapshot) · Internal: [`test-mock-everything`](test-mock-everything.md), [`test-mirror-implementation`](test-mirror-implementation.md)
@@ -0,0 +1,116 @@
1
+ ---
2
+ name: int-codebase-design
3
+ description: "{{ computed.internal_skill_description }}"
4
+ user-invocable: false
5
+ metadata:
6
+ spindle:
7
+ version: 1.1.1
8
+ ---
9
+
10
+ # Codebase Design
11
+
12
+ Design **deep modules**: a lot of behaviour behind a small interface, placed at a clean seam, testable through that interface. Use this language and these principles wherever code is being designed or restructured. The aim is leverage for callers, locality for maintainers, and testability for everyone.
13
+
14
+ ## Glossary
15
+
16
+ Use these terms exactly: don't substitute "component," "service," "API," or "boundary." Consistent language is the whole point.
17
+
18
+ **Module**: anything with an interface and an implementation. Deliberately scale-agnostic: a function, class, package, or tier-spanning slice. _Avoid_: unit, component, service.
19
+
20
+ **Interface**: everything a caller must know to use the module correctly: the type signature, but also invariants, ordering constraints, error modes, required configuration, and performance characteristics. _Avoid_: API, signature (too narrow, they refer only to the type-level surface).
21
+
22
+ **Implementation**: what's inside a module, its body of code. Distinct from **Adapter**: a thing can be a small adapter with a large implementation (a Postgres repo) or a large adapter with a small implementation (an in-memory fake). Reach for "adapter" when the seam is the topic; "implementation" otherwise.
23
+
24
+ **Depth**: leverage at the interface. The amount of behaviour a caller (or test) can exercise per unit of interface they have to learn. A module is **deep** when a large amount of behaviour sits behind a small interface, **shallow** when the interface is nearly as complex as the implementation.
25
+
26
+ **Seam** _(Michael Feathers)_: a place where you can alter behaviour without editing in that place; the _location_ at which a module's interface lives. Where to put the seam is its own design decision, distinct from what goes behind it. _Avoid_: boundary (overloaded with DDD's bounded context).
27
+
28
+ **Adapter**: a concrete thing that satisfies an interface at a seam. Describes _role_ (what slot it fills), not substance (what's inside).
29
+
30
+ **Leverage**: what callers get from depth. More capability per unit of interface they learn. One implementation pays back across N call sites and M tests.
31
+
32
+ **Locality**: what maintainers get from depth. Change, bugs, knowledge, and verification concentrate in one place rather than spreading across callers. Fix once, fixed everywhere.
33
+
34
+ ## Deep vs shallow
35
+
36
+ **Deep module** = small interface + lots of implementation:
37
+
38
+ ```
39
+ ┌─────────────────────┐
40
+ │ Small Interface │ ← Few methods, simple params
41
+ ├─────────────────────┤
42
+ │ │
43
+ │ Deep Implementation│ ← Complex logic hidden
44
+ │ │
45
+ └─────────────────────┘
46
+ ```
47
+
48
+ **Shallow module** = large interface + little implementation (avoid):
49
+
50
+ ```
51
+ ┌─────────────────────────────────┐
52
+ │ Large Interface │ ← Many methods, complex params
53
+ ├─────────────────────────────────┤
54
+ │ Thin Implementation │ ← Just passes through
55
+ └─────────────────────────────────┘
56
+ ```
57
+
58
+ When designing an interface, ask:
59
+
60
+ - Can I reduce the number of methods?
61
+ - Can I simplify the parameters?
62
+ - Can I hide more complexity inside?
63
+
64
+ ## Principles
65
+
66
+ - **Depth is a property of the interface, not the implementation.** A deep module can be internally composed of small, mockable, swappable parts; they just aren't part of the interface. A module can have **internal seams** (private to its implementation, used by its own tests) as well as the **external seam** at its interface.
67
+ - **The deletion test.** Imagine deleting the module. If complexity vanishes, it was a pass-through. If complexity reappears across N callers, it was earning its keep.
68
+ - **The interface is the test surface.** Callers and tests cross the same seam. If you want to test _past_ the interface, the module is probably the wrong shape.
69
+ - **One adapter means a hypothetical seam. Two adapters means a real one.** Don't introduce a seam unless something actually varies across it.
70
+
71
+ ## Designing for testability
72
+
73
+ Good interfaces make testing natural:
74
+
75
+ 1. **Accept dependencies, don't create them.**
76
+
77
+ ```text
78
+ Testable:
79
+ process the order using an injected payment gateway
80
+
81
+ Hard to test:
82
+ process the order
83
+ create the payment gateway inside the operation
84
+ ```
85
+
86
+ 2. **Return results, don't produce side effects.**
87
+
88
+ ```text
89
+ Testable:
90
+ calculate the discount and return it
91
+
92
+ Hard to test:
93
+ apply the discount
94
+ change the cart total directly
95
+ ```
96
+
97
+ 3. **Small surface area.** Fewer methods = fewer tests needed. Fewer params = simpler test setup.
98
+
99
+ ## Relationships
100
+
101
+ - A **Module** has exactly one **Interface** (the surface it presents to callers and tests).
102
+ - **Depth** is a property of a **Module**, measured against its **Interface**.
103
+ - A **Seam** is where a **Module**'s **Interface** lives.
104
+ - An **Adapter** sits at a **Seam** and satisfies the **Interface**.
105
+ - **Depth** produces **Leverage** for callers and **Locality** for maintainers.
106
+
107
+ ## Rejected framings
108
+
109
+ - **Depth as ratio of implementation-lines to interface-lines** (Ousterhout): rewards padding the implementation. We use depth-as-leverage instead.
110
+ - **"Interface" as the TypeScript `interface` keyword or a class's public methods**: too narrow: interface here includes every fact a caller must know.
111
+ - **"Boundary"**: overloaded with DDD's bounded context. Say **seam** or **interface**.
112
+
113
+ ## Going deeper
114
+
115
+ - **Deepening a cluster given its dependencies**, see [DEEPENING.md](./references/DEEPENING.md): dependency categories, seam discipline, and replace-don't-layer testing.
116
+ - **Exploring alternative interfaces**, see [DESIGN-IT-TWICE.md](./references/DESIGN-IT-TWICE.md): spin up parallel sub-agents to design the interface several radically different ways, then compare on depth, locality, and seam placement.
@@ -0,0 +1,37 @@
1
+ # Deepening
2
+
3
+ How to deepen a cluster of shallow modules safely, given its dependencies. Assumes the vocabulary in [SKILL.md](../SKILL.md): **module**, **interface**, **seam**, **adapter**.
4
+
5
+ ## Dependency categories
6
+
7
+ When assessing a candidate for deepening, classify its dependencies. The category determines how the deepened module is tested across its seam.
8
+
9
+ ### 1. In-process
10
+
11
+ Pure computation, in-memory state, no I/O. Always deepenable: merge the modules and test through the new interface directly. No adapter needed.
12
+
13
+ ### 2. Local-substitutable
14
+
15
+ Dependencies that have local test stand-ins (PGLite for Postgres, in-memory filesystem). Deepenable if the stand-in exists. The deepened module is tested with the stand-in running in the test suite. The seam is internal; no port at the module's external interface.
16
+
17
+ ### 3. Remote but owned (Ports & Adapters)
18
+
19
+ Your own services across a network boundary (microservices, internal APIs). Define a **port** (interface) at the seam. The deep module owns the logic; the transport is injected as an **adapter**. Tests use an in-memory adapter. Production uses an HTTP/gRPC/queue adapter.
20
+
21
+ Recommendation shape: _"Define a port at the seam, implement an HTTP adapter for production and an in-memory adapter for testing, so the logic sits in one deep module even though it's deployed across a network."_
22
+
23
+ ### 4. True external (Mock)
24
+
25
+ Third-party services (Stripe, Twilio, etc.) you don't control. The deepened module takes the external dependency as an injected port; tests provide a mock adapter.
26
+
27
+ ## Seam discipline
28
+
29
+ - **One adapter means a hypothetical seam. Two adapters means a real one.** Don't introduce a port unless at least two adapters are justified (typically production + test). A single-adapter seam is just indirection.
30
+ - **Internal seams vs external seams.** A deep module can have internal seams (private to its implementation, used by its own tests) as well as the external seam at its interface. Don't expose internal seams through the interface just because tests use them.
31
+
32
+ ## Testing strategy: replace, don't layer
33
+
34
+ - Old unit tests on shallow modules become waste once tests at the deepened module's interface exist; delete them.
35
+ - Write new tests at the deepened module's interface. The **interface is the test surface**.
36
+ - Tests assert on observable outcomes through the interface, not internal state.
37
+ - Tests should survive internal refactors, since they describe behaviour, not implementation. If a test has to change when the implementation changes, it's testing past the interface.
@@ -0,0 +1,44 @@
1
+ # Design It Twice
2
+
3
+ When the user wants to explore alternative interfaces for a chosen deepening candidate, use this parallel sub-agent pattern. Based on "Design It Twice" (Ousterhout): your first idea is unlikely to be the best.
4
+
5
+ Uses the vocabulary in [SKILL.md](../SKILL.md): **module**, **interface**, **seam**, **adapter**, **leverage**.
6
+
7
+ ## Process
8
+
9
+ ### 1. Frame the problem space
10
+
11
+ Before spawning sub-agents, write a user-facing explanation of the problem space for the chosen candidate:
12
+
13
+ - The constraints any new interface would need to satisfy
14
+ - The dependencies it would rely on, and which category they fall into (see [DEEPENING.md](DEEPENING.md))
15
+ - A rough illustrative code sketch to ground the constraints, not a proposal, just a way to make the constraints concrete
16
+
17
+ Show this to the user, then immediately proceed to Step 2. The user reads and thinks while the sub-agents work in parallel.
18
+
19
+ ### 2. Spawn sub-agents
20
+
21
+ Spawn 3+ sub-agents in parallel. Each must produce a **radically different** interface for the deepened module.
22
+
23
+ Prompt each sub-agent with a separate technical brief (file paths, coupling details, dependency category from [DEEPENING.md](DEEPENING.md), what sits behind the seam). The brief is independent of the user-facing problem-space explanation in Step 1. Give each agent a different design constraint:
24
+
25
+ - Agent 1: "Minimize the interface: aim for 1–3 entry points max. Maximise leverage per entry point."
26
+ - Agent 2: "Maximise flexibility: support many use cases and extension."
27
+ - Agent 3: "Optimise for the most common caller: make the default case trivial."
28
+ - Agent 4 (if applicable): "Design around ports & adapters for cross-seam dependencies."
29
+
30
+ Include both [SKILL.md](../SKILL.md) vocabulary and GLOSSARY.md vocabulary in the brief so each sub-agent names things consistently with the architecture language and the project's domain language.
31
+
32
+ Each sub-agent outputs:
33
+
34
+ 1. Interface (types, methods, params, plus invariants, ordering, error modes)
35
+ 2. Usage example showing how callers use it
36
+ 3. What the implementation hides behind the seam
37
+ 4. Dependency strategy and adapters (see [DEEPENING.md](DEEPENING.md))
38
+ 5. Trade-offs: where leverage is high, where it's thin
39
+
40
+ ### 3. Present and compare
41
+
42
+ Present designs sequentially so the user can absorb each one, then compare them in prose. Contrast by **depth** (leverage at the interface), **locality** (where change concentrates), and **seam placement**.
43
+
44
+ After comparing, give your own recommendation: which design you think is strongest and why. If elements from different designs would combine well, propose a hybrid. Be opinionated: the user wants a strong read, not a menu.