interaqt 0.4.0 → 0.4.2

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.
@@ -152,7 +152,7 @@ git commit -m "feat: Task 3.1.2 - Complete entity and relation implementation"
152
152
  - Clear next step
153
153
 
154
154
 
155
- - [ ] Generate all interactions based on `docs/interaction-design.md`. **DO NOT define any conditions yet** - we will add permissions and business rules later in Task 3.2. No `condition` parameter in Interaction.create()
155
+ - [ ] Generate all interactions based on `requirements/interaction-designs.json`. **DO NOT define any conditions yet** - we will add permissions and business rules later in Task 3.2. No `condition` parameter in Interaction.create()
156
156
  - [ ] Start with simple payload-only interactions (no conditions initially)
157
157
  - [ ] Ensure all payloads match the documented fields
158
158
  - [ ] **Type Check**: Run `npm run check` to ensure TypeScript compilation passes
@@ -380,7 +380,7 @@ git commit -m "feat: Task 3.2.0 - Create permission test file"
380
380
  **📋 Create the Permission and Business Rules Implementation Plan:**
381
381
 
382
382
  - [ ] Create `docs/business-rules-and-permission-control-implementation-plan.json` based on:
383
- - `docs/interaction-design.md` (Stage 2 requirements)
383
+ - `requirements/interactions-design.json`
384
384
  - `requirements/interaction-matrix.md` (permission requirements)
385
385
  - `requirements/test-cases.md` (business rule scenarios)
386
386
 
@@ -511,7 +511,7 @@ git commit -m "feat: Task 3.2.2 - Complete progressive permission and business r
511
511
  }
512
512
  ```
513
513
 
514
- - [ ] All permissions from `docs/interaction-design.md` are implemented
514
+ - [ ] All permissions from `requirements/interactions-design.json` are implemented
515
515
  - [ ] All business rules from requirements are implemented
516
516
  - [ ] Each rule has comprehensive test coverage (success and failure cases)
517
517
  - [ ] All type checks pass (`npm run check`)
@@ -10,7 +10,12 @@ color: blue
10
10
 
11
11
  ## START: Select Next Uncompleted Item
12
12
 
13
- **📖 Reference:** `./agentspace/knowledge/generator/computation-implementation.md` - Detailed computation implementation patterns and examples
13
+ **📖 Reference**
14
+ - `./backend/crud.example.ts` + `./tests/crud.example.test.ts` - Simple CRUD operations with state machines, relations, and permissions
15
+ - `./backend/versionControl.example.ts` + `./tests/versionControl.example.test.ts` - Version control with soft delete pattern
16
+ - `./backend/versionControlHardDelete.example.ts` + `./tests/versionControlHardDelete.example.test.ts` - Version control with hard delete pattern
17
+ - `./agentspace/knowledge/generator/computation-implementation.md` - Detailed computation implementation patterns and examples
18
+
14
19
 
15
20
  **🔴 CRITICAL: Implement ONLY ONE computation per session, then STOP and wait for user confirmation.**
16
21
 
@@ -54,6 +59,13 @@ color: blue
54
59
  1. **Implement the Computation** (following API Reference)
55
60
  - **📖 MANDATORY FIRST STEP: Completely read `./agentspace/knowledge/generator/api-reference.md` to understand all API usage before writing any code**
56
61
  - **📖 MANDATORY SECOND STEP: Completely read `./backend/index.ts` to understand all existing implementations from previous tasks**
62
+ - **📖 MANDATORY THIRD STEP: Study the reference example files above to understand the standard code structure and computation patterns**
63
+ - **🔴 CRITICAL: Check for existing computations** - If the target entity/relation already has computation code:
64
+ - **NEVER overwrite** existing computation logic
65
+ - **ADD branch logic** to handle the new interaction/scenario within existing Transform callback
66
+ - **PRESERVE all existing branches** to ensure previous test cases continue to pass
67
+ - Example: Add `else if` conditions or extend existing conditions in Transform callback
68
+ - **⚠️ Regression Prevention**: All previous tests must continue passing after adding new computation branches
57
69
  - **🔴 SPECIAL CASE 1: `_parent:[parent]` notation**
58
70
  - If the computation name contains `_parent:[parent]` (e.g., `_parent:[User]`), this means:
59
71
  - You should modify the PARENT entity's computation, not the current entity
@@ -166,6 +178,7 @@ color: blue
166
178
  4. **Write Test Implementation**
167
179
  - Add test to `tests/basic.test.ts` in 'Basic Functionality' describe group
168
180
  - Follow the test plan created above
181
+ - **📖 Reference the example test files above for testing patterns and structure**
169
182
  - For StateMachine computations, test ALL StateTransfer transitions
170
183
  - Test all CRUD operations the computation supports
171
184
 
@@ -51,7 +51,7 @@ You are a honest software expert with the following capabilities:
51
51
  }
52
52
  ```
