@polderlabs/bizar 10.7.0 → 10.7.2

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 (148) hide show
  1. package/.claude/agents/_shared/AGENT_BASELINE.md +266 -0
  2. package/.claude/agents/_shared/CLAUDE_TOOLS.md +412 -0
  3. package/.claude/agents/_shared/SKILLS.md +109 -0
  4. package/.claude/agents/brand-designer.md +55 -0
  5. package/.claude/agents/exec-assistant.md +34 -0
  6. package/.claude/agents/help-desk.md +44 -0
  7. package/.claude/agents/it-lead.md +53 -0
  8. package/.claude/agents/knowledge-manager.md +49 -0
  9. package/.claude/agents/office-coordinator.md +39 -0
  10. package/.claude/agents/office-greeter.md +53 -0
  11. package/.claude/agents/office-manager.md +287 -0
  12. package/.claude/agents/principal-engineer.md +58 -0
  13. package/.claude/agents/qa-reviewer.md +51 -0
  14. package/.claude/agents/research-analyst.md +53 -0
  15. package/.claude/agents/senior-engineer.md +55 -0
  16. package/.claude/agents/support-tech.md +87 -0
  17. package/.claude/agents/vp-engineering.md +54 -0
  18. package/.claude/commands/audit.md +48 -0
  19. package/.claude/commands/bizar.md +22 -0
  20. package/.claude/commands/cron.md +36 -0
  21. package/.claude/commands/explain.md +17 -0
  22. package/.claude/commands/goal.md +99 -0
  23. package/.claude/commands/init.md +15 -0
  24. package/.claude/commands/learn.md +46 -0
  25. package/.claude/commands/plan.md +35 -0
  26. package/.claude/commands/plow-through.md +50 -0
  27. package/.claude/commands/pr-review.md +49 -0
  28. package/.claude/commands/setup-provider.md +96 -0
  29. package/.claude/commands/spec.md +47 -0
  30. package/.claude/commands/sprint.md +43 -0
  31. package/.claude/commands/tailscale-serve.md +100 -0
  32. package/.claude/commands/team.md +132 -0
  33. package/.claude/commands/test.md +62 -0
  34. package/.claude/commands/validate.md +68 -0
  35. package/.claude/commands/visual-plan.md +24 -0
  36. package/.claude/hooks/README.md +108 -0
  37. package/.claude/hooks/__tests__/pretooluse-editwrite.test.mjs +146 -0
  38. package/.claude/hooks/__tests__/sessionend-recall.test.mjs +256 -0
  39. package/.claude/hooks/__tests__/sessionstart-prime.test.mjs +325 -0
  40. package/.claude/hooks/__tests__/thinking-route.test.mjs +319 -0
  41. package/.claude/hooks/auto-instinct.sh +81 -0
  42. package/.claude/hooks/learning-extract.mjs +92 -0
  43. package/.claude/hooks/post-merge-audit.sh +93 -0
  44. package/.claude/hooks/posttooluse-editwrite.mjs +91 -0
  45. package/.claude/hooks/pretooluse-bash.mjs +87 -0
  46. package/.claude/hooks/pretooluse-editwrite.mjs +117 -0
  47. package/.claude/hooks/sessionend-recall.mjs +384 -0
  48. package/.claude/hooks/sessionstart-prime.mjs +278 -0
  49. package/.claude/hooks/thinking-route.mjs +314 -0
  50. package/.claude/hooks/worker-suggest.mjs +110 -0
  51. package/.claude/settings.json +167 -0
  52. package/.claude/skills/9router/SKILL.md +80 -0
  53. package/.claude/skills/9router-chat/SKILL.md +73 -0
  54. package/.claude/skills/9router-embeddings/SKILL.md +69 -0
  55. package/.claude/skills/9router-image/SKILL.md +86 -0
  56. package/.claude/skills/9router-stt/SKILL.md +79 -0
  57. package/.claude/skills/9router-tts/SKILL.md +80 -0
  58. package/.claude/skills/9router-web-fetch/SKILL.md +99 -0
  59. package/.claude/skills/9router-web-search/SKILL.md +91 -0
  60. package/.claude/skills/agent-browser/SKILL.md +64 -0
  61. package/.claude/skills/bizar/README.md +9 -0
  62. package/.claude/skills/bizar/SKILL.md +447 -0
  63. package/.claude/skills/cpp-coding-standards/README.md +28 -0
  64. package/.claude/skills/cpp-coding-standards/SKILL.md +634 -0
  65. package/.claude/skills/cpp-coding-standards/references/concurrency.md +320 -0
  66. package/.claude/skills/cpp-coding-standards/references/error-handling.md +229 -0
  67. package/.claude/skills/cpp-coding-standards/references/memory-safety.md +216 -0
  68. package/.claude/skills/cpp-coding-standards/references/modern-idioms.md +282 -0
  69. package/.claude/skills/cpp-coding-standards/references/review-checklist.md +96 -0
  70. package/.claude/skills/cpp-testing/README.md +28 -0
  71. package/.claude/skills/cpp-testing/SKILL.md +304 -0
  72. package/.claude/skills/cpp-testing/references/coverage.md +370 -0
  73. package/.claude/skills/cpp-testing/references/framework-compare.md +175 -0
  74. package/.claude/skills/cpp-testing/references/host-test-for-embedded.md +499 -0
  75. package/.claude/skills/cpp-testing/references/mocking.md +364 -0
  76. package/.claude/skills/cpp-testing/references/tdd-workflow.md +308 -0
  77. package/.claude/skills/cubesandbox/SKILL.md +148 -0
  78. package/.claude/skills/de-sloppify/SKILL.md +38 -0
  79. package/.claude/skills/de-sloppify/cleanup.mjs +253 -0
  80. package/.claude/skills/de-sloppify/cleanup.test.mjs +189 -0
  81. package/.claude/skills/embedded-esp-idf/README.md +41 -0
  82. package/.claude/skills/embedded-esp-idf/SKILL.md +439 -0
  83. package/.claude/skills/embedded-esp-idf/references/freertos-patterns.md +214 -0
  84. package/.claude/skills/embedded-esp-idf/references/host-tests.md +164 -0
  85. package/.claude/skills/embedded-esp-idf/references/idf-py-commands.md +157 -0
  86. package/.claude/skills/embedded-esp-idf/references/kconfig.md +159 -0
  87. package/.claude/skills/embedded-esp-idf/references/logging-discipline.md +118 -0
  88. package/.claude/skills/embedded-esp-idf/references/memory-and-iram.md +137 -0
  89. package/.claude/skills/embedded-esp-idf/references/nvs.md +121 -0
  90. package/.claude/skills/embedded-esp-idf/references/packed-structs.md +192 -0
  91. package/.claude/skills/embedded-esp-idf/scripts/idf_env.sh +47 -0
  92. package/.claude/skills/embedded-esp-idf/scripts/size_check.sh +77 -0
  93. package/.claude/skills/glyph/SKILL.md +163 -0
  94. package/.claude/skills/harness-engineering/SKILL.md +142 -0
  95. package/.claude/skills/lightrag/SKILL.md +81 -0
  96. package/.claude/skills/memory-protocol/SKILL.md +105 -0
  97. package/.claude/skills/obsidian/SKILL.md +306 -0
  98. package/.claude/skills/read-the-damn-docs/SKILL.md +113 -0
  99. package/.claude/skills/self-improvement/SKILL.md +64 -0
  100. package/.claude/skills/skillopt/SKILL.md +129 -0
  101. package/.claude/skills/thinking-archetypes/SKILL.md +90 -0
  102. package/.claude/skills/thinking-bayesian/SKILL.md +267 -0
  103. package/.claude/skills/thinking-bounded-rationality/SKILL.md +406 -0
  104. package/.claude/skills/thinking-circle-of-competence/SKILL.md +216 -0
  105. package/.claude/skills/thinking-cynefin/SKILL.md +70 -0
  106. package/.claude/skills/thinking-debiasing/SKILL.md +192 -0
  107. package/.claude/skills/thinking-dual-process/SKILL.md +282 -0
  108. package/.claude/skills/thinking-effectuation/SKILL.md +366 -0
  109. package/.claude/skills/thinking-feedback-loops/SKILL.md +464 -0
  110. package/.claude/skills/thinking-fermi-estimation/SKILL.md +263 -0
  111. package/.claude/skills/thinking-first-principles/SKILL.md +167 -0
  112. package/.claude/skills/thinking-five-whys-plus/SKILL.md +139 -0
  113. package/.claude/skills/thinking-inversion/SKILL.md +195 -0
  114. package/.claude/skills/thinking-jobs-to-be-done/SKILL.md +363 -0
  115. package/.claude/skills/thinking-kepner-tregoe/SKILL.md +154 -0
  116. package/.claude/skills/thinking-leverage-points/SKILL.md +390 -0
  117. package/.claude/skills/thinking-lindy-effect/SKILL.md +331 -0
  118. package/.claude/skills/thinking-map-territory/SKILL.md +111 -0
  119. package/.claude/skills/thinking-margin-of-safety/SKILL.md +330 -0
  120. package/.claude/skills/thinking-model-combination/SKILL.md +406 -0
  121. package/.claude/skills/thinking-model-router/SKILL.md +360 -0
  122. package/.claude/skills/thinking-model-selection/SKILL.md +341 -0
  123. package/.claude/skills/thinking-occams-razor/SKILL.md +129 -0
  124. package/.claude/skills/thinking-ooda/SKILL.md +127 -0
  125. package/.claude/skills/thinking-opportunity-cost/SKILL.md +360 -0
  126. package/.claude/skills/thinking-pre-mortem/SKILL.md +170 -0
  127. package/.claude/skills/thinking-probabilistic/SKILL.md +324 -0
  128. package/.claude/skills/thinking-red-team/SKILL.md +142 -0
  129. package/.claude/skills/thinking-regret-minimization/SKILL.md +335 -0
  130. package/.claude/skills/thinking-reversibility/SKILL.md +326 -0
  131. package/.claude/skills/thinking-scientific-method/SKILL.md +162 -0
  132. package/.claude/skills/thinking-second-order/SKILL.md +184 -0
  133. package/.claude/skills/thinking-socratic/SKILL.md +198 -0
  134. package/.claude/skills/thinking-steel-manning/SKILL.md +332 -0
  135. package/.claude/skills/thinking-systems/SKILL.md +238 -0
  136. package/.claude/skills/thinking-theory-of-constraints/SKILL.md +338 -0
  137. package/.claude/skills/thinking-thought-experiment/SKILL.md +354 -0
  138. package/.claude/skills/thinking-triz/SKILL.md +171 -0
  139. package/.claude/skills/thinking-via-negativa/SKILL.md +358 -0
  140. package/bizar-dash/skills/publishing/SKILL.md +2 -1
  141. package/cli/install/postinstall.mjs +54 -28
  142. package/cli/install/postinstall.test.mjs +98 -0
  143. package/cli/provision.mjs +29 -0
  144. package/install.sh +7 -0
  145. package/package.json +7 -2
  146. package/scripts/git-hooks/__tests__/commit-msg.test.mjs +61 -0
  147. package/scripts/git-hooks/commit-msg +38 -0
  148. package/scripts/install-hooks.sh +9 -0
