@eventmodelers/cli 1.0.44 → 1.0.46

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 (108) hide show
  1. package/README.md +4 -1
  2. package/cli.js +53 -1
  3. package/package.json +2 -2
  4. package/shared/build-kit/lib/checks/README.md +59 -0
  5. package/shared/build-kit/lib/ralph.js +110 -28
  6. package/shared/build-kit/lib/util/find-slice.cjs +59 -0
  7. package/shared/build-kit/ralph-claude.js +6 -2
  8. package/stacks/blank/templates/build-kit/lib/backend-prompt.md +106 -102
  9. package/stacks/blank/templates/build-kit/lib/prompt.md +102 -106
  10. package/stacks/kurrent/templates/.claude/skills/build-automation/SKILL.md +422 -0
  11. package/stacks/kurrent/templates/.claude/skills/build-automation/references/feature-flag-patterns.md +19 -0
  12. package/stacks/kurrent/templates/.claude/skills/build-automation/references/idempotent-dispatch-patterns.md +65 -0
  13. package/stacks/kurrent/templates/.claude/skills/build-state-change/SKILL.md +418 -0
  14. package/stacks/kurrent/templates/.claude/skills/build-state-change/references/feature-flag-patterns.md +41 -0
  15. package/stacks/kurrent/templates/.claude/skills/build-state-change/references/integration-test-patterns.md +64 -0
  16. package/stacks/kurrent/templates/.claude/skills/build-state-view/SKILL.md +391 -0
  17. package/stacks/kurrent/templates/build-kit/CLAUDE.md +122 -0
  18. package/stacks/kurrent/templates/build-kit/lib/AGENT.md +73 -0
  19. package/stacks/kurrent/templates/build-kit/lib/backend-prompt.md +169 -0
  20. package/stacks/kurrent/templates/build-kit/lib/prompt.md +128 -0
  21. package/stacks/kurrent/templates/root/README.md +46 -0
  22. package/stacks/kurrent/templates/root/docker-compose.yml +45 -0
  23. package/stacks/kurrent/templates/root/mvnw +259 -0
  24. package/stacks/kurrent/templates/root/mvnw.cmd +149 -0
  25. package/stacks/kurrent/templates/root/pom.xml +152 -0
  26. package/stacks/kurrent/templates/root/src/main/java/com/example/quickstart/QuickstartApplication.java +12 -0
  27. package/stacks/kurrent/templates/root/src/main/java/com/example/quickstart/common/EventStore.java +91 -0
  28. package/stacks/kurrent/templates/root/src/main/java/com/example/quickstart/config/KurrentConfiguration.java +42 -0
  29. package/stacks/kurrent/templates/root/src/main/resources/application.properties +14 -0
  30. package/stacks/kurrent/templates/root/src/main/resources/static/index.html +11 -0
  31. package/stacks/modeling-kit/templates/.claude/skills/eventmodeling-core-rules/SKILL.md +4 -2
  32. package/stacks/modeling-kit/templates/.claude/skills/eventmodeling-identifying-outputs/SKILL.md +1 -1
  33. package/stacks/modeling-kit/templates/.claude/skills/eventmodeling-orchestrating-event-modeling/SKILL.md +1 -1
  34. package/stacks/modeling-kit/templates/.claude/skills/eventmodeling-slicing-event-models/SKILL.md +2 -0
  35. package/stacks/modeling-kit/templates/.claude/skills/place-element/SKILL.md +1 -1
  36. package/stacks/node/templates/build-kit/CLAUDE.md +22 -0
  37. package/stacks/node/templates/build-kit/lib/check-commit-scope.cjs +123 -0
  38. package/stacks/node/templates/build-kit/lib/checks/00-blocked-paths.cjs +28 -0
  39. package/stacks/node/templates/build-kit/lib/checks/10-slice-scope.cjs +29 -0
  40. package/stacks/node/templates/build-kit/lib/checks/20-append-only-migrations.cjs +20 -0
  41. package/stacks/node/templates/build-kit/lib/checks/30-test-file-present.cjs +44 -0
  42. package/stacks/node/templates/build-kit/lib/checks/40-no-invented-fields.cjs +92 -0
  43. package/stacks/node/templates/build-kit/lib/checks/50-spec-coverage.cjs +50 -0
  44. package/stacks/node/templates/build-kit/lib/checks/90-tsc-build.cjs +22 -0
  45. package/stacks/node/templates/root/.githooks/pre-commit +11 -0
  46. package/stacks/node/templates/root/README.md +67 -0
  47. package/stacks/node/templates/root/package.json +2 -1
  48. package/stacks/node/templates/root/setup-env.sh +7 -1
  49. package/stacks/opencqrs/templates/.claude/skills/build-automation/SKILL.md +434 -0
  50. package/stacks/opencqrs/templates/.claude/skills/build-automation/references/feature-flag-patterns.md +19 -0
  51. package/stacks/opencqrs/templates/.claude/skills/build-automation/references/idempotent-dispatch-patterns.md +62 -0
  52. package/stacks/opencqrs/templates/.claude/skills/build-state-change/SKILL.md +413 -0
  53. package/stacks/opencqrs/templates/.claude/skills/build-state-change/references/feature-flag-patterns.md +46 -0
  54. package/stacks/opencqrs/templates/.claude/skills/build-state-change/references/rest-api-patterns.md +145 -0
  55. package/stacks/opencqrs/templates/.claude/skills/build-state-change/references/test-fixture-patterns.md +85 -0
  56. package/stacks/opencqrs/templates/.claude/skills/build-state-view/SKILL.md +354 -0
  57. package/stacks/opencqrs/templates/build-kit/CLAUDE.md +101 -0
  58. package/stacks/opencqrs/templates/build-kit/lib/AGENT.md +58 -0
  59. package/stacks/opencqrs/templates/build-kit/lib/backend-prompt.md +169 -0
  60. package/stacks/opencqrs/templates/build-kit/lib/prompt.md +128 -0
  61. package/stacks/opencqrs/templates/root/README.md +42 -0
  62. package/stacks/opencqrs/templates/root/docker-compose.yml +37 -0
  63. package/stacks/opencqrs/templates/root/mvnw +259 -0
  64. package/stacks/opencqrs/templates/root/mvnw.cmd +149 -0
  65. package/stacks/opencqrs/templates/root/pom.xml +139 -0
  66. package/stacks/opencqrs/templates/root/src/main/java/com/example/quickstart/QuickstartApplication.java +12 -0
  67. package/stacks/opencqrs/templates/root/src/main/java/com/example/quickstart/config/CqrsConfiguration.java +74 -0
  68. package/stacks/opencqrs/templates/root/src/main/resources/application.properties +23 -0
  69. package/stacks/opencqrs/templates/root/src/main/resources/schema.sql +19 -0
  70. package/stacks/opencqrs/templates/root/src/main/resources/static/index.html +11 -0
  71. package/stacks/supabase/templates/build-kit/CLAUDE.md +25 -0
  72. package/stacks/supabase/templates/build-kit/lib/check-commit-scope.cjs +126 -0
  73. package/stacks/supabase/templates/build-kit/lib/checks/00-blocked-paths.cjs +28 -0
  74. package/stacks/supabase/templates/build-kit/lib/checks/10-slice-scope.cjs +34 -0
  75. package/stacks/supabase/templates/build-kit/lib/checks/20-append-only-migrations.cjs +21 -0
  76. package/stacks/supabase/templates/build-kit/lib/checks/30-test-file-present.cjs +44 -0
  77. package/stacks/supabase/templates/build-kit/lib/checks/40-no-invented-fields.cjs +92 -0
  78. package/stacks/supabase/templates/build-kit/lib/checks/50-spec-coverage.cjs +50 -0
  79. package/stacks/supabase/templates/build-kit/lib/checks/90-tsc-build.cjs +22 -0
  80. package/stacks/supabase/templates/root/.githooks/pre-commit +11 -0
  81. package/stacks/supabase/templates/root/package.json +2 -1
  82. package/stacks/supabase/templates/root/setup-env.sh +7 -1
  83. package/stacks/umadb/templates/.claude/skills/build-automation/SKILL.md +313 -0
  84. package/stacks/umadb/templates/.claude/skills/build-automation/references/feature-flag-patterns.md +42 -0
  85. package/stacks/umadb/templates/.claude/skills/build-state-change/SKILL.md +376 -0
  86. package/stacks/umadb/templates/.claude/skills/build-state-change/references/feature-flag-patterns.md +42 -0
  87. package/stacks/umadb/templates/.claude/skills/build-state-change/references/umadb-query-patterns.md +78 -0
  88. package/stacks/umadb/templates/.claude/skills/build-state-view/SKILL.md +338 -0
  89. package/stacks/umadb/templates/build-kit/CLAUDE.md +94 -0
  90. package/stacks/umadb/templates/build-kit/lib/AGENT.md +47 -0
  91. package/stacks/umadb/templates/build-kit/lib/backend-prompt.md +169 -0
  92. package/stacks/umadb/templates/build-kit/lib/prompt.md +128 -0
  93. package/stacks/umadb/templates/root/.mvn/wrapper/maven-wrapper.properties +19 -0
  94. package/stacks/umadb/templates/root/README.md +48 -0
  95. package/stacks/umadb/templates/root/docker-compose.yml +29 -0
  96. package/stacks/umadb/templates/root/mvnw +259 -0
  97. package/stacks/umadb/templates/root/mvnw.cmd +149 -0
  98. package/stacks/umadb/templates/root/pom.xml +151 -0
  99. package/stacks/umadb/templates/root/src/main/java/io/umadb/quickstart/QuickstartApplication.java +12 -0
  100. package/stacks/umadb/templates/root/src/main/java/io/umadb/quickstart/config/UmaDbConfig.java +39 -0
  101. package/stacks/umadb/templates/root/src/main/java/io/umadb/quickstart/eventstore/DecisionModelLoader.java +76 -0
  102. package/stacks/umadb/templates/root/src/main/java/io/umadb/quickstart/eventstore/EventCodec.java +40 -0
  103. package/stacks/umadb/templates/root/src/main/java/io/umadb/quickstart/eventstore/EventDispatcher.java +100 -0
  104. package/stacks/umadb/templates/root/src/main/java/io/umadb/quickstart/eventstore/OptimisticConcurrencyException.java +14 -0
  105. package/stacks/umadb/templates/root/src/main/java/io/umadb/quickstart/eventstore/SliceEventListener.java +23 -0
  106. package/stacks/umadb/templates/root/src/main/resources/application.properties +17 -0
  107. package/stacks/umadb/templates/root/src/test/java/io/umadb/quickstart/testsupport/InMemoryUmaDbClient.java +135 -0
  108. package/stacks/umadb/templates/root/src/test/resources/application.properties +8 -0
