interaqt 0.7.3 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,12 @@
2
2
 
3
3
  ## Overview
4
4
 
5
- This guide explains how to analyze data requirements using the new requirement artifacts (`requirements/data-concepts.json` and `requirements/interactions-design.json`) to produce a comprehensive data design for interaqt implementations. The analysis leverages pre-extracted data concepts and interaction specifications to determine entity lifecycles, property dependencies, and computation methods.
5
+ This guide explains how to analyze data requirements using the new requirement artifacts (`requirements/{module}.data-concepts.json`, `requirements/{module}.interactions-design.json`, and `requirements/{module}.integration.json`) to produce a comprehensive data design for interaqt implementations. The analysis leverages pre-extracted data concepts, interaction specifications, and external integration requirements to determine entity lifecycles, property dependencies, and computation methods.
6
+
7
+ **IMPORTANT**: Read the current module name from `.currentmodule` file in project root, and use it to construct the file paths. For example, if `.currentmodule` contains `user-management`, then the paths would be:
8
+ - `requirements/user-management.data-concepts.json`
9
+ - `requirements/user-management.interactions-design.json`
10
+ - `requirements/user-management.integration.json`
6
11
 
7
12
  ## Important Note on Interaction References
8
13
 
@@ -19,26 +24,41 @@ This applies to all interaction-related fields including:
19
24
 
20
25
  ## Input Artifacts
21
26
 
22
- ### 1. requirements/data-concepts.json
27
+ ### 1. requirements/{module}.data-concepts.json
23
28
  Contains pre-extracted data concepts:
24
29
  - **Entities**: Core business objects with their properties
25
30
  - **Relations**: Connections between entities
26
31
  - **Dictionaries**: Global data and system-wide configurations
27
32
  - **Views**: Pre-defined data queries and filters
28
33
 
29
- ### 2. requirements/interactions-design.json
34
+ Note: Replace `{module}` with the value from `.currentmodule` file.
35
+
36
+ ### 2. requirements/{module}.interactions-design.json
30
37
  Contains interaction specifications showing:
31
38
  - **Data operations**: What each interaction creates, reads, updates, or deletes
32
39
  - **Data constraints**: How data is modified or created
33
40
  - **Validation rules**: Business rules and constraints
34
41
 
42
+ Note: Replace `{module}` with the value from `.currentmodule` file.
43
+
44
+ ### 3. requirements/{module}.integration.json
45
+ Contains external system integration requirements:
46
+ - **Integration flows**: Descriptions of interactions with external systems
47
+ - **Asynchronous operations**: Payment processing, AIGC generation, file storage, etc.
48
+ - **System boundaries**: What happens in current system vs external systems
49
+ - **Data flow**: How data moves between systems
50
+
51
+ Note: Replace `{module}` with the value from `.currentmodule` file. This file is used to identify integration event entities for tracking asynchronous external system responses.
52
+
35
53
  ## Analysis Process
36
54
 
37
55
  ### Step 1: Import Core Data Concepts
38
56
 
39
- #### 1.1 Import Entities from requirements/data-concepts.json
57
+ #### 1.1 Import Entities from requirements/{module}.data-concepts.json
58
+
59
+ First, read the module name from `.currentmodule` file in project root to get the current module name.
40
60
 
41
- Read the entities directly from `requirements/data-concepts.json`. Each entity already includes:
61
+ Then read the entities directly from `requirements/{module}.data-concepts.json`. Each entity already includes:
42
62
  - Name and description
43
63
  - Properties with types and purposes
44
64
  - Computed property indicators
@@ -48,21 +68,132 @@ Read the entities directly from `requirements/data-concepts.json`. Each entity a
48
68
 
49
69
  #### 1.2 Import Dictionaries
50
70
 
51
- Read dictionaries from `requirements/data-concepts.json`. These represent:
71
+ Read dictionaries from `requirements/{module}.data-concepts.json`. These represent:
52
72
  - System-wide configurations
53
73
  - Global statistics
54
74
  - Shared validation rules
55
75
  - Cross-entity aggregates
56
76
 
