interaqt 0.7.4 → 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.
- package/agent/.claude/settings.local.json +36 -1
- package/agent/CLAUDE.md +53 -13
- package/agent/agentspace/knowledge/generator/computation-analysis.md +105 -21
- package/agent/agentspace/knowledge/generator/data-analysis.md +211 -17
- package/agent/agentspace/prompt/integration_sub_agent_refactor.md +19 -0
- package/dist/index.js +345 -399
- package/dist/index.js.map +1 -1
- package/dist/shared/Data.d.ts +30 -57
- package/dist/shared/Data.d.ts.map +1 -1
- package/dist/shared/Interaction.d.ts +6 -6
- package/dist/shared/Interaction.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
"allow": [
|
|
4
4
|
"Bash(npm run check)",
|
|
5
5
|
"Bash(npm run test)",
|
|
6
|
+
"Read(STATUS.json)",
|
|
7
|
+
"Write(STATUS.json)",
|
|
8
|
+
"Edit(STATUS.json)",
|
|
6
9
|
"Read(docs/**)",
|
|
7
10
|
"Write(docs/**)",
|
|
8
11
|
"Edit(docs/**)",
|
|
@@ -38,7 +41,39 @@
|
|
|
38
41
|
"Bash(npm run reset)",
|
|
39
42
|
"Bash(git restore backend/index.ts docs/computation-implementation-plan.json tests/basic.test.ts)",
|
|
40
43
|
"Bash(npm run setup)",
|
|
41
|
-
"Bash(mv backend/index.template.ts backend/index.ts)"
|
|
44
|
+
"Bash(mv backend/index.template.ts backend/index.ts)",
|
|
45
|
+
"Bash(npm run build)",
|
|
46
|
+
"Bash(npm run dev:frontend)",
|
|
47
|
+
"Bash(npm run dev)",
|
|
48
|
+
"Bash(pkill:*)",
|
|
49
|
+
"Bash(npx tsc:*)",
|
|
50
|
+
"Bash(npx vitest run:*)",
|
|
51
|
+
"Bash(npm run generate-frontend-api)",
|
|
52
|
+
"Bash(lsof:*)",
|
|
53
|
+
"Bash(curl:*)",
|
|
54
|
+
"Bash(test:*)",
|
|
55
|
+
"Bash(rg:*)",
|
|
56
|
+
"Bash(bash:*)",
|
|
57
|
+
"Bash(npm run type-check)",
|
|
58
|
+
"Bash(echo:*)",
|
|
59
|
+
"Bash(find:*)",
|
|
60
|
+
"Bash(grep:*)",
|
|
61
|
+
"Bash(sed:*)",
|
|
62
|
+
"Bash(awk:*)",
|
|
63
|
+
"Bash(tr:*)",
|
|
64
|
+
"Bash(cut:*)",
|
|
65
|
+
"Bash(sort:*)",
|
|
66
|
+
"Bash(uniq:*)",
|
|
67
|
+
"Bash(wc:*)",
|
|
68
|
+
"Bash(node:*)",
|
|
69
|
+
"WebSearch",
|
|
70
|
+
"WebFetch",
|
|
71
|
+
"Bash(if [ -z \"$VOLC_ACCESS_KEY_ID\" ])",
|
|
72
|
+
"Bash(then echo \"VOLC_ACCESS_KEY_ID is empty or not set\")",
|
|
73
|
+
"Bash(else echo \"VOLC_ACCESS_KEY_ID is set\")",
|
|
74
|
+
"Bash(fi:*)",
|
|
75
|
+
"Bash(if [ -z \"$VOLC_SECRET_ACCESS_KEY\" ])",
|
|
76
|
+
"Bash(then echo \"VOLC_SECRET_ACCESS_KEY is empty or not set\")"
|
|
42
77
|
],
|
|
43
78
|
"deny": [],
|
|
44
79
|
"ask": []
|
package/agent/CLAUDE.md
CHANGED
|
@@ -42,26 +42,62 @@ Each module has its own progress tracking file:
|
|
|
42
42
|
|
|
43
43
|
** IMPORTANT: All tasks in this guide use a global unique numbering system (Task x.x.x.x). You can always find your current position by checking `docs/{module}.status.json`, which tracks the exact Task number you were working on for that module.**
|
|
44
44
|
|
|
45
|
+
**Task Numbering Hierarchy:**
|
|
46
|
+
- **Top-level tasks**: Task 1, Task 2, Task 3 (major phases)
|
|
47
|
+
- **Sub-tasks**: Task 1.1, Task 1.2, Task 1.3, Task 1.4, etc. (steps within a phase)
|
|
48
|
+
- **Sub-sub-tasks**: Task 1.1.1, Task 3.1.4.3, etc. (nested steps)
|
|
49
|
+
- **Rule**: Extract the first digit to determine which sub-agent handles the task
|
|
50
|
+
|
|
45
51
|
** IMPORTANT: Module-Based Generation - All generated artifacts should be organized by module name read from `.currentmodule` file.**
|
|
46
52
|
|
|
47
53
|
## Task-Based Workflow System
|
|
48
54
|
|
|
49
55
|
**📖 STEP 1: Check Current Progress**
|
|
50
56
|
1. Read current module name from `.currentmodule` file
|
|
51
|
-
2. Read `docs/{module}.status.json` to find your current task number (e.g., "Task 1", "Task 2", "Task 3")
|
|
57
|
+
2. Read `docs/{module}.status.json` to find your current task number (e.g., "Task 1.3", "Task 2.1", "Task 3.1.4.3")
|
|
52
58
|
3. If the status file doesn't exist, you should start with Task 1
|
|
53
59
|
|
|
54
|
-
**📖 STEP 2:
|
|
55
|
-
|
|
60
|
+
**📖 STEP 2: Determine Sub-Agent from Task Number**
|
|
61
|
+
|
|
62
|
+
**Extract top-level task (first digit) from currentTask to determine sub-agent:**
|
|
63
|
+
|
|
64
|
+
Algorithm:
|
|
65
|
+
```
|
|
66
|
+
if currentTask starts with "Task 3.1.4.3": use computation-generation-handler
|
|
67
|
+
else if currentTask starts with "Task 3.2.2": use permission-generation-handler
|
|
68
|
+
else:
|
|
69
|
+
topLevel = first digit of currentTask
|
|
70
|
+
if topLevel == 1: use requirements-analysis-handler
|
|
71
|
+
if topLevel == 2: use implement-design-handler
|
|
72
|
+
if topLevel == 3: use code-generation-handler
|
|
73
|
+
if topLevel == 4: use implement-integration-handler
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Examples:
|
|
77
|
+
- "Task 1.3" → Top-level is 1 → `requirements-analysis-handler`
|
|
78
|
+
- "Task 2.5.2" → Top-level is 2 → `implement-design-handler`
|
|
79
|
+
- "Task 3.1.4.3" → Exception → `computation-generation-handler`
|
|
80
|
+
- "Task 3.2.2" → Exception → `permission-generation-handler`
|
|
81
|
+
- "Task 3.x" (other) → Top-level is 3 → `code-generation-handler`
|
|
82
|
+
- "Task 4.2" → Top-level is 4 → `implement-integration-handler`
|
|
83
|
+
|
|
84
|
+
**📖 STEP 3: Execute Task with Sub-Agent**
|
|
85
|
+
|
|
86
|
+
Sub-agent mapping:
|
|
87
|
+
- **Task 1.x** (any sub-task of Task 1) → Use `requirements-analysis-handler`
|
|
88
|
+
- **Task 2.x** (any sub-task of Task 2) → Use `implement-design-handler`
|
|
89
|
+
- **Task 3.x** (any sub-task of Task 3) → Use `code-generation-handler`
|
|
90
|
+
- **Exception: Task 3.1.4.3.x** → Use `computation-generation-handler`
|
|
91
|
+
- **Exception: Task 3.2.2.x** → Use `permission-generation-handler`
|
|
92
|
+
- **Task 4.x** (any sub-task of Task 4) → Use `implement-integration-handler`
|
|
93
|
+
- **Error Checking** → Use `error-check-handler` when user requests error checking
|
|
56
94
|
|
|
57
|
-
-
|
|
58
|
-
- **Task
|
|
59
|
-
- **
|
|
60
|
-
|
|
61
|
-
- **Exception: Task 3.2.2 - Permission and Business Rule Implementation Loop** → Use sub-agent `permission-generation-handler` during the implementation loop
|
|
62
|
-
- **Error Checking** → Use sub-agent `error-check-handler` when user requests error checking or quality assurance
|
|
95
|
+
**CRITICAL - Task Continuation Logic:**
|
|
96
|
+
- **Within same top-level**: Task 1.3 → Task 1.4 (stay in same sub-agent, do NOT jump to Task 2)
|
|
97
|
+
- **Move to next top-level**: Only when status shows `"currentTask": "Task 1"` (no suffix) AND `"completed": true`, then move to Task 2
|
|
98
|
+
- Each sub-agent handles its own task progression; only switch sub-agents when explicitly moving to a new top-level task
|
|
63
99
|
|
|
64
|
-
**📋 STEP
|
|
100
|
+
**📋 STEP 4: Error Checking (Optional)**
|
|
65
101
|
|
|
66
102
|
At any point in the workflow, you can use the `error-check-handler` sub-agent to perform comprehensive error checking:
|
|
67
103
|
- Creates a detailed error report in `docs/{module}.error-check-report.md`
|
|
@@ -78,9 +114,13 @@ At any point in the workflow, you can use the `error-check-handler` sub-agent to
|
|
|
78
114
|
|
|
79
115
|
**🔴 CRITICAL - AUTORUN EXECUTION CONTROL:**
|
|
80
116
|
|
|
81
|
-
**For Top-Level Tasks (Task 1, Task 2, Task 3):**
|
|
82
|
-
- **
|
|
83
|
-
- **
|
|
117
|
+
**For Top-Level Tasks (Task 1, Task 2, Task 3, Task 4):**
|
|
118
|
+
- **IMPORTANT**: "Task 1 complete" means status shows `"currentTask": "Task 1"` (NOT "Task 1.x") AND `"completed": true`
|
|
119
|
+
- **Task 1.3 is WITHIN Task 1**: Continue to Task 1.4 within same sub-agent; do NOT jump to Task 2
|
|
120
|
+
- **Check `SCHEDULE.json`**: When `"autorun": true`, automatically proceed to next top-level task ONLY after current top-level shows as fully completed
|
|
121
|
+
- **Example**: Status shows "Task 1.3" → Continue to Task 1.4 (stay in requirements-analysis-handler)
|
|
122
|
+
- **Example**: Status shows "Task 1" with `completed: true` and `autorun: true` → Start Task 2 (switch to implement-design-handler)
|
|
123
|
+
- **Example**: Status shows "Task 3" with `completed: true` and `autorun: true` → Start Task 4 (switch to implement-integration-handler)
|
|
84
124
|
- **When `autorun` is false or doesn't exist**: Stop after completing each top-level task and wait for user's instruction to continue
|
|
85
125
|
|
|
86
126
|
**For Loop Tasks Within Sub-Tasks:**
|
|
@@ -33,6 +33,8 @@ The `_owner` notation indicates that this property's value is fully controlled b
|
|
|
33
33
|
|
|
34
34
|
Properties marked with `_owner` don't need separate computation control - their logic is embedded in the owner's creation or derivation process.
|
|
35
35
|
|
|
36
|
+
Note: Properties with `controlType: "integration-result"` are NOT marked as `_owner` - they use `StateMachine` to observe and extract values from API Call entity updates.
|
|
37
|
+
|
|
36
38
|
### 1. Entity-Level Computations
|
|
37
39
|
|
|
38
40
|
Look at the entity's `lifecycle.creation` and `lifecycle.deletion`:
|
|
@@ -41,6 +43,7 @@ Look at the entity's `lifecycle.creation` and `lifecycle.deletion`:
|
|
|
41
43
|
|---------------|----------|---------------------|
|
|
42
44
|
| `"integration-event"` | Always `canBeDeleted: false` | `None` - Entity is externally controlled by webhook/callback from external systems |
|
|
43
45
|
| `"created-with-parent"` | Any | `_parent:[lifecycle.creation.parent]` (created by parent's computation) |
|
|
46
|
+
| `"mutation-derived"` | Any | `Transform` from record mutation events (both interaction-created and entity-created produce mutations) |
|
|
44
47
|
| `"interaction-created"` | `canBeDeleted: false` | `Transform` with `InteractionEventEntity` |
|
|
45
48
|
| `"interaction-created"` | `canBeDeleted: true` with `hard-delete` | `Transform` + `HardDeletionProperty` with `StateMachine` |
|
|
46
49
|
| `"interaction-created"` | `canBeDeleted: true` with `soft-delete` | `Transform` + status property with `StateMachine` |
|
|
@@ -68,11 +71,17 @@ Check `lifecycle.creation` and `lifecycle.deletion`:
|
|
|
68
71
|
|
|
69
72
|
### 3. Property-Level Computations
|
|
70
73
|
|
|
74
|
+
**🔴 CRITICAL RULE: Properties can NEVER use Transform computation**
|
|
75
|
+
- Transform is ONLY for Entity/Relation creation
|
|
76
|
+
- Properties must use: _owner, StateMachine, computed, aggregations (Count/Sum/etc.), or Custom
|
|
77
|
+
- Even if a property needs to respond to external events (like Integration Events), use StateMachine with appropriate triggers
|
|
78
|
+
|
|
71
79
|
First check the property's `controlType`, then analyze dependencies if needed:
|
|
72
80
|
|
|
73
81
|
| Control Type | Computation Decision |
|
|
74
82
|
|--------------|---------------------|
|
|
75
83
|
| `creation-only` | `_owner` - controlled by entity/relation creation |
|
|
84
|
+
| `integration-result` | `StateMachine` - observes API Call entity updates, extracts result from response data |
|
|
76
85
|
| `derived-with-parent` | `_owner` - controlled by parent's derivation |
|
|
77
86
|
| `independent` | Further analysis needed (see below) |
|
|
78
87
|
|
|
@@ -82,29 +91,52 @@ Analyze the property's `dataDependencies`, `interactionDependencies`, and `compu
|
|
|
82
91
|
|
|
83
92
|
| Condition | Computation Decision |
|
|
84
93
|
|-----------|---------------------|
|
|
85
|
-
|
|
|
86
|
-
| Has `
|
|
94
|
+
| `calculationMethod` contains "sum of", "count of", "aggregate", or involves Record entities | `Custom` or aggregation (e.g., balance = sum(deposits) - sum(withdrawals)) |
|
|
95
|
+
| Has `interactionDependencies` that can modify it | `StateMachine` for state transitions or value updates (even for external events) |
|
|
96
|
+
| Has `dataDependencies` with relations/entities (including Integration Events) | `StateMachine` if triggered by events, otherwise aggregation computation |
|
|
87
97
|
| `dataDependencies` = self properties only | `computed` function |
|
|
88
98
|
| Complex calculation with multiple entities | `Custom` |
|
|
89
99
|
| Only has `initialValue`, no dependencies | No computation (use `defaultValue`) |
|
|
90
100
|
|
|
101
|
+
**Common Pattern - Integration Result Properties:**
|
|
102
|
+
- **If `controlType: "integration-result"`** → **Always use `StateMachine`**
|
|
103
|
+
- Pattern: Property computed from API Call entity's response data
|
|
104
|
+
- Example: `Donation.voiceUrl` computed from `TTSAPICall.responseData`
|
|
105
|
+
- Implementation:
|
|
106
|
+
- Trigger: Monitor API Call entity creation/update
|
|
107
|
+
- ComputeTarget: Find the business entity that needs the result
|
|
108
|
+
- ComputeValue: Extract value from API Call entity's response field
|
|
109
|
+
|
|
110
|
+
**Common Pattern - Integration Event Updates:**
|
|
111
|
+
- Property needs to update based on Integration Event (e.g., TTSEvent) → Use `StateMachine`
|
|
112
|
+
- Set trigger to monitor the Integration Event Entity creation: `trigger: { recordName: 'TTSEvent', type: 'create' }`
|
|
113
|
+
- Use `computeTarget` to find the target entity/relation to update
|
|
114
|
+
- Use `computeValue` to extract and return the new value from the event
|
|
115
|
+
|
|
91
116
|
#### Decision Priority (check in order):
|
|
92
117
|
|
|
93
118
|
1. **Check `controlType` first**:
|
|
94
119
|
- `creation-only` → **_owner** (property controlled by entity/relation creation)
|
|
120
|
+
- `integration-result` → **StateMachine** (observes API Call entity, extracts from response)
|
|
95
121
|
- `derived-with-parent` → **_owner** (property controlled by parent derivation)
|
|
96
122
|
- `independent` → Continue to step 2
|
|
97
123
|
|
|
98
|
-
2. **
|
|
124
|
+
2. **Check `calculationMethod` for aggregate patterns**:
|
|
125
|
+
- Contains "sum of", "count of", "aggregate" keywords → `Custom` or aggregation
|
|
126
|
+
- Involves multiple Record entities (deposits/withdrawals) → `Custom`
|
|
127
|
+
- Example: balance = sum(RechargeRecord) - sum(DonationRecord) → `Custom`
|
|
128
|
+
- If found, use `Custom` or aggregation, **skip step 3**
|
|
129
|
+
|
|
130
|
+
3. **If has `interactionDependencies` that can modify**:
|
|
99
131
|
- Property changes in response to interactions → `StateMachine`
|
|
100
132
|
- For timestamps: Use StateMachine with `computeValue`
|
|
101
133
|
- For status fields: Use StateMachine with StateNodes
|
|
102
134
|
|
|
103
|
-
|
|
135
|
+
4. **If has `dataDependencies` (no interactions)**:
|
|
104
136
|
- Check `computationMethod` for aggregation type
|
|
105
137
|
- Relations/entities involved → Use appropriate aggregation
|
|
106
138
|
|
|
107
|
-
|
|
139
|
+
5. **If uses only own entity properties**:
|
|
108
140
|
- Simple derivation → `computed` function
|
|
109
141
|
- Better performance than Custom
|
|
110
142
|
|
|
@@ -141,12 +173,14 @@ Then read `requirements/{module}.data-design.json` and extract:
|
|
|
141
173
|
For each element:
|
|
142
174
|
1. **For entities**: Check in this priority order:
|
|
143
175
|
- First check if `isIntegrationEvent: true` → set computation to "None" (externally controlled)
|
|
176
|
+
- Then check if `isAPICallEntity: true` → set computation to "Transform" (mutation-derived pattern)
|
|
144
177
|
- Then check lifecycle.creation.type and lifecycle.deletion
|
|
145
178
|
- For entities that can be hard-deleted, use Transform + HardDeletionProperty with StateMachine
|
|
146
179
|
2. **For relations**: Check lifecycle.creation.type and lifecycle.deletion
|
|
147
180
|
- For relations that can be hard-deleted, use Transform + HardDeletionProperty with StateMachine
|
|
148
|
-
3. **For properties**: Check controlType first:
|
|
181
|
+
3. **For properties**: Check controlType first (PRIORITY ORDER):
|
|
149
182
|
- If `creation-only` or `derived-with-parent` → use `_owner`
|
|
183
|
+
- **If `integration-result` → DIRECTLY use `StateMachine` (no further analysis)**
|
|
150
184
|
- If `independent` → apply standard dependency analysis rules
|
|
151
185
|
|
|
152
186
|
### Step 3: Generate Output Document
|
|
@@ -170,7 +204,7 @@ Create `requirements/{module}.computation-analysis.json` (using the module name
|
|
|
170
204
|
"propertyName": "<property name>",
|
|
171
205
|
"type": "<from requirements/{module}.data-design.json>",
|
|
172
206
|
"purpose": "<from requirements/{module}.data-design.json>",
|
|
173
|
-
"controlType": "<from requirements/{module}.data-design.json: creation-only/derived-with-parent/independent>",
|
|
207
|
+
"controlType": "<from requirements/{module}.data-design.json: creation-only/integration-result/derived-with-parent/independent>",
|
|
174
208
|
"dataSource": "<from computationMethod>",
|
|
175
209
|
"computationDecision": "<_owner/StateMachine/Count/etc. based on controlType and rules>",
|
|
176
210
|
"reasoning": "<automated based on controlType and rules>",
|
|
@@ -230,13 +264,14 @@ Examples:
|
|
|
230
264
|
|
|
231
265
|
```
|
|
232
266
|
1. Entity Lifecycle?
|
|
233
|
-
├─
|
|
267
|
+
├─ isIntegrationEvent: true? → None (externally controlled)
|
|
268
|
+
├─ isAPICallEntity: true? → Transform (mutation-derived pattern)
|
|
234
269
|
├─ lifecycle.creation.type: "created-with-parent"? → _parent:[parent]
|
|
270
|
+
├─ lifecycle.creation.type: "mutation-derived"? → Transform from record mutation event
|
|
235
271
|
├─ lifecycle.creation.type: "interaction-created" + canBeDeleted: true (hard)? → Transform + HardDeletionProperty with StateMachine
|
|
236
272
|
├─ lifecycle.creation.type: "interaction-created" + canBeDeleted: true (soft)? → Transform + status StateMachine
|
|
237
273
|
├─ lifecycle.creation.type: "interaction-created" + canBeDeleted: false? → Transform with InteractionEventEntity
|
|
238
274
|
└─ lifecycle.creation.type: "derived"? → Transform from source entity
|
|
239
|
-
└─ lifecycle.creation.type: "mutation-derived"? → Transform from record mutation event
|
|
240
275
|
|
|
241
276
|
2. Relation Lifecycle?
|
|
242
277
|
├─ lifecycle.creation.type: "created-with-entity"? → _parent:[parent]
|
|
@@ -244,11 +279,14 @@ Examples:
|
|
|
244
279
|
├─ Needs audit trail? → Transform + status StateMachine (soft delete)
|
|
245
280
|
└─ Never deleted? → Transform (if interaction-created) or _parent:[parent]
|
|
246
281
|
|
|
247
|
-
3. Property Value?
|
|
282
|
+
3. Property Value? (🔴 NEVER Transform - Transform is ONLY for Entity/Relation)
|
|
248
283
|
├─ controlType: "creation-only"? → _owner (controlled by entity/relation)
|
|
284
|
+
├─ controlType: "integration-result"? → StateMachine (observe API Call entity)
|
|
249
285
|
├─ controlType: "derived-with-parent"? → _owner (controlled by parent)
|
|
250
286
|
├─ controlType: "independent"?
|
|
287
|
+
│ ├─ calculationMethod has "sum of"/"count of"/"aggregate" or Record entities? → Custom or aggregation
|
|
251
288
|
│ ├─ Has interactionDependencies that can modify? → StateMachine
|
|
289
|
+
│ ├─ Depends on Integration Event? → StateMachine with event trigger
|
|
252
290
|
│ ├─ Has dataDependencies with relations? → Aggregation computation
|
|
253
291
|
│ ├─ Only uses own properties? → computed
|
|
254
292
|
│ └─ Complex with multiple entities? → Custom
|
|
@@ -268,11 +306,52 @@ Examples:
|
|
|
268
306
|
- With defined transitions: Use StateMachine with StateNodes
|
|
269
307
|
- Example: pending → approved/rejected
|
|
270
308
|
|
|
309
|
+
### Integration Result Properties
|
|
310
|
+
**🔴 DIRECT RULE: `controlType: "integration-result"` → Always `StateMachine`**
|
|
311
|
+
|
|
312
|
+
Properties with `controlType: "integration-result"` are computed from external API/integration results:
|
|
313
|
+
- **Pattern**: Extract values from API Call entity's response data
|
|
314
|
+
- **Computation**: Always use `StateMachine`
|
|
315
|
+
- **Trigger**: Observe API Call entity creation/update events
|
|
316
|
+
- **Logic**:
|
|
317
|
+
- Use `computeTarget` to find the business entity that owns this property
|
|
318
|
+
- Use `computeValue` to extract the result from API Call entity's response field
|
|
319
|
+
- Typically extract from the LATEST successful API Call (status='completed')
|
|
320
|
+
|
|
321
|
+
**Example**:
|
|
322
|
+
```json
|
|
323
|
+
{
|
|
324
|
+
"propertyName": "voiceUrl",
|
|
325
|
+
"controlType": "integration-result",
|
|
326
|
+
"dataDependencies": ["TTSAPICall.responseData", "TTSAPICall.status"],
|
|
327
|
+
"computationDecision": "StateMachine",
|
|
328
|
+
"reasoning": "controlType is 'integration-result' - directly maps to StateMachine to observe API Call entity"
|
|
329
|
+
}
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
**Implementation notes**:
|
|
333
|
+
- Monitor related API Call entity (via relation) for updates
|
|
334
|
+
- Extract result when API Call reaches completed status
|
|
335
|
+
- Handle multiple API Call attempts (retries) by using the latest successful one
|
|
336
|
+
|
|
271
337
|
### Counts and Aggregations
|
|
272
338
|
- Simple counts: Use `Count`
|
|
273
339
|
- Sums: Use `Summation`
|
|
274
340
|
- Calculated totals (price × quantity): Use `WeightedSummation`
|
|
275
341
|
|
|
342
|
+
### Balance/Accumulation Properties
|
|
343
|
+
**🔴 CRITICAL**: Properties that aggregate from transaction records should use `Custom`, NOT `StateMachine`
|
|
344
|
+
- Pattern: `balance = sum(deposits) - sum(withdrawals)`
|
|
345
|
+
- Examples:
|
|
346
|
+
- `UserGiftProfile.giftBalance = sum(RechargeRecord.amount) - sum(DonationRecord.giftAmount)`
|
|
347
|
+
- `Account.balance = sum(CreditRecord.amount) - sum(DebitRecord.amount)`
|
|
348
|
+
- `Inventory.stockLevel = sum(PurchaseOrder.quantity) - sum(SalesOrder.quantity)`
|
|
349
|
+
- **How to identify**:
|
|
350
|
+
- `calculationMethod` contains "sum of", "aggregate", "increased by", "decreased by"
|
|
351
|
+
- Involves multiple Record entities (entities ending in "Record", "Transaction", "Event")
|
|
352
|
+
- Even if has `interactionDependencies`, prioritize aggregation over StateMachine
|
|
353
|
+
- Use `Custom` computation to aggregate from related records reactively
|
|
354
|
+
|
|
276
355
|
### Deletion Patterns
|
|
277
356
|
|
|
278
357
|
#### For Entities:
|
|
@@ -291,19 +370,23 @@ Examples:
|
|
|
291
370
|
## Validation
|
|
292
371
|
|
|
293
372
|
Before finalizing, verify:
|
|
294
|
-
1.
|
|
295
|
-
2. Every entity with `
|
|
373
|
+
1. **🔴 CRITICAL**: NO property has `computationDecision: "Transform"` - Transform is ONLY for Entity/Relation
|
|
374
|
+
2. Every entity with `isIntegrationEvent: true` has `computationDecision: "None"` or no computation
|
|
375
|
+
3. Every entity with `isAPICallEntity: true` has `computationDecision: "Transform"`
|
|
376
|
+
4. Every entity with `interactionDependencies` has appropriate computation:
|
|
296
377
|
- If `canBeDeleted: true` with `hard-delete` → Must use Transform + HardDeletionProperty with StateMachine
|
|
297
378
|
- If `canBeDeleted: false` → Can use Transform (unless `created-with-parent` or `integration-event`)
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
379
|
+
5. Entities/relations with `lifecycle.creation.type: "created-with-parent/entity"` use `_parent:[ParentName]`
|
|
380
|
+
6. Properties with `controlType: "creation-only"` or `"derived-with-parent"` have computation `_owner`
|
|
381
|
+
7. Properties with `controlType: "integration-result"` use `StateMachine` to observe API Call entities
|
|
382
|
+
8. Properties with `controlType: "independent"` are analyzed for appropriate computation
|
|
383
|
+
9. Properties with modifying `interactionDependencies` use StateMachine (if `controlType: "independent"`)
|
|
384
|
+
10. Properties that depend on Integration Events use StateMachine with event triggers (NOT Transform)
|
|
385
|
+
11. Properties with only `dataDependencies` use data-based computation (if `controlType: "independent"`)
|
|
386
|
+
12. All entities or relations with `canBeDeleted:true` and `hard-delete` use Transform + HardDeletionProperty
|
|
387
|
+
13. All dependencies are properly formatted with specific properties
|
|
388
|
+
14. `InteractionEventEntity` is included when interactions are dependencies
|
|
389
|
+
15. The parent name in `_parent:[ParentName]` matches `lifecycle.creation.parent`
|
|
307
390
|
|
|
308
391
|
|
|
309
392
|
## Implementation Checklist
|
|
@@ -311,6 +394,7 @@ Before finalizing, verify:
|
|
|
311
394
|
- [ ] Read module name from `.currentmodule` file in project root
|
|
312
395
|
- [ ] Parse `requirements/{module}.data-design.json` completely
|
|
313
396
|
- [ ] Check for entities with `isIntegrationEvent: true` and set computation to "None"
|
|
397
|
+
- [ ] Check for entities with `isAPICallEntity: true` and set computation to "Transform"
|
|
314
398
|
- [ ] Apply mapping rules for every entity (check deletion capability)
|
|
315
399
|
- [ ] Check `controlType` for every property first
|
|
316
400
|
- [ ] Apply mapping rules for properties based on `controlType`
|