53
53
 
54
- ## Task 2.2: Interaction Analysis
54
+ ## Task 2.2: Computation Analysis
55
55
 
56
56
  **🔄 Update `docs/STATUS.json`:**
57
57
  ```json
@@ -60,75 +60,6 @@ You are a honest software expert with the following capabilities:
60
60
  "completed": false
61
61
  }
62
62
  ```
63
- **📖 MUST READ: `./agentspace/knowledge/generator/basic-interaction-generation.md`**
64
-
65
- ⚠️ **DO NOT proceed without reading the above reference document completely!**
66
-
67
- **Create `docs/interaction-design.md` documenting:**
68
-
69
- - [ ] All interactions identified from use cases
70
- - [ ] For each interaction:
71
- - Name and purpose
72
- - Required payload fields
73
- - Which entities/relations it affects
74
- - Expected outcomes
75
- - Permission requirements (for Stage 2)
76
- - Business rules (for Stage 2)
77
- - [ ] **IMPORTANT**: Design interactions for core business logic first:
78
- - Basic CRUD operations
79
- - State transitions
80
- - Relationship management
81
- - [ ] **Document but don't implement yet**:
82
- - Permission checks (role-based access control)
83
- - Business rule validations (e.g., quantity limits, state checks, time restrictions)
84
- - Complex data validations beyond basic field requirements
85
-
86
- **Example structure:**
87
- ```markdown
88
- # Interaction Design
89
-
90
- ## CreateDormitory
91
- - **Purpose**: Create a new dormitory
92
- - **Payload**:
93
- - name: string (required)
94
- - capacity: number (required, 4-6)
95
- - **Effects**:
96
- - Creates new Dormitory entity
97
- - Initializes with empty beds
98
- - **Stage 2 - Permissions**: Only admin can create
99
- - **Stage 2 - Business Rules**: Capacity must be 4-6
100
-
101
- ## AssignUserToDormitory
102
- - **Purpose**: Assign a student to a dormitory
103
- - **Payload**:
104
- - userId: string
105
- - dormitoryId: string
106
- - **Effects**:
107
- - Creates UserDormitoryRelation
108
- - Updates dormitory occupancy count
109
- - **Stage 2 - Permissions**: Admin or dormHead of target dormitory
110
- - **Stage 2 - Business Rules**:
111
- - User must not already be assigned
112
- - Dormitory must have available capacity
113
- ```
114
-
115
- **✅ END Task 2.2: Update `docs/STATUS.json`:**
116
- ```json
117
- {
118
- "currentTask": "Task 2.2",
119
- "completed": true
120
- }
121
- ```
122
-
123
- ## Task 2.3: Computation Analysis
124
-
125
- **🔄 Update `docs/STATUS.json`:**
126
- ```json
127
- {
128
- "currentTask": "Task 2.3",
129
- "completed": false
130
- }
131
- ```
132
63
  **📖 PRIMARY GUIDE: `./agentspace/knowledge/generator/computation-analysis.md`**