@@ -0,0 +1,338 @@
1
+ ---
2
+ name: build-state-view
3
+ authors:
4
+ - Martin Dilger
5
+ description: >
6
+ Implement read slices (JPA-backed projections + query method + REST API + tests) that react to
7
+ events off the shared EventDispatcher subscription, in this project's one established pattern:
8
+ Query record → JPA entity/repository → @Component Projector implementing SliceEventListener →
9
+ plain on(event)/handle(query) unit test (no client, no Spring context). Use when implementing a
10
+ new read slice / projection from a slice.json event model in this project. There is exactly one
11
+ supported style — do not offer alternatives.
12
+ ---
13
+
14
+ # UmaDB — Read Slice
15
+
16
+ Grounded in the `AllCustomers` slice (test in `AllCustomersProjectorTest`) — verified, compiled and
17
+ passing under `mvn test`, including the one Testcontainers-based end-to-end test
18
+ (`UmaDbContainerIntegrationTest`) that proves a real `umadb/umadb:0.7.5` server, `EventDispatcher`'s
19
+ live subscription, and this JPA projection all wire together correctly for real.
20
+
21
+ UmaDB has no read-model/projection concept of its own (no `@EventHandler`, no query bus) — a read
22
+ slice here is entirely this project's own convention, built on the shared `eventstore` package:
23
+ `SliceEventListener` is the interface every projector implements, and `EventDispatcher` (already in
24
+ the root scaffold, already proven — see below) is the ONE shared subscription that fans events out
25
+ to every projector and automation processor in the app. **You do not need to write a new
26
+ subscription or a new Testcontainers test for each read slice** — just implement
27
+ `SliceEventListener` and `EventDispatcher` picks it up automatically as a Spring bean.
28
+
29
+ ## Step 0: Discover Target Project Conventions
30
+
31
+ > **Comments & description**: each element carries a `comments: string[]` array (board comments)
32
+ > and a `description` field — use them as implementation hints, and resolve consumed comments via
33
+ > `POST <BASE_URL>/api/org/<ORG_ID>/boards/<BOARD_ID>/nodes/<nodeId>/comments/<commentId>/resolve`.
34
+
35
+ Before writing any code, read the target project's `.build-kit/CLAUDE.md`.
36
+
37
+ **Determine `{basePackage}`** — every code example below is rooted at
38
+ `{basePackage}.slices.{context}.{slicename}`. Resolve `{basePackage}` as documented there.
39
+
40
+ ## Step 1: Ensure Events Exist
41
+
42
+ Before implementing the read slice, verify that every event the projector reacts to already exists
43
+ in `src/main/java/.../{context}/events/`. If one doesn't, create it first following
44
+ `build-state-change` Step 2 (sealed interface + concrete record + `TYPE` constant + `EventTags`
45
+ entry) — a read slice never invents its own copy of an event another slice already owns.
46
+
47
+ ## Step 2: Implement the Read Slice
48
+
49
+ If the slice details include `## Scenarios (GWTs)`, use them to derive test cases. GWT format for
50
+ read slices: `Given (events) → Then (information)` — no When. Events in Given tell you which events
51
+ the projector reacts to. The information element in Then describes the expected query result.
52
+
53
+ If the slice description or comments contain `## Implementation Guidelines`, **follow them**.
54
+
55
+ A read slice lives in a single package. **Do NOT add Domain/Application/Presentation section
56
+ comments** — those are only for write slices. Read slices are never feature-flagged (no
57
+ `@ConditionalOnProperty`) — unlike write and automation slices.
58
+
59
+ ### Slice package structure
60
+
61
+ ```
62
+ .../slices/{context}/{slicename}/ (i.e. {basePackage}.slices.{context}.{slicename} — see Step 0)
63
+ ├── Get{SliceName}.java ← query record + nested Result
64
+ ├── {SliceName}Summary.java ← read model (projection output shape)
65
+ ├── {SliceName}Entity.java ← JPA entity, package-private
66
+ ├── {SliceName}Repository.java ← package-private JpaRepository
67
+ ├── {SliceName}Projector.java ← @Component, implements SliceEventListener
68
+ └── {SliceName}RestApi.java ← @RestController (if REST chosen)
69
+ ```
70
+
71
+ ### Query record
72
+
73
+ ```java
74
+ package {basePackage}.slices.{context}.{slicename};
75
+
76
+ import java.util.List;
77
+
78
+ public record Get{SliceName}({filterField type} {filterField}) {
79
+
80
+ public record Result(List<{SliceName}Summary> items) {}
81
+ }
82
+ ```
83
+
84
+ No `@Query` annotation exists in this project (UmaDB has nothing like Axon's query bus) — the
85
+ record is just this slice's own input/output shape, called directly (see Step 3's `RestApi`).
86
+
87
+ ### Read model summary
88
+
89
+ ```java
90
+ public record {SliceName}Summary(String field1, String field2) {}
91
+ ```
92
+
93
+ ### JPA entity + repository
94
+
95
+ Projections persist to a database via Spring Data JPA — this is the only supported style. Verified
96
+ against `AllCustomersEntity`/`AllCustomersRepository`:
97
+
98
+ ```java
99
+ package {basePackage}.slices.{context}.{slicename};
100
+
101
+ import jakarta.persistence.Entity;
102
+ import jakarta.persistence.Id;
103
+ import jakarta.persistence.Table;
104
+
105
+ @Entity
106
+ @Table(name = "{context}_{slicename}")
107
+ class {SliceName}Entity {
108
+
109
+ @Id
110
+ private String id;
111
+ private String field1;
112
+
113
+ protected {SliceName}Entity() {
114
+ }
115
+
116
+ {SliceName}Entity(String id, String field1) {
117
+ this.id = id;
118
+ this.field1 = field1;
119
+ }
120
+
121
+ {SliceName}Summary toSummary() {
122
+ return new {SliceName}Summary(id, field1);
123
+ }
124
+ }
125
+ ```
126
+
127
+ ```java
128
+ package {basePackage}.slices.{context}.{slicename};
129
+
130
+ import org.springframework.data.jpa.repository.JpaRepository;
131
+
132
+ interface {SliceName}Repository extends JpaRepository<{SliceName}Entity, String> {
133
+ }
134
+ ```
135
+
136
+ For filtered queries, add an indexed column and a derived-query method instead of `findAll()` —
137
+ `@Table(indexes = {@Index(...)})` plus `List<{SliceName}Entity> findAllBy{FilterField}(String {filterField})`,
138
+ used from the `@QueryHandler`-equivalent method below. DB-level filtering, not client-side.
139
+
140
+ ### Projector — implements `SliceEventListener`
141
+
142
+ ```java
143
+ package {basePackage}.slices.{context}.{slicename};
144
+
145
+ import io.umadb.client.Event;
146
+ import {basePackage}.eventstore.EventCodec;
147
+ import {basePackage}.eventstore.SliceEventListener;
148
+ import {basePackage}.slices.{context}.events.{EventName};
149
+ import org.springframework.stereotype.Component;
150
+
151
+ import java.util.List;
152
+
153
+ @Component
154
+ public class {SliceName}Projector implements SliceEventListener {
155
+
156
+ private final {SliceName}Repository repository;
157
+
158
+ public {SliceName}Projector({SliceName}Repository repository) {
159
+ this.repository = repository;
160
+ }
161
+
162
+ @Override
163
+ public boolean supports(String eventType) {
164
+ return {EventName}.TYPE.equals(eventType);
165
+ }
166
+
167
+ @Override
168
+ public void onEvent(Event event) {
169
+ on(EventCodec.fromEvent(event, {EventName}.class));
170
+ }
171
+
172
+ /** Called directly (no client, no dispatcher) by {SliceName}ProjectorTest - see Step 4. */
173
+ public void on({EventName} event) {
174
+ repository.save(new {SliceName}Entity(event.idField(), event.field1()));
175
+ }
176
+
177
+ public Get{SliceName}.Result handle(Get{SliceName} query) {
178
+ List<{SliceName}Summary> items = repository.findAll().stream()
179
+ .map({SliceName}Entity::toSummary)
180
+ .toList();
181
+ return new Get{SliceName}.Result(items);
182
+ }
183
+ }
184
+ ```
185
+
186
+ `supports`/`onEvent` are the only two methods `EventDispatcher` calls — everything else (`on`,
187
+ `handle`) is this projector's own API, called directly by tests and by the REST layer. Multiple
188
+ event types: repeat the `event.type().equals(...)` check in `supports`, and add one more public
189
+ `on(OtherEvent event)` overload.
190
+
191
+ ### Result DTO rules
192
+
193
+ - If the read model matches the query result **1:1**, expose the summary record directly.
194
+ - If the read model contains fields the caller already knows from the query (e.g. the filter
195
+ field), omit those from `Result` and map from the projector's internal model.
196
+
197
+ ## Step 3: REST API Exposure (Optional)
198
+
199
+ Check the target project's convention first.
200
+
201
+ ```java
202
+ package {basePackage}.slices.{context}.{slicename};
203
+
204
+ import org.springframework.web.bind.annotation.GetMapping;
205
+ import org.springframework.web.bind.annotation.RestController;
206
+
207
+ @RestController
208
+ public class {SliceName}RestApi {
209
+
210
+ private final {SliceName}Projector projector;
211
+
212
+ public {SliceName}RestApi({SliceName}Projector projector) {
213
+ this.projector = projector;
214
+ }
215
+
216
+ @GetMapping("/api/{context}/{resource}")
217
+ public Get{SliceName}.Result query() {
218
+ return projector.handle(new Get{SliceName}());
219
+ }
220
+ }
221
+ ```
222
+
223
+ Plain Spring MVC, not WebFlux — same reasoning as `build-state-change` Step 5.
224
+
225
+ ## Step 4: Implement the Slice Test
226
+
227
+ Pure unit test — instantiate the projector directly with a `@DataJpaTest`-provided repository, no
228
+ `UmaDbClient` and no `EventDispatcher` involved. `@DataJpaTest` gives a real (embedded H2, not
229
+ Testcontainers) JPA repository without a full Spring Boot application context:
230
+
231
+ ```java
232
+ package {basePackage}.slices.{context}.{slicename};
233
+
234
+ import {basePackage}.slices.{context}.events.{EventName};
235
+ import org.junit.jupiter.api.BeforeEach;
236
+ import org.junit.jupiter.api.DisplayName;
237
+ import org.junit.jupiter.api.Test;
238
+ import org.springframework.beans.factory.annotation.Autowired;
239
+ import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
240
+
241
+ import static org.assertj.core.api.Assertions.assertThat;
242
+
243
+ @DataJpaTest
244
+ class {SliceName}ProjectorTest {
245
+
246
+ @Autowired
247
+ private {SliceName}Repository repository;
248
+
249
+ private {SliceName}Projector projector;
250
+
251
+ @BeforeEach
252
+ void setUp() {
253
+ projector = new {SliceName}Projector(repository);
254
+ }
255
+
256
+ @Test
257
+ @DisplayName("given no events, when query, then empty result")
258
+ void emptyState() {
259
+ var result = projector.handle(new Get{SliceName}());
260
+
261
+ assertThat(result.items()).isEmpty();
262
+ }
263
+
264
+ @Test
265
+ @DisplayName("given a {EventName} event, then it appears in the result")
266
+ void creationEvent() {
267
+ projector.on(new {EventName}("id-1", "value1"));
268
+
269
+ var result = projector.handle(new Get{SliceName}());
270
+
271
+ assertThat(result.items()).containsExactly(new {SliceName}Summary("id-1", "value1"));
272
+ }
273
+ }
274
+ ```
275
+
276
+ Add a `com.h2database:h2` test-scope dependency once, project-wide, if it isn't already there
277
+ (already in the root scaffold's `pom.xml`).
278
+
279
+ ### Mapping GWT Scenarios to Tests
280
+
281
+ | GWT Element | Test Code |
282
+ |---|---|
283
+ | `NOTHING` in Given | instantiate projector, call `handle(query)` directly |
284
+ | Event in Given | call `projector.on(event)` |
285
+ | Information in Then | `assertThat(result.items()).containsExactlyInAnyOrder(...)` |
286
+
287
+ ## Step 4b: Storyline-Derived Tests (Optional)
288
+
289
+ `slice.json` may also carry a `storylines[]` array — narrated walkthroughs where the *same* read
290
+ model appears as multiple ordered "beats" across one flow. This is a secondary, supplementary
291
+ source: `specifications[]` (Step 4) remains the primary and default source of test cases. Most
292
+ slices have no `storylines[]` — skip this step silently when there's nothing relevant.
293
+
294
+ For each storyline, find beats whose `type` is `READMODEL`. Two such beats **adjacent with only
295
+ `EVENT` beat(s) between them** describe one clean, isolable projection test — events = the
296
+ cumulative ordered `EVENT` beats through the intervening event(s), expected result = the later
297
+ `READMODEL` beat's `fields`/`examples`/`expectEmptyList`. Keep these in a `@Nested` class named
298
+ after the storyline's title:
299
+
300
+ ```java
301
+ @Nested
302
+ @DisplayName("Storyline: {storyline.title}")
303
+ class StorylineTests {
304
+ @Test
305
+ @DisplayName("after {EventName}, read model shows {expected state}")
306
+ void beatTransition() {
307
+ projector.on(new {EventName}(/* fields from the intervening beat(s) */));
308
+
309
+ var result = projector.handle(new Get{SliceName}());
310
+
311
+ assertThat(result.items()).containsExactly(/* expected shape from the later beat */);
312
+ }
313
+ }
314
+ ```
315
+
316
+ If a beat between two read-model states is a `COMMAND` rather than an `EVENT`, that half belongs to
317
+ `build-state-change` (its own command-handler test), not here.
318
+
319
+ ## Reference: Proving `EventDispatcher` Itself (already done — don't repeat per slice)
320
+
321
+ `{basePackage}.eventstore.EventDispatcher` (root scaffold) is the ONE shared live subscription every
322
+ projector and automation reacts through — it's already proven end-to-end against a real
323
+ `umadb/umadb:0.7.5` server via Testcontainers (`UmaDbContainerIntegrationTest`, verified against
324
+ `AllCustomersProjector` + `AutoSubscribeToDefaultCourseProcessor`). A new read slice does not need
325
+ its own Testcontainers test — implementing `SliceEventListener` correctly (Step 2) and unit-testing
326
+ `on(event)`/`handle(query)` directly (Step 4) is sufficient; `EventDispatcher` will deliver real
327
+ events to it in production exactly as it does for the already-verified slices.
328
+
329
+ ## Final Verification: Does the Implementation Match slice.json?
330
+
331
+ Before marking this slice as `Done`, verify the implementation against slice.json:
332
+
333
+ - [ ] Every field in the read model / query result definition in slice.json has a field in `{SliceName}Summary` — no invented fields
334
+ - [ ] Every event type in `events[]` has a `type().equals(...)` check in `supports` and a matching `on(...)` overload — no events missed or assumed
335
+ - [ ] Every GWT scenario in `specifications[]` maps to a test case in `{SliceName}ProjectorTest`
336
+ - [ ] If `storylines[]` is present: every adjacent READMODEL↔READMODEL beat pair for this slice's read model (with only EVENT beats between) has a `@Nested` storyline test — or was deliberately skipped as untraceable
337
+ - [ ] No extra query parameters or filter logic were added beyond what slice.json defines
338
+ - [ ] No field names were assumed or guessed — if a field is not in slice.json, it is not in the code
@@ -0,0 +1,94 @@
1
+ # Project Configuration
2
+
3
+ Read events in `src/main/java/<basePackage>/slices/{context}/events/` to understand the global
4
+ structure - one sealed event interface plus an `EventTags` class per context.
5
+
6
+ `<basePackage>` in this project's Java code (`src/main/java/<basePackage>/slices/...`) is this
7
+ project's own Java package prefix, not a fixed value - resolve it, in order: (1) the package of the
8
+ project's `@SpringBootApplication` class, (2) the package of any existing slice already under
9
+ `.../slices/{context}/{slicename}/`, (3) only if no code exists yet, Maven's `<groupId>` in
10
+ `pom.xml`. Never hardcode `io.umadb.quickstart` (the shipped quickstart scaffold's package) or any
11
+ other specific package.
12
+
13
+ ## File Structure Constraints
14
+
15
+ - **Strict Path Limitation**: if not instructed otherwise, only check
16
+ `src/main/java/<basePackage>/slices/{context}/{slicename}/*.java` and its test counterpart under
17
+ `src/test/java/...`
18
+ - **Slice Organization**: each feature/domain is a separate slice, flat under its context - no
19
+ `write`/`read`/`automation` folder layer in between (only the shared `slices/{context}/events/`
20
+ folder sits alongside slice folders, and automations live under `slices/{context}/automation/{slicename}/`)
21
+
22
+ ## Code Standards
23
+
24
+ - **Language**: Java 21
25
+ - **Module System**: standard Maven `src/main/java` / `src/test/java` layout
26
+ - **Framework**: Spring Boot (plain MVC, not WebFlux - UmaDB's client API is blocking)
27
+ - **Type Safety**: commands, events, and query/result types are records; decision models and
28
+ projectors are plain classes
29
+
30
+ ## Development Guidelines
31
+
32
+ 1. Each slice should be self-contained and focused on a specific domain
33
+ 2. Maintain clear separation of concerns within each slice
34
+ 3. Reuse the shared `eventstore` package's infrastructure (`DecisionModelLoader`, `EventCodec`,
35
+ `SliceEventListener`, `EventDispatcher`) rather than re-implementing the read/append or
36
+ subscribe/dispatch loop per slice - see each build skill's own reference to that infrastructure
37
+
38
+ Ignore case for files and slices in prompts. "CartItems" slice is the same as "cartitems".
39
+
40
+ Do not change test files unless explicitly instructed.
41
+
42
+ At the start of every session, read `.build-kit/AGENTS.md` if it exists to load accumulated project learnings.
43
+
44
+ When starting to work on a slice, invoke the `update-slice-status` skill with `InProgress` status before doing anything else.
45
+
46
+ ## Building a Slice
47
+
48
+ **CRITICAL: You MUST always use the provided skills to build slices. NEVER implement a slice manually.**
49
+ **ALL fields, event names, command names, and business rules MUST come exclusively from slice.json. Do NOT invent, assume, or guess any field or logic not present in the slice definition.**
50
+
51
+ **If, at any point below, the slice's requirements are genuinely ambiguous, contradictory, or missing
52
+ a decision you need in order to proceed — do not guess, and do not build anyway.** Invoke the
53
+ `request-feedback` skill with the specific question; it posts the question as a comment on the slice
54
+ and marks it `Blocked`, and you then stop work on this slice for this run. This is an escalation path,
55
+ not a routine step — read `slice.json` and the matching build skill's own instructions fully first;
56
+ most slices are fully specified and need none of this.
57
+
58
+ When asked to build a slice, always follow this flow:
59
+
60
+ 1. Read the slice definition from `.build-kit/.slices/<context>/<slicename>/slice.json`.
61
+ 2. Determine the slice type:
62
+ - **Translation** — `sliceType === "TRANSLATION"` → read `description` and `notes` from slice.json for hints; default to `/build-automation` if nothing else is specified
63
+ - **Automation** — `processors` array is non-empty → invoke `/build-automation`
64
+ - **State-view** — `projections` or `queries` array is non-empty → invoke `/build-state-view`
65
+ - **State-change** — default (has `commands` / `events`) → invoke `/build-state-change`
66
+ 3. Invoke the matching skill and follow its instructions completely. Do not deviate.
67
+ 4. **Verify against slice.json**: After the skill completes, check that every command field, event field, and specification in slice.json appears in the implementation. No invented fields — if it is not in slice.json, it must not be in the code.
68
+ 5. Run quality checks (`./mvnw compile -q`, then the slice tests only).
69
+ 6. If checks pass, commit with `feat: [Slice Name]` and set slice status to `Done`.
70
+
71
+ After you are done, automatically run the tests for the slice that was edited.
72
+
73
+ ## Example Slice Structure
74
+
75
+ ```
76
+ src/main/java/<basePackage>/slices/
77
+ ├── {context}/
78
+ │ ├── events/
79
+ │ │ ├── {Context}Event.java ← sealed interface every event in this context implements
80
+ │ │ └── EventTags.java ← "key:value" tag-string constants for this context
81
+ │ ├── {slicename}/ ← write slice (build-state-change)
82
+ │ │ ├── {SliceName}Command.java
83
+ │ │ ├── {SliceName}Decision.java ← package-private, mutable
84
+ │ │ ├── {SliceName}CommandHandler.java
85
+ │ │ └── {SliceName}RestController.java (only if a SCREEN depends on the command)
86
+ │ ├── {slicename}/ ← read slice (build-state-view)
87
+ │ │ ├── Get{SliceName}.java ← query record + nested Result
88
+ │ │ ├── {SliceName}Summary.java ← read model shape
89
+ │ │ ├── {SliceName}Entity.java + {SliceName}Repository.java ← JPA
90
+ │ │ ├── {SliceName}Projector.java ← implements SliceEventListener
91
+ │ │ └── {SliceName}RestApi.java
92
+ │ └── automation/{slicename}/ ← automation slice (build-automation)
93
+ │ └── {AutomationName}Processor.java ← implements SliceEventListener
94
+ ```
@@ -0,0 +1,47 @@
1
+ # Agent Learnings
2
+
3
+ Patterns and gotchas discovered during task processing. Update this file whenever you encounter something reusable.
4
+
5
+ ## tasks.json
6
+
7
+ - Tasks are objects with `id`, `createdAt`, and `payload` (a `SliceChangedPayload`).
8
+ - After completing a task, remove it from the array entirely — do not add a status field.
9
+ - Write `[]` to `tasks.json` if the last task is completed.
10
+
11
+ ## SliceChangedPayload fields
12
+
13
+ ```
14
+ event always "slice:changed"
15
+ organizationId org UUID or null
16
+ boardId board UUID
17
+ sliceId SLICE_BORDER node UUID — use this with /load-slice
18
+ sliceTitle human-readable slice name (may be null)
19
+ sliceStatus e.g. "Created", "InProgress", "Done", "Blocked" (may be null)
20
+ timestamp unix ms when the change was emitted
21
+ ```
22
+
23
+ ## Slice files
24
+
25
+ The realtime agent writes one file per slice on startup and after each `slice:changed` event:
26
+
27
+ ```
28
+ .slices/<context>/<sliceName>/slice.json
29
+ ```
30
+
31
+ - `<context>` is the slice's context value, or `default` if none.
32
+ - `<sliceName>` is the slice title lowercased with spaces removed (e.g. `"Enable User"` → `enableuser`).
33
+
34
+ These files are always up to date — read them directly before invoking any skill.
35
+
36
+ ## Skill Usage
37
+
38
+ - Always run `/connect` first to load credentials from `.eventmodelers/config.json` before calling any other skill.
39
+ - `/load-slice sliceId=<uuid>` re-fetches all slices from the API, refreshes the slice files, and returns the requested slice. Use it when you need a guaranteed-fresh view of a specific slice.
40
+ - Read `.slices/<context>/<sliceName>/slice.json` directly when you already know the context and name and the file is recent enough.
41
+
42
+ ## Board API
43
+
44
+ - The `boardId` and `organizationId` from each payload provide full context — pass them to skills.
45
+ - Node events use `node:created`, `node:changed`, `node:deleted` — always POST to `/api/org/:orgId/boards/:boardId/nodes/events`.
46
+ - Slice metadata (title, status) lives on the SLICE_BORDER node under `meta.sliceStatus` and `meta.title`.
47
+ - `/update-slice-status` rejects moving a slice into a status it's already in — this is a concurrency guard, not a bug. It means another agent already claimed the slice. Treat it as `ALREADY_IN_STATUS`, skip that slice, and move on to the next `Planned` one instead of erroring out.
@@ -0,0 +1,169 @@
1
+ # Ralph Agent Instructions
2
+
3
+ You are an autonomous coding agent working on a software project. You apply your skills to build software slices. You only work on one slice at a time.
4
+
5
+ The structure defined in the Project-Skills is relevant.
6
+
7
+ ## Context Boundary (READ FIRST — NON-NEGOTIABLE)
8
+
9
+ You work within **exactly ONE context at a time** — the one named in `.build-kit/.slices/current_context.json`.
10
+
11
+ - **ONLY** look for and build slices inside `.build-kit/.slices/<currentContext>/`.
12
+ - **NEVER** read, scan, or build slices from any other context directory, even if it has "Planned" slices, and even if the current context has no work left.
13
+ - A "Planned" slice in a *different* context (e.g. "Rename organization" while you are in "Board Invitations") is **NOT yours to build**. Ignore it completely.
14
+ - If the current context has no "Planned" slice, you are **done for this iteration** — reply `<promise>NO_TASKS</promise>` and stop. Do not go looking elsewhere. The context is only ever changed on the board, never by you.
15
+
16
+ ## Your Task
17
+
18
+ 0. Do not read the entire code base. Focus on the tasks in this description.
19
+ 1. Read `.build-kit/.slices/current_context.json` to find the active context name, then read `.build-kit/.slices/<contextName>/index.json`. Every item in status "planned" is a task.
20
+ 2. Read the progress log at `progress.txt` (check Codebase Patterns section first)
21
+ 3. Make sure you are on the right branch "feature/<slicename>", if unsure, start from main.
22
+ 5. Pick the **highest priority** slice where status is **exactly** "Planned" (case insensitive). This becomes your PRD. Set the status "InProgress" in the index.json **and** update the slice status on the eventmodelers board using the `update-slice-status` skill (or MCP if available).
23
+ **IMPORTANT: Only work on slices with status "Planned" in the CURRENT context. Never pick up a slice that is "InProgress", "Done", "Blocked", "Created", or any other status — even if it looks incomplete. If no slice has status "Planned" in the current context, reply with:**
24
+ <promise>NO_TASKS</promise> and stop immediately. Do not work on other slices and do not switch to another context.
25
+ **Claim conflict**: the board rejects the status update if the slice is already in the target status — this is expected: another agent claimed it first, racing you for the same slice. This is NOT an error. Do not stop, do not retry the same slice. Re-read `index.json` (or re-fetch via `load-slice`), pick the next-highest-priority slice still "Planned", and try claiming that one instead. Repeat until a claim succeeds or no "Planned" slice remains, in which case reply `<promise>NO_TASKS</promise>`.
26
+ 6. Pick the slice definition from `.build-kit/.slices/<contextName>/<folder>/slice.json` as defined in the prd. Never work on more than one slice per iteration.
27
+ 7. A slice can define additional prompts as codegen/backendPrompt. any additional prompts defined in backend are hints for the implementation of the slice and have to be taken into account. If you use the additional prompt, add a line in progress.txt
28
+ 7. Define the slice type and load the matching skill:
29
+ - Write slice (has commands, no processors) → `build-state-change`
30
+ - Read slice (has readModel / information flow) → `build-state-view`
31
+ - Translation slice (`sliceType === "TRANSLATION"`) → read `description` and `notes` from slice.json for hints; default to `build-automation` if nothing else is specified
32
+ - Automation slice (processors-array is not empty) → `build-automation`
33
+ 8. Write a short progress one liner after each step to progress.txt
34
+ 9. Analyze and Implement that single slice, make use of the skills in the skills directory, but also your previsously collected
35
+ knowledge. Make a list TODO list for what needs to be done. Also make sure to adjust the implementation according to the json definition. Carefully inspect events, fields and compare against the implemented slice. JSON is the desired state. ATTENTION: A "planned" task can also be just added specifications. So always look at the slice itself, but also the specifications. If specifications were added in json, which are not on code, you need to add them in code.
36
+ 10. The slice in the json is always true, the code follows what is defined in the json
37
+ 11. slice is only 'Done' if business logic is implemented as defined in the JSON, APIs are implemented, all scenarios in JSON are implemented in code and it
38
+ fulfills the slice.json. There must be no specification in json, that has no equivalent in code.
39
+ 12. make sure to write the ui-prompt.md as defined if defined in the skill
40
+ 13. Run quality checks — it is enough to run the tests for the slice only, not all tests:
41
+ - Compile: `./mvnw compile -q`
42
+ - Test: `./mvnw test -Dtest="<SliceName>*" -q`
43
+ If the tests for the slice are not yet named predictably, run `./mvnw test -q` and check for failures.
44
+ 15. If checks pass, commit ALL changes with message: `feat: [Slice Name]` and merge back to main as FF merge ( update
45
+ first )
46
+ 16. Update the PRD to set `status: Done` for the completed story in index.json **and** update the slice status on the eventmodelers board using the `update-slice-status` skill (or MCP if available).
47
+ 17. Append your progress to `progress.txt` after each step in the iteration.
48
+ 18. append your new learnings to `.build-kit/AGENTS.md` in a compressed form, reusable for future iterations. Only add learnings if they are not already there.
49
+ 19. Finish the iteration.
50
+
51
+ ## Escalating Ambiguity
52
+
53
+ **If the slice's requirements are genuinely ambiguous, contradictory, or missing a decision you need
54
+ in order to proceed — do not guess, and do not build anyway.** Invoke `/request-feedback` with the
55
+ specific question; it posts the question as a comment on the slice and marks it `Blocked` on the
56
+ board (overriding the `InProgress` set earlier), then stop this iteration without finishing the
57
+ build — reply `<promise>DONE</promise>` as if the iteration's work was to raise the question, not to
58
+ implement the slice. This is an escalation path, not a routine step — read the slice.json and the
59
+ matching build skill's own instructions fully first; most slices are fully specified and need none of
60
+ this.
61
+
62
+ ## Progress Report Format
63
+
64
+ APPEND to progress.txt (never replace, always append):
65
+
66
+ ```
67
+ ## [Date/Time] - [Slice]
68
+
69
+ - What was implemented
70
+ - Files changed
71
+ - **Learnings for future iterations:**
72
+ - Patterns discovered (e.g., "this codebase uses X for Y")
73
+ - Gotchas encountered (e.g., "don't forget to update Z when changing W")
74
+ - Useful context (e.g., "the evaluation panel is in component X")
75
+ ---
76
+ ```
77
+
78
+ The learnings section is critical - it helps future iterations avoid repeating mistakes and understand the codebase
79
+ better.
80
+
81
+ ## Consolidate Patterns
82
+
83
+ If you discover a **reusable pattern** that future iterations should know, add it to the `## Codebase Patterns` section
84
+ at the TOP of progress.txt (create it if it doesn't exist). This section should consolidate the most important
85
+ learnings:
86
+
87
+ ```
88
+ ## Codebase Patterns
89
+ - Example: Use event sourcing aggregate patterns for all state changes
90
+ - Example: Always use @CommandHandler on the aggregate for write slices
91
+ - Example: Export query result types from the slice package
92
+ ```
93
+
94
+ Only add patterns that are **general and reusable**, not story-specific details.
95
+
96
+ ## Update AGENTS.md Files
97
+
98
+ Before committing, check if any edited files have learnings worth preserving in nearby AGENTS.md files:
99
+
100
+ 1. **Identify directories with edited files** - Look at which directories you modified
101
+ 3. **Add valuable learnings that apply to all tasks** to the Agents.md - If you discovered something future developers/agents should know:
102
+ - API patterns or conventions specific to that module
103
+ - Gotchas or non-obvious requirements
104
+ - Dependencies between files
105
+ - Testing approaches for that area
106
+ - Configuration or environment requirements
107
+
108
+ **Examples of good AGENTS.md additions:**
109
+
110
+ - "When modifying X, also update Y to keep them in sync"
111
+ - "This module uses pattern Z for all API calls"
112
+ - "Tests require the dev server running on PORT 3000"
113
+ - "Field names must match the template exactly"
114
+
115
+ **Do NOT add:**
116
+
117
+ - Slice specific implementation details
118
+ - Story-specific implementation details
119
+ - Temporary debugging notes
120
+ - Information already in progress.txt
121
+ - Task specific learnings
122
+
123
+ Only update AGENTS.md if you have **genuinely reusable knowledge** that would help future work
124
+
125
+ ## Quality Requirements
126
+
127
+ - ALL commits must pass your project's quality checks
128
+ - Compile: `./mvnw compile -q`
129
+ - Test: `./mvnw test -Dtest="<SliceName>*" -q`
130
+ - Do NOT commit broken code
131
+ - Keep changes focused and minimal
132
+ - Follow existing code patterns
133
+
134
+ ## Skills
135
+
136
+ Use the provided skills in the skills folder as guidance.
137
+ Update skill definitions if you find an improvement you can make.
138
+
139
+ ## Specifications
140
+
141
+ For every specification added to the Slice, you need to implement one use executable Specification in Code.
142
+
143
+ A Slice is not complete if specifications are missing or can´t be executed.
144
+
145
+ ## Stop Condition
146
+
147
+ **After completing ONE slice, always stop — regardless of whether more slices are Planned.** The ralph loop will invoke you again for the next slice. Never chain multiple slices in one iteration.
148
+
149
+ If the slice was completed and committed successfully, reply with:
150
+ <promise>DONE</promise>
151
+
152
+ If no slice has status "Planned" in the current context, reply with:
153
+ <promise>NO_TASKS</promise>
154
+ (Do NOT switch to another context to find work — stop here.)
155
+
156
+ If ALL slices in the current context are Done, reply with:
157
+ <promise>COMPLETE</promise>
158
+
159
+ ## Important
160
+
161
+ - If `.build-kit/.eventmodelers/config.json` is absent, skip all platform communication (MCP calls, `update-slice-status`, board sync) and continue working locally.
162
+ - Work on ONE slice per iteration
163
+ - Commit frequently
164
+ - update progress.txt frequently
165
+ - Read the Codebase Patterns section in progress.txt before starting
166
+
167
+ ## When an iteration completes
168
+
169
+ Use all the key learnings from the progress.txt and update the `.build-kit/AGENTS.md` file with those learnings.