77
+ #### 1.3 Identify Integration Event Entities
78
+
79
+ Read integration requirements from `requirements/{module}.integration.json` (using the module name from `.currentmodule`).
80
+
81
+ **Identify Asynchronous External Calls:**
82
+ For each integration in the file, analyze whether it involves asynchronous responses:
83
+ - Webhook callbacks from external systems
84
+ - Polling-based status checks
85
+ - Delayed processing results (payment confirmations, AIGC generation results, etc.)
86
+
87
+ **Create Event Entities for Asynchronous Integrations:**
88
+ For each asynchronous integration identified, create a corresponding event entity following this pattern:
89
+
90
+ **Naming Convention:**
91
+ - `{IntegrationName}Event` (e.g., `PaymentEvent`, `AIGCEvent`, `FileUploadEvent`)
92
+ - Use the integration name from `requirements/{module}.integration.json`
93
+
94
+ **Event Entity Characteristics:**
95
+ - **Immutable**: Can only be created, never updated or deleted
96
+ - **Append-only**: New events are added to track state changes
97
+ - **Source of Truth**: Business data in the system should be computed based on these events
98
+
99
+ **Event Entity Properties:**
100
+ Based on the integration's `flow_description` and `current_system_data`, determine what properties the event should capture:
101
+ - External system's response data (transaction IDs, status codes, results)
102
+ - Timestamp of when the event was received
103
+ - Reference to related entities in current system (User.id, Order.id, etc.)
104
+ - Any relevant metadata from the external system
105
+
106
+ **Example:**
107
+ ```json
108
+ // From requirements/{module}.integration.json:
109
+ {
110
+ "id": "INT001",
111
+ "name": "PaymentProcessing",
112
+ "external_system": "Stripe",
113
+ "flow_description": "...Stripe processes payment...returns payment result..."
114
+ }
115
+
116
+ // Generated Event Entity:
117
+ "PaymentEvent": {
118
+ "purpose": "Records payment status updates received from Stripe",
119
+ "isIntegrationEvent": true,
120
+ "properties": {
121
+ "transactionId": {
122
+ "type": "string",
123
+ "purpose": "External payment transaction ID from Stripe"
124
+ },
125
+ "eventType": {
126
+ "type": "string",
127
+ "purpose": "Type of External payment event type"
128
+ },
129
+ "paymentStatus": {
130
+ "type": "string",
131
+ "purpose": "Status returned by Stripe (success, failed, pending)"
132
+ },
133
+ "amount": {
134
+ "type": "number",
135
+ "purpose": "Payment amount"
136
+ },
137
+ "timestamp": {
138
+ "type": "date",
139
+ "purpose": "When the payment result was received"
140
+ },
141
+ "userId": {
142
+ "type": "string",
143
+ "purpose": "Reference to User who initiated payment"
144
+ },
145
+ "orderId": {
146
+ "type": "string",
147
+ "purpose": "Reference to Order being paid for"
148
+ }
149
+ }
150
+ }
151
+ ```
152
+
153
+ **Documentation:**
154
+ - Document the relationship between event entities and business entities
155
+ - Explain how business data should be computed from these events
156
+ - Note that other entities' properties may depend on these event entities
157
+
57
158
  ### Step 2: Analyze Entity Lifecycles Using Interactions
58
159
 
59
- For **EACH entity** in data-concepts.json:
160
+ For **EACH entity** in `requirements/{module}.data-concepts.json`:
60
161
 
61
162
  #### 2.1 Determine Creation Pattern
62
163
 
63
- Analyze `requirements/interactions-design.json` to identify how entities are created:
164
+ Analyze `requirements/{module}.interactions-design.json` (using the module name from `.currentmodule`) to identify how entities are created:
165
+
166
+ **Step A: Check if Entity is Integration Event (PRIORITY CHECK)**
167
+ ⚠️ **CRITICAL: This check MUST be performed FIRST, before analyzing interactions.**
168
+
169
+ 1. Check if entity's `entityType` in `requirements/{module}.data-concepts.json` is `"integration-event"`
170
+ 2. Check if entity's `note` or `description` in `requirements/{module}.data-concepts.json` contains keywords: "external event", "integration event", "webhook", "external system"
171
+ 3. If EITHER condition is true:
172
+ - **Type = "integration-event"**
173
+ - **creationInteractions = [] (empty array)**
174
+ - **computationMethod = "Created by external system integration/webhook/callback"**
175
+ - **STOP and skip Step B and Step C**
176
+ - Note: Even if this entity appears in interactions-design.json's creates array, ignore it - the creates entry is only for tracking data flow, not for actual creation logic
177
+
178
+ **Step B: Check if Entity is API Call Entity (PRIORITY CHECK)**
179
+ ⚠️ **CRITICAL: This check MUST be performed after Step A.**
180
+
181
+ 1. Check if entity's `entityType` in `requirements/{module}.data-concepts.json` is `"api-call"`
182
+ 2. If true, API Call entities require special handling as they need dual creation sources:
183
+ - **Type = "mutation-derived"**
184
+ - Set `isAPICallEntity: true` in the output
185
+ - Set `relatedBusinessEntity` to identify the primary business entity that triggers API calls
186
+ - **computationMethod**: Describe using Transform computation to auto-create when business entity is created AND support retry through explicit interactions
187
+ - **STOP and skip Step C and Step D**
188
+
189
+ **Rationale**: API Call entities track external API invocations. They must be:
190
+ - Auto-created when business data is created (via record mutation)
191
+ - Re-creatable through retry interactions when failures occur
192
+ Since both interactions and entity creation produce record mutations, mutation-derived handles both scenarios via Transform computations.
193
+
194
+ **Step C: Find Creation Interactions**
195
+ (Only perform this step if entity is NOT an integration event AND NOT an API call entity)
64
196
 