133
64
  **📖 REFERENCE ONLY: `./agentspace/knowledge/generator/computation-implementation.md`**
134
65
 
@@ -138,7 +69,7 @@ You are a honest software expert with the following capabilities:
138
69
  1. **FIRST**: Read and understand `computation-analysis.md` completely
139
70
  2. **USE PREVIOUS OUTPUTS**: Base your analysis on:
140
71
  - `docs/data-design.json` (from Task 2.1)
141
- - `docs/interaction-design.md` (from Task 2.2)
72
+ - `requirements/interactions-design.json`
142
73
  3. **ANALYZE**: For EVERY entity and EVERY property, follow the step-by-step analysis process
143
74
  4. **DOCUMENT**: Create `docs/computation-analysis.json` documenting your analysis for each entity/property
144
75
  5. **REFERENCE**: Use `./agentspace/knowledge/generator/computation-implementation.md` as a reference for syntax and examples
@@ -161,7 +92,6 @@ You are a honest software expert with the following capabilities:
161
92
  "completed": true,
162
93
  "completedItems": [
163
94
  "data-design.json created",
164
- "interaction-design.md created",
165
95
  "computation-analysis.json created"
166
96
  ]
167
97
  }
@@ -624,11 +624,57 @@ git commit -m "feat: Task 1.3 - Complete data concept extraction"
624
624
  "role": "Actor role",
625
625
  "action": "Action name",
626
626
  "payload": "Input data (optional)",
627
- "data": "Data from current requirement (optional)",
627
+ "data": {
628
+ "creates": [
629
+ {
630
+ "target": "EntityOrRelationName",
631
+ "description": "Detailed description of how to create using what data",
632
+ "dependencies": ["Entity.property", "OtherEntity", "Relation.property"]
633
+ }
634
+ ],
635
+ "updates": [
636
+ {
637
+ "target": "EntityOrRelationName.propertyName",
638
+ "description": "Detailed description of how to update using what data",
639
+ "dependencies": ["Entity.property", "OtherEntity", "Relation.property"]
640
+ }
641
+ ],
642
+ "deletes": [
643
+ {
644
+ "target": "EntityOrRelationName",
645
+ "description": "Detailed description of how to delete and conditions",
646
+ "dependencies": ["Entity.property", "OtherEntity", "Relation.property"]
647
+ }
648
+ ],
649
+ "reads": ["Entity.property", "OtherEntity", "View"] // Only for read-type interactions
650
+ },
628
651
  "dataConstraints": "Inherited data constraints from fulfilled requirement"
629
652
  }
