Task tree
Parent-child event tasks, validation, sync linearity, ACS tree builder, and DIP import/export
Data model
Event tasks (EventTaskModel) belong to exactly one connector–event mapping via connectorEventMappingId. The tree is encoded with:
parentId—nullfor the root task; otherwise references another task’s_idin the same mapping.type— pipeline step kind (enrich,transform,filter,mapping,dispatch,extract,http); see Task types reference.config— type-specific JSON payload.continueOnFailure— whether downstream steps still run after a failure.
The mapping document stores an ordered list of tasks (ObjectId references) for quick access; the authoritative structure is the parentId graph on the task documents.
Validation rules (TaskTreeValidator in @libs/dip-v2)
| Rule | Meaning |
|---|---|
| Single root | Exactly one task with parentId null/undefined. |
| No orphans | Every non-null parentId must point to another task in the same mapping set. |
| No cycles | Following parent pointers must not loop (detectCycles). |
ACS uses an additional helper CycleDetector when mutating parent links to reject edits that would introduce a cycle before persistence.
Sync API: linear chain only
POST /ingress/sync enforces stricter rules than async ingress:
- At most one connector–event mapping may apply to the inbound event; otherwise the request fails with a clear error (
request-handler.ts). - Tasks must pass
validateLinearTaskChainForSync: after standard tree validation, each parent may have at most one child (no branching). If the tree forks, sync responds with an error such as Sync API can't be used where task structure is not linear.
Async POST /ingress can process multiple mappings and branched trees, subject to egress execution capabilities.
Building a tree in the DIP UI
- Create or edit a connector–event mapping and open the task editor (task list + graph).
- Add the root task first (
parentIdempty). - Add children pointing to their parent task id; the graph (
TaskGraph) reflects parent/child edges. - Save through ACS so server-side validation runs.
Maximum depth can be reasoned about with TaskTreeBuilder.calculateMaxDepth (used for limits or diagnostics where implemented).
ACS TaskTreeBuilder
Server-side utility that turns a flat EventTaskDocument[] into a nested TaskTreeNode (single root with children[]). It assumes a valid tree; if multiple roots exist, the builder overwrites rootNode and the last root wins—rely on TaskTreeValidator.validate before persisting, not on the builder, to catch invalid shapes.
Import and export (task-tree-import-export.ts)
The console can export a JSON envelope:
format:g1-dip-task-treeversion:1exportedAt: ISO timestamptasks: array of task form rows (including_id,parentId,type,config, optional layoutposition)
Import validates basic shape (_id, name, type), normalizes parentId, and runs the same parent-id checks as create flows (validateTasksHaveParentIds, validateAllTasksHaveValidData from utility/connectors.ts).
Use this to clone pipelines across environments or mappings without manual re-entry.
Related
- Ingress async and sync — where sync linear validation is applied.
- Task types reference — per-type
configfields.