11# Map Infrastructure (SQL Core)
22
3+ ** NOTE: This PLAN.md file should be removed in the final PR once all map infrastructure is complete.**
4+
35## Implementation Status
46
57### Sequential Child PR Plan
68
79- [x] ** PR #207 : Add .array() to DSL** - ` feature-map-and-array `
810 - TypeScript DSL enhancement for array creation
911 - Foundation for map step functionality
10- - [x] ** PR #208 : Foundation - Schema & add_step()** - ` 09-10-feat_add_map_step_type_in_sql ` (CURRENT PR)
11-
12+ - [x] ** PR #208 : Foundation - Schema & add_step()** - ` 09-10-feat_add_map_step_type_in_sql `
1213 - Schema changes (initial_tasks, remaining_tasks, constraints)
1314 - add_step() function with map step validation
1415 - Basic tests for map step creation
15-
16- - [ ] ** PR #209 : Root Map Support** - ` 09-11-root-map-support `
16+ - [x] ** PR #209 : Root Map Support** - ` 09-11-root-map-support ` (COMPLETED)
1717
1818 - Enhanced start_flow() for root map validation and count setting
1919 - Tests for root map scenarios
2020
21- - [ ] ** PR # 210 : Task Spawning** - ` 09-12-task-spawning `
21+ - [ ] ** Task Spawning**
2222
2323 - Enhanced start_ready_steps() for N task generation
2424 - Empty array auto-completion
2525 - Tests for batch task creation
2626
27- - [ ] ** PR # 211 : Array Element Extraction** - ` 09-13-array-extraction `
27+ - [ ] ** Array Element Extraction**
2828
2929 - Enhanced start_tasks() for map input extraction
3030 - Support for root and dependent maps
3131 - Tests for element extraction
3232
33- - [ ] ** PR # 212 : Dependent Map Support** - ` 09-14-dependent-map `
33+ - [ ] ** Dependent Map Support**
3434
3535 - Enhanced complete_task() for map dependency handling
3636 - Array validation and count propagation
3737 - Tests for dependency scenarios
3838
39- - [ ] ** PR # 213 : Output Aggregation** - ` 09-15-output-aggregation `
39+ - [ ] ** Output Aggregation**
4040
4141 - Enhanced maybe_complete_run() for array aggregation
4242 - Ordered output collection
4343 - Tests for aggregation
4444
45- - [ ] ** PR # 214 : Integration Tests** - ` 09-16-integration-tests `
45+ - [ ] ** Integration Tests**
4646 - End-to-end test suite
4747 - Edge case coverage
4848 - Performance validation
@@ -97,54 +97,9 @@ The implementation is split across multiple PRs as shown in the Sequential Child
9797
9898## Database Schema Changes
9999
100- ### Migration Strategy
101-
102- Using Atlas migrations with the established pkgs/core/scripts workflow:
103-
104- #### Initial Migration Generation
105-
106- ``` bash
107- # Navigate to pkgs/core directory
108- cd pkgs/core
109-
110- # First update schema files in pkgs/core/schemas/, then generate migration
111- ./scripts/atlas-migrate-diff add_map_step_type
112-
113- # Review generated migration file, then apply and verify
114- pnpm nx verify-migrations core
115- ```
116-
117- #### Regenerating Migration After Schema Updates
118-
119- ``` bash
120- # 1. Decide on migration name
121- migration_name=add_map_step_type
100+ For detailed schema development workflow, migration generation, and regeneration instructions, see:
122101
123- # 1. Remove the previous version of the migration file
124- git rm -f supabase/migrations/* _pgflow_${migration_name} .sql
125-
126- # 2. Reset the Atlas hash to allow regeneration
127- ./scripts/atlas-migrate-hash --yes
128-
129- # 3. reset database state to pre-migration
130- pnpm nx supabase:reset core
131-
132- # 4. Update schema files in pkgs/core/schemas/ as needed (or if already updated, skip this step)
133-
134- # 5. generate the migration with the same name
135- ./scripts/atlas-migrate-diff ${migration_name}
136-
137- # 6. verify the migration
138- pnpm nx verify-migrations core
139- ```
140-
141- ** Key Points:**
142-
143- - START WITH REMOVING PREVIOUS MIGRATION FILE BEFORE REGENERATING TO AVOID CONFLICTS !!!!
144- - Always use the same migration name (` add_map_step_type ` ) for the entire PR
145- - do not include ` pgflow_ ` prefix when genrating migration - it is included by atlas-migrate-diff automatically
146- - Reset Atlas hash before regeneration to allow the same name to be used
147- - This maintains a single, comprehensive migration per PR
102+ - ` .claude/schema_development.md ` - Concise workflow guide
148103
149104### Schema Updates (DONE)
150105
@@ -180,7 +135,7 @@ pnpm nx verify-migrations core
180135- Added validation for map steps (max 1 dependency)
181136- Function now stores step_type in database
182137
183- ### 2. ` start_flow() ` - Root Map Count Setting (TODO: PR # 209 )
138+ ### 2. ` start_flow() ` - Root Map Count Setting (CURRENT PR)
184139
185140** File** : ` pkgs/core/schemas/0100_function_start_flow.sql `
186141
@@ -191,7 +146,7 @@ pnpm nx verify-migrations core
191146- Set ` initial_tasks = jsonb_array_length(input) ` for root maps
192147- Fail with clear error if input is not array for root map
193148
194- ### 3. ` complete_task() ` - Dependent Map Count Setting (TODO: PR # 212 )
149+ ### 3. ` complete_task() ` - Dependent Map Count Setting (TODO)
195150
196151** File** : ` pkgs/core/schemas/0100_function_complete_task.sql `
197152
@@ -202,7 +157,7 @@ pnpm nx verify-migrations core
202157- For map→map: count completed tasks, set ` initial_tasks = task_count `
203158- Fail with clear error if dependency output is not array when needed
204159
205- ### 4. ` start_ready_steps() ` - Task Spawning (TODO: PR # 210 )
160+ ### 4. ` start_ready_steps() ` - Task Spawning (TODO)
206161
207162** File** : ` pkgs/core/schemas/0100_function_start_ready_steps.sql `
208163
@@ -218,7 +173,7 @@ pnpm nx verify-migrations core
218173- Transition directly ` created ` → ` completed ` for initial_tasks=0
219174- Send single ` step:completed ` event with ` output: [] `
220175
221- ### 5. ` start_tasks() ` - Array Element Extraction (TODO: PR # 211 )
176+ ### 5. ` start_tasks() ` - Array Element Extraction (TODO)
222177
223178** File** : ` pkgs/core/schemas/0120_function_start_tasks.sql `
224179
@@ -229,7 +184,7 @@ pnpm nx verify-migrations core
229184- Dependent maps: extract from aggregated dependency output
230185- Single steps: unchanged behavior (keep existing logic)
231186
232- ### 6. ` maybe_complete_run() ` - Output Aggregation (TODO: PR # 213 )
187+ ### 6. ` maybe_complete_run() ` - Output Aggregation (TODO)
233188
234189** File** : ` pkgs/core/schemas/0100_function_maybe_complete_run.sql `
235190
@@ -250,13 +205,26 @@ pnpm nx verify-migrations core
250205- map_dependency_limit.test.sql
251206- map_step_with_no_deps.test.sql
252207
253- ** PR #209 -214:** Each PR will include its own comprehensive test suite covering:
208+ ** PR #209 (CURRENT):**
209+
210+ - root_map_array_validation.test.sql
211+ - root_map_initial_tasks.test.sql
212+ - mixed_step_types.test.sql
213+ - multiple_root_maps.test.sql
214+ - null_input_validation.test.sql
215+ - large_array_handling.test.sql
216+ - nested_array_handling.test.sql
217+ - mixed_type_arrays.test.sql
218+ - invalid_json_types.test.sql
219+ - flow_only_maps.test.sql
220+
221+ ** Subsequent PRs:** Each will include its own comprehensive test suite covering:
254222
255223- Function-specific tests
256224- Edge cases and error handling
257225- Integration with existing functionality
258226
259- ** PR # 214 :** Final integration test suite covering end-to-end workflows
227+ ** Final PR :** Integration test suite covering end-to-end workflows
260228
261229## Edge Cases Handled
262230
0 commit comments