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,316 @@
1
+ # Persistence Standards
2
+
3
+ > Java/Spring persistence standards using Spring Data JPA, Hibernate, and PostgreSQL.
4
+
5
+ > This document defines generic persistence behavior and practices. Architecture, module boundaries, folder structure, and domain-modeling rules are governed by their respective standards.
6
+
7
+ ---
8
+
9
+ ## 1. JPA / Hibernate Conventions
10
+
11
+ - JPA entity mapping MUST use standard Jakarta Persistence annotations such as `@Entity`, `@Table`, `@Column`, `@Id`, and `@Version` where applicable.
12
+
13
+ - Persistence mappings MUST accurately represent the database schema and MUST NOT rely on implicit behavior that can cause schema ambiguity.
14
+
15
+ - Java time types SHOULD be preferred over legacy date/time APIs.
16
+
17
+ - Time-based database columns MUST use a timezone-safe representation appropriate for the selected database. For PostgreSQL, `TIMESTAMP WITH TIME ZONE` (`timestamptz`) SHOULD be used for timestamps representing an absolute point in time.
18
+
19
+ - JPA/Hibernate-specific annotations MUST be used only where they provide a clear persistence concern.
20
+
21
+ - Persistence configuration MUST NOT introduce business behavior that belongs in the domain model.
22
+
23
+ ---
24
+
25
+ ## 2. Repository and Data Access Rules
26
+
27
+ - Repository abstractions MUST expose only the persistence operations required by the application.
28
+
29
+ - Spring Data repositories SHOULD be preferred over unnecessary custom persistence infrastructure.
30
+
31
+ - Complex or reusable query logic SHOULD use Spring Data JPA `Specification` where appropriate.
32
+
33
+ - Direct `EntityManager` usage SHOULD be limited to persistence operations that cannot be expressed cleanly through the repository abstraction.
34
+
35
+ - Persistence queries MUST NOT contain business rules that belong in the domain model.
36
+
37
+ - Repository methods SHOULD remain focused and avoid becoming general-purpose data-access objects.
38
+
39
+ - Queries MUST retrieve only the data required by the operation where practical.
40
+
41
+ - N+1 query patterns MUST be avoided.
42
+
43
+ ---
44
+
45
+ ## 3. Specification and Query Rules
46
+
47
+ - Spring Data JPA `Specification` MAY be used for dynamic and composable query predicates. :contentReference[oaicite:0]{index=0}
48
+
49
+ - Specifications SHOULD be used when multiple optional criteria need to be combined dynamically.
50
+
51
+ - Specifications SHOULD remain focused on persistence/query criteria rather than business decisions.
52
+
53
+ - Specifications SHOULD be composable using operations such as `.and()` and `.or()`.
54
+
55
+ - Paging and sorting SHOULD use Spring Data's `Pageable` and `Sort` mechanisms where applicable.
56
+
57
+ - Queries MUST avoid unnecessary joins, eager loading, and unbounded result sets.
58
+
59
+ - Native SQL MAY be used when required for database-specific functionality or when it provides a significant persistence benefit that cannot be expressed appropriately through JPA.
60
+
61
+ - Native queries MUST remain maintainable and MUST NOT bypass required business invariants.
62
+
63
+ ---
64
+
65
+ ## 4. Entity Lifecycle and State
66
+
67
+ - JPA entities MUST provide the constructors required by the persistence provider.
68
+
69
+ - Entity state changes MUST be persisted through the normal JPA transaction lifecycle.
70
+
71
+ - Persistence entities MUST NOT expose unnecessary mutable state solely for persistence convenience.
72
+
73
+ - Lazy loading SHOULD be preferred for relationships unless eager loading is explicitly justified.
74
+
75
+ - `FetchType.EAGER` MUST NOT be used by default for relationships.
76
+
77
+ - Collection relationships SHOULD be configured deliberately to avoid accidental large object graphs.
78
+
79
+ - Cascade operations MUST be explicitly selected based on the lifecycle relationship between persisted objects.
80
+
81
+ - `orphanRemoval = true` MUST only be used when the child lifecycle is fully owned by the parent persistence relationship.
82
+
83
+ ---
84
+
85
+ ## 5. Concurrency Handling
86
+
87
+ - Optimistic locking SHOULD be used where concurrent updates can cause lost-update problems.
88
+
89
+ - JPA optimistic locking SHOULD use `@Version` on an appropriate numeric or supported version field.
90
+
91
+ - The persistence provider MUST manage the version value rather than application code manually incrementing it.
92
+
93
+ - Applications MUST handle optimistic locking failures according to the application's error-handling policy.
94
+
95
+ - Pessimistic locking MAY be used when optimistic locking is insufficient and the concurrency requirement justifies it.
96
+
97
+ - Locking strategies MUST be selected based on the actual consistency requirement rather than applied indiscriminately. Spring Data JPA supports explicit lock modes through `@Lock`. :contentReference[oaicite:1]{index=1}
98
+
99
+ ---
100
+
101
+ ## 6. Soft Delete
102
+
103
+ - Soft delete MAY be used when records must remain physically stored while being excluded from normal application queries.
104
+
105
+ - A soft-delete implementation SHOULD use an explicit deletion-state field such as `deletedAt` or an equivalent representation.
106
+
107
+ - Soft-delete filtering MUST be applied consistently to normal queries.
108
+
109
+ - Hard deletion MUST NOT be used where retention, regulatory, or business requirements require logical deletion.
110
+
111
+ - Administrative or reporting access to soft-deleted data MUST use an explicitly defined persistence mechanism.
112
+
113
+ - Soft-delete behavior MUST NOT accidentally apply to entities that are not intended to be soft-deletable.
114
+
115
+ - Database-level retention and physical deletion policies are separate concerns and MUST be handled explicitly.
116
+
117
+ ---
118
+
119
+ ## 7. Auditing
120
+
121
+ - Persistence auditing MAY be implemented using Spring Data JPA auditing facilities.
122
+
123
+ - Creation and modification timestamps SHOULD use appropriate Java time types.
124
+
125
+ - Creator and modifier information MAY be captured where required by the application.
126
+
127
+ - Audit fields SHOULD be populated automatically through the configured persistence auditing mechanism rather than duplicated across application code. Spring Data JPA provides auditing support for creation/modification metadata. :contentReference[oaicite:2]{index=2}
128
+
129
+ - Audit metadata MUST NOT be modified manually unless the application's requirements explicitly require such behavior.
130
+
131
+ - Auditing configuration MUST remain separate from business-domain rules.
132
+
133
+ ---
134
+
135
+ ## 8. Transaction and Persistence Context Rules
136
+
137
+ - Database modifications MUST execute within an appropriate transaction boundary.
138
+
139
+ - Transactions SHOULD be kept as short as practical.
140
+
141
+ - Long-running transactions MUST be avoided unless explicitly required.
142
+
143
+ - Persistence entities SHOULD NOT be accessed after the persistence context is no longer available.
144
+
145
+ - Lazy-loading behavior MUST be considered when designing transaction boundaries.
146
+
147
+ - Open-session/open-entity-manager behavior MUST NOT be relied upon to hide incorrect transaction boundaries.
148
+
149
+ - Read-only operations SHOULD use read-only transaction semantics where supported and appropriate.
150
+
151
+ ---
152
+
153
+ ## 9. Database and Schema Management
154
+
155
+ - Database schema changes MUST be managed through the project's approved migration mechanism.
156
+
157
+ - Flyway SHOULD be used when it is the project's approved migration tool.
158
+
159
+ - Hibernate schema generation MUST NOT be used as the primary production schema-management mechanism.
160
+
161
+ - In higher environments, Hibernate schema validation SHOULD be used instead of automatic schema mutation.
162
+
163
+ - Schema migrations MUST be deterministic and repeatable across environments.
164
+
165
+ - Migrations MUST be tested against a clean database.
166
+
167
+ - Database constraints SHOULD be used where they provide meaningful data-integrity guarantees.
168
+
169
+ - Indexes MUST be introduced based on actual query and constraint requirements.
170
+
171
+ - Database naming conventions MUST remain consistent across the application.
172
+
173
+ ---
174
+
175
+ ## 10. PostgreSQL Standards
176
+
177
+ - PostgreSQL SHOULD be the default relational database when PostgreSQL is the project's approved production provider.
178
+
179
+ - PostgreSQL-specific features MAY be used when they provide a clear requirement or operational benefit.
180
+
181
+ - Database-specific behavior MUST be documented when it prevents straightforward portability.
182
+
183
+ - SQL types MUST be selected deliberately rather than relying on implicit database conversions.
184
+
185
+ - UUIDs, timestamps, numeric values, JSON/JSONB, and other PostgreSQL-specific types MUST use mappings appropriate to their intended semantics.
186
+
187
+ - Database queries SHOULD be validated against the PostgreSQL version used by the application.
188
+
189
+ ---
190
+
191
+ ## 11. Testing Persistence
192
+
193
+ - Persistence behavior MUST be covered by integration tests where unit tests cannot adequately validate JPA/Hibernate behavior.
194
+
195
+ - PostgreSQL integration tests SHOULD use Testcontainers or an equivalent real PostgreSQL environment.
196
+
197
+ - H2 or other in-memory databases SHOULD NOT be used to validate PostgreSQL-specific persistence behavior.
198
+
199
+ - Persistence tests SHOULD verify:
200
+
201
+ - Entity mappings
202
+ - Repository queries
203
+ - Constraints
204
+ - Transactions
205
+ - Optimistic locking where applicable
206
+ - Migration compatibility
207
+ - Soft-delete behavior where applicable
208
+
209
+ - Database migrations MUST be tested against a fresh database during CI where schema changes are introduced.
210
+
211
+ ---
212
+
213
+ ## 12. Performance
214
+
215
+ - Persistence performance MUST be considered for queries operating on potentially large datasets.
216
+
217
+ - N+1 queries MUST be identified and eliminated where they affect application behavior or performance.
218
+
219
+ - Unbounded queries MUST be avoided for potentially large datasets.
220
+
221
+ - Pagination SHOULD be used for large result sets.
222
+
223
+ - Fetch joins, entity graphs, projections, or other optimized retrieval strategies MAY be used where justified.
224
+
225
+ - Database indexes SHOULD support frequently executed filtering, joining, ordering, and uniqueness requirements.
226
+
227
+ - Persistence logging MUST NOT expose sensitive data.
228
+
229
+ - Query optimization SHOULD be based on measured behavior rather than speculative optimization.
230
+
231
+ ---
232
+
233
+ ## 13. Mapping and Persistence Boundaries
234
+
235
+ - Persistence entities MUST NOT be treated as generic API response objects.
236
+
237
+ - Database-specific types SHOULD NOT leak into unrelated application contracts.
238
+
239
+ - Persistence-specific annotations and configuration MUST remain associated with persistence concerns.
240
+
241
+ - Conversion between persistence representations and application/domain representations MUST be explicit where the representations differ.
242
+
243
+ - Attribute converters MAY be used for custom persistence mappings when they provide a clear and maintainable solution.
244
+
245
+ - Reflection-heavy persistence mapping SHOULD be avoided unless required by the selected persistence framework.
246
+
247
+ ---
248
+
249
+ ## 14. Prohibited Persistence Practices
250
+
251
+ The following practices are prohibited unless explicitly justified and approved:
252
+
253
+ 1. Automatic production schema mutation through Hibernate `ddl-auto=update` or equivalent.
254
+
255
+ 2. Unbounded queries against potentially large tables.
256
+
257
+ 3. Default use of `FetchType.EAGER` for relationships.
258
+
259
+ 4. N+1 query patterns that can reasonably be avoided.
260
+
261
+ 5. Manual manipulation of optimistic-lock version values.
262
+
263
+ 6. Persistence queries that implement business rules that belong elsewhere.
264
+
265
+ 7. Hard-coded database credentials or connection secrets.
266
+
267
+ 8. Database access outside the application's approved persistence mechanism.
268
+
269
+ 9. Use of H2 as proof of PostgreSQL-specific production behavior.
270
+
271
+ 10. Unnecessary native SQL when an appropriate JPA/Spring Data solution is available.
272
+
273
+ 11. Persistence configuration that silently changes business behavior.
274
+
275
+ 12. Unnecessary custom persistence frameworks or abstractions.
276
+
277
+ ---
278
+
279
+ ## 15. Quality Gates
280
+
281
+ - Persistence tests MUST pass.
282
+
283
+ - Database migrations MUST apply successfully to a fresh database.
284
+
285
+ - Hibernate/JPA validation MUST pass where schema validation is configured.
286
+
287
+ - Repository and query tests MUST pass for changed persistence behavior.
288
+
289
+ - Optimistic-locking behavior MUST be tested where concurrency control is required.
290
+
291
+ - PostgreSQL compatibility MUST be verified for PostgreSQL-specific queries or features.
292
+
293
+ - No hard-coded database credentials or secrets may be present.
294
+
295
+ - Persistence changes SHOULD be reviewed for query performance and migration impact.
296
+
297
+ ---
298
+
299
+ ## 16. Implementation Boundary
300
+
301
+ This rule defines generic Java/Spring persistence behavior.
302
+
303
+ The following remain implementation decisions unless explicitly required elsewhere:
304
+
305
+ - Exact entity class names
306
+ - Exact repository class names
307
+ - Exact package structure
308
+ - Exact database table names
309
+ - Exact migration filenames
310
+ - Exact Hibernate configuration
311
+ - Exact connection-pool configuration
312
+ - Exact indexing strategy
313
+ - Exact query implementation
314
+ - Exact Testcontainers configuration
315
+
316
+ Persistence implementation MUST follow the applicable project architecture, DDD, security, API, and domain-specific standards without duplicating those standards here.
@@ -0,0 +1,98 @@
1
+ # Problem Details Component Architectural Specification (Rule)
2
+
3
+ ## 1. Purpose
4
+
5
+ The purpose of the Problem Details component is to standardize the HTTP error representation returned by the Project Management application.
6
+
7
+ It provides a boundary between application-level error information and HTTP-specific error representation, converting application errors and exceptions into a standardized HTTP error response.
8
+
9
+ The Domain and Application layers MUST NOT depend on HTTP-specific Problem Details types.
10
+
11
+ ---
12
+
13
+ ## 2. Component Responsibilities
14
+
15
+ The component MUST provide reusable implementation for:
16
+
17
+ - Mapping application-level error representations to Problem Details.
18
+ - Mapping appropriate exceptions to Problem Details.
19
+ - Representing multiple errors where supported.
20
+ - Representing validation errors.
21
+ - Providing configurable diagnostic metadata.
22
+ - Providing configurable stack-trace exposure.
23
+ - Providing standardized default title/status behavior.
24
+ - Providing externalized configuration.
25
+ - Protecting sensitive information from HTTP error responses.
26
+ - Consuming existing tracing/correlation context when available.
27
+
28
+ The component MUST NOT own:
29
+
30
+ - Business rules or Domain error semantics.
31
+ - Validation execution.
32
+ - Result Mapping logic.
33
+ - Exception generation.
34
+ - Logging, Metrics, or Distributed tracing.
35
+ - Authentication/authorization decisions.
36
+ - Business audit logging.
37
+
38
+ ---
39
+
40
+ ## 3. Standard Problem Details Representation
41
+
42
+ The component MUST use the application's approved standard Problem Details representation, which SHOULD align with the established Java/Spring HTTP Problem Details mechanism.
43
+
44
+ The representation SHOULD support the standard Problem Details fields, as applicable:
45
+
46
+ - `type`
47
+ - `title`
48
+ - `status`
49
+ - `detail`
50
+ - `instance`
51
+
52
+ Application-specific diagnostic information MAY be represented through extensions when justified, such as:
53
+
54
+ - trace ID
55
+ - correlation ID
56
+ - error ID
57
+ - tenant ID
58
+ - validation errors
59
+ - other approved diagnostic metadata
60
+
61
+ The component MUST NOT make every possible extension mandatory or invent unnecessary mandatory fields.
62
+
63
+ ---
64
+
65
+ ## 4. Error and Exception Mapping
66
+
67
+ The component MUST support mapping appropriate application-level error representations and exceptions into standardized Problem Details responses.
68
+
69
+ It MUST distinguish between information useful for internal diagnostics and information safe to expose to API consumers.
70
+
71
+ Exception messages MUST NOT automatically be assumed to be safe for external exposure.
72
+
73
+ The component MUST NOT expose internal implementation details or sensitive exception information unintentionally.
74
+
75
+ Stack traces MUST be configurable and MUST NOT be exposed in production by default.
76
+
77
+ The component MUST NOT generate business exceptions.
78
+
79
+ ---
80
+
81
+ ## 5. Validation Integration
82
+
83
+ Problem Details MUST support the representation of validation failures, but it MUST NOT perform validation itself.
84
+
85
+ Validation remains a separate cross-cutting concern.
86
+
87
+ The Problem Details component MAY consume validation errors and represent them in the standardized HTTP response.
88
+
89
+ The responsibility boundary MUST remain:
90
+
91
+ ```text
92
+ Validation
93
+ ↓
94
+ Validation error
95
+ ↓
96
+ Problem Details
97
+ ↓
98
+ Standardized HTTP error response
@@ -0,0 +1,48 @@
1
+ # Result Mapping Component Architectural Specification (Rule)
2
+
3
+ ## 1. Purpose
4
+
5
+ The purpose of the Result Mapping component is to provide a standardized mechanism for converting application-level Result objects into HTTP responses.
6
+
7
+ The component MUST keep application Result semantics separate from HTTP response construction.
8
+
9
+ ---
10
+
11
+ ## 2. Component Responsibilities
12
+
13
+ The component MUST provide reusable behavior for:
14
+
15
+ - Mapping generic application Results containing a value to HTTP responses.
16
+ - Mapping non-generic application Results to HTTP responses.
17
+ - Determining the HTTP response outcome based on the Result's established success/failure state.
18
+ - Returning the contained value for successful generic Results.
19
+ - Returning a successful response without a body for successful non-generic Results.
20
+ - Delegating failed Results to the Problem Details component.
21
+ - Providing a Result Mapper contract and concrete implementation where the reusable mapping capability requires an explicit contract.
22
+ - Providing framework/dependency-injection registration for the mapper.
23
+ - Providing exception-to-Result conversion where this behavior is part of the application's established Result model.
24
+
25
+ The component MUST NOT own:
26
+
27
+ - Business rules or Domain error semantics.
28
+ - Problem Details construction or HTTP error representation.
29
+ - Validation, Logging, Metrics, or Distributed tracing.
30
+ - Authentication or authorization decisions.
31
+ - Business audit logging.
32
+
33
+ ---
34
+
35
+ ## 3. Result Mapping Behavior
36
+
37
+ The mapper MUST evaluate the established success/failure state of the Result.
38
+
39
+ ### 3.1 Successful Generic Result
40
+
41
+ When a generic Result represents success, the contained Result value MUST become the HTTP response body.
42
+
43
+ ```text
44
+ Result<T>
45
+ ↓
46
+ HTTP Success Response
47
+ ↓
48
+ Result value as response body
@@ -0,0 +1,168 @@
1
+ # Technology Constitution — java-spring (domain-agnostic base)
2
+
3
+ > The technology-only governance base for this stack corpus. It heads the set mapped under
4
+ > `## /aw-spec-constitution` in a project's `tech-rule-bindings.md` — this file, then the
5
+ > standard technical rules beside it, then the project team's `technical-requirements.md` —
6
+ > which `/aw-spec-orch constitution` ratifies into `.aw-spec/memory/constitution.technical.md`.
7
+
8
+ This file is domain-agnostic on purpose: the constitution command loads it *before* the domain
9
+ is selected, and that ordering is what keeps the technical half free of domain material. The
10
+ project's three constitutional SETS are siblings, never merged here — each is headed by
11
+ its own base file:
12
+
13
+ | Source | Ratified into | Principle series |
14
+ |---|---|---|
15
+ | `technology-constitution.md` (this file) | `constitution.technical.md` | I–XV |
16
+ | `domain-constitution.md` | `constitution.domain.md` | XVI+ |
17
+ | the lane corpus's `ui-constitution.md` | `constitution.ui.md` | UX-* |
18
+
19
+ - Core Principles **I–XV** below are domain-agnostic and reused across every project that maps this corpus.
20
+ - **PROJECT IDENTITY**, **REGULATORY REGIME**, domain principles (**XVI+**), domain folder
21
+ additions and governance-override values are **not** filled here — they come from
22
+ `domain-constitution.md`.
23
+ - **Experience principles (UX-\*)** are not filled here — they come from the lane corpus's
24
+ `ui-constitution.md`.
25
+
26
+ This content is the supreme engineering authority for the service lane: where any other
27
+ engineering guidance in the repository disagrees, this document wins. It stays slim and
28
+ authoritative — the detailed rules live in the technical rule files each principle cites.
29
+
30
+ ## Runtime Style
31
+
32
+ A Modular Monolith built to evolve into independent services. It uses Hexagonal
33
+ Architecture (Ports and Adapters), Domain-Driven Design, CQRS where appropriate,
34
+ and Specification-Driven Development in a Spring Boot environment. Each module
35
+ owns its domain model, application use cases, ports, and adapters. Cross-cutting
36
+ concerns are provided through the appropriate infrastructure capabilities; business
37
+ logic lives inside aggregates and application use cases within their owning module.
38
+
39
+ ## Core Principles (domain-agnostic)
40
+
41
+ > Essence only — the full rules live in the cited rule file.
42
+
43
+ ### I — Modular Monolith (NON-NEGOTIABLE)
44
+ Single deployable Spring Boot service partitioned into logical modules; each module = Domain/Features/Persistence/Shared; no cross-module Domain coupling; no horizontal service layers across boundaries.
45
+ → `guardrails/technology/java-spring/modular-monolith.md`
46
+
47
+ ### II — Hexagonal Architecture Dependency Rule (NON-NEGOTIABLE)
48
+ Dependencies flow inward toward the Domain and Application core. Inbound Adapters
49
+ depend on Inbound Ports/Application use cases, while Outbound Ports are implemented
50
+ by Infrastructure Adapters. Domain and Application code MUST NOT depend on Infrastructure,
51
+ HTTP, or framework-specific concerns. Endpoints call application use cases/ports,
52
+ never repositories or persistence adapters directly.
53
+ → `guardrails/technology/java-spring/clean-architecture.md`
54
+
55
+ ### III — Domain-Driven Design with Rich Aggregates (NON-NEGOTIABLE)
56
+ Access entities through aggregate roots; strongly-typed IDs; sealed validating value objects; immutable domain events; invariants enforced in the aggregate; transaction boundary = aggregate boundary.
57
+ → `guardrails/technology/java-spring/domain-driven-design.md`, `guardrails/technology/java-spring/domain_abstraction.md`
58
+
59
+ ### IV — Standardized Result Mapping (NON-NEGOTIABLE)
60
+ All application logic returns standard result types rather than throwing business exceptions for control flow; errors are returned as explicit failures and mapped to HTTP responses.
61
+ → `guardrails/technology/java-spring/result_mapping.md`
62
+
63
+ ### V — Specification-Driven Persistence (NON-NEGOTIABLE)
64
+ Data access logic and query composition live in Domain Specifications; no ad-hoc SQL or JPQL in handlers; no cross-aggregate JPA navigation joins; reference parents by strongly-typed ID.
65
+ → `guardrails/technology/java-spring/persistence.md`
66
+
67
+ ### VI — Immutable Contracts at the Edge
68
+ Shared DTOs mapped explicitly; no automatic reflection mappers (e.g. strict mapping rules); DTOs are immutable; external projections stay parallel.
69
+ → `guardrails/technology/java-spring/clean-architecture.md`
70
+
71
+ ### VII — Standardized Global Exception Handling (NON-NEGOTIABLE)
72
+ System-level and unhandled exceptions are caught centrally and formatted according to RFC 7807 Problem Details; standard error payload structure across all APIs.
73
+ → `guardrails/technology/java-spring/problem_details.md`, `guardrails/technology/java-spring/global_exception_handler.md`
74
+
75
+ ### VIII — Multi-Tenant & Robust Persistence
76
+ Provider-aware persistence with PostgreSQL; transactional integrity via Spring `@Transactional` bounded to application services; cross-cutting soft-delete/audit behaviors; hard delete forbidden for retention-protected data.
77
+ → `guardrails/technology/java-spring/persistence.md`
78
+
79
+ ### IX — Security by Default & Zero Trust (NON-NEGOTIABLE)
80
+ Explicit role-based and scope-based authorization via Spring Security; external IdP only; zero trust networks; sensitive data encrypted in transit and at rest; strict TLS and CORS policies.
81
+ → `guardrails/technology/java-spring/zero-trust.md`, `guardrails/technology/java-spring/authorization.md`
82
+
83
+ ### X — Observability is a First-Class Citizen (NON-NEGOTIABLE)
84
+ Structured logging using SLF4J with an approved logging backend; never log secrets
85
+ or sensitive data; available trace, span, and correlation context is included in
86
+ logs through the established context-propagation mechanism. Logging MUST remain
87
+ separate from distributed tracing, metrics, and business audit logging.
88
+ → `guardrails/technology/java-spring/logging.md`
89
+
90
+ ### XI — Cloud-Native Orchestration via Spring Boot
91
+ Spring Boot acts as the composition root; backing services are referenced via externalized configuration (12-Factor App); no hard-coded connection strings/ports.
92
+
93
+ ### XII — REST API Standards
94
+ Internal REST (Spring MVC `@RestController`, kebab routes); standard paging; versioned breaking changes via explicit API versioning policies; machine-readable contracts (OpenAPI).
95
+ → `guardrails/technology/java-spring/api-versioning.md`
96
+
97
+ ### XIII — Test-First Engineering
98
+ Tests for every aggregate behavior/value object/specification/handler/endpoint; deterministic testing; contract changes ship with test updates in the same commit.
99
+ → `guardrails/technology/java-spring/testing.md`
100
+
101
+ ### XIV — Data Integration Layer / Single Source of Truth (NON-NEGOTIABLE)
102
+ Authoritative system of record; consumers use the REST API / published projections / Domain Events only; no direct DB access from external services; inbound feeds flow through Interop adapters.
103
+ → `guardrails/technology/java-spring/api-versioning.md`
104
+
105
+ ### XV — Evolutionary Path to Microservices
106
+ Modules own their aggregates, application services, ports, adapters, persistence,
107
+ and DTOs. Cross-module communication occurs through application service interfaces
108
+ or application/domain events. Modules MUST NOT access another module's repositories
109
+ or domain internals. Per-module schemas are recommended to support future extraction;
110
+ service extraction requires an approved architectural amendment.
111
+ → `guardrails/technology/java-spring/modular-monolith.md`
112
+
113
+ > **Domain principles (XVI and beyond) are supplied by `domain-constitution.md`.**
114
+ > **Experience principles (UX-\*) are supplied by the lane corpus's `ui-constitution.md`.**
115
+
116
+ ## Mandatory Folder Structure
117
+
118
+ Governed by the technical rule files; this file does not duplicate the tree.
119
+
120
+ - Technology layout (src/tests/helm/docs, module = Domain/Features/Persistence/Shared):
121
+ `guardrails/technology/java-spring/folder-structure.md`
122
+ - Domain-specific additions (Interop adapters, domain test fixtures, regulatory controls):
123
+ supplied by `domain-constitution.md` + the active domain corpus's `folder-structure.domain.md`
124
+ - The frontend lane's layout lives entirely under its own root and is supplied by that lane's
125
+ own corpus, `guardrails/technology/nextjs/ui-constitution.md`. Nothing here applies to it.
126
+
127
+ Project names use the `<SampleProjectName>` placeholder. Cross-cutting files (e.g. `pom.xml` / `build.gradle`, application properties) MUST stay at the same level they occupy in the standard template.
128
+
129
+ ## Conventions, Forbidden Patterns, AI Rules, Quality Gates
130
+
131
+ Governed in full by the technical rule files; this file does not duplicate them.
132
+
133
+ - Naming & coding conventions, the Forbidden Patterns, and the CI Quality Gates:
134
+ `guardrails/technology/java-spring/coding-standards.md`
135
+ - Package governance (approved/banned packages, supply-chain, licensing):
136
+ `guardrails/technology/java-spring/dependency-policy.md`
137
+ - AI operational rules (generation, context loading, refusal conditions):
138
+ `guardrails/technology/java-spring/ai-rules.md` — the domain half extends this with domain-specific masking,
139
+ code-set and refusal rules
140
+
141
+ ## Governance
142
+
143
+ - This constitution supersedes all other engineering documentation in the repository. Where they
144
+ disagree, this document wins; a rule file that contradicts a principle here is the file that
145
+ gets corrected.
146
+ - Amendments are proposed via pull request that modifies this file (and the affected rule
147
+ files), includes a migration plan for non-compliant code, bumps the version per the policy
148
+ below, and is approved per the roles named in `domain-constitution.md`'s Governance Overrides
149
+ (at minimum one Principal Engineer + the domain's mandatory approver).
150
+ - Versioning follows SemVer applied to governance:
151
+ - **MAJOR** — removal or weakening of a NON-NEGOTIABLE principle, or a backward-incompatible
152
+ change to the Mandatory Folder Structure.
153
+ - **MINOR** — addition of a new principle, new mandatory section, or new bounded context.
154
+ - **PATCH** — clarifications, wording fixes, non-semantic edits.
155
+ - This file versions independently of `domain-constitution.md` and `ui-constitution.md`.
156
+ - Compliance review happens on every PR. Reviewers MUST cite the principle number when
157
+ requesting changes.
158
+ - A quarterly architecture and security review MUST audit a random sample of modules against
159
+ this constitution and file remediation tickets for any deviation.
160
+ - Runtime guidance files MUST carry a single pointer to the ratified constitution and MUST NOT
161
+ duplicate or paraphrase its rules.
162
+ - Domain-specific governance overrides (approver roles, regulatory review triggers, control
163
+ mappings) are supplied by `domain-constitution.md`.
164
+
165
+ ## Ratification Metadata
166
+
167
+ > Carried into `constitution.technical.md` at ratification; the constitution command owns the
168
+ > version bump from there.