@@ -0,0 +1,338 @@
1
+ ---
2
+ name: thinking-theory-of-constraints
3
+ description: Use when optimizing latency or throughput in a pipeline and one stage dominates—focus all effort on that single bottleneck, since speeding up the others changes nothing until it's fixed.
4
+ ---
5
+
6
+ # Theory of Constraints
7
+
8
+ ## Overview
9
+
10
+ The Theory of Constraints (TOC), from Eliyahu Goldratt's "The Goal," says a throughput-limited system has exactly one constraint setting its rate. Optimizing anything else is wasted effort—often counterproductive. Find the bottleneck, exploit it, subordinate everything else to it, and only then elevate it.
11
+
12
+ **Core Principle:** A chain is only as strong as its weakest link. Strengthening any other link does nothing.
13
+
14
+ ## When to Use
15
+
16
+ - Latency optimization where one stage dominates the time budget
17
+ - Throughput optimization where one stage caps the rate
18
+ - A pipeline where work piles up before one specific stage
19
+
20
+ ```
21
+ Trying to improve latency/throughput?
22
+ → Have you identified the constraint? → no → FIND THE CONSTRAINT FIRST
23
+ → Are you optimizing a non-constraint? → yes → STOP, FOCUS ON CONSTRAINT
24
+ → Is the constraint working at 100%? → no → EXPLOIT BEFORE ELEVATING
25
+ ```
26
+
27
+ ## When NOT to Use
28
+
29
+ - **No single stage dominates** (latency/load is spread roughly evenly, or many stages are near 100%) → there is no one constraint to exploit. Use `thinking-systems` to model the interactions instead.
30
+ - The problem is correctness, not throughput → this is the wrong lens; debug the fault.
31
+ - The bottleneck is already obvious and cheap to fix → just fix it; skip the five steps.
32
+ - "Bottleneck" shifts every run (it's contention/coupling, not a fixed stage) → that's a systems problem, not a constraint.
33
+
34
+ ## The Five Focusing Steps
35
+
36
+ ### Step 1: Identify the Constraint
37
+
38
+ Find the one thing limiting the system:
39
+
40
+ ```markdown
41
+ ## Constraint Identification
42
+
43
+ System: Software delivery pipeline
44
+
45
+ Potential constraints:
46
+ | Stage | Capacity | Utilization | Queue Time |
47
+ |-------|----------|-------------|------------|
48
+ | Requirements | 10/week | 60% | 0 days |
49
+ | Development | 8/week | 95% | 3 days |
50
+ | Code Review | 5/week | 100% | 5 days |←CONSTRAINT
51
+ | Testing | 12/week | 40% | 0 days |
52
+ | Deployment | 20/week | 20% | 0 days |
53
+
54
+ Constraint: Code Review
55
+ Evidence: 100% utilization, 5-day queue, lowest throughput
56
+ ```
57
+
58
+ **How to find the constraint:**
59
+ - Highest utilization
60
+ - Longest queue/wait time
61
+ - Lowest throughput rate
62
+ - Where work piles up
63
+ - What people complain about waiting for
64
+
65
+ ### Step 2: Exploit the Constraint
66
+
67
+ Get maximum output from the constraint without spending money:
68
+
69
+ ```markdown
70
+ ## Exploiting the Constraint
71
+
72
+ Constraint: Code Review (5/week capacity)
73
+
74
+ Exploitation strategies:
75
+ | Strategy | Effort | Impact |
76
+ |----------|--------|--------|
77
+ | Never let reviewers wait for reviewable PRs | Low | +10% |
78
+ | Batch small PRs together | Low | +15% |
79
+ | Clear review criteria to reduce back-and-forth | Low | +20% |
80
+ | Prioritize reviews over other reviewer work | Medium | +10% |
81
+ | Remove unnecessary review requirements | Low | +15% |
82
+
83
+ Total potential: 5/week → 8/week (60% increase, no new resources)
84
+ ```
85
+
86
+ **Exploitation questions:**
87
+ - Is the constraint ever idle? Why?
88
+ - Is the constraint doing any unnecessary work?
89
+ - Is the constraint's output ever wasted downstream?
90
+ - Can we reduce setup/changeover time?
91
+ - Can we improve quality at the constraint (less rework)?
92
+
93
+ ### Step 3: Subordinate Everything Else
94
+
95
+ Non-constraints should serve the constraint:
96
+
97
+ ```markdown
98
+ ## Subordination
99
+
100
+ Every other stage should optimize FOR code review, not for itself.
101
+
102
+ Requirements:
103
+ - DON'T: Maximize requirement throughput
104
+ - DO: Pace requirements to match code review capacity
105
+ - DO: Ensure requirements are clear (reduce review iterations)
106
+
107
+ Development:
108
+ - DON'T: Maximize development output
109
+ - DO: Produce review-ready code at the rate review can handle
110
+ - DO: Spend extra time on clarity (save reviewer time)
111
+
112
+ Testing:
113
+ - DON'T: Maximize testing efficiency
114
+ - DO: Be ready to test immediately when reviews complete
115
+ - DO: Provide feedback that helps reviewers learn
116
+
117
+ Counter-intuitive: Keeping developers busy beyond review capacity
118
+ creates work-in-progress that HURTS throughput
119
+ ```
120
+
121
+ **Subordination principle:**
122
+ Local optimization of non-constraints often hurts global throughput. A 100% utilized developer feeding a 100% utilized reviewer creates a queue that slows everything.
123
+
124
+ ### Step 4: Elevate the Constraint
125
+
126
+ If exploitation isn't enough, invest in increasing constraint capacity:
127
+
128
+ ```markdown
129
+ ## Elevating the Constraint
130
+
131
+ Current constraint capacity: 8/week (after exploitation)
132
+ Required capacity: 12/week
133
+
134
+ Elevation options:
135
+ | Option | Cost | Capacity Gain |
136
+ |--------|------|---------------|
137
+ | Hire dedicated reviewer | $150K/year | +4/week |
138
+ | Train more reviewers | $10K training | +2/week |
139
+ | Adopt review tooling | $5K/year | +1/week |
140
+ | Pair reviewing | Process change | +3/week |
141
+
142
+ Recommendation: Training + tooling first ($15K for +3/week)
143
+ Then hire if still insufficient
144
+ ```
145
+
146
+ **Elevation timing:**
147
+ Only elevate after exploitation is maxed out. Elevating is expensive; exploitation is cheap.
148
+
149
+ ### Step 5: Prevent Inertia (Go Back to Step 1)
150
+
151
+ When you elevate, the constraint often moves:
152
+
153
+ ```markdown
154
+ ## Constraint Movement
155
+
156
+ Before: Code Review was constraint (5/week)
157
+ After elevation: Code Review does 12/week
158
+
159
+ New constraint search:
160
+ | Stage | Capacity | Utilization |
161
+ |-------|----------|-------------|
162
+ | Requirements | 10/week | 100% | ←NEW CONSTRAINT
163
+ | Development | 15/week | 80% |
164
+ | Code Review | 12/week | 80% |
165
+ | Testing | 12/week | 100% | ←OR THIS ONE |
166
+
167
+ System bottleneck moved—repeat the process.
168
+ ```
169
+
170
+ ## Finding Constraints
171
+
172
+ ### Types of Constraints
173
+
174
+ | Type | Examples | How to Find |
175
+ |------|----------|-------------|
176
+ | Physical | Machine capacity, server limits | Utilization metrics |
177
+ | Policy | Approval requirements, rules | Process analysis |
178
+ | Market | Customer demand | Sales/pipeline data |
179
+ | Time | Fixed deadlines | Schedule analysis |
180
+ | Knowledge | Expert availability | Skill matrix |
181
+
182
+ ### Constraint Indicators
183
+
184
+ ```
185
+ Signs of a constraint:
186
+ ✓ Work queues up before this stage
187
+ ✓ Downstream stages have idle time
188
+ ✓ Increasing input doesn't increase output
189
+ ✓ This stage is always at full capacity
190
+ ✓ Small improvements here have large system effects
191
+
192
+ Signs of a non-constraint:
193
+ ✓ Often has idle time
194
+ ✓ Improvement has no system effect
195
+ ✓ Work flows through without queuing
196
+ ```
197
+
198
+ ## TOC Application Patterns
199
+
200
+ ### Performance Optimization
201
+
202
+ ```markdown
203
+ ## System Performance Analysis
204
+
205
+ Request flow:
206
+ API Gateway → Auth → App Logic → Database → Response
207
+
208
+ Latency breakdown:
209
+ | Component | Latency | % of Total |
210
+ |-----------|---------|------------|
211
+ | API Gateway | 5ms | 2% |
212
+ | Auth | 10ms | 4% |
213
+ | App Logic | 30ms | 12% |
214
+ | Database | 200ms | 80% | ←CONSTRAINT
215
+ | Response | 5ms | 2% |
216
+
217
+ Constraint: Database
218
+
219
+ Wrong approach: Optimize app logic (12% of latency)
220
+ Right approach: Focus 100% on database optimization
221
+ Query optimization, caching, indexing, read replicas
222
+ ```
223
+
224
+ ### Batch/Data Pipeline Throughput
225
+
226
+ ```markdown
227
+ ## Pipeline Throughput Analysis
228
+
229
+ Stage flow:
230
+ Ingest → Parse → Transform → Enrich (external API) → Write
231
+
232
+ Throughput analysis:
233
+ | Stage | Rate (rec/s) | Utilization |
234
+ |-------|--------------|-------------|
235
+ | Ingest | 50,000 | 20% |
236
+ | Parse | 30,000 | 35% |
237
+ | Transform | 20,000 | 50% |
238
+ | Enrich (external API) | 2,000 | 100% | ←CONSTRAINT
239
+ | Write | 40,000 | 25% |
240
+
241
+ System throughput is capped at 2,000 rec/s by the enrichment call.
242
+ Parallelizing parse/transform does nothing—it just grows the queue before Enrich.
243
+
244
+ Exploit: batch the API calls, cache repeat lookups, drop redundant enrichments.
245
+ Subordinate: pace upstream stages to 2,000 rec/s; don't build WIP.
246
+ Elevate (only if exploit insufficient): add API concurrency / a second provider.
247
+ ```
248
+
249
+ ### Concurrency / Lock Contention
250
+
251
+ ```markdown
252
+ ## Contention Analysis
253
+
254
+ Symptom: throughput plateaus far below CPU capacity.
255
+
256
+ | Resource | Wait time | Notes |
257
+ |----------|-----------|-------|
258
+ | CPU | low | cores idle |
259
+ | Global mutex | HIGH | every request serializes here | ←CONSTRAINT
260
+ | DB pool | low | |
261
+
262
+ The single hot lock is the constraint; adding workers makes contention worse.
263
+ Exploit: shorten the critical section to the minimum.
264
+ Elevate: shard the lock / switch to a lock-free or per-key structure.
265
+ ```
266
+
267
+ ## Theory of Constraints Template
268
+
269
+ ```markdown
270
+ # TOC Analysis: [System/Process]
271
+
272
+ ## System Definition
273
+ What flows through this system: [Work items, requests, features]
274
+ Goal: [What throughput matters]
275
+
276
+ ## Constraint Identification
277
+
278
+ | Stage | Capacity | Utilization | Queue Time | Throughput |
279
+ |-------|----------|-------------|------------|------------|
280
+ | | | | | |
281
+
282
+ **Identified Constraint:** [Stage]
283
+ **Evidence:** [Why this is the constraint]
284
+
285
+ ## Step 2: Exploit
286
+
287
+ How to maximize constraint output without investment:
288
+ | Exploitation | Effort | Expected Gain |
289
+ |--------------|--------|---------------|
290
+ | | | |
291
+
292
+ ## Step 3: Subordinate
293
+
294
+ How should non-constraints support the constraint?
295
+ | Stage | Current Behavior | Should Change To |
296
+ |-------|------------------|------------------|
297
+ | | | |
298
+
299
+ ## Step 4: Elevate (if needed)
300
+
301
+ If exploitation isn't sufficient:
302
+ | Elevation Option | Cost | Capacity Gain |
303
+ |------------------|------|---------------|
304
+ | | | |
305
+
306
+ ## Step 5: Next Constraint
307
+
308
+ After elevation, where will the constraint move?
309
+ [Prediction]
310
+ ```
311
+
312
+ ## Verification Checklist
313
+
314
+ - [ ] Identified the single constraint (not multiple "bottlenecks")
315
+ - [ ] Have data supporting the constraint identification
316
+ - [ ] Maximized exploitation before considering elevation
317
+ - [ ] Non-constraints are subordinated (not locally optimized)
318
+ - [ ] Not investing in non-constraint improvements
319
+ - [ ] Monitoring for constraint movement
320
+
321
+ ## Key Questions
322
+
323
+ - "What's the ONE thing limiting throughput?"
324
+ - "Is the constraint ever idle? Why?"
325
+ - "Are we improving a non-constraint while ignoring the constraint?"
326
+ - "Are non-constraint improvements building inventory?"
327
+ - "What should the rest of the system do to serve the constraint?"
328
+ - "If we improve this, where will the constraint move?"
329
+
330
+ ## Goldratt's Wisdom
331
+
332
+ "Every action that brings the company closer to its goal is productive. Every action that does not bring a company closer to its goal is not productive."
333
+
334
+ "An hour lost at a bottleneck is an hour lost forever. An hour saved at a non-bottleneck is a mirage."
335
+
336
+ "The sum of local optimums is not equal to the global optimum."
337
+
338
+ Optimizing everywhere is the same as optimizing nowhere. Find the constraint. Make it work. That's all that matters until the constraint moves.
@@ -0,0 +1,354 @@
1
+ ---
2
+ name: thinking-thought-experiment
3
+ description: You need to trace how a system would fail or behave at a scale you can't cheaply test or measure. Use to imagine the scenario and walk the consequence chain step by step.
4
+ ---
5
+
6
+ # Thought Experiments
7
+
8
+ ## Overview
9
+
10
+ Thought experiments use imagination to test ideas when direct experimentation is impractical, impossible, or premature. Einstein's elevator, Schrödinger's cat, and the trolley problem have advanced physics and philosophy. In engineering, thought experiments help evaluate designs, explore edge cases, and stress-test decisions before implementation.
11
+
12
+ **Core Principle:** Structured imagination is a tool. When you can't test in reality, test in your mind with discipline.
13
+
14
+ ## The Core Reframe
15
+
16
+ When you can't run the real experiment — the failure is too rare, the scale too large, the decision too one-way — you can still run it in your head with discipline: fix the conditions, then trace the consequence chain one step at a time until something breaks. The value is in the *step-by-step trace*, not in the verdict you jumped to.
17
+
18
+ ## When to Use
19
+
20
+ - Tracing a failure mode you can't easily trigger (primary DB down at peak, region outage)
21
+ - Reasoning about behavior at a scale you can't currently reach (10x/100x traffic)
22
+ - Evaluating a one-way architectural decision before committing
23
+ - Exploring edge cases that are expensive or impossible to reproduce
24
+
25
+ Decision flow:
26
+
27
+ ```
28
+ Need to understand how something behaves?
29
+ → Can you cheaply test or measure it? → yes → DO THAT (stop here)
30
+ → Is the real test too rare/large/irreversible? → yes → THOUGHT EXPERIMENT
31
+ ```
32
+
33
+ ## When NOT to Use
34
+
35
+ - **If you can cheaply test or measure it, test it.** A thought experiment is a substitute for empiricism, not a replacement — a load test, a feature flag, a query against real data, or a pam spike beats imagined consequences every time. Reach for this skill only when the real experiment is genuinely out of reach.
36
+ - **For adversarial "how would an attacker break this" analysis, use thinking-red-team** — it has the structured attack-surface and findings format. Don't reinvent it here.
37
+
38
+ ## Trigger Card
39
+
40
+ When you need to trace how a system would behave at a scale you can't cheaply test:
41
+
42
+ 1. **Define the scenario precisely** — what changed? What's different from normal operation? Set initial conditions.
43
+ 2. **Walk the consequence chain step by step** — given these conditions, what does the system do next? Then what? Then what? Be mechanistic, not hand-wavy.
44
+ 3. **Derive what you'd need to check** — what observation would confirm or refute this chain? If you can test one link cheaply, test it.
45
+
46
+ If you can cheaply test or measure the real thing (load test, feature flag, query against real data), do that instead — a thought experiment is a substitute for empiricism, not a replacement. For adversarial "how would an attacker break this" analysis, use `thinking-red-team`.
47
+
48
+ ## Types of Thought Experiments
49
+
50
+ ### 1. The Hypothetical Scenario
51
+
52
+ Imagine a specific situation and trace consequences:
53
+
54
+ ```
55
+ "What if we had 100x current traffic tomorrow?"
56
+ "What if our primary database failed right now?"
57
+ "What if a competitor copied our core feature?"
58
+ ```
59
+
60
+ ### 2. The Extreme Case
61
+
62
+ Push a parameter to its limit:
63
+
64
+ ```
65
+ "What happens with 0 users? 1 billion users?"
66
+ "What if latency was 0? What if it was 10 seconds?"
67
+ "What if this team was 1 person? 100 people?"
68
+ ```
69
+
70
+ ### 3. The Counterfactual
71
+
72
+ Imagine the opposite of reality:
73
+
74
+ ```
75
+ "What if we hadn't chosen microservices?"
76
+ "What if we didn't have this dependency?"
77
+ "What if our main customer segment didn't exist?"
78
+ ```
79
+
80
+ ### 4. The Role Reversal
81
+
82
+ Think from a different perspective:
83
+
84
+ ```
85
+ "What would a malicious actor do with this system?"
86
+ "How would a new hire experience this codebase?"
87
+ "What would a competitor do with our technology?"
88
+ ```
89
+
90
+ ### 5. The Time Shift
91
+
92
+ Move forward or backward in time:
93
+
94
+ ```
95
+ "How will this look in 5 years?"
96
+ "If we had known this a year ago, what would we have done?"
97
+ "What will we wish we had built today?"
98
+ ```
99
+
100
+ ## The Thought Experiment Process
101
+
102
+ ### Step 1: Define the Experiment
103
+
104
+ State clearly what you're testing:
105
+
106
+ ```markdown
107
+ ## Thought Experiment: Database Failure Resilience
108
+
109
+ Question: How would our system behave if the primary database
110
+ became unavailable for 30 minutes during peak traffic?
111
+
112
+ Variables:
113
+ - Database state: Unavailable
114
+ - Duration: 30 minutes
115
+ - Traffic: Peak (3x normal)
116
+ - Preparation time: None (unexpected)
117
+ ```
118
+
119
+ ### Step 2: Set the Initial Conditions
120
+
121
+ Describe the starting state precisely:
122
+
123
+ ```markdown
124
+ ## Initial Conditions
125
+
126
+ System state:
127
+ - 10,000 active users
128
+ - 500 RPS to database
129
+ - No circuit breaker currently
130
+ - 10-second connection timeout
131
+ - No read replica failover configured
132
+
133
+ User behavior:
134
+ - Users will retry failed requests
135
+ - ~50% will leave after 2 failures
136
+ ```
137
+
138
+ ### Step 3: Trace the Consequences
139
+
140
+ Walk through what happens step by step:
141
+
142
+ ```markdown
143
+ ## Consequence Chain
144
+
145
+ T+0s: Database becomes unavailable
146
+ T+0-10s: Requests queue waiting for connection
147
+ T+10s: Connection timeouts start
148
+ T+10-30s: App servers accumulate waiting requests
149
+ T+30s: Thread pools exhausted
150
+ T+30s-2m: Cascading timeouts to upstream services
151
+ T+2m: Load balancer health checks fail
152
+ T+2m: Alerts fire (too late - damage done)
153
+ T+2-30m: Service completely unavailable
154
+ T+30m: Database returns, but app servers need restart
155
+ T+35m: Service gradually recovers
156
+ T+1h: Backlog of failed requests processed
157
+ ```
158
+
159
+ ### Step 4: Identify Insights
160
+
161
+ What did you learn?
162
+
163
+ ```markdown
164
+ ## Insights
165
+
166
+ 1. Circuit breaker would limit cascade (need to implement)
167
+ 2. Thread pool exhaustion is the failure mode (need limits)
168
+ 3. Alerts fire too late (need proactive monitoring)
169
+ 4. Recovery is slow (need automated recovery)
170
+ 5. User experience is terrible (need graceful degradation)
171
+ ```
172
+
173
+ ### Step 5: Derive Actions
174
+
175
+ What should you do based on this experiment?
176
+
177
+ ```markdown
178
+ ## Actions
179
+
180
+ | Insight | Action | Priority |
181
+ |---------|--------|----------|
182
+ | No circuit breaker | Implement circuit breaker | High |
183
+ | Thread pool exhaustion | Add connection limits | High |
184
+ | Late alerts | Add DB latency monitoring | Medium |
185
+ | Slow recovery | Automate failover | Medium |
186
+ | Poor UX | Implement degraded mode | Medium |
187
+ ```
188
+
189
+ ## Thought Experiment Patterns
190
+
191
+ ### The Failure Mode Analysis
192
+
193
+ ```markdown
194
+ ## Thought Experiment: What if [component] fails?
195
+
196
+ For each critical component:
197
+ - API Gateway fails: [Trace consequences]
198
+ - Auth service fails: [Trace consequences]
199
+ - Cache layer fails: [Trace consequences]
200
+ - Message queue fails: [Trace consequences]
201
+
202
+ Template for each:
203
+ 1. What fails immediately?
204
+ 2. What fails within 1 minute?
205
+ 3. What's the blast radius?
206
+ 4. How would we know?
207
+ 5. How would we recover?
208
+ ```
209
+
210
+ ### The Adversarial Analysis
211
+
212
+ > For real security work, prefer **thinking-red-team** (structured attack surface + reproducible-attack-path findings). Use the sketch below only as a pam lens, not a substitute.
213
+
214
+ ```markdown
215
+ ## Thought Experiment: Attacker Perspective
216
+
217
+ "I am a malicious actor with [access level]. How would I cause maximum damage?"
218
+
219
+ Scenario 1: External attacker with no access
220
+ - What public endpoints are vulnerable?
221
+ - What would a DDoS look like?
222
+ - What data could I infer from public behavior?
223
+
224
+ Scenario 2: Compromised user account
225
+ - What can I access beyond my own data?
226
+ - Can I escalate privileges?
227
+ - What's the blast radius of one compromised account?
228
+
229
+ Scenario 3: Malicious insider
230
+ - What would a rogue employee do?
231
+ - What access is over-provisioned?
232
+ - What audit trails would catch this?
233
+ ```
234
+
235
+ ### The Scale Experiment
236
+
237
+ ```markdown
238
+ ## Thought Experiment: 10x Scale
239
+
240
+ Current: 10,000 users, 100 RPS
241
+ Imagined: 100,000 users, 1,000 RPS
242
+
243
+ What breaks?
244
+ - [ ] Database connections (pool exhaustion at ~300)
245
+ - [ ] Single-threaded workers (CPU bound at ~500 RPS)
246
+ - [ ] Memory per request (OOM at ~800 RPS)
247
+ - [ ] Network bandwidth (saturated at ~1500 RPS)
248
+
249
+ What doesn't break?
250
+ - [x] Stateless API servers (horizontally scalable)
251
+ - [x] CDN-served assets (already edge-cached)
252
+ - [x] Read-heavy queries (can add replicas)
253
+
254
+ First constraint to address: Database connection pooling
255
+ ```
256
+
257
+ ### The Timeline Experiment
258
+
259
+ ```markdown
260
+ ## Thought Experiment: 3 Years From Now
261
+
262
+ It's 2027. Our system is [successful/struggling]. Why?
263
+
264
+ Success scenario:
265
+ - What architectural decisions paid off?
266
+ - What did we avoid that would have hurt us?
267
+ - What did we invest in that scaled well?
268
+
269
+ Struggle scenario:
270
+ - What technical debt crushed us?
271
+ - What market change did we miss?
272
+ - What architecture couldn't adapt?
273
+
274
+ Present implications:
275
+ - What should we invest in now for 2027 success?
276
+ - What should we avoid now to prevent 2027 failure?
277
+ ```
278
+
279
+ ## Thought Experiment Template
280
+
281
+ ```markdown
282
+ # Thought Experiment: [Title]
283
+
284
+ ## Question
285
+ What am I trying to understand?
286
+ [Precise question]
287
+
288
+ ## Setup
289
+ Initial conditions:
290
+ - [Condition 1]
291
+ - [Condition 2]
292
+
293
+ Variables being tested:
294
+ - [Variable 1]: [Value in experiment]
295
+ - [Variable 2]: [Value in experiment]
296
+
297
+ ## Thought Experiment
298
+ [Step-by-step trace of what happens]
299
+
300
+ T+0: [Initial event]
301
+ T+X: [Consequence]
302
+ T+Y: [Next consequence]
303
+ ...
304
+ T+end: [Final state]
305
+
306
+ ## Observations
307
+ What happened in the experiment?
308
+ - [Observation 1]
309
+ - [Observation 2]
310
+
311
+ ## Insights
312
+ What did I learn?
313
+ - [Insight 1]
314
+ - [Insight 2]
315
+
316
+ ## Implications
317
+ What should I do differently?
318
+ - [Action 1]
319
+ - [Action 2]
320
+
321
+ ## Limitations
322
+ What didn't this experiment capture?
323
+ - [Limitation 1]
324
+ - [Limitation 2]
325
+ ```
326
+
327
+ ## Verification Checklist
328
+
329
+ - [ ] Defined a clear, specific question
330
+ - [ ] Set up realistic initial conditions
331
+ - [ ] Traced consequences systematically
332
+ - [ ] Considered second-order effects
333
+ - [ ] Identified non-obvious insights
334
+ - [ ] Derived actionable implications
335
+ - [ ] Acknowledged experiment limitations
336
+
337
+ ## Key Questions
338
+
339
+ - "What happens if [extreme scenario]?"
340
+ - "How would this look from [different perspective]?"
341
+ - "What would [5 years from now] tell us about this decision?"
342
+ - "What if the opposite were true?"
343
+ - "What's the worst thing that could happen?"
344
+ - "How would a [malicious actor/competitor/novice] interact with this?"
345
+
346
+ ## Einstein's Approach
347
+
348
+ "A thought experiment is a device with which one performs an intentional, structured process of intellectual deliberation in order to speculate, within a specifiable problem domain, about potential consequents (or antecedents) for a designated antecedent (or consequent)."
349
+
350
+ More simply: Imagine a scenario, trace what happens, and learn.
351
+
352
+ "I have no special talents. I am only passionately curious."
353
+
354
+ Thought experiments are curiosity with structure. Ask "what if?" systematically, trace the answer carefully, and you'll see what testing in reality would eventually show you—sometimes years sooner.