65
- **Step A: Find Creation Interactions**
66
197
  1. Search all interactions where the entity appears in `interactions.specification.data.creates`
67
198
  2. For each creation interaction, capture:
68
199
  - Interaction name (not ID)
@@ -70,9 +201,23 @@ Analyze `requirements/interactions-design.json` to identify how entities are cre
70
201
  - Dependencies from the creates entry
71
202
  3. Store as `creationInteractions` with detailed information for each interaction
72
203
 
73
- **Step B: Determine Creation Type**
204
+ **Step D: Determine Creation Type**
205
+ (Only perform this step if entity is NOT an integration event AND NOT an API call entity)
206
+
207
+ **Priority Check: User Profile Entity Type**
208
+ 1. Check if entity has `entityType` field in `requirements/{module}.data-concepts.json`
209
+ 2. If `entityType === "user-profile"`:
210
+ - **Type = "derived"**
211
+ - **parent = "User"**
212
+ - **Reason**: User profile entities are automatically derived from the User entity upon User creation
213
+ - **STOP and skip remaining type analysis**
214
+
74
215
  Analyze the creation pattern:
75
216
 
217
+ - **integration-event**: Entity is an event entity for external system integration
218
+ - Should have been caught in Step A
219
+ - If you reach this point, review Step A logic
220
+
76
221
  - **interaction-created**: Entity is created independently by interactions
77
222
  - Entity appears alone in `data.creates`
78
223
  - Or is the primary entity being created
@@ -84,16 +229,76 @@ Analyze the creation pattern:
84
229
 
85
230
  - **derived**: Entity is filtered/computed from other entities
86
231
  - No interactions directly create it
87
- - Views in data-concepts.json are typically derived
232
+ - Views in `requirements/{module}.data-concepts.json` are typically derived
233
+ - **Special case**: User profile entities (`entityType: "user-profile"`) are derived from User entity (caught by Priority Check above)
88
234
 
89
235
  - **mutation-derived**: Entity is created from record mutation events
90
236
  - Not directly in any interaction's `data.creates`
91
237
  - Created by reactive computations (e.g., Transform) responding to other entities' creation/update/deletion
92
238
  - Check for descriptions mentioning "when X is created/updated/deleted, create Y"
93
239
  - Often used for audit logs, history tracking, or event-driven workflows
240
+ - **Dual-creation pattern**: Entities that need to be both auto-created with business data AND manually created through interactions
241
+ - Both scenarios produce record mutations, so Transform can handle both
242
+ - Example: API Call entities that auto-create when business entity is created, but also support retry interactions
243
+ - Set `relatedBusinessEntity` field to identify the triggering business entity
94
244
 
95
245
  **Example Analysis**:
96
246
  ```json
247
+ // Example 1: User Profile Entity (PRIORITY CHECK catches it)
248
+ // In requirements/user.data-concepts.json:
249
+ {
250
+ "name": "UserProfile",
251
+ "entityType": "user-profile",
252
+ "description": "Extended profile information for users",
253
+ "properties": {
254
+ "bio": {"type": "string"},
255
+ "avatar": {"type": "string"}
256
+ }
257
+ }
258
+ // Analysis using Step D Priority Check:
259
+ // - Entity has entityType field with value "user-profile" ✓
260
+ // - Result: Type = "derived", parent = "User"
261
+ // - STOP, skip remaining type analysis
262
+ // ⚠️ Note: User profile entities are automatically generated with User creation
263
+
264
+ // Example 2: Integration Event (PRIORITY CHECK catches it)
265
+ // In requirements/donate.data-concepts.json:
266
+ {
267
+ "name": "TTSGenerationEvent",
268
+ "note": "External event entity - created when TTS service returns response..."
269
+ }
270
+ // In requirements/donate.interactions-design.json (DonateToContent):
271
+ "creates": [
272
+ {
273
+ "target": "TTSGenerationEvent",
274
+ "description": "Create initial TTSGenerationEvent with status='pending'...",
275
+ "dependencies": ["DonationRecord"]
276
+ }
277
+ ]
278
+ // Analysis using Step A:
279
+ // - Step A check 2: entity note contains "External event entity" ✓
280
+ // - Result: Type = "integration-event", creationInteractions = []
281
+ // - STOP, skip Step B, C and D
282
+ // ⚠️ Note: Ignore the creates entry in interactions - it's only for tracking data flow
283
+
284
+ // Example 3: API Call Entity (mutation-derived with dual creation)
285
+ // In requirements/donate.data-concepts.json:
286
+ {
287
+ "name": "TTSAPICall",
288
+ "entityType": "api-call",
289
+ "description": "Records TTS API call execution for tracking"
290
+ }
291
+ // Analysis using Step B:
292
+ // - Step A: No integration event indicators ✗
293
+ // - Step B: entityType is "api-call" ✓
294
+ // - Result: Type = "mutation-derived"
295
+ // Set isAPICallEntity: true
296
+ // Set relatedBusinessEntity: "DonationRecord"
297
+ // computationMethod: "Transform: Auto-create when DonationRecord is created. Also supports retry via RetryTTSCall interaction. Both paths produce mutations handled by same Transform."
298
+ // - STOP, skip Step C and D
299
+ // ⚠️ Note: Dual creation pattern - auto-created with business entity AND manually via retry interaction
300
+
301
+ // Example 4: Interaction-created
97
302
  // In interaction "CreateDormitory":
98
303
  "data": {
99
304
  "creates": [
@@ -109,15 +314,23 @@ Analyze the creation pattern:
109
314
  }
110
315
  ]
111
316
  }
112
- // Result:
113
- // Dormitory is interaction-created with creation details
114
- // Bed is created-with-parent (parent: Dormitory) with creation details
115
-
116
- // For mutation-derived entity (not in any interaction's creates):
117
- // In data-concepts.json: "UserActivityLog: Records all user actions"
317
+ // Analysis:
318
+ // - Step A: No integration event indicators ✗
319
+ // - Step B: No api-call entityType
320
+ // - Step D Priority Check: No user-profile entityType ✗
321
+ // - Step C: Find creates entries
322
+ // - Step D: Dormitory is interaction-created, Bed is created-with-parent (parent: Dormitory)
323
+
324
+ // Example 5: Mutation-derived
325
+ // In requirements/{module}.data-concepts.json: "UserActivityLog: Records all user actions"
118
326
  // In interactions: No interaction directly creates UserActivityLog
119
327
  // In descriptions: "Activity logs are automatically created when users perform actions"
120
- // Result: UserActivityLog is mutation-derived
328
+ // Analysis:
329
+ // - Step A: No integration event indicators ✗
330
+ // - Step B: No api-call entityType ✗
331
+ // - Step D Priority Check: No user-profile entityType ✗
332
+ // - Step C: Not in any creates array
333
+ // - Step D: Result = mutation-derived
121
334
  ```
122
335
 
123
336
  #### 2.2 Determine Deletion Pattern
@@ -139,7 +352,7 @@ For **EACH property** of every entity:
139
352
 
140
353
  #### 3.1 Identify Data Dependencies
141
354
 
142
- From data-concepts.json, check if property is marked as `computed`:
355
+ From `requirements/{module}.data-concepts.json`, check if property is marked as `computed`:
143
356
  - If `computed: true`, examine the `computation` field
144
357
  - List all entities/relations/properties mentioned in `computation.dependencies`
145
358
  - These become the property's `dataDependencies`
@@ -151,7 +364,7 @@ From data-concepts.json, check if property is marked as `computed`:
151
364
 
152
365
  #### 3.2 Identify Interaction Dependencies
153
366
 
154
- Search interactions-design.json to find which interactions modify this property:
367
+ Search `requirements/{module}.interactions-design.json` (using the module name from `.currentmodule`) to find which interactions modify this property:
155
368
  1. Look for entity property in `data.updates` (e.g., "User.behaviorScore")
156
369
  2. Look for entity in `data.creates` (properties set at creation)
157
370
  3. List all matching interactions as `interactionDependencies` (use interaction **names**, not IDs)
@@ -159,7 +372,7 @@ Search interactions-design.json to find which interactions modify this property:
159
372
  #### 3.3 Determine Computation Method
160
373
 
161
374
  Transform the computation description using semantic best practices:
162
- - **Don't copy directly** from data-concepts.json
375
+ - **Don't copy directly** from `requirements/{module}.data-concepts.json`
163
376
  - Apply the "Best Practices for Computation Design" principles
164
377
  - Use semantic computations (Count, Every, Any, Summation, etc.) where possible
165
378
  - Decompose complex calculations into intermediate properties
@@ -167,16 +380,37 @@ Transform the computation description using semantic best practices:
167
380
 
168
381
  #### 3.4 Determine Control Type
169
382
 
170
- Based on the analysis:
171
- - **creation-only**: Only set when entity is created (no updates found)
172
- - **derived-with-parent**: Property of a derived entity
173
- - **independent**: Has separate update logic (found in `data.updates`)
383
+ Follow this decision process:
384
+
385
+ 1. **Check if property has `computation.method: "integration-result"` in `requirements/{module}.data-concepts.json`**
386
+ - If YES **integration-result**
387
+ - Used for properties computed from external API/integration results
388
+ - These properties react to API call entity updates
389
+
390
+ 2. **Check if parent entity's `lifecycle.creation.type` is `"derived"`**
391
+ - If YES → **derived-with-parent**
392
+ - Property belongs to a derived entity (e.g., UserProfile)
393
+
394
+ 3. **Check if property appears in any interaction's `data.updates`**
395
+ - If YES → **independent**
396
+ - Property has explicit update interactions
397
+
398
+ 4. **Check if property is computed**
399
+ - If NO (not computed) → **creation-only**
400
+ - If YES (computed) → **derived-with-parent**
401
+ - Covers reactive computed properties (Count, Summation, etc.)
402
+
403
+ **Control Type Definitions**:
404
+ - **creation-only**: Set once at entity creation, never changes
405
+ - **integration-result**: Computed from external API/integration results, reacts to API call entity changes
406
+ - **derived-with-parent**: Property of a derived entity, or reactive computed property
407
+ - **independent**: Has explicit update interactions separate from creation
174
408
 
