aw-spec-cli 0.1.10 → 0.1.11

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 (58) hide show
  1. package/assets/.appweaver/ORCH-DIALECT.md +17 -5
  2. package/assets/.appweaver/orchestrator/README.md +1 -1
  3. package/assets/.appweaver/orchestrator/adapters/claude_agent_sdk.py +2 -2
  4. package/assets/.appweaver/orchestrator/adapters/google_antigravity.py +28 -6
  5. package/assets/.appweaver/orchestrator/modules/delta-spec.orch.yaml +13 -1
  6. package/assets/.appweaver/orchestrator/orchestrator.py +126 -39
  7. package/assets/.appweaver/orchestrator/workflows/aw-spec-adopt.orch.yaml +5 -0
  8. package/assets/.appweaver/orchestrator/workflows/aw-spec-characterize.orch.yaml +1 -0
  9. package/assets/.appweaver/orchestrator/workflows/aw-spec-onboard.orch.yaml +1 -0
  10. package/assets/.appweaver/orchestrator/workflows/aw-spec-specify.orch.yaml +888 -141
  11. package/assets/.appweaver/scripts/bash/aw-spec-actions.sh +826 -16
  12. package/assets/.appweaver/scripts/powershell/aw-spec-actions.ps1 +780 -12
  13. package/assets/.appweaver/stack-profiles/java-spring.json +3 -3
  14. package/assets/.appweaver/templates/spec-template.md +73 -62
  15. package/assets/.appweaver/templates/story-template.md +107 -0
  16. package/assets/guardrails/technology/java-spring/ai-rules.md +505 -0
  17. package/assets/guardrails/technology/java-spring/api-versioning.md +782 -0
  18. package/assets/guardrails/technology/java-spring/authorization.md +618 -0
  19. package/assets/guardrails/technology/java-spring/clean-architecture.md +960 -0
  20. package/assets/guardrails/technology/java-spring/coding-standards.md +821 -0
  21. package/assets/guardrails/technology/java-spring/dependency-policy.md +91 -0
  22. package/assets/guardrails/technology/java-spring/domain-driven-design.md +467 -0
  23. package/assets/guardrails/technology/java-spring/domain_abstraction.md +424 -0
  24. package/assets/guardrails/technology/java-spring/folder-structure.md +1537 -0
  25. package/assets/guardrails/technology/java-spring/global_exception_handler.md +247 -0
  26. package/assets/guardrails/technology/java-spring/logging.md +215 -0
  27. package/assets/guardrails/technology/java-spring/modular-monolith.md +77 -0
  28. package/assets/guardrails/technology/java-spring/persistence.md +316 -0
  29. package/assets/guardrails/technology/java-spring/problem_details.md +98 -0
  30. package/assets/guardrails/technology/java-spring/result_mapping.md +48 -0
  31. package/assets/guardrails/technology/java-spring/technology-constitution.md +168 -0
  32. package/assets/guardrails/technology/java-spring/testing.md +601 -0
  33. package/assets/guardrails/technology/java-spring/zero-trust.md +210 -0
  34. package/dist/index.js +0 -0
  35. package/dist/utils/config.d.ts +22 -0
  36. package/dist/utils/config.d.ts.map +1 -0
  37. package/dist/utils/config.js +76 -0
  38. package/dist/utils/config.js.map +1 -0
  39. package/dist/utils/copy-assets.d.ts.map +1 -1
  40. package/dist/utils/copy-assets.js +4 -11
  41. package/dist/utils/copy-assets.js.map +1 -1
  42. package/dist/utils/paths.d.ts.map +1 -1
  43. package/dist/utils/paths.js +11 -7
  44. package/dist/utils/paths.js.map +1 -1
  45. package/package.json +2 -1
  46. package/assets/guardrails/technology/java-spring/README.md +0 -62
  47. package/dist/commands/update.d.ts +0 -3
  48. package/dist/commands/update.d.ts.map +0 -1
  49. package/dist/commands/update.js +0 -142
  50. package/dist/commands/update.js.map +0 -1
  51. package/dist/utils/manifest.d.ts +0 -31
  52. package/dist/utils/manifest.d.ts.map +0 -1
  53. package/dist/utils/manifest.js +0 -91
  54. package/dist/utils/manifest.js.map +0 -1
  55. package/dist/utils/update-engine.d.ts +0 -52
  56. package/dist/utils/update-engine.d.ts.map +0 -1
  57. package/dist/utils/update-engine.js +0 -203
  58. package/dist/utils/update-engine.js.map +0 -1
