@lenardangeloolajay/len-toolkit 1.1.0
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/LICENSE +21 -0
- package/README.md +209 -0
- package/bin/cli.js +244 -0
- package/package.json +35 -0
- package/src/installer.js +236 -0
- package/templates/configs/.editorconfig +12 -0
- package/templates/configs/sample.gitignore +8 -0
- package/templates/docs/FEATURE.md +40 -0
- package/templates/docs/HANDOFF.md +39 -0
- package/templates/docs/IMPLEMENTATION_PLAN.md +47 -0
- package/templates/docs/SPEC_INDEX.md +12 -0
- package/templates/docs/VERIFICATION.md +14 -0
- package/templates/docs/product/ARCHITECTURE.md +22 -0
- package/templates/docs/product/CONSTRAINTS.md +22 -0
- package/templates/docs/product/DATA_MODEL.md +22 -0
- package/templates/docs/product/OVERVIEW.md +22 -0
- package/templates/examples/flutter-handoff/EXERCISES.md +16 -0
- package/templates/examples/flutter-handoff/HANDOFF.md +32 -0
- package/templates/examples/flutter-handoff/docs/SPEC_INDEX.md +19 -0
- package/templates/examples/flutter-handoff/docs/evidence/FEAT-001-verification.md +14 -0
- package/templates/examples/flutter-handoff/docs/features/FEAT-001-local-note.md +40 -0
- package/templates/examples/flutter-handoff/docs/plans/FEAT-001-implementation.md +43 -0
- package/templates/examples/flutter-handoff/docs/product/ARCHITECTURE.md +24 -0
- package/templates/examples/flutter-handoff/docs/product/CONSTRAINTS.md +13 -0
- package/templates/examples/flutter-handoff/docs/product/DATA_MODEL.md +20 -0
- package/templates/examples/flutter-handoff/docs/product/OVERVIEW.md +26 -0
- package/templates/rules/.cursorrules +7 -0
- package/templates/rules/AGENTS.md +61 -0
- package/templates/rules/GEMINI.md +7 -0
- package/templates/skills/a-philosophy-of-software-design/SKILL.md +11 -0
- package/templates/skills/a-philosophy-of-software-design/a-philosophy-of-software-design.md +370 -0
- package/templates/skills/a-philosophy-of-software-design/a-philosophy-of-software-design.mini.md +46 -0
- package/templates/skills/a-philosophy-of-software-design/a-philosophy-of-software-design.nano.md +35 -0
- package/templates/skills/clean-architecture/SKILL.md +11 -0
- package/templates/skills/clean-architecture/clean-architecture.md +515 -0
- package/templates/skills/clean-architecture/clean-architecture.mini.md +49 -0
- package/templates/skills/clean-architecture/clean-architecture.nano.md +36 -0
- package/templates/skills/clean-code/SKILL.md +11 -0
- package/templates/skills/clean-code/clean-code.md +297 -0
- package/templates/skills/clean-code/clean-code.mini.md +47 -0
- package/templates/skills/clean-code/clean-code.nano.md +32 -0
- package/templates/skills/code-complete/SKILL.md +11 -0
- package/templates/skills/code-complete/code-complete.md +354 -0
- package/templates/skills/code-complete/code-complete.mini.md +56 -0
- package/templates/skills/code-complete/code-complete.nano.md +41 -0
- package/templates/skills/council/SKILL.md +37 -0
- package/templates/skills/designing-data-intensive-applications/SKILL.md +11 -0
- package/templates/skills/designing-data-intensive-applications/designing-data-intensive-applications.md +393 -0
- package/templates/skills/designing-data-intensive-applications/designing-data-intensive-applications.mini.md +55 -0
- package/templates/skills/designing-data-intensive-applications/designing-data-intensive-applications.nano.md +34 -0
- package/templates/skills/domain-driven-design/SKILL.md +11 -0
- package/templates/skills/domain-driven-design/domain-driven-design.md +979 -0
- package/templates/skills/domain-driven-design/domain-driven-design.mini.md +48 -0
- package/templates/skills/domain-driven-design/domain-driven-design.nano.md +39 -0
- package/templates/skills/domain-driven-design-distilled/SKILL.md +11 -0
- package/templates/skills/domain-driven-design-distilled/domain-driven-design-distilled.md +317 -0
- package/templates/skills/domain-driven-design-distilled/domain-driven-design-distilled.mini.md +56 -0
- package/templates/skills/domain-driven-design-distilled/domain-driven-design-distilled.nano.md +41 -0
- package/templates/skills/implementation-plan/SKILL.md +42 -0
- package/templates/skills/implementing-domain-driven-design/SKILL.md +11 -0
- package/templates/skills/implementing-domain-driven-design/implementing-domain-driven-design.md +337 -0
- package/templates/skills/implementing-domain-driven-design/implementing-domain-driven-design.mini.md +57 -0
- package/templates/skills/implementing-domain-driven-design/implementing-domain-driven-design.nano.md +37 -0
- package/templates/skills/patterns-of-enterprise-application-architecture/SKILL.md +11 -0
- package/templates/skills/patterns-of-enterprise-application-architecture/patterns-of-enterprise-application-architecture.md +404 -0
- package/templates/skills/patterns-of-enterprise-application-architecture/patterns-of-enterprise-application-architecture.mini.md +54 -0
- package/templates/skills/patterns-of-enterprise-application-architecture/patterns-of-enterprise-application-architecture.nano.md +35 -0
- package/templates/skills/ponytail/SKILL.md +124 -0
- package/templates/skills/ponytail-audit/SKILL.md +45 -0
- package/templates/skills/ponytail-debt/SKILL.md +48 -0
- package/templates/skills/ponytail-gain/SKILL.md +17 -0
- package/templates/skills/ponytail-help/SKILL.md +42 -0
- package/templates/skills/ponytail-review/SKILL.md +61 -0
- package/templates/skills/refactoring/SKILL.md +11 -0
- package/templates/skills/refactoring/refactoring.md +433 -0
- package/templates/skills/refactoring/refactoring.mini.md +49 -0
- package/templates/skills/refactoring/refactoring.nano.md +37 -0
- package/templates/skills/refactoring-guru/SKILL.md +11 -0
- package/templates/skills/refactoring-guru/refactoring-guru.md +765 -0
- package/templates/skills/refactoring-guru/refactoring-guru.mini.md +64 -0
- package/templates/skills/refactoring-guru/refactoring-guru.nano.md +41 -0
- package/templates/skills/release-it/SKILL.md +11 -0
- package/templates/skills/release-it/release-it.md +382 -0
- package/templates/skills/release-it/release-it.mini.md +48 -0
- package/templates/skills/release-it/release-it.nano.md +38 -0
- package/templates/skills/security-audit/AI-AND-LLM.md +83 -0
- package/templates/skills/security-audit/ATTACK-CLASSES.md +130 -0
- package/templates/skills/security-audit/CLIENT-SIDE.md +83 -0
- package/templates/skills/security-audit/CLOUD-AND-DEPLOYMENT.md +86 -0
- package/templates/skills/security-audit/DATA-ISOLATION-AND-LIFECYCLE.md +84 -0
- package/templates/skills/security-audit/DESKTOP-MOBILE-AND-LOCAL-IPC.md +89 -0
- package/templates/skills/security-audit/HUNTING.md +251 -0
- package/templates/skills/security-audit/MEMORY-SAFETY-AND-BINARY.md +101 -0
- package/templates/skills/security-audit/PROTOCOLS-RPC-AND-MESSAGING.md +81 -0
- package/templates/skills/security-audit/RECONNAISSANCE.md +156 -0
- package/templates/skills/security-audit/RESOURCE-EXHAUSTION-AND-AVAILABILITY.md +78 -0
- package/templates/skills/security-audit/SKILL.md +192 -0
- package/templates/skills/security-audit/SUPPLY-CHAIN-AND-RELEASE.md +73 -0
- package/templates/skills/security-audit/VALIDATION-AND-REPORTING.md +186 -0
- package/templates/skills/security-audit/WEB-PROTOCOL-AND-AUTH.md +105 -0
- package/templates/skills/security-audit/report-schema.json +461 -0
- package/templates/skills/security-audit/validate-coverage-ledger.cjs +872 -0
- package/templates/skills/security-audit/validate-coverage-ledger.test.cjs +740 -0
- package/templates/skills/security-audit/validate-findings.cjs +773 -0
- package/templates/skills/security-audit/validate-findings.test.cjs +652 -0
- package/templates/skills/spec/SKILL.md +55 -0
- package/templates/skills/the-pragmatic-programmer/SKILL.md +11 -0
- package/templates/skills/the-pragmatic-programmer/the-pragmatic-programmer.md +359 -0
- package/templates/skills/the-pragmatic-programmer/the-pragmatic-programmer.mini.md +65 -0
- package/templates/skills/the-pragmatic-programmer/the-pragmatic-programmer.nano.md +44 -0
- package/templates/skills/working-effectively-with-legacy-code/SKILL.md +11 -0
- package/templates/skills/working-effectively-with-legacy-code/working-effectively-with-legacy-code.md +371 -0
- package/templates/skills/working-effectively-with-legacy-code/working-effectively-with-legacy-code.mini.md +50 -0
- package/templates/skills/working-effectively-with-legacy-code/working-effectively-with-legacy-code.nano.md +35 -0
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
# OBEY Designing Data-Intensive Applications by Martin Kleppmann
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
This repository follows **Designing Data-Intensive Applications** in the sense of Martin Kleppmann:
|
|
6
|
+
design systems around explicit trade-offs in reliability, scalability, maintainability, consistency, and data flow.
|
|
7
|
+
|
|
8
|
+
All code generation, edits, and reviews must optimize for:
|
|
9
|
+
- explicit data and consistency semantics
|
|
10
|
+
- idempotent and replay-safe processing
|
|
11
|
+
- clear ownership of truth
|
|
12
|
+
- durable boundaries between storage, messaging, and computation
|
|
13
|
+
- schema evolution awareness
|
|
14
|
+
- realistic distributed systems assumptions
|
|
15
|
+
|
|
16
|
+
This file is a binding engineering policy: `MUST` is binding, `SHOULD` is a strong default, and `MUST NOT` is forbidden.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Primary Directive
|
|
21
|
+
|
|
22
|
+
Data systems are defined by trade-offs.
|
|
23
|
+
When uncertain, make those trade-offs explicit instead of hiding them behind vague abstractions.
|
|
24
|
+
|
|
25
|
+
Always ask:
|
|
26
|
+
1. what is the source of truth?
|
|
27
|
+
2. what are the consistency expectations?
|
|
28
|
+
3. what happens on retries, duplicates, reordering, and partial failure?
|
|
29
|
+
4. how does the data evolve over time?
|
|
30
|
+
5. where is state durable, cached, derived, or ephemeral?
|
|
31
|
+
|
|
32
|
+
Do not design distributed behavior as if everything were local, ordered, and exactly once.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Reliability Rules
|
|
37
|
+
|
|
38
|
+
1. Treat crashes, partial writes, duplicate work, timeouts, and stale reads as normal design inputs.
|
|
39
|
+
2. Make write acknowledgment semantics explicit.
|
|
40
|
+
3. Avoid hidden assumptions about durable success.
|
|
41
|
+
4. Design for restart, replay, and partial failure recovery.
|
|
42
|
+
|
|
43
|
+
Anti-patterns (MUST NOT):
|
|
44
|
+
- side effects that cannot be retried safely
|
|
45
|
+
- no distinction between accepted, persisted, and applied
|
|
46
|
+
- assuming one successful response means all downstream effects succeeded
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Scalability and Maintainability Rules
|
|
51
|
+
|
|
52
|
+
1. Describe load with concrete parameters before changing architecture.
|
|
53
|
+
2. Describe performance with latency, throughput, percentiles, and tail behavior where they matter.
|
|
54
|
+
3. Do not claim scalability from node count alone; identify the bottleneck, access pattern, and contention point.
|
|
55
|
+
4. Keep operability, simplicity, and evolvability as first-class design goals.
|
|
56
|
+
5. Prefer designs that make production behavior inspectable and changeable over opaque clever mechanisms.
|
|
57
|
+
6. Avoid accidental complexity from unnecessary distribution, premature heterogeneity, or hidden coupling.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Data Model and Storage Rules
|
|
62
|
+
|
|
63
|
+
1. Choose storage shape based on access patterns, consistency needs, and update behavior.
|
|
64
|
+
2. Do not force one storage pattern onto all workloads.
|
|
65
|
+
3. Keep the ownership of each dataset explicit.
|
|
66
|
+
4. Distinguish primary data from indexes, caches, projections, and search copies.
|
|
67
|
+
|
|
68
|
+
### Source of Truth
|
|
69
|
+
For every important piece of data, identify:
|
|
70
|
+
- primary owner
|
|
71
|
+
- derived copies
|
|
72
|
+
- replication path
|
|
73
|
+
- update path
|
|
74
|
+
- consistency expectation
|
|
75
|
+
|
|
76
|
+
Anti-patterns (MUST NOT):
|
|
77
|
+
- many writable copies with no ownership
|
|
78
|
+
- cache quietly becoming the real source of truth
|
|
79
|
+
- denormalized copies with no repair strategy
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Query Model and Data Shape Rules
|
|
84
|
+
|
|
85
|
+
1. Choose relational, document, graph, key-value, or analytical models according to relationships, query needs, update locality, and evolution pressure.
|
|
86
|
+
2. Do not use a document model when many-to-one or many-to-many relationships require awkward duplication or application-side joins.
|
|
87
|
+
3. Do not force a relational shape when data is naturally self-contained and usually accessed together.
|
|
88
|
+
4. Use declarative query languages where they make intent clearer and leave optimization to the engine.
|
|
89
|
+
5. Use graph models when relationships are first-class and traversal is central.
|
|
90
|
+
6. Treat Cypher, SPARQL, Datalog, SQL, MapReduce, and application code as different expression choices with different maintainability and optimization tradeoffs.
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Storage Engine and Indexing Rules
|
|
95
|
+
|
|
96
|
+
1. Match indexing strategy to write pattern, read pattern, range scans, update cost, and recovery needs.
|
|
97
|
+
2. Use log-structured storage, SSTables, and LSM-tree style approaches when write throughput and sequential writes are the dominant fit.
|
|
98
|
+
3. Use B-tree style indexes when ordered access, point lookups, and mature transactional behavior fit the workload.
|
|
99
|
+
4. Treat secondary indexes as separate data structures with write amplification, partitioning, and consistency costs.
|
|
100
|
+
5. Distinguish OLTP access from analytical workloads; do not force one layout to serve both well.
|
|
101
|
+
6. Use column-oriented storage, compression, sort order, materialized views, or cubes only when analytical access patterns justify them.
|
|
102
|
+
7. Keep in-memory assumptions explicit; memory residency is a performance strategy, not a durability model.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Consistency Rules
|
|
107
|
+
|
|
108
|
+
1. Be explicit about read-after-write expectations.
|
|
109
|
+
2. Be explicit about staleness tolerance.
|
|
110
|
+
3. Be explicit about conflict handling.
|
|
111
|
+
4. Use strong consistency only where the product truly requires it.
|
|
112
|
+
5. Use eventual consistency intentionally, not accidentally.
|
|
113
|
+
|
|
114
|
+
### Write Semantics
|
|
115
|
+
Document or encode:
|
|
116
|
+
- when a write is durable
|
|
117
|
+
- when it is visible
|
|
118
|
+
- whether readers may see stale data
|
|
119
|
+
- how conflicts are detected or resolved
|
|
120
|
+
|
|
121
|
+
Anti-patterns (MUST NOT):
|
|
122
|
+
- “eventual consistency” used as a slogan instead of a contract
|
|
123
|
+
- stale-read bugs blamed on infrastructure with no product decision behind them
|
|
124
|
+
- no conflict model for concurrent updates
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Idempotency and Replay Rules
|
|
129
|
+
|
|
130
|
+
1. Handlers of commands, jobs, and events must tolerate retries where delivery or acknowledgment is uncertain.
|
|
131
|
+
2. Prefer deduplication keys or naturally idempotent state transitions.
|
|
132
|
+
3. Design processing to survive replay after crashes.
|
|
133
|
+
4. Never assume exactly-once delivery unless the system boundary truly provides it and the design proves it.
|
|
134
|
+
|
|
135
|
+
Anti-patterns (MUST NOT):
|
|
136
|
+
- duplicate billing/order/send on retry
|
|
137
|
+
- handlers with non-repeatable side effects and no guard
|
|
138
|
+
- event processors depending on “it probably won't happen twice”
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## Ordering Rules
|
|
143
|
+
|
|
144
|
+
1. Do not assume global order in distributed systems.
|
|
145
|
+
2. Require only the minimum ordering guarantees the business logic actually needs.
|
|
146
|
+
3. When ordering matters, define its scope:
|
|
147
|
+
- per key
|
|
148
|
+
- per stream
|
|
149
|
+
- per partition
|
|
150
|
+
- per record or entity whose history is being updated
|
|
151
|
+
4. Keep ordering-sensitive logic close to the key or stream that defines the order.
|
|
152
|
+
|
|
153
|
+
Anti-patterns (MUST NOT):
|
|
154
|
+
- implicit reliance on total ordering
|
|
155
|
+
- out-of-order events corrupting state because no versioning or sequence policy exists
|
|
156
|
+
- parallel consumers updating the same key with no ordering plan
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## Event, Log, and Stream Rules
|
|
161
|
+
|
|
162
|
+
1. Distinguish commands, events, and materialized views clearly.
|
|
163
|
+
2. Events describe facts that happened; commands request action.
|
|
164
|
+
3. Logs and streams are durable histories, not merely transport pipes.
|
|
165
|
+
4. Consumers must tolerate lag, duplicates, restart, and replay.
|
|
166
|
+
5. Derived projections must be rebuildable where feasible.
|
|
167
|
+
|
|
168
|
+
### Event Design
|
|
169
|
+
- use stable identifiers
|
|
170
|
+
- include enough metadata for correlation and replay
|
|
171
|
+
- version payloads carefully
|
|
172
|
+
- keep semantics explicit
|
|
173
|
+
|
|
174
|
+
Anti-patterns (MUST NOT):
|
|
175
|
+
- event payloads tied to one serializer or internal object layout
|
|
176
|
+
- projections that cannot be rebuilt
|
|
177
|
+
- assuming consumers keep up forever
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Schema Evolution Rules
|
|
182
|
+
|
|
183
|
+
1. Schemas will change; plan for it.
|
|
184
|
+
2. Version contracts intentionally.
|
|
185
|
+
3. Prefer backward- and forward-compatible changes where possible.
|
|
186
|
+
4. Keep old readers and writers in mind during rollout.
|
|
187
|
+
5. Distinguish internal refactors from contract changes.
|
|
188
|
+
|
|
189
|
+
Anti-patterns (MUST NOT):
|
|
190
|
+
- breaking payloads or DB semantics without migration strategy
|
|
191
|
+
- reusing fields with new meaning
|
|
192
|
+
- silently changing enum or status semantics across services
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Encoding and Data Flow Rules
|
|
197
|
+
|
|
198
|
+
1. Choose encoding formats by compatibility needs, schema guarantees, readability, size, and language independence.
|
|
199
|
+
2. Do not rely on language-specific serialization for long-lived or cross-service data.
|
|
200
|
+
3. Treat JSON, XML, binary encodings, Thrift, Protocol Buffers, and Avro as contract choices with different schema-evolution tradeoffs.
|
|
201
|
+
4. Define reader and writer compatibility during rolling upgrades.
|
|
202
|
+
5. Keep database writes, service calls, and asynchronous messages explicit about who reads old and new formats during migration.
|
|
203
|
+
6. Avoid RPC designs that hide network failure, version skew, latency, or partial failure behind local-call syntax.
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Partitioning and Locality Rules
|
|
208
|
+
|
|
209
|
+
1. Keep data and work colocated by the key that most often drives consistency or aggregation.
|
|
210
|
+
2. Partition by a workload-relevant key, not by convenience alone.
|
|
211
|
+
3. Be explicit about hot-key risk and skew.
|
|
212
|
+
4. Design cross-partition operations carefully.
|
|
213
|
+
|
|
214
|
+
Anti-patterns (MUST NOT):
|
|
215
|
+
- partitioning that makes every common query cross-node
|
|
216
|
+
- no plan for skew or hotspots
|
|
217
|
+
- requiring cross-partition transactions for ordinary operations
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## Replication Rules
|
|
222
|
+
|
|
223
|
+
1. Choose leader-follower, multi-leader, or leaderless replication according to write topology, failure tolerance, latency, and conflict handling.
|
|
224
|
+
2. Be explicit about synchronous and asynchronous replication tradeoffs.
|
|
225
|
+
3. Define behavior during node outages, follower catch-up, failover, and reconfiguration.
|
|
226
|
+
4. Preserve read-your-writes, monotonic reads, and consistent prefix reads only when the product or workflow requires them and the design provides them.
|
|
227
|
+
5. Do not rely on quorum formulas without checking stale reads, sloppy quorums, hinted handoff, and concurrent writes.
|
|
228
|
+
6. Make conflict detection and resolution explicit for concurrent writes.
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Transaction Rules
|
|
233
|
+
|
|
234
|
+
1. Use local transactions where they solve a real consistency problem cleanly.
|
|
235
|
+
2. Avoid distributed transactions as a default coordination strategy.
|
|
236
|
+
3. When cross-boundary coordination is required, define the commit, recovery, reconciliation, and failure semantics explicitly.
|
|
237
|
+
4. Make atomicity scope explicit.
|
|
238
|
+
|
|
239
|
+
### Isolation and Invariants
|
|
240
|
+
- Know whether read committed, snapshot isolation, serial execution, two-phase locking, or serializable snapshot isolation is required for the invariant.
|
|
241
|
+
- Protect against lost updates, write skew, and phantoms where application correctness depends on them.
|
|
242
|
+
- Do not accept weaker isolation for correctness-critical invariants without a deliberate design that preserves the invariant another way.
|
|
243
|
+
|
|
244
|
+
Anti-patterns (MUST NOT):
|
|
245
|
+
- multi-system two-phase coordination by default
|
|
246
|
+
- side effects emitted outside transactional boundaries with no repair path
|
|
247
|
+
- pretending asynchronous side effects are atomic because they “usually happen”
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## Derived Data Rules
|
|
252
|
+
|
|
253
|
+
1. Treat indexes, search copies, caches, and read models as derived data unless they are explicitly authoritative.
|
|
254
|
+
2. Derived data must be repairable, rebuildable, or re-syncable.
|
|
255
|
+
3. Know how lag affects user-visible behavior.
|
|
256
|
+
4. Keep derivation pipelines observable.
|
|
257
|
+
|
|
258
|
+
Anti-patterns (MUST NOT):
|
|
259
|
+
- no way to rebuild projections
|
|
260
|
+
- no lag visibility
|
|
261
|
+
- mixing primary writes directly into derived stores with no ownership model
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## Distributed Fault, Clock, and Consensus Rules
|
|
266
|
+
|
|
267
|
+
1. Treat network delay, packet loss, partitions, duplicated messages, and arbitrary pauses as normal distributed-system risks.
|
|
268
|
+
2. Do not infer remote failure or success from timeout alone.
|
|
269
|
+
3. Use monotonic clocks for measuring elapsed time; do not use wall clocks for ordering unless clock assumptions are explicit and safe.
|
|
270
|
+
4. Do not rely on synchronized clocks for correctness unless uncertainty bounds and failure behavior are part of the design.
|
|
271
|
+
5. Treat majority decisions, leases, locks, and leadership as assumptions that need a fault model.
|
|
272
|
+
6. Use linearizability only where a single up-to-date value is required and the availability/latency cost is acceptable.
|
|
273
|
+
7. Use total order broadcast, atomic commit, or consensus only when the coordination problem truly requires it.
|
|
274
|
+
8. Make membership and coordination-service dependencies explicit; they are part of the system design, not invisible plumbing.
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## Batch and Stream Processing Rules
|
|
279
|
+
|
|
280
|
+
1. Design batch jobs so inputs, outputs, and intermediate state can be recomputed or recovered.
|
|
281
|
+
2. Keep external side effects out of replayable jobs unless idempotency is explicit.
|
|
282
|
+
3. Use MapReduce-style, dataflow, or high-level batch APIs according to join strategy, intermediate materialization, and operational needs.
|
|
283
|
+
4. Distinguish event time, processing time, and ingestion time in stream processing.
|
|
284
|
+
5. Define windowing, late data, joins, state storage, checkpoints, and fault tolerance for streams that affect correctness.
|
|
285
|
+
6. Treat change data capture, event sourcing, and log-based synchronization as ways to derive and propagate data, not as magic consistency.
|
|
286
|
+
7. Define at-most-once, at-least-once, or exactly-once processing guarantees for each source-to-sink path.
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## API and Service Boundary Rules
|
|
291
|
+
|
|
292
|
+
1. Service boundaries must reflect data ownership and update semantics.
|
|
293
|
+
2. Do not split one tightly consistent business concept across many services casually.
|
|
294
|
+
3. Avoid chatty cross-service joins on hot paths.
|
|
295
|
+
4. Contracts must encode identifiers, versions, and failure semantics clearly.
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
## Review Rules
|
|
300
|
+
|
|
301
|
+
When reviewing code, actively look for:
|
|
302
|
+
- hidden assumptions about ordering
|
|
303
|
+
- hidden assumptions about exactly-once delivery
|
|
304
|
+
- lack of idempotency
|
|
305
|
+
- no source-of-truth ownership
|
|
306
|
+
- broken schema evolution practices
|
|
307
|
+
- no versioning or sequencing where concurrency matters
|
|
308
|
+
- side effects that cannot be repaired
|
|
309
|
+
- write paths that update several stores with unclear guarantees
|
|
310
|
+
- projections that cannot be rebuilt
|
|
311
|
+
- partitioning blind to locality or hotspots
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
## Forbidden Patterns
|
|
316
|
+
|
|
317
|
+
### Exactly-Once Wishful Thinking
|
|
318
|
+
- assuming a broker or queue magically prevents all duplicates
|
|
319
|
+
- writing non-idempotent handlers without safeguards
|
|
320
|
+
|
|
321
|
+
### Hidden Consistency Contract
|
|
322
|
+
- readers and writers disagreeing on freshness requirements
|
|
323
|
+
- stale or conflicting behavior treated as incidental instead of product design
|
|
324
|
+
|
|
325
|
+
### Uncoordinated Multi-Writes
|
|
326
|
+
- writing to several authorities in one operation with no atomicity or repair strategy
|
|
327
|
+
- side effects sent before durable state with no recovery path
|
|
328
|
+
|
|
329
|
+
### Schema Drift by Accident
|
|
330
|
+
- changing payload meaning without versioning
|
|
331
|
+
- reusing fields for new concepts
|
|
332
|
+
- no rollout compatibility strategy
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## Code Generation Rules
|
|
337
|
+
|
|
338
|
+
When generating code, default to:
|
|
339
|
+
1. explicit identifiers and ownership
|
|
340
|
+
2. explicit idempotency where retries or duplicates can happen
|
|
341
|
+
3. explicit versioning or conflict strategy where ordering matters
|
|
342
|
+
4. explicit distinction between authoritative and derived data
|
|
343
|
+
5. repairable or rebuildable downstream state
|
|
344
|
+
6. compatibility-aware schema changes
|
|
345
|
+
7. observability for lag, retries, and failures
|
|
346
|
+
|
|
347
|
+
Avoid by default:
|
|
348
|
+
- assuming strict global order
|
|
349
|
+
- exactly-once promises with no proof
|
|
350
|
+
- writing the same fact into several places as if they were one transaction
|
|
351
|
+
- treating streams and queues as fire-and-forget
|
|
352
|
+
|
|
353
|
+
---
|
|
354
|
+
|
|
355
|
+
## Testing Rules
|
|
356
|
+
|
|
357
|
+
1. Test duplicate delivery handling.
|
|
358
|
+
2. Test out-of-order event or message handling where applicable.
|
|
359
|
+
3. Test replay safety.
|
|
360
|
+
4. Test conflict resolution or optimistic concurrency behavior.
|
|
361
|
+
5. Test schema compatibility when contracts evolve.
|
|
362
|
+
6. Test rebuild or repair of derived views where that capability exists.
|
|
363
|
+
|
|
364
|
+
---
|
|
365
|
+
|
|
366
|
+
## Review Checklist
|
|
367
|
+
|
|
368
|
+
Before finalizing any change, verify:
|
|
369
|
+
- Is the source of truth explicit?
|
|
370
|
+
- Are consistency expectations explicit?
|
|
371
|
+
- Is the code safe under retry or duplicate delivery?
|
|
372
|
+
- Is ordering dependency explicit and scoped?
|
|
373
|
+
- Can derived data be rebuilt or repaired?
|
|
374
|
+
- Is schema evolution considered?
|
|
375
|
+
- Is atomicity scope honest?
|
|
376
|
+
- Did we avoid exactly-once wishful thinking?
|
|
377
|
+
- Are service boundaries aligned with data ownership?
|
|
378
|
+
- Are lag and failure observable?
|
|
379
|
+
|
|
380
|
+
If any answer is no, revise before shipping.
|
|
381
|
+
|
|
382
|
+
---
|
|
383
|
+
|
|
384
|
+
## Final Instruction
|
|
385
|
+
|
|
386
|
+
When uncertain, prefer the design that:
|
|
387
|
+
1. makes data ownership explicit
|
|
388
|
+
2. makes consistency semantics explicit
|
|
389
|
+
3. survives retries, duplicates, and replay
|
|
390
|
+
4. supports evolution without silent breakage
|
|
391
|
+
5. treats distributed systems trade-offs honestly
|
|
392
|
+
|
|
393
|
+
Do not hide distributed complexity behind local-looking code.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# OBEY Designing Data-Intensive Applications by Martin Kleppmann
|
|
2
|
+
|
|
3
|
+
## When to use
|
|
4
|
+
|
|
5
|
+
Use for systems where correctness depends on data ownership, consistency, durability, replication, partitioning, schema evolution, event flow, replay, or derived-data maintenance.
|
|
6
|
+
|
|
7
|
+
## Primary bias to correct
|
|
8
|
+
|
|
9
|
+
Do not design distributed data behavior as if every write, read, queue, cache, replica, clock, and downstream side effect were local, ordered, fresh, and exactly once.
|
|
10
|
+
|
|
11
|
+
## Decision rules
|
|
12
|
+
|
|
13
|
+
- Make core trade-offs explicit: source of truth, consistency expectation, retry behavior, duplicate and reordered work, partial failure, data evolution, and whether state is durable, cached, derived, or ephemeral.
|
|
14
|
+
- Treat crashes, partial writes, duplicate work, timeouts, stale reads, and unknown downstream success as normal inputs. Distinguish accepted, persisted, applied, and durable success.
|
|
15
|
+
- Describe load and performance with concrete request rates, data volume, access patterns, latency, throughput, percentiles, bottlenecks, contention, and tail behavior before changing architecture.
|
|
16
|
+
- Choose data models, query models, and ownership boundaries from relationships, access patterns, consistency needs, update locality, evolution pressure, and whether data is primary or derived.
|
|
17
|
+
- Match storage engines, indexes, and analytical layouts to write patterns, read patterns, range scans, recovery needs, write amplification, OLTP-vs-analytics separation, and memory-vs-durability assumptions.
|
|
18
|
+
- Treat indexes, caches, search copies, read models, materialized views, and denormalized copies as derived data with explicit propagation, lag, observability, repair, and rebuild paths.
|
|
19
|
+
- Define write semantics: when a write is durable, when it is visible, whether stale reads are allowed, which conflicts can happen, and how conflicts are detected or resolved.
|
|
20
|
+
- Make commands, jobs, events, batch jobs, and stream processors safe under retry and replay with deduplication keys, naturally idempotent transitions, or an explicit transactional recovery contract.
|
|
21
|
+
- Preserve only the ordering the business logic actually needs. Scope it per key, stream, partition, record, entity history, or stronger contract, and keep ordering-sensitive logic close to that scope.
|
|
22
|
+
- Separate commands, events, durable logs, streams, and materialized views. Events describe facts; consumers must tolerate lag, duplicates, restart, replay, stable identifiers, correlation metadata, and versioned payloads.
|
|
23
|
+
- Design schemas, encodings, APIs, messages, events, and database changes as evolving contracts across old readers, old writers, old data, in-flight messages, rolling upgrades, and cross-service formats.
|
|
24
|
+
- Choose replication topology from write topology, latency, failure tolerance, lag, failover, reconfiguration, conflict handling, read-your-writes, monotonic-read, consistent-prefix, quorum, and convergence needs.
|
|
25
|
+
- Partition by workload-relevant locality and consistency keys, with hot-key, skew, routing, secondary-index, rebalancing, and cross-partition-operation costs explicit.
|
|
26
|
+
- Match transactions and isolation to invariants. Make atomicity scope, commit behavior, recovery, reconciliation, lost-update, write-skew, phantom, and side-effect repair semantics explicit.
|
|
27
|
+
- Treat network delay, packet loss, partitions, duplicate messages, pauses, stale leaders, timeouts, wall-clock uncertainty, leases, locks, majorities, and leadership as assumptions needing a fault model.
|
|
28
|
+
- Use linearizability, total order broadcast, atomic commit, or consensus only where the coordination problem truly requires agreement and the availability or latency cost is acceptable.
|
|
29
|
+
- Make batch and stream processing recomputable and recoverable: define inputs, outputs, intermediate state, checkpoints, external side effects, event time, processing time, ingestion time, windows, late data, joins, and source-to-sink guarantees.
|
|
30
|
+
- Align service boundaries with data ownership and update semantics. Do not casually split one tightly consistent business concept across services or put chatty cross-service joins on hot paths.
|
|
31
|
+
|
|
32
|
+
## Trigger rules
|
|
33
|
+
|
|
34
|
+
- When changing a write path, state the source of truth, consistency boundary, durability point, visibility point, downstream effects, rollback or repair path, and behavior after timeout or unknown success.
|
|
35
|
+
- When adding or changing a cache, index, projection, search copy, read model, warehouse, or denormalized field, define ownership, propagation, staleness, write cost, lag visibility, rebuild, and repair.
|
|
36
|
+
- When changing a schema, API, message, event, enum, status, or payload meaning, plan compatibility for old readers, old writers, old stored data, old messages, new writers, rollout, and migration.
|
|
37
|
+
- When adding retries, jobs, consumers, queues, CDC, event sourcing, stream processors, or replayable batch work, prove duplicate, replay, ordering, retention, side-effect, and recovery safety.
|
|
38
|
+
- When routing reads to replicas or using asynchronous replication, identify read-your-writes, monotonic-read, consistent-prefix, staleness, catch-up, failover, and conflict expectations before allowing the read.
|
|
39
|
+
- When partitioning data or work, test the ordinary query path for locality, skew, hot keys, routing metadata, rebalancing cost, secondary-index behavior, and cross-partition coordination.
|
|
40
|
+
- When choosing transaction isolation or weakening consistency, map each anomaly to the invariant it can break and add serializable isolation, locks, compare-and-set, versioning, reconciliation, or another compensating design where needed.
|
|
41
|
+
- When using timestamps, leases, locks, leadership, majority decisions, coordination services, or consensus-like mechanisms, define the clock assumption, quorum/session semantics, stale-authority behavior, and fencing.
|
|
42
|
+
- When reviewing or testing data-intensive code, look specifically for hidden source-of-truth ownership, missing idempotency, accidental exactly-once assumptions, unscoped ordering, schema drift, unrebuildable projections, unclear multi-writes, and unobservable lag or failure.
|
|
43
|
+
|
|
44
|
+
## Final checklist
|
|
45
|
+
|
|
46
|
+
- Source of truth and derived representations are explicit.
|
|
47
|
+
- Consistency expectations, durability points, visibility points, staleness, and conflict rules are concrete.
|
|
48
|
+
- Retries, duplicate delivery, replay, reordering, timeouts, crashes, and unknown success are handled.
|
|
49
|
+
- Schemas, encodings, APIs, messages, events, enums, and statuses evolve safely across mixed versions.
|
|
50
|
+
- Storage, indexing, replication, partitioning, routing, and analytical layouts match the actual workload.
|
|
51
|
+
- Transaction isolation and coordination choices protect the named invariants.
|
|
52
|
+
- Events, logs, streams, batch jobs, and projections are replayable or have explicit repair paths.
|
|
53
|
+
- Service boundaries follow data ownership and update semantics.
|
|
54
|
+
- Lag, retries, failures, rebuilds, and repair paths are observable.
|
|
55
|
+
- The design avoids exactly-once wishful thinking and hidden distributed-system contracts.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# OBEY Designing Data-Intensive Applications by Martin Kleppmann
|
|
2
|
+
|
|
3
|
+
## When to use
|
|
4
|
+
|
|
5
|
+
Use when data correctness, durability, or distributed write semantics matter more than local code style.
|
|
6
|
+
|
|
7
|
+
## Primary bias to correct
|
|
8
|
+
|
|
9
|
+
Hidden data contracts are still contracts.
|
|
10
|
+
|
|
11
|
+
## Decision rules
|
|
12
|
+
|
|
13
|
+
- State the source of truth, consistency expectation, durability point, visibility point, retry semantics, and evolution path for every important data change.
|
|
14
|
+
- Choose data models, storage, indexes, replication, partitioning, transactions, queues, streams, and APIs from workload, access pattern, consistency, reliability, maintainability, and operational cost.
|
|
15
|
+
- Treat caches, indexes, projections, search copies, denormalized data, and materialized views as derived data with staleness, lag visibility, repair, and rebuild paths.
|
|
16
|
+
- Make retried, replayed, queued, batch, stream, and event-driven work idempotent or transactional; reject casual exactly-once claims.
|
|
17
|
+
- Treat schemas, encodings, service APIs, messages, logs, and events as versioned contracts that must survive old code, old data, rolling upgrades, and in-flight messages.
|
|
18
|
+
- Assume distributed uncertainty: crashes, partial writes, timeouts, duplicate messages, reordered events, stale replicas, lag, clock error, pauses, stale leaders, and unknown success.
|
|
19
|
+
- Match replication, partitioning, isolation, transactions, and coordination to the invariant; do not rely on follower freshness, quorum formulas, weak isolation, wall-clock order, or ad hoc leadership without proof.
|
|
20
|
+
|
|
21
|
+
## Trigger rules
|
|
22
|
+
|
|
23
|
+
- When adding retries, jobs, consumers, queues, CDC, event sourcing, or stream processing, prove duplicate, replay, ordering, side-effect, and recovery safety.
|
|
24
|
+
- When changing schemas, APIs, messages, events, enum values, or status meanings, plan backward and forward compatibility plus migration, bootstrap, or rebuild paths.
|
|
25
|
+
- When reading from replicas or partitioning data, define staleness, routing, hot-key, ordering, rebalancing, and cross-partition behavior.
|
|
26
|
+
- When using locks, leases, timestamps, leadership, majorities, or coordination services, define the fault model, quorum/session semantics, stale-authority behavior, and fencing.
|
|
27
|
+
|
|
28
|
+
## Final checklist
|
|
29
|
+
|
|
30
|
+
- Clear owner and source of truth?
|
|
31
|
+
- Explicit consistency, durability, visibility, and staleness semantics?
|
|
32
|
+
- Safe under retry, replay, duplicate delivery, reordering, and unknown success?
|
|
33
|
+
- Compatible across old data, old code, new code, and messages in flight?
|
|
34
|
+
- Isolation, replication, partitioning, transactions, and coordination checked against actual invariants?
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: domain-driven-design
|
|
3
|
+
description: Apply Eric Evans-inspired DDD rules when modeling a complex domain, defining bounded contexts, protecting ubiquitous language, or designing aggregates.
|
|
4
|
+
license: MIT
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Domain-Driven Design Skill
|
|
8
|
+
|
|
9
|
+
Use this skill when a task involves strategic domain modeling, ubiquitous language, bounded contexts, context mapping, aggregates, repositories, domain services, or model-driven design.
|
|
10
|
+
|
|
11
|
+
Before making design or code decisions, read and apply [domain-driven-design.mini.md](domain-driven-design.mini.md). Use [domain-driven-design.md](domain-driven-design.md) only as a deeper reference when the mini rules are not enough for the current domain-modeling tradeoff.
|