175
409
  ### Step 4: Analyze Relations
176
410
 
177
411
  #### 4.1 Import Relation Structure
178
412
 
179
- Read relations from data-concepts.json:
413
+ Read relations from `requirements/{module}.data-concepts.json` (using the module name from `.currentmodule`):
180
414
  - Source and target entities
181
415
  - Cardinality
182
416
  - Relation properties
@@ -193,18 +427,64 @@ Similar to entities, analyze how relations are created:
193
427
  - Dependencies from the creates entry
194
428
  3. Analyze creation context
195
429
 
196
- **Determine Creation Type**:
197
- - **interaction-created**: Relation created independently
198
- - **created-with-entity**: Created when source/target entity is created
430
+ **Determine Creation Type - MANDATORY ALGORITHM**:
431
+
432
+ **🔴 CRITICAL: Follow this exact decision algorithm for EACH relation:**
433
+
434
+ ```
435
+ FOR each Relation found in interaction's data.creates:
436
+
437
+ STEP 1: Check if relation NOT in any interaction's data.creates
438
+ → IF TRUE: Type = "mutation-derived"
439
+ → STOP
440
+
441
+ STEP 2: Check the SAME interaction's data.creates array
442
+ → Find all Entities in the same creates array
443
+
444
+ STEP 3: Check relation's dependencies field
445
+ → IF dependencies contains ANY Entity from STEP 2:
446
+ → Type = "created-with-entity"
447
+ → parent = that Entity name
448
+ → STOP
449
+
450
+ STEP 4: Check description for keywords
451
+ → IF description contains "newly created" OR "just created" OR "connecting to created":
452
+ → Type = "created-with-entity"
453
+ → parent = the Entity being referenced
454
+ → STOP
455
+
456
+ STEP 5: Default case (relation only, no entity in same creates)
457
+ → Type = "interaction-created"
458
+ → parent = null
459
+ ```
460
+
461
+ **Type Definitions**:
462
+ - **integration-event**: Relation created from external system events (rare, most integration events are entities)
463
+ - Would be identified if a relation needs to track external system relationships
464
+ - Immutable and append-only like integration-event entities
465
+
466
+ - **created-with-entity**: Relation created together with an entity in the SAME interaction
467
+ - **Key signal**: Relation's dependencies include an Entity that is ALSO in the same `data.creates` array
468
+ - **Key signal**: Description mentions "newly created" or "connecting to created" entity
469
+ - The relation should be created automatically by the entity's Transform computation
470
+ - Set `parent` to the entity name
471
+
472
+ - **interaction-created**: Relation created independently (no entity being created in same interaction)
473
+ - **Key signal**: Relation is the ONLY item in `data.creates`, or
474
+ - **Key signal**: All entities in dependencies already exist (not being created in same interaction)
475
+ - The relation needs its own Transform computation
476
+
199
477
  - **derived**: Computed from data conditions
478
+
200
479
  - **mutation-derived**: Created from record mutation events
201
480
  - Not directly in any interaction's `data.creates`
202
481
  - Created by reactive computations responding to entity/relation changes
203
482
  - Common for maintaining referential integrity or creating audit trails
204
483
 