@@ -0,0 +1,91 @@
1
+ # Java Dependency Policy
2
+
3
+ > Pure technology (domain-agnostic). See also: `coding-standards.md`, `ai-rules.md`.
4
+
5
+ ## Dependency Governance
6
+
7
+ - Dependencies MUST be declared in the approved Java build files, normally `pom.xml` for Maven projects.
8
+ - Dependency versions MUST be controlled consistently through the project parent, dependency management, Maven properties, or an approved BOM.
9
+ - New production dependencies MUST have a clear architectural purpose and an identified owning layer.
10
+ - Generated code MUST NOT introduce new top-level dependencies unless the specification, design, or explicit developer instruction authorizes them.
11
+ - Dependencies MUST NOT bypass hexagonal boundaries or make the domain depend on infrastructure frameworks.
12
+ - Unused, duplicate, abandoned, or overlapping dependencies MUST be removed.
13
+
14
+ ## Approved Technology Defaults
15
+
16
+ - Runtime: Java 21 or the Java version declared by the active AppWeaver Java foundation.
17
+ - Application framework: Spring Boot.
18
+ - Web/API: Spring Web or Spring MVC, with explicit REST contracts.
19
+ - Validation: Jakarta Bean Validation for request shape validation.
20
+ - Persistence: PostgreSQL for production unless an approved architecture decision states otherwise.
21
+ - ORM/persistence adapters: Spring Data JPA and Hibernate inside infrastructure only.
22
+ - Migrations: Flyway unless an approved project decision selects another migration tool.
23
+ - Testing: JUnit 5, Mockito, Spring Boot Test, and Testcontainers where applicable.
24
+ - API documentation: OpenAPI-compatible tooling where API contracts are exposed.
25
+ - Observability: SLF4J-compatible structured logging, Micrometer metrics, health checks, and OpenTelemetry-compatible tracing where required.
26
+
27
+ ## Layer Ownership
28
+
29
+ - Domain MAY depend only on Java language/runtime APIs and approved domain-safe libraries.
30
+ - Domain MUST NOT depend on Spring, JPA, Hibernate, database drivers, HTTP clients, messaging clients, logging implementations, or external SDKs.
31
+ - Application MAY depend on domain types and application-owned ports/contracts.
32
+ - Application MUST NOT depend directly on persistence implementations or external service SDKs.
33
+ - Inbound adapters MAY depend on Spring Web, validation, security, and API documentation libraries.
34
+ - Outbound adapters MAY depend on persistence, messaging, HTTP client, cloud, or vendor SDK libraries needed to implement output ports.
35
+ - Infrastructure configuration MAY wire frameworks, transactions, repositories, security, observability, and external clients.
36
+
37
+ ## Preferred Practices
38
+
39
+ - Prefer standard Spring Boot starters already present in the foundation over introducing alternative frameworks.
40
+ - Prefer explicit mapping code over reflection-based object mapping.
41
+ - Prefer small, focused dependencies over broad utility libraries.
42
+ - Prefer Java standard library features when they satisfy the requirement cleanly.
43
+ - Prefer mature, maintained libraries with active security updates.
44
+ - Prefer dependencies that integrate cleanly with Maven, Spring Boot, testing, observability, and CI.
45
+
46
+ ## Banned or Restricted Dependencies
47
+
48
+ - Reflection-based mapping frameworks are restricted and require explicit approval.
49
+ - Alternate web frameworks, persistence frameworks, mediator frameworks, or dependency injection containers are restricted unless an architecture decision approves them.
50
+ - Libraries that require domain objects to inherit framework base classes or carry framework annotations are forbidden for domain use.
51
+ - Dependencies that exfiltrate telemetry, analytics, or customer data by default are forbidden.
52
+ - Dependencies with incompatible licenses are forbidden.
53
+ - Libraries with known unresolved critical vulnerabilities MUST NOT be introduced.
54
+ - Snapshot, local, or unpublished dependencies MUST NOT be used in production builds without explicit approval.
55
+
56
+ ## Supply Chain Rules
57
+
58
+ - New dependencies MUST be reviewed for license, maintenance status, vulnerability history, transitive dependency risk, and operational impact.
59
+ - Dependency updates SHOULD be small, reviewable, and tested.
60
+ - Transitive dependencies MUST be monitored for vulnerabilities.
61
+ - Build plugins MUST be governed with the same care as runtime dependencies.
62
+ - Dependency repositories MUST be trusted and approved.
63
+ - Credentials for artifact repositories MUST NOT be committed to source control.
64
+
65
+ ## Versioning Rules
66
+
67
+ - Dependency versions MUST be reproducible in CI.
68
+ - Version ranges are forbidden for production dependencies.
69
+ - Major version upgrades require compatibility review and regression testing.
70
+ - Security patches SHOULD be applied promptly after impact assessment.
71
+ - The project MUST avoid mixing incompatible Spring Boot, Spring Framework, Hibernate, Jakarta, and Java versions.
72
+
73
+ ## AI / AW-Spec Rules
74
+
75
+ - AI-generated changes MUST reuse existing dependencies and framework patterns where possible.
76
+ - AI MUST NOT add Maven dependencies, plugins, repositories, or BOMs without explicit authority from the specification, design, or developer instruction.
77
+ - AI MUST NOT introduce a dependency to avoid writing straightforward application code.
78
+ - AI MUST keep dependency usage within the owning layer.
79
+ - AI MUST update tests and documentation when an approved dependency changes behavior or public contracts.
80
+
81
+ ## Quality Gates
82
+
83
+ - Maven dependency resolution MUST succeed in CI.
84
+ - Tests MUST pass after dependency changes.
85
+ - Vulnerability and license checks SHOULD pass where configured.
86
+ - Static checks SHOULD verify that forbidden dependencies do not appear in domain modules or packages.
87
+ - The dependency tree SHOULD be reviewed when adding production dependencies.
88
+
89
+ ## Related
90
+
91
+ See also: `coding-standards.md` · `ai-rules.md`
@@ -0,0 +1,467 @@
1
+ # Domain-Driven Design Standards (Tactical Patterns)
2
+
3
+ > Domain-focused and technology-agnostic DDD standards.
4
+ >
5
+ > Business-specific aggregate definitions and domain rules belong in the relevant
6
+ > domain specification files.
7
+
8
+ ---
9
+
10
+ ## 1. Ubiquitous Language
11
+
12
+ - Each bounded context MUST use a consistent ubiquitous language.
13
+ - Domain concepts MUST use terminology that reflects the business domain.
14
+ - Terms with different meanings in different bounded contexts MUST NOT be treated as the same concept without an explicit translation.
15
+ - Technical implementation terminology MUST NOT replace established domain terminology.
16
+ - Business-specific terminology MUST be defined in the relevant domain specification rather than this generic standard.
17
+
18
+ ---
19
+
20
+ ## 2. Bounded Contexts
21
+
22
+ - A bounded context defines a clear boundary around a domain model and its ubiquitous language.
23
+ - Domain models MUST remain internally consistent within their bounded context.
24
+ - A domain model MUST NOT directly depend on another bounded context's internal domain model.
25
+ - Communication between bounded contexts MUST use explicitly defined contracts or translation mechanisms.
26
+ - Shared concepts MUST be introduced only when they genuinely represent the same concept across the relevant contexts.
27
+ - Business-specific bounded-context definitions belong in the relevant domain specification.
28
+
29
+ ---
30
+
31
+ ## 3. Aggregate Design
32
+
33
+ - An Aggregate is a consistency boundary containing one or more related domain objects.
34
+ - Every Aggregate MUST have exactly one Aggregate Root.
35
+ - The Aggregate Root is the only object through which external code may modify the Aggregate.
36
+ - Aggregate boundaries MUST be designed around business invariants and transactional consistency requirements.
37
+ - Aggregates SHOULD remain as small as practical.
38
+ - An Aggregate MUST NOT contain objects merely because they are conceptually related if they do not require the same consistency boundary.
39
+ - Cross-aggregate references SHOULD use identity rather than direct object references.
40
+ - Aggregates MUST protect their internal state from uncontrolled external mutation.
41
+
42
+ ### Aggregate Root Responsibilities
43
+
44
+ An Aggregate Root SHOULD:
45
+
46
+ 1. Enforce business invariants.
47
+ 2. Control the lifecycle of child entities.
48
+ 3. Coordinate state changes within the Aggregate.
49
+ 4. Protect the Aggregate's internal state.
50
+ 5. Raise domain events for significant externally observable state changes where required.
51
+
52
+ ---
53
+
54
+ ## 4. Aggregate Invariants
55
+
56
+ - Business invariants MUST be enforced within the domain model.
57
+ - An Aggregate MUST NOT allow a state that violates one of its invariants.
58
+ - Invariants MUST be enforced regardless of which application use case invokes the Aggregate.
59
+ - Public methods that mutate domain state MUST preserve the Aggregate's invariants.
60
+ - Validation performed at an API or application boundary MUST NOT be considered a replacement for domain invariant enforcement.
61
+ - Business rules that require multiple domain objects within the same consistency boundary SHOULD be enforced by the Aggregate Root.
62
+
63
+ ---
64
+
65
+ ## 5. Entity
66
+
67
+ - An Entity is a domain object whose identity distinguishes it from other objects of the same type.
68
+ - Entity identity MUST remain stable throughout the Entity lifecycle.
69
+ - Entity equality MUST be based on identity rather than mutable attributes.
70
+ - Mutable domain attributes MUST NOT be used as the basis of Entity identity.
71
+ - Entities MUST protect state changes through intention-revealing domain operations where business rules apply.
72
+ - Entities SHOULD NOT expose unrestricted setters when doing so would allow invalid domain state.
73
+
74
+ ---
75
+
76
+ ## 6. Child Entities
77
+
78
+ - Child Entities belong to the lifecycle of their Aggregate.
79
+ - Child Entities MUST NOT be independently modified in a way that bypasses Aggregate invariants.
80
+ - Creation, modification, and removal of child Entities SHOULD be controlled by the Aggregate Root.
81
+ - Child Entities MAY enforce their own local invariants.
82
+ - Aggregate-level invariants MUST remain the responsibility of the Aggregate Root.
83
+ - Child Entity identity MUST remain distinct from the identity of the Aggregate Root.
84
+
85
+ ---
86
+
87
+ ## 7. Value Objects
88
+
89
+ Value Objects represent descriptive domain concepts whose identity is determined by their values.
90
+
91
+ Value Objects SHOULD follow these rules:
92
+
93
+ - They MUST be immutable.
94
+ - They MUST be compared by value rather than identity.
95
+ - They SHOULD validate themselves when created.
96
+ - Invalid Value Objects MUST NOT be created.
97
+ - They SHOULD expose meaningful domain behavior rather than being treated as generic data containers.
98
+ - Their implementation MUST NOT expose mutable internal state.
99
+ - Value Objects SHOULD use meaningful domain names rather than generic wrappers such as `StringValue` or `GenericCode`.
100
+
101
+ Example:
102
+
103
+ ```java
104
+ public final class ProjectCode {
105
+
106
+ private final String value;
107
+
108
+ private ProjectCode(String value) {
109
+ if (value == null || value.isBlank()) {
110
+ throw new DomainException("Project code cannot be blank.");
111
+ }
112
+
113
+ this.value = value.strip().toUpperCase();
114
+ }
115
+
116
+ public static ProjectCode from(String value) {
117
+ return new ProjectCode(value);
118
+ }
119
+
120
+ public String value() {
121
+ return value;
122
+ }
123
+
124
+ @Override
125
+ public boolean equals(Object other) {
126
+ return other instanceof ProjectCode that
127
+ && value.equals(that.value);
128
+ }
129
+
130
+ @Override
131
+ public int hashCode() {
132
+ return value.hashCode();
133
+ }
134
+
135
+ @Override
136
+ public String toString() {
137
+ return value;
138
+ }
139
+ }
140
+ ````
141
+
142
+ ---
143
+
144
+ ## 8. Strongly Typed Domain Identifiers
145
+
146
+ * Aggregate Roots and Entities SHOULD use dedicated domain identifier types when the domain benefits from stronger type safety.
147
+ * A domain identifier MUST represent one specific identity concept.
148
+ * Different identity concepts MUST NOT be interchangeable merely because they use the same underlying primitive type.
149
+ * Identifier equality MUST be value-based.
150
+ * Identifiers MUST NOT contain business behavior unrelated to identity.
151
+ * Identifier creation MUST reject invalid or missing values.
152
+ * The underlying representation of an identifier is an implementation concern and MUST NOT determine the domain semantics.
153
+
154
+ Example:
155
+
156
+ ```java
157
+ public final class ProjectId {
158
+
159
+ private final UUID value;
160
+
161
+ private ProjectId(UUID value) {
162
+ this.value = Objects.requireNonNull(value);
163
+ }
164
+
165
+ public static ProjectId from(UUID value) {
166
+ return new ProjectId(value);
167
+ }
168
+
169
+ public static ProjectId generate() {
170
+ return new ProjectId(UUID.randomUUID());
171
+ }
172
+
173
+ public UUID value() {
174
+ return value;
175
+ }
176
+
177
+ @Override
178
+ public boolean equals(Object other) {
179
+ return other instanceof ProjectId that
180
+ && value.equals(that.value);
181
+ }
182
+
183
+ @Override
184
+ public int hashCode() {
185
+ return value.hashCode();
186
+ }
187
+ }
188
+ ```
189
+
190
+ ---
191
+
192
+ ## 9. Domain Events
193
+
194
+ * A Domain Event represents a significant business occurrence that has already happened.
195
+ * Domain Events MUST be expressed in domain terms.
196
+ * Domain Events SHOULD be immutable.
197
+ * Domain Events SHOULD contain the information required by consumers to understand the occurrence without exposing internal Aggregate state.
198
+ * Domain Events SHOULD use past-tense naming.
199
+
200
+ Examples:
201
+
202
+ * `ProjectCreated`
203
+
204
+ * `BookingConfirmed`
205
+
206
+ * `FlightCancelled`
207
+
208
+ * `PaymentReceived`
209
+
210
+ * Domain Events SHOULD be raised by the domain model when the corresponding business state transition occurs.
211
+
212
+ * The domain model is responsible for representing and collecting domain events.
213
+
214
+ * Publishing, transporting, persisting, retrying, or delivering events to external systems is outside the responsibility of the domain model.
215
+
216
+ * Domain event dispatch mechanisms MUST NOT change the business meaning of the event.
217
+
218
+ ---
219
+
220
+ ## 10. Domain Services
221
+
222
+ A Domain Service SHOULD be used only when:
223
+
224
+ * The behavior is genuinely part of the domain.
225
+ * The behavior does not naturally belong to a single Entity, Value Object, or Aggregate.
226
+ * The behavior represents a meaningful domain operation.
227
+ * Moving the behavior into an Entity or Value Object would make the model less coherent.
228
+
229
+ Domain Services:
230
+
231
+ * MUST contain domain behavior rather than application orchestration.
232
+ * MUST NOT become general-purpose utility classes.
233
+ * MUST NOT contain infrastructure concerns.
234
+ * MUST NOT be used merely to avoid placing behavior inside an appropriate Aggregate.
235
+ * SHOULD remain stateless where practical.
236
+
237
+ ---
238
+
239
+ ## 11. Repositories
240
+
241
+ * Repositories represent a domain-oriented means of obtaining and storing Aggregates.
242
+ * A Repository abstraction SHOULD exist for Aggregate Roots when persistence access is required by the domain model.
243
+ * Repository operations SHOULD be expressed using domain concepts and domain identifiers.
244
+ * Repository abstractions MUST NOT expose persistence-specific implementation details.
245
+ * A Repository MUST NOT be used to bypass Aggregate boundaries.
246
+ * Repositories SHOULD return Aggregates rather than individual child entities when the child belongs to an Aggregate.
247
+ * Query operations that do not require loading an Aggregate MAY use dedicated query/read-model mechanisms.
248
+
249
+ ---
250
+
251
+ ## 12. Domain Specifications
252
+
253
+ A Specification represents a reusable business predicate or domain rule.
254
+
255
+ * Specifications SHOULD be used when a business rule is meaningful, reusable, and independently composable.
256
+ * Specifications MUST express domain concepts rather than persistence implementation details.
257
+ * Specifications MAY be combined when the domain requires logical composition of business rules.
258
+ * Specifications MUST NOT become a generic query abstraction for unrelated technical concerns.
259
+ * Persistence-specific query specifications belong outside the domain model unless they directly represent a domain concept.
260
+
261
+ ---
262
+
263
+ ## 13. Domain Exceptions
264
+
265
+ * Domain exceptions MAY be used when a domain operation violates a business rule or invariant.
266
+ * Domain exceptions MUST describe domain failures rather than infrastructure failures.
267
+ * Domain exceptions SHOULD contain stable, meaningful messages suitable for controlled translation at an application boundary.
268
+ * Domain code MUST NOT create HTTP-specific exceptions.
269
+ * Domain code MUST NOT expose database, persistence, framework, or transport errors as domain concepts.
270
+ * Infrastructure failures MUST NOT be disguised as domain rule violations.
271
+
272
+ Example:
273
+
274
+ ```java
275
+ public class DomainException extends RuntimeException {
276
+
277
+ public DomainException(String message) {
278
+ super(message);
279
+ }
280
+ }
281
+ ```
282
+
283
+ ---
284
+
285
+ ## 14. Encapsulation
286
+
287
+ * Domain state MUST be protected from uncontrolled modification.
288
+ * Public setters SHOULD NOT be used for business state changes.
289
+ * State-changing operations SHOULD express business intent.
290
+
291
+ Prefer:
292
+
293
+ ```java
294
+ booking.confirm();
295
+ ```
296
+
297
+ over:
298
+
299
+ ```java
300
+ booking.setStatus(CONFIRMED);
301
+ ```
302
+
303
+ * Domain methods SHOULD represent meaningful business actions.
304
+ * Aggregates SHOULD expose only the information and operations required by their consumers.
305
+ * Collections owned by Aggregates MUST NOT expose mutable internal collections directly.
306
+ * Internal domain collections SHOULD be exposed through read-only views where required.
307
+
308
+ ---
309
+
310
+ ## 15. Rich Domain Model
311
+
312
+ * Business decisions SHOULD live in the domain model.
313
+ * Application services SHOULD orchestrate domain operations rather than reproduce domain rules.
314
+ * Controllers, DTOs, repositories, and infrastructure components MUST NOT become the primary location for domain decisions.
315
+ * Anemic domain models SHOULD be avoided when the domain contains meaningful business behavior.
316
+ * Simple data-only domain objects MAY remain simple when no meaningful behavior or invariant belongs to them.
317
+ * Domain behavior MUST be placed where the corresponding business responsibility naturally belongs.
318
+
319
+ ---
320
+
321
+ ## 16. Immutability
322
+
323
+ * Value Objects MUST be immutable.
324
+ * Domain Events SHOULD be immutable.
325
+ * Domain identifiers SHOULD be immutable.
326
+ * Mutable state in Entities and Aggregates MUST be changed only through controlled domain operations.
327
+ * Domain objects SHOULD avoid exposing mutable collections or mutable internal objects.
328
+ * Immutability MUST be preferred where it does not conflict with legitimate Aggregate lifecycle requirements.
329
+
330
+ ---
331
+
332
+ ## 17. Time and External State
333
+
334
+ * Domain logic SHOULD avoid directly depending on system time when deterministic behavior and testing are important.
335
+ * When the current time affects a business decision, the time source SHOULD be supplied through an appropriate abstraction or application boundary.
336
+ * Domain logic SHOULD NOT directly access databases, HTTP services, message brokers, environment variables, or other external systems.
337
+ * External information required for a domain decision SHOULD be supplied through an appropriate domain/application boundary.
338
+
339
+ ---
340
+
341
+ ## 18. Cross-Aggregate Interaction
342
+
343
+ * Aggregates MUST remain independently consistent.
344
+ * One Aggregate MUST NOT directly mutate another Aggregate.
345
+ * Cross-Aggregate operations SHOULD be coordinated by an application-level operation or domain event where appropriate.
346
+ * References between Aggregates SHOULD use identifiers rather than direct mutable object navigation.
347
+ * A business process spanning multiple Aggregates MUST NOT assume that all Aggregates form one consistency boundary.
348
+ * If immediate consistency across multiple Aggregates is required, the Aggregate boundaries SHOULD be reconsidered before introducing coordination logic.
349
+
350
+ ---
351
+
352
+ ## 19. Cross-Bounded-Context Interaction
353
+
354
+ * A bounded context MUST NOT directly modify another bounded context's domain objects.
355
+ * Each bounded context owns its own domain model.
356
+ * Communication between bounded contexts MUST use explicit contracts.
357
+ * Anti-Corruption Layers SHOULD be used when an external domain model must be translated into the local domain model.
358
+ * Shared concepts MUST NOT be used merely to avoid defining appropriate context-specific models.
359
+ * Domain models MUST NOT become coupled simply because two contexts happen to use similar terminology.
360
+
361
+ ---
362
+
363
+ ## 20. Domain Modeling Guidelines
364
+
365
+ When introducing a new domain concept:
366
+
367
+ 1. Identify the business concept it represents.
368
+ 2. Determine whether it is an Entity, Value Object, Aggregate, Aggregate Root, Domain Event, or Domain Service.
369
+ 3. Identify the invariants that must always hold.
370
+ 4. Define the responsibility of the concept.
371
+ 5. Determine its lifecycle and ownership.
372
+ 6. Determine whether it belongs inside an existing Aggregate or requires a separate Aggregate.
373
+ 7. Identify the domain events produced by significant state transitions.
374
+ 8. Avoid introducing abstractions that do not represent a genuine domain concept.
375
+
376
+ ---
377
+
378
+ ## 21. Anti-Patterns
379
+
380
+ The following patterns are forbidden or strongly discouraged:
381
+
382
+ | Anti-pattern | Reason |
383
+ | ------------------------------------------------------------- | --------------------------------------------------- |
384
+ | Anemic domain model when meaningful business behavior exists | Moves business decisions away from the domain model |
385
+ | Public setters for business state | Allows invalid state transitions |
386
+ | Primitive obsession for important domain concepts | Weakens domain semantics and type safety |
387
+ | Cross-Aggregate direct mutation | Breaks Aggregate boundaries |
388
+ | Treating an entire bounded context as one Aggregate | Creates excessive coupling and consistency scope |
389
+ | Using Value Objects as mutable DTOs | Violates Value Object semantics |
390
+ | Using Entities as generic data containers | Weakens domain behavior and encapsulation |
391
+ | Generic utility classes containing domain rules | Hides domain responsibilities |
392
+ | Infrastructure logic inside domain concepts | Couples the domain to external concerns |
393
+ | Domain logic inside controllers | Makes business behavior dependent on transport |
394
+ | Domain logic inside persistence implementations | Couples business behavior to storage |
395
+ | Using Domain Events as generic integration messages | Blurs domain and integration responsibilities |
396
+ | Creating abstractions without domain meaning | Adds unnecessary complexity |
397
+ | Direct cross-bounded-context domain object sharing | Couples independent models |
398
+ | Using repositories to manipulate child entities independently | Bypasses Aggregate boundaries |
399
+
400
+ ---
401
+
402
+ ## 22. DDD Quality Criteria
403
+
404
+ A domain model SHOULD satisfy the following criteria:
405
+
406
+ * [ ] Ubiquitous language is clear and consistent.
407
+ * [ ] Bounded-context boundaries are explicit.
408
+ * [ ] Aggregate boundaries are based on business consistency requirements.
409
+ * [ ] Every Aggregate has a clear Aggregate Root.
410
+ * [ ] Aggregate invariants are enforced by the domain model.
411
+ * [ ] Entities use identity-based semantics.
412
+ * [ ] Value Objects use value-based semantics.
413
+ * [ ] Value Objects are immutable.
414
+ * [ ] Domain Events represent meaningful business occurrences.
415
+ * [ ] Domain Services are used only where domain behavior does not naturally belong elsewhere.
416
+ * [ ] Repository abstractions operate around Aggregate boundaries.
417
+ * [ ] Cross-Aggregate mutation is avoided.
418
+ * [ ] Cross-bounded-context coupling is minimized.
419
+ * [ ] Domain state is properly encapsulated.
420
+ * [ ] Infrastructure concerns are not represented as domain concepts.
421
+ * [ ] No unnecessary domain abstractions have been introduced.
422
+
423
+ ---
424
+
425
+ ## 23. Scope
426
+
427
+ This document defines **generic DDD tactical modeling standards only**.
428
+
429
+ It does not define:
430
+
431
+ * Project folder or package structure.
432
+ * Hexagonal or Clean Architecture layer structure.
433
+ * Spring Boot configuration.
434
+ * JPA entity mapping strategy.
435
+ * Database schema or migration strategy.
436
+ * REST/API design.
437
+ * Security configuration.
438
+ * Dependency management.
439
+ * Testing framework configuration.
440
+ * Infrastructure adapter implementation.
441
+
442
+ Those concerns MUST be defined in their respective technology, architecture, API, security, persistence, or project-specific standards.
443
+
444
+ ```
445
+
446
+ ### Important change
447
+
448
+ I deliberately removed the old sections that prescribed things such as:
449
+
450
+ - `domain / application / infrastructure / api` package structure
451
+ - Hexagonal dependency diagrams
452
+ - `@EntityScan`
453
+ - `@EnableJpaAuditing`
454
+ - `@SQLRestriction`
455
+ - `@Transactional`
456
+ - `JpaRepository`
457
+ - `ApplicationEventPublisher`
458
+ - JPA `AttributeConverter`
459
+ - Spring `@Service`, `@Repository`, `@RestControllerAdvice`
460
+ - `spring.jpa.open-in-view`
461
+ - `ddl-auto`
462
+ - infrastructure implementation examples
463
+
464
+ Those belong in the **architecture/technology-specific guardrails**, not in the generic DDD standard.
465
+
466
+ This version should therefore work much better with your separation of **architecture rules vs. DDD rules vs. Java coding rules**.
467
+ ```