630
653
  ```
631
654
 
655
+ ### Data Field Specification Details
656
+
657
+ The `data` field describes all data operations performed by the interaction:
658
+
659
+ **For Write Operations (creates/updates/deletes):**
660
+ - Each operation must specify:
661
+ - `target`: The entity/relation name (for creates/deletes) or entity/relation.property (for updates)
662
+ - `description`: Detailed explanation of how the operation is performed, including what data is used
663
+ - `dependencies`: Array of other entities/relations/properties that must be read to perform this operation
664
+ - Dependencies should use dot notation for specific properties (e.g., `Book.availableCount`, `Reader.status`)
665
+ - Dependencies include all data that needs to be read or validated during the operation
666
+
667
+ **For Read Operations:**
668
+ - `reads`: Array of entities/relations/properties that the user wants to retrieve through this interaction
669
+ - Use dot notation for specific properties (e.g., `Book.title`, `Reader.name`)
670
+ - Include views and aggregated values as needed
671
+ - This represents the data the user expects to receive, not dependencies for internal operations
672
+
673
+ **Important Notes:**
674
+ - Write operations should NOT include a `reads` field - use `dependencies` within each operation instead
675
+ - Read operations should ONLY have a `reads` field - no creates/updates/deletes
676
+ - All referenced entities/relations must exist in the data concepts from Task 1.3
677
+
632
678
  ### Output: interactions-design.json
633
679
 
634
680
  Create `requirements/interactions-design.json`:
@@ -667,9 +713,20 @@ Create `requirements/interactions-design.json`:
667
713
  }
668
714
  },
669
715
  "data": {
670
- "creates": ["BorrowRecord"],
671
- "updates": ["Book.availableCount"],
672
- "reads": ["Reader", "Book", "SystemConfig.maxBorrowLimit"]
716
+ "creates": [
717
+ {
718
+ "target": "BorrowRecord",
719
+ "description": "Create new borrow record using readerId, bookId, current timestamp as borrowDate, and calculated dueDate based on loan period from SystemConfig",
720
+ "dependencies": ["Reader", "Book", "SystemConfig.loanPeriod"]
721
+ }
722
+ ],
723
+ "updates": [
724
+ {
725
+ "target": "Book.availableCount",
726
+ "description": "Decrease available count by 1 after validating current count is greater than 0",
727
+ "dependencies": ["Book.availableCount"]
728
+ }
729
+ ]
673
730
  },
674
731
  "dataConstraints": [
675
732
  "Automatically decrease Book.availableCount by 1",
@@ -710,14 +767,64 @@ Create `requirements/interactions-design.json`:
710
767
  }
711
768
  },
712
769
  "data": {
713
- "reads": ["Book", "Book.availableCount"],
714
- "returns": "BookListView"
770
+ "reads": ["Book.title", "Book.author", "Book.availableCount", "Book.category"]
715
771
  },
716
772
  "dataConstraints": [
717
773
  "Only show books with availableCount > 0",
718
774
  "Exclude books marked as 'restricted' for regular readers"
719
775
  ]
720
776
  }
777
+ },
778
+ {
779
+ "id": "ReturnBook",
780
+ "fulfills_requirements": ["R102"],
781
+ "type": "update",
782
+ "specification": {
783
+ "role": "Librarian",
784
+ "action": "return",
785
+ "conditions": [
786
+ "BorrowRecord exists for the given readerId and bookId",
787
+ "BorrowRecord.returnDate is null"
788
+ ],
789
+ "payload": {
790
+ "readerId": {
791
+ "type": "string",
792
+ "description": "ID of the reader returning the book",
793
+ "required": true
794
+ },
795
+ "bookId": {
796
+ "type": "string",
797
+ "description": "ID of the book being returned",
798
+ "required": true
799
+ }
800
+ },
801
+ "data": {
802
+ "updates": [
803
+ {
804
+ "target": "BorrowRecord.returnDate",
805
+ "description": "Set return date to current timestamp for the specific borrow record matching readerId and bookId",
806
+ "dependencies": ["BorrowRecord.readerId", "BorrowRecord.bookId", "BorrowRecord.returnDate"]
807
+ },
808
+ {
809
+ "target": "Book.availableCount",
810
+ "description": "Increase available count by 1 after confirming the book return",
811
+ "dependencies": ["Book.availableCount", "BorrowRecord"]
812
+ }
813
+ ],
814
+ "deletes": [
815
+ {
816
+ "target": "BorrowRecord",
817
+ "description": "Delete the borrow record after successful return if hard deletion is enabled",
818
+ "dependencies": ["BorrowRecord.returnDate", "SystemConfig.enableHardDeletion"]
819
+ }
820
+ ]
821
+ },
822
+ "dataConstraints": [
823
+ "Only update return date if it's currently null",
824
+ "Increase Book.availableCount only after confirming valid return",
825
+ "Delete BorrowRecord only if system configuration allows hard deletion"
826
+ ]
827
+ }
721
828
  }
722
829
  ],
723
830
  "interaction_matrix": {
@@ -63,8 +63,12 @@ For **EACH entity** in data-concepts.json:
63
63
  Analyze `requirements/interactions-design.json` to identify how entities are created:
64
64
 
65
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)
66
+ 1. Search all interactions where the entity appears in `interactions.specification.data.creates`
67
+ 2. For each creation interaction, capture:
68
+ - Interaction name (not ID)
69
+ - Description from the creates entry
70
+ - Dependencies from the creates entry
71
+ 3. Store as `creationInteractions` with detailed information for each interaction
68
72
 
69
73
  **Step B: Determine Creation Type**
70
74
  Analyze the creation pattern:
@@ -92,12 +96,22 @@ Analyze the creation pattern:
92
96
  ```json
