Gap found by the #94 capstone (lead-finder declarative pipeline, workers/api/src/lib/pipelines/lead-finder.test.ts, "GAP #1").
Problem. The lead-finder recipe sweeps a grid of cells and runs one Places searchNearby per cell. Expressed declaratively that is fan_out (grid) → http_request with forEach: {$ref:"grid.cells"}. But a forEach step whose per-item tool returns an ARRAY (a page of places) binds an array-of-arrays [[place,…],[place,…]]. Nothing in the current step library or $ref grammar flattens it: map treats each inner array as a non-record and emits one {} per CELL, not per place. So the grid source cannot feed map/filter/dedupe_upsert.
Evidence. map([[{place_id:a}],[{place_id:b},{place_id:c}]]) → count:2 (cells), not 3 (places). Asserted in the capstone test.
Consequence. The shipped reference JSON (lead-finder.json) falls back to a SINGLE searchNearby at the geocoded centre — it drops the grid, so it covers less area than the live worker.
Proposed fix (pick one):
- A first-party
flatten step ({items: $ref, depth?}) that concatenates an array-of-arrays — smallest, composes with everything.
- A
flatten:true option on map/filter that pre-concats array-of-array items.
- A
$ref array-projection grammar (grid.cells[].places) mirroring the responseMap arr[] grammar in connectors/http.ts.
Option 1 is the cleanest declarative primitive. Blocks the grid half of the epic proof.
Part of #94.
Gap found by the #94 capstone (lead-finder declarative pipeline,
workers/api/src/lib/pipelines/lead-finder.test.ts, "GAP #1").Problem. The lead-finder recipe sweeps a grid of cells and runs one Places
searchNearbyper cell. Expressed declaratively that isfan_out(grid) →http_requestwithforEach: {$ref:"grid.cells"}. But aforEachstep whose per-item tool returns an ARRAY (a page of places) binds an array-of-arrays[[place,…],[place,…]]. Nothing in the current step library or$refgrammar flattens it:maptreats each inner array as a non-record and emits one{}per CELL, not per place. So the grid source cannot feedmap/filter/dedupe_upsert.Evidence.
map([[{place_id:a}],[{place_id:b},{place_id:c}]])→count:2(cells), not3(places). Asserted in the capstone test.Consequence. The shipped reference JSON (
lead-finder.json) falls back to a SINGLEsearchNearbyat the geocoded centre — it drops the grid, so it covers less area than the live worker.Proposed fix (pick one):
flattenstep ({items: $ref, depth?}) that concatenates an array-of-arrays — smallest, composes with everything.flatten:trueoption onmap/filterthat pre-concats array-of-arrayitems.$refarray-projection grammar (grid.cells[].places) mirroring the responseMaparr[]grammar inconnectors/http.ts.Option 1 is the cleanest declarative primitive. Blocks the grid half of the epic proof.
Part of #94.