205
- **Example**:
484
+ **Examples with Algorithm Applied**:
485
+
206
486
  ```json
207
- // UserBedAssignment appears in:
487
+ // Example 1: interaction-created
208
488
  // "AssignUserToBed": "data": {
209
489
  // "creates": [{
210
490
  // "target": "UserBedAssignment",
@@ -212,26 +492,47 @@ Similar to entities, analyze how relations are created:
212
492
  // "dependencies": ["User", "Bed", "AvailabilityCheck"]
213
493
  // }]
214
494
  // }
215
- // Result: interaction-created with detailed creation info
495
+ // Analysis:
496
+ // - STEP 2: Same creates array has: [] (no entities)
497
+ // - STEP 3: Dependencies ["User", "Bed"] are NOT in creates array
498
+ // - STEP 5: Result = interaction-created
216
499
 
217
- // If it appeared with entity creation:
500
+ // Example 2: created-with-entity
218
501
  // "CreatePost": "data": {
219
502
  // "creates": [
220
503
  // {"target": "Post", "description": "Create new post", "dependencies": ["User"]},
221
504
  // {"target": "PostAuthorRelation", "description": "Link post to author", "dependencies": ["Post", "User"]}
222
505
  // ]
223
506
  // }
224
- // Result: PostAuthorRelation is created-with-entity (Post) with creation details
507
+ // Analysis for PostAuthorRelation:
508
+ // - STEP 2: Same creates array has: ["Post"]
509
+ // - STEP 3: Dependencies contain "Post" which IS in creates array
510
+ // - Result = created-with-entity (parent: "Post")
511
+
512
+ // Example 3: created-with-entity (donate module case)
513
+ // "RechargeGifts": "data": {
514
+ // "creates": [
515
+ // {"target": "RechargeRecord", "description": "Create new recharge record...", "dependencies": []},
516
+ // {"target": "UserRechargeRelation", "description": "Create relation connecting current User to the newly created RechargeRecord", "dependencies": ["User", "RechargeRecord"]}
517
+ // ]
518
+ // }
519
+ // Analysis for UserRechargeRelation:
520
+ // - STEP 2: Same creates array has: ["RechargeRecord"]
521
+ // - STEP 3: Dependencies contain "RechargeRecord" which IS in creates array
522
+ // - STEP 4: Description contains "newly created"
523
+ // - Result = created-with-entity (parent: "RechargeRecord")
225
524
 
226
- // For mutation-derived relation:
525
+ // Example 4: mutation-derived
227
526
  // UserFollowRelation not in any interaction's creates
228
527
  // Description: "Automatically created when user likes multiple posts by same author"
229
- // Result: UserFollowRelation is mutation-derived
528
+ // Analysis:
529
+ // - STEP 1: NOT in any creates array
530
+ // - Result = mutation-derived
230
531
  ```
231
532
 
232
533
  ### Step 5: Transform Dictionaries to Analysis Format
233
534
 
234
- For each dictionary in data-concepts.json:
535
+ For each dictionary in `requirements/{module}.data-concepts.json` (using the module name from `.currentmodule`):
235
536
 
236
537
  #### 5.1 Analyze Usage Patterns
237
538
 
@@ -330,14 +631,6 @@ Decompose into intermediate semantic computations:
330
631
  }
331
632
  ```
332
633
 
333
- ### Benefits of This Approach
334
-
335
- 1. **Clarity**: Each property has a single, clear purpose
336
- 2. **Reusability**: Intermediate properties can be used by multiple consumers
337
- 3. **Performance**: System can optimize semantic computations
338
- 4. **Maintainability**: Changes to business logic are localized
339
- 5. **Testability**: Each computation can be validated independently
340
-
341
634
  ### When to Create Intermediate Properties
342
635
 
343
636
  Create intermediate computed properties when you find yourself:
@@ -358,13 +651,16 @@ Transform the analyzed data into the standard output format:
358
651
  {
359
652
  "entities": {
360
653
  "[EntityName]": {
361
- "purpose": "[From data-concepts.json description]",
654
+ "purpose": "[From requirements/{module}.data-concepts.json description]",
655
+ "isAPICallEntity": "[true if entityType is 'api-call', omit otherwise]",
656
+ "isIntegrationEvent": "[true if this is an integration event entity, false otherwise]",
362
657
  "dataDependencies": "[Dependencies identified in Step 2]",
363
658
  "computationMethod": "[Creation pattern description]",
364
659
  "lifecycle": {
365
660
  "creation": {
366
- "type": "[interaction-created | derived | created-with-parent | mutation-derived]",
661
+ "type": "[integration-event | interaction-created | derived | created-with-parent | mutation-derived]",
367
662
  "parent": "[Parent entity name if created-with-parent]",
663
+ "relatedBusinessEntity": "[For API Call entities with mutation-derived type: the business entity that triggers API calls]",
368
664
  "creationInteractions": [
369
665
  {
370
666
  "name": "[Interaction name]",
@@ -374,8 +670,8 @@ Transform the analyzed data into the standard output format:
374
670
  ]
375
671
  },
376
672
  "deletion": {
377
- "canBeDeleted": "[true/false based on Step 2.2]",
378
- "deletionType": "[soft-delete | hard-delete | auto-delete]",
673
+ "canBeDeleted": "[true/false based on Step 2.2, always false for integration-event entities]",
674
+ "deletionType": "[soft-delete | hard-delete | auto-delete | none for integration-event]",
379
675
  "deletionInteractions": [
380
676
  {
381
677
  "name": "[Interaction name]",
@@ -387,8 +683,8 @@ Transform the analyzed data into the standard output format:
387
683
  },
388
684
  "properties": {
389
685
  "[propertyName]": {
390
- "type": "[From data-concepts.json]",
391
- "purpose": "[From data-concepts.json or inferred]",
686
+ "type": "[From requirements/{module}.data-concepts.json]",
687
+ "purpose": "[From requirements/{module}.data-concepts.json or inferred]",
392
688
  "controlType": "[From Step 3.4]",
393
689
  "dataDependencies": "[From Step 3.1]",
394
690
  "interactionDependencies": "[From Step 3.2]",
@@ -400,17 +696,17 @@ Transform the analyzed data into the standard output format:
400
696
  },
401
697
  "relations": {
402
698
  "[RelationName]": {
403
- "type": "[From data-concepts.json cardinality]",
404
- "purpose": "[From data-concepts.json description]",
405
- "sourceEntity": "[From data-concepts.json]",
406
- "targetEntity": "[From data-concepts.json]",
699
+ "type": "[From requirements/{module}.data-concepts.json cardinality]",
700
+ "purpose": "[From requirements/{module}.data-concepts.json description]",
701
+ "sourceEntity": "[From requirements/{module}.data-concepts.json]",
702
+ "targetEntity": "[From requirements/{module}.data-concepts.json]",
407
703
  "sourceProperty": "[Inferred or specified]",
408
704
  "targetProperty": "[Inferred or specified]",
409
705
  "dataDependencies": "[Always includes source and target entities]",
410
706
  "computationMethod": "[From Step 4.2]",
411
707
  "lifecycle": {
412
708
  "creation": {
413
- "type": "[interaction-created | created-with-entity | derived | mutation-derived]",
709
+ "type": "[integration-event | interaction-created | created-with-entity | derived | mutation-derived]",
414
710
  "parent": "[If created-with-entity]",
415
711
  "creationInteractions": [
416
712
  {
@@ -441,7 +737,7 @@ Transform the analyzed data into the standard output format:
441
737
  },
442
738
  "dictionaries": {
443
739
  "[DictionaryName]": {
444
- "purpose": "[From data-concepts.json description]",
740
+ "purpose": "[From requirements/{module}.data-concepts.json description]",
445
741
  "type": "[object with key types]",
446
742
  "dataDependencies": "[From Step 5.2]",
447
743
  "interactionDependencies": "[From Step 5.2]",
@@ -511,7 +807,62 @@ Properties affected by multiple sources:
511
807
  }
512
808
  ```