93
97
  // In interaction "CreateDormitory":
94
98
  "data": {
95
- "creates": ["Dormitory", "Bed"]
96
- },
97
- "dataConstraints": [
98
- "Automatically create individual bed entities for each bed"
99
- ]
100
- // Result: Dormitory is interaction-created, Bed is created-with-parent (parent: Dormitory)
99
+ "creates": [
100
+ {
101
+ "target": "Dormitory",
102
+ "description": "Create new dormitory with basic info",
103
+ "dependencies": ["DormitoryValidation"]
104
+ },
105
+ {
106
+ "target": "Bed",
107
+ "description": "Automatically create individual bed entities for each bed",
108
+ "dependencies": ["Dormitory"]
109
+ }
110
+ ]
111
+ }
112
+ // Result:
113
+ // Dormitory is interaction-created with creation details
114
+ // Bed is created-with-parent (parent: Dormitory) with creation details
101
115
 
102
116
  // For mutation-derived entity (not in any interaction's creates):
103
117
  // In data-concepts.json: "UserActivityLog: Records all user actions"
@@ -109,8 +123,12 @@ Analyze the creation pattern:
109
123
  #### 2.2 Determine Deletion Pattern
110
124
 
111
125
  Search interactions for deletion operations:
112
- 1. Find interactions where entity appears in `data.deletes` (record interaction **names**, not IDs)
113
- 2. Determine deletion type:
126
+ 1. Find interactions where entity appears in `data.deletes`
127
+ 2. For each deletion interaction, capture:
128
+ - Interaction name (not ID)
129
+ - Description from the deletes entry
130
+ - Dependencies from the deletes entry
131
+ 3. Determine deletion type:
114
132
  - **hard-delete**: Entity removed from storage
115
133
  - **soft-delete**: Entity marked as deleted (status change)
116
134
  - **auto-delete**: Deleted when parent/dependency is deleted
@@ -169,8 +187,11 @@ Similar to entities, analyze how relations are created:
169
187
 
170
188
  **Find Creation Interactions**:
171
189
  1. Search for relation name in `data.creates`
172
- 2. Analyze creation context
173
- 3. Record interaction **names**, not IDs
190
+ 2. For each creation interaction, capture:
191
+ - Interaction name (not ID)
192
+ - Description from the creates entry
193
+ - Dependencies from the creates entry
194
+ 3. Analyze creation context
174
195
 
175
196
  **Determine Creation Type**:
176
197
  - **interaction-created**: Relation created independently
@@ -184,12 +205,23 @@ Similar to entities, analyze how relations are created:
184
205
  **Example**:
