interaqt 0.3.0 → 0.3.1

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 (35) hide show
  1. package/agent/.claude/agents/code-generation-handler.md +2 -0
  2. package/agent/.claude/agents/computation-generation-handler.md +1 -0
  3. package/agent/.claude/agents/implement-design-handler.md +4 -13
  4. package/agent/.claude/agents/requirements-analysis-handler.md +46 -14
  5. package/agent/agentspace/knowledge/generator/api-reference.md +3378 -0
  6. package/agent/agentspace/knowledge/generator/basic-interaction-generation.md +377 -0
  7. package/agent/agentspace/knowledge/generator/computation-analysis.md +307 -0
  8. package/agent/agentspace/knowledge/generator/computation-implementation.md +959 -0
  9. package/agent/agentspace/knowledge/generator/data-analysis.md +463 -0
  10. package/agent/agentspace/knowledge/generator/entity-relation-generation.md +395 -0
  11. package/agent/agentspace/knowledge/generator/permission-implementation.md +460 -0
  12. package/agent/agentspace/knowledge/generator/permission-test-implementation.md +870 -0
  13. package/agent/agentspace/knowledge/generator/test-implementation.md +674 -0
  14. package/agent/agentspace/knowledge/usage/00-mindset-shift.md +322 -0
  15. package/agent/agentspace/knowledge/usage/01-core-concepts.md +131 -0
  16. package/agent/agentspace/knowledge/usage/02-define-entities-properties.md +407 -0
  17. package/agent/agentspace/knowledge/usage/03-entity-relations.md +599 -0
  18. package/agent/agentspace/knowledge/usage/04-reactive-computations.md +2186 -0
  19. package/agent/agentspace/knowledge/usage/05-interactions.md +1411 -0
  20. package/agent/agentspace/knowledge/usage/06-attributive-permissions.md +10 -0
  21. package/agent/agentspace/knowledge/usage/07-payload-parameters.md +593 -0
  22. package/agent/agentspace/knowledge/usage/08-activities.md +863 -0
  23. package/agent/agentspace/knowledge/usage/09-filtered-entities.md +784 -0
  24. package/agent/agentspace/knowledge/usage/10-async-computations.md +734 -0
  25. package/agent/agentspace/knowledge/usage/11-global-dictionaries.md +942 -0
  26. package/agent/agentspace/knowledge/usage/12-data-querying.md +1033 -0
  27. package/agent/agentspace/knowledge/usage/13-testing.md +1201 -0
  28. package/agent/agentspace/knowledge/usage/14-api-reference.md +1606 -0
  29. package/agent/agentspace/knowledge/usage/15-entity-crud-patterns.md +1122 -0
  30. package/agent/agentspace/knowledge/usage/16-frontend-page-design-guide.md +485 -0
  31. package/agent/agentspace/knowledge/usage/17-performance-optimization.md +283 -0
  32. package/agent/agentspace/knowledge/usage/18-api-exports-reference.md +176 -0
  33. package/agent/agentspace/knowledge/usage/19-common-anti-patterns.md +563 -0
  34. package/agent/agentspace/knowledge/usage/README.md +148 -0
  35. package/package.json +1 -1
