You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: PLAN_use_null_for_map_initial_tasks.md
+25-42Lines changed: 25 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,39 +1,31 @@
1
1
# Plan: Use NULL for Unknown initial_tasks in Dependent Map Steps
2
2
3
3
## Motivation
4
+
4
5
Currently, dependent map steps have `initial_tasks = 1` as a placeholder until their dependencies complete. This is semantically incorrect and confusing:
6
+
5
7
-`1` implies "will spawn exactly 1 task" but that's false
6
8
-`NULL` correctly means "unknown until dependencies complete"
7
9
- Reduces cognitive load - see NULL, know it's unknown
8
10
9
11
## Critical Considerations
12
+
10
13
Before implementing, these issues must be addressed:
11
14
12
-
### 1. ~~The "Last Dependency" Problem~~ RESOLVED
13
-
**Map steps can have at most 1 dependency** (enforced in add_step.sql:24):
14
-
```sql
15
-
-- This constraint simplifies everything:
16
-
IF step_type ='map'AND array_length(deps_slugs, 1) >1 THEN
17
-
RAISE EXCEPTION 'Map step can have at most one dependency'
18
-
```
19
-
This means we always know exactly when to resolve `initial_tasks` - when the single dependency completes!
15
+
### 1. Non-Array Output Handling
20
16
21
-
### 2. Non-Array Output Handling
22
17
What if a dependency doesn't produce an array?
23
-
```sql
24
-
-- Must handle both cases:
25
-
CASE
26
-
WHEN jsonb_typeof(output) ='array' THEN jsonb_array_length(output)
27
-
ELSE 1-- Treat non-array as single item to map
28
-
END
29
-
```
30
18
31
-
### 3. ~~Race Condition Prevention~~ RESOLVED
32
-
Since map steps have at most 1 dependency, no race conditions possible!
33
-
The single dependency completes once, updates initial_tasks atomically.
19
+
We should chat about how to handle this case, as it is an invalid state
20
+
and we need to handle it somehow.
21
+
22
+
We should probably raise an explicit, well versed and detailed error,
23
+
so user's flow will fail early.
24
+
25
+
### 2. The Start Ready Steps Problem
34
26
35
-
### 4. The Start Ready Steps Problem
36
27
**CRITICAL**: We cannot use COALESCE - steps must NOT start with NULL initial_tasks
0 commit comments