185
206
  ```json
186
207
  // UserBedAssignment appears in:
187
- // "AssignUserToBed": "data": { "creates": ["UserBedAssignment"] }
188
- // Result: interaction-created
208
+ // "AssignUserToBed": "data": {
209
+ // "creates": [{
210
+ // "target": "UserBedAssignment",
211
+ // "description": "Create assignment between user and bed",
212
+ // "dependencies": ["User", "Bed", "AvailabilityCheck"]
213
+ // }]
214
+ // }
215
+ // Result: interaction-created with detailed creation info
189
216
 
190
217
  // If it appeared with entity creation:
191
- // "CreatePost": "data": { "creates": ["Post", "PostAuthorRelation"] }
192
- // Result: PostAuthorRelation is created-with-entity (Post)
218
+ // "CreatePost": "data": {
219
+ // "creates": [
220
+ // {"target": "Post", "description": "Create new post", "dependencies": ["User"]},
221
+ // {"target": "PostAuthorRelation", "description": "Link post to author", "dependencies": ["Post", "User"]}
222
+ // ]
223
+ // }
224
+ // Result: PostAuthorRelation is created-with-entity (Post) with creation details
193
225
 
194
226
  // For mutation-derived relation:
195
227
  // UserFollowRelation not in any interaction's creates
@@ -333,12 +365,24 @@ Transform the analyzed data into the standard output format:
333
365
  "creation": {
334
366
  "type": "[interaction-created | derived | created-with-parent | mutation-derived]",
335
367
  "parent": "[Parent entity name if created-with-parent]",
336
- "creationInteractions": "[List from Step 2.1]"
368
+ "creationInteractions": [
369
+ {
370
+ "name": "[Interaction name]",
371
+ "description": "[Description from creates entry]",
372
+ "dependencies": "[Dependencies from creates entry]"
373
+ }
374
+ ]
337
375
  },
338
376
  "deletion": {
339
377
  "canBeDeleted": "[true/false based on Step 2.2]",
340
378
  "deletionType": "[soft-delete | hard-delete | auto-delete]",
341
- "deletionInteractions": "[List from Step 2.2]"
379
+ "deletionInteractions": [
380
+ {
381
+ "name": "[Interaction name]",
382
+ "description": "[Description from deletes entry]",
383
+ "dependencies": "[Dependencies from deletes entry]"
384
+ }
385
+ ]
342
386
  }
343
387
  },
344
388
  "properties": {
@@ -368,12 +412,24 @@ Transform the analyzed data into the standard output format:
368
412
  "creation": {
369
413
  "type": "[interaction-created | created-with-entity | derived | mutation-derived]",
370
414
  "parent": "[If created-with-entity]",
371
- "creationInteractions": "[From Step 4.2]"
415
+ "creationInteractions": [
416
+ {
417
+ "name": "[Interaction name]",
418
+ "description": "[Description from creates entry]",
419
+ "dependencies": "[Dependencies from creates entry]"
420
+ }
421
+ ]
372
422
  },
373
423
  "deletion": {
374
424
  "canBeDeleted": "[Based on analysis]",
375
425
  "deletionType": "[Type identified]",
376
- "deletionInteractions": "[List of interactions]"
426
+ "deletionInteractions": [
427
+ {
428
+ "name": "[Interaction name]",
429
+ "description": "[Description from deletes entry]",
430
+ "dependencies": "[Dependencies from deletes entry]"
431
+ }
432
+ ]
377
433
  }
378
434
  },
379
435
  "properties": {
@@ -470,6 +526,31 @@ Entities filtered from base entities:
470
526
  }
471
527
  ```
472
528
 
529
+ ### 5. Multiple Creation Interactions
530
+ Entity created by different interactions with different logic:
531
+ ```json
532
+ "Style": {
533
+ "lifecycle": {
534
+ "creation": {
535
+ "type": "interaction-created",
536
+ "parent": null,
537
+ "creationInteractions": [
538
+ {
539
+ "name": "CreateStyle",
540
+ "description": "Create new Style entity with provided data, automatically setting status to 'draft', generating slug if not provided, and setting timestamps",
541
+ "dependencies": ["SlugUniquenessCheck"]
542
+ },
543
+ {
544
+ "name": "RestoreToVersion",
545
+ "description": "Recreate Style entities from version snapshot data",
546
+ "dependencies": ["StyleVersion.snapshotData"]
547
+ }
548
+ ]
549
+ }
550
+ }
551
+ }
552
+ ```
553
+
473
554
  ## Validation Checklist
474
555
 
475
556
  - [ ] All entities from data-concepts.json are analyzed