@@ -0,0 +1,463 @@
1
+ # Data Analysis Guide for interaqt Projects (v2)
2
+
3
+ ## Overview
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.
6
+
7
+ ## Important Note on Interaction References
8
+
9
+ **CRITICAL**: Throughout this analysis process, always use **interaction names** (not interaction IDs) when referencing interactions.
10
+
11
+ - ✅ Correct: `"creationInteractions": ["CreateUser", "AssignUserToBed"]`
12
+ - ❌ Incorrect: `"creationInteractions": ["I101", "I102"]`
13
+
14
+ This applies to all interaction-related fields including:
15
+ - `creationInteractions`
16
+ - `deletionInteractions`
17
+ - `interactionDependencies`
18
+ - Any other references to interactions in the analysis output
19
+
20
+ ## Input Artifacts
21
+
22
+ ### 1. requirements/data-concepts.json
23
+ Contains pre-extracted data concepts:
24
+ - **Entities**: Core business objects with their properties
25
+ - **Relations**: Connections between entities
26
+ - **Dictionaries**: Global data and system-wide configurations
27
+ - **Views**: Pre-defined data queries and filters
28
+
29
+ ### 2. requirements/interactions-design.json
30
+ Contains interaction specifications showing:
31
+ - **Data operations**: What each interaction creates, reads, updates, or deletes
32
+ - **Data constraints**: How data is modified or created
33
+ - **Validation rules**: Business rules and constraints
34
+
35
+ ## Analysis Process
36
+
37
+ ### Step 1: Import Core Data Concepts
38
+
39
+ #### 1.1 Import Entities from requirements/data-concepts.json
40
+
41
+ Read the entities directly from `requirements/data-concepts.json`. Each entity already includes:
42
+ - Name and description
43
+ - Properties with types and purposes
44
+ - Computed property indicators
45
+ - Reference information
46
+
47
+ **No extraction needed** - the entities are already identified and structured.
48
+
49
+ #### 1.2 Import Dictionaries
50
+
51
+ Read dictionaries from `requirements/data-concepts.json`. These represent:
52
+ - System-wide configurations
53
+ - Global statistics
54
+ - Shared validation rules
55
+ - Cross-entity aggregates
56
+
57
+ ### Step 2: Analyze Entity Lifecycles Using Interactions
58
+
59
+ For **EACH entity** in data-concepts.json:
60
+
61
+ #### 2.1 Determine Creation Pattern
62
+
63
+ Analyze `requirements/interactions-design.json` to identify how entities are created:
64
+
65
+ **Step A: Find Creation Interactions**
66
+ 1. Search all interactions where the entity appears in `data.creates`
67
+ 2. List these as `creationInteractions` (use interaction **names**, not IDs)
68
+
69
+ **Step B: Determine Creation Type**
70
+ Analyze the creation pattern:
71
+
72
+ - **interaction-created**: Entity is created independently by interactions
73
+ - Entity appears alone in `data.creates`
74
+ - Or is the primary entity being created
75
+
76
+ - **created-with-parent**: Entity is created as part of another entity's creation
77
+ - Multiple entities appear in same interaction's `data.creates`
78
+ - Check `dataConstraints` for phrases like "automatically create", "create for each"
79
+ - The parent is the primary entity, child entities are secondary
80
+
81
+ - **derived**: Entity is filtered/computed from other entities
82
+ - No interactions directly create it
83
+ - Views in data-concepts.json are typically derived
84
+
85
+ **Example Analysis**:
86
+ ```json
87
+ // In interaction "CreateDormitory":
88
+ "data": {
89
+ "creates": ["Dormitory", "Bed"]
90
+ },
91
+ "dataConstraints": [
92
+ "Automatically create individual bed entities for each bed"
93
+ ]
94
+ // Result: Dormitory is interaction-created, Bed is created-with-parent (parent: Dormitory)
95
+ ```
96
+
97
+ #### 2.2 Determine Deletion Pattern
98
+
99
+ Search interactions for deletion operations:
100
+ 1. Find interactions where entity appears in `data.deletes` (record interaction **names**, not IDs)
101
+ 2. Determine deletion type:
102
+ - **hard-delete**: Entity removed from storage
103
+ - **soft-delete**: Entity marked as deleted (status change)
104
+ - **auto-delete**: Deleted when parent/dependency is deleted
105
+
106
+ ### Step 3: Analyze Property Dependencies
107
+
108
+ For **EACH property** of every entity:
109
+
110
+ #### 3.1 Identify Data Dependencies
111
+
112
+ From data-concepts.json, check if property is marked as `computed`:
113
+ - If `computed: true`, examine the `computation` field
114
+ - List all entities/relations/properties mentioned in `computation.dependencies`
115
+ - These become the property's `dataDependencies`
116
+
117
+ **Important**: Consider if this property could be decomposed:
118
+ - Could parts of the computation be extracted as separate properties?
119
+ - Are there reusable metrics hidden in the computation?
120
+ - Would intermediate properties make the logic clearer?
121
+
122
+ #### 3.2 Identify Interaction Dependencies
123
+
124
+ Search interactions-design.json to find which interactions modify this property:
125
+ 1. Look for entity property in `data.updates` (e.g., "User.behaviorScore")
126
+ 2. Look for entity in `data.creates` (properties set at creation)
127
+ 3. List all matching interactions as `interactionDependencies` (use interaction **names**, not IDs)
128
+
129
+ #### 3.3 Determine Computation Method
130
+
131
+ Transform the computation description using semantic best practices:
132
+ - **Don't copy directly** from data-concepts.json
133
+ - Apply the "Best Practices for Computation Design" principles
134
+ - Use semantic computations (Count, Every, Any, Summation, etc.) where possible
135
+ - Decompose complex calculations into intermediate properties
136
+ - Make the computation intent clear and implementation-ready
137
+
138
+ #### 3.4 Determine Control Type
139
+
140
+ Based on the analysis:
141
+ - **creation-only**: Only set when entity is created (no updates found)
142
+ - **derived-with-parent**: Property of a derived entity
143
+ - **independent**: Has separate update logic (found in `data.updates`)
144
+
145
+ ### Step 4: Analyze Relations
146
+
147
+ #### 4.1 Import Relation Structure
148
+
149
+ Read relations from data-concepts.json:
150
+ - Source and target entities
151
+ - Cardinality
152
+ - Relation properties
153
+
154
+ #### 4.2 Determine Relation Lifecycle
155
+
156
+ Similar to entities, analyze how relations are created:
157
+
158
+ **Find Creation Interactions**:
159
+ 1. Search for relation name in `data.creates`
160
+ 2. Analyze creation context
161
+ 3. Record interaction **names**, not IDs
162
+
163
+ **Determine Creation Type**:
164
+ - **interaction-created**: Relation created independently
165
+ - **created-with-entity**: Created when source/target entity is created
166
+ - **derived**: Computed from data conditions
167
+
168
+ **Example**:
169
+ ```json
170
+ // UserBedAssignment appears in:
171
+ // "AssignUserToBed": "data": { "creates": ["UserBedAssignment"] }
172
+ // Result: interaction-created
173
+
174
+ // If it appeared with entity creation:
175
+ // "CreatePost": "data": { "creates": ["Post", "PostAuthorRelation"] }
176
+ // Result: PostAuthorRelation is created-with-entity (Post)
177
+ ```
178
+
179
+ ### Step 5: Transform Dictionaries to Analysis Format
180
+
181
+ For each dictionary in data-concepts.json:
182
+
183
+ #### 5.1 Analyze Usage Patterns
184
+
185
+ Search interactions for dictionary usage:
186
+ 1. Find where dictionary appears in `data.reads` (record interaction **names**, not IDs)
187
+ 2. Find where dictionary values are used in conditions
188
+ 3. Determine if values are static or computed
189
+
190
+ #### 5.2 Determine Dependencies
191
+
192
+ - **Data Dependencies**: If dictionary aggregates from entities
193
+ - **Interaction Dependencies**: If interactions update dictionary values (use interaction **names**, not IDs)
194
+ - **Computation Method**: How the value is calculated or maintained
195
+
196
+ ## Best Practices for Computation Design
197
+
198
+ ### Prioritize Semantic Computations
199
+
200
+ To ensure data clarity, follow these principles:
201
+
202
+ 1. **Use System-Provided Semantic Computations First**
203
+ - Prefer built-in computations over custom implementations:
204
+ - `Count` - Count entities or relations
205
+ - `Every` - Check if all items meet a condition
206
+ - `Any` - Check if at least one item meets a condition
207
+ - `Summation` - Sum numeric values across relations
208
+ - `Average` - Calculate average of numeric values
209
+ - `WeightedSummation` - Calculate weighted sum with custom weights
210
+ - These provide better performance and clearer intent
211
+ - Examples:
212
+ - Use `Count` for counting relations instead of custom counter logic
213
+ - Use `Every` for "all items meet condition" instead of custom validation
214
+ - Use `Any` for "at least one item meets condition" instead of custom checks
215
+ - Use `Summation` for totaling values (e.g., order totals, scores)
216
+ - Use `Average` for calculating means (e.g., average rating, average price)
217
+ - Use `WeightedSummation` for weighted calculations (e.g., GPA, weighted scores)
218
+
219
+ 2. **Decompose Complex Calculations with Intermediate Data Concepts**
220
+ - When custom calculations are necessary, identify reusable parts
221
+ - Extract these parts as intermediate computed properties using semantic computations
222
+ - Reference intermediate properties in final custom calculations
223
+ - This approach:
224
+ - Reduces complexity of custom logic
225
+ - Improves reusability
226
+ - Makes data dependencies clearer
227
+ - Enables better optimization
228
+
229
+ ### Example: Order Fulfillment Status
230
+
231
+ Instead of a complex custom calculation:
232
+
233
+ ```json
234
+ // ❌ Complex custom calculation mixing multiple concerns
235
+ "fulfillmentStatus": {
236
+ "type": "string",
237
+ "purpose": "Overall order fulfillment status",
238
+ "dataDependencies": ["OrderItemRelation", "Item.status", "Item.shippedDate"],
239
+ "interactionDependencies": [],
240
+ "computationMethod": "Custom: Loop through all items, check each status, count shipped, check dates, determine overall status"
241
+ }
242
+ ```
243
+
244
+ Decompose into intermediate semantic computations:
245
+
246
+ ```json
247
+ // ✅ Better: Use intermediate properties with semantic computations
248
+ "properties": {
249
+ "totalItems": {
250
+ "type": "number",
251
+ "purpose": "Total number of items in order",
252
+ "dataDependencies": ["OrderItemRelation"],
253
+ "interactionDependencies": [],
254
+ "computationMethod": "Count of OrderItemRelation"
255
+ },
256
+ "shippedItems": {
257
+ "type": "number",
258
+ "purpose": "Number of shipped items",
259
+ "dataDependencies": ["OrderItemRelation", "Item.status"],
260
+ "interactionDependencies": [],
261
+ "computationMethod": "Count of OrderItemRelation where Item.status = 'shipped'"
262
+ },
263
+ "allItemsShipped": {
264
+ "type": "boolean",
265
+ "purpose": "Whether all items are shipped",
266
+ "dataDependencies": ["OrderItemRelation", "Item.status"],
267
+ "interactionDependencies": [],
268
+ "computationMethod": "Every(item => item.status === 'shipped')"
269
+ },
270
+ "fulfillmentStatus": {
271
+ "type": "string",
272
+ "purpose": "Overall order fulfillment status",
273
+ "dataDependencies": ["allItemsShipped", "shippedItems", "totalItems"],
274
+ "interactionDependencies": [],
275
+ "computationMethod": "Custom: if (allItemsShipped) return 'complete'; if (shippedItems > 0) return 'partial'; return 'pending'"
276
+ }
277
+ }
278
+ ```
279
+
280
+ ### Benefits of This Approach
281
+
282
+ 1. **Clarity**: Each property has a single, clear purpose
283
+ 2. **Reusability**: Intermediate properties can be used by multiple consumers
284
+ 3. **Performance**: System can optimize semantic computations
285
+ 4. **Maintainability**: Changes to business logic are localized
286
+ 5. **Testability**: Each computation can be validated independently
287
+
288
+ ### When to Create Intermediate Properties
289
+
290
+ Create intermediate computed properties when you find yourself:
291
+ - Counting or aggregating within custom logic
292
+ - Checking conditions across collections
293
+ - Repeatedly calculating the same sub-values
294
+ - Combining multiple data sources in complex ways
295
+
296
+ Remember: It's better to have several simple, semantic computations than one complex custom calculation.
297
+
298
+ ## Output Generation
299
+
300
+ ### Generate Analysis JSON
301
+
302
+ Transform the analyzed data into the standard output format:
303
+
304
+ ```json
305
+ {
306
+ "entities": {
307
+ "[EntityName]": {
308
+ "purpose": "[From data-concepts.json description]",
309
+ "dataDependencies": "[Dependencies identified in Step 2]",
310
+ "computationMethod": "[Creation pattern description]",
311
+ "lifecycle": {
312
+ "creation": {
313
+ "type": "[interaction-created | derived | created-with-parent]",
314
+ "parent": "[Parent entity name if created-with-parent]",
315
+ "creationInteractions": "[List from Step 2.1]"
316
+ },
317
+ "deletion": {
318
+ "canBeDeleted": "[true/false based on Step 2.2]",
319
+ "deletionType": "[soft-delete | hard-delete | auto-delete]",
320
+ "deletionInteractions": "[List from Step 2.2]"
321
+ }
322
+ },
323
+ "properties": {
324
+ "[propertyName]": {
325
+ "type": "[From data-concepts.json]",
326
+ "purpose": "[From data-concepts.json or inferred]",
327
+ "controlType": "[From Step 3.4]",
328
+ "dataDependencies": "[From Step 3.1]",
329
+ "interactionDependencies": "[From Step 3.2]",
330
+ "computationMethod": "[From Step 3.3]",
331
+ "initialValue": "[Default or creation logic]"
332
+ }
333
+ }
334
+ }
335
+ },
336
+ "relations": {
337
+ "[RelationName]": {
338
+ "type": "[From data-concepts.json cardinality]",
339
+ "purpose": "[From data-concepts.json description]",
340
+ "sourceEntity": "[From data-concepts.json]",
341
+ "targetEntity": "[From data-concepts.json]",
342
+ "sourceProperty": "[Inferred or specified]",
343
+ "targetProperty": "[Inferred or specified]",
344
+ "dataDependencies": "[Always includes source and target entities]",
345
+ "computationMethod": "[From Step 4.2]",
346
+ "lifecycle": {
347
+ "creation": {
348
+ "type": "[From Step 4.2]",
349
+ "parent": "[If created-with-entity]",
350
+ "creationInteractions": "[From Step 4.2]"
351
+ },
352
+ "deletion": {
353
+ "canBeDeleted": "[Based on analysis]",
354
+ "deletionType": "[Type identified]",
355
+ "deletionInteractions": "[List of interactions]"
356
+ }
357
+ },
358
+ "properties": {
359
+ "[propertyName]": {
360
+ // Same structure as entity properties
361
+ }
362
+ }
363
+ }
364
+ },
365
+ "dictionaries": {
366
+ "[DictionaryName]": {
367
+ "purpose": "[From data-concepts.json description]",
368
+ "type": "[object with key types]",
369
+ "dataDependencies": "[From Step 5.2]",
370
+ "interactionDependencies": "[From Step 5.2]",
371
+ "computationMethod": "[From Step 5.2]"
372
+ }
373
+ }
374
+ }
375
+ ```
376
+
377
+ ## Best Practices for Analysis
378
+
379
+ ### 1. Cross-Reference Data Operations
380
+
381
+ Always verify entity/property modifications by:
382
+ - Checking all interactions that mention the entity
383
+ - Looking for indirect updates through relations
384
+ - Identifying cascade effects in dataConstraints
385
+
386
+ ### 2. Identify Computation Patterns
387
+
388
+ When analyzing computed properties:
389
+ - Look for standard patterns (Count, Sum, Average, etc.)
390
+ - Identify if computation can use built-in interaqt computations
391
+ - Document complex custom logic clearly
392
+
393
+ ### 3. Track Dependency Chains
394
+
395
+ Ensure all dependencies are identified:
396
+ - Direct data dependencies from computation logic
397
+ - Indirect dependencies through relations
398
+ - Interaction chains that affect the data
399
+
400
+ ### 4. Validate Lifecycle Consistency
401
+
402
+ Verify that:
403
+ - Creation patterns match the business logic
404
+ - Deletion handling preserves data integrity
405
+ - Parent-child relationships are properly maintained
406
+
407
+ ## Common Analysis Patterns
408
+
409
+ ### 1. Aggregation Properties
410
+ Properties that count or sum related data:
411
+ ```json
412
+ "currentOccupancy": {
413
+ "dataDependencies": ["Bed", "UserBedAssignment"],
414
+ "computationMethod": "Count of occupied beds (Bed.isOccupied = true)"
415
+ }
416
+ ```
417
+
418
+ ### 2. Status-Driven Properties
419
+ Properties that change based on interactions:
420
+ ```json
421
+ "status": {
422
+ "interactionDependencies": ["CreateUser", "ActivateUser", "DeactivateUser"],
423
+ "computationMethod": "Set by interactions, defaults to 'active' on creation"
424
+ }
425
+ ```
426
+
427
+ ### 3. Cascading Updates
428
+ Properties affected by multiple sources:
429
+ ```json
430
+ "behaviorScore": {
431
+ "dataDependencies": ["BehaviorViolation"],
432
+ "interactionDependencies": ["ModifyBehaviorScore"],
433
+ "computationMethod": "Base score minus sum of violations, can be overridden by admin"
434
+ }
435
+ ```
436
+
437
+ ### 4. Derived Entities
438
+ Entities filtered from base entities:
439
+ ```json
440
+ "ActiveUser": {
441
+ "computationMethod": "Derived from User where lastLoginDate > (now - 30 days)",
442
+ "lifecycle": {
443
+ "creation": {
444
+ "type": "derived",
445
+ "parent": null,
446
+ "creationInteractions": []
447
+ }
448
+ }
449
+ }
450
+ ```
451
+
452
+ ## Validation Checklist
453
+
454
+ - [ ] All entities from data-concepts.json are analyzed
455
+ - [ ] All relations from data-concepts.json are analyzed
456
+ - [ ] All dictionaries from data-concepts.json are analyzed
457
+ - [ ] Creation patterns identified for each entity/relation
458
+ - [ ] Interaction dependencies found by searching interactions-design.json
459
+ - [ ] Data dependencies match computed property definitions
460
+ - [ ] Lifecycle patterns are consistent with business logic
461
+ - [ ] Parent-child relationships properly identified
462
+ - [ ] All properties have defined control types
463
+ - [ ] Computation methods clearly documented