513
809
 
514
- ### 4. Derived Entities
810
+ ### 4. Integration Result Properties
811
+ Properties computed from external API/integration results:
812
+ ```json
813
+ "voiceUrl": {
814
+ "type": "string",
815
+ "purpose": "AI-generated audio URL from TTS service",
816
+ "controlType": "integration-result",
817
+ "dataDependencies": ["TTSAPICall.responseData", "TTSAPICall.status"],
818
+ "interactionDependencies": [],
819
+ "computationMethod": "Statemachine: Extract from latest TTSAPICall.responseData where status='completed'",
820
+ "initialValue": "null"
821
+ }
822
+ ```
823
+
824
+ Note: Use `controlType: "integration-result"` when:
825
+ - Property value comes from external API/service responses
826
+ - Property is computed from API Call entity's response data
827
+ - Always specified in `requirements/{module}.data-concepts.json` with `computation.method: "integration-result"`
828
+
829
+ ### 5. Derived Entities
830
+
831
+ #### 5.1 User Profile Entity (Special Case)
832
+ User profile entities with `entityType: "user-profile"`:
833
+ ```json
834
+ "UserProfile": {
835
+ "purpose": "Extended profile information for users",
836
+ "isIntegrationEvent": false,
837
+ "dataDependencies": ["User"],
838
+ "computationMethod": "Automatically created with User entity creation",
839
+ "lifecycle": {
840
+ "creation": {
841
+ "type": "derived",
842
+ "parent": "User",
843
+ "creationInteractions": []
844
+ },
845
+ "deletion": {
846
+ "canBeDeleted": true,
847
+ "deletionType": "auto-delete",
848
+ "deletionInteractions": []
849
+ }
850
+ },
851
+ "properties": {
852
+ "bio": {
853
+ "type": "string",
854
+ "purpose": "User biography",
855
+ "controlType": "independent",
856
+ "dataDependencies": [],
857
+ "interactionDependencies": ["UpdateProfile"],
858
+ "computationMethod": "Set by user through UpdateProfile interaction",
859
+ "initialValue": "''"
860
+ }
861
+ }
862
+ }
863
+ ```
864
+
865
+ #### 5.2 Filtered/Computed Entities
515
866
  Entities filtered from base entities:
516
867
  ```json
517
868
  "ActiveUser": {
@@ -526,7 +877,7 @@ Entities filtered from base entities:
526
877
  }
527
878
  ```
528
879
 
529
- ### 5. Multiple Creation Interactions
880
+ ### 6. Multiple Creation Interactions
530
881
  Entity created by different interactions with different logic:
531
882
  ```json
532
883
  "Style": {
@@ -551,13 +902,83 @@ Entity created by different interactions with different logic:
551
902
  }
552
903
  ```
553
904
 
905
+ ### 7. Integration Event Entity
906
+ Event entity for tracking asynchronous external system responses:
907
+ ```json
908
+ "PaymentEvent": {
909
+ "purpose": "Records payment status updates received from Stripe payment gateway",
910
+ "isIntegrationEvent": true,
911
+ "dataDependencies": [],
912
+ "computationMethod": "Created when webhook receives payment status from Stripe",
913
+ "lifecycle": {
914
+ "creation": {
915
+ "type": "integration-event",
916
+ "parent": null,
917
+ "creationInteractions": []
918
+ },
919
+ "deletion": {
920
+ "canBeDeleted": false,
921
+ "deletionType": "none",
922
+ "deletionInteractions": []
923
+ }
924
+ },
925
+ "properties": {
926
+ "transactionId": {
927
+ "type": "string",
928
+ "purpose": "External payment transaction ID from Stripe",
929
+ "controlType": "creation-only",
930
+ "dataDependencies": [],
931
+ "interactionDependencies": [],
932
+ "computationMethod": "Set from Stripe webhook payload",
933
+ "initialValue": "From external system response"
934
+ },
935
+ "paymentStatus": {
936
+ "type": "string",
937
+ "purpose": "Payment status (success, failed, pending)",
938
+ "controlType": "creation-only",
939
+ "dataDependencies": [],
940
+ "interactionDependencies": [],
941
+ "computationMethod": "Set from Stripe webhook payload",
942
+ "initialValue": "From external system response"
943
+ },
944
+ "timestamp": {
945
+ "type": "date",
946
+ "purpose": "When the payment event was received",
947
+ "controlType": "creation-only",
948
+ "dataDependencies": [],
949
+ "interactionDependencies": [],
950
+ "computationMethod": "Current server timestamp when event is created",
951
+ "initialValue": "now()"
952
+ }
953
+ }
954
+ }
955
+ ```
956
+
957
+ Note: Other business entities (like `Order.paymentStatus`, `User.premiumUntil`) should be computed based on these event entities to maintain reactive consistency.
958
+
554
959
  ## Validation Checklist
555
960
 
556
- - [ ] All entities from data-concepts.json are analyzed
557
- - [ ] All relations from data-concepts.json are analyzed
558
- - [ ] All dictionaries from data-concepts.json are analyzed
961
+ - [ ] Read module name from `.currentmodule` file in project root
962
+ - [ ] All entities from `requirements/{module}.data-concepts.json` are analyzed
963
+ - [ ] All relations from `requirements/{module}.data-concepts.json` are analyzed
964
+ - [ ] All dictionaries from `requirements/{module}.data-concepts.json` are analyzed
965
+ - [ ] **🔴 CRITICAL: For EACH entity, performed Step A (Integration Event Priority Check) FIRST**
966
+ - [ ] **🔴 CRITICAL: For EACH entity, performed Step B (API Call Entity Priority Check) after Step A**
967
+ - [ ] **🔴 CRITICAL: For EACH entity, performed Step D Priority Check (User Profile Entity Type) after Step A and B**
968
+ - [ ] API Call entities (with `entityType: "api-call"`) have `isAPICallEntity: true` flag set
969
+ - [ ] User profile entities (with `entityType: "user-profile"`) have lifecycle.creation.type set to "derived"
970
+ - [ ] User profile entities have lifecycle.creation.parent set to "User"
971
+ - [ ] Integration event entities identified from `requirements/{module}.integration.json` OR entity notes/descriptions
972
+ - [ ] Event entities properly marked with `isIntegrationEvent: true`
973
+ - [ ] Event entities have lifecycle.creation.type set to "integration-event"
974
+ - [ ] Event entities have lifecycle.creation.creationInteractions set to [] (empty array)
975
+ - [ ] Event entities have deletion.canBeDeleted set to false
976
+ - [ ] **🔴 CRITICAL: Integration event entities do NOT have computationMethod from interactions** (should be "Created by external system...")
559
977
  - [ ] Creation patterns identified for each entity/relation
560
- - [ ] Interaction dependencies found by searching interactions-design.json
978
+ - [ ] **🔴 CRITICAL: For EACH relation, executed the 5-step algorithm in Step 4.2 to determine lifecycle type**
979
+ - [ ] **🔴 CRITICAL: For relations with type "created-with-entity", verified parent field is set correctly**
980
+ - [ ] **🔴 CRITICAL: For relations in same creates array as entities, checked dependencies to identify created-with-entity pattern**
981
+ - [ ] Interaction dependencies found by searching `requirements/{module}.interactions-design.json`
561
982
  - [ ] Data dependencies match computed property definitions
562
983
  - [ ] Lifecycle patterns are consistent with business logic
563
984
  - [ ] Parent-child relationships properly identified